Index: include/llvm/CodeGen/LiveInterval.h =================================================================== --- include/llvm/CodeGen/LiveInterval.h +++ include/llvm/CodeGen/LiveInterval.h @@ -605,6 +605,26 @@ /// activated in the constructor of the live range. void flushSegmentSet(); + /// Returns an array of indexes this LiveRange is live at. + /// R is a range of _ascending sorted_ _random_ access iterators + /// to the input indexes + template + std::vector findIndexesLiveAt(Range &&R) const { + std::vector IndexesLiveAt; + auto I = R.begin(), E = R.end(); + for (auto &S : segments) { + auto Lower = std::lower_bound(I, E, S.start); + if (Lower == E) + break; + auto Upper = std::upper_bound(Lower, E, S.end); + IndexesLiveAt.insert(IndexesLiveAt.end(), Lower, Upper); + if (Upper == E) + break; + I = Upper; + } + return IndexesLiveAt; + } + void print(raw_ostream &OS) const; void dump() const;