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

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 14 14:30:19 PST 2026


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

To elaborate, because this logic is tricky, the regressions appear in cases like this one:

```llvm
define dso_local tailcc void @void_test(i32, i32, i32, i32) {
; X64-LABEL: void_test:
; X64:       # %bb.0: # %entry
; X64-NEXT:    jmp void_test # TAILCALL
;
; X86-LABEL: void_test:
; X86:       # %bb.0: # %entry
; X86-NEXT:    jmp void_test # TAILCALL
  entry:
   musttail call tailcc void @void_test( i32 %0, i32 %1, i32 %2, i32 %3)
   ret void
}
```

With the current logic, both `isTailCall` and `IsSibcall` are `true`, with your suggestion `IsSibcall` is `false`. I think it is harmless to conclude that this is in fact a sibcall, and use the more optimal codegen that it enables.


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


More information about the llvm-commits mailing list