[llvm] [AArch64] Skip storing of stack arguments when lowering tail calls (PR #126735)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 5 14:57:34 PDT 2025
================
@@ -296,10 +298,60 @@ struct OutgoingArgHandler : public CallLowering::OutgoingValueHandler {
MIRBuilder.buildCopy(PhysReg, ExtReg);
}
+ /// Check whether a stack argument requires lowering in a tail call.
+ static bool shouldLowerTailCallStackArg(const MachineFunction &MF,
+ const CCValAssign &VA,
+ Register ValVReg,
+ Register StoreAddr) {
+ const MachineRegisterInfo &MRI = MF.getRegInfo();
+ // Print the defining instruction for the value.
+ auto *DefMI = MRI.getVRegDef(ValVReg);
+ assert(DefMI && "No defining instruction");
+ for (;;) {
+ // Look through nodes that don't alter the bits of the incoming value.
+ unsigned Op = DefMI->getOpcode();
+ if (Op == TargetOpcode::G_ZEXT || Op == TargetOpcode::G_ANYEXT ||
+ Op == TargetOpcode::G_BITCAST || isAssertMI(*DefMI)) {
+ DefMI = MRI.getVRegDef(DefMI->getOperand(1).getReg());
+ continue;
+ }
+ break;
+ }
+
+ auto *Load = dyn_cast<GLoad>(DefMI);
+ if (!Load)
+ return true;
+ Register LoadReg = Load->getPointerReg();
+ auto *LoadAddrDef = MRI.getVRegDef(LoadReg);
+ assert(LoadAddrDef && "No defining instruction");
----------------
aemerson wrote:
Not strictly necessary since vreg's should always have defs.
https://github.com/llvm/llvm-project/pull/126735
More information about the llvm-commits
mailing list