diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-02-11 19:57:46 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-02-11 19:57:46 +0000 |
commit | 7c384ccea28e7f0f7c178f6c8b5870a99a425c56 (patch) | |
tree | 700f76953b07032e8a54ecb44dc52e2070b3b67a /llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | |
parent | b473e1e473c4dd85cb6323129a619ac3a31f4e77 (diff) | |
download | bcm5719-llvm-7c384ccea28e7f0f7c178f6c8b5870a99a425c56.tar.gz bcm5719-llvm-7c384ccea28e7f0f7c178f6c8b5870a99a425c56.zip |
DwarfDebug: emit type units immediately.
Rather than storing type units in a vector and emitting them at the end
of code generation, emit them immediately and destroy them, reclaiming the
memory we were using for their DIEs.
In one benchmark carried out against Chromium's 50 largest (by bitcode
file size) translation units, total peak memory consumption with type units
decreased by median 17%, or by 7% when compared against disabling type units.
Tested using check-{llvm,clang}, the GDB 7.5 test suite (with
'-fdebug-types-section') and by eyeballing llvm-dwarfdump output on those
Chromium translation units with split DWARF both disabled and enabled, and
verifying that the only changes were to addresses and abbreviation ordering.
Differential Revision: http://reviews.llvm.org/D17118
llvm-svn: 260578
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp index 51b27b462a7..e9fe98ab3cf 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "DwarfFile.h" +#include "DwarfCompileUnit.h" #include "DwarfDebug.h" #include "DwarfUnit.h" #include "llvm/ADT/STLExtras.h" @@ -50,22 +51,25 @@ DIEAbbrev &DwarfFile::assignAbbrevNumber(DIE &Die) { return *New; } -void DwarfFile::addUnit(std::unique_ptr<DwarfUnit> U) { +void DwarfFile::addUnit(std::unique_ptr<DwarfCompileUnit> U) { CUs.push_back(std::move(U)); } // Emit the various dwarf units to the unit section USection with // the abbreviations going into ASection. void DwarfFile::emitUnits(bool UseOffsets) { - for (const auto &TheU : CUs) { - DIE &Die = TheU->getUnitDie(); - MCSection *USection = TheU->getSection(); - Asm->OutStreamer->SwitchSection(USection); + for (const auto &TheU : CUs) + emitUnit(TheU.get(), UseOffsets); +} - TheU->emitHeader(UseOffsets); +void DwarfFile::emitUnit(DwarfUnit *TheU, bool UseOffsets) { + DIE &Die = TheU->getUnitDie(); + MCSection *USection = TheU->getSection(); + Asm->OutStreamer->SwitchSection(USection); - Asm->emitDwarfDIE(Die); - } + TheU->emitHeader(UseOffsets); + + Asm->emitDwarfDIE(Die); } // Compute the size and offset for each DIE. @@ -77,17 +81,20 @@ void DwarfFile::computeSizeAndOffsets() { // DIE within each compile unit. All offsets are CU relative. for (const auto &TheU : CUs) { TheU->setDebugInfoOffset(SecOffset); + SecOffset += computeSizeAndOffsetsForUnit(TheU.get()); + } +} - // CU-relative offset is reset to 0 here. - unsigned Offset = sizeof(int32_t) + // Length of Unit Info - TheU->getHeaderSize(); // Unit-specific headers +unsigned DwarfFile::computeSizeAndOffsetsForUnit(DwarfUnit *TheU) { + // CU-relative offset is reset to 0 here. + unsigned Offset = sizeof(int32_t) + // Length of Unit Info + TheU->getHeaderSize(); // Unit-specific headers - // EndOffset here is CU-relative, after laying out - // all of the CU DIE. - unsigned EndOffset = computeSizeAndOffset(TheU->getUnitDie(), Offset); - SecOffset += EndOffset; - } + // The return value here is CU-relative, after laying out + // all of the CU DIE. + return computeSizeAndOffset(TheU->getUnitDie(), Offset); } + // Compute the size and offset of a DIE. The offset is relative to start of the // CU. It returns the offset after laying out the DIE. unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) { |