[PATCH] D36079: Binary search to find a relocation.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 03:03:00 PDT 2017
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];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36079.108889.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/8dc464d8/attachment.bin>
More information about the llvm-commits
mailing list