mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[llvm] Use llvm::lower_bound and llvm::upper_bound (NFC)
This commit is contained in:
parent
d5846298bc
commit
cac304a74c
@ -222,7 +222,7 @@ public:
|
||||
|
||||
/// Check whether the CPU string is valid.
|
||||
bool isCPUStringValid(StringRef CPU) const {
|
||||
auto Found = std::lower_bound(ProcDesc.begin(), ProcDesc.end(), CPU);
|
||||
auto Found = llvm::lower_bound(ProcDesc, CPU);
|
||||
return Found != ProcDesc.end() && StringRef(Found->Key) == CPU;
|
||||
}
|
||||
|
||||
|
@ -562,10 +562,9 @@ StringRef InstrProfSymtab::getFuncNameOrExternalSymbol(uint64_t FuncMD5Hash) {
|
||||
|
||||
StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) {
|
||||
finalizeSymtab();
|
||||
auto Result =
|
||||
std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash,
|
||||
[](const std::pair<uint64_t, StringRef> &LHS,
|
||||
uint64_t RHS) { return LHS.first < RHS; });
|
||||
auto Result = llvm::lower_bound(MD5NameMap, FuncMD5Hash,
|
||||
[](const std::pair<uint64_t, StringRef> &LHS,
|
||||
uint64_t RHS) { return LHS.first < RHS; });
|
||||
if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash)
|
||||
return Result->second;
|
||||
return StringRef();
|
||||
@ -573,10 +572,9 @@ StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) {
|
||||
|
||||
Function* InstrProfSymtab::getFunction(uint64_t FuncMD5Hash) {
|
||||
finalizeSymtab();
|
||||
auto Result =
|
||||
std::lower_bound(MD5FuncMap.begin(), MD5FuncMap.end(), FuncMD5Hash,
|
||||
[](const std::pair<uint64_t, Function*> &LHS,
|
||||
uint64_t RHS) { return LHS.first < RHS; });
|
||||
auto Result = llvm::lower_bound(MD5FuncMap, FuncMD5Hash,
|
||||
[](const std::pair<uint64_t, Function *> &LHS,
|
||||
uint64_t RHS) { return LHS.first < RHS; });
|
||||
if (Result != MD5FuncMap.end() && Result->first == FuncMD5Hash)
|
||||
return Result->second;
|
||||
return nullptr;
|
||||
|
@ -88,8 +88,7 @@ private:
|
||||
if (Offset >= getLength())
|
||||
return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
|
||||
++Offset;
|
||||
auto Iter =
|
||||
std::lower_bound(ItemEndOffsets.begin(), ItemEndOffsets.end(), Offset);
|
||||
auto Iter = llvm::lower_bound(ItemEndOffsets, Offset);
|
||||
size_t Idx = std::distance(ItemEndOffsets.begin(), Iter);
|
||||
assert(Idx < Items.size() && "binary search for offset failed");
|
||||
return Idx;
|
||||
|
@ -1016,7 +1016,7 @@ SortNonLocalDepInfoCache(MemoryDependenceResults::NonLocalDepInfo &Cache,
|
||||
NonLocalDepEntry Val = Cache.back();
|
||||
Cache.pop_back();
|
||||
MemoryDependenceResults::NonLocalDepInfo::iterator Entry =
|
||||
std::upper_bound(Cache.begin(), Cache.end(), Val);
|
||||
llvm::upper_bound(Cache, Val);
|
||||
Cache.insert(Entry, Val);
|
||||
}
|
||||
break;
|
||||
|
@ -52,9 +52,8 @@ static uint64_t getDebugInfoSize(DWARFContext &Dwarf) {
|
||||
/// Similar to DWARFUnitSection::getUnitForOffset(), but returning our
|
||||
/// CompileUnit object instead.
|
||||
static CompileUnit *getUnitForOffset(const UnitListTy &Units, uint64_t Offset) {
|
||||
auto CU = std::upper_bound(
|
||||
Units.begin(), Units.end(), Offset,
|
||||
[](uint64_t LHS, const std::unique_ptr<CompileUnit> &RHS) {
|
||||
auto CU = llvm::upper_bound(
|
||||
Units, Offset, [](uint64_t LHS, const std::unique_ptr<CompileUnit> &RHS) {
|
||||
return LHS < RHS->getOrigUnit().getNextUnitOffset();
|
||||
});
|
||||
return CU != Units.end() ? CU->get() : nullptr;
|
||||
|
@ -172,10 +172,10 @@ Error LazyRandomTypeCollection::visitRangeForType(TypeIndex TI) {
|
||||
if (PartialOffsets.empty())
|
||||
return fullScanForType(TI);
|
||||
|
||||
auto Next = std::upper_bound(PartialOffsets.begin(), PartialOffsets.end(), TI,
|
||||
[](TypeIndex Value, const TypeIndexOffset &IO) {
|
||||
return Value < IO.Type;
|
||||
});
|
||||
auto Next = llvm::upper_bound(PartialOffsets, TI,
|
||||
[](TypeIndex Value, const TypeIndexOffset &IO) {
|
||||
return Value < IO.Type;
|
||||
});
|
||||
|
||||
assert(Next != PartialOffsets.begin());
|
||||
auto Prev = std::prev(Next);
|
||||
|
@ -289,10 +289,10 @@ void UDTLayoutBase::addChildToLayout(std::unique_ptr<LayoutItemBase> Child) {
|
||||
UsedBytes |= ChildBytes;
|
||||
|
||||
if (ChildBytes.count() > 0) {
|
||||
auto Loc = std::upper_bound(LayoutItems.begin(), LayoutItems.end(), Begin,
|
||||
[](uint32_t Off, const LayoutItemBase *Item) {
|
||||
return (Off < Item->getOffsetInParent());
|
||||
});
|
||||
auto Loc = llvm::upper_bound(
|
||||
LayoutItems, Begin, [](uint32_t Off, const LayoutItemBase *Item) {
|
||||
return (Off < Item->getOffsetInParent());
|
||||
});
|
||||
|
||||
LayoutItems.insert(Loc, Child.get());
|
||||
}
|
||||
|
@ -589,11 +589,10 @@ ELFFile<ELFT>::toMappedAddr(uint64_t VAddr, WarningHandler WarnHandler) const {
|
||||
llvm::stable_sort(LoadSegments, SortPred);
|
||||
}
|
||||
|
||||
const Elf_Phdr *const *I =
|
||||
std::upper_bound(LoadSegments.begin(), LoadSegments.end(), VAddr,
|
||||
[](uint64_t VAddr, const Elf_Phdr_Impl<ELFT> *Phdr) {
|
||||
return VAddr < Phdr->p_vaddr;
|
||||
});
|
||||
const Elf_Phdr *const *I = llvm::upper_bound(
|
||||
LoadSegments, VAddr, [](uint64_t VAddr, const Elf_Phdr_Impl<ELFT> *Phdr) {
|
||||
return VAddr < Phdr->p_vaddr;
|
||||
});
|
||||
|
||||
if (I == LoadSegments.begin())
|
||||
return createError("virtual address is not in any segment: 0x" +
|
||||
|
@ -117,10 +117,10 @@ constexpr GPUInfo AMDGCNGPUs[] = {
|
||||
const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef<GPUInfo> Table) {
|
||||
GPUInfo Search = { {""}, {""}, AK, AMDGPU::FEATURE_NONE };
|
||||
|
||||
auto I = std::lower_bound(Table.begin(), Table.end(), Search,
|
||||
[](const GPUInfo &A, const GPUInfo &B) {
|
||||
return A.Kind < B.Kind;
|
||||
});
|
||||
auto I =
|
||||
llvm::lower_bound(Table, Search, [](const GPUInfo &A, const GPUInfo &B) {
|
||||
return A.Kind < B.Kind;
|
||||
});
|
||||
|
||||
if (I == Table.end())
|
||||
return nullptr;
|
||||
|
@ -107,9 +107,10 @@ public:
|
||||
SetTagZeroFn(SetTagZeroFn), StgpFn(StgpFn) {}
|
||||
|
||||
bool addRange(uint64_t Start, uint64_t End, Instruction *Inst) {
|
||||
auto I = std::lower_bound(
|
||||
Ranges.begin(), Ranges.end(), Start,
|
||||
[](const Range &LHS, uint64_t RHS) { return LHS.End <= RHS; });
|
||||
auto I =
|
||||
llvm::lower_bound(Ranges, Start, [](const Range &LHS, uint64_t RHS) {
|
||||
return LHS.End <= RHS;
|
||||
});
|
||||
if (I != Ranges.end() && End > I->Start) {
|
||||
// Overlap - bail.
|
||||
return false;
|
||||
|
@ -132,8 +132,7 @@ const PfmCountersInfo &ExegesisTarget::getPfmCounters(StringRef CpuName) const {
|
||||
"CpuPfmCounters table is not sorted");
|
||||
|
||||
// Find entry
|
||||
auto Found =
|
||||
std::lower_bound(CpuPfmCounters.begin(), CpuPfmCounters.end(), CpuName);
|
||||
auto Found = llvm::lower_bound(CpuPfmCounters, CpuName);
|
||||
if (Found == CpuPfmCounters.end() || StringRef(Found->CpuName) != CpuName) {
|
||||
// Use the default.
|
||||
if (CpuPfmCounters.begin() != CpuPfmCounters.end() &&
|
||||
|
@ -203,7 +203,7 @@ public:
|
||||
// using lower bound operation
|
||||
uint32_t getIndexForAddr(uint64_t Address) const {
|
||||
uint64_t Offset = virtualAddrToOffset(Address);
|
||||
auto Low = std::lower_bound(CodeAddrs.begin(), CodeAddrs.end(), Offset);
|
||||
auto Low = llvm::lower_bound(CodeAddrs, Offset);
|
||||
return Low - CodeAddrs.begin();
|
||||
}
|
||||
|
||||
|
@ -640,10 +640,8 @@ public:
|
||||
{
|
||||
auto E =
|
||||
std::make_pair(Top, Top->ExtraData.TerminalDurations.size());
|
||||
TopStacksByCount.insert(std::lower_bound(TopStacksByCount.begin(),
|
||||
TopStacksByCount.end(), E,
|
||||
greater_second),
|
||||
E);
|
||||
TopStacksByCount.insert(
|
||||
llvm::lower_bound(TopStacksByCount, E, greater_second), E);
|
||||
if (TopStacksByCount.size() == 11)
|
||||
TopStacksByCount.pop_back();
|
||||
}
|
||||
|
@ -462,18 +462,16 @@ void RegisterInfoEmitter::EmitRegMappingTables(
|
||||
|
||||
DefInit *DI = cast<DefInit>(V->getValue());
|
||||
Record *Alias = DI->getDef();
|
||||
const auto &AliasIter =
|
||||
std::lower_bound(DwarfRegNums.begin(), DwarfRegNums.end(), Alias,
|
||||
[](const DwarfRegNumsMapPair &A, const Record *B) {
|
||||
return LessRecordRegister()(A.first, B);
|
||||
});
|
||||
const auto &AliasIter = llvm::lower_bound(
|
||||
DwarfRegNums, Alias, [](const DwarfRegNumsMapPair &A, const Record *B) {
|
||||
return LessRecordRegister()(A.first, B);
|
||||
});
|
||||
assert(AliasIter != DwarfRegNums.end() && AliasIter->first == Alias &&
|
||||
"Expected Alias to be present in map");
|
||||
const auto &RegIter =
|
||||
std::lower_bound(DwarfRegNums.begin(), DwarfRegNums.end(), Reg,
|
||||
[](const DwarfRegNumsMapPair &A, const Record *B) {
|
||||
return LessRecordRegister()(A.first, B);
|
||||
});
|
||||
const auto &RegIter = llvm::lower_bound(
|
||||
DwarfRegNums, Reg, [](const DwarfRegNumsMapPair &A, const Record *B) {
|
||||
return LessRecordRegister()(A.first, B);
|
||||
});
|
||||
assert(RegIter != DwarfRegNums.end() && RegIter->first == Reg &&
|
||||
"Expected Reg to be present in map");
|
||||
RegIter->second = AliasIter->second;
|
||||
|
Loading…
Reference in New Issue
Block a user