Skip to content

Commit 0dd90a7

Browse files
committed
Update old closure tests for current conventions
Fixes assert: SIL verification failed: on-stack closures do not support owned arguments:
1 parent 20f99b2 commit 0dd90a7

File tree

3 files changed

+89
-118
lines changed

3 files changed

+89
-118
lines changed

test/IRGen/async/partial_apply.sil

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class SwiftClass {}
1212
sil_vtable SwiftClass {}
1313
sil @$s13partial_apply10SwiftClassCfD : $@async @convention(method) (SwiftClass) -> ()
1414

15-
sil @partially_applyable_to_class : $@async @convention(thin) (@owned SwiftClass) -> () {
15+
sil @partially_applyable_to_class : $@async @convention(thin) (@guaranteed SwiftClass) -> () {
1616
entry(%c : $SwiftClass):
1717
%0 = builtin "int_trap"() : $Never
1818
unreachable
1919
}
20-
sil @partially_applyable_to_two_classes : $@async @convention(thin) (@owned SwiftClass, @owned SwiftClass) -> () {
20+
sil @partially_applyable_to_two_classes : $@async @convention(thin) (@guaranteed SwiftClass, @guaranteed SwiftClass) -> () {
2121
entry(%c : $SwiftClass, %d : $SwiftClass):
2222
%0 = builtin "int_trap"() : $Never
2323
unreachable
@@ -29,16 +29,16 @@ sil @use_closure : $@async @convention(thin) (@noescape @async @callee_guarantee
2929
// CHECK: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_class(
3030
sil @partial_apply_class : $@async @convention(thin) (SwiftClass) -> @async @callee_guaranteed () -> () {
3131
entry(%c : $SwiftClass):
32-
%f = function_ref @partially_applyable_to_class : $@async @convention(thin) (@owned SwiftClass) -> ()
33-
%g = partial_apply [callee_guaranteed] %f(%c) : $@async @convention(thin) (@owned SwiftClass) -> ()
32+
%f = function_ref @partially_applyable_to_class : $@async @convention(thin) (@guaranteed SwiftClass) -> ()
33+
%g = partial_apply [callee_guaranteed] %f(%c) : $@async @convention(thin) (@guaranteed SwiftClass) -> ()
3434
return %g : $@async @callee_guaranteed () -> ()
3535
}
3636

3737
// CHECK: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_class_on_stack(
3838
sil @partial_apply_class_on_stack : $@async @convention(thin) (@owned SwiftClass) -> () {
3939
entry(%a : $SwiftClass):
40-
%f = function_ref @partially_applyable_to_class : $@async @convention(thin) (@owned SwiftClass) -> ()
41-
%c = partial_apply [callee_guaranteed] [on_stack] %f(%a) : $@async @convention(thin) (@owned SwiftClass) -> ()
40+
%f = function_ref @partially_applyable_to_class : $@async @convention(thin) (@guaranteed SwiftClass) -> ()
41+
%c = partial_apply [callee_guaranteed] [on_stack] %f(%a) : $@async @convention(thin) (@guaranteed SwiftClass) -> ()
4242
%use = function_ref @use_closure : $@async @convention(thin) (@noescape @async @callee_guaranteed () -> ()) -> ()
4343
apply %use(%c) : $@async @convention(thin) (@noescape @async @callee_guaranteed () -> ()) -> ()
4444
dealloc_stack %c : $@noescape @async @callee_guaranteed () ->()
@@ -51,8 +51,8 @@ entry(%a : $SwiftClass):
5151

5252
sil @partial_apply_two_classes_on_stack : $@async @convention(thin) (@owned SwiftClass, @owned SwiftClass) -> () {
5353
entry(%a : $SwiftClass, %b: $SwiftClass):
54-
%f = function_ref @partially_applyable_to_two_classes : $@async @convention(thin) (@owned SwiftClass, @owned SwiftClass) -> ()
55-
%c = partial_apply [callee_guaranteed] [on_stack] %f(%a, %b) : $@async @convention(thin) (@owned SwiftClass, @owned SwiftClass) -> ()
54+
%f = function_ref @partially_applyable_to_two_classes : $@async @convention(thin) (@guaranteed SwiftClass, @guaranteed SwiftClass) -> ()
55+
%c = partial_apply [callee_guaranteed] [on_stack] %f(%a, %b) : $@async @convention(thin) (@guaranteed SwiftClass, @guaranteed SwiftClass) -> ()
5656
%use = function_ref @use_closure : $@async @convention(thin) (@noescape @async @callee_guaranteed () -> ()) -> ()
5757
apply %use(%c) : $@async @convention(thin) (@noescape @async @callee_guaranteed () -> ()) -> ()
5858
dealloc_stack %c : $@noescape @async @callee_guaranteed () ->()
@@ -201,7 +201,7 @@ bb0(%x : $*SwiftClassPair):
201201
return %p : $@async @callee_guaranteed (Int) -> Int
202202
}
203203

204-
sil public @captured_fixed_and_dependent_params : $@async @convention(thin) <A> (@owned SwiftClass, @in A, Int) -> () {
204+
sil public @captured_fixed_and_dependent_params : $@async @convention(thin) <A> (@guaranteed SwiftClass, @in_guaranteed A, Int) -> () {
205205
entry(%c : $SwiftClass, %a : $*A, %i : $Int):
206206
%0 = builtin "int_trap"() : $Never
207207
unreachable
@@ -211,8 +211,8 @@ entry(%c : $SwiftClass, %a : $*A, %i : $Int):
211211
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s35captured_fixed_and_dependent_paramsTA"(
212212
sil @partial_apply_indirect_non_fixed_layout : $@async @convention(thin) <T> (@owned SwiftClass, @in T, Int) -> @async @callee_guaranteed () -> () {
213213
bb0(%a : $SwiftClass, %b : $*T, %c : $Int):
214-
%f = function_ref @captured_fixed_and_dependent_params : $@async @convention(thin) <B> (@owned SwiftClass, @in B, Int) -> ()
215-
%p = partial_apply [callee_guaranteed] %f<T>(%a, %b, %c) : $@async @convention(thin) <C> (@owned SwiftClass, @in C, Int) -> ()
214+
%f = function_ref @captured_fixed_and_dependent_params : $@async @convention(thin) <B> (@guaranteed SwiftClass, @in_guaranteed B, Int) -> ()
215+
%p = partial_apply [callee_guaranteed] %f<T>(%a, %b, %c) : $@async @convention(thin) <C> (@guaranteed SwiftClass, @in_guaranteed C, Int) -> ()
216216
return %p : $@async @callee_guaranteed () -> ()
217217
}
218218

@@ -248,27 +248,27 @@ class Sub : Base {
248248

249249
sil_vtable Sub {}
250250

251-
sil @parametric_casting_closure : $@async @convention(thin) <C where C : Base> (@owned Base) -> @owned C {
251+
sil @parametric_casting_closure : $@async @convention(thin) <C where C : Base> (@guaranteed Base) -> @owned C {
252252
bb0(%0 : $Base):
253253
%1 = unconditional_checked_cast %0 : $Base to C
254254
return %1 : $C
255255
}
256256

257257
sil public_external @receive_closure : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed () -> (@owned C)) -> ()
258-
sil public_external @receive_closure2 : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed (@owned Base) -> (@owned C)) -> ()
258+
sil public_external @receive_closure2 : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed (@guaranteed Base) -> (@owned C)) -> ()
259259

260260
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @test_partial_apply(
261261
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s26parametric_casting_closureTA"(
262262
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s26parametric_casting_closureTA.{{[0-9]+}}"(
263263
sil @test_partial_apply : $@async @convention(thin) (@owned Base) -> () {
264264
bb0(%0 : $Base):
265-
%1 = function_ref @parametric_casting_closure : $@async @convention(thin) <C where C : Base> (@owned Base) -> @owned C
266-
%6 = partial_apply [callee_guaranteed] %1<Sub>() : $@async @convention(thin) <C where C : Base> (@owned Base) -> @owned C
267-
%2 = partial_apply [callee_guaranteed] %1<Sub>(%0) : $@async @convention(thin) <C where C : Base> (@owned Base) -> @owned C
265+
%1 = function_ref @parametric_casting_closure : $@async @convention(thin) <C where C : Base> (@guaranteed Base) -> @owned C
266+
%6 = partial_apply [callee_guaranteed] %1<Sub>() : $@async @convention(thin) <C where C : Base> (@guaranteed Base) -> @owned C
267+
%2 = partial_apply [callee_guaranteed] %1<Sub>(%0) : $@async @convention(thin) <C where C : Base> (@guaranteed Base) -> @owned C
268268
%3 = function_ref @receive_closure : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed () -> (@owned C)) -> ()
269269
%4 = apply %3<Sub>(%2) : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed () -> (@owned C)) -> ()
270-
%5 = function_ref @receive_closure2 : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed (@owned Base) -> (@owned C)) -> ()
271-
%8 = apply %5<Sub>(%6) : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed (@owned Base) -> (@owned C)) -> ()
270+
%5 = function_ref @receive_closure2 : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed (@guaranteed Base) -> (@owned C)) -> ()
271+
%8 = apply %5<Sub>(%6) : $@async @convention(thin) <C where C : Base> (@owned @async @callee_guaranteed (@guaranteed Base) -> (@owned C)) -> ()
272272
%7 = tuple ()
273273
return %7 : $()
274274
}
@@ -372,7 +372,7 @@ sil @partial_apply_generic_indirect_return2 : $@async @convention(thin) (Int) ->
372372

373373
struct SwiftStruct {}
374374

375-
sil @fun : $@async @convention(thin) (@thin SwiftStruct.Type, @owned SwiftClass) -> () {
375+
sil @fun : $@async @convention(thin) (@thin SwiftStruct.Type, @guaranteed SwiftClass) -> () {
376376
entry(%t : $@thin SwiftStruct.Type, %c : $SwiftClass):
377377
%0 = builtin "int_trap"() : $Never
378378
unreachable
@@ -382,8 +382,8 @@ entry(%t : $@thin SwiftStruct.Type, %c : $SwiftClass):
382382

383383
sil @partial_apply_thin_type : $@async @convention(thin) (@thin SwiftStruct.Type, @owned SwiftClass) -> @async @callee_guaranteed () -> () {
384384
entry(%0: $@thin SwiftStruct.Type, %1: $SwiftClass):
385-
%fun = function_ref @fun : $@async @convention(thin) (@thin SwiftStruct.Type, @owned SwiftClass) -> ()
386-
%closure = partial_apply [callee_guaranteed] %fun (%0, %1) : $@async @convention(thin) (@thin SwiftStruct.Type, @owned SwiftClass) -> ()
385+
%fun = function_ref @fun : $@async @convention(thin) (@thin SwiftStruct.Type, @guaranteed SwiftClass) -> ()
386+
%closure = partial_apply [callee_guaranteed] %fun (%0, %1) : $@async @convention(thin) (@thin SwiftStruct.Type, @guaranteed SwiftClass) -> ()
387387
return %closure : $@async @callee_guaranteed () -> ()
388388
}
389389

@@ -483,16 +483,16 @@ bb0(%x : $*SwiftClassPair):
483483

484484
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_stack_callee_guaranteed_indirect_in_class_pair_param(
485485
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s37indirect_in_captured_class_pair_paramTA"(
486-
sil public @indirect_in_captured_class_pair_param : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int {
486+
sil public @indirect_in_captured_class_pair_param : $@async @convention(thin) (Int, @in_guaranteed SwiftClassPair) -> Int {
487487
entry(%i : $Int, %p : $*SwiftClassPair):
488488
%0 = builtin "int_trap"() : $Never
489489
unreachable
490490
}
491491

492492
sil @partial_apply_stack_callee_guaranteed_indirect_in_class_pair_param : $@async @convention(thin) (@in SwiftClassPair) -> () {
493493
bb0(%x : $*SwiftClassPair):
494-
%f = function_ref @indirect_in_captured_class_pair_param : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int
495-
%p = partial_apply [callee_guaranteed] [on_stack] %f(%x) : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int
494+
%f = function_ref @indirect_in_captured_class_pair_param : $@async @convention(thin) (Int, @in_guaranteed SwiftClassPair) -> Int
495+
%p = partial_apply [callee_guaranteed] [on_stack] %f(%x) : $@async @convention(thin) (Int, @in_guaranteed SwiftClassPair) -> Int
496496
%u = function_ref @use_closure2 : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
497497
%r = apply %u(%p) : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
498498
dealloc_stack %p : $@noescape @async @callee_guaranteed (Int) ->(Int)
@@ -504,16 +504,16 @@ bb0(%x : $*SwiftClassPair):
504504

505505
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_stack_callee_guaranteed_indirect_in_constant_class_pair_param(
506506
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s46indirect_in_constant_captured_class_pair_paramTA"(
507-
sil public @indirect_in_constant_captured_class_pair_param : $@async @convention(thin) (Int, @in_constant SwiftClassPair) -> Int {
507+
sil public @indirect_in_constant_captured_class_pair_param : $@async @convention(thin) (Int, @in_guaranteed SwiftClassPair) -> Int {
508508
entry(%i : $Int, %ic : $*SwiftClassPair):
509509
%0 = builtin "int_trap"() : $Never
510510
unreachable
511511
}
512512

513513
sil @partial_apply_stack_callee_guaranteed_indirect_in_constant_class_pair_param : $@async @convention(thin) (@in SwiftClassPair) -> () {
514514
bb0(%x : $*SwiftClassPair):
515-
%f = function_ref @indirect_in_constant_captured_class_pair_param : $@async @convention(thin) (Int, @in_constant SwiftClassPair) -> Int
516-
%p = partial_apply [callee_guaranteed] [on_stack] %f(%x) : $@async @convention(thin) (Int, @in_constant SwiftClassPair) -> Int
515+
%f = function_ref @indirect_in_constant_captured_class_pair_param : $@async @convention(thin) (Int, @in_guaranteed SwiftClassPair) -> Int
516+
%p = partial_apply [callee_guaranteed] [on_stack] %f(%x) : $@async @convention(thin) (Int, @in_guaranteed SwiftClassPair) -> Int
517517
%u = function_ref @use_closure2 : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
518518
%r = apply %u(%p) : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
519519
dealloc_stack %p : $@noescape @async @callee_guaranteed (Int) ->(Int)

0 commit comments

Comments
 (0)