summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveDebugVariables.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-02 18:15:44 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-02 18:15:44 +0000
commit30e2128a731e5a0bcac45a6a79a03bdedce68a0a (patch)
treea8a5e0cfd89c3e580072681ff23340e004549298 /lib/CodeGen/LiveDebugVariables.cpp
parent1ab4b211ea5165445b791277507d58dcf1e46688 (diff)
downloadllvm-30e2128a731e5a0bcac45a6a79a03bdedce68a0a.tar.gz
llvm-30e2128a731e5a0bcac45a6a79a03bdedce68a0a.tar.bz2
llvm-30e2128a731e5a0bcac45a6a79a03bdedce68a0a.tar.xz
Update LiveDebugVariables during coalescing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120720 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r--lib/CodeGen/LiveDebugVariables.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/CodeGen/LiveDebugVariables.cpp b/lib/CodeGen/LiveDebugVariables.cpp
index 9a15a2723d..4b428f6589 100644
--- a/lib/CodeGen/LiveDebugVariables.cpp
+++ b/lib/CodeGen/LiveDebugVariables.cpp
@@ -241,6 +241,10 @@ public:
/// collecting all their def points.
void computeIntervals(LiveIntervals &LIS, MachineDominatorTree &MDT);
+ /// renameRegister - Update locations to rewrite OldReg as NewReg:SubIdx.
+ void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx,
+ const TargetRegisterInfo *TRI);
+
void print(raw_ostream&, const TargetRegisterInfo*);
};
} // namespace
@@ -269,6 +273,9 @@ class LDVImpl {
/// getUserValue - Find or create a UserValue.
UserValue *getUserValue(const MDNode *Var, unsigned Offset);
+ /// lookupVirtReg - Find the EC leader for VirtReg or null.
+ UserValue *lookupVirtReg(unsigned VirtReg);
+
/// mapVirtReg - Map virtual register to an equivalence class.
void mapVirtReg(unsigned VirtReg, UserValue *EC);
@@ -300,6 +307,9 @@ public:
userVarMap.clear();
}
+ /// renameRegister - Replace all references to OldReg wiht NewReg:SubIdx.
+ void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx);
+
void print(raw_ostream&);
};
} // namespace
@@ -379,6 +389,12 @@ void LDVImpl::mapVirtReg(unsigned VirtReg, UserValue *EC) {
Leader = UserValue::merge(Leader, EC);
}
+UserValue *LDVImpl::lookupVirtReg(unsigned VirtReg) {
+ if (UserValue *UV = virtRegMap.lookup(VirtReg))
+ return UV->getLeader();
+ return 0;
+}
+
bool LDVImpl::handleDebugValue(MachineInstr *MI, SlotIndex Idx) {
// DBG_VALUE loc, offset, variable
if (MI->getNumOperands() != 3 ||
@@ -551,3 +567,36 @@ LiveDebugVariables::~LiveDebugVariables() {
if (pImpl)
delete static_cast<LDVImpl*>(pImpl);
}
+
+void UserValue::
+renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx,
+ const TargetRegisterInfo *TRI) {
+ for (unsigned i = 0, e = locations.size(); i != e; ++i) {
+ Location &Loc = locations[i];
+ if (Loc.Kind != OldReg)
+ continue;
+ Loc.Kind = NewReg;
+ if (SubIdx && Loc.Data.SubIdx)
+ Loc.Data.SubIdx = TRI->composeSubRegIndices(SubIdx, Loc.Data.SubIdx);
+ }
+}
+
+void LDVImpl::
+renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx) {
+ for (UserValue *UV = lookupVirtReg(OldReg); UV; UV = UV->getNext())
+ UV->renameRegister(OldReg, NewReg, SubIdx, TRI);
+}
+
+void LiveDebugVariables::
+renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx) {
+ if (pImpl)
+ static_cast<LDVImpl*>(pImpl)->renameRegister(OldReg, NewReg, SubIdx);
+}
+
+#ifndef NDEBUG
+void LiveDebugVariables::dump() {
+ if (pImpl)
+ static_cast<LDVImpl*>(pImpl)->print(dbgs());
+}
+#endif
+