diff options
author | Reid Kleckner <rnk@google.com> | 2019-02-07 18:16:22 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-02-07 18:16:22 +0000 |
commit | f21c022380f52b5f2275ad5433fc291b2fee820c (patch) | |
tree | 109fc88ca542885208745b2cb3a7da79d16084ed | |
parent | c0f7569aab704435ba3517b9326b3f20432b1ae2 (diff) | |
download | bcm5719-llvm-f21c022380f52b5f2275ad5433fc291b2fee820c.tar.gz bcm5719-llvm-f21c022380f52b5f2275ad5433fc291b2fee820c.zip |
[InstrProf] Avoid reconstructing Triple, NFC
llvm-svn: 353439
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index ff4a8404292..295273b4dd7 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -678,7 +678,8 @@ static inline bool shouldRecordFunctionAddr(Function *F) { } static inline Comdat *getOrCreateProfileComdat(Module &M, Function &F, - InstrProfIncrementInst *Inc) { + InstrProfIncrementInst *Inc, + const Triple &TT) { if (!needsComdatForCounter(F, M)) return nullptr; @@ -686,23 +687,20 @@ static inline Comdat *getOrCreateProfileComdat(Module &M, Function &F, // name. The linker targeting COFF also requires that the COMDAT // a section is associated to must precede the associating section. For this // reason, we must choose the counter var's name as the name of the comdat. - StringRef ComdatPrefix = (Triple(M.getTargetTriple()).isOSBinFormatCOFF() - ? getInstrProfCountersVarPrefix() - : getInstrProfComdatPrefix()); + StringRef ComdatPrefix = + (TT.isOSBinFormatCOFF() ? getInstrProfCountersVarPrefix() + : getInstrProfComdatPrefix()); return M.getOrInsertComdat(StringRef(getVarName(Inc, ComdatPrefix))); } -static bool needsRuntimeRegistrationOfSectionRange(const Module &M) { +static bool needsRuntimeRegistrationOfSectionRange(const Triple &TT) { // Don't do this for Darwin. compiler-rt uses linker magic. - if (Triple(M.getTargetTriple()).isOSDarwin()) + if (TT.isOSDarwin()) return false; // Use linker script magic to get data/cnts/name start/end. - if (Triple(M.getTargetTriple()).isOSLinux() || - Triple(M.getTargetTriple()).isOSFreeBSD() || - Triple(M.getTargetTriple()).isOSNetBSD() || - Triple(M.getTargetTriple()).isOSFuchsia() || - Triple(M.getTargetTriple()).isPS4CPU()) + if (TT.isOSLinux() || TT.isOSFreeBSD() || TT.isOSNetBSD() || + TT.isOSFuchsia() || TT.isPS4CPU()) return false; return true; @@ -725,7 +723,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { // linking. Function *Fn = Inc->getParent()->getParent(); Comdat *ProfileVarsComdat = nullptr; - ProfileVarsComdat = getOrCreateProfileComdat(*M, *Fn, Inc); + ProfileVarsComdat = getOrCreateProfileComdat(*M, *Fn, Inc, TT); uint64_t NumCounters = Inc->getNumCounters()->getZExtValue(); LLVMContext &Ctx = M->getContext(); @@ -746,7 +744,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { // Allocate statically the array of pointers to value profile nodes for // the current function. Constant *ValuesPtrExpr = ConstantPointerNull::get(Int8PtrTy); - if (ValueProfileStaticAlloc && !needsRuntimeRegistrationOfSectionRange(*M)) { + if (ValueProfileStaticAlloc && !needsRuntimeRegistrationOfSectionRange(TT)) { uint64_t NS = 0; for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) NS += PD.NumValueSites[Kind]; @@ -819,7 +817,7 @@ void InstrProfiling::emitVNodes() { // For now only support this on platforms that do // not require runtime registration to discover // named section start/end. - if (needsRuntimeRegistrationOfSectionRange(*M)) + if (needsRuntimeRegistrationOfSectionRange(TT)) return; size_t TotalNS = 0; @@ -887,7 +885,7 @@ void InstrProfiling::emitNameData() { } void InstrProfiling::emitRegistration() { - if (!needsRuntimeRegistrationOfSectionRange(*M)) + if (!needsRuntimeRegistrationOfSectionRange(TT)) return; // Construct the function. @@ -928,7 +926,7 @@ void InstrProfiling::emitRegistration() { bool InstrProfiling::emitRuntimeHook() { // We expect the linker to be invoked with -u<hook_var> flag for linux, // for which case there is no need to emit the user function. - if (Triple(M->getTargetTriple()).isOSLinux()) + if (TT.isOSLinux()) return false; // If the module's provided its own runtime, we don't need to do anything. @@ -949,7 +947,7 @@ bool InstrProfiling::emitRuntimeHook() { if (Options.NoRedZone) User->addFnAttr(Attribute::NoRedZone); User->setVisibility(GlobalValue::HiddenVisibility); - if (Triple(M->getTargetTriple()).supportsCOMDAT()) + if (TT.supportsCOMDAT()) User->setComdat(M->getOrInsertComdat(User->getName())); IRBuilder<> IRB(BasicBlock::Create(M->getContext(), "", User)); |