[llvm] [X86][APX] Implement push+push2+push pre-alignment strategy for PP2 (PR #205031)

Feng Zou via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 21:33:34 PDT 2026


================
@@ -383,20 +383,35 @@ MachineInstrBuilder X86FrameLowering::BuildStackAdjustment(
   }
 
   MachineInstrBuilder MI;
-  if (UseLEA) {
+  // Use NF (no-flags) variants when the target supports it, avoiding
+  // gratuitous EFLAGS clobber. The NF stack-adjust opcodes below are 64-bit
+  // (SUB64ri32_NF/ADD64ri32_NF), so don't use them for the x32 ABI where the
+  // stack pointer is 32-bit. On Windows whether NF is safe in the epilogue
+  // depends on how the OS unwinder reads the code: the prologue unwinder is
+  // data-driven (it walks the unwind codes and never disassembles the
+  // prologue), so NF is always safe there; but the v1/v2 epilogue unwinder
+  // disassembles the epilogue and doesn't recognize EVEX NF add/sub
+  // instructions, so only use NF in a Windows epilogue under unwind v3 (which
+  // encodes epilog operations declaratively and needs no disassembly).
+  bool UseNF = STI.hasNF() && Uses64BitFramePtr &&
+               !(InEpilogue && needsWin64NonV3EpilogueUnwind(*MBB.getParent()));
+  if (UseLEA && !UseNF) {
----------------
fzou1 wrote:

Updated. Thanks.

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


More information about the llvm-commits mailing list