[llvm] [SimplifyCFG] Don't delete basic block if it is a partial cleanuppad (PR #157363)

Gábor Spaits via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 7 13:57:52 PDT 2025


================
@@ -8340,8 +8340,9 @@ bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) {
 
   // Remove basic blocks that have no predecessors (except the entry block)...
   // or that just have themself as a predecessor.  These are unreachable.
-  if ((pred_empty(BB) && BB != &BB->getParent()->getEntryBlock()) ||
-      BB->getSinglePredecessor() == BB) {
+  if (((pred_empty(BB) && BB != &BB->getParent()->getEntryBlock()) ||
+       BB->getSinglePredecessor() == BB) &&
+      (!BB->isEHPad() || BB->isEHPadWithReturn())) {
----------------
spaits wrote:

Should we do the same with `catchret` and `catchret` or `landingpad` and `resume`?

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


More information about the llvm-commits mailing list