[llvm-commits] [llvm] r161115 - /llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Wed Aug 1 09:02:59 PDT 2012
Author: stoklund
Date: Wed Aug 1 11:02:59 2012
New Revision: 161115
URL: http://llvm.org/viewvc/llvm-project?rev=161115&view=rev
Log:
Add DataDep constructors. Explicitly check SSA form.
Modified:
llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
Modified: llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp?rev=161115&r1=161114&r2=161115&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineTraceMetrics.cpp Wed Aug 1 11:02:59 2012
@@ -515,6 +515,20 @@
const MachineInstr *DefMI;
unsigned DefOp;
unsigned UseOp;
+
+ DataDep(const MachineInstr *DefMI, unsigned DefOp, unsigned UseOp)
+ : DefMI(DefMI), DefOp(DefOp), UseOp(UseOp) {}
+
+ /// Create a DataDep from an SSA form virtual register.
+ DataDep(const MachineRegisterInfo *MRI, unsigned VirtReg, unsigned UseOp)
+ : UseOp(UseOp) {
+ assert(TargetRegisterInfo::isVirtualRegister(VirtReg));
+ MachineRegisterInfo::def_iterator DefI = MRI->def_begin(VirtReg);
+ assert(!DefI.atEnd() && "Register has no defs");
+ DefMI = &*DefI;
+ DefOp = DefI.getOperandNo();
+ assert((++DefI).atEnd() && "Register has multiple defs");
+ }
};
}
@@ -535,14 +549,8 @@
continue;
}
// Collect virtual register reads.
- if (!MO->readsReg())
- continue;
- MachineRegisterInfo::def_iterator DefI = MRI->def_begin(Reg);
- DataDep Dep;
- Dep.DefMI = &*DefI;
- Dep.DefOp = DefI.getOperandNo();
- Dep.UseOp = MO.getOperandNo();
- Deps.push_back(Dep);
+ if (MO->readsReg())
+ Deps.push_back(DataDep(MRI, Reg, MO.getOperandNo()));
}
return HasPhysRegs;
}
@@ -561,13 +569,7 @@
for (unsigned i = 1; i != UseMI->getNumOperands(); i += 2) {
if (UseMI->getOperand(i + 1).getMBB() == Pred) {
unsigned Reg = UseMI->getOperand(i).getReg();
- assert(TargetRegisterInfo::isVirtualRegister(Reg) && "Bad PHI op");
- MachineRegisterInfo::def_iterator DefI = MRI->def_begin(Reg);
- DataDep Dep;
- Dep.DefMI = &*DefI;
- Dep.DefOp = DefI.getOperandNo();
- Dep.UseOp = i;
- Deps.push_back(Dep);
+ Deps.push_back(DataDep(MRI, Reg, i));
return;
}
}
@@ -617,11 +619,7 @@
SparseSet<LiveRegUnit>::iterator I = RegUnits.find(*Units);
if (I == RegUnits.end())
continue;
- DataDep Dep;
- Dep.DefMI = I->DefMI;
- Dep.DefOp = I->DefOp;
- Dep.UseOp = MO.getOperandNo();
- Deps.push_back(Dep);
+ Deps.push_back(DataDep(I->DefMI, I->DefOp, MO.getOperandNo()));
break;
}
}
More information about the llvm-commits
mailing list