[llvm] [AArch64] Disable variadic tail-calls for ARM64EC (PR #78914)
Billy Laws via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 21 12:53:02 PST 2024
https://github.com/bylaws created https://github.com/llvm/llvm-project/pull/78914
Arm64EC varargs calls expect that x4 = sp at entry, this complicates tail call handling so disable for now.
CC: @cjacek
>From fc7afc876b11a4cce48b90c0e1142f1c7647a182 Mon Sep 17 00:00:00 2001
From: Billy Laws <blaws05 at gmail.com>
Date: Sun, 21 Jan 2024 18:58:14 +0000
Subject: [PATCH] [AArch64] Disable variadic tail-calls for ARM64EC
Arm64EC varargs calls expect that x4 = sp at entry, this complicates
tail call handling so disable for now.
---
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 5 +++++
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 96ea692d03f563..264c301d81194f 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -7235,6 +7235,11 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
const Function &CallerF = MF.getFunction();
CallingConv::ID CallerCC = CallerF.getCallingConv();
+ // Arm64EC varargs calls expect that x4 = sp at entry, this complicates tail
+ // call handling so disable for now.
+ if (IsVarArg && Subtarget->isWindowsArm64EC())
+ return false;
+
// SME Streaming functions are not eligible for TCO as they may require
// the streaming mode or ZA to be restored after returning from the call.
SMEAttrs CallerAttrs(MF.getFunction());
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
index 84057ea8d2214a..43a279de035ac7 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
@@ -909,6 +909,7 @@ bool AArch64CallLowering::isEligibleForTailCallOptimization(
CallingConv::ID CalleeCC = Info.CallConv;
MachineFunction &MF = MIRBuilder.getMF();
const Function &CallerF = MF.getFunction();
+ const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>();
LLVM_DEBUG(dbgs() << "Attempting to lower call as tail call\n");
@@ -926,6 +927,11 @@ bool AArch64CallLowering::isEligibleForTailCallOptimization(
return false;
}
+ // Arm64EC varargs calls expect that x4 = sp at entry, this complicates tail
+ // call handling so disable for now.
+ if (Info.IsVarArg && Subtarget.isWindowsArm64EC())
+ return false;
+
// Byval parameters hand the function a pointer directly into the stack area
// we want to reuse during a tail call. Working around this *is* possible (see
// X86).
More information about the llvm-commits
mailing list