Correct the algorithms for choosing spill and restore points so that we don't try to insert loads/stores between call frame setup and the actual call.

This fixes the last known failure for the pre-alloc-splitter.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-01-29 22:13:06 +00:00
parent 15b3830bcd
commit 3ef4549d9d

View File

@ -50,6 +50,7 @@ namespace {
MachineFunction *CurrMF; MachineFunction *CurrMF;
const TargetMachine *TM; const TargetMachine *TM;
const TargetInstrInfo *TII; const TargetInstrInfo *TII;
const TargetRegisterInfo* TRI;
MachineFrameInfo *MFI; MachineFrameInfo *MFI;
MachineRegisterInfo *MRI; MachineRegisterInfo *MRI;
LiveIntervals *LIs; LiveIntervals *LIs;
@ -223,12 +224,21 @@ PreAllocSplitting::findSpillPoint(MachineBasicBlock *MBB, MachineInstr *MI,
Pt = MII; Pt = MII;
SpillIndex = Gap; SpillIndex = Gap;
break; break;
}
// We can't insert the spill between the barrier (a call), and its
// corresponding call frame setup.
} else if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode() &&
MII == MachineBasicBlock::iterator(MI))
break;
} while (MII != EndPt); } while (MII != EndPt);
} else { } else {
MachineBasicBlock::iterator MII = MI; MachineBasicBlock::iterator MII = MI;
MachineBasicBlock::iterator EndPt = DefMI MachineBasicBlock::iterator EndPt = DefMI
? MachineBasicBlock::iterator(DefMI) : MBB->begin(); ? MachineBasicBlock::iterator(DefMI) : MBB->begin();
// We can't insert the spill between the barrier (a call), and its
// corresponding call frame setup.
if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode()) --MII;
while (MII != EndPt && !RefsInMBB.count(MII)) { while (MII != EndPt && !RefsInMBB.count(MII)) {
unsigned Index = LIs->getInstructionIndex(MII); unsigned Index = LIs->getInstructionIndex(MII);
if (LIs->hasGapBeforeInstr(Index)) { if (LIs->hasGapBeforeInstr(Index)) {
@ -269,12 +279,22 @@ PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI,
Pt = MII; Pt = MII;
RestoreIndex = Gap; RestoreIndex = Gap;
break; break;
}
// We can't insert a restore between the barrier (a call) and its
// corresponding call frame teardown.
} else if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode() &&
prior(MII) == MachineBasicBlock::iterator(MI))
break;
--MII; --MII;
} while (MII != EndPt); } while (MII != EndPt);
} else { } else {
MachineBasicBlock::iterator MII = MI; MachineBasicBlock::iterator MII = MI;
MII = ++MII; MII = ++MII;
// We can't insert a restore between the barrier (a call) and its
// corresponding call frame teardown.
if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode())
++MII;
// FIXME: Limit the number of instructions to examine to reduce // FIXME: Limit the number of instructions to examine to reduce
// compile time? // compile time?
while (MII != MBB->getFirstTerminator()) { while (MII != MBB->getFirstTerminator()) {
@ -1291,6 +1311,7 @@ bool PreAllocSplitting::createsNewJoin(LiveRange* LR,
bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) { bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) {
CurrMF = &MF; CurrMF = &MF;
TM = &MF.getTarget(); TM = &MF.getTarget();
TRI = TM->getRegisterInfo();
TII = TM->getInstrInfo(); TII = TM->getInstrInfo();
MFI = MF.getFrameInfo(); MFI = MF.getFrameInfo();
MRI = &MF.getRegInfo(); MRI = &MF.getRegInfo();