/// removeRange - Remove the specified range from this interval. Note that /// the range must already be in this interval in its entirety. void LiveInterval::removeRange(unsigned Start, unsigned End) { // Find the LiveRange containing this span. Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); assert(I != ranges.begin() && "Range is not in interval!"); --I; assert(I->contains(Start) && I->contains(End-1) && "Range is not entirely in interval!"); // If the span we are removing is at the start of the LiveRange, adjust it. if (I->start == Start) { if (I->end == End) ranges.erase(I); // Removed the whole LiveRange. else I->start = End; return; } // Otherwise if the span we are removing is at the end of the LiveRange, // adjust the other way. if (I->end == End) { I->end = Start; return; } // Otherwise, we are splitting the LiveRange into two pieces. unsigned OldEnd = I->end; I->end = Start; // Trim the old interval. // Insert the new one. ranges.insert(next(I), LiveRange(End, OldEnd, I->ValId)); }
/// isInOneLiveRange - Return true if the range specified is entirely in the /// a single LiveRange of the live interval. bool LiveInterval::isInOneLiveRange(unsigned Start, unsigned End) { Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); if (I == ranges.begin()) return false; --I; return I->contains(Start) && I->contains(End-1); }
/// removeRange - Remove the specified range from this interval. Note that /// the range must be in a single LiveRange in its entirety. void LiveInterval::removeRange(unsigned Start, unsigned End, bool RemoveDeadValNo) { // Find the LiveRange containing this span. Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); assert(I != ranges.begin() && "Range is not in interval!"); --I; assert(I->contains(Start) && I->contains(End-1) && "Range is not entirely in interval!"); // If the span we are removing is at the start of the LiveRange, adjust it. VNInfo *ValNo = I->valno; if (I->start == Start) { if (I->end == End) { removeKills(I->valno, Start, End); if (RemoveDeadValNo) { // Check if val# is dead. bool isDead = true; for (const_iterator II = begin(), EE = end(); II != EE; ++II) if (II != I && II->valno == ValNo) { isDead = false; break; } if (isDead) { // Now that ValNo is dead, remove it. If it is the largest value // number, just nuke it (and any other deleted values neighboring it), // otherwise mark it as ~1U so it can be nuked later. if (ValNo->id == getNumValNums()-1) { do { VNInfo *VNI = valnos.back(); valnos.pop_back(); VNI->~VNInfo(); } while (!valnos.empty() && valnos.back()->def == ~1U); } else { ValNo->def = ~1U; } } } ranges.erase(I); // Removed the whole LiveRange. } else I->start = End; return; } // Otherwise if the span we are removing is at the end of the LiveRange, // adjust the other way. if (I->end == End) { removeKills(ValNo, Start, End); I->end = Start; return; } // Otherwise, we are splitting the LiveRange into two pieces. unsigned OldEnd = I->end; I->end = Start; // Trim the old interval. // Insert the new one. ranges.insert(next(I), LiveRange(End, OldEnd, ValNo)); }