|
| 1 | +// RUN: %target-sil-opt -enable-sil-verify-all %s -simplify-cfg |
| 2 | + |
| 3 | +enum FakeOptional<T> { |
| 4 | + case some(T) |
| 5 | + case none |
| 6 | +} |
| 7 | + |
| 8 | +class SuperKlass { |
| 9 | +} |
| 10 | + |
| 11 | +class Klass : SuperKlass { |
| 12 | +} |
| 13 | + |
| 14 | +sil [ossa] @use_klass : $@convention(thin) (@guaranteed Klass) -> () |
| 15 | + |
| 16 | +// Test we don't get an assert while replacing branch target of checked_cast_br |
| 17 | +sil [ossa] @test_cfg1 : $@convention(thin) (@guaranteed SuperKlass) -> @out FakeOptional<Klass> { |
| 18 | +bb0(%0 : $*FakeOptional<Klass>, %1 : @guaranteed $SuperKlass): |
| 19 | + %2 = init_enum_data_addr %0 : $*FakeOptional<Klass>, #FakeOptional.some!enumelt |
| 20 | + checked_cast_br %1 : $SuperKlass to Klass, bb1, bb2 |
| 21 | + |
| 22 | +bb1(%6 : @guaranteed $Klass): |
| 23 | + %7 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %6 : $Klass |
| 24 | + br bb3(%7 : $FakeOptional<Klass>) |
| 25 | + |
| 26 | +bb2(%9 : @guaranteed $SuperKlass): |
| 27 | + %10 = enum $FakeOptional<Klass>, #FakeOptional.none!enumelt |
| 28 | + br bb3(%10 : $FakeOptional<Klass>) |
| 29 | + |
| 30 | + |
| 31 | +bb3(%12 : @guaranteed $FakeOptional<Klass>): |
| 32 | + switch_enum %12 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb4, case #FakeOptional.none!enumelt: bb6 |
| 33 | + |
| 34 | +bb4(%14 : @guaranteed $Klass): |
| 35 | + %15 = copy_value %14 : $Klass |
| 36 | + store %15 to [init] %2 : $*Klass |
| 37 | + inject_enum_addr %0 : $*FakeOptional<Klass>, #FakeOptional.some!enumelt |
| 38 | + br bb5 |
| 39 | + |
| 40 | +bb5: |
| 41 | + %21 = tuple () |
| 42 | + return %21 : $() |
| 43 | + |
| 44 | +bb6: |
| 45 | + inject_enum_addr %0 : $*FakeOptional<Klass>, #FakeOptional.none!enumelt |
| 46 | + br bb5 |
| 47 | +} |
0 commit comments