[llvm] [X86] Don't allocate unused padding in front of realigned locals (PR #227495)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 12:45:58 PDT 2026
================
@@ -1901,9 +1927,14 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
NumBytes =
FrameSize - (X86FI->getCalleeSavedFrameSize() + TailCallArgReserveSize);
- // Callee-saved registers are pushed on stack before the stack is realigned.
- if (TRI->hasStackRealignment(MF) && !IsWin64Prologue)
- NumBytes = alignTo(NumBytes, MaxAlign);
+ // Callee-saved registers are pushed on stack before the stack is realigned,
+ // and the realignment itself already provides the local objects' alignment,
+ // so leave out the padding PEI put in front of them for it.
+ if (TRI->hasStackRealignment(MF) && !IsWin64Prologue) {
+ uint64_t Padding = getUnusedLocalAreaPadding(MFI);
+ assert(Padding <= NumBytes && "Padding exceeds the local area");
+ NumBytes = alignTo(NumBytes - Padding, MaxAlign);
----------------
e-kud wrote:
In my mind under-allocation is more problematic than over-allocation. But I don't have any example from the top of my hand. But is still doesn't address the hackish (in my mind) way of fixing it.
https://github.com/llvm/llvm-project/pull/227495
More information about the llvm-commits
mailing list