[llvm] [ARM] Do not use r7 as a temporary in THUMB if it is a stack pointer (NFC) (PR #86156)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 10:13:41 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-arm

Author: AtariDreams (AtariDreams)

<details>
<summary>Changes</summary>

Many programs and debuggers do in fact poll the value of r7 to keep track of frame pointers and see which functions have been called.

If there is a way to ensure this is not happening, then maybe we can get the compiler to use r7. However, I do not even know if the TargetRegisterInfo class already takes care of that or not.

It is best to remove this code in the interim. Plus, because r7 is marked as reserved anyway, it will always be marked as unallocatable, and hence this code has no effect anyway, hence why it is marked as NFC, even though technically the only reason why this code has no effect is a bug. It is a bug that has prevented this code from causing problems.

---
Full diff: https://github.com/llvm/llvm-project/pull/86156.diff


1 Files Affected:

- (modified) llvm/lib/Target/ARM/Thumb1FrameLowering.cpp (-5) 


``````````diff
diff --git a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
index 0f4ece64bff532..5d5968c9c849ea 100644
--- a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
+++ b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
@@ -710,11 +710,6 @@ bool Thumb1FrameLowering::emitPopSpecialFixUp(MachineBasicBlock &MBB,
   unsigned TemporaryReg = 0;
   BitVector PopFriendly =
       TRI.getAllocatableSet(MF, TRI.getRegClass(ARM::tGPRRegClassID));
-  // R7 may be used as a frame pointer, hence marked as not generally
-  // allocatable, however there's no reason to not use it as a temporary for
-  // restoring LR.
-  if (STI.getFramePointerReg() == ARM::R7)
-    PopFriendly.set(ARM::R7);
 
   assert(PopFriendly.any() && "No allocatable pop-friendly register?!");
   // Rebuild the GPRs from the high registers because they are removed

``````````

</details>


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


More information about the llvm-commits mailing list