[llvm] [LoopVersioningLICM] Do not let llvm.pseudoprobe block loop versioning (PR #209684)

chandan singh via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 07:18:15 PDT 2026


================
@@ -303,6 +305,15 @@ bool LoopVersioningLICM::instructionSafeForVersioning(Instruction *I) {
   assert(I != nullptr && "Null instruction found!");
   // Check function call safety
   if (auto *Call = dyn_cast<CallBase>(I)) {
+    // Pseudo probe intrinsics are placeholders used for sample-based profiling.
+    // They are marked as accessing inaccessible memory so that the optimizer
+    // does not remove or move them, but they have no observable effect on the
+    // loop's memory accesses. Ignore them so that their presence under
+    // sample-based profiling (in the presence of -fpseudo-probe-for-profiling)
+    // does not block loop versioning.
+    if (isa<PseudoProbeInst>(Call))
----------------
chandankds wrote:

Thanks for the suggestions! I switched to onlyAccessesInaccessibleMemory() instead of special-casing the intrinsic, and also added the missing willReturn() check in this patch.

https://github.com/llvm/llvm-project/pull/209684


More information about the llvm-commits mailing list