r204301 - PGO: use linker magic to find instrumentation data on Darwin
Duncan P. N. Exon Smith
dexonsmith at apple.com
Wed Mar 19 20:57:11 PDT 2014
Author: dexonsmith
Date: Wed Mar 19 22:57:11 2014
New Revision: 204301
URL: http://llvm.org/viewvc/llvm-project?rev=204301&view=rev
Log:
PGO: use linker magic to find instrumentation data on Darwin
<rdar://problem/15943240>
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=204301&r1=204300&r2=204301&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Wed Mar 19 22:57:11 2014
@@ -182,6 +182,10 @@ static llvm::Function *getRegisterFunc(C
}
static llvm::BasicBlock *getOrInsertRegisterBB(CodeGenModule &CGM) {
+ // Don't do this for Darwin. compiler-rt uses linker magic.
+ if (CGM.getTarget().getTriple().isOSDarwin())
+ return nullptr;
+
// Only need to insert this once per module.
if (llvm::Function *RegisterF = getRegisterFunc(CGM))
return &RegisterF->getEntryBlock();
@@ -286,9 +290,10 @@ void CodeGenPGO::emitInstrumentationData
auto *Data = buildDataVar();
// Register the data.
- //
- // TODO: only register when static initialization is required.
- CGBuilderTy Builder(getOrInsertRegisterBB(CGM)->getTerminator());
+ auto *RegisterBB = getOrInsertRegisterBB(CGM);
+ if (!RegisterBB)
+ return;
+ CGBuilderTy Builder(RegisterBB->getTerminator());
auto *VoidPtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
Builder.CreateCall(getOrInsertRuntimeRegister(CGM),
Builder.CreateBitCast(Data, VoidPtrTy));
More information about the cfe-commits
mailing list