@@ -83,10 +83,11 @@ bb2(%5 : @owned $Error):
83
83
throw %5 : $Error
84
84
}
85
85
86
- // Partial Apply copy_value test.
86
+ // Partial Apply copy_value, begin_borrow
87
87
88
88
sil @nativeobject_plus : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
89
89
sil @partial_apply_user : $@convention(thin) (@owned @callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
90
+ sil @partial_apply_user_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
90
91
91
92
sil [ossa] [transparent] @test_partial_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
92
93
bb0(%0 : @owned $Builtin.NativeObject, %1 : @owned $Builtin.NativeObject):
@@ -101,6 +102,12 @@ bb0(%0 : @owned $@callee_owned (@owned Builtin.NativeObject) -> @owned Builtin.N
101
102
return %7 : $Builtin.NativeObject
102
103
}
103
104
105
+ sil [ossa] [transparent] @test_partial_nativeobject_bar_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
106
+ bb0(%0 : @guaranteed $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, %1 : @owned $Builtin.NativeObject):
107
+ %7 = apply %0(%1) : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
108
+ return %7 : $Builtin.NativeObject
109
+ }
110
+
104
111
// CHECK-LABEL: sil [transparent] [ossa] @test_partial_nativeobject_foo : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
105
112
// CHECK: bb0([[ARG:%.*]] : @owned $Builtin.NativeObject):
106
113
// CHECK: [[FN:%.*]] = function_ref @test_partial_nativeobject_baz :
@@ -145,6 +152,99 @@ bb3:
145
152
return %13 : $Builtin.NativeObject
146
153
}
147
154
155
+ // Make sure we do not eliminate the actual closure but do the inlining.
156
+ //
157
+ // CHECK-LABEL: sil [transparent] [ossa] @test_partial_nativeobject_foo_guaranteed_explicit_borrow : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
158
+ // CHECK: [[PAI:%.*]] = partial_apply [callee_guaranteed]
159
+ // CHECK: [[NATIVEOBJECT_PLUS_FUNC:%.*]] = function_ref @nativeobject_plus : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
160
+ // CHECK-NEXT: apply [[NATIVEOBJECT_PLUS_FUNC]](
161
+ // CHECK: } // end sil function 'test_partial_nativeobject_foo_guaranteed_explicit_borrow'
162
+ sil [transparent] [ossa] @test_partial_nativeobject_foo_guaranteed_explicit_borrow : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
163
+ bb0(%0 : @owned $Builtin.NativeObject):
164
+ %2 = function_ref @test_partial_nativeobject_bar_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
165
+ %3 = function_ref @test_partial_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
166
+ br bb1
167
+
168
+ bb1:
169
+ %0copy1 = copy_value %0 : $Builtin.NativeObject
170
+ %5 = partial_apply [callee_guaranteed] %3(%0copy1) : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
171
+ %6 = begin_borrow %5 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
172
+ br bb2
173
+
174
+ bb2:
175
+ %0copy2 = copy_value %0 : $Builtin.NativeObject
176
+ %13 = apply %2(%6, %0copy2) : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
177
+ end_borrow %6 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
178
+ br bb3
179
+
180
+ bb3:
181
+ %15 = function_ref @partial_apply_user_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
182
+ apply %15(%5) : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
183
+ destroy_value %5 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
184
+ destroy_value %0 : $Builtin.NativeObject
185
+ return %13 : $Builtin.NativeObject
186
+ }
187
+
188
+ // Make sure we do the inlining and delete the closure.
189
+ // CHECK-LABEL: sil [transparent] [ossa] @test_partial_nativeobject_foo_guaranteed_explicit_borrow_dead_pa : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
190
+ // CHECK-NOT: partial_apply
191
+ // CHECK: [[NATIVEOBJECT_PLUS_FUNC:%.*]] = function_ref @nativeobject_plus : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
192
+ // CHECK-NEXT: apply [[NATIVEOBJECT_PLUS_FUNC]](
193
+ // CHECK-NOT: partial_apply
194
+ // CHECK: } // end sil function 'test_partial_nativeobject_foo_guaranteed_explicit_borrow_dead_pa'
195
+ sil [transparent] [ossa] @test_partial_nativeobject_foo_guaranteed_explicit_borrow_dead_pa : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
196
+ bb0(%0 : @owned $Builtin.NativeObject):
197
+ %2 = function_ref @test_partial_nativeobject_bar_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
198
+ %3 = function_ref @test_partial_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
199
+ br bb1
200
+
201
+ bb1:
202
+ %0copy1 = copy_value %0 : $Builtin.NativeObject
203
+ %5 = partial_apply [callee_guaranteed] %3(%0copy1) : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
204
+ %6 = begin_borrow %5 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
205
+ br bb2
206
+
207
+ bb2:
208
+ %0copy2 = copy_value %0 : $Builtin.NativeObject
209
+ %13 = apply %2(%6, %0copy2) : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
210
+ end_borrow %6 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
211
+ br bb3
212
+
213
+ bb3:
214
+ destroy_value %5 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
215
+ destroy_value %0 : $Builtin.NativeObject
216
+ return %13 : $Builtin.NativeObject
217
+ }
218
+
219
+ // CHECK-LABEL: sil [transparent] [ossa] @test_partial_nativeobject_foo_guaranteed_implicit_borrow : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
220
+ // We shouldn't delete the PAI here.
221
+ // CHECK: [[PAI:%.*]] = partial_apply [callee_guaranteed]
222
+ // CHECK: [[NATIVEOBJECT_PLUS_FUNC:%.*]] = function_ref @nativeobject_plus : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
223
+ // CHECK: apply [[NATIVEOBJECT_PLUS_FUNC]](
224
+ // CHECK: } // end sil function 'test_partial_nativeobject_foo_guaranteed_implicit_borrow'
225
+ sil [transparent] [ossa] @test_partial_nativeobject_foo_guaranteed_implicit_borrow : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
226
+ bb0(%0 : @owned $Builtin.NativeObject):
227
+ %2 = function_ref @test_partial_nativeobject_bar_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
228
+ %3 = function_ref @test_partial_nativeobject_baz : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
229
+ br bb1
230
+
231
+ bb1:
232
+ %0copy1 = copy_value %0 : $Builtin.NativeObject
233
+ %5 = partial_apply [callee_guaranteed] %3(%0copy1) : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
234
+ br bb2
235
+
236
+ bb2:
237
+ %0copy2 = copy_value %0 : $Builtin.NativeObject
238
+ %13 = apply %2(%5, %0copy2) : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject, @owned Builtin.NativeObject) -> @owned Builtin.NativeObject
239
+ br bb3
240
+
241
+ bb3:
242
+ %15 = function_ref @partial_apply_user_guaranteed : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
243
+ apply %15(%5) : $@convention(thin) (@guaranteed @callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject) -> ()
244
+ destroy_value %5 : $@callee_guaranteed (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject
245
+ destroy_value %0 : $Builtin.NativeObject
246
+ return %13 : $Builtin.NativeObject
247
+ }
148
248
149
249
sil [transparent] [ossa] @term_ossa_checked_cast_addr_br_takealways_callee : $@convention(thin) (@owned Builtin.NativeObject) -> () {
150
250
bb0(%0 : @owned $Builtin.NativeObject):
0 commit comments