[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Jul 18 21:47:46 PDT 2004
Changes in directory llvm/lib/CodeGen:
RegAllocLinearScan.cpp updated: 1.77 -> 1.78
---
Log message:
Add some asserts that the list of intervals returned by addIntervalsForSpills
is sorted. This is not the case currently, which is causing no end of
problems.
---
Diffs of the changes: (+30 -6)
Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp
diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.77 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.78
--- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.77 Sun Jul 4 12:23:35 2004
+++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Jul 18 23:47:36 2004
@@ -386,18 +386,42 @@
int slot = vrm_->assignVirt2StackSlot(cur->reg);
std::vector<LiveInterval*> added =
li_->addIntervalsForSpills(*cur, *vrm_, slot);
-
- // merge added with unhandled
+ if (added.empty())
+ return; // Early exit if all spills were folded.
+#ifndef NDEBUG
+ int OldStart = -1;
+#endif
+
+ // Merge added with unhandled. Note that we know that
+ // addIntervalsForSpills returns intervals sorted by their starting
+ // point.
std::vector<LiveInterval*>::iterator addedIt = added.begin();
std::vector<LiveInterval*>::iterator addedItEnd = added.end();
- for (IntervalPtrs::iterator i = unhandled_.begin(), e = unhandled_.end();
+ for (IntervalPtrs::iterator i = unhandled_.begin(), e =unhandled_.end();
i != e && addedIt != addedItEnd; ++i) {
- if ((*i)->start() > (*addedIt)->start())
+ while ((*i)->start() > (*addedIt)->start() &&
+ addedIt != addedItEnd) {
+#ifndef NDEBUG
+ // This code only works if addIntervalsForSpills retursn a
+ // sorted interval list. Assert this is the case now.
+ assert(OldStart <= (int)(*addedIt)->start() &&
+ "addIntervalsForSpills didn't return sorted interval list!");
+ OldStart = (*addedIt)->start();
+#endif
i = unhandled_.insert(i, *(addedIt++));
+ }
}
- while (addedIt != addedItEnd)
- unhandled_.push_back(*(addedIt++));
+ while (addedIt != addedItEnd) {
+#ifndef NDEBUG
+ // This code only works if addIntervalsForSpills retursn a
+ // sorted interval list. Assert this is the case now.
+ assert(OldStart <= (int)(*addedIt)->start() &&
+ "addIntervalsForSpills didn't return sorted interval list!");
+ OldStart = (*addedIt)->start();
+#endif
+ unhandled_.push_back(*(addedIt++));
+ }
return;
}
More information about the llvm-commits
mailing list