[llvm] [x86] Enable indirect tail calls with more arguments (PR #137643)
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 08:15:40 PST 2026
================
@@ -3475,6 +3503,63 @@ static bool mayUseCarryFlag(X86::CondCode CC) {
return true;
}
+bool X86DAGToDAGISel::checkTCRetEnoughRegs(SDNode *N) const {
+ // Check that there is enough volatile registers to load the callee address.
+
+ const X86RegisterInfo *RI = Subtarget->getRegisterInfo();
+ unsigned AvailGPRs;
+ if (Subtarget->is64Bit()) {
+ const TargetRegisterClass *TCGPRs =
+ Subtarget->isCallingConvWin64(MF->getFunction().getCallingConv())
+ ? &X86::GR64_TCW64RegClass
+ : &X86::GR64_TCRegClass;
+ // Can't use RSP or RIP for the load in general.
+ assert(TCGPRs->contains(X86::RSP));
+ assert(TCGPRs->contains(X86::RIP));
+ AvailGPRs = TCGPRs->getNumRegs() - 2;
+ } else {
+ const TargetRegisterClass *TCGPRs =
+ MF->getFunction().getCallingConv() == CallingConv::HiPE
+ ? &X86::GR32RegClass
+ : &X86::GR32_TCRegClass;
+ // Can't use ESP for the address in general.
+ assert(TCGPRs->contains(X86::ESP));
+ AvailGPRs = TCGPRs->getNumRegs() - 1;
+ }
+
+ // The load's base and index need up to two registers.
+ unsigned LoadGPRs = 2;
+
+ assert(N->getOpcode() == X86ISD::TC_RETURN);
+ // X86tcret args: (*chain, ptr, imm, regs..., glue)
+
+ if (Subtarget->is32Bit()) {
+ // FIXME: This was carried from X86tcret_1reg which was used for 32-bit,
+ // but it could apply to 64-bit too.
+ const SDValue &BasePtr = cast<LoadSDNode>(N->getOperand(1))->getBasePtr();
+ if (isa<FrameIndexSDNode>(BasePtr)) {
+ LoadGPRs -= 1; // Base is ESP, no reg needed.
----------------
zmodem wrote:
Ah yes, because the index will be a constant. Done.
https://github.com/llvm/llvm-project/pull/137643
More information about the llvm-commits
mailing list