|
1 |
| -// RUN: %target-sil-opt -test-runner -sil-infinite-jump-threading-budget %s 2>&1 |
| 1 | +// RUN: %target-sil-opt -test-runner -sil-infinite-jump-threading-budget %s 2>&1 | %FileCheck %s |
2 | 2 |
|
3 | 3 | import Builtin
|
4 | 4 | import Swift
|
@@ -105,6 +105,10 @@ bb4:
|
105 | 105 | return %4 : $Builtin.Int1
|
106 | 106 | }
|
107 | 107 |
|
| 108 | +// CHECK-LABEL: sil [ossa] @test_jump_thread_ref_ele_loop : $@convention(thin) () -> () { |
| 109 | +// CHECK: begin_borrow |
| 110 | +// CHECK: begin_borrow |
| 111 | +// CHECK-LABEL: } // end sil function 'test_jump_thread_ref_ele_loop' |
108 | 112 | sil [ossa] @test_jump_thread_ref_ele_loop : $@convention(thin) () -> () {
|
109 | 113 | bb0:
|
110 | 114 | specify_test "simplify-cfg-try-jump-threading @instruction[3]"
|
|
141 | 145 | }
|
142 | 146 |
|
143 | 147 | // CHECK-LABEL: sil [ossa] @test_jump_thread_checked_cast_value :
|
144 |
| -// CHECK: select_enum |
145 |
| -// CHECK: select_enum |
| 148 | +// CHECK: checked_cast_br |
| 149 | +// CHECK: checked_cast_br |
146 | 150 | // CHECK-LABEL: } // end sil function 'test_jump_thread_checked_cast_value'
|
147 | 151 | sil [ossa] @test_jump_thread_checked_cast_value : $@convention(thin) (@owned AnyKlass, @owned AnyKlass) -> () {
|
148 | 152 | bb0(%0 : @owned $AnyKlass, %1 : @owned $AnyKlass):
|
@@ -174,3 +178,54 @@ bb9:
|
174 | 178 | %999 = tuple ()
|
175 | 179 | return %999 : $()
|
176 | 180 | }
|
| 181 | + |
| 182 | +// Partial apply cannot be cloned, even in OSSA. OSSA lowering does |
| 183 | +// not know how to allocate for multiple partial applies. |
| 184 | +// |
| 185 | +// rdar://119768691 (OwnershipModelEliminator triggers assertion when |
| 186 | +// lowering certain [on_stack] partial_applys in certain |
| 187 | +// circumstances) |
| 188 | + |
| 189 | +sil @test_simple_jump_thread_clone_partial_apply_closure : $@convention(thin) (@inout_aliasable Klass) -> () |
| 190 | +sil @test_simple_jump_thread_clone_partial_apply_take_closure : $@convention(thin) (@noescape @callee_guaranteed () ->()) -> () |
| 191 | + |
| 192 | +// CHECK-LABEL: sil [ossa] @test_simple_jump_thread_clone_partial_apply : $@convention(thin) (@owned Klass, @inout Klass) -> Builtin.Int1 { |
| 193 | +// CHECK: bb{{.*}}(%{{.*}} : @owned $FakeOptional<Klass>): |
| 194 | +// CHECK: partial_apply [callee_guaranteed] |
| 195 | +// CHECK-NEXT: mark_dependence |
| 196 | +// CHECK-NEXT: begin_borrow [lexical] |
| 197 | +// CHECK-NOT: partial_apply [callee_guaranted] |
| 198 | +// CHECK-NOT: begin_borrow |
| 199 | +// CHECK-LABEL: } // end sil function 'test_simple_jump_thread_clone_partial_apply' |
| 200 | +sil [ossa] @test_simple_jump_thread_clone_partial_apply : $@convention(thin) (@owned Klass, @inout Klass) -> Builtin.Int1 { |
| 201 | +bb0(%0 : @owned $Klass, %1 : $*Klass): |
| 202 | + %t = integer_literal $Builtin.Int1, 1 |
| 203 | + %f = integer_literal $Builtin.Int1, 0 |
| 204 | + cond_br undef, bb1, bb2 |
| 205 | + |
| 206 | +bb1: |
| 207 | + specify_test "simplify-cfg-try-jump-threading @instruction[4]" |
| 208 | + %2 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt, %0 : $Klass |
| 209 | + br bb3(%2 : $FakeOptional<Klass>) |
| 210 | + |
| 211 | +bb2: |
| 212 | + destroy_value %0 : $Klass |
| 213 | + %3 = enum $FakeOptional<Klass>, #FakeOptional.none!enumelt |
| 214 | + br bb3(%3 : $FakeOptional<Klass>) |
| 215 | + |
| 216 | +bb3(%4 : @owned $FakeOptional<Klass>): |
| 217 | + %5 = select_enum %4 : $FakeOptional<Klass>, case #FakeOptional.some!enumelt: %t, case #FakeOptional.none!enumelt: %f : $Builtin.Int1 |
| 218 | + %6 = function_ref @test_simple_jump_thread_clone_partial_apply_closure : $@convention(thin) (@inout_aliasable Klass) -> () |
| 219 | + %7 = partial_apply [callee_guaranteed] [on_stack] %6(%1) : $@convention(thin) (@inout_aliasable Klass) -> () |
| 220 | + %8 = mark_dependence %7 : $@noescape @callee_guaranteed () ->() on %1 : $*Klass |
| 221 | + %9 = begin_borrow [lexical] %8 : $@noescape @callee_guaranteed () ->() |
| 222 | + br bb4 |
| 223 | + |
| 224 | +bb4: |
| 225 | + %func = function_ref @test_simple_jump_thread_clone_partial_apply_take_closure : $@convention(thin) (@noescape @callee_guaranteed () ->()) -> () |
| 226 | + %call = apply %func(%9) : $@convention(thin) (@noescape @callee_guaranteed () ->()) -> () |
| 227 | + end_borrow %9 : $@noescape @callee_guaranteed () ->() |
| 228 | + destroy_value %8 : $@noescape @callee_guaranteed () ->() |
| 229 | + destroy_value %4 : $FakeOptional<Klass> |
| 230 | + return %5 : $Builtin.Int1 |
| 231 | +} |
0 commit comments