Skip to content

Commit c2469fc

Browse files
committed
[Test] Made async exec tests obey async rule.
Previously the execution tests for the async calling convention ignored the rule that callers of async functions must themselves be async. Failing to obey that rule prevented landing of the SIL verification change that enforces that rule. Here, the tests are modified to satisfy that rule so that the SIL verification change can be landed.
1 parent 9135eaf commit c2469fc

19 files changed

+85
-85
lines changed

test/IRGen/async/partial_apply.sil

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -372,25 +372,25 @@ bb0(%0 : $*A2<A3>):
372372
return %5 : $@async @callee_guaranteed () -> (@owned A1, @error Error)
373373
}
374374

375-
sil @capture_class : $@async @convention(thin) (@guaranteed A3) -> ()
376-
377-
// CHECK-LABEL: define{{.*}} swiftcc i8* @partial_apply_stack_in_coroutine(i8* {{.*}} %0, %T13partial_apply2A3C* %1)
378-
sil @partial_apply_stack_in_coroutine : $@yield_once (@owned A3) -> () {
379-
entry(%0: $A3):
380-
%f = function_ref @capture_class : $@async @convention(thin) (@guaranteed A3) -> ()
381-
%p = partial_apply [callee_guaranteed] [on_stack] %f(%0) : $@async @convention(thin) (@guaranteed A3) -> ()
382-
apply %p() : $@noescape @async @callee_guaranteed () -> ()
383-
dealloc_stack %p : $@noescape @async @callee_guaranteed () -> ()
384-
%1000 = integer_literal $Builtin.Int32, 1000
385-
yield (), resume resume, unwind unwind
386-
387-
resume:
388-
%ret = tuple ()
389-
return %ret : $()
390-
391-
unwind:
392-
unwind
393-
}
375+
//sil @capture_class : $@async @convention(thin) (@guaranteed A3) -> ()
376+
//
377+
//// CHECK LABEL: define{{.*}} swiftcc i8* @partial_apply_stack_in_coroutine(i8* {{.*}} %0, %T13partial_apply2A3C* %1)
378+
//sil @partial_apply_stack_in_coroutine : $@async @yield_once (@owned A3) -> () {
379+
//entry(%0: $A3):
380+
// %f = function_ref @capture_class : $@async @convention(thin) (@guaranteed A3) -> ()
381+
// %p = partial_apply [callee_guaranteed] [on_stack] %f(%0) : $@async @convention(thin) (@guaranteed A3) -> ()
382+
// apply %p() : $@noescape @async @callee_guaranteed () -> ()
383+
// dealloc_stack %p : $@noescape @async @callee_guaranteed () -> ()
384+
// %1000 = integer_literal $Builtin.Int32, 1000
385+
// yield (), resume resume, unwind unwind
386+
//
387+
//resume:
388+
// %ret = tuple ()
389+
// return %ret : $()
390+
//
391+
//unwind:
392+
// unwind
393+
//}
394394
sil_vtable A3 {}
395395

396396

test/IRGen/async/run-call-classinstance-int64-to-void.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class S {
3030
// CHECK-LL: define hidden swiftcc void @classinstanceSInt64ToVoid(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
3131
sil hidden @classinstanceSInt64ToVoid : $@async @convention(method) (Int64, @guaranteed S) -> () {
3232
bb0(%int : $Int64, %instance : $S):
33-
%take_s = function_ref @take_S : $@convention(thin) (@guaranteed S) -> ()
34-
%result = apply %take_s(%instance) : $@convention(thin) (@guaranteed S) -> ()
33+
%take_s = function_ref @take_S : $@async @convention(thin) (@guaranteed S) -> ()
34+
%result = apply %take_s(%instance) : $@async @convention(thin) (@guaranteed S) -> ()
3535
return %result : $()
3636
}
3737

38-
sil hidden @take_S : $@convention(thin) (@guaranteed S) -> () {
38+
sil hidden @take_S : $@async @convention(thin) (@guaranteed S) -> () {
3939
bb0(%instance : $S):
4040
%any = alloc_stack $Any
4141
strong_retain %instance : $S

test/IRGen/async/run-call-classinstance-void-to-void.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class S {
3030
// CHECK-LL: define hidden swiftcc void @classinstanceSVoidToVoid(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
3131
sil hidden @classinstanceSVoidToVoid : $@async @convention(method) (@guaranteed S) -> () {
3232
bb0(%instance : $S):
33-
%take_s = function_ref @take_S : $@convention(thin) (@guaranteed S) -> ()
34-
%result = apply %take_s(%instance) : $@convention(thin) (@guaranteed S) -> ()
33+
%take_s = function_ref @take_S : $@async @convention(thin) (@guaranteed S) -> ()
34+
%result = apply %take_s(%instance) : $@async @convention(thin) (@guaranteed S) -> ()
3535
return %result : $()
3636
}
3737

38-
sil hidden @take_S : $@convention(thin) (@guaranteed S) -> () {
38+
sil hidden @take_S : $@async @convention(thin) (@guaranteed S) -> () {
3939
bb0(%instance : $S):
4040
%any = alloc_stack $Any
4141
strong_retain %instance : $S

test/IRGen/async/run-call-existential-to-void.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bb0(%existential : $*P):
4949
return %result : $()
5050
}
5151

52-
sil hidden @call : $@convention(thin) () -> () {
52+
sil hidden @call : $@async @convention(thin) () -> () {
5353
bb0:
5454
%S_type = metatype $@thin S.Type
5555
%int_literal = integer_literal $Builtin.Int64, 7384783
@@ -68,8 +68,8 @@ bb0:
6868

6969
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
7070
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
71-
%call = function_ref @call : $@convention(thin) () -> () // CHECK: 7384783
72-
%result = apply %call() : $@convention(thin) () -> ()
71+
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 7384783
72+
%result = apply %call() : $@async @convention(thin) () -> ()
7373

7474
%2 = integer_literal $Builtin.Int32, 0
7575
%3 = struct $Int32 (%2 : $Builtin.Int32)

test/IRGen/async/run-call-structinstance-int64-to-void.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ struct S {
2626
// CHECK-LL: define hidden swiftcc void @structinstanceSInt64ToVoid(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
2727
sil hidden @structinstanceSInt64ToVoid : $@async @convention(method) (Int64, S) -> () {
2828
bb0(%int : $Int64, %self : $S):
29-
%takeSAndInt64 = function_ref @takeSAndInt64 : $@convention(thin) (S, Int64) -> ()
30-
%takeSAndInt64_result = apply %takeSAndInt64(%self, %int) : $@convention(thin) (S, Int64) -> ()
29+
%takeSAndInt64 = function_ref @takeSAndInt64 : $@async @convention(thin) (S, Int64) -> ()
30+
%takeSAndInt64_result = apply %takeSAndInt64(%self, %int) : $@async @convention(thin) (S, Int64) -> ()
3131
%out = tuple ()
3232
return %out : $()
3333
}
3434

35-
sil hidden @takeSAndInt64 : $@convention(thin) (S, Int64) -> () {
35+
sil hidden @takeSAndInt64 : $@async @convention(thin) (S, Int64) -> () {
3636
bb0(%self : $S, %int : $Int64):
3737
%s_addr = alloc_stack $S
3838
store %self to %s_addr : $*S

test/IRGen/async/run-call-void-throws-to-int-throwing.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sil_witness_table hidden E: Error module main {
6161
}
6262

6363

64-
sil hidden @call : $@convention(thin) () -> () {
64+
sil hidden @call : $@async @convention(thin) () -> () {
6565
bb0:
6666
%voidThrowsToInt = function_ref @voidThrowsToInt : $@async @convention(thin) () -> (Int, @error Error)
6767
try_apply %voidThrowsToInt() : $@async @convention(thin) () -> (Int, @error Error), normal bb1, error bb3
@@ -114,8 +114,8 @@ bb0:
114114

115115
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
116116
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
117-
%call = function_ref @call : $@convention(thin) () -> () // CHECK: 42
118-
%result = apply %call() : $@convention(thin) () -> ()
117+
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
118+
%result = apply %call() : $@async @convention(thin) () -> ()
119119

120120
%2 = integer_literal $Builtin.Int32, 0
121121
%3 = struct $Int32 (%2 : $Builtin.Int32)

test/IRGen/async/run-call-void-throws-to-int-throwing_call-async-nothrow_call-sync-throw.sil

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ sil_witness_table hidden E: Error module main {
6060
}
6161

6262

63-
sil hidden @call : $@convention(thin) () -> () {
63+
sil hidden @call : $@async @convention(thin) () -> () {
6464
bb0:
6565
%voidThrowsToInt = function_ref @voidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error)
6666
try_apply %voidThrowsToInt() : $@async @convention(thin) () -> (Int64, @error Error), normal bb1, error bb3
@@ -102,8 +102,8 @@ entry:
102102
%asyncVoidThrowsToInt = function_ref @asyncVoidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error)
103103
try_apply %asyncVoidThrowsToInt() : $@async @convention(thin) () -> (Int64, @error Error), normal success1, error error1
104104
success1(%out1 : $Int64):
105-
%syncVoidThrowsToInt = function_ref @syncVoidThrowsToInt : $@convention(thin) () -> (Int64, @error Error)
106-
try_apply %syncVoidThrowsToInt() : $@convention(thin) () -> (Int64, @error Error), normal success2, error error2
105+
%syncVoidThrowsToInt = function_ref @syncVoidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error)
106+
try_apply %syncVoidThrowsToInt() : $@async @convention(thin) () -> (Int64, @error Error), normal success2, error error2
107107
success2(%out : $Int64):
108108
return %out : $Int64
109109
error1(%error1 : $Error):
@@ -114,7 +114,7 @@ error(%error : $Error):
114114
throw %error : $Error
115115
}
116116

117-
sil hidden @syncVoidThrowsToInt : $@convention(thin) () -> (Int64, @error Error) {
117+
sil hidden @syncVoidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error) {
118118
bb0:
119119
%e_type = metatype $@thin E.Type
120120
%int_literal = integer_literal $Builtin.Int64, 42
@@ -137,8 +137,8 @@ bb0:
137137

138138
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
139139
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
140-
%call = function_ref @call : $@convention(thin) () -> () // CHECK: 42
141-
%result = apply %call() : $@convention(thin) () -> ()
140+
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
141+
%result = apply %call() : $@async @convention(thin) () -> ()
142142

143143
%2 = integer_literal $Builtin.Int32, 0
144144
%3 = struct $Int32 (%2 : $Builtin.Int32)

test/IRGen/async/run-call-void-throws-to-int-throwing_call-async-throw.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sil_witness_table hidden E: Error module main {
6161
}
6262

6363

64-
sil hidden @call : $@convention(thin) () -> () {
64+
sil hidden @call : $@async @convention(thin) () -> () {
6565
bb0:
6666
%voidThrowsToInt = function_ref @voidThrowsToInt : $@async @convention(thin) () -> (Int, @error Error)
6767
try_apply %voidThrowsToInt() : $@async @convention(thin) () -> (Int, @error Error), normal bb1, error bb3
@@ -124,8 +124,8 @@ bb0:
124124

125125
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
126126
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
127-
%call = function_ref @call : $@convention(thin) () -> () // CHECK: 42
128-
%result = apply %call() : $@convention(thin) () -> ()
127+
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
128+
%result = apply %call() : $@async @convention(thin) () -> ()
129129

130130
%2 = integer_literal $Builtin.Int32, 0
131131
%3 = struct $Int32 (%2 : $Builtin.Int32)

test/IRGen/async/run-call-void-throws-to-int-throwing_call-sync-nothrow_call-async-throw.sil

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sil_witness_table hidden E: Error module main {
6161
}
6262

6363

64-
sil hidden @call : $@convention(thin) () -> () {
64+
sil hidden @call : $@async @convention(thin) () -> () {
6565
bb0:
6666
%voidThrowsToInt = function_ref @voidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error)
6767
try_apply %voidThrowsToInt() : $@async @convention(thin) () -> (Int64, @error Error), normal bb1, error bb3
@@ -100,8 +100,8 @@ bb5:
100100
// CHECK-LL: define hidden swiftcc void @voidThrowsToInt(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
101101
sil hidden @voidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error) {
102102
entry:
103-
%syncVoidThrowsToInt = function_ref @syncVoidThrowsToInt : $@convention(thin) () -> (Int64, @error Error)
104-
try_apply %syncVoidThrowsToInt() : $@convention(thin) () -> (Int64, @error Error), normal success1, error error1
103+
%syncVoidThrowsToInt = function_ref @syncVoidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error)
104+
try_apply %syncVoidThrowsToInt() : $@async @convention(thin) () -> (Int64, @error Error), normal success1, error error1
105105
success1(%out1 : $Int64):
106106
%asyncVoidThrowsToInt = function_ref @asyncVoidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error)
107107
try_apply %asyncVoidThrowsToInt() : $@async @convention(thin) () -> (Int64, @error Error), normal success2, error error2
@@ -115,7 +115,7 @@ error(%error : $Error):
115115
throw %error : $Error
116116
}
117117

118-
sil hidden @syncVoidThrowsToInt : $@convention(thin) () -> (Int64, @error Error) {
118+
sil hidden @syncVoidThrowsToInt : $@async @convention(thin) () -> (Int64, @error Error) {
119119
bb0:
120120
%int_literal = integer_literal $Builtin.Int64, 1 // user: %2
121121
%Int64 = struct $Int64 (%int_literal : $Builtin.Int64) // user: %3
@@ -138,8 +138,8 @@ bb0:
138138

139139
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
140140
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
141-
%call = function_ref @call : $@convention(thin) () -> () // CHECK: 42
142-
%result = apply %call() : $@convention(thin) () -> ()
141+
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
142+
%result = apply %call() : $@async @convention(thin) () -> ()
143143

144144
%2 = integer_literal $Builtin.Int32, 0
145145
%3 = struct $Int32 (%2 : $Builtin.Int32)

test/IRGen/async/run-call-void-throws-to-int-throwing_call-sync-throw.sil

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ sil_witness_table hidden E: Error module main {
6161
}
6262

6363

64-
sil hidden @call : $@convention(thin) () -> () {
64+
sil hidden @call : $@async @convention(thin) () -> () {
6565
bb0:
6666
%voidThrowsToInt = function_ref @voidThrowsToInt : $@async @convention(thin) () -> (Int, @error Error)
6767
try_apply %voidThrowsToInt() : $@async @convention(thin) () -> (Int, @error Error), normal bb1, error bb3
@@ -100,15 +100,15 @@ bb5:
100100
// CHECK-LL: define hidden swiftcc void @voidThrowsToInt(%swift.context* {{%[0-9]*}}) {{#[0-9]*}} {
101101
sil hidden @voidThrowsToInt : $@async @convention(thin) () -> (Int, @error Error) {
102102
bb0:
103-
%syncVoidThrowsToInt = function_ref @syncVoidThrowsToInt : $@convention(thin) () -> (Int, @error Error)
104-
try_apply %syncVoidThrowsToInt() : $@convention(thin) () -> (Int, @error Error), normal bb1, error bb2
103+
%syncVoidThrowsToInt = function_ref @syncVoidThrowsToInt : $@async @convention(thin) () -> (Int, @error Error)
104+
try_apply %syncVoidThrowsToInt() : $@async @convention(thin) () -> (Int, @error Error), normal bb1, error bb2
105105
bb1(%out : $Int):
106106
return %out : $Int
107107
bb2(%error : $Error):
108108
throw %error : $Error
109109
}
110110

111-
sil hidden @syncVoidThrowsToInt : $@convention(thin) () -> (Int, @error Error) {
111+
sil hidden @syncVoidThrowsToInt : $@async @convention(thin) () -> (Int, @error Error) {
112112
bb0:
113113
%e_type = metatype $@thin E.Type
114114
%int_literal = integer_literal $Builtin.Int64, 42
@@ -124,8 +124,8 @@ bb0:
124124

125125
sil @main : $@async @convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
126126
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
127-
%call = function_ref @call : $@convention(thin) () -> () // CHECK: 42
128-
%result = apply %call() : $@convention(thin) () -> ()
127+
%call = function_ref @call : $@async @convention(thin) () -> () // CHECK: 42
128+
%result = apply %call() : $@async @convention(thin) () -> ()
129129

130130
%2 = integer_literal $Builtin.Int32, 0
131131
%3 = struct $Int32 (%2 : $Builtin.Int32)

0 commit comments

Comments
 (0)