diff options
author | Xinliang David Li <davidxl@google.com> | 2016-07-21 23:19:10 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2016-07-21 23:19:10 +0000 |
commit | 6f8c504f10e738f5cf73cb4575c81598598dc002 (patch) | |
tree | 2d7d80624cabbbac6365dc7895b4cc3085dba334 /llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | |
parent | 8765dbcb7899b4687fbe5af2880ec2d6308f1366 (diff) | |
download | llvm-6f8c504f10e738f5cf73cb4575c81598598dc002.zip llvm-6f8c504f10e738f5cf73cb4575c81598598dc002.tar.gz llvm-6f8c504f10e738f5cf73cb4575c81598598dc002.tar.bz2 |
[Profile] deprecate __llvm_profile_override_default_filename
This eliminates unncessary calls and init functions.
Differential Revision: http://reviews.llvm.org/D22613
llvm-svn: 276354
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index 1b60b19..2b3d1cc 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -575,8 +575,23 @@ void InstrProfiling::emitUses() { void InstrProfiling::emitInitialization() { StringRef InstrProfileOutput = Options.InstrProfileOutput; + if (!InstrProfileOutput.empty()) { + // Create variable for profile name. + Constant *ProfileNameConst = + ConstantDataArray::getString(M->getContext(), InstrProfileOutput, true); + GlobalVariable *ProfileNameVar = new GlobalVariable( + *M, ProfileNameConst->getType(), true, GlobalValue::WeakAnyLinkage, + ProfileNameConst, INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR)); + Triple TT(M->getTargetTriple()); + if (TT.supportsCOMDAT()) { + ProfileNameVar->setLinkage(GlobalValue::ExternalLinkage); + ProfileNameVar->setComdat(M->getOrInsertComdat( + StringRef(INSTR_PROF_QUOTE(INSTR_PROF_PROFILE_NAME_VAR)))); + } + } + Constant *RegisterF = M->getFunction(getInstrProfRegFuncsName()); - if (!RegisterF && InstrProfileOutput.empty()) + if (!RegisterF) return; // Create the initialization function. @@ -593,21 +608,6 @@ void InstrProfiling::emitInitialization() { IRBuilder<> IRB(BasicBlock::Create(M->getContext(), "", F)); if (RegisterF) IRB.CreateCall(RegisterF, {}); - if (!InstrProfileOutput.empty()) { - auto *Int8PtrTy = Type::getInt8PtrTy(M->getContext()); - auto *SetNameTy = FunctionType::get(VoidTy, Int8PtrTy, false); - auto *SetNameF = Function::Create(SetNameTy, GlobalValue::ExternalLinkage, - getInstrProfFileOverriderFuncName(), M); - - // Create variable for profile name. - Constant *ProfileNameConst = - ConstantDataArray::getString(M->getContext(), InstrProfileOutput, true); - GlobalVariable *ProfileName = - new GlobalVariable(*M, ProfileNameConst->getType(), true, - GlobalValue::PrivateLinkage, ProfileNameConst); - - IRB.CreateCall(SetNameF, IRB.CreatePointerCast(ProfileName, Int8PtrTy)); - } IRB.CreateRetVoid(); appendToGlobalCtors(*M, F, 0); |