File tree Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -6138,6 +6138,11 @@ void IRGenSILFunction::visitCheckedCastAddrBranchInst(
61386138}
61396139
61406140void IRGenSILFunction::visitHopToExecutorInst (HopToExecutorInst *i) {
6141+ if (!i->getFunction ()->isAsync ()) {
6142+ // This should never occur.
6143+ assert (false && " The hop_to_executor should have been eliminated" );
6144+ return ;
6145+ }
61416146 assert (i->getTargetExecutor ()->getType ().is <BuiltinExecutorType>());
61426147 llvm::Value *resumeFn = Builder.CreateIntrinsicCall (
61436148 llvm::Intrinsic::coro_async_resume, {});
Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ class SILInlineCloner
288288
289289 void visitDebugValueInst (DebugValueInst *Inst);
290290 void visitDebugValueAddrInst (DebugValueAddrInst *Inst);
291+ void visitHopToExecutorInst (HopToExecutorInst *Inst);
291292
292293 void visitTerminator (SILBasicBlock *BB);
293294
@@ -620,7 +621,15 @@ void SILInlineCloner::visitDebugValueAddrInst(DebugValueAddrInst *Inst) {
620621
621622 return SILCloner<SILInlineCloner>::visitDebugValueAddrInst (Inst);
622623}
624+ void SILInlineCloner::visitHopToExecutorInst (HopToExecutorInst *Inst) {
625+ // Drop hop_to_executor in non async functions.
626+ if (!Apply.getFunction ()->isAsync ()) {
627+ assert (Apply.isNonAsync ());
628+ return ;
629+ }
623630
631+ return SILCloner<SILInlineCloner>::visitHopToExecutorInst (Inst);
632+ }
624633const SILDebugScope *
625634SILInlineCloner::getOrCreateInlineScope (const SILDebugScope *CalleeScope) {
626635 if (!CalleeScope)
Original file line number Diff line number Diff line change @@ -1481,3 +1481,22 @@ bb0:
14811481 return %r : $()
14821482}
14831483
1484+ sil [transparent] @hop_to_executor : $@convention(thin) @async (@guaranteed Builtin.Executor) -> () {
1485+ entry(%executor: $Builtin.Executor):
1486+ hop_to_executor %executor : $Builtin.Executor
1487+ %r = tuple ()
1488+ return %r : $()
1489+ }
1490+
1491+ // CHECK-LABEL: sil @test_inline_nonasync
1492+ // CHECK-NOT: hop_to_executor
1493+ // CHECK-NOT: apply
1494+ // CHECK: } // end sil function 'test_inline_nonasync'
1495+
1496+ sil @test_inline_nonasync : $@convention(thin) (@guaranteed Builtin.Executor) -> () {
1497+ entry(%executor: $Builtin.Executor):
1498+ %f = function_ref @hop_to_executor : $@convention(thin) @async (@guaranteed Builtin.Executor) -> ()
1499+ %c = apply [noasync] %f(%executor) : $@convention(thin) @async (@guaranteed Builtin.Executor) -> ()
1500+ %r = tuple ()
1501+ return %r : $()
1502+ }
Original file line number Diff line number Diff line change @@ -994,3 +994,22 @@ bb0(%1 : $@thick X.Type):
994994 return %30 : $X
995995}
996996
997+ sil @hop_to_executor : $@convention(thin) @async (@guaranteed Builtin.Executor) -> () {
998+ entry(%executor: $Builtin.Executor):
999+ hop_to_executor %executor : $Builtin.Executor
1000+ %r = tuple ()
1001+ return %r : $()
1002+ }
1003+
1004+ // CHECK-LABEL: sil @test_inline_nonasync
1005+ // CHECK-NOT: hop_to_executor
1006+ // CHECK-NOT: apply
1007+ // CHECK: } // end sil function 'test_inline_nonasync'
1008+
1009+ sil @test_inline_nonasync : $@convention(thin) (@guaranteed Builtin.Executor) -> () {
1010+ entry(%executor: $Builtin.Executor):
1011+ %f = function_ref @hop_to_executor : $@convention(thin) @async (@guaranteed Builtin.Executor) -> ()
1012+ %c = apply [noasync] %f(%executor) : $@convention(thin) @async (@guaranteed Builtin.Executor) -> ()
1013+ %r = tuple ()
1014+ return %r : $()
1015+ }
You can’t perform that action at this time.
0 commit comments