summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-06-30 11:19:56 +0000
committerFangrui Song <maskray@google.com>2019-06-30 11:19:56 +0000
commit78ee2fbf984b84db814bf7b3a68e2317e32b1a24 (patch)
tree83fad2d809aa8d625b95a949b0d36ef9ceeaa2e4 /llvm/lib
parent2d2cb77e45d4c9ca34d05f80430e0f9404252980 (diff)
downloadbcm5719-llvm-78ee2fbf984b84db814bf7b3a68e2317e32b1a24.tar.gz
bcm5719-llvm-78ee2fbf984b84db814bf7b3a68e2317e32b1a24.zip
Cleanup: llvm::bsearch -> llvm::partition_point after r364719
llvm-svn: 364720
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ProfileSummaryInfo.cpp4
-rw-r--r--llvm/lib/CodeGen/ExecutionDomainFix.cpp4
-rw-r--r--llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp9
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp2
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp4
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp8
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp4
-rw-r--r--llvm/lib/IR/DataLayout.cpp4
-rw-r--r--llvm/lib/IR/Function.cpp5
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp11
-rw-r--r--llvm/lib/Target/X86/X86InstrFMA3Info.cpp4
-rw-r--r--llvm/lib/TextAPI/MachO/InterfaceFile.cpp16
-rw-r--r--llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp4
13 files changed, 37 insertions, 42 deletions
diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index 52e015b5bb3..dce19d6d546 100644
--- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp
+++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
@@ -60,8 +60,8 @@ static cl::opt<int> ProfileSummaryColdCount(
// Find the summary entry for a desired percentile of counts.
static const ProfileSummaryEntry &getEntryForPercentile(SummaryEntryVector &DS,
uint64_t Percentile) {
- auto It = llvm::bsearch(DS, [=](const ProfileSummaryEntry &Entry) {
- return Percentile <= Entry.Cutoff;
+ auto It = partition_point(DS, [=](const ProfileSummaryEntry &Entry) {
+ return Entry.Cutoff < Percentile;
});
// The required percentile has to be <= one of the percentiles in the
// detailed summary.
diff --git a/llvm/lib/CodeGen/ExecutionDomainFix.cpp b/llvm/lib/CodeGen/ExecutionDomainFix.cpp
index c350ede635d..a2dd5eee33b 100644
--- a/llvm/lib/CodeGen/ExecutionDomainFix.cpp
+++ b/llvm/lib/CodeGen/ExecutionDomainFix.cpp
@@ -337,8 +337,8 @@ void ExecutionDomainFix::visitSoftInstr(MachineInstr *mi, unsigned mask) {
// Sorted insertion.
// Enables giving priority to the latest domains during merging.
const int Def = RDA->getReachingDef(mi, RC->getRegister(rx));
- auto I = llvm::bsearch(Regs, [&](int I) {
- return Def < RDA->getReachingDef(mi, RC->getRegister(I));
+ auto I = partition_point(Regs, [&](int I) {
+ return RDA->getReachingDef(mi, RC->getRegister(I)) <= Def;
});
Regs.insert(I, rx);
}
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
index 0010ca72d76..14df53b9e84 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
@@ -544,11 +544,10 @@ LegalizerInfo::findAction(const SizeAndActionsVec &Vec, const uint32_t Size) {
// Find the last element in Vec that has a bitsize equal to or smaller than
// the requested bit size.
// That is the element just before the first element that is bigger than Size.
- auto VecIt = llvm::bsearch(
- Vec, [=](const SizeAndAction &A) { return Size < A.first; });
- assert(VecIt != Vec.begin() && "Does Vec not start with size 1?");
- --VecIt;
- int VecIdx = VecIt - Vec.begin();
+ auto It = partition_point(
+ Vec, [=](const SizeAndAction &A) { return A.first <= Size; });
+ assert(It != Vec.begin() && "Does Vec not start with size 1?");
+ int VecIdx = It - Vec.begin() - 1;
LegalizeAction Action = Vec[VecIdx].second;
switch (Action) {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
index 010b0106a83..6460c9feeab 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
@@ -115,7 +115,7 @@ void DWARFDebugAranges::construct() {
uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const {
RangeCollIterator It =
- llvm::bsearch(Aranges, [=](Range RHS) { return Address < RHS.HighPC(); });
+ partition_point(Aranges, [=](Range R) { return R.HighPC() <= Address; });
if (It != Aranges.end() && It->LowPC <= Address)
return It->CUOffset;
return -1U;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 65a6b57ddb5..b3f23366f2a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -532,8 +532,8 @@ void DWARFDebugFrame::parse(DWARFDataExtractor Data) {
}
FrameEntry *DWARFDebugFrame::getEntryAtOffset(uint64_t Offset) const {
- auto It = llvm::bsearch(Entries, [=](const std::unique_ptr<FrameEntry> &E) {
- return Offset <= E->getOffset();
+ auto It = partition_point(Entries, [=](const std::unique_ptr<FrameEntry> &E) {
+ return E->getOffset() < Offset;
});
if (It != Entries.end() && (*It)->getOffset() == Offset)
return It->get();
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index e0d62215d9b..6d8f4bee77c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -57,8 +57,8 @@ void DWARFDebugLoc::LocationList::dump(raw_ostream &OS, bool IsLittleEndian,
DWARFDebugLoc::LocationList const *
DWARFDebugLoc::getLocationListAtOffset(uint64_t Offset) const {
- auto It = llvm::bsearch(
- Locations, [=](const LocationList &L) { return Offset <= L.Offset; });
+ auto It = partition_point(
+ Locations, [=](const LocationList &L) { return L.Offset < Offset; });
if (It != Locations.end() && It->Offset == Offset)
return &(*It);
return nullptr;
@@ -212,8 +212,8 @@ void DWARFDebugLoclists::parse(DataExtractor data, unsigned Version) {
DWARFDebugLoclists::LocationList const *
DWARFDebugLoclists::getLocationListAtOffset(uint64_t Offset) const {
- auto It = llvm::bsearch(
- Locations, [=](const LocationList &L) { return Offset <= L.Offset; });
+ auto It = partition_point(
+ Locations, [=](const LocationList &L) { return L.Offset < Offset; });
if (It != Locations.end() && It->Offset == Offset)
return &(*It);
return nullptr;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
index cff5c288d06..047c63461cc 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp
@@ -172,8 +172,8 @@ DWARFUnitIndex::getFromOffset(uint32_t Offset) const {
E2->Contributions[InfoColumn].Offset;
});
}
- auto I = llvm::bsearch(OffsetLookup, [&](Entry *E2) {
- return Offset < E2->Contributions[InfoColumn].Offset;
+ auto I = partition_point(OffsetLookup, [&](Entry *E2) {
+ return E2->Contributions[InfoColumn].Offset <= Offset;
});
if (I == OffsetLookup.begin())
return nullptr;
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index b8c130a54e9..6e0ebbd4a73 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -463,8 +463,8 @@ DataLayout::AlignmentsTy::iterator
DataLayout::findAlignmentLowerBound(AlignTypeEnum AlignType,
uint32_t BitWidth) {
auto Pair = std::make_pair((unsigned)AlignType, BitWidth);
- return llvm::bsearch(Alignments, [=](const LayoutAlignElem &E) {
- return Pair <= std::make_pair(E.AlignType, E.TypeBitWidth);
+ return partition_point(Alignments, [=](const LayoutAlignElem &E) {
+ return std::make_pair(E.AlignType, E.TypeBitWidth) < Pair;
});
}
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 6a276b18023..dc28d22548d 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -533,9 +533,8 @@ static ArrayRef<const char *> findTargetSubtable(StringRef Name) {
// Drop "llvm." and take the first dotted component. That will be the target
// if this is target specific.
StringRef Target = Name.drop_front(5).split('.').first;
- auto It = llvm::bsearch(Targets, [=](const IntrinsicTargetInfo &TI) {
- return Target <= TI.Name;
- });
+ auto It = partition_point(
+ Targets, [=](const IntrinsicTargetInfo &TI) { return TI.Name < Target; });
// We've either found the target or just fall back to the generic set, which
// is always first.
const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0];
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index c0b067a490e..510fd9887d9 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -363,16 +363,15 @@ Error InstrProfSymtab::create(Module &M, bool InLTO) {
uint64_t InstrProfSymtab::getFunctionHashFromAddress(uint64_t Address) {
finalizeSymtab();
- auto Result =
- llvm::bsearch(AddrToMD5Map, [=](std::pair<uint64_t, uint64_t> A) {
- return Address <= A.first;
- });
+ auto It = partition_point(AddrToMD5Map, [=](std::pair<uint64_t, uint64_t> A) {
+ return A.first < Address;
+ });
// Raw function pointer collected by value profiler may be from
// external functions that are not instrumented. They won't have
// mapping data to be used by the deserializer. Force the value to
// be 0 in this case.
- if (Result != AddrToMD5Map.end() && Result->first == Address)
- return (uint64_t)Result->second;
+ if (It != AddrToMD5Map.end() && It->first == Address)
+ return (uint64_t)It->second;
return 0;
}
diff --git a/llvm/lib/Target/X86/X86InstrFMA3Info.cpp b/llvm/lib/Target/X86/X86InstrFMA3Info.cpp
index 77dc75386fc..25bbdddb7a2 100644
--- a/llvm/lib/Target/X86/X86InstrFMA3Info.cpp
+++ b/llvm/lib/Target/X86/X86InstrFMA3Info.cpp
@@ -158,8 +158,8 @@ const X86InstrFMA3Group *llvm::getFMA3Group(unsigned Opcode, uint64_t TSFlags) {
// FMA 231 instructions have an opcode of 0xB6-0xBF
unsigned FormIndex = ((BaseOpcode - 0x90) >> 4) & 0x3;
- auto I = llvm::bsearch(Table, [=](const X86InstrFMA3Group &Group) {
- return Opcode <= Group.Opcodes[FormIndex];
+ auto I = partition_point(Table, [=](const X86InstrFMA3Group &Group) {
+ return Group.Opcodes[FormIndex] < Opcode;
});
assert(I != Table.end() && I->Opcodes[FormIndex] == Opcode &&
"Couldn't find FMA3 opcode!");
diff --git a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
index f1851014e70..54ba8cc3126 100644
--- a/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/MachO/InterfaceFile.cpp
@@ -14,17 +14,15 @@
#include <iomanip>
#include <sstream>
-using namespace llvm::MachO;
-
namespace llvm {
namespace MachO {
namespace detail {
template <typename C>
typename C::iterator addEntry(C &Container, StringRef InstallName) {
- auto I = llvm::bsearch(Container, [=](const InterfaceFileRef &O) {
- return InstallName <= O.getInstallName();
+ auto I = partition_point(Container, [=](const InterfaceFileRef &O) {
+ return O.getInstallName() < InstallName;
});
- if ((I != std::end(Container)) && !(InstallName < I->getInstallName()))
+ if (I != Container.end() && I->getInstallName() == InstallName)
return I;
return Container.emplace(I, InstallName);
@@ -44,10 +42,10 @@ void InterfaceFile::addReexportedLibrary(StringRef InstallName,
}
void InterfaceFile::addUUID(Architecture Arch, StringRef UUID) {
- auto I =
- llvm::bsearch(UUIDs, [=](const std::pair<Architecture, std::string> &O) {
- return Arch <= O.first;
- });
+ auto I = partition_point(UUIDs,
+ [=](const std::pair<Architecture, std::string> &O) {
+ return O.first < Arch;
+ });
if (I != UUIDs.end() && Arch == I->first) {
I->second = UUID;
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index cf852111283..dfedd7c6fd3 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -278,8 +278,8 @@ void MemsetRanges::addRange(int64_t Start, int64_t Size, Value *Ptr,
unsigned Alignment, Instruction *Inst) {
int64_t End = Start+Size;
- range_iterator I = llvm::bsearch(
- Ranges, [=](const MemsetRange &O) { return Start <= O.End; });
+ range_iterator I = partition_point(
+ Ranges, [=](const MemsetRange &O) { return O.End < Start; });
// We now know that I == E, in which case we didn't find anything to merge
// with, or that Start <= I->End. If End < I->Start or I == E, then we need
OpenPOWER on IntegriCloud