Skip to content

Commit 1aba91e

Browse files
[IRGen] Fix missing musttail for dynamic replacement calls.
Fixes rdar://78284346. (Found when trying to land musttail verification. :D) (cherry picked from commit a044644)
1 parent 9c9124e commit 1aba91e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,10 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) {
29532953
FunctionPointer(fnType, typeFnPtr, authInfo, signature)
29542954
.getAsFunction(IGF),
29552955
forwardedArgs);
2956+
Res->setTailCall();
2957+
if (f->isAsync()) {
2958+
Res->setTailCallKind(IGF.IGM.AsyncTailCallKind);
2959+
}
29562960

29572961
if (implFn->getReturnType()->isVoidTy())
29582962
IGF.Builder.CreateRetVoid();

test/IRGen/async_dynamic_replacement.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ internal func _replacement_number() async -> Int {
1414
// rdar://78284346 - Dynamic replacement should use musttail
1515
// for tail calls from swifttailcc to swifttailcc
1616
// CHECK-LABEL: define {{.*}} swifttailcc void @"$s25async_dynamic_replacement01_C7_numberSiyYaFTI"
17-
// CHECK-NOT: musttail
18-
// CHECK: call swifttailcc void
17+
// CHECK: musttail call swifttailcc void
1918
// CHECK-NEXT: ret void
2019

2120
public func calls_number() async -> Int {

0 commit comments

Comments
 (0)