@@ -35,3 +35,88 @@ public func testClosureToFuncPtr() {
35
35
public func testClosureToBlockReturnNonTrivial( ) {
36
36
cfuncReturnNonTrivial ( { ( ) -> NonTrivial in return NonTrivial ( ) } )
37
37
}
38
+
39
+ // CHECK-LABEL: sil private [thunk] [ossa] @$s4main22testConstRefNonTrivialyyFySo0eF0VcfU_To : $@convention(c) (@in_guaranteed NonTrivial) -> () {
40
+ // CHECK: bb0(%[[V0:.*]] : $*NonTrivial):
41
+ // CHECK: %[[V1:.*]] = alloc_stack $NonTrivial
42
+ // CHECK: copy_addr %[[V0]] to [init] %[[V1]] : $*NonTrivial
43
+ // CHECK: %[[V3:.*]] = function_ref @$s4main22testConstRefNonTrivialyyFySo0eF0VcfU_ : $@convention(thin) (@in_guaranteed NonTrivial) -> ()
44
+ // CHECK: %[[V4:.*]] = apply %[[V3]](%[[V1]]) : $@convention(thin) (@in_guaranteed NonTrivial) -> ()
45
+ // CHECK: destroy_addr %[[V1]] : $*NonTrivial
46
+ // CHECK: dealloc_stack %[[V1]] : $*NonTrivial
47
+ // CHECK: return %[[V4]] : $()
48
+
49
+ public func testConstRefNonTrivial( ) {
50
+ cfuncConstRefNonTrivial ( { S in } ) ;
51
+ }
52
+
53
+ // CHECK-LABEL: sil private [thunk] [ossa] @$s4main19testConstRefTrivialyyFySo0E0VcfU_To : $@convention(c) (@in_guaranteed Trivial) -> () {
54
+ // CHECK: bb0(%[[V0:.*]] : $*Trivial):
55
+ // CHECK: %[[V1:.*]] = load [trivial] %[[V0]] : $*Trivial
56
+ // CHECK: %[[V2:.*]] = function_ref @$s4main19testConstRefTrivialyyFySo0E0VcfU_ : $@convention(thin) (Trivial) -> ()
57
+ // CHECK: %[[V3:.*]] = apply %[[V2]](%[[V1]]) : $@convention(thin) (Trivial) -> ()
58
+ // CHECK: return %[[V3]] : $()
59
+
60
+ public func testConstRefTrivial( ) {
61
+ cfuncConstRefTrivial ( { S in } ) ;
62
+ }
63
+
64
+ // CHECK-LABEL: sil private [thunk] [ossa] @$s4main18testConstRefStrongyyFySo9ARCStrongVcfU_To : $@convention(c) (@in_guaranteed ARCStrong) -> () {
65
+ // CHECK: bb0(%[[V0:.*]] : $*ARCStrong):
66
+ // CHECK: %[[V1:.*]] = alloc_stack $ARCStrong
67
+ // CHECK: copy_addr %[[V0]] to [init] %[[V1]] : $*ARCStrong
68
+ // CHECK: %[[V3:.*]] = load [copy] %[[V1]] : $*ARCStrong
69
+ // CHECK: %[[V4:.*]] = begin_borrow %[[V3]] : $ARCStrong
70
+ // CHECK: %[[V5:.*]] = function_ref @$s4main18testConstRefStrongyyFySo9ARCStrongVcfU_ : $@convention(thin) (@guaranteed ARCStrong) -> ()
71
+ // CHECK: %[[V6:.*]] = apply %[[V5]](%[[V4]]) : $@convention(thin) (@guaranteed ARCStrong) -> ()
72
+ // CHECK: end_borrow %[[V4]] : $ARCStrong
73
+ // CHECK: destroy_value %[[V3]] : $ARCStrong
74
+ // CHECK: destroy_addr %[[V1]] : $*ARCStrong
75
+ // CHECK: dealloc_stack %[[V1]] : $*ARCStrong
76
+ // CHECK: return %[[V6]] : $()
77
+
78
+ public func testConstRefStrong( ) {
79
+ cfuncConstRefStrong ( { S in } ) ;
80
+ }
81
+
82
+ // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sSo10NonTrivialVIegn_ABIeyBn_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@in_guaranteed NonTrivial) -> (), @in_guaranteed NonTrivial) -> () {
83
+ // CHECK: bb0(%[[V0:.*]] : $*@block_storage @callee_guaranteed (@in_guaranteed NonTrivial) -> (), %[[V1:.*]] : $*NonTrivial):
84
+ // CHECK: %[[V2:.*]] = project_block_storage %[[V0]] : $*@block_storage @callee_guaranteed (@in_guaranteed NonTrivial) -> ()
85
+ // CHECK: %[[V3:.*]] = load [copy] %[[V2]] : $*@callee_guaranteed (@in_guaranteed NonTrivial) -> ()
86
+ // CHECK: %[[V4:.*]] = begin_borrow %[[V3]] : $@callee_guaranteed (@in_guaranteed NonTrivial) -> ()
87
+ // CHECK: apply %[[V4]](%[[V1]]) : $@callee_guaranteed (@in_guaranteed NonTrivial) -> ()
88
+ // CHECK: end_borrow %[[V4]] : $@callee_guaranteed (@in_guaranteed NonTrivial) -> ()
89
+ // CHECK: destroy_value %[[V3]] : $@callee_guaranteed (@in_guaranteed NonTrivial) -> ()
90
+
91
+ public func testBlockConstRefNonTrivial( ) {
92
+ blockConstRefNonTrivial ( { S in } ) ;
93
+ }
94
+
95
+ // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sSo7TrivialVIegy_ABIeyBn_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (Trivial) -> (), @in_guaranteed Trivial) -> () {
96
+ // CHECK: bb0(%[[V0:.*]] : $*@block_storage @callee_guaranteed (Trivial) -> (), %[[V1:.*]] : $*Trivial):
97
+ // CHECK: %[[V2:.*]] = project_block_storage %[[V0]] : $*@block_storage @callee_guaranteed (Trivial) -> ()
98
+ // CHECK: %[[V3:.*]] = load [copy] %[[V2]] : $*@callee_guaranteed (Trivial) -> ()
99
+ // CHECK: %[[V4:.*]] = load [trivial] %[[V1]] : $*Trivial
100
+ // CHECK: %[[V5:.*]] = begin_borrow %[[V3]] : $@callee_guaranteed (Trivial) -> ()
101
+ // CHECK: apply %[[V5]](%[[V4]]) : $@callee_guaranteed (Trivial) -> ()
102
+ // CHECK: end_borrow %[[V5]] : $@callee_guaranteed (Trivial) -> ()
103
+ // CHECK: destroy_value %[[V3]] : $@callee_guaranteed (Trivial) -> ()
104
+
105
+ public func testBlockConstRefTrivial( ) {
106
+ blockConstRefTrivial ( { S in } ) ;
107
+ }
108
+
109
+ // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sSo9ARCStrongVIegg_ABIeyBn_TR : $@convention(c) (@inout_aliasable @block_storage @callee_guaranteed (@guaranteed ARCStrong) -> (), @in_guaranteed ARCStrong) -> () {
110
+ // CHECK: bb0(%[[V0:.*]] : $*@block_storage @callee_guaranteed (@guaranteed ARCStrong) -> (), %[[V1:.*]] : $*ARCStrong):
111
+ // CHECK: %[[V2:.*]] = project_block_storage %[[V0]] : $*@block_storage @callee_guaranteed (@guaranteed ARCStrong) -> ()
112
+ // CHECK: %[[V3:.*]] = load [copy] %[[V2]] : $*@callee_guaranteed (@guaranteed ARCStrong) -> ()
113
+ // CHECK: %[[V4:.*]] = load_borrow %[[V1]] : $*ARCStrong
114
+ // CHECK: %[[V5:.*]] = begin_borrow %[[V3]] : $@callee_guaranteed (@guaranteed ARCStrong) -> ()
115
+ // CHECK: apply %[[V5]](%[[V4]]) : $@callee_guaranteed (@guaranteed ARCStrong) -> ()
116
+ // CHECK: end_borrow %[[V5]] : $@callee_guaranteed (@guaranteed ARCStrong) -> ()
117
+ // CHECK: end_borrow %[[V4]] : $ARCStrong
118
+ // CHECK: destroy_value %[[V3]] : $@callee_guaranteed (@guaranteed ARCStrong) -> ()
119
+
120
+ public func testBlockConstRefStrong( ) {
121
+ blockConstRefStrong ( { S in } ) ;
122
+ }
0 commit comments