@@ -21,15 +21,22 @@ import Swift
21
21
// CHECK: [[STRUCT:%.*]] = struct $Int32 ({{%.*}} : $Builtin.Int32)
22
22
// CHECK: return [[STRUCT]] : $Int32
23
23
24
+ protocol P {
25
+ func boo() -> Int64
26
+ }
27
+
24
28
class Bar {
29
+ func boo() -> Int64
25
30
func foo()
26
31
@objc func foo_objc()
27
32
}
28
33
29
34
sil @_TFC4main3Bar3foofS0_FT_T_ : $@convention(method) (@guaranteed Bar) -> ()
35
+ sil @_TFC4main3Bar3boofS0_FT_T_ : $@convention(method) (@guaranteed Bar) -> Int64
30
36
sil @_TFC4main3Bar3foo_objcfS0_FT_T_ : $@convention(objc_method) (Bar) -> ()
31
37
32
38
sil_vtable Bar {
39
+ #Bar.boo!1: _TFC4main3Bar3boofS0_FT_T_
33
40
#Bar.foo!1: _TFC4main3Bar3foofS0_FT_T_
34
41
#Bar.foo_objc!1: _TFC4main3Bar3foofS0_FT_T_
35
42
}
@@ -104,6 +111,45 @@ bb3 (%23 : $Builtin.Int32) :
104
111
return %24 : $Int32
105
112
}
106
113
114
+ // The following function used to crash the compiler, because loop rotate
115
+ // could not properly handle the reference from witness_method to the
116
+ // archetype opened by open_existential_addr
117
+ // CHECK-LABEL: sil @looprotate_with_opened_archetype
118
+ // CHECK: return
119
+ sil @looprotate_with_opened_archetype : $@convention(thin) (Int32, @in P) -> Int32 {
120
+ bb0(%0 : $Int32, %25: $*P):
121
+ %1 = struct_extract %0 : $Int32, #Int32._value
122
+ %2 = integer_literal $Builtin.Int32, 0
123
+ %30 = alloc_box $Bool
124
+ %30a = project_box %30 : $@box Bool
125
+ %40 = open_existential_addr %25 : $*P to $*@opened("C22498FA-CABF-11E5-B9A9-685B35C48C83") P
126
+ br bb1(%1 : $Builtin.Int32, %2 : $Builtin.Int32, %25: $*P, %30 : $@box Bool, %30a : $*Bool)
127
+
128
+ bb1(%4 : $Builtin.Int32, %5 : $Builtin.Int32, %26: $*P, %31 : $@box Bool, %32 : $*Bool):
129
+ %111 = witness_method $@opened("C22498FA-CABF-11E5-B9A9-685B35C48C83") P, #P.boo!1, %40 : $*@opened("C22498FA-CABF-11E5-B9A9-685B35C48C83") P : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64
130
+ %122 = apply %111<@opened("C22498FA-CABF-11E5-B9A9-685B35C48C83") P>(%40) : $@convention(witness_method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> Int64
131
+ %6 = struct $Int32 (%5 : $Builtin.Int32)
132
+ %8 = builtin "cmp_eq_Word"(%5 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
133
+ cond_br %8, bb3, bb2
134
+
135
+ bb2:
136
+ %10 = integer_literal $Builtin.Int32, 1
137
+ %12 = integer_literal $Builtin.Int1, -1
138
+ %13 = builtin "sadd_with_overflow_Word"(%5 : $Builtin.Int32, %10 : $Builtin.Int32, %12 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
139
+ %14 = tuple_extract %13 : $(Builtin.Int32, Builtin.Int1), 0
140
+ %15 = enum $Optional<Int32>, #Optional.some!enumelt.1, %6 : $Int32
141
+ %16 = unchecked_enum_data %15 : $Optional<Int32>, #Optional.some!enumelt.1
142
+ %17 = struct_extract %16 : $Int32, #Int32._value
143
+ %19 = integer_literal $Builtin.Int1, -1
144
+ %20 = builtin "sadd_with_overflow_Word"(%4 : $Builtin.Int32, %17 : $Builtin.Int32, %19 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
145
+ %21 = tuple_extract %20 : $(Builtin.Int32, Builtin.Int1), 0
146
+ br bb1(%21 : $Builtin.Int32, %14 : $Builtin.Int32, %26: $*P, %31 : $@box Bool, %32 : $*Bool)
147
+
148
+ bb3:
149
+ %23 = struct $Int32 (%4 : $Builtin.Int32)
150
+ return %23 : $Int32
151
+ }
152
+
107
153
// Don't assert on this loop. bb2 is bb1 loop's new header after rotation but
108
154
// also bb2 loop's header.
109
155
0 commit comments