diff options
author | Rui Ueyama <ruiu@google.com> | 2017-08-01 04:11:03 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-08-01 04:11:03 +0000 |
commit | f974994e158db52bf9a0a9978cbb4b7642587f99 (patch) | |
tree | a772eb94e98b0eb50916a7bc329e3606d9c56529 | |
parent | b9417dbd482b86087129ffec11a1a41d74103ad1 (diff) | |
download | bcm5719-llvm-f974994e158db52bf9a0a9978cbb4b7642587f99.tar.gz bcm5719-llvm-f974994e158db52bf9a0a9978cbb4b7642587f99.zip |
Binary search to find a relocation.
This change makes -gdb-index 40% faster. My test case is self-linking lld.
Differential Revision: https://reviews.llvm.org/D36079
llvm-svn: 309652
-rw-r--r-- | lld/ELF/GdbIndex.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lld/ELF/GdbIndex.cpp b/lld/ELF/GdbIndex.cpp index 1d242923220..d7313af0bdf 100644 --- a/lld/ELF/GdbIndex.cpp +++ b/lld/ELF/GdbIndex.cpp @@ -79,11 +79,13 @@ template <class RelTy> 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]; |