[lld] r276108 - Avoid some binary searches.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 04:47:51 PDT 2016
Author: rafael
Date: Wed Jul 20 06:47:50 2016
New Revision: 276108
URL: http://llvm.org/viewvc/llvm-project?rev=276108&view=rev
Log:
Avoid some binary searches.
In here we are iterating relocations in order, so we can do the same
with the pieces of .eh_frame and avoid a binary search.
The link times I got with this patch were:
firefox
master 7.22977811
patch 7.141041442 0.987726225252
chromium
master 4.478966851
patch 4.506602207 1.00617002914
chromium fast
master 1.894713371
patch 1.866446889 0.98508139414
the gold plugin
master 0.386193907
patch 0.382374918 0.990111213743
clang
master 0.654849589
patch 0.647899815 0.989387220949
llvm-as
master 0.037212718
patch 0.036858172 0.990472450843
the gold plugin fsds
master 0.410876711
patch 0.407418613 0.991583611562
clang fsds
master 0.734623069
patch 0.728237526 0.991307728726
llvm-as fsds
master 0.033446197
patch 0.03302833 0.987506292569
scylla
master 3.38134402
patch 3.414188846 1.00971354166
Modified:
lld/trunk/ELF/Relocations.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=276108&r1=276107&r2=276108&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Jul 20 06:47:50 2016
@@ -524,6 +524,14 @@ static void scanRelocs(InputSectionBase<
const elf::ObjectFile<ELFT> &File = *C.getFile();
ArrayRef<uint8_t> SectionData = C.getSectionData();
const uint8_t *Buf = SectionData.begin();
+
+ SectionPiece *PieceI = nullptr;
+ SectionPiece *PieceE = nullptr;
+ if (auto *Eh = dyn_cast<EhInputSection<ELFT>>(&C)) {
+ PieceI = &*Eh->Pieces.begin();
+ PieceE = &*Eh->Pieces.end();
+ }
+
for (auto I = Rels.begin(), E = Rels.end(); I != E; ++I) {
const RelTy &RI = *I;
SymbolBody &Body = File.getRelocTargetSym(RI);
@@ -536,8 +544,12 @@ static void scanRelocs(InputSectionBase<
continue;
// Skip a relocation that points to a dead piece
- // in a mergeable section.
- if (C.getOffset(RI.r_offset) == (uintX_t)-1)
+ // in a eh_frame section.
+ while (PieceI != PieceE &&
+ (PieceI->InputOff + PieceI->size() <= RI.r_offset))
+ ++PieceI;
+ if (PieceI != PieceE && PieceI->InputOff <= RI.r_offset &&
+ PieceI->OutputOff == (uintX_t)-1)
continue;
// This relocation does not require got entry, but it is relative to got and
More information about the llvm-commits
mailing list