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(
6138
6138
}
6139
6139
6140
6140
void 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
+ }
6141
6146
assert (i->getTargetExecutor ()->getType ().is <BuiltinExecutorType>());
6142
6147
llvm::Value *resumeFn = Builder.CreateIntrinsicCall (
6143
6148
llvm::Intrinsic::coro_async_resume, {});
Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ class SILInlineCloner
288
288
289
289
void visitDebugValueInst (DebugValueInst *Inst);
290
290
void visitDebugValueAddrInst (DebugValueAddrInst *Inst);
291
+ void visitHopToExecutorInst (HopToExecutorInst *Inst);
291
292
292
293
void visitTerminator (SILBasicBlock *BB);
293
294
@@ -620,7 +621,15 @@ void SILInlineCloner::visitDebugValueAddrInst(DebugValueAddrInst *Inst) {
620
621
621
622
return SILCloner<SILInlineCloner>::visitDebugValueAddrInst (Inst);
622
623
}
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
+ }
623
630
631
+ return SILCloner<SILInlineCloner>::visitHopToExecutorInst (Inst);
632
+ }
624
633
const SILDebugScope *
625
634
SILInlineCloner::getOrCreateInlineScope (const SILDebugScope *CalleeScope) {
626
635
if (!CalleeScope)
Original file line number Diff line number Diff line change @@ -1481,3 +1481,22 @@ bb0:
1481
1481
return %r : $()
1482
1482
}
1483
1483
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):
994
994
return %30 : $X
995
995
}
996
996
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