@@ -16,7 +16,7 @@ entry(%x : $Int, %y : $Int):
16
16
// CHECK-LABEL: sil @closure_common_uses_user_a
17
17
// CHECK: bb0([[Y:%.*]] : $Int):
18
18
// CHECK: [[F:%.*]] = function_ref @closure_common_uses
19
- // CHECK-NEXT: [[BOX:%.*]] = alloc_box ${ let Int }
19
+ // CHECK-NEXT: [[BOX:%.*]] = alloc_box [reflection] ${ let Int }
20
20
// CHECK-NEXT: [[BOX_0:%.*]] = project_box [[BOX]] : ${ let Int }, 0
21
21
// CHECK-NEXT: store [[Y]] to [[BOX_0]]
22
22
// CHECK-NEXT: [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]([[BOX]])
@@ -30,7 +30,7 @@ entry(%y : $Int):
30
30
// CHECK-LABEL: sil @closure_common_uses_user_b
31
31
// CHECK: bb0([[Y:%.*]] : $Int):
32
32
// CHECK: [[F:%.*]] = function_ref @closure_common_uses
33
- // CHECK-NEXT: [[BOX:%.*]] = alloc_box ${ let Int }
33
+ // CHECK-NEXT: [[BOX:%.*]] = alloc_box [reflection] ${ let Int }
34
34
// CHECK-NEXT: [[BOX_0:%.*]] = project_box [[BOX]] : ${ let Int }, 0
35
35
// CHECK-NEXT: store [[Y]] to [[BOX_0]]
36
36
// CHECK-NEXT: [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]([[BOX]])
@@ -83,7 +83,7 @@ entry(%r : $*Int, %x : $Int, %y : $Int):
83
83
// CHECK-LABEL: sil @closure_out_param_user
84
84
// CHECK: bb0([[Y:%.*]] : $Int):
85
85
// CHECK: [[F:%.*]] = function_ref @closure_out_param
86
- // CHECK-NEXT: [[BOX:%.*]] = alloc_box ${ let Int }
86
+ // CHECK-NEXT: [[BOX:%.*]] = alloc_box [reflection] ${ let Int }
87
87
// CHECK-NEXT: [[BOX_0:%.*]] = project_box [[BOX]] : ${ let Int }, 0
88
88
// CHECK-NEXT: store [[Y]] to [[BOX_0]]
89
89
// CHECK-NEXT: [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]([[BOX]])
@@ -93,3 +93,42 @@ entry(%y : $Int):
93
93
%c = partial_apply [callee_guaranteed] %f(%y) : $@convention(thin) (Int, Int) -> @out Int
94
94
return %c : $@callee_guaranteed (Int) -> @out Int
95
95
}
96
+
97
+ sil @add : $@convention(thin) (Int, Int) -> Int
98
+
99
+ // CHECK-LABEL: sil private @closure_multi_capture
100
+ // CHECK-SAME: : $@convention(method) (Int, @guaranteed { let (Int, Int) }) -> Int
101
+ // CHECK: bb0([[X:%.*]] : $Int, [[YZ:%.*]] : ${ let (Int, Int) }):
102
+ // CHECK-NEXT: [[BOX_PROJ:%.*]] = project_box [[YZ]] :
103
+ // CHECK-NEXT: [[BOX_0:%.*]] = tuple_element_addr [[BOX_PROJ]] : {{.*}}, 0
104
+ // CHECK-NEXT: [[Y:%.*]] = load [[BOX_0]] : $*Int
105
+ // CHECK-NEXT: [[BOX_PROJ:%.*]] = project_box [[YZ]] :
106
+ // CHECK-NEXT: [[BOX_1:%.*]] = tuple_element_addr [[BOX_PROJ]] : {{.*}}, 1
107
+ // CHECK-NEXT: [[Z:%.*]] = load [[BOX_1]] : $*Int
108
+ // CHECK: [[ADD:%.*]] = function_ref @add
109
+ // CHECK-NEXT: apply [[ADD]]([[Y]], [[Z]])
110
+ sil private @closure_multi_capture : $@convention(thin) (Int, Int, Int) -> Int {
111
+ entry(%x : $Int, %y : $Int, %z : $Int):
112
+ %f = function_ref @add : $@convention(thin) (Int, Int) -> Int
113
+ %r = apply %f(%y, %z) : $@convention(thin) (Int, Int) -> Int
114
+ return %r : $Int
115
+ }
116
+
117
+ // CHECK-LABEL: sil @closure_multi_capture_user
118
+ // CHECK: bb0([[Y:%.*]] : $Int, [[Z:%.*]] : $Int):
119
+ // CHECK: [[BOX:%.*]] = alloc_box [reflection] ${ let (Int, Int) }
120
+ // CHECK: [[BOX_PROJ:%.*]] = project_box [[BOX]]
121
+ // CHECK: [[BOX_0:%.*]] = tuple_element_addr [[BOX_PROJ]] : {{.*}}, 0
122
+ // CHECK: store [[Y]] to [[BOX_0]]
123
+ // CHECK: [[BOX_PROJ:%.*]] = project_box [[BOX]]
124
+ // CHECK: [[BOX_1:%.*]] = tuple_element_addr [[BOX_PROJ]] : {{.*}}, 1
125
+ // CHECK: store [[Z]] to [[BOX_1]]
126
+ // CHECK: [[RESULT:%.*]] = partial_apply [callee_guaranteed] {{%.*}}([[BOX]])
127
+ // CHECK: return [[RESULT]]
128
+ sil @closure_multi_capture_user : $@convention(thin) (Int, Int) -> @owned @callee_guaranteed (Int) -> Int {
129
+ entry(%y : $Int, %z : $Int):
130
+ %f = function_ref @closure_multi_capture : $@convention(thin) (Int, Int, Int) -> Int
131
+ %c = partial_apply [callee_guaranteed] %f(%y, %z) : $@convention(thin) (Int, Int, Int) -> Int
132
+ return %c : $@callee_guaranteed (Int) -> Int
133
+ }
134
+
0 commit comments