diff options
author | Lang Hames <lhames@gmail.com> | 2009-10-30 18:12:09 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2009-10-30 18:12:09 +0000 |
commit | 788fa17af87dba8836fca691c9028c57ef8fc4fe (patch) | |
tree | 1bce9ac0c3d068a5a29a3200090b06f8a278c0d0 /lib/CodeGen/SimpleRegisterCoalescing.cpp | |
parent | c1382b745faa62bc6f2570a193bce6aee8d78885 (diff) |
Stop the iterator in ValueLiveAt from potentially running off the end of the interval.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SimpleRegisterCoalescing.cpp')
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 430df54081..2aa6307502 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -1866,8 +1866,10 @@ bool SimpleRegisterCoalescing::RangeIsDefinedByCopyFromReg(LiveInterval &li, /// iterator, or any subsequent range with the same value number, /// is live at the given point. bool SimpleRegisterCoalescing::ValueLiveAt(LiveInterval::iterator LRItr, + LiveInterval::iterator LREnd, LiveIndex defPoint) const { - for (const VNInfo *valno = LRItr->valno; LRItr->valno == valno; ++LRItr) { + for (const VNInfo *valno = LRItr->valno; + (LRItr != LREnd) && (LRItr->valno == valno); ++LRItr) { if (LRItr->contains(defPoint)) return true; } @@ -1922,7 +1924,7 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){ if (!RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) return false; // Nope, bail out. - if (ValueLiveAt(LHSIt, RHSIt->valno->def)) + if (ValueLiveAt(LHSIt, LHS.end(), RHSIt->valno->def)) // Here is an interesting situation: // BB1: // vr1025 = copy vr1024 @@ -1960,7 +1962,7 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){ // Otherwise, if this is a copy from the RHS, mark it as being merged // in. if (RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) { - if (ValueLiveAt(LHSIt, RHSIt->valno->def)) + if (ValueLiveAt(LHSIt, LHS.end(), RHSIt->valno->def)) // Here is an interesting situation: // BB1: // vr1025 = copy vr1024 |