Skip to content

Commit

Permalink
[AArch64] Preserve X8 for thunks ending in variadic musttail calls
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rnk committed May 24, 2019
1 parent ed595e8 commit b7a78c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Expand Up @@ -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));
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/AArch64/vararg-tallcall.ll
Expand Up @@ -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

0 comments on commit b7a78c7

Please sign in to comment.