[llvm] [AArch64] Fix Windows prologue handling to pair more registers. (PR #170214)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 09:52:48 PST 2025


================
@@ -179,11 +179,23 @@ AArch64PrologueEpilogueCommon::convertCalleeSaveRestoreToSPPrePostIncDec(
   (void)Success;
   assert(Success && "unknown load/store opcode");
 
+  const auto *TRI = Subtarget.getRegisterInfo();
   // If the first store isn't right where we want SP then we can't fold the
   // update in so create a normal arithmetic instruction instead.
+  //
+  // On Windows, some register pairs involving LR can't be folded because
+  // there isn't a corresponding unwind opcode. (Note that packed unwind expects
+  // a sequence like "sub sp, sp, #16; stp x19, lr, [sp]; sub sp, sp, #16",
+  // but we currently generate "sub sp, sp, #32; stp x19, lr, [sp, #16]". We
+  // could handle that here, but it's not clearly profitable; it saves up to
+  // 4 words of xdata, but it costs 2 instructions.)
----------------
efriedma-quic wrote:

One instruction in the prologue, one instruction in the epilogue.  I'll try to rephrase.

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


More information about the llvm-commits mailing list