[llvm] [win][x64] Various fixes for unwind v2 (PR #154834)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 14:52:32 PDT 2025
================
@@ -190,8 +196,30 @@ bool X86WinEHUnwindV2::runOnMachineFunction(MachineFunction &MF) {
State = FunctionState::FinishedEpilog;
break;
- case X86::LEA64r:
case X86::MOV64rr:
+ if (State == FunctionState::InEpilog) {
+ // If the prolog contains a stack allocation, then the first
+ // instruction in the epilog must be to adjust the stack pointer.
+ if (!HasSetFrame)
+ return rejectCurrentFunctionInternalError(
+ MF, Mode,
+ "The epilog is setting frame back, but prolog did not set it");
+ if (PoppedRegCount > 0)
+ return rejectCurrentFunctionInternalError(
+ MF, Mode,
+ "The epilog is setting the frame back after popping "
+ "registers");
+ if (HasStackDealloc)
+ return rejectCurrentFunctionInternalError(
+ MF, Mode,
+ "Cannot set the frame back after the stack "
+ "allocation has been deallocated");
+ } else if (State == FunctionState::FinishedEpilog)
+ return rejectCurrentFunctionInternalError(
+ MF, Mode, "Unexpected mov instruction after the epilog");
+ break;
+
+ case X86::LEA64r:
----------------
dpaoliello wrote:
Only if there was a SetFrame AND a stack alloc, otherwise MOV is used:
https://github.com/llvm/llvm-project/blob/1277a1111d420b244a0e595ad9b74827841b723a/llvm/lib/Target/X86/X86FrameLowering.cpp#L2574-L2597
https://github.com/llvm/llvm-project/pull/154834
More information about the llvm-commits
mailing list