[llvm-commits] [llvm] r117631 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Oct 28 17:40:59 PDT 2010
Author: stoklund
Date: Thu Oct 28 19:40:59 2010
New Revision: 117631
URL: http://llvm.org/viewvc/llvm-project?rev=117631&view=rev
Log:
Fix broken equivalence class calculation. We could probably also use
EquvivalenceClasses.h except it looks like overkill when elements are continuous
integers.
Modified:
llvm/trunk/lib/CodeGen/LiveInterval.cpp
Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=117631&r1=117630&r2=117631&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Thu Oct 28 19:40:59 2010
@@ -709,15 +709,14 @@
/// multiple LiveIntervals.
void ConnectedVNInfoEqClasses::Connect(unsigned a, unsigned b) {
- unsigned eqa = eqClass_[a];
- unsigned eqb = eqClass_[b];
- if (eqa == eqb)
- return;
- // Make sure a and b are in the same class while maintaining eqClass_[i] <= i.
- if (eqa > eqb)
- eqClass_[a] = eqb;
- else
- eqClass_[b] = eqa;
+ while (eqClass_[a] != eqClass_[b]) {
+ if (eqClass_[a] > eqClass_[b])
+ std::swap(a, b);
+ unsigned t = eqClass_[b];
+ assert(t <= b && "Invariant broken");
+ eqClass_[b] = eqClass_[a];
+ b = t;
+ }
}
unsigned ConnectedVNInfoEqClasses::Renumber() {
@@ -745,8 +744,6 @@
for (LiveInterval::const_vni_iterator I = LI->vni_begin(), E = LI->vni_end();
I != E; ++I) {
const VNInfo *VNI = *I;
- if (VNI->id == eqClass_.size())
- eqClass_.push_back(VNI->id);
assert(!VNI->isUnused() && "Cannot handle unused values");
if (VNI->isPHIDef()) {
const MachineBasicBlock *MBB = lis_.getMBBFromIndex(VNI->def);
More information about the llvm-commits
mailing list