[llvm-commits] [llvm] r120720 - in /llvm/trunk/lib/CodeGen: LiveDebugVariables.cpp LiveDebugVariables.h SimpleRegisterCoalescing.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Dec 2 10:15:44 PST 2010
Author: stoklund
Date: Thu Dec 2 12:15:44 2010
New Revision: 120720
URL: http://llvm.org/viewvc/llvm-project?rev=120720&view=rev
Log:
Update LiveDebugVariables during coalescing.
Modified:
llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp
llvm/trunk/lib/CodeGen/LiveDebugVariables.h
llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=120720&r1=120719&r2=120720&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Thu Dec 2 12:15:44 2010
@@ -241,6 +241,10 @@
/// 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 @@
/// 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 @@
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 @@
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 @@
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
+
Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.h?rev=120720&r1=120719&r2=120720&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveDebugVariables.h (original)
+++ llvm/trunk/lib/CodeGen/LiveDebugVariables.h Thu Dec 2 12:15:44 2010
@@ -44,6 +44,9 @@
/// that happened during register allocation.
void emitDebugValues();
+ /// dump - Print data structures to dbgs().
+ void dump();
+
private:
virtual bool runOnMachineFunction(MachineFunction &);
Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=120720&r1=120719&r2=120720&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Thu Dec 2 12:15:44 2010
@@ -696,6 +696,9 @@
unsigned DstReg = CP.getDstReg();
unsigned SubIdx = CP.getSubIdx();
+ // Update LiveDebugVariables.
+ ldv_->renameRegister(SrcReg, DstReg, SubIdx);
+
for (MachineRegisterInfo::reg_iterator I = mri_->reg_begin(SrcReg);
MachineInstr *UseMI = I.skipInstruction();) {
// A PhysReg copy that won't be coalesced can perhaps be rematerialized
@@ -1779,6 +1782,7 @@
}
DEBUG(dump());
+ DEBUG(ldv_->dump());
return true;
}
More information about the llvm-commits
mailing list