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
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 82760bf..a79add6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -67,9 +67,6 @@
/// source file.
class DwarfUnit {
protected:
- /// A numeric ID unique among all CUs in the module
- unsigned UniqueID;
-
/// MDNode for the compile unit.
const DICompileUnit *CUNode;
@@ -79,9 +76,6 @@
/// Unit debug information entry.
DIE &UnitDie;
- /// Offset of the UnitDie from beginning of debug info section.
- unsigned DebugInfoOffset;
-
/// Target of Dwarf emission.
AsmPrinter *Asm;
@@ -110,8 +104,8 @@
/// The section this unit will be emitted in.
MCSection *Section;
- DwarfUnit(unsigned UID, dwarf::Tag, const DICompileUnit *CU, AsmPrinter *A,
- DwarfDebug *DW, DwarfFile *DWU);
+ DwarfUnit(dwarf::Tag, const DICompileUnit *CU, AsmPrinter *A, DwarfDebug *DW,
+ DwarfFile *DWU);
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie);
@@ -127,14 +121,10 @@
// Accessors.
AsmPrinter* getAsmPrinter() const { return Asm; }
- unsigned getUniqueID() const { return UniqueID; }
uint16_t getLanguage() const { return CUNode->getSourceLanguage(); }
const DICompileUnit *getCUNode() const { return CUNode; }
DIE &getUnitDie() { return UnitDie; }
- unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
- void setDebugInfoOffset(unsigned DbgInfoOff) { DebugInfoOffset = DbgInfoOff; }
-
/// Return true if this compile unit has something to write out.
bool hasContent() const { return UnitDie.hasChildren(); }
@@ -221,7 +211,7 @@
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIEEntry Entry);
/// Add a type's DW_AT_signature and set the declaration flag.
- void addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type);
+ void addDIETypeSignature(DIE &Die, uint64_t Signature);
/// Add an attribute containing the type signature for a unique identifier.
void addDIETypeSignature(DIE &Die, dwarf::Attribute Attribute,
StringRef Identifier);
@@ -383,12 +373,10 @@
bool isDwoUnit() const override;
public:
- DwarfTypeUnit(unsigned UID, DwarfCompileUnit &CU, AsmPrinter *A,
- DwarfDebug *DW, DwarfFile *DWU,
- MCDwarfDwoLineTable *SplitLineTable = nullptr);
+ DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW,
+ DwarfFile *DWU, MCDwarfDwoLineTable *SplitLineTable = nullptr);
void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
- uint64_t getTypeSignature() const { return TypeSignature; }
void setType(const DIE *Ty) { this->Ty = Ty; }
/// Emit the header for this unit, not including the initial length field.