summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2019-01-27 16:42:12 +0000
committerpatrick <patrick@openbsd.org>2019-01-27 16:42:12 +0000
commitb773203fb58f3ef282fb69c832d8710cab5bc82d (patch)
treee75913f147570fbd75169647b144df85b88a038c /gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
parenttweak errno in previous (diff)
downloadwireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.tar.xz
wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.zip
Import LLVM 7.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp')
-rw-r--r--gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp b/gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
index ba00b3d79da..5c745e112b2 100644
--- a/gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
+++ b/gnu/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
@@ -127,7 +127,7 @@ void Thumb1FrameLowering::emitPrologue(MachineFunction &MF,
// Debug location must be unknown since the first debug location is used
// to determine the end of the prologue.
DebugLoc dl;
-
+
unsigned FramePtr = RegInfo->getFrameRegister(MF);
unsigned BasePtr = RegInfo->getBaseRegister();
int CFAOffset = 0;
@@ -611,6 +611,12 @@ 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.useR7AsFramePointer())
+ PopFriendly.set(ARM::R7);
+
assert(PopFriendly.any() && "No allocatable pop-friendly register?!");
// Rebuild the GPRs from the high registers because they are removed
// form the GPR reg class for thumb1.
@@ -622,17 +628,20 @@ bool Thumb1FrameLowering::emitPopSpecialFixUp(MachineBasicBlock &MBB,
GPRsNoLRSP.reset(ARM::PC);
findTemporariesForLR(GPRsNoLRSP, PopFriendly, UsedRegs, PopReg, TemporaryReg);
- // If we couldn't find a pop-friendly register, restore LR before popping the
- // other callee-saved registers, so we can use one of them as a temporary.
+ // If we couldn't find a pop-friendly register, try restoring LR before
+ // popping the other callee-saved registers, so we could use one of them as a
+ // temporary.
bool UseLDRSP = false;
if (!PopReg && MBBI != MBB.begin()) {
auto PrevMBBI = MBBI;
PrevMBBI--;
if (PrevMBBI->getOpcode() == ARM::tPOP) {
- MBBI = PrevMBBI;
- UsedRegs.stepBackward(*MBBI);
+ UsedRegs.stepBackward(*PrevMBBI);
findTemporariesForLR(GPRsNoLRSP, PopFriendly, UsedRegs, PopReg, TemporaryReg);
- UseLDRSP = true;
+ if (PopReg) {
+ MBBI = PrevMBBI;
+ UseLDRSP = true;
+ }
}
}