diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-10-26 15:34:24 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-10-26 15:34:24 +0000 |
| commit | 5da1d88492e2487b67c3cf79031b8e273bd6fb35 (patch) | |
| tree | f5099035219190e0e55c91c295d8a79fd0b924d6 /lld/ELF/InputFiles.cpp | |
| parent | 81e8b771d72d23a513d3acde43d1396d435e9b26 (diff) | |
| download | bcm5719-llvm-5da1d88492e2487b67c3cf79031b8e273bd6fb35.tar.gz bcm5719-llvm-5da1d88492e2487b67c3cf79031b8e273bd6fb35.zip | |
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
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 2dd34f0d5d8..507090d563d 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -140,8 +140,8 @@ template <class ELFT> void ELFFileBase<ELFT>::initStringTable() { } template <class ELFT> -elf::ObjectFile<ELFT>::ObjectFile(MemoryBufferRef M) - : ELFFileBase<ELFT>(Base::ObjectKind, M) {} +elf::ObjectFile<ELFT>::ObjectFile(BumpPtrAllocator &Alloc, MemoryBufferRef M) + : ELFFileBase<ELFT>(Base::ObjectKind, M), Alloc(Alloc) {} template <class ELFT> ArrayRef<SymbolBody *> elf::ObjectFile<ELFT>::getNonLocalSymbols() { @@ -547,7 +547,7 @@ ArchiveFile::getMember(const Archive::Symbol *Sym) { } template <class ELFT> -SharedFile<ELFT>::SharedFile(MemoryBufferRef M) +SharedFile<ELFT>::SharedFile(BumpPtrAllocator &Alloc, MemoryBufferRef M) : ELFFileBase<ELFT>(Base::SharedKind, M), AsNeeded(Config->AsNeeded) {} template <class ELFT> @@ -793,7 +793,7 @@ void BitcodeFile::parse(DenseSet<CachedHashStringRef> &ComdatGroups) { } template <template <class> class T> -static InputFile *createELFFile(MemoryBufferRef MB) { +static InputFile *createELFFile(BumpPtrAllocator &Alloc, MemoryBufferRef MB) { unsigned char Size; unsigned char Endian; std::tie(Size, Endian) = getElfArchType(MB.getBuffer()); @@ -802,13 +802,13 @@ static InputFile *createELFFile(MemoryBufferRef MB) { InputFile *Obj; if (Size == ELFCLASS32 && Endian == ELFDATA2LSB) - Obj = new T<ELF32LE>(MB); + Obj = new T<ELF32LE>(Alloc, MB); else if (Size == ELFCLASS32 && Endian == ELFDATA2MSB) - Obj = new T<ELF32BE>(MB); + Obj = new T<ELF32BE>(Alloc, MB); else if (Size == ELFCLASS64 && Endian == ELFDATA2LSB) - Obj = new T<ELF64LE>(MB); + Obj = new T<ELF64LE>(Alloc, MB); else if (Size == ELFCLASS64 && Endian == ELFDATA2MSB) - Obj = new T<ELF64BE>(MB); + Obj = new T<ELF64BE>(Alloc, MB); else fatal("invalid file class: " + MB.getBufferIdentifier()); @@ -825,7 +825,7 @@ template <class ELFT> InputFile *BinaryFile::createELF() { Buffer = wrapBinaryWithElfHeader<ELFT>(Blob, Filename); return createELFFile<ObjectFile>( - MemoryBufferRef(toStringRef(Buffer), Filename)); + Alloc, MemoryBufferRef(toStringRef(Buffer), Filename)); } static bool isBitcode(MemoryBufferRef MB) { @@ -833,17 +833,18 @@ static bool isBitcode(MemoryBufferRef MB) { return identify_magic(MB.getBuffer()) == file_magic::bitcode; } -InputFile *elf::createObjectFile(MemoryBufferRef MB, StringRef ArchiveName, +InputFile *elf::createObjectFile(BumpPtrAllocator &Alloc, MemoryBufferRef MB, + StringRef ArchiveName, uint64_t OffsetInArchive) { - InputFile *F = - isBitcode(MB) ? new BitcodeFile(MB) : createELFFile<ObjectFile>(MB); + InputFile *F = isBitcode(MB) ? new BitcodeFile(MB) + : createELFFile<ObjectFile>(Alloc, MB); F->ArchiveName = ArchiveName; F->OffsetInArchive = OffsetInArchive; return F; } -InputFile *elf::createSharedFile(MemoryBufferRef MB) { - return createELFFile<SharedFile>(MB); +InputFile *elf::createSharedFile(BumpPtrAllocator &Alloc, MemoryBufferRef MB) { + return createELFFile<SharedFile>(Alloc, MB); } MemoryBufferRef LazyObjectFile::getBuffer() { |

