release/23.x: [CodeGen][ARM64EC] Copy first four arguments to FP registers in vararg exit thunks (#209581) - #210315
Merged
Merged
Conversation
Member
Author
|
@efriedma-quic What do you think about merging this PR to the release branch? |
|
@llvm/pr-subscribers-backend-aarch64 Author: llvmbot ChangesBackport 9c6a9f5 Requested by: @cjacek Full diff: https://github.com/llvm/llvm-project/pull/210315.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d6f2633297e51..abb62492342f8 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -10556,6 +10556,27 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
const TargetOptions &Options = DAG.getTarget().Options;
if (Options.EmitCallSiteInfo)
CSInfo.ArgRegPairs.emplace_back(VA.getLocReg(), i);
+ if (IsArm64ECVarArgExitThunk) {
+ Register FPReg;
+ switch (VA.getLocReg()) {
+ case AArch64::X0:
+ FPReg = AArch64::D0;
+ break;
+ case AArch64::X1:
+ FPReg = AArch64::D1;
+ break;
+ case AArch64::X2:
+ FPReg = AArch64::D2;
+ break;
+ case AArch64::X3:
+ FPReg = AArch64::D3;
+ break;
+ }
+ if (FPReg) {
+ RegsToPass.emplace_back(FPReg, Arg);
+ RegsUsed.insert(FPReg);
+ }
+ }
}
} else {
assert(VA.isMemLoc());
diff --git a/llvm/test/CodeGen/AArch64/arm64ec-exit-thunks.ll b/llvm/test/CodeGen/AArch64/arm64ec-exit-thunks.ll
index 03ce3ca919a56..78b59cfa196d8 100644
--- a/llvm/test/CodeGen/AArch64/arm64ec-exit-thunks.ll
+++ b/llvm/test/CodeGen/AArch64/arm64ec-exit-thunks.ll
@@ -313,7 +313,11 @@ declare void @has_varargs(...) nounwind;
; CHECK-NEXT: mov x2, x5
; CHECK-NEXT: bl "#memcpy"
; CHECK-NEXT: sub sp, sp, #32
+; CHECK-NEXT: fmov d0, x22
+; CHECK-NEXT: fmov d1, x21
; CHECK-NEXT: mov x9, x26
+; CHECK-NEXT: fmov d2, x20
+; CHECK-NEXT: fmov d3, x19
; CHECK-NEXT: mov x0, x22
; CHECK-NEXT: mov x1, x21
; CHECK-NEXT: mov x2, x20
@@ -391,7 +395,11 @@ declare [2 x i8] @has_varargs_small_struct(...) nounwind;
; CHECK-NEXT: mov x2, x5
; CHECK-NEXT: bl "#memcpy"
; CHECK-NEXT: sub sp, sp, #32
+; CHECK-NEXT: fmov d0, x22
+; CHECK-NEXT: fmov d1, x21
; CHECK-NEXT: mov x9, x26
+; CHECK-NEXT: fmov d2, x20
+; CHECK-NEXT: fmov d3, x19
; CHECK-NEXT: mov x0, x22
; CHECK-NEXT: mov x1, x21
; CHECK-NEXT: mov x2, x20
@@ -566,7 +574,11 @@ declare void @has_varargs_sret(ptr sret([100 x i8]), ...) nounwind;
; CHECK-NEXT: mov x2, x4
; CHECK-NEXT: bl "#memcpy"
; CHECK-NEXT: sub sp, sp, #32
+; CHECK-NEXT: fmov d0, x22
+; CHECK-NEXT: fmov d1, x21
; CHECK-NEXT: mov x9, x26
+; CHECK-NEXT: fmov d2, x20
+; CHECK-NEXT: fmov d3, x19
; CHECK-NEXT: mov x0, x22
; CHECK-NEXT: mov x1, x21
; CHECK-NEXT: mov x2, x20
|
…g exit thunks (llvm#209581) ARM64EC vararg functions receive all types of the first four arguments in x0-x3. Because x86_64 expects floating-point arguments in FP registers, always copy x0-x3 to d0-d3 in the exit thunks, matching MSVC's behavior. (cherry picked from commit 9c6a9f5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport 9c6a9f5
Requested by: @cjacek