|
1 |
| -// RUN: %target-swiftxx-frontend -I %S/Inputs -emit-sil %s | %FileCheck %s |
| 1 | +// RUN: %target-swiftxx-frontend -I %S/Inputs -emit-silgen %s | %FileCheck %s |
2 | 2 |
|
3 | 3 | // REQUIRES: OS=macosx
|
4 | 4 |
|
5 | 5 | import Closure
|
6 | 6 |
|
7 |
| -// CHECK: sil @$s4main25testClosureToBlockARCWeakyyF : $@convention(thin) () -> () { |
8 |
| -// CHECK: %[[V0:.*]] = function_ref @$s4main25testClosureToBlockARCWeakyyFySo0F0VcfU_ : $@convention(thin) (@in_guaranteed ARCWeak) -> () |
9 |
| -// CHECK: %[[V1:.*]] = thin_to_thick_function %[[V0]] : $@convention(thin) (@in_guaranteed ARCWeak) -> () to $@callee_guaranteed (@in_guaranteed ARCWeak) -> () |
10 |
| -// CHECK: %[[V2:.*]] = alloc_stack $@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> () |
11 |
| -// CHECK: %[[V3:.*]] = project_block_storage %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> () |
12 |
| -// CHECK: store %[[V1]] to %[[V3]] : $*@callee_guaranteed (@in_guaranteed ARCWeak) -> () |
13 |
| -// CHECK: %[[V7:.*]] = function_ref @$sSo7ARCWeakVIegn_ABIeyBi_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), @in ARCWeak) -> () |
14 |
| -// CHECK: %[[V6:.*]] = init_block_storage_header %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), invoke %[[V7]] : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), @in ARCWeak) -> (), type $@convention(block) (@in ARCWeak) -> () |
15 |
| -// CHECK: %[[V8:.*]] = copy_block %[[V6]] : $@convention(block) (@in ARCWeak) -> () |
16 |
| -// CHECK: dealloc_stack %[[V2]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> () |
17 |
| -// CHECK: %[[V11:.*]] = function_ref @_Z12cfuncARCWeakU13block_pointerFv7ARCWeakE : $@convention(c) (@convention(block) (@in ARCWeak) -> ()) -> () |
18 |
| -// CHECK: apply %[[V11]](%[[V8]]) : $@convention(c) (@convention(block) (@in ARCWeak) -> ()) -> () |
19 |
| -// CHECK: strong_release %[[V8]] : $@convention(block) (@in ARCWeak) -> () |
20 |
| -// CHECK: %[[V12:.*]] = tuple () |
21 |
| -// CHECK: return %[[V12]] : $() |
22 |
| - |
23 |
| -// CHECK: sil shared [transparent] [reabstraction_thunk] @$sSo7ARCWeakVIegn_ABIeyBi_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), @in ARCWeak) -> () { |
24 |
| -// CHECK: bb0(%[[V0:.*]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> (), %[[V1:.*]] : $*ARCWeak): |
25 |
| -// CHECK: %[[V2:.*]] = project_block_storage %[[V0]] : $*@block_storage @callee_guaranteed (@in_guaranteed ARCWeak) -> () |
26 |
| -// CHECK: %[[V3:.*]] = load %[[V2]] : $*@callee_guaranteed (@in_guaranteed ARCWeak) -> () |
27 |
| -// CHECK: strong_retain %[[V3]] : $@callee_guaranteed (@in_guaranteed ARCWeak) -> () |
28 |
| -// CHECK: apply %[[V3]](%[[V1]]) : $@callee_guaranteed (@in_guaranteed ARCWeak) -> () |
29 |
| -// CHECK: %[[V6:.*]] = tuple () |
30 |
| -// CHECK: destroy_addr %[[V1]] : $*ARCWeak |
31 |
| -// CHECK: strong_release %[[V3]] : $@callee_guaranteed (@in_guaranteed ARCWeak) -> () |
32 |
| -// CHECK: return %[[V6]] : $() |
33 |
| - |
34 |
| -// ARCWeak is destroyed by the callee. |
35 |
| -public func testClosureToBlockARCWeak() { |
36 |
| - cfuncARCWeak({ARCWeak in}) |
37 |
| -} |
38 |
| - |
39 |
| -// CHECK: sil @$s4main20testClosureToFuncPtryyF : $@convention(thin) () -> () { |
| 7 | +// CHECK: sil [ossa] @$s4main20testClosureToFuncPtryyF : $@convention(thin) () -> () { |
40 | 8 | // CHECK: %[[V0:.*]] = function_ref @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_To : $@convention(c) (@owned ARCStrong) -> ()
|
41 | 9 | // CHECK: %[[V1:.*]] = function_ref @_Z14cfuncARCStrongPFv9ARCStrongE : $@convention(c) (@convention(c) (@owned ARCStrong) -> ()) -> ()
|
42 | 10 | // CHECK: apply %[[V1]](%[[V0]]) : $@convention(c) (@convention(c) (@owned ARCStrong) -> ()) -> ()
|
43 | 11 |
|
44 |
| -// CHECK: sil private [thunk] @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_To : $@convention(c) (@owned ARCStrong) -> () { |
45 |
| -// CHECK: bb0(%[[V0:.*]] : $ARCStrong): |
46 |
| -// CHECK: %[[V1:.*]] = function_ref @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_ : $@convention(thin) (@guaranteed ARCStrong) -> () |
47 |
| -// CHECK: apply %[[V1]](%[[V0]]) : $@convention(thin) (@guaranteed ARCStrong) -> () |
48 |
| -// CHECK: release_value %[[V0]] : $ARCStrong |
49 |
| -// CHECK: return %[[V2]] : $() |
| 12 | +// CHECK: sil private [thunk] [ossa] @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_To : $@convention(c) (@owned ARCStrong) -> () { |
| 13 | +// CHECK: bb0(%[[V0:.*]] : @owned $ARCStrong): |
| 14 | +// CHECK: %[[V1:.*]] = begin_borrow %[[V0]] : $ARCStrong |
| 15 | +// CHECK: %[[V2:.*]] = function_ref @$s4main20testClosureToFuncPtryyFySo9ARCStrongVcfU_ : $@convention(thin) (@guaranteed ARCStrong) -> () |
| 16 | +// CHECK: apply %[[V2]](%[[V1]]) : $@convention(thin) (@guaranteed ARCStrong) -> () |
| 17 | +// CHECK: end_borrow %[[V1]] : $ARCStrong |
| 18 | +// CHECK: destroy_value %[[V0]] : $ARCStrong |
50 | 19 |
|
51 | 20 | public func testClosureToFuncPtr() {
|
52 | 21 | cfuncARCStrong({N in})
|
|
0 commit comments