Skip to content

Commit 74da05c

Browse files
committed
increase strictness of hop_to_executor test
Added an implicit CHECK-NOT to catch any unexpected hop_to_executor instructions in the output of SILGen.
1 parent 05f03b0 commit 74da05c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

test/SILGen/hop_to_executor.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-silgen %s -module-name test -swift-version 5 -enable-experimental-concurrency | %FileCheck --enable-var-scope %s
1+
// RUN: %target-swift-frontend -emit-silgen %s -module-name test -swift-version 5 -enable-experimental-concurrency | %FileCheck --enable-var-scope %s --implicit-check-not 'hop_to_executor {{%[0-9]+}}'
22
// REQUIRES: concurrency
33

44

@@ -45,7 +45,14 @@ actor MyActor {
4545
await callee(p)
4646
}
4747

48+
///// MyActor.testClosure()
49+
// CHECK: sil hidden [ossa] @$s4test7MyActorC0A7ClosureSiyYaF : $@convention(method) @async (@guaranteed MyActor) -> Int {
50+
// CHECK: hop_to_executor [[A:%[0-9]+]] : $MyActor
51+
// CHECK: {{%[0-9]+}} = apply
52+
// CHECK: hop_to_executor [[A]] : $MyActor
53+
// CHECK: } // end sil function '$s4test7MyActorC0A7ClosureSiyYaF'
4854

55+
///// closure #1 in MyActor.testClosure()
4956
// CHECK-LABEL: sil private [ossa] @$s4test7MyActorC0A7ClosureSiyYaFSiyYaXEfU_ : $@convention(thin) @async (@guaranteed MyActor) -> Int {
5057
// CHECK: [[COPIED_SELF:%[0-9]+]] = copy_value %0 : $MyActor
5158
// CHECK: [[BORROWED_SELF:%[0-9]+]] = begin_borrow [[COPIED_SELF]] : $MyActor
@@ -86,6 +93,14 @@ struct GlobalActor {
8693
func testGlobalActor() async {
8794
}
8895

96+
///// testGlobalActorWithClosure()
97+
// CHECK: sil hidden [ossa] @$s4test0A22GlobalActorWithClosureyyYaF : $@convention(thin) @async () -> () {
98+
// CHECK: hop_to_executor [[A:%[0-9]+]] : $MyActor
99+
// CHECK: {{%[0-9]+}} = apply
100+
// CHECK: hop_to_executor [[A]] : $MyActor
101+
// CHECK: // end sil function '$s4test0A22GlobalActorWithClosureyyYaF'
102+
103+
///// closure #1 in testGlobalActorWithClosure()
89104
// CHECK-LABEL: sil private [ossa] @$s4test0A22GlobalActorWithClosureyyYaFyyYaXEfU_ : $@convention(thin) @async () -> () {
90105
// CHECK: [[F:%[0-9]+]] = function_ref @$s4test11GlobalActorV6sharedAA02MyC0Cvau : $@convention(thin) () -> Builtin.RawPointer
91106
// CHECK: [[P:%[0-9]+]] = apply [[F]]() : $@convention(thin) () -> Builtin.RawPointer
@@ -129,14 +144,11 @@ actor BlueActorImpl {
129144
// CHECK-LABEL: sil hidden [ossa] @$s4test13BlueActorImplC4poke6personyAA03RedcD0C_tYaF : $@convention(method) @async (@guaranteed RedActorImpl, @guaranteed BlueActorImpl) -> () {
130145
// CHECK: bb0([[RED:%[0-9]+]] : @guaranteed $RedActorImpl, [[BLUE:%[0-9]+]] : @guaranteed $BlueActorImpl):
131146
// CHECK: hop_to_executor [[BLUE]] : $BlueActorImpl
132-
// CHECK-NOT: hop_to_executor
133147
// CHECK: [[INTARG:%[0-9]+]] = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
134-
// CHECK-NOT: hop_to_executor
135148
// CHECK: [[METH:%[0-9]+]] = class_method [[RED]] : $RedActorImpl, #RedActorImpl.hello : (isolated RedActorImpl) -> (Int) -> (), $@convention(method) (Int, @guaranteed RedActorImpl) -> ()
136149
// CHECK: hop_to_executor [[RED]] : $RedActorImpl
137150
// CHECK-NEXT: {{%[0-9]+}} = apply [[METH]]([[INTARG]], [[RED]]) : $@convention(method) (Int, @guaranteed RedActorImpl) -> ()
138151
// CHECK-NEXT: hop_to_executor [[BLUE]] : $BlueActorImpl
139-
// CHECK-NOT: hop_to_executor
140152
// CHECK: } // end sil function '$s4test13BlueActorImplC4poke6personyAA03RedcD0C_tYaF'
141153
func poke(person red : RedActorImpl) async {
142154
await red.hello(42)
@@ -203,31 +215,26 @@ struct BlueActor {
203215
// CHECK: destroy_value [[R]] : $RedActorImpl
204216
// CHECK: end_borrow [[BLUEEXE]] : $BlueActorImpl
205217
// CHECK: destroy_value [[B]] : $BlueActorImpl
206-
// CHECK-NOT: hop_to_executor
207218
// CHECK: } // end sil function '$s4test6blueFnyyYaF'
208219
@BlueActor func blueFn() async {
209220
await redFn(100)
210221
}
211222

212223
// CHECK-LABEL: sil hidden [ossa] @$s4test20unspecifiedAsyncFuncyyYaF : $@convention(thin) @async () -> () {
213-
// CHECK-NOT: hop_to_executor
214224
// CHECK: [[BORROW:%[0-9]+]] = begin_borrow {{%[0-9]+}} : $RedActorImpl
215225
// CHECK-NEXT: [[PREV_EXEC:%.*]] = builtin "getCurrentExecutor"()
216226
// CHECK-NEXT: hop_to_executor [[BORROW]] : $RedActorImpl
217227
// CHECK-NEXT: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}) : $@convention(thin) (Int) -> ()
218228
// CHECK-NEXT: hop_to_executor [[PREV_EXEC]]
219229
// CHECK-NEXT: end_borrow [[BORROW]] : $RedActorImpl
220-
// CHECK-NOT: hop_to_executor
221230
// CHECK: } // end sil function '$s4test20unspecifiedAsyncFuncyyYaF'
222231
func unspecifiedAsyncFunc() async {
223232
await redFn(200)
224233
}
225234

226235
// CHECK-LABEL: sil hidden [ossa] @$s4test27anotherUnspecifiedAsyncFuncyyAA12RedActorImplCYaF : $@convention(thin) @async (@guaranteed RedActorImpl) -> () {
227236
// CHECK: bb0([[RED:%[0-9]+]] : @guaranteed $RedActorImpl):
228-
// CHECK-NOT: hop_to_executor
229237
// CHECK: [[INTARG:%[0-9]+]] = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
230-
// CHECK-NOT: hop_to_executor
231238
// CHECK: [[METH:%[0-9]+]] = class_method [[RED]] : $RedActorImpl, #RedActorImpl.hello : (isolated RedActorImpl) -> (Int) -> (), $@convention(method) (Int, @guaranteed RedActorImpl) -> ()
232239
// CHECK-NEXT: [[PREV_EXEC:%.*]] = builtin "getCurrentExecutor"()
233240
// CHECK-NEXT: hop_to_executor [[RED]] : $RedActorImpl

0 commit comments

Comments
 (0)