[llvm] 19e2b40 - [AArch64] Remove dead code for inserting SEH opcodes for realignment. NFC.

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 12 23:54:29 PDT 2022


Author: Martin Storsjö
Date: 2022-10-13T09:47:38+03:00
New Revision: 19e2b403b4a9d92b95400dd6e3ecb198884de64a

URL: https://github.com/llvm/llvm-project/commit/19e2b403b4a9d92b95400dd6e3ecb198884de64a
DIFF: https://github.com/llvm/llvm-project/commit/19e2b403b4a9d92b95400dd6e3ecb198884de64a.diff

LOG: [AArch64] Remove dead code for inserting SEH opcodes for realignment. NFC.

If the stack is realigned, we've emitted a frame pointer and
already terminated the SEH prologue, making this dead code since
a07787c9a50c046e45921dd665f5a53a752bbc31.

The immediate to this SEH opcode was entirely bogus - we don't
know how many bytes the AND operation adjusts the SP, and by
doing "NumBytes & andMaskEncoded" (where andMaskEncoded was the
immediate bitpattern for the AND instruction), the immediate to the
opcode was total gibberish.

This hasn't had any practical effect, since the original stack
pointer always was restored from the frame pointer afterwards anyway.

Differential Revision: https://reviews.llvm.org/D135815

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index f759b60a43eb..9ed87902eec0 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -1833,12 +1833,10 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
           .addReg(scratchSPReg, RegState::Kill)
           .addImm(andMaskEncoded);
       AFI->setStackRealigned(true);
-      if (NeedsWinCFI) {
-        HasWinCFI = true;
-        BuildMI(MBB, MBBI, DL, TII->get(AArch64::SEH_StackAlloc))
-            .addImm(NumBytes & andMaskEncoded)
-            .setMIFlag(MachineInstr::FrameSetup);
-      }
+
+      // No need for SEH instructions here; if we're realigning the stack,
+      // we've set a frame pointer and already finished the SEH prologue.
+      assert(!NeedsWinCFI);
     }
   }
 


        


More information about the llvm-commits mailing list