[PATCH] D36079: Binary search to find a relocation.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 17:05:57 PDT 2017
LGTM
We already depend or r_offset being sorted for .eh_frame.
Cheers,
Rafael
Rui Ueyama via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:
> ruiu created this revision.
> Herald added a subscriber: emaste.
>
> This change makes -gdb-index 40% faster. My test case is self-linking lld.
>
>
> https://reviews.llvm.org/D36079
>
> Files:
> lld/ELF/GdbIndex.cpp
>
>
> Index: lld/ELF/GdbIndex.cpp
> ===================================================================
> --- lld/ELF/GdbIndex.cpp
> +++ lld/ELF/GdbIndex.cpp
> @@ -79,11 +79,13 @@
> Optional<RelocAddrEntry>
> LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos,
> ArrayRef<RelTy> Rels) const {
> - auto I = llvm::find_if(Rels,
> - [=](const RelTy &Rel) { return Rel.r_offset == Pos; });
> - if (I == Rels.end())
> + auto It = std::lower_bound(
> + Rels.begin(), Rels.end(), Pos,
> + [](const RelTy &A, uint64_t B) { return A.r_offset < B; });
> + if (It == Rels.end() || It->r_offset != Pos)
> return None;
> - const RelTy &Rel = *I;
> + const RelTy &Rel = *It;
> +
> const ObjFile<ELFT> *File = Sec.getFile<ELFT>();
> uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
> const typename ELFT::Sym &Sym = File->getELFSymbols()[SymIndex];
>
>
> Index: lld/ELF/GdbIndex.cpp
> ===================================================================
> --- lld/ELF/GdbIndex.cpp
> +++ lld/ELF/GdbIndex.cpp
> @@ -79,11 +79,13 @@
> Optional<RelocAddrEntry>
> LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos,
> ArrayRef<RelTy> Rels) const {
> - auto I = llvm::find_if(Rels,
> - [=](const RelTy &Rel) { return Rel.r_offset == Pos; });
> - if (I == Rels.end())
> + auto It = std::lower_bound(
> + Rels.begin(), Rels.end(), Pos,
> + [](const RelTy &A, uint64_t B) { return A.r_offset < B; });
> + if (It == Rels.end() || It->r_offset != Pos)
> return None;
> - const RelTy &Rel = *I;
> + const RelTy &Rel = *It;
> +
> const ObjFile<ELFT> *File = Sec.getFile<ELFT>();
> uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
> const typename ELFT::Sym &Sym = File->getELFSymbols()[SymIndex];
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list