ARM fix: Miscompilation when frame pointer can't be eliminated. Uninitialized frame pointer register is used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33703 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lauro Ramos Venancio
2007-01-31 13:12:46 +00:00
parent 193f850880
commit b5b84f92bf
4 changed files with 12 additions and 13 deletions

View File

@@ -573,8 +573,7 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const{
// There is alloca()'s in this function, must reference off the frame
// pointer instead.
FrameReg = getFrameRegister(MF);
if (STI.isTargetDarwin())
Offset -= AFI->getFramePtrSpillOffset();
Offset -= AFI->getFramePtrSpillOffset();
}
unsigned Opcode = MI.getOpcode();
@@ -882,6 +881,12 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
}
}
if (hasFP(MF)) {
MF.changePhyRegUsed(FramePtr, true);
NumGPRSpills++;
CanEliminateFrame = false;
}
if (!CanEliminateFrame) {
AFI->setHasStackFrame(true);
@@ -895,11 +900,6 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
ForceLRSpill = false;
}
if (STI.isTargetDarwin()) {
MF.changePhyRegUsed(FramePtr, true);
NumGPRSpills++;
}
// If stack and double are 8-byte aligned and we are spilling an odd number
// of GPRs. Spill one extra callee save GPR so we won't have to pad between
// the integer and double callee save areas.
@@ -1030,7 +1030,7 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
++MBBI;
// Point FP to the stack slot that contains the previous FP.
if (STI.isTargetDarwin())
if (hasFP(MF))
BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
.addFrameIndex(FramePtrSpillFI).addImm(0);
@@ -1116,7 +1116,7 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
if (isThumb)
emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII);
else {
if (STI.isTargetDarwin()) {
if (hasFP(MF)){
NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
// Reset SP based on frame pointer only if the stack frame extends beyond
// frame pointer stack slot.
@@ -1131,7 +1131,6 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
} else if (NumBytes) {
emitSPUpdate(MBB, MBBI, NumBytes, false, TII);
}
// Move SP to start of integer callee save spill area 2.
movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
emitSPUpdate(MBB, MBBI, AFI->getDPRCalleeSavedAreaSize(), false, TII);