[llvm] [CSSPGO] [Pseudo-Probe] Avoid infinite loop on cyclic invoke destinations (PR #221630)

Wei Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 21:13:50 PDT 2026


================
@@ -226,7 +227,9 @@ void SampleProfileProber::findInvokeNormalDests(
     auto *TI = BB.getTerminator();
     if (auto *II = dyn_cast<InvokeInst>(TI)) {
       auto *ND = II->getNormalDest();
-      InvokeNormalDests.insert(ND);
+      // instrument self-looping invoke in the original block
+      if (ND != &BB)
----------------
apolloww wrote:

Can this handle cycle with more than 2 blocks?

I guess if we have 
```cpp
try {
  for(;;) {
    f1();
    f2();
    }
  } catch(...) {}
```
It would become something like
```llvm
for.cond:
  invoke @f1() to label %invoke.cont unwind label %lpad
invoke.cont:
  invoke @f2() to label %for.cond   unwind label %lpad
```

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


More information about the llvm-commits mailing list