Fix several bugs in the new fast-path:

1) Remove an incorrect assertion.
  2) Set the stack slot weight properly.
  3) Resize the VirtRegMap when needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson
2008-08-18 21:20:32 +00:00
parent 70053c340e
commit 9a03293145

View File

@@ -1608,11 +1608,7 @@ std::vector<LiveInterval*> LiveIntervals::
addIntervalsForSpillsFast(const LiveInterval &li, addIntervalsForSpillsFast(const LiveInterval &li,
const MachineLoopInfo *loopInfo, const MachineLoopInfo *loopInfo,
VirtRegMap &vrm, float& SSWeight) { VirtRegMap &vrm, float& SSWeight) {
unsigned slot = vrm.assignVirt2StackSlot(li.reg); vrm.assignVirt2StackSlot(li.reg);
// since this is called after the analysis is done we don't know if
// LiveVariables is available
lv_ = getAnalysisToUpdate<LiveVariables>();
std::vector<LiveInterval*> added; std::vector<LiveInterval*> added;
@@ -1628,14 +1624,17 @@ addIntervalsForSpillsFast(const LiveInterval &li,
DenseMap<MachineInstr*, unsigned> VRegMap; DenseMap<MachineInstr*, unsigned> VRegMap;
DenseMap<MachineInstr*, VNInfo*> VNMap; DenseMap<MachineInstr*, VNInfo*> VNMap;
SSWeight = 0.0f;
for (MachineRegisterInfo::reg_iterator RI = mri_->reg_begin(li.reg), for (MachineRegisterInfo::reg_iterator RI = mri_->reg_begin(li.reg),
RE = mri_->reg_end(); RI != RE; ) { RE = mri_->reg_end(); RI != RE; ) {
// Create a new virtual register for the spill interval. // Create a new virtual register for the spill interval.
MachineOperand& MO = RI.getOperand(); MachineOperand& MO = RI.getOperand();
unsigned NewVReg = 0; unsigned NewVReg = 0;
if (!VRegMap.count(MO.getParent())) if (!VRegMap.count(MO.getParent())) {
VRegMap[MO.getParent()] = NewVReg = mri_->createVirtualRegister(rc); VRegMap[MO.getParent()] = NewVReg = mri_->createVirtualRegister(rc);
else vrm.grow();
} else
NewVReg = VRegMap[MO.getParent()]; NewVReg = VRegMap[MO.getParent()];
// Increment iterator to avoid invalidation. // Increment iterator to avoid invalidation.
@@ -1644,10 +1643,7 @@ addIntervalsForSpillsFast(const LiveInterval &li,
MO.setReg(NewVReg); MO.setReg(NewVReg);
// create a new register for this spill // create a new register for this spill
vrm.grow();
vrm.assignVirt2StackSlot(NewVReg, slot);
LiveInterval &nI = getOrCreateInterval(NewVReg); LiveInterval &nI = getOrCreateInterval(NewVReg);
assert(nI.empty());
// the spill weight is now infinity as it // the spill weight is now infinity as it
// cannot be spilled again // cannot be spilled again
@@ -1673,16 +1669,20 @@ addIntervalsForSpillsFast(const LiveInterval &li,
added.push_back(&nI); added.push_back(&nI);
// update live variables if it is available
if (lv_)
lv_->addVirtualRegisterKilled(NewVReg, MO.getParent());
DOUT << "\t\t\t\tadded new interval: "; DOUT << "\t\t\t\tadded new interval: ";
DEBUG(nI.dump()); DEBUG(nI.dump());
DOUT << '\n'; DOUT << '\n';
}
SSWeight = HUGE_VALF; unsigned loopDepth = loopInfo->getLoopDepth(MO.getParent()->getParent());
if (HasUse) {
if (HasDef)
SSWeight += getSpillWeight(true, true, loopDepth);
else
SSWeight += getSpillWeight(false, true, loopDepth);
} else
SSWeight += getSpillWeight(true, false, loopDepth);
}
std::sort(added.begin(), added.end(), LISorter()); std::sort(added.begin(), added.end(), LISorter());