[llvm] r201445 - DebugInfo: Implement DW_AT_stmt_list for type units
David Blaikie
dblaikie at gmail.com
Fri Feb 14 15:58:14 PST 2014
Author: dblaikie
Date: Fri Feb 14 17:58:13 2014
New Revision: 201445
URL: http://llvm.org/viewvc/llvm-project?rev=201445&view=rev
Log:
DebugInfo: Implement DW_AT_stmt_list for type units
Type units will share the statement list of their defining compile unit.
This is a tradeoff that reduces .o debug info size at the cost of some
linked debug info size (since the contents of those string tables won't
be deduplicated along with the type unit) which seems right for now.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=201445&r1=201444&r2=201445&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Feb 14 17:58:13 2014
@@ -2944,14 +2944,17 @@ DwarfCompileUnit *DwarfDebug::constructS
// This DIE has the following attributes: DW_AT_comp_dir, DW_AT_dwo_name,
// DW_AT_addr_base.
DwarfTypeUnit *DwarfDebug::constructSkeletonTU(DwarfTypeUnit *TU) {
+ DwarfCompileUnit &CU = static_cast<DwarfCompileUnit &>(
+ *SkeletonHolder.getUnits()[TU->getCU().getUniqueID()]);
DIE *Die = new DIE(dwarf::DW_TAG_type_unit);
- DwarfTypeUnit *NewTU = new DwarfTypeUnit(TU->getUniqueID(), Die, TU->getCU(),
- Asm, this, &SkeletonHolder);
+ DwarfTypeUnit *NewTU =
+ new DwarfTypeUnit(TU->getUniqueID(), Die, CU, Asm, this, &SkeletonHolder);
NewTU->setTypeSignature(TU->getTypeSignature());
NewTU->setType(NULL);
NewTU->initSection(
Asm->getObjFileLowering().getDwarfTypesSection(TU->getTypeSignature()));
+ CU.applyStmtList(*Die);
initSkeletonUnit(TU, Die, NewTU);
return NewTU;
@@ -3020,6 +3023,8 @@ void DwarfDebug::addDwarfTypeUnitType(Dw
NewTU->setTypeSignature(Signature);
if (useSplitDwarf())
NewTU->setSkeleton(constructSkeletonTU(NewTU));
+ else
+ CU.applyStmtList(*UnitDie);
NewTU->setType(NewTU->createTypeDIE(CTy));
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=201445&r1=201444&r2=201445&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Feb 14 17:58:13 2014
@@ -1990,6 +1990,8 @@ void DwarfCompileUnit::initStmtList(MCSy
bool UseTheFirstCU =
Asm->OutStreamer.hasRawTextSupport() || (getUniqueID() == 0);
+ stmtListIndex = UnitDie->getValues().size();
+
// DW_AT_stmt_list is a offset of line number information for this
// compile unit in debug_line section. For split dwarf this is
// left in the skeleton CU and so not included.
@@ -2005,6 +2007,12 @@ void DwarfCompileUnit::initStmtList(MCSy
DwarfLineSectionSym);
}
+void DwarfCompileUnit::applyStmtList(DIE &D) {
+ D.addValue(dwarf::DW_AT_stmt_list,
+ UnitDie->getAbbrev().getData()[stmtListIndex].getForm(),
+ UnitDie->getValues()[stmtListIndex]);
+}
+
void DwarfTypeUnit::emitHeader(const MCSection *ASection,
const MCSymbol *ASectionSym) const {
DwarfUnit::emitHeader(ASection, ASectionSym);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=201445&r1=201444&r2=201445&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Fri Feb 14 17:58:13 2014
@@ -539,12 +539,19 @@ private:
};
class DwarfCompileUnit : public DwarfUnit {
+ /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
+ /// the need to search for it in applyStmtList.
+ unsigned stmtListIndex;
+
public:
DwarfCompileUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU);
void initStmtList(MCSymbol *DwarfLineSectionSym);
+ /// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
+ void applyStmtList(DIE &D);
+
/// createGlobalVariableDIE - create global variable DIE.
void createGlobalVariableDIE(DIGlobalVariable GV);
Modified: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll?rev=201445&r1=201444&r2=201445&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Fri Feb 14 17:58:13 2014
@@ -71,6 +71,7 @@
; FISSION-NOT: type_signature
; FISSION-LABEL: type_signature = 0x1d02f3be30cc5688
; FISSION: DW_TAG_type_unit
+; FISSION: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
; FISSION: DW_AT_GNU_dwo_name{{.*}}"bar.dwo"
; FISSION: DW_AT_comp_dir{{.*}}"/tmp/dbginfo"
; FISSION-NOT: type_signature
@@ -114,6 +115,8 @@
; CHECK-NOT: type_signature
; CHECK-LABEL: type_signature = 0xe94f6d3843e62d6b
; CHECK: DW_TAG_type_unit
+; SINGLE: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
+; FISSION-NOT: DW_AT_stmt_list
; CHECK-NOT: NULL
; CHECK-NOT: DW_AT_GNU_odr_signature
; CHECK: DW_TAG_structure_type
@@ -141,21 +144,21 @@
; CHECK-NEXT: Offset Name
; CHECK-NEXT: "walrus"
; Type unit for 'bar'
-; SINGLE-NEXT: unit_size = 0x00000023
-; FISSION-NEXT: unit_size = 0x00000024
+; SINGLE-NEXT: unit_size = 0x00000027
+; FISSION-NEXT: unit_size = 0x00000028
; CHECK-NEXT: Offset Name
; CHECK-NEXT: "bar"
-; SINGLE-NEXT: unit_size = 0x0000005d
-; FISSION-NEXT: unit_size = 0x00000024
+; SINGLE-NEXT: unit_size = 0x00000061
+; FISSION-NEXT: unit_size = 0x00000028
; CHECK-NEXT: Offset Name
; CHECK-NEXT: "int"
; CHECK-NEXT: "echidna::capybara::mongoose::fluffy"
-; SINGLE-NEXT: unit_size = 0x0000003a
-; FISSION-NEXT: unit_size = 0x00000024
+; SINGLE-NEXT: unit_size = 0x0000003e
+; FISSION-NEXT: unit_size = 0x00000028
; CHECK-NEXT: Offset Name
; CHECK-NEXT: "wombat"
-; SINGLE-NEXT: unit_size = 0x0000004b
-; FISSION-NEXT: unit_size = 0x00000024
+; SINGLE-NEXT: unit_size = 0x0000004f
+; FISSION-NEXT: unit_size = 0x00000028
; CHECK-NEXT: Offset Name
; CHECK-NEXT: "int"
More information about the llvm-commits
mailing list