[AArch64] Preserve X8 for thunks ending in variadic musttail calls

Summary:
On Windows, X8 may be used to pass in the address of an aggregate that
is returned indirectly. Therefore, it should be forwarded to variadic
musttail calls and preserved in thunks.

Fixes PR41997

Reviewers: mgrang, efriedma

Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62344

llvm-svn: 361585
This commit is contained in:
Reid Kleckner 2019-05-24 01:27:20 +00:00
parent ed595e8627
commit b7a78c7dff
2 changed files with 9 additions and 3 deletions

View File

@ -3207,6 +3207,12 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
FuncInfo->getForwardedMustTailRegParms();
CCInfo.analyzeMustTailForwardedRegisters(Forwards, RegParmTypes,
CC_AArch64_AAPCS);
// Conservatively forward X8, since it might be used for aggregate return.
if (!CCInfo.isAllocated(AArch64::X8)) {
unsigned X8VReg = MF.addLiveIn(AArch64::X8, &AArch64::GPR64RegClass);
Forwards.push_back(ForwardedRegister(X8VReg, AArch64::X8, MVT::i64));
}
}
}

View File

@ -28,7 +28,7 @@ entry:
attributes #1 = { noinline optnone "thunk" }
; CHECK: mov v16.16b, v0.16b
; CHECK: ldr x8, [x0]
; CHECK: ldr x8, [x8]
; CHECK: ldr x9, [x0]
; CHECK: ldr x9, [x9]
; CHECK: mov v0.16b, v16.16b
; CHECK: br x8
; CHECK: br x9