aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-12-21 21:52:27 +0000
committerXinliang David Li <davidxl@google.com>2015-12-21 21:52:27 +0000
commitab361efee7c5641cd214cf64d0f3ef3c48ba21b8 (patch)
treebf84204bc1af2592519456123a705688979a02e4 /llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
parent88dddf9198962c67c3f2e3f0b5ed607b59f0b246 (diff)
downloadllvm-ab361efee7c5641cd214cf64d0f3ef3c48ba21b8.zip
llvm-ab361efee7c5641cd214cf64d0f3ef3c48ba21b8.tar.gz
llvm-ab361efee7c5641cd214cf64d0f3ef3c48ba21b8.tar.bz2
Resubmit r256193 with test fix: assertion failure analyzed
llvm-svn: 256201
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 57ed2f7..0c0b54f 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -279,6 +279,16 @@ static inline bool shouldRecordFunctionAddr(Function *F) {
return F->hasAddressTaken();
}
+static inline Comdat *getOrCreateProfileComdat(Module &M,
+ InstrProfIncrementInst *Inc) {
+ // COFF format requires a COMDAT section to have a key symbol with the same
+ // name.
+ StringRef ComdatPrefix = (Triple(M.getTargetTriple()).isOSBinFormatCOFF()
+ ? getInstrProfDataVarPrefix()
+ : getInstrProfComdatPrefix());
+ return M.getOrInsertComdat(StringRef(getVarName(Inc, ComdatPrefix)));
+}
+
GlobalVariable *
InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
GlobalVariable *NamePtr = Inc->getName();
@@ -297,8 +307,7 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
Function *Fn = Inc->getParent()->getParent();
Comdat *ProfileVarsComdat = nullptr;
if (Fn->hasComdat())
- ProfileVarsComdat = M->getOrInsertComdat(
- StringRef(getVarName(Inc, getInstrProfComdatPrefix())));
+ ProfileVarsComdat = getOrCreateProfileComdat(*M, Inc);
NamePtr->setSection(getNameSection());
NamePtr->setAlignment(1);
NamePtr->setComdat(ProfileVarsComdat);