1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-21 18:22:53 +01:00

[llvm] Use llvm::lower_bound and llvm::upper_bound (NFC)

This commit is contained in:
Kazu Hirata 2021-01-29 23:23:35 -08:00
parent 04422f73a1
commit 95dfb94fbd
5 changed files with 8 additions and 17 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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),