summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-03-20 21:13:59 +0000
committerBill Wendling <isanbard@gmail.com>2013-03-20 21:13:59 +0000
commitc77e9440cf1f9100e6c61624501186f37582b1a8 (patch)
treeb0f4ea979faf7e33dec0ae808321d3927d6df7a8 /llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
parent51a6ff57995ee07378b7a87c45e61d48c8363731 (diff)
downloadbcm5719-llvm-c77e9440cf1f9100e6c61624501186f37582b1a8.tar.gz
bcm5719-llvm-c77e9440cf1f9100e6c61624501186f37582b1a8.zip
Call the new llvm_gcov_init function to register the environment.
Use the new `llvm_gcov_init' function to register the writeout and flush functions. The initialization function will also call `atexit' for some cleanups and final writout calls. But it does this only once. This is better than checking for the `main' function, because in a library that function may not exist. <rdar://problem/12439551> llvm-svn: 177579
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp39
1 files changed, 10 insertions, 29 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 093984cac69..3310ed5e2b0 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -566,35 +566,16 @@ bool GCOVProfiler::emitProfileArcs() {
IRBuilder<> Builder(BB);
FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
- FTy = FunctionType::get(Builder.getVoidTy(),
- PointerType::get(FTy, 0), false);
-
- // Register the local writeout function.
- Constant *RegWriteout =
- M->getOrInsertFunction("llvm_register_writeout_function", FTy);
- Builder.CreateCall(RegWriteout, WriteoutF);
-
- // Register the local flush function.
- Constant *RegFlush =
- M->getOrInsertFunction("llvm_register_flush_function", FTy);
- Builder.CreateCall(RegFlush, FlushF);
-
- if (M->getFunction("main")) {
- Constant *AtExitFn = M->getOrInsertFunction("atexit", FTy);
-
- // In the module that has the 'main' function, make sure that the flush
- // and writeout function lists are deleted. Also make sure that the
- // writeout function list is deleted.
- Builder.CreateCall(AtExitFn, getDeleteWriteoutFunctionListFunc());
- Builder.CreateCall(AtExitFn, getDeleteFlushFunctionListFunc());
-
- // Make sure we write out all files when exiting. Note: This is called
- // first from atexit().
- FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
- Builder.CreateCall(AtExitFn,
- M->getOrInsertFunction("__llvm_writeout_files", FTy));
- }
-
+ Type *Params[] = {
+ PointerType::get(FTy, 0),
+ PointerType::get(FTy, 0)
+ };
+ FTy = FunctionType::get(Builder.getVoidTy(), Params, false);
+
+ // Inialize the environment and register the local writeout and flush
+ // functions.
+ Constant *GCOVInit = M->getOrInsertFunction("llvm_gcov_init", FTy);
+ Builder.CreateCall2(GCOVInit, WriteoutF, FlushF);
Builder.CreateRetVoid();
appendToGlobalCtors(*M, F, 0);
OpenPOWER on IntegriCloud