Skip to content

Commit dc8de60

Browse files
committed
Simplify std::lower_bound with llvm::{bsearch,lower_bound}. NFC
llvm-svn: 364006
1 parent d5e1ce3 commit dc8de60

26 files changed

+64
-101
lines changed

llvm/lib/Analysis/ProfileSummaryInfo.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ static cl::opt<int> ProfileSummaryColdCount(
6060
// Find the summary entry for a desired percentile of counts.
6161
static const ProfileSummaryEntry &getEntryForPercentile(SummaryEntryVector &DS,
6262
uint64_t Percentile) {
63-
auto Compare = [](const ProfileSummaryEntry &Entry, uint64_t Percentile) {
64-
return Entry.Cutoff < Percentile;
65-
};
66-
auto It = std::lower_bound(DS.begin(), DS.end(), Percentile, Compare);
63+
auto It = llvm::bsearch(DS, [=](const ProfileSummaryEntry &Entry) {
64+
return Percentile <= Entry.Cutoff;
65+
});
6766
// The required percentile has to be <= one of the percentiles in the
6867
// detailed summary.
6968
if (It == DS.end())

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,7 @@ bool LiveIntervals::checkRegMaskInterference(LiveInterval &LI,
900900

901901
// We are going to enumerate all the register mask slots contained in LI.
902902
// Start with a binary search of RegMaskSlots to find a starting point.
903-
ArrayRef<SlotIndex>::iterator SlotI =
904-
std::lower_bound(Slots.begin(), Slots.end(), LiveI->start);
903+
ArrayRef<SlotIndex>::iterator SlotI = llvm::lower_bound(Slots, LiveI->start);
905904
ArrayRef<SlotIndex>::iterator SlotE = Slots.end();
906905

907906
// No slots in range, LI begins after the last call.
@@ -1370,8 +1369,7 @@ class LiveIntervals::HMEditor {
13701369

13711370
void updateRegMaskSlots() {
13721371
SmallVectorImpl<SlotIndex>::iterator RI =
1373-
std::lower_bound(LIS.RegMaskSlots.begin(), LIS.RegMaskSlots.end(),
1374-
OldIdx);
1372+
llvm::lower_bound(LIS.RegMaskSlots, OldIdx);
13751373
assert(RI != LIS.RegMaskSlots.end() && *RI == OldIdx.getRegSlot() &&
13761374
"No RegMask at OldIdx.");
13771375
*RI = NewIdx.getRegSlot();

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3726,9 +3726,8 @@ void SwingSchedulerDAG::checkValidNodeOrder(const NodeSetType &Circuits) const {
37263726

37273727
for (SDep &PredEdge : SU->Preds) {
37283728
SUnit *PredSU = PredEdge.getSUnit();
3729-
unsigned PredIndex =
3730-
std::get<1>(*std::lower_bound(Indices.begin(), Indices.end(),
3731-
std::make_pair(PredSU, 0), CompareKey));
3729+
unsigned PredIndex = std::get<1>(
3730+
*llvm::lower_bound(Indices, std::make_pair(PredSU, 0), CompareKey));
37323731
if (!PredSU->getInstr()->isPHI() && PredIndex < Index) {
37333732
PredBefore = true;
37343733
Pred = PredSU;
@@ -3743,9 +3742,8 @@ void SwingSchedulerDAG::checkValidNodeOrder(const NodeSetType &Circuits) const {
37433742
// return Indices.end().
37443743
if (SuccSU->isBoundaryNode())
37453744
continue;
3746-
unsigned SuccIndex =
3747-
std::get<1>(*std::lower_bound(Indices.begin(), Indices.end(),
3748-
std::make_pair(SuccSU, 0), CompareKey));
3745+
unsigned SuccIndex = std::get<1>(
3746+
*llvm::lower_bound(Indices, std::make_pair(SuccSU, 0), CompareKey));
37493747
if (!SuccSU->getInstr()->isPHI() && SuccIndex < Index) {
37503748
SuccBefore = true;
37513749
Succ = SuccSU;
@@ -3756,9 +3754,8 @@ void SwingSchedulerDAG::checkValidNodeOrder(const NodeSetType &Circuits) const {
37563754
if (PredBefore && SuccBefore && !SU->getInstr()->isPHI()) {
37573755
// instructions in circuits are allowed to be scheduled
37583756
// after both a successor and predecessor.
3759-
bool InCircuit = std::any_of(
3760-
Circuits.begin(), Circuits.end(),
3761-
[SU](const NodeSet &Circuit) { return Circuit.count(SU); });
3757+
bool InCircuit = llvm::any_of(
3758+
Circuits, [SU](const NodeSet &Circuit) { return Circuit.count(SU); });
37623759
if (InCircuit)
37633760
LLVM_DEBUG(dbgs() << "In a circuit, predecessor ";);
37643761
else {

llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,9 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
532532
}
533533

534534
FrameEntry *DWARFDebugFrame::getEntryAtOffset(uint64_t Offset) const {
535-
auto It =
536-
std::lower_bound(Entries.begin(), Entries.end(), Offset,
537-
[](const std::unique_ptr<FrameEntry> &E,
538-
uint64_t Offset) { return E->getOffset() < Offset; });
535+
auto It = llvm::bsearch(Entries, [=](const std::unique_ptr<FrameEntry> &E) {
536+
return Offset <= E->getOffset();
537+
});
539538
if (It != Entries.end() && (*It)->getOffset() == Offset)
540539
return It->get();
541540
return nullptr;

llvm/lib/IR/DataLayout.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,9 @@ DataLayout::AlignmentsTy::iterator
463463
DataLayout::findAlignmentLowerBound(AlignTypeEnum AlignType,
464464
uint32_t BitWidth) {
465465
auto Pair = std::make_pair((unsigned)AlignType, BitWidth);
466-
return std::lower_bound(Alignments.begin(), Alignments.end(), Pair,
467-
[](const LayoutAlignElem &LHS,
468-
const std::pair<unsigned, uint32_t> &RHS) {
469-
return std::tie(LHS.AlignType, LHS.TypeBitWidth) <
470-
std::tie(RHS.first, RHS.second);
471-
});
466+
return llvm::bsearch(Alignments, [=](const LayoutAlignElem &E) {
467+
return Pair <= std::make_pair(E.AlignType, E.TypeBitWidth);
468+
});
472469
}
473470

474471
void

llvm/lib/IR/Function.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ static ArrayRef<const char *> findTargetSubtable(StringRef Name) {
533533
// Drop "llvm." and take the first dotted component. That will be the target
534534
// if this is target specific.
535535
StringRef Target = Name.drop_front(5).split('.').first;
536-
auto It = std::lower_bound(Targets.begin(), Targets.end(), Target,
537-
[](const IntrinsicTargetInfo &TI,
538-
StringRef Target) { return TI.Name < Target; });
536+
auto It = llvm::bsearch(Targets, [=](const IntrinsicTargetInfo &TI) {
537+
return Target <= TI.Name;
538+
});
539539
// We've either found the target or just fall back to the generic set, which
540540
// is always first.
541541
const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0];

llvm/lib/MC/MCSubtargetInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace llvm;
2424
template <typename T>
2525
static const T *Find(StringRef S, ArrayRef<T> A) {
2626
// Binary search the array
27-
auto F = std::lower_bound(A.begin(), A.end(), S);
27+
auto F = llvm::lower_bound(A, S);
2828
// If not found then return NULL
2929
if (F == A.end() || StringRef(F->Key) != S) return nullptr;
3030
// Return the found array item

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ Error InstrProfSymtab::create(Module &M, bool InLTO) {
364364
uint64_t InstrProfSymtab::getFunctionHashFromAddress(uint64_t Address) {
365365
finalizeSymtab();
366366
auto Result =
367-
std::lower_bound(AddrToMD5Map.begin(), AddrToMD5Map.end(), Address,
368-
[](const std::pair<uint64_t, uint64_t> &LHS,
369-
uint64_t RHS) { return LHS.first < RHS; });
367+
llvm::bsearch(AddrToMD5Map, [=](std::pair<uint64_t, uint64_t> A) {
368+
return Address <= A.first;
369+
});
370370
// Raw function pointer collected by value profiler may be from
371371
// external functions that are not instrumented. They won't have
372372
// mapping data to be used by the deserializer. Force the value to

llvm/lib/Support/SourceMgr.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,9 @@ unsigned SourceMgr::SrcBuffer::getLineNumber(const char *Ptr) const {
9595
assert(PtrDiff >= 0 && static_cast<size_t>(PtrDiff) <= std::numeric_limits<T>::max());
9696
T PtrOffset = static_cast<T>(PtrDiff);
9797

98-
// std::lower_bound returns the first EOL offset that's not-less-than
99-
// PtrOffset, meaning the EOL that _ends the line_ that PtrOffset is on
100-
// (including if PtrOffset refers to the EOL itself). If there's no such
101-
// EOL, returns end().
102-
auto EOL = std::lower_bound(Offsets->begin(), Offsets->end(), PtrOffset);
103-
104-
// Lines count from 1, so add 1 to the distance from the 0th line.
105-
return (1 + (EOL - Offsets->begin()));
98+
// llvm::lower_bound gives the number of EOL before PtrOffset. Add 1 to get
99+
// the line number.
100+
return llvm::lower_bound(*Offsets, PtrOffset) - Offsets->begin() + 1;
106101
}
107102

108103
SourceMgr::SrcBuffer::SrcBuffer(SourceMgr::SrcBuffer &&Other)

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,7 @@ void ARMConstantIslands::updateForInsertedWaterBlock(MachineBasicBlock *NewBB) {
875875

876876
// Next, update WaterList. Specifically, we need to add NewMBB as having
877877
// available water after it.
878-
water_iterator IP =
879-
std::lower_bound(WaterList.begin(), WaterList.end(), NewBB,
880-
CompareMBBNumbers);
878+
water_iterator IP = llvm::lower_bound(WaterList, NewBB, CompareMBBNumbers);
881879
WaterList.insert(IP, NewBB);
882880
}
883881

@@ -928,9 +926,7 @@ MachineBasicBlock *ARMConstantIslands::splitBlockBeforeInstr(MachineInstr *MI) {
928926
// available water after it (but not if it's already there, which happens
929927
// when splitting before a conditional branch that is followed by an
930928
// unconditional branch - in that case we want to insert NewBB).
931-
water_iterator IP =
932-
std::lower_bound(WaterList.begin(), WaterList.end(), OrigBB,
933-
CompareMBBNumbers);
929+
water_iterator IP = llvm::lower_bound(WaterList, OrigBB, CompareMBBNumbers);
934930
MachineBasicBlock* WaterBB = *IP;
935931
if (WaterBB == OrigBB)
936932
WaterList.insert(std::next(IP), NewBB);

llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,7 @@ static const NEONLdStTableEntry *LookupNEONLdSt(unsigned Opcode) {
423423
}
424424
#endif
425425

426-
auto I = std::lower_bound(std::begin(NEONLdStTable),
427-
std::end(NEONLdStTable), Opcode);
426+
auto I = llvm::lower_bound(NEONLdStTable, Opcode);
428427
if (I != std::end(NEONLdStTable) && I->PseudoOpc == Opcode)
429428
return I;
430429
return nullptr;

llvm/lib/Target/Hexagon/HexagonGenInsert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ namespace {
436436
} // end anonymous namespace
437437

438438
void OrderedRegisterList::insert(unsigned VR) {
439-
iterator L = std::lower_bound(Seq.begin(), Seq.end(), VR, Ord);
439+
iterator L = llvm::lower_bound(Seq, VR, Ord);
440440
if (L == Seq.end())
441441
Seq.push_back(VR);
442442
else
@@ -449,7 +449,7 @@ void OrderedRegisterList::insert(unsigned VR) {
449449
}
450450

451451
void OrderedRegisterList::remove(unsigned VR) {
452-
iterator L = std::lower_bound(Seq.begin(), Seq.end(), VR, Ord);
452+
iterator L = llvm::lower_bound(Seq, VR, Ord);
453453
if (L != Seq.end())
454454
Seq.erase(L);
455455
}

llvm/lib/Target/Mips/Mips16ISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
459459
}
460460
// one more look at list of intrinsics
461461
const Mips16IntrinsicHelperType *Helper =
462-
std::lower_bound(std::begin(Mips16IntrinsicHelper),
463-
std::end(Mips16IntrinsicHelper), IntrinsicFind);
462+
llvm::lower_bound(Mips16IntrinsicHelper, IntrinsicFind);
464463
if (Helper != std::end(Mips16IntrinsicHelper) &&
465464
*Helper == IntrinsicFind) {
466465
Mips16HelperFunction = Helper->Helper;

llvm/lib/Target/Mips/MipsConstantIslandPass.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,7 @@ void MipsConstantIslands::updateForInsertedWaterBlock
841841

842842
// Next, update WaterList. Specifically, we need to add NewMBB as having
843843
// available water after it.
844-
water_iterator IP =
845-
std::lower_bound(WaterList.begin(), WaterList.end(), NewBB,
846-
CompareMBBNumbers);
844+
water_iterator IP = llvm::lower_bound(WaterList, NewBB, CompareMBBNumbers);
847845
WaterList.insert(IP, NewBB);
848846
}
849847

@@ -893,9 +891,7 @@ MipsConstantIslands::splitBlockBeforeInstr(MachineInstr &MI) {
893891
// available water after it (but not if it's already there, which happens
894892
// when splitting before a conditional branch that is followed by an
895893
// unconditional branch - in that case we want to insert NewBB).
896-
water_iterator IP =
897-
std::lower_bound(WaterList.begin(), WaterList.end(), OrigBB,
898-
CompareMBBNumbers);
894+
water_iterator IP = llvm::lower_bound(WaterList, OrigBB, CompareMBBNumbers);
899895
MachineBasicBlock* WaterBB = *IP;
900896
if (WaterBB == OrigBB)
901897
WaterList.insert(std::next(IP), NewBB);

llvm/lib/Target/X86/X86EvexToVex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ bool EvexToVexInstPass::CompressEvexToVexImpl(MachineInstr &MI) const {
252252
(Desc.TSFlags & X86II::VEX_L) ? makeArrayRef(X86EvexToVex256CompressTable)
253253
: makeArrayRef(X86EvexToVex128CompressTable);
254254

255-
auto I = std::lower_bound(Table.begin(), Table.end(), MI.getOpcode());
255+
auto I = llvm::lower_bound(Table, MI.getOpcode());
256256
if (I == Table.end() || I->EvexOpcode != MI.getOpcode())
257257
return false;
258258

llvm/lib/Target/X86/X86FloatingPoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ namespace {
596596
}
597597

598598
static int Lookup(ArrayRef<TableEntry> Table, unsigned Opcode) {
599-
const TableEntry *I = std::lower_bound(Table.begin(), Table.end(), Opcode);
599+
const TableEntry *I = llvm::lower_bound(Table, Opcode);
600600
if (I != Table.end() && I->from == Opcode)
601601
return I->to;
602602
return -1;

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13099,11 +13099,9 @@ static SDValue lowerV8I16GeneralSingleInputShuffle(
1309913099
copy_if(HiMask, std::back_inserter(HiInputs), [](int M) { return M >= 0; });
1310013100
array_pod_sort(HiInputs.begin(), HiInputs.end());
1310113101
HiInputs.erase(std::unique(HiInputs.begin(), HiInputs.end()), HiInputs.end());
13102-
int NumLToL =
13103-
std::lower_bound(LoInputs.begin(), LoInputs.end(), 4) - LoInputs.begin();
13102+
int NumLToL = llvm::lower_bound(LoInputs, 4) - LoInputs.begin();
1310413103
int NumHToL = LoInputs.size() - NumLToL;
13105-
int NumLToH =
13106-
std::lower_bound(HiInputs.begin(), HiInputs.end(), 4) - HiInputs.begin();
13104+
int NumLToH = llvm::lower_bound(HiInputs, 4) - HiInputs.begin();
1310713105
int NumHToH = HiInputs.size() - NumLToH;
1310813106
MutableArrayRef<int> LToLInputs(LoInputs.data(), NumLToL);
1310913107
MutableArrayRef<int> LToHInputs(HiInputs.data(), NumLToH);

llvm/lib/Target/X86/X86InstrFMA3Info.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ const X86InstrFMA3Group *llvm::getFMA3Group(unsigned Opcode, uint64_t TSFlags) {
158158
// FMA 231 instructions have an opcode of 0xB6-0xBF
159159
unsigned FormIndex = ((BaseOpcode - 0x90) >> 4) & 0x3;
160160

161-
auto I = std::lower_bound(Table.begin(), Table.end(), Opcode,
162-
[FormIndex](const X86InstrFMA3Group &Group,
163-
unsigned Opcode) {
164-
return Group.Opcodes[FormIndex] < Opcode;
165-
});
161+
auto I = llvm::bsearch(Table, [=](const X86InstrFMA3Group &Group) {
162+
return Opcode <= Group.Opcodes[FormIndex];
163+
});
166164
assert(I != Table.end() && I->Opcodes[FormIndex] == Opcode &&
167165
"Couldn't find FMA3 opcode!");
168166
return I;

llvm/lib/Target/X86/X86InstrFoldTables.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5288,9 +5288,7 @@ lookupFoldTableImpl(ArrayRef<X86MemoryFoldTableEntry> Table, unsigned RegOp) {
52885288
}
52895289
#endif
52905290

5291-
const X86MemoryFoldTableEntry *Data = std::lower_bound(Table.begin(),
5292-
Table.end(),
5293-
RegOp);
5291+
const X86MemoryFoldTableEntry *Data = llvm::lower_bound(Table, RegOp);
52945292
if (Data != Table.end() && Data->KeyOp == RegOp &&
52955293
!(Data->Flags & TB_NO_FORWARD))
52965294
return Data;
@@ -5377,7 +5375,7 @@ static ManagedStatic<X86MemUnfoldTable> MemUnfoldTable;
53775375
const X86MemoryFoldTableEntry *
53785376
llvm::lookupUnfoldTable(unsigned MemOp) {
53795377
auto &Table = MemUnfoldTable->Table;
5380-
auto I = std::lower_bound(Table.begin(), Table.end(), MemOp);
5378+
auto I = llvm::lower_bound(Table, MemOp);
53815379
if (I != Table.end() && I->KeyOp == MemOp)
53825380
return &*I;
53835381
return nullptr;

llvm/lib/TextAPI/MachO/InterfaceFile.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ namespace MachO {
2121
namespace detail {
2222
template <typename C>
2323
typename C::iterator addEntry(C &Container, StringRef InstallName) {
24-
auto I =
25-
std::lower_bound(std::begin(Container), std::end(Container), InstallName,
26-
[](const InterfaceFileRef &LHS, const StringRef &RHS) {
27-
return LHS.getInstallName() < RHS;
28-
});
24+
auto I = llvm::bsearch(Container, [=](const InterfaceFileRef &O) {
25+
return InstallName <= O.getInstallName();
26+
});
2927
if ((I != std::end(Container)) && !(InstallName < I->getInstallName()))
3028
return I;
3129

@@ -46,11 +44,12 @@ void InterfaceFile::addReexportedLibrary(StringRef InstallName,
4644
}
4745

4846
void InterfaceFile::addUUID(Architecture Arch, StringRef UUID) {
49-
auto I = std::lower_bound(UUIDs.begin(), UUIDs.end(), Arch,
50-
[](const std::pair<Architecture, std::string> &LHS,
51-
Architecture RHS) { return LHS.first < RHS; });
47+
auto I =
48+
llvm::bsearch(UUIDs, [=](const std::pair<Architecture, std::string> &O) {
49+
return Arch <= O.first;
50+
});
5251

53-
if ((I != UUIDs.end()) && !(Arch < I->first)) {
52+
if (I != UUIDs.end() && Arch == I->first) {
5453
I->second = UUID;
5554
return;
5655
}

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BlockToIndexMapping {
5252
}
5353

5454
size_t blockToIndex(BasicBlock *BB) const {
55-
auto *I = std::lower_bound(V.begin(), V.end(), BB);
55+
auto *I = llvm::lower_bound(V, BB);
5656
assert(I != V.end() && *I == BB && "BasicBlockNumberng: Unknown block");
5757
return I - V.begin();
5858
}

llvm/lib/Transforms/Scalar/JumpThreading.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,7 @@ bool JumpThreadingPass::SimplifyPartiallyRedundantLoad(LoadInst *LoadI) {
14801480
for (pred_iterator PI = PB; PI != PE; ++PI) {
14811481
BasicBlock *P = *PI;
14821482
AvailablePredsTy::iterator I =
1483-
std::lower_bound(AvailablePreds.begin(), AvailablePreds.end(),
1484-
std::make_pair(P, (Value*)nullptr));
1483+
llvm::lower_bound(AvailablePreds, std::make_pair(P, (Value *)nullptr));
14851484

14861485
assert(I != AvailablePreds.end() && I->first == P &&
14871486
"Didn't find entry for predecessor!");

llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ void MemsetRanges::addRange(int64_t Start, int64_t Size, Value *Ptr,
278278
unsigned Alignment, Instruction *Inst) {
279279
int64_t End = Start+Size;
280280

281-
range_iterator I = std::lower_bound(Ranges.begin(), Ranges.end(), Start,
282-
[](const MemsetRange &LHS, int64_t RHS) { return LHS.End < RHS; });
281+
range_iterator I = llvm::bsearch(
282+
Ranges, [=](const MemsetRange &O) { return Start <= O.End; });
283283

284284
// We now know that I == E, in which case we didn't find anything to merge
285285
// with, or that Start <= I->End. If End < I->Start or I == E, then we need

llvm/lib/Transforms/Scalar/Reassociate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ Value *ReassociatePass::OptimizeMul(BinaryOperator *I,
18261826
return V;
18271827

18281828
ValueEntry NewEntry = ValueEntry(getRank(V), V);
1829-
Ops.insert(std::lower_bound(Ops.begin(), Ops.end(), NewEntry), NewEntry);
1829+
Ops.insert(llvm::lower_bound(Ops, NewEntry), NewEntry);
18301830
return nullptr;
18311831
}
18321832

llvm/tools/dsymutil/DwarfLinker.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,18 +1766,16 @@ static void insertLineSequence(std::vector<DWARFDebugLine::Row> &Seq,
17661766
return;
17671767
}
17681768

1769-
auto InsertPoint = std::lower_bound(
1770-
Rows.begin(), Rows.end(), Seq.front(),
1771-
[](const DWARFDebugLine::Row &LHS, const DWARFDebugLine::Row &RHS) {
1772-
return LHS.Address < RHS.Address;
1773-
});
1769+
object::SectionedAddress Front = Seq.front().Address;
1770+
auto InsertPoint = llvm::bsearch(
1771+
Rows, [=](const DWARFDebugLine::Row &O) { return !(O.Address < Front); });
17741772

17751773
// FIXME: this only removes the unneeded end_sequence if the
17761774
// sequences have been inserted in order. Using a global sort like
17771775
// described in patchLineTableForUnit() and delaying the end_sequene
17781776
// elimination to emitLineTableForUnit() we can get rid of all of them.
1779-
if (InsertPoint != Rows.end() &&
1780-
InsertPoint->Address == Seq.front().Address && InsertPoint->EndSequence) {
1777+
if (InsertPoint != Rows.end() && InsertPoint->Address == Front &&
1778+
InsertPoint->EndSequence) {
17811779
*InsertPoint = Seq.front();
17821780
Rows.insert(InsertPoint + 1, Seq.begin() + 1, Seq.end());
17831781
} else {

0 commit comments

Comments
 (0)