[llvm] ec19223 - Revert "[LiveInterval] Simplify. NFC"

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 26 02:51:21 PDT 2022


Author: Nikita Popov
Date: 2022-06-26T11:51:07+02:00
New Revision: ec1922313101f94ffa0f3fe8c721220b83ebcb32

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

LOG: Revert "[LiveInterval] Simplify. NFC"

This reverts commit e733b80f3cba26bf2df9bd691120f37fc1af21ce.

This caused a major compile-time regression:
https://llvm-compile-time-tracker.com/compare.php?from=3b7c3a654c9175f41ac871a937cbcae73dfb3c5d&to=e733b80f3cba26bf2df9bd691120f37fc1af21ce&stat=instructions

About 1% on average, 10% on individual files.

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveInterval.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index 0303d8048924..9ded0fb6ae0a 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/lib/CodeGen/LiveInterval.cpp
@@ -348,7 +348,23 @@ class CalcLiveRangeUtilSet : public CalcLiveRangeUtilSetBase {
 //===----------------------------------------------------------------------===//
 
 LiveRange::iterator LiveRange::find(SlotIndex Pos) {
-  return llvm::partition(*this, [&](const Segment &X) { return X.end <= 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;
 }
 
 VNInfo *LiveRange::createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc) {


        


More information about the llvm-commits mailing list