[llvm] ee5709b - [nfc][ctx_prof] Don't try finding callsite annotation for un-instrumentable callsites (#109184)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 21:13:52 PDT 2024


Author: Mircea Trofin
Date: 2024-09-18T21:13:48-07:00
New Revision: ee5709b3b4bfd6e8e7fed8195e14e78ef10c9d74

URL: https://github.com/llvm/llvm-project/commit/ee5709b3b4bfd6e8e7fed8195e14e78ef10c9d74
DIFF: https://github.com/llvm/llvm-project/commit/ee5709b3b4bfd6e8e7fed8195e14e78ef10c9d74.diff

LOG: [nfc][ctx_prof] Don't try finding callsite annotation for un-instrumentable callsites (#109184)

Reinforcing properties ensured at instrumentation time.

Added: 
    

Modified: 
    llvm/lib/Analysis/CtxProfAnalysis.cpp

Removed: 
    


################################################################################
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-commits mailing list