Prologue and epilogue bugs for non-Darwin targets.
llvm-svn: 33390
This commit is contained in:
parent
aa24f08926
commit
a9af4be5ac
|
|
@ -484,7 +484,8 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const{
|
||||||
// There is alloca()'s in this function, must reference off the frame
|
// There is alloca()'s in this function, must reference off the frame
|
||||||
// pointer instead.
|
// pointer instead.
|
||||||
FrameReg = getFrameRegister(MF);
|
FrameReg = getFrameRegister(MF);
|
||||||
Offset -= AFI->getFramePtrSpillOffset();
|
if (STI.isTargetDarwin())
|
||||||
|
Offset -= AFI->getFramePtrSpillOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Opcode = MI.getOpcode();
|
unsigned Opcode = MI.getOpcode();
|
||||||
|
|
@ -724,6 +725,14 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
|
||||||
if (Spilled) {
|
if (Spilled) {
|
||||||
NumGPRSpills++;
|
NumGPRSpills++;
|
||||||
|
|
||||||
|
if (!STI.isTargetDarwin()) {
|
||||||
|
if (Reg == ARM::LR)
|
||||||
|
LRSpilled = true;
|
||||||
|
else
|
||||||
|
CS1Spilled = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Keep track if LR and any of R4, R5, R6, and R7 is spilled.
|
// Keep track if LR and any of R4, R5, R6, and R7 is spilled.
|
||||||
switch (Reg) {
|
switch (Reg) {
|
||||||
case ARM::LR:
|
case ARM::LR:
|
||||||
|
|
@ -739,6 +748,11 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (!STI.isTargetDarwin()) {
|
||||||
|
UnspilledCS1GPRs.push_back(Reg);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (Reg) {
|
switch (Reg) {
|
||||||
case ARM::R4:
|
case ARM::R4:
|
||||||
case ARM::R5:
|
case ARM::R5:
|
||||||
|
|
@ -768,17 +782,21 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
|
||||||
UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
|
UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If stack and double are 8-byte aligned and we are spilling a odd number
|
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
|
// of GPRs. Spill one extra callee save GPR so we won't have to pad between
|
||||||
// the integer and double callee save areas.
|
// the integer and double callee save areas.
|
||||||
unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
|
unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
|
||||||
if (TargetAlign == 8 && (NumGPRSpills & 1)) {
|
if (TargetAlign == 8 && (NumGPRSpills & 1)) {
|
||||||
if (CS1Spilled && !UnspilledCS1GPRs.empty())
|
if (CS1Spilled && !UnspilledCS1GPRs.empty())
|
||||||
MF.changePhyRegUsed(UnspilledCS1GPRs.front(), true);
|
MF.changePhyRegUsed(UnspilledCS1GPRs.front(), true);
|
||||||
else
|
else if (!UnspilledCS2GPRs.empty())
|
||||||
MF.changePhyRegUsed(UnspilledCS2GPRs.front(), true);
|
MF.changePhyRegUsed(UnspilledCS2GPRs.front(), true);
|
||||||
}
|
}
|
||||||
MF.changePhyRegUsed(FramePtr, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -871,18 +889,21 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Align == 8 && (GPRCS1Size & 7) != 0)
|
||||||
|
// Pad CS1 to ensure proper alignment.
|
||||||
|
GPRCS1Size += 4;
|
||||||
|
|
||||||
if (!isThumb) {
|
if (!isThumb) {
|
||||||
// Build the new SUBri to adjust SP for integer callee-save spill area 1.
|
// Build the new SUBri to adjust SP for integer callee-save spill area 1.
|
||||||
emitSPUpdate(MBB, MBBI, -GPRCS1Size, isThumb, TII);
|
emitSPUpdate(MBB, MBBI, -GPRCS1Size, isThumb, TII);
|
||||||
movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
|
movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
|
||||||
} else {
|
} else if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
|
||||||
if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
|
++MBBI;
|
||||||
++MBBI;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Point FP to the stack slot that contains the previous FP.
|
// Point FP to the stack slot that contains the previous FP.
|
||||||
BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
|
if (STI.isTargetDarwin())
|
||||||
.addFrameIndex(FramePtrSpillFI).addImm(0);
|
BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
|
||||||
|
.addFrameIndex(FramePtrSpillFI).addImm(0);
|
||||||
|
|
||||||
if (!isThumb) {
|
if (!isThumb) {
|
||||||
// Build the new SUBri to adjust SP for integer callee-save spill area 2.
|
// Build the new SUBri to adjust SP for integer callee-save spill area 2.
|
||||||
|
|
@ -977,18 +998,21 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||||
if (isThumb)
|
if (isThumb)
|
||||||
emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
|
emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
|
||||||
else {
|
else {
|
||||||
NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
|
if (STI.isTargetDarwin()) {
|
||||||
// Reset SP based on frame pointer only if the stack frame extends beyond
|
NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
|
||||||
// frame pointer stack slot.
|
// Reset SP based on frame pointer only if the stack frame extends beyond
|
||||||
if (AFI->getGPRCalleeSavedArea2Size() ||
|
// frame pointer stack slot.
|
||||||
AFI->getDPRCalleeSavedAreaSize() ||
|
if (AFI->getGPRCalleeSavedArea2Size() ||
|
||||||
AFI->getDPRCalleeSavedAreaOffset())
|
AFI->getDPRCalleeSavedAreaSize() ||
|
||||||
if (NumBytes)
|
AFI->getDPRCalleeSavedAreaOffset())
|
||||||
BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
|
if (NumBytes)
|
||||||
.addImm(NumBytes);
|
BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
|
||||||
else
|
.addImm(NumBytes);
|
||||||
BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tMOVrr : ARM::MOVrr),
|
else
|
||||||
ARM::SP).addReg(FramePtr);
|
BuildMI(MBB, MBBI, TII.get(ARM::MOVrr), ARM::SP).addReg(FramePtr);
|
||||||
|
} else if (NumBytes) {
|
||||||
|
emitSPUpdate(MBB, MBBI, NumBytes, false, TII);
|
||||||
|
}
|
||||||
|
|
||||||
// Move SP to start of integer callee save spill area 2.
|
// Move SP to start of integer callee save spill area 2.
|
||||||
movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
|
movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue