[lld] 863aa0a - [LLD][ELF] Fix performance of MarkLive::scanEhFrameSection
Andrew Ng via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 11:36:07 PDT 2020
Author: Andrew Ng
Date: 2020-09-08T19:32:34+01:00
New Revision: 863aa0a37bd1a57b0720eda6d646f9abd51bf6c2
URL: https://github.com/llvm/llvm-project/commit/863aa0a37bd1a57b0720eda6d646f9abd51bf6c2
DIFF: https://github.com/llvm/llvm-project/commit/863aa0a37bd1a57b0720eda6d646f9abd51bf6c2.diff
LOG: [LLD][ELF] Fix performance of MarkLive::scanEhFrameSection
MarkLive::scanEhFrameSection is used to retain personality/LSDA
functions when --gc-sections is enabled.
Improve its performance by only iterating over the .eh_frame relocations
that need to be resolved for an EhSectionPiece. This optimization makes
the same assumption as elsewhere in LLD that the .eh_frame relocations
are sorted by r_offset.
This appears to be a performance regression introduced in commit
e6c24299d237 (https://reviews.llvm.org/D59800).
This change has been seen to reduce link time by up to ~50%.
Differential Revision: https://reviews.llvm.org/D87245
Added:
Modified:
lld/ELF/MarkLive.cpp
Removed:
################################################################################
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index 28e13e8c1234..af6c08c21581 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -152,9 +152,9 @@ void MarkLive<ELFT>::scanEhFrameSection(EhInputSection &eh,
// a LSDA. We only need to keep the LSDA alive, so ignore anything that
// points to executable sections.
uint64_t pieceEnd = piece.inputOff + piece.size;
- for (size_t j = firstRelI, end2 = rels.size(); j < end2; ++j)
- if (rels[j].r_offset < pieceEnd)
- resolveReloc(eh, rels[j], true);
+ for (size_t j = firstRelI, end2 = rels.size();
+ j < end2 && rels[j].r_offset < pieceEnd; ++j)
+ resolveReloc(eh, rels[j], true);
}
}
More information about the llvm-commits
mailing list