[PATCH] D62411: LiveIntervals: add LiveRange::findIndexesLiveAt function - return a list of SlotIndexes the LiveRange live at.
Valery Pykhtin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 24 10:52:44 PDT 2019
vpykhtin created this revision.
Herald added subscribers: llvm-commits, arphaman, MatzeB.
Herald added a project: LLVM.
Returns an array of indexes the LiveRange is live at.
R is a range of ascending sorted random access iterators to the input SlotIndexes.
Complexity is proportional to O(segments.size * lg(R)) due to a binary search used.
Repository:
rL LLVM
https://reviews.llvm.org/D62411
Files:
include/llvm/CodeGen/LiveInterval.h
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 <typename Range>
+ std::vector<SlotIndex> findIndexesLiveAt(Range &&R) const {
+ std::vector<SlotIndex> 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62411.201287.patch
Type: text/x-patch
Size: 1076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190524/171cc9e6/attachment.bin>
More information about the llvm-commits
mailing list