Skip to content

Commit 67bcb66

Browse files
[IRGen] Fix missing musttail call for dynamic functions.
1 parent b78e3b8 commit 67bcb66

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2613,7 +2613,12 @@ void IRGenModule::createReplaceableProlog(IRGenFunction &IGF, SILFunction *f) {
26132613
FunctionPointer(silFunctionType, realReplFn, authInfo, signature)
26142614
.getAsFunction(IGF),
26152615
forwardedArgs);
2616-
Res->setTailCall();
2616+
if (Res->getCallingConv() == llvm::CallingConv::SwiftTail &&
2617+
Res->getCaller()->getCallingConv() == llvm::CallingConv::SwiftTail) {
2618+
Res->setTailCallKind(IGF.IGM.AsyncTailCallKind);
2619+
} else {
2620+
Res->setTailCall();
2621+
}
26172622
if (IGF.CurFn->getReturnType()->isVoidTy())
26182623
IGF.Builder.CreateRetVoid();
26192624
else

test/IRGen/async/run-call-dynamic-void_to_void.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import _Concurrency
1717
// CHECK-LL: @"$s4main3runyyYFTu" = hidden global %swift.async_func_pointer
1818

1919
// CHECK-LL: define hidden swift{{(tail)?}}cc void @"$s4main3runyyYF"(%swift.context* swiftasync {{%[0-9]+}}) {{#[0-9]*}}
20+
// CHECK-LL: musttail call swifttailcc void
2021
dynamic func run() async {
2122
print("running")
2223
}

0 commit comments

Comments
 (0)