[llvm] [ShrinkWrap] Modify shrink wrapping to accommodate functions terminated by no-return blocks (PR #167548)

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 23 23:54:53 PST 2025


================
@@ -697,14 +697,12 @@ void ShrinkWrapImpl::updateSaveRestorePoints(MachineBasicBlock &MBB,
 
   if (!Restore)
     Restore = &MBB;
-  else if (MPDT->getNode(&MBB)) // If the block is not in the post dom tree, it
-                                // means the block never returns. If that's the
-                                // case, we don't want to call
-                                // `findNearestCommonDominator`, which will
-                                // return `Restore`.
+  else if (MBB.isNoReturnBlock()) {
+    // MBB exits the function without returning, so we don't need an epilogue
+    // here. This is common for things like cleanup landing pads etc. In these
+    // cases, we can skip updating `Restore`.
+  } else
     Restore = MPDT->findNearestCommonDominator(Restore, &MBB);
----------------
sushgokh wrote:

is not this `isNoReturnBlock()` check applicable to entire If()Else() structure ?  Also, I dont understand why are you altering the existing condition i.e what if you dont find common post dom ?

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


More information about the llvm-commits mailing list