[llvm] r364152 - SlotIndexes: simplify IdxMBBPair operators
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 23 06:16:04 PDT 2019
Author: maskray
Date: Sun Jun 23 06:16:03 2019
New Revision: 364152
URL: http://llvm.org/viewvc/llvm-project?rev=364152&view=rev
Log:
SlotIndexes: simplify IdxMBBPair operators
Modified:
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
llvm/trunk/lib/CodeGen/SlotIndexes.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=364152&r1=364151&r2=364152&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Sun Jun 23 06:16:03 2019
@@ -308,20 +308,6 @@ class raw_ostream;
using IdxMBBPair = std::pair<SlotIndex, MachineBasicBlock *>;
- 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.
Modified: llvm/trunk/lib/CodeGen/SlotIndexes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SlotIndexes.cpp?rev=364152&r1=364151&r2=364152&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SlotIndexes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SlotIndexes.cpp Sun Jun 23 06:16:03 2019
@@ -94,7 +94,7 @@ bool SlotIndexes::runOnMachineFunction(M
}
// Sort the Idx2MBBMap
- llvm::sort(idx2MBBMap, Idx2MBBCompare());
+ llvm::sort(idx2MBBMap, less_first());
LLVM_DEBUG(mf->print(dbgs(), this));
More information about the llvm-commits
mailing list