|
| 1 | +// RUN: %target-sil-opt -enable-sil-verify-all %s -mandatory-generic-specializer | %FileCheck %s |
| 2 | + |
| 3 | +import Builtin |
| 4 | + |
| 5 | +sil @paable : $@convention(thin) (Builtin.Int64) -> () |
| 6 | + |
| 7 | +sil [ossa] [transparent] @partial_apply_on_stack_nesting_violator : $@convention(thin) <T> () -> () { |
| 8 | + %paable = function_ref @paable : $@convention(thin) (Builtin.Int64) -> () |
| 9 | + %one = integer_literal $Builtin.Int64, 1 |
| 10 | + %first = partial_apply [callee_guaranteed] [on_stack] %paable(%one) : $@convention(thin) (Builtin.Int64) -> () |
| 11 | + %two = integer_literal $Builtin.Int64, 2 |
| 12 | + %second = partial_apply [callee_guaranteed] [on_stack] %paable(%two) : $@convention(thin) (Builtin.Int64) -> () |
| 13 | + // Note that the destroy_values do not occur in an order which coincides |
| 14 | + // with stack disciplined dealloc_stacks. |
| 15 | + destroy_value %first : $@noescape @callee_guaranteed () -> () |
| 16 | + destroy_value %second : $@noescape @callee_guaranteed () -> () |
| 17 | + %retval = tuple () |
| 18 | + return %retval : $() |
| 19 | +} |
| 20 | + |
| 21 | +// Verify that when inlining partial_apply_on_stack_nesting_violator, the stack |
| 22 | +// nesting of the on_stack closures is fixed. |
| 23 | +// CHECK-LABEL: sil [no_locks] @test_inline_stack_violating_ossa_func : {{.*}} { |
| 24 | +// CHECK: [[PAABLE:%[^,]+]] = function_ref @paable |
| 25 | +// CHECK: [[FIRST:%[^,]+]] = partial_apply [callee_guaranteed] [on_stack] [[PAABLE]] |
| 26 | +// CHECK: [[SECOND:%[^,]+]] = partial_apply [callee_guaranteed] [on_stack] [[PAABLE]] |
| 27 | +// CHECK: dealloc_stack [[SECOND]] |
| 28 | +// CHECK: dealloc_stack [[FIRST]] |
| 29 | +// CHECK-LABEL: } // end sil function 'test_inline_stack_violating_ossa_func' |
| 30 | +sil [no_locks] @test_inline_stack_violating_ossa_func : $@convention(thin) () -> () { |
| 31 | + %callee = function_ref @partial_apply_on_stack_nesting_violator : $@convention(thin) <T> () -> () |
| 32 | + apply %callee<Builtin.Int64>() : $@convention(thin) <T> () -> () |
| 33 | + %retval = tuple () |
| 34 | + return %retval : $() |
| 35 | +} |
| 36 | + |
| 37 | + |
0 commit comments