[InstrProf] Mark counters as used in debug correlation mode

In debug info correlation mode we do not emit the data globals so we
need to explicitly mark the counter globals as used so they don't get
stripped.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D115981
This commit is contained in:
Ellis Hoag 2021-12-30 14:49:50 -08:00
parent 59442a5460
commit a699b2f1c0
1 changed files with 4 additions and 1 deletions

View File

@ -997,8 +997,11 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfIncrementInst *Inc) {
ConstantExpr::getBitCast(ValuesVar, Type::getInt8PtrTy(Ctx));
}
if (DebugInfoCorrelate)
if (DebugInfoCorrelate) {
// Mark the counter variable as used so that it isn't optimized out.
CompilerUsedVars.push_back(PD.RegionCounters);
return PD.RegionCounters;
}
// Create data variable.
auto *IntPtrTy = M->getDataLayout().getIntPtrType(M->getContext());