[llvm] [ARM] R11 not pushed adjacent to link register with PAC-M and AAPCS frame chain fix (PR #82801)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 13:20:19 PST 2024


================
@@ -441,18 +441,28 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
   }
 
   /// Returns true if the frame setup is split into two separate pushes (first
-  /// r0-r7,lr then r8-r11), principally so that the frame pointer is adjacent
-  /// to lr. This is always required on Thumb1-only targets, as the push and
-  /// pop instructions can't access the high registers.
-  bool splitFramePushPop(const MachineFunction &MF) const {
-    if (MF.getInfo<ARMFunctionInfo>()->shouldSignReturnAddress())
+  /// r0-r7,lr then r8-r11), principally so that the frame pointer r7 is
+  /// adjacent to lr. This is always required on Thumb1-only targets, as the
+  /// push and pop instructions can't access the high registers.
+  bool splitFramePushPopR7(const MachineFunction &MF) const {
+    if (MF.getInfo<ARMFunctionInfo>()->shouldSignReturnAddress() &&
+        !createAAPCSFrameChain())
       return true;
     return (getFramePointerReg() == ARM::R7 &&
             MF.getTarget().Options.DisableFramePointerElim(MF)) ||
            isThumb1Only();
   }
 
-  bool splitFramePointerPush(const MachineFunction &MF) const;
+  bool framePointerRequiredForSEHUnwind(const MachineFunction &MF) const;
+
+  // Returns true if R11 and lr are not adjacent to each other in the list of
+  // callee saved registers in a frame.
+  bool r11AndLRNotAdjacent(const MachineFunction &MF) const;
+
+  // Returns true if the frame setup is split into two separate pushes (first
+  // r0-r10,r12 then r11,lr), principally so that the frame pointer r11 is
+  // adjacent to lr.
+  bool splitFramePushPopR11(const MachineFunction &MF) const;
----------------
efriedma-quic wrote:

Would it make sense to introduce an enum of some sort here?  Having a bunch of separate boolean methods representing different variations is confusing.

As far as I can tell, the following variations exist:

- The normal push: push r4-r11+lr all at once
- The Thumb1 split push: push r4-r7+lr, then r8-r11
- The Thumb1 r11 frame chain split push: push lr, then r11, then r0-r7, then r8-r11.
- The branch signing unsplit push: push r4-r12+lr all at once.
- The branch signing split push: push r4-r7+lr, then r8-r12
- The branch signing r11 frame chain split push: push r4-r10+r12, then r11+lr
- The Windows SEH split push: push r4-r10, then r11+lr

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


More information about the llvm-commits mailing list