[llvm-branch-commits] [llvm] [nfc][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 14:27:03 PDT 2024
https://github.com/mtrofin updated https://github.com/llvm/llvm-project/pull/109184
>From 152a2a965e4c500f207b960293578c3715ffd903 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