summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-12-22 00:11:15 +0000
committerXinliang David Li <davidxl@google.com>2015-12-22 00:11:15 +0000
commit5fe0455563a1f15ca5dfdedebd7a4e5b4f4ee610 (patch)
treef7021aef1fc5cfb1f7bb64b972e19acd922f6e20 /llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
parentd763f19db33b91c2b0db8c71f219699eaea35139 (diff)
downloadbcm5719-llvm-5fe0455563a1f15ca5dfdedebd7a4e5b4f4ee610.tar.gz
bcm5719-llvm-5fe0455563a1f15ca5dfdedebd7a4e5b4f4ee610.zip
[PGO] Fix another comdat related issue for COFF
The linker requires that a comdat section must be associated with a another comdat section that precedes it. This means the comdat section's name needs to use the profile name var's name. Patch tested by Johan Engelen. llvm-svn: 256220
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 0c0b54fe689..92e41ee27c0 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -282,9 +282,11 @@ static inline bool shouldRecordFunctionAddr(Function *F) {
static inline Comdat *getOrCreateProfileComdat(Module &M,
InstrProfIncrementInst *Inc) {
// COFF format requires a COMDAT section to have a key symbol with the same
- // name.
+ // name. The linker targeting COFF also requires that the COMDAT section
+ // a section is associated to must precede the associating section. For this
+ // reason, we must choose the name var's name as the name of the comdat.
StringRef ComdatPrefix = (Triple(M.getTargetTriple()).isOSBinFormatCOFF()
- ? getInstrProfDataVarPrefix()
+ ? getInstrProfNameVarPrefix()
: getInstrProfComdatPrefix());
return M.getOrInsertComdat(StringRef(getVarName(Inc, ComdatPrefix)));
}
OpenPOWER on IntegriCloud