From 5da1d88492e2487b67c3cf79031b8e273bd6fb35 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 26 Oct 2016 15:34:24 +0000 Subject: [PATCH] Reduce the number of allocators. We used to have one allocator per file, which reduces the advantage of using an allocator in the first place. This is a small speed up is most cases. The largest speedup was in 1.014X in chromium no-gc. The largest slowdown was scylla at 1.003X. llvm-svn: 285205 --- lld/ELF/Driver.cpp | 6 +++--- lld/ELF/InputFiles.cpp | 29 +++++++++++++++-------------- lld/ELF/InputFiles.h | 12 +++++++----- lld/ELF/LTO.cpp | 3 ++- lld/ELF/LTO.h | 1 + lld/ELF/SymbolTable.cpp | 8 ++++---- lld/ELF/Symbols.cpp | 15 ++++++++------- lld/ELF/Symbols.h | 6 +++--- 8 files changed, 43 insertions(+), 37 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 5cb0746..207a2e58 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -137,7 +137,7 @@ void LinkerDriver::addFile(StringRef Path) { case file_magic::archive: if (InWholeArchive) { for (MemoryBufferRef MB : getArchiveMembers(MBRef)) - Files.push_back(createObjectFile(MB, Path)); + Files.push_back(createObjectFile(Alloc, MB, Path)); return; } Files.push_back(new ArchiveFile(MBRef)); @@ -147,13 +147,13 @@ void LinkerDriver::addFile(StringRef Path) { error("attempted static link of dynamic object " + Path); return; } - Files.push_back(createSharedFile(MBRef)); + Files.push_back(createSharedFile(Alloc, MBRef)); return; default: if (InLib) Files.push_back(new LazyObjectFile(MBRef)); else - Files.push_back(createObjectFile(MBRef)); + Files.push_back(createObjectFile(Alloc, MBRef)); } } diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 2dd34f0..507090d 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -140,8 +140,8 @@ template void ELFFileBase::initStringTable() { } template -elf::ObjectFile::ObjectFile(MemoryBufferRef M) - : ELFFileBase(Base::ObjectKind, M) {} +elf::ObjectFile::ObjectFile(BumpPtrAllocator &Alloc, MemoryBufferRef M) + : ELFFileBase(Base::ObjectKind, M), Alloc(Alloc) {} template ArrayRef elf::ObjectFile::getNonLocalSymbols() { @@ -547,7 +547,7 @@ ArchiveFile::getMember(const Archive::Symbol *Sym) { } template -SharedFile::SharedFile(MemoryBufferRef M) +SharedFile::SharedFile(BumpPtrAllocator &Alloc, MemoryBufferRef M) : ELFFileBase(Base::SharedKind, M), AsNeeded(Config->AsNeeded) {} template @@ -793,7 +793,7 @@ void BitcodeFile::parse(DenseSet &ComdatGroups) { } template