summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-19 04:47:36 +0000
committerChris Lattner <sabre@nondot.org>2004-07-19 04:47:36 +0000
commit70f8dca59ba76cb4692da7bf122b40a479ce237b (patch)
treed842a9dc72f9b9b4820f09d868b0fd3475bc0090 /llvm/lib/CodeGen
parent4f2e2a3f80bb78597a8daaa1b8d01d73df36c64b (diff)
downloadbcm5719-llvm-70f8dca59ba76cb4692da7bf122b40a479ce237b.tar.gz
bcm5719-llvm-70f8dca59ba76cb4692da7bf122b40a479ce237b.zip
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. llvm-svn: 14990
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/RegAllocLinearScan.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/RegAllocLinearScan.cpp b/llvm/lib/CodeGen/RegAllocLinearScan.cpp
index d5d3459906f..24508fbbb02 100644
--- a/llvm/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/llvm/lib/CodeGen/RegAllocLinearScan.cpp
@@ -386,18 +386,42 @@ void RA::assignRegOrStackSlotAtInterval(IntervalPtrs::value_type cur)
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;
}
OpenPOWER on IntegriCloud