From a62f7e28e5406a186253ac21e0fbd0feb123377a Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 23 Jun 2019 13:16:03 +0000 Subject: [PATCH] SlotIndexes: simplify IdxMBBPair operators git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364152 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SlotIndexes.h | 19 +++---------------- lib/CodeGen/SlotIndexes.cpp | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h index 63461d61bf3..76d5ff34d84 100644 --- a/include/llvm/CodeGen/SlotIndexes.h +++ b/include/llvm/CodeGen/SlotIndexes.h @@ -308,20 +308,6 @@ class raw_ostream; using IdxMBBPair = std::pair; - inline bool operator<(SlotIndex V, const IdxMBBPair &IM) { - return V < IM.first; - } - - inline bool operator<(const IdxMBBPair &IM, SlotIndex V) { - return IM.first < V; - } - - struct Idx2MBBCompare { - bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const { - return LHS.first < RHS.first; - } - }; - /// SlotIndexes pass. /// /// This pass assigns indexes to each instruction. @@ -513,7 +499,8 @@ class raw_ostream; /// Move iterator to the next IdxMBBPair where the SlotIndex is greater or /// equal to \p To. MBBIndexIterator advanceMBBIndex(MBBIndexIterator I, SlotIndex To) const { - return std::lower_bound(I, idx2MBBMap.end(), To); + return llvm::bsearch(I, idx2MBBMap.end(), + [=](const IdxMBBPair &IM) { return To <= IM.first; }); } /// Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex @@ -677,7 +664,7 @@ class raw_ostream; idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb)); renumberIndexes(newItr); - llvm::sort(idx2MBBMap, Idx2MBBCompare()); + llvm::sort(idx2MBBMap, less_first()); } /// Free the resources that were required to maintain a SlotIndex. diff --git a/lib/CodeGen/SlotIndexes.cpp b/lib/CodeGen/SlotIndexes.cpp index a55e74c4c06..ce00fa9a136 100644 --- a/lib/CodeGen/SlotIndexes.cpp +++ b/lib/CodeGen/SlotIndexes.cpp @@ -94,7 +94,7 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) { } // Sort the Idx2MBBMap - llvm::sort(idx2MBBMap, Idx2MBBCompare()); + llvm::sort(idx2MBBMap, less_first()); LLVM_DEBUG(mf->print(dbgs(), this)); -- 2.11.0