[llvm] [IfConversion] Fix bug related to !HasFallThrough (PR #145471)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 24 01:58:37 PDT 2025


================
@@ -21,16 +21,18 @@ name:            foo
 body:             |
   ; CHECK-LABEL: name: foo
   ; CHECK: bb.0:
-  ; CHECK:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
-  ; CHECK:   tBcc %bb.2, 1 /* CC::ne */, $cpsr
-  ; CHECK: bb.1:
-  ; CHECK:   successors:
-  ; CHECK:   tBL 14 /* CC::al */, $cpsr, @__stack_chk_fail
-  ; CHECK: bb.2:
-  ; CHECK:   tBL 1 /* CC::ne */, $cpsr, @__stack_chk_fail
-  ; CHECK:   $sp = tADDspi $sp, 2, 14 /* CC::al */, $noreg
-  ; CHECK:   $sp = tADDspi $sp, 2, 14 /* CC::al */, $noreg
-  ; CHECK:   tTAILJMPdND @bar, 14 /* CC::al */, $cpsr
+  ; CHECK-NEXT:   successors: %bb.1(0x40000000), %bb.2(0x40000000)
----------------
bjope wrote:

I took another look at this. And I'll make an update to also check for empty successor list in `blockNeverFallThrough`, which would imply that there is no fallthrough. That way we can let IfConversion merge the blocks (just like it used to do here), and avoid the lit test diff.
Given that BlockFolding (called by IfConversion in the end) did a similar cleanup it did not matter much for this specific test case, but maybe there could be potential regressions in similar situations with no-successor blocks. So it is probably better to handle that as well.

(I had some doubts earlier about inspecting the successor lists in `blockNeverFallThrough`, but I actually had missed the check for empty successor lists in my earlier experiments. Now it makes more sense.)

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


More information about the llvm-commits mailing list