Skip to content

Commit a044644

Browse files
[IRGen] Fix missing musttail for dynamic replacement calls.
Fixes rdar://78284346. (Found when trying to land musttail verification. :D)
1 parent 94593e4 commit a044644

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
@@ -2955,6 +2955,10 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) {
29552955
FunctionPointer(fnType, typeFnPtr, authInfo, signature)
29562956
.getAsFunction(IGF),
29572957
forwardedArgs);
2958+
Res->setTailCall();
2959+
if (f->isAsync()) {
2960+
Res->setTailCallKind(IGF.IGM.AsyncTailCallKind);
2961+
}
29582962

29592963
if (implFn->getReturnType()->isVoidTy())
29602964
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)