Skip to content

Commit 9fc1171

Browse files
committed
[concurrency] SILGen: only emit hop_to_executor instructions in async functions.
1 parent f3de3b4 commit 9fc1171

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ void SILGenFunction::emitProlog(CaptureInfo captureInfo,
451451
}
452452
}
453453

454+
if (!F.isAsync())
455+
return;
456+
454457
if (auto *funcDecl =
455458
dyn_cast_or_null<AbstractFunctionDecl>(FunctionDC->getAsDecl())) {
456459
auto actorIsolation = getActorIsolation(funcDecl);

test/SILGen/hop_to_executor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ actor class MyActor {
4747
await callee(p)
4848
}
4949

50+
// CHECK-LABEL: sil hidden [ossa] @$s4test7MyActorC13dontInsertHTESiyF : $@convention(method) (@guaranteed MyActor) -> Int {
51+
// CHECK-NOT: hop_to_executor
52+
// CHECK: } // end sil function '$s4test7MyActorC13dontInsertHTESiyF'
53+
func dontInsertHTE() -> Int {
54+
return p
55+
}
56+
5057
init() {
5158
p = 27
5259
}

0 commit comments

Comments
 (0)