Skip to content

Conversation

mtrofin
Copy link
Member

@mtrofin mtrofin commented Sep 18, 2024

Reinforcing properties ensured at instrumentation time.

@mtrofin mtrofin changed the title [ctx_prof] Don't try finding callsite annotation for un-instrumentable callsites [nfc][ctx_prof] Don't try finding callsite annotation for un-instrumentable callsites Sep 18, 2024
@mtrofin mtrofin marked this pull request as ready for review September 18, 2024 19:58
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Sep 18, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Mircea Trofin (mtrofin)

Changes

Reinforcing properties ensured at instrumentation time.


Full diff: https://github.com/llvm/llvm-project/pull/109184.diff

1 Files Affected:

  • (modified) llvm/lib/Analysis/CtxProfAnalysis.cpp (+9-2)
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;
 }
 

@mtrofin mtrofin force-pushed the users/mtrofin/09-17-_ctx_prof_fix_profileannotator_alltakenpathsexit_ branch from 6d23eef to 1c6e49a Compare September 18, 2024 21:26
@mtrofin mtrofin force-pushed the users/mtrofin/09-17-_ctx_prof_don_t_try_finding_callsite_annotation_for_un-instrumentable_callsites branch from 987562a to 152a2a9 Compare September 18, 2024 21:26
@mtrofin mtrofin force-pushed the users/mtrofin/09-17-_ctx_prof_fix_profileannotator_alltakenpathsexit_ branch from 1c6e49a to bbb3ba0 Compare September 19, 2024 02:48
@mtrofin mtrofin force-pushed the users/mtrofin/09-17-_ctx_prof_don_t_try_finding_callsite_annotation_for_un-instrumentable_callsites branch from 152a2a9 to f654c77 Compare September 19, 2024 02:48
Copy link
Member Author

mtrofin commented Sep 19, 2024

Base automatically changed from users/mtrofin/09-17-_ctx_prof_fix_profileannotator_alltakenpathsexit_ to main September 19, 2024 04:08
@mtrofin mtrofin force-pushed the users/mtrofin/09-17-_ctx_prof_don_t_try_finding_callsite_annotation_for_un-instrumentable_callsites branch from f654c77 to 241afaa Compare September 19, 2024 04:10
@mtrofin mtrofin merged commit ee5709b into main Sep 19, 2024
5 of 7 checks passed
Copy link
Member Author

mtrofin commented Sep 19, 2024

Merge activity

@mtrofin mtrofin deleted the users/mtrofin/09-17-_ctx_prof_don_t_try_finding_callsite_annotation_for_un-instrumentable_callsites branch September 19, 2024 04:13
tmsri pushed a commit to tmsri/llvm-project that referenced this pull request Sep 19, 2024
…ntable callsites (llvm#109184)

Reinforcing properties ensured at instrumentation time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:analysis Includes value tracking, cost tables and constant folding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants