For Thumb2, try to use frame pointer references for stack slots even when a
authorJim Grosbach <grosbach@apple.com>
Mon, 18 Oct 2010 18:39:46 +0000 (18:39 +0000)
committerJim Grosbach <grosbach@apple.com>
Mon, 18 Oct 2010 18:39:46 +0000 (18:39 +0000)
base register is available. rdar://8525298

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116729 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMBaseRegisterInfo.cpp

index acb61b218ac7b000f946c4b09b7666f6d0c73ec0..37e15f4f1c14f61f129f064d00f178128834f71f 100644 (file)
@@ -953,8 +953,16 @@ ARMBaseRegisterInfo::ResolveFrameIndexReference(const MachineFunction &MF,
       return FPOffset;
     } else if (MFI->hasVarSizedObjects()) {
       assert(hasBasePointer(MF) && "missing base pointer!");
-      // Use the base register since we have it.
-      FrameReg = BasePtr;
+      // Try to use the frame pointer if we can, else use the base pointer
+      // since it's available. This is handy for the emergency spill slot, in
+      // particular.
+      if (AFI->isThumb2Function()) {
+        if (FPOffset >= -255 && FPOffset < 0) {
+          FrameReg = getFrameRegister(MF);
+          return FPOffset;
+        }
+      } else
+        FrameReg = BasePtr;
     } else if (AFI->isThumb2Function()) {
       // In Thumb2 mode, the negative offset is very limited. Try to avoid
       // out of range references.