[llvm] 1a2d67f - [llvm] Use llvm::lower_bound and llvm::upper_bound (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 23:24:00 PST 2021
Author: Kazu Hirata
Date: 2021-01-29T23:23:36-08:00
New Revision: 1a2d67fa23b2b65c7f07481dd0184957f8d058d9
URL: https://github.com/llvm/llvm-project/commit/1a2d67fa23b2b65c7f07481dd0184957f8d058d9
DIFF: https://github.com/llvm/llvm-project/commit/1a2d67fa23b2b65c7f07481dd0184957f8d058d9.diff
LOG: [llvm] Use llvm::lower_bound and llvm::upper_bound (NFC)
Added:
Modified:
llvm/lib/CodeGen/LiveInterval.cpp
llvm/lib/CodeGen/LiveRangeCalc.cpp
llvm/lib/MC/MCSection.cpp
llvm/lib/Target/X86/X86IntrinsicsInfo.h
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index ce0e58772068..4114fbdfab94 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/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/llvm/lib/CodeGen/LiveRangeCalc.cpp b/llvm/lib/CodeGen/LiveRangeCalc.cpp
index e9c9b70d29a9..3ef28042acb0 100644
--- a/llvm/lib/CodeGen/LiveRangeCalc.cpp
+++ b/llvm/lib/CodeGen/LiveRangeCalc.cpp
@@ -158,8 +158,7 @@ bool LiveRangeCalc::isDefOnEntry(LiveRange &LR, ArrayRef<SlotIndex> 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/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp
index 7997b237a7eb..8342abacec09 100644
--- a/llvm/lib/MC/MCSection.cpp
+++ b/llvm/lib/MC/MCSection.cpp
@@ -60,10 +60,8 @@ MCSection::getSubsectionInsertionPoint(unsigned Subsection) {
if (Subsection == 0 && SubsectionFragmentMap.empty())
return end();
- SmallVectorImpl<std::pair<unsigned, MCFragment *>>::iterator MI =
- std::lower_bound(SubsectionFragmentMap.begin(),
- SubsectionFragmentMap.end(),
- std::make_pair(Subsection, (MCFragment *)nullptr));
+ SmallVectorImpl<std::pair<unsigned, MCFragment *>>::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/llvm/lib/Target/X86/X86IntrinsicsInfo.h b/llvm/lib/Target/X86/X86IntrinsicsInfo.h
index 72ab3e9cf78d..de2500b8e1bd 100644
--- a/llvm/lib/Target/X86/X86IntrinsicsInfo.h
+++ b/llvm/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/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index 29408e7c4946..1aca6a24de0f 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/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<uint64_t>
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),
More information about the llvm-commits
mailing list