summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-01-30 01:18:38 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-01-30 01:18:38 +0000
commit7fa6964dc2df14a626fc5b1c90f9e747d60defef (patch)
tree7fd23547156a396521837101fc97d4a9bc7c9e68 /llvm/lib/Target/ARM/ARMRegisterInfo.cpp
parent863736b0ad3fd26fc60f8d9ba0ff24cfc92a5624 (diff)
downloadbcm5719-llvm-7fa6964dc2df14a626fc5b1c90f9e747d60defef.tar.gz
bcm5719-llvm-7fa6964dc2df14a626fc5b1c90f9e747d60defef.zip
- In thumb mode, if size of MachineFunction is >= 2048, force LR to be
spilled (if it is not already). - If LR is spilled, use BL to implement far jumps. LR is not used as a GPR in thumb mode so it can be clobbered if it is properly spilled / restored in prologue / epilogue. - If LR is force spilled but no far jump has been emitted, try undo'ing the spill by: push lr -> delete pop pc -> bx lr llvm-svn: 33650
Diffstat (limited to 'llvm/lib/Target/ARM/ARMRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMRegisterInfo.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARM/ARMRegisterInfo.cpp b/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
index 2accaf890e6..07869e4cf8a 100644
--- a/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
@@ -770,17 +770,29 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
}
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
+ bool ForceLRSpill = false;
+ if (!LRSpilled && AFI->isThumbFunction()) {
+ unsigned FnSize = ARM::GetFunctionSize(MF);
+ // Force LR spill if the Thumb function size is > 2048. This enables the
+ // use of BL to implement far jump. If it turns out that it's not needed
+ // the branch fix up path will undo it.
+ if (FnSize >= (1 << 11)) {
+ CanEliminateFrame = false;
+ ForceLRSpill = true;
+ }
+ }
+
if (!CanEliminateFrame) {
AFI->setHasStackFrame(true);
// If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled.
// Spill LR as well so we can fold BX_RET to the registers restore (LDM).
if (!LRSpilled && CS1Spilled) {
- LRSpilled = true;
MF.changePhyRegUsed(ARM::LR, true);
NumGPRSpills++;
UnspilledCS1GPRs.erase(std::find(UnspilledCS1GPRs.begin(),
UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
+ ForceLRSpill = false;
}
if (STI.isTargetDarwin()) {
@@ -800,8 +812,10 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
}
}
- // Remembe if LR has been spilled.
- AFI->setLRIsSpilled(LRSpilled);
+ if (ForceLRSpill) {
+ MF.changePhyRegUsed(ARM::LR, true);
+ AFI->setLRIsForceSpilled(true);
+ }
}
/// Move iterator pass the next bunch of callee save load / store ops for
OpenPOWER on IntegriCloud