Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
Show First 20 Lines • Show All 823 Lines • ▼ Show 20 Lines | if (TT.isOSBinFormatCOFF()) { | ||||
// comdats. We can't use a group because the Visual C++ linker will | // comdats. We can't use a group because the Visual C++ linker will | ||||
// report duplicate symbol errors if there are multiple external symbols | // report duplicate symbol errors if there are multiple external symbols | ||||
// with the same name marked IMAGE_COMDAT_SELECT_ASSOCIATIVE. | // with the same name marked IMAGE_COMDAT_SELECT_ASSOCIATIVE. | ||||
Linkage = GlobalValue::LinkOnceODRLinkage; | Linkage = GlobalValue::LinkOnceODRLinkage; | ||||
Visibility = GlobalValue::HiddenVisibility; | Visibility = GlobalValue::HiddenVisibility; | ||||
} | } | ||||
} | } | ||||
std::string DataVarName = getVarName(Inc, getInstrProfDataVarPrefix()); | std::string DataVarName = getVarName(Inc, getInstrProfDataVarPrefix()); | ||||
auto MaybeSetComdat = [=](GlobalVariable *GV) { | auto MaybeSetComdat = [=](GlobalVariable *GV) { | ||||
if (NeedComdat) | // For ELF, when not using COMDAT, put counters, data and values into | ||||
davidxl: maybe this:
bool UseSectGroup = (NeedComdat || TT.isOSBinFormatELF());
if (UseSectGroup) {… | |||||
GV->setComdat(M->getOrInsertComdat(TT.isOSBinFormatCOFF() ? GV->getName() | // a noduplicates COMDAT which is lowered to a zero-flag section group. | ||||
: DataVarName)); | // This allows linker GC to discard the entire group when the function | ||||
// is discarded. | |||||
bool UseComdat = (NeedComdat || TT.isOSBinFormatELF()); | |||||
if (UseComdat) { | |||||
auto GroupName = TT.isOSBinFormatCOFF() ? GV->getName() : DataVarName; | |||||
Comdat *C = M->getOrInsertComdat(GroupName); | |||||
if (!NeedComdat) | |||||
C->setSelectionKind(Comdat::NoDuplicates); | |||||
GV->setComdat(C); | |||||
} | |||||
}; | }; | ||||
uint64_t NumCounters = Inc->getNumCounters()->getZExtValue(); | uint64_t NumCounters = Inc->getNumCounters()->getZExtValue(); | ||||
LLVMContext &Ctx = M->getContext(); | LLVMContext &Ctx = M->getContext(); | ||||
ArrayType *CounterTy = ArrayType::get(Type::getInt64Ty(Ctx), NumCounters); | ArrayType *CounterTy = ArrayType::get(Type::getInt64Ty(Ctx), NumCounters); | ||||
// Create the counters variable. | // Create the counters variable. | ||||
auto *CounterPtr = | auto *CounterPtr = | ||||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |
maybe this:
bool UseSectGroup = (NeedComdat || TT.isOSBinFormatELF());
if (UseSectGroup) {
}