[lld] r319976 - Add a call to std::vector::reserve.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 14:32:19 PST 2017
Author: rafael
Date: Wed Dec 6 14:32:19 2017
New Revision: 319976
URL: http://llvm.org/viewvc/llvm-project?rev=319976&view=rev
Log:
Add a call to std::vector::reserve.
This reduces total allocations when linking clang fsds from 263.21MB
to 174.62MB.
This also has some very nice speed improvements on some
benchmarks. Chromium and clang fsds link 6% faster.
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=319976&r1=319975&r2=319976&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Dec 6 14:32:19 2017
@@ -867,6 +867,9 @@ template <class ELFT, class RelTy>
static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) {
OffsetGetter GetOffset(Sec);
+ // Not all relocations end up in Sec.Relocations, but a lot do.
+ Sec.Relocations.reserve(Rels.size());
+
for (auto I = Rels.begin(), End = Rels.end(); I != End; ++I) {
const RelTy &Rel = *I;
Symbol &Sym = Sec.getFile<ELFT>()->getRelocTargetSym(Rel);
More information about the llvm-commits
mailing list