diff options
author | Diego Novillo <dnovillo@google.com> | 2015-05-27 19:34:01 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2015-05-27 19:34:01 +0000 |
commit | df4837ba6ba113369bdca69e5351017caebc3d6c (patch) | |
tree | c841478b96696f45da4a5e47e9f65f147235f68c /llvm/lib/Transforms | |
parent | 583bc03829fb39435db56bb4bc8d4049c19a167a (diff) | |
download | bcm5719-llvm-df4837ba6ba113369bdca69e5351017caebc3d6c.tar.gz bcm5719-llvm-df4837ba6ba113369bdca69e5351017caebc3d6c.zip |
Final fix for PR 23499 and IR test case.
This fixes a bit I forgot in r238335. In addition to the data record and
the counter, we can also move the name of the counter to the comdat for
the associated function.
I'm also adding an IR test case to check that these three elements are
placed in the proper comdat.
llvm-svn: 238351
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index 610ff52ba9d..81899688eab 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -196,14 +196,17 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { if (It != RegionCounters.end()) return It->second; - // Move the name variable to the right section. + // Move the name variable to the right section. Make sure it is placed in the + // same comdat as its associated function. Otherwise, we may get multiple + // counters for the same function in certain cases. + Function *Fn = Inc->getParent()->getParent(); Name->setSection(getNameSection()); Name->setAlignment(1); + Name->setComdat(Fn->getComdat()); uint64_t NumCounters = Inc->getNumCounters()->getZExtValue(); LLVMContext &Ctx = M->getContext(); ArrayType *CounterTy = ArrayType::get(Type::getInt64Ty(Ctx), NumCounters); - Function *Fn = Inc->getParent()->getParent(); // Create the counters variable. auto *Counters = new GlobalVariable(*M, CounterTy, false, Name->getLinkage(), @@ -212,9 +215,6 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) { Counters->setVisibility(Name->getVisibility()); Counters->setSection(getCountersSection()); Counters->setAlignment(8); - // Place the counters in the same comdat section as its parent function. - // Otherwise, we may get multiple counters for the same function in certain - // cases. Counters->setComdat(Fn->getComdat()); RegionCounters[Inc->getName()] = Counters; |