[llvm] [x86] Enable indirect tail calls with more arguments (PR #137643)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 15:39:13 PDT 2025


================
@@ -1353,6 +1376,22 @@ void X86DAGToDAGISel::PreprocessISelDAG() {
          (N->getOpcode() == X86ISD::TC_RETURN &&
           (Subtarget->is64Bit() ||
            !getTargetMachine().isPositionIndependent())))) {
+
+      if (N->getOpcode() == X86ISD::TC_RETURN) {
+        // There needs to be enough non-callee-saved GPRs available to compute
+        // the load address if folded into the tailcall. See how the
+        // X86tcret_6regs and X86tcret_1reg classes are used and defined.
+        unsigned NumRegs = 0;
+        for (unsigned I = 3, E = N->getNumOperands(); I != E; ++I) {
+          if (isa<RegisterSDNode>(N->getOperand(I)))
----------------
rnk wrote:

We can skip XMM / FP register operands, so I would do a GPR64 class check here before counting up.

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


More information about the llvm-commits mailing list