diff options
Diffstat (limited to 'llvm/lib/Target/ARM/ARMFrameLowering.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMFrameLowering.cpp | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp index 2703af7d73b..3b1c843f035 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -322,24 +322,6 @@ static void emitAligningInstructions(MachineFunction &MF, ARMFunctionInfo *AFI, } } -/// We need the offset of the frame pointer relative to other MachineFrameInfo -/// offsets which are encoded relative to SP at function begin. -/// See also emitPrologue() for how the FP is set up. -/// Unfortunately we cannot determine this value in determineCalleeSaves() yet -/// as assignCalleeSavedSpillSlots() hasn't run at this point. Instead we use -/// this to produce a conservative estimate that we check in an assert() later. -static int getMaxFPOffset(const Function &F, const ARMFunctionInfo &AFI) { - // We may end up saving a lot of registers that are higher numbered than the - // r7 used for FP in thumb. - if (F.hasFnAttribute("interrupt") || - F.getCallingConv() == CallingConv::CXX_FAST_TLS) - return -AFI.getArgRegsSaveSize() - (8 * 4); - - // Usually it is just the link register and the FP itself (and in rare cases - // r12?) saved to reach FP. - return -AFI.getArgRegsSaveSize() - 12; -} - void ARMFrameLowering::emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const { MachineBasicBlock::iterator MBBI = MBB.begin(); @@ -450,10 +432,8 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF, unsigned DPRCSOffset = GPRCS2Offset - DPRGapSize - DPRCSSize; int FramePtrOffsetInPush = 0; if (HasFP) { - int FPOffset = MFI.getObjectOffset(FramePtrSpillFI); - assert(getMaxFPOffset(*MF.getFunction(), *AFI) <= FPOffset && - "Max FP estimation is wrong"); - FramePtrOffsetInPush = FPOffset + ArgRegsSaveSize; + FramePtrOffsetInPush = + MFI.getObjectOffset(FramePtrSpillFI) + ArgRegsSaveSize; AFI->setFramePtrSpillOffset(MFI.getObjectOffset(FramePtrSpillFI) + NumBytes); } @@ -1720,14 +1700,6 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, // worth the effort and added fragility? unsigned EstimatedStackSize = MFI.estimateStackSize(MF) + 4 * (NumGPRSpills + NumFPRSpills); - - // Determine biggest (positive) SP offset in MachineFrameInfo. - int MaxFixedOffset = 0; - for (int I = MFI.getObjectIndexBegin(); I < 0; ++I) { - int MaxObjectOffset = MFI.getObjectOffset(I) + MFI.getObjectSize(I); - MaxFixedOffset = std::max(MaxFixedOffset, MaxObjectOffset); - } - bool HasFP = hasFP(MF); if (HasFP) { if (AFI->hasStackFrame()) @@ -1735,20 +1707,15 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, } else { // If FP is not used, SP will be used to access arguments, so count the // size of arguments into the estimation. - EstimatedStackSize += MaxFixedOffset; + EstimatedStackSize += AFI->getArgumentStackSize(); } EstimatedStackSize += 16; // For possible paddings. - unsigned EstimatedRSStackSizeLimit = estimateRSStackSizeLimit(MF, this); - int MaxFPOffset = getMaxFPOffset(*MF.getFunction(), *AFI); - bool BigFrameOffsets = EstimatedStackSize >= EstimatedRSStackSizeLimit || - MFI.hasVarSizedObjects() || - (MFI.adjustsStack() && !canSimplifyCallFramePseudos(MF)) || - // For large argument stacks fp relative addressed may overflow. - (HasFP && (MaxFixedOffset - MaxFPOffset) >= (int)EstimatedRSStackSizeLimit); + bool BigStack = EstimatedStackSize >= estimateRSStackSizeLimit(MF, this) || + MFI.hasVarSizedObjects() || + (MFI.adjustsStack() && !canSimplifyCallFramePseudos(MF)); bool ExtraCSSpill = false; - if (BigFrameOffsets || - !CanEliminateFrame || RegInfo->cannotEliminateFrame(MF)) { + if (BigStack || !CanEliminateFrame || RegInfo->cannotEliminateFrame(MF)) { AFI->setHasStackFrame(true); if (HasFP) { @@ -1932,7 +1899,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF, // callee-saved register or reserve a special spill slot to facilitate // register scavenging. Thumb1 needs a spill slot for stack pointer // adjustments also, even when the frame itself is small. - if (BigFrameOffsets && !ExtraCSSpill) { + if (BigStack && !ExtraCSSpill) { // If any non-reserved CS register isn't spilled, just spill one or two // extra. That should take care of it! unsigned NumExtras = TargetAlign / 4; |