File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -1632,6 +1632,12 @@ ConstantFolder::processWorkList() {
1632
1632
// instructions.
1633
1633
auto UserV = cast<SingleValueInstruction>(User);
1634
1634
1635
+ // Handle a corner case: if this instruction is an unreachable CFG loop
1636
+ // there is no defined dominance order and we can end up with loops in the
1637
+ // use-def chain. Just bail in this case.
1638
+ if (C == UserV)
1639
+ continue ;
1640
+
1635
1641
// Ok, we have succeeded. Add user to the FoldedUsers list and perform the
1636
1642
// necessary cleanups, RAUWs, etc.
1637
1643
FoldedUsers.insert (User);
Original file line number Diff line number Diff line change @@ -3047,3 +3047,51 @@ bb3(%res : $Builtin.Int32):
3047
3047
release_value %pa : $@callee_guaranteed (Builtin.Int32) -> (Builtin.Int32)
3048
3048
return %res : $Builtin.Int32
3049
3049
}
3050
+
3051
+ struct TestStr {
3052
+ let a: Int32
3053
+ let c: Int32
3054
+ }
3055
+
3056
+ enum TestEnm {
3057
+ case X
3058
+ case Y(TestStr)
3059
+ }
3060
+
3061
+ // CHECK-LABEL: sil @dont_crash
3062
+ // CHECK: bb0(%0 : $TestEnm, %1 : $Int32):
3063
+ // CHECK-NEXT: %2 = tuple ()
3064
+ // CHECK-NEXT: return %2 : $()
3065
+ sil @dont_crash : $@convention(method) (TestEnm, Int32) -> () {
3066
+ bb0(%2 : $TestEnm, %3 : $Int32):
3067
+ %98 = integer_literal $Builtin.Int1, -1
3068
+ cond_br %98, bb2, bb3
3069
+
3070
+ bb2:
3071
+ %18 = tuple()
3072
+ return %18 : $()
3073
+
3074
+ bb3:
3075
+ br bb8(%2 : $TestEnm)
3076
+
3077
+ bb8(%47 : $TestEnm):
3078
+ %49 = unchecked_enum_data %47 : $TestEnm, #TestEnm.Y!enumelt.1
3079
+ %57 = struct_extract %49 : $TestStr, #TestStr.c
3080
+ cond_br undef, bb9, bb11
3081
+
3082
+ bb9:
3083
+ br bb10
3084
+
3085
+ bb10:
3086
+ %64 = struct $TestStr (%3 : $Int32, %57 : $Int32)
3087
+ %65 = enum $TestEnm, #TestEnm.Y!enumelt.1, %64 : $TestStr
3088
+ cond_br undef, bb2, bb16
3089
+
3090
+ bb11:
3091
+ br bb10
3092
+
3093
+
3094
+ bb16:
3095
+ br bb8(%65 : $TestEnm)
3096
+ }
3097
+
You can’t perform that action at this time.
0 commit comments