[llvm] [AArch64] Skip storing of stack arguments when lowering tail calls (PR #126735)

Guy David via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 01:15:20 PDT 2025


================
@@ -8968,6 +8968,46 @@ getSMToggleCondition(const SMECallAttrs &CallAttrs) {
   llvm_unreachable("Unsupported attributes");
 }
 
+/// Check whether a stack argument requires lowering in a tail call.
+static bool shouldLowerTailCallStackArg(const MachineFunction &MF,
+                                        const CCValAssign &VA, SDValue Arg,
+                                        ISD::ArgFlagsTy Flags, int CallOffset) {
+  // FIXME: We should be able to handle this case, but it's not clear how to.
+  if (Flags.isZExt() || Flags.isSExt())
+    return true;
+
+  for (;;) {
+    // Look through nodes that don't alter the bits of the incoming value.
+    unsigned Op = Arg.getOpcode();
+    if (Op == ISD::ZERO_EXTEND || Op == ISD::ANY_EXTEND || Op == ISD::BITCAST ||
----------------
guy-david wrote:

Both operations may change the size of the value, but not the contents. Ultimately, if the value is derived from an argument which occupies the same stack slot as the tail-call argument and has the same object size, it is safe to assume it can be forwarded free of charge. The same logic takes place in the X86 backend.

https://github.com/llvm/llvm-project/pull/126735


More information about the llvm-commits mailing list