Add a LiveRangeEdit delegate callback before shrinking a live range.

The register allocator needs to adjust its live interval unions when that happens.

llvm-svn: 127774
This commit is contained in:
Jakob Stoklund Olesen 2011-03-16 22:56:16 +00:00
parent c738c96519
commit e14b2b226f
3 changed files with 19 additions and 1 deletions

View File

@ -201,8 +201,11 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
break;
// Shrink just one live interval. Then delete new dead defs.
LIS.shrinkToUses(ToShrink.back(), &Dead);
LiveInterval *LI = ToShrink.back();
ToShrink.pop_back();
if (delegate_)
delegate_->LRE_WillShrinkVirtReg(LI->reg);
LIS.shrinkToUses(LI, &Dead);
}
}

View File

@ -39,6 +39,9 @@ public:
/// its deletion from LiveIntervals.
virtual bool LRE_CanEraseVirtReg(unsigned) { return true; }
/// Called before shrinking the live range of a virtual register.
virtual void LRE_WillShrinkVirtReg(unsigned) {}
virtual ~Delegate() {}
};

View File

@ -162,6 +162,7 @@ public:
private:
void LRE_WillEraseInstruction(MachineInstr*);
bool LRE_CanEraseVirtReg(unsigned);
void LRE_WillShrinkVirtReg(unsigned);
bool checkUncachedInterference(LiveInterval&, unsigned);
LiveInterval *getSingleInterference(LiveInterval&, unsigned);
@ -260,6 +261,17 @@ bool RAGreedy::LRE_CanEraseVirtReg(unsigned VirtReg) {
return false;
}
void RAGreedy::LRE_WillShrinkVirtReg(unsigned VirtReg) {
unsigned PhysReg = VRM->getPhys(VirtReg);
if (!PhysReg)
return;
// Register is assigned, put it back on the queue for reassignment.
LiveInterval &LI = LIS->getInterval(VirtReg);
unassign(LI, PhysReg);
enqueue(&LI);
}
void RAGreedy::releaseMemory() {
SpillerInstance.reset(0);
LRStage.clear();