summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-03-16 22:56:16 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-03-16 22:56:16 +0000
commit1d5b84508173b93faf513032b3847152e6060791 (patch)
tree739e46881a412abef08c15ccd609bc5b3b6c682a /lib
parentcc5c4296fda7270e8394626d7254596f5f9c8d82 (diff)
downloadllvm-1d5b84508173b93faf513032b3847152e6060791.tar.gz
llvm-1d5b84508173b93faf513032b3847152e6060791.tar.bz2
llvm-1d5b84508173b93faf513032b3847152e6060791.tar.xz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/LiveRangeEdit.cpp5
-rw-r--r--lib/CodeGen/LiveRangeEdit.h3
-rw-r--r--lib/CodeGen/RegAllocGreedy.cpp12
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp
index e994d8c32d..489d88c1df 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 a784826e95..2bd34611c2 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 940ed81465..6feae4790d 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();