Skip to content

Commit a049fc0

Browse files
Merge pull request swiftlang#36704 from nate-chandler/rdar75806862
[Test] Restore tests for async capture of @in and @in_constant args.
2 parents 1859b3c + 0ba0464 commit a049fc0

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

test/IRGen/async/partial_apply.sil

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ bb0(%x : $*SwiftClass):
128128
return %p : $@async @callee_guaranteed (Int) -> Int
129129
}
130130

131+
sil public @indirect_consumed_captured_class_param : $@async @convention(thin) (Int, @in SwiftClass) -> Int {
132+
entry(%i : $Int, %c : $*SwiftClass):
133+
%0 = builtin "int_trap"() : $Never
134+
unreachable
135+
}
136+
137+
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_indirect_consumed_class_param(
138+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s38indirect_consumed_captured_class_paramTA"(
139+
140+
sil @partial_apply_indirect_consumed_class_param : $@async @convention(thin) (@in SwiftClass) -> @async @callee_guaranteed (Int) -> Int {
141+
bb0(%x : $*SwiftClass):
142+
%f = function_ref @indirect_consumed_captured_class_param : $@async @convention(thin) (Int, @in SwiftClass) -> Int
143+
%p = partial_apply [callee_guaranteed] %f(%x) : $@async @convention(thin) (Int, @in SwiftClass) -> Int
144+
return %p : $@async @callee_guaranteed (Int) -> Int
145+
}
146+
131147
/*****************************************************************************/
132148
/* A non-trivial capture. Indirect applications can directly reference the */
133149
/* field from the partial apply context. */
@@ -168,6 +184,53 @@ bb0(%x : $*SwiftClassPair):
168184
return %p : $@async @callee_guaranteed (Int) -> Int
169185
}
170186

187+
sil public @indirect_consumed_captured_class_pair_param : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int {
188+
entry(%i : $Int, %c : $*SwiftClassPair):
189+
%0 = builtin "int_trap"() : $Never
190+
unreachable
191+
}
192+
193+
194+
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_indirect_consumed_class_pair_param(
195+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s43indirect_consumed_captured_class_pair_paramTA"(
196+
197+
sil @partial_apply_indirect_consumed_class_pair_param : $@async @convention(thin) (@in SwiftClassPair) -> @async @callee_guaranteed (Int) -> Int {
198+
bb0(%x : $*SwiftClassPair):
199+
%f = function_ref @indirect_consumed_captured_class_pair_param : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int
200+
%p = partial_apply [callee_guaranteed] %f(%x) : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int
201+
return %p : $@async @callee_guaranteed (Int) -> Int
202+
}
203+
204+
sil public @captured_fixed_and_dependent_params : $@async @convention(thin) <A> (@owned SwiftClass, @in A, Int) -> () {
205+
entry(%c : $SwiftClass, %a : $*A, %i : $Int):
206+
%0 = builtin "int_trap"() : $Never
207+
unreachable
208+
}
209+
210+
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_indirect_non_fixed_layout
211+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s35captured_fixed_and_dependent_paramsTA"(
212+
sil @partial_apply_indirect_non_fixed_layout : $@async @convention(thin) <T> (@owned SwiftClass, @in T, Int) -> @async @callee_guaranteed () -> () {
213+
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) -> ()
216+
return %p : $@async @callee_guaranteed () -> ()
217+
}
218+
219+
sil public @captured_dependent_out_param : $@async @convention(thin) <A> (@in A) -> @out A {
220+
entry(%o : $*A, %i : $*A):
221+
%0 = builtin "int_trap"() : $Never
222+
unreachable
223+
}
224+
225+
sil @partial_apply_with_out_param : $@async @convention(thin) <T> (@in T) -> @async @callee_guaranteed () -> @out T {
226+
bb0(%x : $*T):
227+
%f = function_ref @captured_dependent_out_param : $@async @convention(thin) <B> (@in B) -> @out B
228+
%p = partial_apply [callee_guaranteed] %f<T>(%x) : $@async @convention(thin) <C> (@in C) -> @out C
229+
return %p : $@async @callee_guaranteed () -> @out T
230+
}
231+
232+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s28captured_dependent_out_paramTA"(
233+
171234
sil @partial_apply_dynamic_with_out_param : $@async @convention(thin) <T> (Int32, @owned @async @callee_guaranteed (Int32) -> @out T) -> @async @callee_guaranteed () -> @out T {
172235
bb0(%x : $Int32, %f : $@async @callee_guaranteed (Int32) -> @out T):
173236
%p = partial_apply [callee_guaranteed] %f(%x) : $@async @callee_guaranteed (Int32) -> @out T
@@ -406,6 +469,47 @@ bb0(%x : $*SwiftClassPair):
406469
return %t : $()
407470
}
408471

472+
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_stack_callee_guaranteed_indirect_in_class_pair_param(
473+
474+
sil public @indirect_in_captured_class_pair_param : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int {
475+
entry(%i : $Int, %p : $*SwiftClassPair):
476+
%0 = builtin "int_trap"() : $Never
477+
unreachable
478+
}
479+
480+
sil @partial_apply_stack_callee_guaranteed_indirect_in_class_pair_param : $@async @convention(thin) (@in SwiftClassPair) -> () {
481+
bb0(%x : $*SwiftClassPair):
482+
%f = function_ref @indirect_in_captured_class_pair_param : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int
483+
%p = partial_apply [callee_guaranteed] [on_stack] %f(%x) : $@async @convention(thin) (Int, @in SwiftClassPair) -> Int
484+
%u = function_ref @use_closure2 : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
485+
%r = apply %u(%p) : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
486+
dealloc_stack %p : $@noescape @async @callee_guaranteed (Int) ->(Int)
487+
destroy_addr %x: $*SwiftClassPair
488+
%t = tuple()
489+
return %t : $()
490+
}
491+
492+
493+
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @partial_apply_stack_callee_guaranteed_indirect_in_constant_class_pair_param(
494+
495+
sil public @indirect_in_constant_captured_class_pair_param : $@async @convention(thin) (Int, @in_constant SwiftClassPair) -> Int {
496+
entry(%i : $Int, %ic : $*SwiftClassPair):
497+
%0 = builtin "int_trap"() : $Never
498+
unreachable
499+
}
500+
501+
sil @partial_apply_stack_callee_guaranteed_indirect_in_constant_class_pair_param : $@async @convention(thin) (@in SwiftClassPair) -> () {
502+
bb0(%x : $*SwiftClassPair):
503+
%f = function_ref @indirect_in_constant_captured_class_pair_param : $@async @convention(thin) (Int, @in_constant SwiftClassPair) -> Int
504+
%p = partial_apply [callee_guaranteed] [on_stack] %f(%x) : $@async @convention(thin) (Int, @in_constant SwiftClassPair) -> Int
505+
%u = function_ref @use_closure2 : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
506+
%r = apply %u(%p) : $@async @convention(thin) (@noescape @async @callee_guaranteed (Int) -> Int) -> ()
507+
dealloc_stack %p : $@noescape @async @callee_guaranteed (Int) ->(Int)
508+
destroy_addr %x: $*SwiftClassPair
509+
%t = tuple()
510+
return %t : $()
511+
}
512+
409513
sil public @closure : $@async @convention(thin) (@in_guaranteed ResilientInt, @guaranteed SwiftClass) -> () {
410514
entry(%i : $*ResilientInt, %c : $SwiftClass):
411515
%0 = builtin "int_trap"() : $Never
@@ -504,6 +608,8 @@ bb0(%thick : $@callee_guaranteed @async @convention(thick) (Int64, Int32) -> Int
504608
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s23generic_indirect_returnTA"(
505609
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s24generic_indirect_return2TA"(
506610
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s45indirect_guaranteed_captured_class_pair_paramTA.{{[0-9]+}}"(
611+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s37indirect_in_captured_class_pair_paramTA"(
612+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s46indirect_in_constant_captured_class_pair_paramTA"(
507613
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s12create_pa_f2Tw_"(
508614
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s12create_pa_f2Tw0_"(
509615

0 commit comments

Comments
 (0)