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();
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);