Skip to content

Commit

Permalink
[ELF] --gdb-index: fix memory usage regression after D74773
Browse files Browse the repository at this point in the history
On an internal target,

* Before D74773: time -f '%M' => 18275680
* After D74773:  time -f '%M' => 22088964

This patch restores to the status before D74773.
  • Loading branch information
MaskRay committed Mar 12, 2020
1 parent af7fc8c commit 0bb362c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lld/ELF/SyntheticSections.cpp
Expand Up @@ -2822,14 +2822,16 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
std::vector<std::vector<NameAttrEntry>> nameAttrs(sections.size());

parallelForEachN(0, sections.size(), [&](size_t i) {
DWARFContext *dwarf =
sections[i]->getFile<ELFT>()->getDwarf()->getContext();
// To keep memory usage low, we don't want to keep cached DWARFContext, so
// avoid getDwarf() here.
ObjFile<ELFT> *file = sections[i]->getFile<ELFT>();
DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(file));

chunks[i].sec = sections[i];
chunks[i].compilationUnits = readCuList(*dwarf);
chunks[i].addressAreas = readAddressAreas(*dwarf, sections[i]);
chunks[i].compilationUnits = readCuList(dwarf);
chunks[i].addressAreas = readAddressAreas(dwarf, sections[i]);
nameAttrs[i] = readPubNamesAndTypes<ELFT>(
static_cast<const LLDDwarfObj<ELFT> &>(dwarf->getDWARFObj()),
static_cast<const LLDDwarfObj<ELFT> &>(dwarf.getDWARFObj()),
chunks[i].compilationUnits);
});

Expand Down

0 comments on commit 0bb362c

Please sign in to comment.