File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -405,7 +405,11 @@ bool swift::isCriticalEdge(TermInst *T, unsigned EdgeIdx) {
405
405
assert (T->getSuccessors ().size () > EdgeIdx && " Not enough successors" );
406
406
407
407
auto SrcSuccs = T->getSuccessors ();
408
- if (SrcSuccs.size () <= 1 )
408
+
409
+ if (SrcSuccs.size () <= 1 &&
410
+ // Also consider non-branch instructions with a single successor for
411
+ // critical edges, for example: a switch_enum of a single-case enum.
412
+ (isa<BranchInst>(T) || isa<CondBranchInst>(T)))
409
413
return false ;
410
414
411
415
SILBasicBlock *DestBB = SrcSuccs[EdgeIdx];
Original file line number Diff line number Diff line change @@ -1684,6 +1684,32 @@ exit:
1684
1684
return %9999 : $()
1685
1685
}
1686
1686
1687
+ // CHECK-LABEL: sil @dont_crash_jump_threading_single_case_switch_enums
1688
+ // CHECK-NOT: switch_enum
1689
+ // CHECK: } // end sil function
1690
+ sil @dont_crash_jump_threading_single_case_switch_enums : $@convention(thin) () -> () {
1691
+ bb0:
1692
+ br bb1(undef : $OneCase)
1693
+
1694
+ bb1(%19 : $OneCase):
1695
+ switch_enum %19 : $OneCase, case #OneCase.First!enumelt.1: bb2
1696
+
1697
+ bb2:
1698
+ switch_enum %19 : $OneCase, case #OneCase.First!enumelt.1: bb3
1699
+
1700
+ bb3:
1701
+ %48 = enum $OneCase, #OneCase.First!enumelt.1
1702
+ cond_br undef, bb6, bb7
1703
+
1704
+ bb6:
1705
+ %72 = tuple ()
1706
+ return %72 : $()
1707
+
1708
+ bb7:
1709
+ br bb1(%48 : $OneCase)
1710
+ }
1711
+
1712
+
1687
1713
enum IntEnum : Int32 {
1688
1714
case E0
1689
1715
case E1
You can’t perform that action at this time.
0 commit comments