@@ -229,3 +229,49 @@ bb4:
229
229
destroy_value %4 : $FakeOptional<Klass>
230
230
return %5 : $Builtin.Int1
231
231
}
232
+
233
+ sil_global @my_global : $S
234
+
235
+ sil @globalinit_func11 : $@convention(thin) () -> ()
236
+
237
+ struct S {
238
+ }
239
+
240
+ // This test is not optimized because the dest bb of the branch has a single predecessor
241
+ // CHECK-LABEL: sil [ossa] @test_simplify_switch_enum_jump_threading_sil_token :
242
+ // CHECK: switch_enum
243
+ // CHECK-NOT: switch_enum
244
+ // CHECK-LABEL: } // end sil function 'test_simplify_switch_enum_jump_threading_sil_token'
245
+ sil [ossa] @test_simplify_switch_enum_jump_threading_sil_token : $@convention(thin) (@owned Klass, Builtin.RawPointer) -> () {
246
+ bb0(%0 : @owned $Klass, %1 : $Builtin.RawPointer):
247
+ cond_br undef, bb1, bb2
248
+
249
+ bb1:
250
+ specify_test "simplify-cfg-try-jump-threading @instruction[2]"
251
+ %s = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass
252
+ br bb3(%s : $FakeOptional<Klass>)
253
+
254
+ bb2:
255
+ destroy_value %0 : $Klass
256
+ %n = enum $FakeOptional<Klass>, #FakeOptional.none!enumelt
257
+ br bb3(%n : $FakeOptional<Klass>)
258
+
259
+ bb3(%3 : @owned $FakeOptional<Klass>):
260
+ %f = function_ref @globalinit_func11 : $@convention(thin) () -> ()
261
+ %b = builtin "once"(%1 : $Builtin.RawPointer, %f : $@convention(thin) () -> ()) : $Builtin.SILToken
262
+ %g = global_addr @my_global : $*S depends_on %b
263
+ switch_enum %3 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb5, case #FakeOptional.none!enumelt: bb4
264
+
265
+ bb4:
266
+ br bb6
267
+
268
+ bb5(%6 : @owned $Klass):
269
+ %ld = load [trivial] %g : $*S
270
+ apply undef(%ld) : $@convention(thin) (S) -> ()
271
+ destroy_value %6 : $Klass
272
+ br bb6
273
+
274
+ bb6:
275
+ %t = tuple ()
276
+ return %t : $()
277
+ }
0 commit comments