[all-commits] [llvm/llvm-project] 2fd8d4: [X86] Don't fold loads from non-fixed stack object...

Akash Manna via All-commits all-commits at lists.llvm.org
Mon Sep 7 02:44:24 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2fd8d41d7b8824637be32d569c1e1482128b057b
      https://github.com/llvm/llvm-project/commit/2fd8d41d7b8824637be32d569c1e1482128b057b
  Author: Akash Manna <akash.manna.mymail at gmail.com>
  Date:   2026-09-07 (Mon, 07 Sep 2026)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
    A llvm/test/CodeGen/X86/pr216504.ll

  Log Message:
  -----------
  [X86] Don't fold loads from non-fixed stack objects into tail calls (#221243)

Fixes #216504

The callee of a tail call can be folded into the jump as a memory
operand (`TCRETURNmi64`). That jump runs after the epilogue, so the
operand is resolved relative to the incoming stack pointer, which only
works for fixed objects such as incoming arguments. Here the callee was
a `volatile` local, so the load stayed on the stack and got folded,
while a variable-index extract from a 256-bit vector went through a
32-byte stack temporary and forced dynamic realignment. Once the stack
is realigned a local has no static offset from the incoming stack
pointer, and PEI tripped the assertion. The sibcall eligibility check
does look at realignment, but it runs before legalization, so it never
saw the temporary. Spill slots created during register allocation can
cause the same thing, so no check at that point can be complete.

The fold is now refused whenever the load's address may use a non-fixed
frame index, in `checkTCRetEnoughRegs`, which gates both the
`TCRETURNmi` patterns and the callee-load hoisting in
`PreprocessISelDAG`. The callee is loaded into a register before the
epilogue and the call is still emitted as a tail call. Loads from fixed
objects fold as before. As a side effect this also stops the jump from
reading a slot below the restored stack pointer, which was only safe
inside the red zone.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list