[llvm] [RISCV] improve `musttail` support (PR #170547)

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 3 13:54:49 PST 2025


================
@@ -115,6 +115,36 @@ bool TargetLowering::parametersInCSRMatch(const MachineRegisterInfo &MRI,
   return true;
 }
 
+SDValue TargetLowering::addTokenForArgument(SDValue Chain, SelectionDAG &DAG,
+                                            MachineFrameInfo &MFI,
+                                            int ClobberedFI) const {
+  SmallVector<SDValue, 8> ArgChains;
+  int64_t FirstByte = MFI.getObjectOffset(ClobberedFI);
+  int64_t LastByte = FirstByte + MFI.getObjectSize(ClobberedFI) - 1;
+
+  // Include the original chain at the beginning of the list. When this is
+  // used by target LowerCall hooks, this helps legalize find the
+  // CALLSEQ_BEGIN node.
+  ArgChains.push_back(Chain);
+
+  // Add a chain value for each stack argument corresponding
+  for (SDNode *U : DAG.getEntryNode().getNode()->users())
----------------
folkertdev wrote:

I'm for sure not the right person to answer that question.

This code is taken from the aarch64 backend originally, which fixed its tail calls in https://github.com/llvm/llvm-project/pull/109943. From what I've been able to gather, the other backends in play worked off of the aarch64 template.

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


More information about the llvm-commits mailing list