Fix a bug where I didn't test for an empty range before inspecting the
authorChandler Carruth <chandlerc@gmail.com>
Tue, 10 Jul 2012 15:41:33 +0000 (15:41 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 10 Jul 2012 15:41:33 +0000 (15:41 +0000)
back of it.

I don't have anything even remotely close to a test case for this. It
only broke two build bots, both of them doing bootstrap builds, one of
them a dragonegg bootstrap. It doesn't break for me when I bootstrap
either. It doesn't reproduce every time or on many machines during the
bootstrap. Many thanks to Duncan Sands who got the exact command (and
stage of the bootstrap) which failed on the dragonegg bootstrap and
managed to get it to trigger under valgrind with debug symbols. The fix
was then found by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159993 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveInterval.cpp

index 2dfd714e9ecae9f8eeb151a3cddc24bef634b60d..9342439cc3da28914432f2586bb73583dbcd70e2 100644 (file)
@@ -579,7 +579,8 @@ void LiveInterval::mergeIntervalRanges(const LiveInterval &RHS,
 
   // And finally insert any trailing end of RHS (if we have one).
   for (; RI != RE; ++RI)
-    if (ranges.back().valno == LHSValNo && RI->start <= ranges.back().end) {
+    if (!ranges.empty() &&
+        ranges.back().valno == LHSValNo && RI->start <= ranges.back().end) {
       ranges.back().end = std::max(ranges.back().end, RI->end);
     } else {
       ranges.push_back(*RI);