Changes in directory llvm/lib/Target/ARM:
ARMRegisterInfo.cpp updated: 1.90 -> 1.91 ARMRegisterInfo.h updated: 1.17 -> 1.18 --- Log message: Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function. This eliminates the need for add/sub sp brackets around call sites. However, this is not always a good idea. If the "call frame" is large and the target load / store instructions have small immediate field to encode sp offset, this can cause poor codegen. In the worst case, this can make it impossible to scavenge a register if the reserved spill slot is pushed too far apart from sp / fp. --- Diffs of the changes: (+29 -3) ARMRegisterInfo.cpp | 30 +++++++++++++++++++++++++++--- ARMRegisterInfo.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.90 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.91 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.90 Fri Apr 27 15:10:08 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Mon Apr 30 19:52:08 2007 @@ -386,6 +386,29 @@ return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects(); } +// hasReservedCallFrame - Under normal circumstances, when a frame pointer is +// not required, we reserve argument space for call sites in the function +// immediately on entry to the current function. This eliminates the need for +// add/sub sp brackets around call sites. Returns true if the call frame is +// included as part of the stack frame. +bool ARMRegisterInfo::hasReservedCallFrame(MachineFunction &MF) const { + const MachineFrameInfo *FFI = MF.getFrameInfo(); + unsigned CFSize = FFI->getMaxCallFrameSize(); + ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>(); + // It's not always a good idea to include the call frame as part of the + // stack frame. ARM (especially Thumb) has small immediate offset to + // address the stack frame. So a large call frame can cause poor codegen + // and may even makes it impossible to scavenge a register. + if (AFI->isThumbFunction()) { + if (CFSize >= ((1 << 8) - 1) * 4 / 2) // Half of imm8 * 4 + return false; + } else { + if (CFSize >= ((1 << 12) - 1) / 2) // Half of imm12 + return false; + } + return !hasFP(MF); +} + /// emitARMRegPlusImmediate - Emits a series of instructions to materialize /// a destreg = basereg + immediate in ARM code. static @@ -605,7 +628,7 @@ void ARMRegisterInfo:: eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { - if (hasFP(MF)) { + if (!hasReservedCallFrame(MF)) { // If we have alloca, convert as follows: // ADJCALLSTACKDOWN -> sub, sp, sp, amount // ADJCALLSTACKUP -> add, sp, sp, amount @@ -1146,8 +1169,9 @@ Limit = (1 << 8) - 1; goto DoneEstimating; } else if (AddrMode == ARMII::AddrMode5) { - Limit = ((1 << 8) - 1) * 4; - goto DoneEstimating; + unsigned ThisLimit = ((1 << 8) - 1) * 4; + if (ThisLimit < Limit) + Limit = ThisLimit; } } } Index: llvm/lib/Target/ARM/ARMRegisterInfo.h diff -u llvm/lib/Target/ARM/ARMRegisterInfo.h:1.17 llvm/lib/Target/ARM/ARMRegisterInfo.h:1.18 --- llvm/lib/Target/ARM/ARMRegisterInfo.h:1.17 Tue Mar 20 03:07:04 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.h Mon Apr 30 19:52:08 2007 @@ -78,6 +78,8 @@ bool hasFP(const MachineFunction &MF) const; + bool hasReservedCallFrame(MachineFunction &MF) const; + void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits