diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-02-09 01:14:03 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-02-09 01:14:03 +0000 |
commit | 1305bc0a6572cf0b884fffe2c5aeb9e1a006ff3b (patch) | |
tree | 0e59e6b74bcfb423a578b1d8fb29e8ad4a765ea6 /llvm/lib/CodeGen/RegAllocBasic.cpp | |
parent | f4cd4f94d9300efbbc3b25832ac433d0bc609f23 (diff) | |
download | bcm5719-llvm-1305bc0a6572cf0b884fffe2c5aeb9e1a006ff3b.tar.gz bcm5719-llvm-1305bc0a6572cf0b884fffe2c5aeb9e1a006ff3b.zip |
Evict a lighter single interference before attempting to split a live range.
Registers are not allocated strictly in spill weight order when live range
splitting and spilling has created new shorter intervals with higher spill
weights.
When one of the new heavy intervals conflicts with a single lighter interval,
simply evict the old interval instead of trying to split the heavy one.
The lighter interval is a better candidate for splitting, it has a smaller use
density.
llvm-svn: 125151
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocBasic.cpp')
-rw-r--r-- | llvm/lib/CodeGen/RegAllocBasic.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/RegAllocBasic.cpp b/llvm/lib/CodeGen/RegAllocBasic.cpp index 1175923cd27..7fbb035ed61 100644 --- a/llvm/lib/CodeGen/RegAllocBasic.cpp +++ b/llvm/lib/CodeGen/RegAllocBasic.cpp @@ -238,6 +238,18 @@ seedLiveVirtRegs(std::priority_queue<std::pair<float, unsigned> > &VirtRegQ) { } } +void RegAllocBase::assign(LiveInterval &VirtReg, unsigned PhysReg) { + assert(!VRM->hasPhys(VirtReg.reg) && "Duplicate VirtReg assignment"); + VRM->assignVirt2Phys(VirtReg.reg, PhysReg); + PhysReg2LiveUnion[PhysReg].unify(VirtReg); +} + +void RegAllocBase::unassign(LiveInterval &VirtReg, unsigned PhysReg) { + assert(VRM->getPhys(VirtReg.reg) == PhysReg && "Inconsistent unassign"); + PhysReg2LiveUnion[PhysReg].extract(VirtReg); + VRM->clearVirt(VirtReg.reg); +} + // Top-level driver to manage the queue of unassigned VirtRegs and call the // selectOrSplit implementation. void RegAllocBase::allocatePhysRegs() { @@ -264,9 +276,7 @@ void RegAllocBase::allocatePhysRegs() { if (AvailablePhysReg) { DEBUG(dbgs() << "allocating: " << TRI->getName(AvailablePhysReg) << " for " << VirtReg << '\n'); - assert(!VRM->hasPhys(VirtReg.reg) && "duplicate vreg in union"); - VRM->assignVirt2Phys(VirtReg.reg, AvailablePhysReg); - PhysReg2LiveUnion[AvailablePhysReg].unify(VirtReg); + assign(VirtReg, AvailablePhysReg); } for (VirtRegVec::iterator I = SplitVRegs.begin(), E = SplitVRegs.end(); I != E; ++I) { @@ -308,10 +318,7 @@ void RegAllocBase::spillReg(LiveInterval& VirtReg, unsigned PhysReg, // Deallocate the interfering vreg by removing it from the union. // A LiveInterval instance may not be in a union during modification! - PhysReg2LiveUnion[PhysReg].extract(SpilledVReg); - - // Clear the vreg assignment. - VRM->clearVirt(SpilledVReg.reg); + unassign(SpilledVReg, PhysReg); // Spill the extracted interval. spiller().spill(&SpilledVReg, SplitVRegs, PendingSpills); |