forked from OSchip/llvm-project
Change some llvm::{lower,upper}_bound to llvm::bsearch. NFC
llvm-svn: 358564
This commit is contained in:
parent
b0b65cae59
commit
c82e92bca8
|
@ -462,12 +462,11 @@ public:
|
||||||
DWARFDie getDIEForOffset(uint32_t Offset) {
|
DWARFDie getDIEForOffset(uint32_t Offset) {
|
||||||
extractDIEsIfNeeded(false);
|
extractDIEsIfNeeded(false);
|
||||||
assert(!DieArray.empty());
|
assert(!DieArray.empty());
|
||||||
auto it = llvm::lower_bound(
|
auto It = llvm::bsearch(DieArray, [=](const DWARFDebugInfoEntry &LHS) {
|
||||||
DieArray, Offset, [](const DWARFDebugInfoEntry &LHS, uint32_t Offset) {
|
return Offset <= LHS.getOffset();
|
||||||
return LHS.getOffset() < Offset;
|
});
|
||||||
});
|
if (It != DieArray.end() && It->getOffset() == Offset)
|
||||||
if (it != DieArray.end() && it->getOffset() == Offset)
|
return DWARFDie(this, &*It);
|
||||||
return DWARFDie(this, &*it);
|
|
||||||
return DWARFDie();
|
return DWARFDie();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,10 +506,8 @@ LegalizerInfo::findAction(const SizeAndActionsVec &Vec, const uint32_t Size) {
|
||||||
// Find the last element in Vec that has a bitsize equal to or smaller than
|
// Find the last element in Vec that has a bitsize equal to or smaller than
|
||||||
// the requested bit size.
|
// the requested bit size.
|
||||||
// That is the element just before the first element that is bigger than Size.
|
// That is the element just before the first element that is bigger than Size.
|
||||||
auto VecIt = llvm::upper_bound(
|
auto VecIt = llvm::bsearch(
|
||||||
Vec, Size, [](const uint32_t Size, const SizeAndAction lhs) -> bool {
|
Vec, [=](const SizeAndAction &A) { return Size < A.first; });
|
||||||
return Size < lhs.first;
|
|
||||||
});
|
|
||||||
assert(VecIt != Vec.begin() && "Does Vec not start with size 1?");
|
assert(VecIt != Vec.begin() && "Does Vec not start with size 1?");
|
||||||
--VecIt;
|
--VecIt;
|
||||||
int VecIdx = VecIt - Vec.begin();
|
int VecIdx = VecIt - Vec.begin();
|
||||||
|
|
|
@ -115,9 +115,7 @@ void DWARFDebugAranges::construct() {
|
||||||
|
|
||||||
uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const {
|
uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const {
|
||||||
RangeCollIterator It =
|
RangeCollIterator It =
|
||||||
llvm::upper_bound(Aranges, Address, [](uint64_t LHS, Range RHS) {
|
llvm::bsearch(Aranges, [=](Range RHS) { return Address < RHS.HighPC(); });
|
||||||
return LHS < RHS.HighPC();
|
|
||||||
});
|
|
||||||
if (It != Aranges.end() && It->LowPC <= Address)
|
if (It != Aranges.end() && It->LowPC <= Address)
|
||||||
return It->CUOffset;
|
return It->CUOffset;
|
||||||
return -1U;
|
return -1U;
|
||||||
|
|
|
@ -57,9 +57,8 @@ void DWARFDebugLoc::LocationList::dump(raw_ostream &OS, bool IsLittleEndian,
|
||||||
|
|
||||||
DWARFDebugLoc::LocationList const *
|
DWARFDebugLoc::LocationList const *
|
||||||
DWARFDebugLoc::getLocationListAtOffset(uint64_t Offset) const {
|
DWARFDebugLoc::getLocationListAtOffset(uint64_t Offset) const {
|
||||||
auto It = llvm::lower_bound(
|
auto It = llvm::bsearch(
|
||||||
Locations, Offset,
|
Locations, [=](const LocationList &L) { return Offset <= L.Offset; });
|
||||||
[](const LocationList &L, uint64_t Offset) { return L.Offset < Offset; });
|
|
||||||
if (It != Locations.end() && It->Offset == Offset)
|
if (It != Locations.end() && It->Offset == Offset)
|
||||||
return &(*It);
|
return &(*It);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -213,9 +212,8 @@ void DWARFDebugLoclists::parse(DataExtractor data, unsigned Version) {
|
||||||
|
|
||||||
DWARFDebugLoclists::LocationList const *
|
DWARFDebugLoclists::LocationList const *
|
||||||
DWARFDebugLoclists::getLocationListAtOffset(uint64_t Offset) const {
|
DWARFDebugLoclists::getLocationListAtOffset(uint64_t Offset) const {
|
||||||
auto It = llvm::lower_bound(
|
auto It = llvm::bsearch(
|
||||||
Locations, Offset,
|
Locations, [=](const LocationList &L) { return Offset <= L.Offset; });
|
||||||
[](const LocationList &L, uint64_t Offset) { return L.Offset < Offset; });
|
|
||||||
if (It != Locations.end() && It->Offset == Offset)
|
if (It != Locations.end() && It->Offset == Offset)
|
||||||
return &(*It);
|
return &(*It);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -172,10 +172,9 @@ DWARFUnitIndex::getFromOffset(uint32_t Offset) const {
|
||||||
E2->Contributions[InfoColumn].Offset;
|
E2->Contributions[InfoColumn].Offset;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
auto I =
|
auto I = llvm::bsearch(OffsetLookup, [&](Entry *E2) {
|
||||||
llvm::upper_bound(OffsetLookup, Offset, [&](uint32_t Offset, Entry *E2) {
|
return Offset < E2->Contributions[InfoColumn].Offset;
|
||||||
return Offset < E2->Contributions[InfoColumn].Offset;
|
});
|
||||||
});
|
|
||||||
if (I == OffsetLookup.begin())
|
if (I == OffsetLookup.begin())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
--I;
|
--I;
|
||||||
|
|
|
@ -1045,10 +1045,9 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
|
||||||
error(ExportEntry.getExportRVA(RVA));
|
error(ExportEntry.getExportRVA(RVA));
|
||||||
|
|
||||||
uint64_t VA = COFFObj->getImageBase() + RVA;
|
uint64_t VA = COFFObj->getImageBase() + RVA;
|
||||||
auto Sec = llvm::upper_bound(
|
auto Sec = llvm::bsearch(
|
||||||
SectionAddresses, VA,
|
SectionAddresses, [VA](const std::pair<uint64_t, SectionRef> &RHS) {
|
||||||
[](uint64_t LHS, const std::pair<uint64_t, SectionRef> &RHS) {
|
return VA < RHS.first;
|
||||||
return LHS < RHS.first;
|
|
||||||
});
|
});
|
||||||
if (Sec != SectionAddresses.begin()) {
|
if (Sec != SectionAddresses.begin()) {
|
||||||
--Sec;
|
--Sec;
|
||||||
|
@ -1302,35 +1301,33 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
|
||||||
// N.B. We don't walk the relocations in the relocatable case yet.
|
// N.B. We don't walk the relocations in the relocatable case yet.
|
||||||
auto *TargetSectionSymbols = &Symbols;
|
auto *TargetSectionSymbols = &Symbols;
|
||||||
if (!Obj->isRelocatableObject()) {
|
if (!Obj->isRelocatableObject()) {
|
||||||
auto SectionAddress = llvm::upper_bound(
|
auto It = llvm::bsearch(
|
||||||
SectionAddresses, Target,
|
SectionAddresses,
|
||||||
[](uint64_t LHS, const std::pair<uint64_t, SectionRef> &RHS) {
|
[=](const std::pair<uint64_t, SectionRef> &RHS) {
|
||||||
return LHS < RHS.first;
|
return Target < RHS.first;
|
||||||
});
|
});
|
||||||
if (SectionAddress != SectionAddresses.begin()) {
|
if (It != SectionAddresses.begin()) {
|
||||||
--SectionAddress;
|
--It;
|
||||||
TargetSectionSymbols = &AllSymbols[SectionAddress->second];
|
TargetSectionSymbols = &AllSymbols[It->second];
|
||||||
} else {
|
} else {
|
||||||
TargetSectionSymbols = &AbsoluteSymbols;
|
TargetSectionSymbols = &AbsoluteSymbols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the first symbol in the section whose offset is less than
|
// Find the last symbol in the section whose offset is less than
|
||||||
// or equal to the target. If there isn't a section that contains
|
// or equal to the target. If there isn't a section that contains
|
||||||
// the target, find the nearest preceding absolute symbol.
|
// the target, find the nearest preceding absolute symbol.
|
||||||
auto TargetSym = llvm::upper_bound(
|
auto TargetSym = llvm::bsearch(
|
||||||
*TargetSectionSymbols, Target,
|
*TargetSectionSymbols,
|
||||||
[](uint64_t LHS,
|
[=](const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
|
||||||
const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
|
return Target < std::get<0>(RHS);
|
||||||
return LHS < std::get<0>(RHS);
|
|
||||||
});
|
});
|
||||||
if (TargetSym == TargetSectionSymbols->begin()) {
|
if (TargetSym == TargetSectionSymbols->begin()) {
|
||||||
TargetSectionSymbols = &AbsoluteSymbols;
|
TargetSectionSymbols = &AbsoluteSymbols;
|
||||||
TargetSym = llvm::upper_bound(
|
TargetSym = llvm::bsearch(
|
||||||
AbsoluteSymbols, Target,
|
AbsoluteSymbols,
|
||||||
[](uint64_t LHS,
|
[=](const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
|
||||||
const std::tuple<uint64_t, StringRef, uint8_t> &RHS) {
|
return Target < std::get<0>(RHS);
|
||||||
return LHS < std::get<0>(RHS);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (TargetSym != TargetSectionSymbols->begin()) {
|
if (TargetSym != TargetSectionSymbols->begin()) {
|
||||||
|
|
Loading…
Reference in New Issue