[llvm] e733b80 - [LiveInterval] Simplify. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 25 11:59:37 PDT 2022


Author: Fangrui Song
Date: 2022-06-25T11:59:33-07:00
New Revision: e733b80f3cba26bf2df9bd691120f37fc1af21ce

URL: https://github.com/llvm/llvm-project/commit/e733b80f3cba26bf2df9bd691120f37fc1af21ce
DIFF: https://github.com/llvm/llvm-project/commit/e733b80f3cba26bf2df9bd691120f37fc1af21ce.diff

LOG: [LiveInterval] Simplify. NFC

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveInterval.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index 9ded0fb6ae0a..0303d8048924 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/lib/CodeGen/LiveInterval.cpp
@@ -348,23 +348,7 @@ class CalcLiveRangeUtilSet : public CalcLiveRangeUtilSetBase {
 //===----------------------------------------------------------------------===//
 
 LiveRange::iterator LiveRange::find(SlotIndex Pos) {
-  // This algorithm is basically std::upper_bound.
-  // Unfortunately, std::upper_bound cannot be used with mixed types until we
-  // adopt C++0x. Many libraries can do it, but not all.
-  if (empty() || Pos >= endIndex())
-    return end();
-  iterator I = begin();
-  size_t Len = size();
-  do {
-    size_t Mid = Len >> 1;
-    if (Pos < I[Mid].end) {
-      Len = Mid;
-    } else {
-      I += Mid + 1;
-      Len -= Mid + 1;
-    }
-  } while (Len);
-  return I;
+  return llvm::partition(*this, [&](const Segment &X) { return X.end <= Pos; });
 }
 
 VNInfo *LiveRange::createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc) {


        


More information about the llvm-commits mailing list