Fix PR5149.

http://llvm.org/bugs/show_bug.cgi?id=5149



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86543 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bruno Cardoso Lopes 2009-11-09 14:27:49 +00:00
parent 47fc9d3366
commit b8e0ebf034
2 changed files with 6 additions and 8 deletions

View File

@ -103,6 +103,7 @@ public:
int getGPFI() const { return GPHolder.FI; }
void setGPStackOffset(int Off) { GPHolder.SPOffset = Off; }
void setGPFI(int FI) { GPHolder.FI = FI; }
bool needGPSaveRestore() const { return GPHolder.SPOffset != -1; }
bool hasLoadArgs() const { return HasLoadArgs; }
bool hasStoreVarArgs() const { return HasStoreVarArgs; }

View File

@ -438,11 +438,10 @@ emitPrologue(MachineFunction &MF) const
.addReg(Mips::SP).addReg(Mips::ZERO);
}
// PIC speficic function prologue
if ((isPIC) && (MFI->hasCalls())) {
// Restore GP from the saved stack location
if (MipsFI->needGPSaveRestore())
BuildMI(MBB, MBBI, dl, TII.get(Mips::CPRESTORE))
.addImm(MipsFI->getGPStackOffset());
}
}
void MipsRegisterInfo::
@ -489,13 +488,11 @@ emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const
void MipsRegisterInfo::
processFunctionBeforeFrameFinalized(MachineFunction &MF) const {
// Set the SPOffset on the FI where GP must be saved/loaded.
// Set the stack offset where GP must be saved/loaded from.
MachineFrameInfo *MFI = MF.getFrameInfo();
bool isPIC = (MF.getTarget().getRelocationModel() == Reloc::PIC_);
if (MFI->hasCalls() && isPIC) {
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
if (MipsFI->needGPSaveRestore())
MFI->setObjectOffset(MipsFI->getGPFI(), MipsFI->getGPStackOffset());
}
}
unsigned MipsRegisterInfo::