[PATCH] D52126: Discard uncompressed buffer after creating .gdb_index contents.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 14 15:37:30 PDT 2018
ruiu created this revision.
ruiu added a reviewer: MaskRay.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
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.
https://reviews.llvm.org/D52126
Files:
lld/ELF/InputSection.h
lld/ELF/SyntheticSections.cpp
Index: lld/ELF/SyntheticSections.cpp
===================================================================
--- lld/ELF/SyntheticSections.cpp
+++ lld/ELF/SyntheticSections.cpp
@@ -2493,13 +2493,6 @@
template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
std::vector<InputSection *> 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<GdbChunk> Chunks(Sections.size());
std::vector<std::vector<NameTypeEntry>> NameTypes(Sections.size());
@@ -2513,6 +2506,16 @@
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 = nullptr;
+ }
+
auto *Ret = make<GdbIndexSection>();
Ret->Chunks = std::move(Chunks);
Ret->Symbols = createSymbols(NameTypes);
Index: lld/ELF/InputSection.h
===================================================================
--- lld/ELF/InputSection.h
+++ lld/ELF/InputSection.h
@@ -205,7 +205,6 @@
return llvm::makeArrayRef<T>((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<char[]> DecompressBuf;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52126.165603.patch
Type: text/x-patch
Size: 1841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180914/4f22e3bf/attachment.bin>
More information about the llvm-commits
mailing list