Skip to content

Commit

Permalink
[InstrProf] Mark counters as used in debug correlation mode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ellishg committed Dec 30, 2021
1 parent 59442a5 commit a699b2f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a699b2f

Please sign in to comment.