[llvm] x86: fix musttail sibcall miscompilation (PR #168956)

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 11:29:41 PST 2025


================
@@ -3000,6 +3115,11 @@ bool X86TargetLowering::IsEligibleForTailCallOptimization(
       X86::isCalleePop(CalleeCC, Subtarget.is64Bit(), isVarArg,
                        MF.getTarget().Options.GuaranteedTailCallOpt);
 
+  // If the stack arguments for this call do not fit into our own save area then
+  // the call cannot be made tail.
+  if (CCInfo.getStackSize() > FuncInfo->getArgumentStackSize())
+    return false;
+
----------------
folkertdev wrote:

This might already be covered by the `getBytesToPopOnReturn` check below? Those ideas sound similar but I'm not sure so for now I've copied this check from the arm implementation.

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


More information about the llvm-commits mailing list