[llvm-branch-commits] [llvm] [ctx_prof] Don't try finding callsite annotation for un-instrumentable callsites (PR #109184)
Mircea Trofin via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Sep 18 12:49:15 PDT 2024
https://github.com/mtrofin created https://github.com/llvm/llvm-project/pull/109184
None
>From 987562aab1c409b62b1a4c5d6d8566ad812b8313 Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Tue, 17 Sep 2024 22:03:30 -0700
Subject: [PATCH] [ctx_prof] Don't try finding callsite annotation for
un-instrumentable callsites
---
llvm/lib/Analysis/CtxProfAnalysis.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Analysis/CtxProfAnalysis.cpp b/llvm/lib/Analysis/CtxProfAnalysis.cpp
index c29709b613410e..3df72983862d98 100644
--- a/llvm/lib/Analysis/CtxProfAnalysis.cpp
+++ b/llvm/lib/Analysis/CtxProfAnalysis.cpp
@@ -234,16 +234,23 @@ PreservedAnalyses CtxProfAnalysisPrinterPass::run(Module &M,
}
InstrProfCallsite *CtxProfAnalysis::getCallsiteInstrumentation(CallBase &CB) {
- for (auto *Prev = CB.getPrevNode(); Prev; Prev = Prev->getPrevNode())
+ if (!InstrProfCallsite::canInstrumentCallsite(CB))
+ return nullptr;
+ for (auto *Prev = CB.getPrevNode(); Prev; Prev = Prev->getPrevNode()) {
if (auto *IPC = dyn_cast<InstrProfCallsite>(Prev))
return IPC;
+ assert(!isa<CallBase>(Prev) &&
+ "didn't expect to find another call, that's not the callsite "
+ "instrumentation, before an instrumentable callsite");
+ }
return nullptr;
}
InstrProfIncrementInst *CtxProfAnalysis::getBBInstrumentation(BasicBlock &BB) {
for (auto &I : BB)
if (auto *Incr = dyn_cast<InstrProfIncrementInst>(&I))
- return Incr;
+ if (!isa<InstrProfIncrementInstStep>(&I))
+ return Incr;
return nullptr;
}
More information about the llvm-branch-commits
mailing list