|
82 | 82 | return %t : $()
|
83 | 83 | }
|
84 | 84 |
|
| 85 | +sil [ossa] @test_simplify_switch_enum1 : $@convention(thin) (@owned Klass) -> () { |
| 86 | +bb0(%0 : @owned $Klass): |
| 87 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 88 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 89 | + |
| 90 | +bb2: |
| 91 | + br bb3 |
| 92 | + |
| 93 | +bb1(%3 : @owned $Klass): |
| 94 | + destroy_value %3 : $Klass |
| 95 | + br bb3 |
| 96 | + |
| 97 | +bb3: |
| 98 | + %t = tuple () |
| 99 | + return %t : $() |
| 100 | +} |
| 101 | + |
| 102 | +sil [ossa] @test_simplify_switch_enum2 : $@convention(thin) (@guaranteed Klass) -> () { |
| 103 | +bb0(%0 : @guaranteed $Klass): |
| 104 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 105 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 106 | + |
| 107 | +bb2: |
| 108 | + br bb3 |
| 109 | + |
| 110 | +bb1(%3 : @guaranteed $Klass): |
| 111 | + br bb3 |
| 112 | + |
| 113 | +bb3: |
| 114 | + %t = tuple () |
| 115 | + return %t : $() |
| 116 | +} |
| 117 | + |
| 118 | +sil [ossa] @test_simplify_switch_enum3 : $@convention(thin) (@owned Klass) -> () { |
| 119 | +bb0(%0 : @owned $Klass): |
| 120 | + %b = begin_borrow %0 : $Klass |
| 121 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %b : $Klass |
| 122 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 123 | + |
| 124 | +bb2: |
| 125 | + br bb3 |
| 126 | + |
| 127 | +bb1(%3 : @guaranteed $Klass): |
| 128 | + br bb3 |
| 129 | + |
| 130 | +bb3: |
| 131 | + end_borrow %b : $Klass |
| 132 | + destroy_value %0 : $Klass |
| 133 | + %t = tuple () |
| 134 | + return %t : $() |
| 135 | +} |
| 136 | + |
| 137 | +sil @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 138 | + |
| 139 | +sil [ossa] @test_simplify_switch_enum4 : $@convention(thin) (@guaranteed Klass) -> () { |
| 140 | +bb0(%0 : @guaranteed $Klass): |
| 141 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 142 | + %f = function_ref @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 143 | + %c = apply %f(%1) : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 144 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 145 | + |
| 146 | +bb2: |
| 147 | + br bb3 |
| 148 | + |
| 149 | +bb1(%3 : @guaranteed $Klass): |
| 150 | + br bb3 |
| 151 | + |
| 152 | +bb3: |
| 153 | + %t = tuple () |
| 154 | + return %t : $() |
| 155 | +} |
| 156 | + |
| 157 | +sil [ossa] @test_simplify_switch_enum5 : $@convention(thin) (@owned Klass) -> () { |
| 158 | +bb0(%0 : @owned $Klass): |
| 159 | + %b = begin_borrow %0 : $Klass |
| 160 | + %1 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %b : $Klass |
| 161 | + %f = function_ref @use_optional : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 162 | + %c = apply %f(%1) : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () |
| 163 | + switch_enum %1 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 |
| 164 | + |
| 165 | +bb2: |
| 166 | + br bb3 |
| 167 | + |
| 168 | +bb1(%3 : @guaranteed $Klass): |
| 169 | + br bb3 |
| 170 | + |
| 171 | +bb3: |
| 172 | + end_borrow %b : $Klass |
| 173 | + destroy_value %0 : $Klass |
| 174 | + %t = tuple () |
| 175 | + return %t : $() |
| 176 | +} |
| 177 | + |
0 commit comments