summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
diff options
context:
space:
mode:
authorRobert Lytton <robert@xmos.com>2014-01-06 14:20:47 +0000
committerRobert Lytton <robert@xmos.com>2014-01-06 14:20:47 +0000
commitcbb588a26486527f71028a3c8e6a979053d7ccd5 (patch)
tree09a34367217acc098bfd6e6eda40c0fe7b90722c /llvm/lib/Target/XCore/XCoreFrameLowering.cpp
parenta53360a339998a4523b2f819d727b77454ea6fa5 (diff)
downloadbcm5719-llvm-cbb588a26486527f71028a3c8e6a979053d7ccd5.tar.gz
bcm5719-llvm-cbb588a26486527f71028a3c8e6a979053d7ccd5.zip
XCore target: Optimise entsp / retsp selection
llvm-svn: 198612
Diffstat (limited to 'llvm/lib/Target/XCore/XCoreFrameLowering.cpp')
-rw-r--r--llvm/lib/Target/XCore/XCoreFrameLowering.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Target/XCore/XCoreFrameLowering.cpp b/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
index 22d0e6604bd..3d1fb9cafc1 100644
--- a/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreFrameLowering.cpp
@@ -427,12 +427,20 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
RegScavenger *RS) const {
XCoreFunctionInfo *XFI = MF.getInfo<XCoreFunctionInfo>();
+ bool LRUsed = MF.getRegInfo().isPhysRegUsed(XCore::LR);
+ // If we need to extend the stack it is more efficient to use entsp / retsp.
+ // We force the LR to be saved so these instructions are used.
+ if (!LRUsed && !MF.getFunction()->isVarArg() &&
+ MF.getFrameInfo()->estimateStackSize(MF))
+ LRUsed = true;
+
// We will handling LR in the prologue/epilogue
// and space on the stack ourselves.
- if (MF.getRegInfo().isPhysRegUsed(XCore::LR)) {
+ if (LRUsed) {
MF.getRegInfo().setPhysRegUnused(XCore::LR);
XFI->createLRSpillSlot(MF);
}
+
// A callee save register is used to hold the FP.
// This needs saving / restoring in the epilogue / prologue.
if (hasFP(MF))
OpenPOWER on IntegriCloud