Skip to content

Commit ee5709b

Browse files
authored
[nfc][ctx_prof] Don't try finding callsite annotation for un-instrumentable callsites (#109184)
Reinforcing properties ensured at instrumentation time.
1 parent ce9209f commit ee5709b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

llvm/lib/Analysis/CtxProfAnalysis.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,23 @@ PreservedAnalyses CtxProfAnalysisPrinterPass::run(Module &M,
234234
}
235235

236236
InstrProfCallsite *CtxProfAnalysis::getCallsiteInstrumentation(CallBase &CB) {
237-
for (auto *Prev = CB.getPrevNode(); Prev; Prev = Prev->getPrevNode())
237+
if (!InstrProfCallsite::canInstrumentCallsite(CB))
238+
return nullptr;
239+
for (auto *Prev = CB.getPrevNode(); Prev; Prev = Prev->getPrevNode()) {
238240
if (auto *IPC = dyn_cast<InstrProfCallsite>(Prev))
239241
return IPC;
242+
assert(!isa<CallBase>(Prev) &&
243+
"didn't expect to find another call, that's not the callsite "
244+
"instrumentation, before an instrumentable callsite");
245+
}
240246
return nullptr;
241247
}
242248

243249
InstrProfIncrementInst *CtxProfAnalysis::getBBInstrumentation(BasicBlock &BB) {
244250
for (auto &I : BB)
245251
if (auto *Incr = dyn_cast<InstrProfIncrementInst>(&I))
246-
return Incr;
252+
if (!isa<InstrProfIncrementInstStep>(&I))
253+
return Incr;
247254
return nullptr;
248255
}
249256

0 commit comments

Comments
 (0)