From: Rui Ueyama Date: Fri, 14 Sep 2018 22:57:39 +0000 (+0000) Subject: Discard uncompressed buffer after creating .gdb_index contents. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=751dfbe39b8a0206883bce7259ba4f3464fc420d;p=platform%2Fupstream%2Fllvm.git Discard uncompressed buffer after creating .gdb_index contents. Once we create .gdb_index contents, .zdebug_gnu_pub{names,types} are useless, so there's no need to keep their uncompressed data in memory. I observed that for a test case in which lld creates a 3GB .gdb_index section, the maximum resident set size reduced from 43GB to 29GB after this patch. Differential Revision: https://reviews.llvm.org/D52126 llvm-svn: 342297 --- diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index c68b7d1..06644c7 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -205,7 +205,6 @@ public: return llvm::makeArrayRef((const T *)Data.data(), S / sizeof(T)); } -private: // A pointer that owns decompressed data if a section is compressed by zlib. // Since the feature is not used often, this is usually a nullptr. std::unique_ptr DecompressBuf; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index b547956..96eb3846 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2495,13 +2495,6 @@ createSymbols(ArrayRef> NameTypes) { template GdbIndexSection *GdbIndexSection::create() { std::vector Sections = getDebugInfoSections(); - // .debug_gnu_pub{names,types} are useless in executables. - // They are present in input object files solely for creating - // a .gdb_index. So we can remove them from the output. - for (InputSectionBase *S : InputSections) - if (S->Name == ".debug_gnu_pubnames" || S->Name == ".debug_gnu_pubtypes") - S->Live = false; - std::vector Chunks(Sections.size()); std::vector> NameTypes(Sections.size()); @@ -2515,6 +2508,16 @@ template GdbIndexSection *GdbIndexSection::create() { NameTypes[I] = readPubNamesAndTypes(Dwarf, I); }); + // .debug_gnu_pub{names,types} are useless in executables. + // They are present in input object files solely for creating + // a .gdb_index. So we can remove them from the output. + for (InputSectionBase *S : InputSections) { + if (S->Name != ".debug_gnu_pubnames" && S->Name != ".debug_gnu_pubtypes") + continue; + S->Live = false; + S->DecompressBuf.reset(); + } + auto *Ret = make(); Ret->Chunks = std::move(Chunks); Ret->Symbols = createSymbols(NameTypes);