llvm.org GIT mirror llvm / 010b1b9
Do not use frame register to reference fixed stack objects if the function is frameless. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79067 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 10 years ago
2 changed file(s) with 14 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
439439 MFI->isFrameAddressTaken());
440440 }
441441
442 bool ARMBaseRegisterInfo::hasStackFrame(const MachineFunction &MF) const {
442 bool ARMBaseRegisterInfo::cannotEliminateFrame(const MachineFunction &MF) const {
443443 const MachineFrameInfo *MFI = MF.getFrameInfo();
444444 if (NoFramePointerElim && MFI->hasCalls())
445445 return true;
595595 }
596596
597597 bool ExtraCSSpill = false;
598 if (!CanEliminateFrame || hasStackFrame(MF)) {
598 if (!CanEliminateFrame || cannotEliminateFrame(MF)) {
599599 AFI->setHasStackFrame(true);
600600
601601 // If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled.
10211021 MachineInstr &MI = *II;
10221022 MachineBasicBlock &MBB = *MI.getParent();
10231023 MachineFunction &MF = *MBB.getParent();
1024 const MachineFrameInfo *MFI = MF.getFrameInfo();
10241025 ARMFunctionInfo *AFI = MF.getInfo();
10251026 assert(!AFI->isThumb1OnlyFunction() &&
10261027 "This eliminateFrameIndex does not suppor Thumb1!");
10321033
10331034 unsigned FrameReg = ARM::SP;
10341035 int FrameIndex = MI.getOperand(i).getIndex();
1035 int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
1036 MF.getFrameInfo()->getStackSize() + SPAdj;
1036 int Offset = MFI->getObjectOffset(FrameIndex) + MFI->getStackSize() + SPAdj;
10371037
10381038 if (AFI->isGPRCalleeSavedArea1Frame(FrameIndex))
10391039 Offset -= AFI->getGPRCalleeSavedArea1Offset();
10411041 Offset -= AFI->getGPRCalleeSavedArea2Offset();
10421042 else if (AFI->isDPRCalleeSavedAreaFrame(FrameIndex))
10431043 Offset -= AFI->getDPRCalleeSavedAreaOffset();
1044 else if (hasFP(MF)) {
1045 assert(SPAdj == 0 && "Unexpected");
1046 // There is alloca()'s in this function, must reference off the frame
1047 // pointer instead.
1044 else if (hasFP(MF) && AFI->hasStackFrame()) {
1045 assert(SPAdj == 0 && "Unexpected stack offset!");
1046 // Use frame pointer to reference fixed objects unless this is a
1047 // frameless function,
10481048 FrameReg = getFrameRegister(MF);
10491049 Offset -= AFI->getFramePtrSpillOffset();
10501050 }
12871287
12881288 // Darwin ABI requires FP to point to the stack slot that contains the
12891289 // previous FP.
1290 if ((STI.isTargetDarwin() && NumBytes) || hasFP(MF)) {
1290 bool HasFP = hasFP(MF);
1291 if ((STI.isTargetDarwin() && NumBytes) || HasFP) {
12911292 NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
12921293 // Reset SP based on frame pointer only if the stack frame extends beyond
12931294 // frame pointer stack slot or target is ELF and the function has FP.
1294 if (AFI->getGPRCalleeSavedArea2Size() ||
1295 if (HasFP ||
1296 AFI->getGPRCalleeSavedArea2Size() ||
12951297 AFI->getDPRCalleeSavedAreaSize() ||
1296 AFI->getDPRCalleeSavedAreaOffset()||
1297 hasFP(MF)) {
1298 AFI->getDPRCalleeSavedAreaOffset()) {
12981299 if (NumBytes) {
12991300 if (isARM)
13001301 emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes,
8888
8989 bool hasFP(const MachineFunction &MF) const;
9090
91 bool hasStackFrame(const MachineFunction &MF) const;
91 bool cannotEliminateFrame(const MachineFunction &MF) const;
9292
9393 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
9494 RegScavenger *RS = NULL) const;