diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-20 19:23:46 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-20 19:23:46 +0000 |
| commit | 5188e91cd4c7463029654119860e972541e8dd42 (patch) | |
| tree | 8eb00ff8f621958be03de37de4b0ae970f703f0b /clang/lib/CodeGen/CodeGenPGO.cpp | |
| parent | 47f2be8847121e4e078e9f9a117566c17481c8cf (diff) | |
| download | bcm5719-llvm-5188e91cd4c7463029654119860e972541e8dd42.tar.gz bcm5719-llvm-5188e91cd4c7463029654119860e972541e8dd42.zip | |
PGO: Remove explicit static initialization
Remove the remaining explicit static initialization from translation
units, at least on Darwin. Instead, create a use of __llvm_pgo_runtime,
which will pull in required code from compiler-rt.
After this commit (and its pair in compiler-rt), a user can define their
own __llvm_pgo_runtime to satisfy this undefined symbol and call the
functions in compiler-rt directly.
<rdar://problem/15943240>
llvm-svn: 204379
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 20305c3567e..96409fef64b 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -198,7 +198,6 @@ static llvm::BasicBlock *getOrInsertRegisterBB(CodeGenModule &CGM) { "__llvm_pgo_register_functions", &CGM.getModule()); RegisterF->setUnnamedAddr(true); - RegisterF->addFnAttr(llvm::Attribute::NoInline); if (CGM.getCodeGenOpts().DisableRedZone) RegisterF->addFnAttr(llvm::Attribute::NoRedZone); @@ -217,14 +216,6 @@ static llvm::Constant *getOrInsertRuntimeRegister(CodeGenModule &CGM) { RuntimeRegisterTy); } -static llvm::Constant *getOrInsertRuntimeWriteAtExit(CodeGenModule &CGM) { - // TODO: make this depend on a command-line option. - auto *VoidTy = llvm::Type::getVoidTy(CGM.getLLVMContext()); - auto *WriteAtExitTy = llvm::FunctionType::get(VoidTy, false); - return CGM.getModule().getOrInsertFunction("__llvm_pgo_register_write_atexit", - WriteAtExitTy); -} - static bool isMachO(const CodeGenModule &CGM) { return CGM.getTarget().getTriple().isOSBinFormatMachO(); } @@ -307,10 +298,9 @@ llvm::Function *CodeGenPGO::emitInitialization(CodeGenModule &CGM) { if (CGM.getModule().getFunction("__llvm_pgo_init")) return nullptr; - // Get the functions to call at initialization. + // Get the function to call at initialization. llvm::Constant *RegisterF = getRegisterFunc(CGM); - llvm::Constant *WriteAtExitF = getOrInsertRuntimeWriteAtExit(CGM); - if (!RegisterF && !WriteAtExitF) + if (!RegisterF) return nullptr; // Create the initialization function. @@ -325,10 +315,7 @@ llvm::Function *CodeGenPGO::emitInitialization(CodeGenModule &CGM) { // Add the basic block and the necessary calls. CGBuilderTy Builder(llvm::BasicBlock::Create(CGM.getLLVMContext(), "", F)); - if (RegisterF) - Builder.CreateCall(RegisterF); - if (WriteAtExitF) - Builder.CreateCall(WriteAtExitF); + Builder.CreateCall(RegisterF); Builder.CreateRetVoid(); return F; |

