diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-16 22:56:16 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-16 22:56:16 +0000 |
commit | 1d5b84508173b93faf513032b3847152e6060791 (patch) | |
tree | 739e46881a412abef08c15ccd609bc5b3b6c682a | |
parent | cc5c4296fda7270e8394626d7254596f5f9c8d82 (diff) | |
download | external_llvm-1d5b84508173b93faf513032b3847152e6060791.zip external_llvm-1d5b84508173b93faf513032b3847152e6060791.tar.gz external_llvm-1d5b84508173b93faf513032b3847152e6060791.tar.bz2 |
Add a LiveRangeEdit delegate callback before shrinking a live range.
The register allocator needs to adjust its live interval unions when that happens.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127774 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/LiveRangeEdit.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/LiveRangeEdit.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocGreedy.cpp | 12 |
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp index e994d8c..489d88c 100644 --- a/lib/CodeGen/LiveRangeEdit.cpp +++ b/lib/CodeGen/LiveRangeEdit.cpp @@ -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); } } diff --git a/lib/CodeGen/LiveRangeEdit.h b/lib/CodeGen/LiveRangeEdit.h index a784826..2bd3461 100644 --- a/lib/CodeGen/LiveRangeEdit.h +++ b/lib/CodeGen/LiveRangeEdit.h @@ -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() {} }; diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp index 940ed81..6feae47 100644 --- a/lib/CodeGen/RegAllocGreedy.cpp +++ b/lib/CodeGen/RegAllocGreedy.cpp @@ -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(); |