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

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 14 10:14:01 PST 2026


================
@@ -2098,15 +2142,18 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
       isTailCall = false;
   }
 
-  if (isTailCall && !IsMustTail) {
+  if (isTailCall) {
----------------
rnk wrote:

I think this block can be simplified to avoid the eligibility check for the "guaranteed" TCO case, and I made some comment suggestions that hopefully explain this better.

```suggestion
  // Check if this tail call is a "sibling" call, which is loosely defined to
  // be a tail call that doesn't require heroics like moving the return address
  // or swapping byval arguments.
  bool IsSibcall = false;
  if (isTailCall && !ShouldGuaranteeTCO) {
```

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


More information about the llvm-commits mailing list