[PATCH] D62344: [AArch64] Preserve X8 for thunks ending in variadic musttail calls
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 13:53:48 PDT 2019
rnk created this revision.
rnk added reviewers: mgrang, efriedma.
Herald added subscribers: hiraditya, kristof.beyls, javed.absar.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62344
Files:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/vararg-tallcall.ll
Index: llvm/test/CodeGen/AArch64/vararg-tallcall.ll
===================================================================
--- llvm/test/CodeGen/AArch64/vararg-tallcall.ll
+++ llvm/test/CodeGen/AArch64/vararg-tallcall.ll
@@ -28,7 +28,7 @@
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
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -3207,6 +3207,12 @@
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));
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62344.201059.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190523/36861880/attachment.bin>
More information about the llvm-commits
mailing list