From 95dfb94fbdd9aa4a32553c5438d889a25d1b4316 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 29 Jan 2021 23:23:35 -0800 Subject: [PATCH] [llvm] Use llvm::lower_bound and llvm::upper_bound (NFC) --- lib/CodeGen/LiveInterval.cpp | 2 +- lib/CodeGen/LiveRangeCalc.cpp | 3 +-- lib/MC/MCSection.cpp | 6 ++---- lib/Target/X86/X86IntrinsicsInfo.h | 8 ++------ tools/dsymutil/DwarfLinkerForBinary.cpp | 6 ++---- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index ce0e5877206..4114fbdfab9 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -487,7 +487,7 @@ bool LiveRange::overlaps(const LiveRange &Other, const CoalescerPair &CP, /// by [Start, End). bool LiveRange::overlaps(SlotIndex Start, SlotIndex End) const { assert(Start < End && "Invalid range"); - const_iterator I = std::lower_bound(begin(), end(), End); + const_iterator I = lower_bound(*this, End); return I != begin() && (--I)->end > Start; } diff --git a/lib/CodeGen/LiveRangeCalc.cpp b/lib/CodeGen/LiveRangeCalc.cpp index e9c9b70d29a..3ef28042acb 100644 --- a/lib/CodeGen/LiveRangeCalc.cpp +++ b/lib/CodeGen/LiveRangeCalc.cpp @@ -158,8 +158,7 @@ bool LiveRangeCalc::isDefOnEntry(LiveRange &LR, ArrayRef Undefs, // If LR has a segment S that starts at the next block, i.e. [End, ...), // std::upper_bound will return the segment following S. Instead, // S should be treated as the first segment that does not overlap B. - LiveRange::iterator UB = std::upper_bound(LR.begin(), LR.end(), - End.getPrevSlot()); + LiveRange::iterator UB = upper_bound(LR, End.getPrevSlot()); if (UB != LR.begin()) { LiveRange::Segment &Seg = *std::prev(UB); if (Seg.end > Begin) { diff --git a/lib/MC/MCSection.cpp b/lib/MC/MCSection.cpp index 7997b237a7e..8342abacec0 100644 --- a/lib/MC/MCSection.cpp +++ b/lib/MC/MCSection.cpp @@ -60,10 +60,8 @@ MCSection::getSubsectionInsertionPoint(unsigned Subsection) { if (Subsection == 0 && SubsectionFragmentMap.empty()) return end(); - SmallVectorImpl>::iterator MI = - std::lower_bound(SubsectionFragmentMap.begin(), - SubsectionFragmentMap.end(), - std::make_pair(Subsection, (MCFragment *)nullptr)); + SmallVectorImpl>::iterator MI = lower_bound( + SubsectionFragmentMap, std::make_pair(Subsection, (MCFragment *)nullptr)); bool ExactMatch = false; if (MI != SubsectionFragmentMap.end()) { ExactMatch = MI->first == Subsection; diff --git a/lib/Target/X86/X86IntrinsicsInfo.h b/lib/Target/X86/X86IntrinsicsInfo.h index 72ab3e9cf78..de2500b8e1b 100644 --- a/lib/Target/X86/X86IntrinsicsInfo.h +++ b/lib/Target/X86/X86IntrinsicsInfo.h @@ -324,9 +324,7 @@ static const IntrinsicData IntrinsicsWithChain[] = { * Find Intrinsic data by intrinsic ID */ static const IntrinsicData* getIntrinsicWithChain(unsigned IntNo) { - const IntrinsicData *Data = std::lower_bound(std::begin(IntrinsicsWithChain), - std::end(IntrinsicsWithChain), - IntNo); + const IntrinsicData *Data = lower_bound(IntrinsicsWithChain, IntNo); if (Data != std::end(IntrinsicsWithChain) && Data->Id == IntNo) return Data; return nullptr; @@ -1152,9 +1150,7 @@ static const IntrinsicData IntrinsicsWithoutChain[] = { * Return nullptr if intrinsic is not defined in the table. */ static const IntrinsicData* getIntrinsicWithoutChain(unsigned IntNo) { - const IntrinsicData *Data = std::lower_bound(std::begin(IntrinsicsWithoutChain), - std::end(IntrinsicsWithoutChain), - IntNo); + const IntrinsicData *Data = lower_bound(IntrinsicsWithoutChain, IntNo); if (Data != std::end(IntrinsicsWithoutChain) && Data->Id == IntNo) return Data; return nullptr; diff --git a/tools/dsymutil/DwarfLinkerForBinary.cpp b/tools/dsymutil/DwarfLinkerForBinary.cpp index 29408e7c494..1aca6a24de0 100644 --- a/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -613,8 +613,7 @@ bool DwarfLinkerForBinary::AddressManager::findValidRelocsInDebugSections( bool DwarfLinkerForBinary::AddressManager::hasValidDebugAddrRelocationAt( uint64_t Offset) { - auto It = std::lower_bound(ValidDebugAddrRelocs.begin(), - ValidDebugAddrRelocs.end(), Offset); + auto It = lower_bound(ValidDebugAddrRelocs, Offset); return It != ValidDebugAddrRelocs.end(); } @@ -769,8 +768,7 @@ bool DwarfLinkerForBinary::AddressManager::applyValidRelocs( llvm::Expected DwarfLinkerForBinary::AddressManager::relocateIndexedAddr(uint64_t Offset) { - auto It = std::lower_bound(ValidDebugAddrRelocs.begin(), - ValidDebugAddrRelocs.end(), Offset); + auto It = lower_bound(ValidDebugAddrRelocs, Offset); if (It == ValidDebugAddrRelocs.end()) return createStringError( std::make_error_code(std::errc::invalid_argument),