Skip to content

Commit 5b7a79f

Browse files
committed
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 llvm-svn: 276108
1 parent bbed03e commit 5b7a79f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lld/ELF/Relocations.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
524524
const elf::ObjectFile<ELFT> &File = *C.getFile();
525525
ArrayRef<uint8_t> SectionData = C.getSectionData();
526526
const uint8_t *Buf = SectionData.begin();
527+
528+
SectionPiece *PieceI = nullptr;
529+
SectionPiece *PieceE = nullptr;
530+
if (auto *Eh = dyn_cast<EhInputSection<ELFT>>(&C)) {
531+
PieceI = &*Eh->Pieces.begin();
532+
PieceE = &*Eh->Pieces.end();
533+
}
534+
527535
for (auto I = Rels.begin(), E = Rels.end(); I != E; ++I) {
528536
const RelTy &RI = *I;
529537
SymbolBody &Body = File.getRelocTargetSym(RI);
@@ -536,8 +544,12 @@ static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
536544
continue;
537545

538546
// Skip a relocation that points to a dead piece
539-
// in a mergeable section.
540-
if (C.getOffset(RI.r_offset) == (uintX_t)-1)
547+
// in a eh_frame section.
548+
while (PieceI != PieceE &&
549+
(PieceI->InputOff + PieceI->size() <= RI.r_offset))
550+
++PieceI;
551+
if (PieceI != PieceE && PieceI->InputOff <= RI.r_offset &&
552+
PieceI->OutputOff == (uintX_t)-1)
541553
continue;
542554

543555
// This relocation does not require got entry, but it is relative to got and

0 commit comments

Comments
 (0)