Skip to content

Commit 154b8cd

Browse files
committed
Merge from mainline.
Assorted debug info fixes. - DW_AT_bit_size is only suitable for bitfields. - Encode source ___location info for derived types. - Source ___location and type size info is not useful for subroutine_type (info is included in respective DISubprogram) and array_type. llvm-svn: 63209
1 parent d815d8f commit 154b8cd

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,8 +1733,8 @@ class DwarfDebug : public Dwarf {
17331733

17341734
// Add source line info if available and TyDesc is not a forward
17351735
// declaration.
1736-
// FIXME - Enable this. if (!DTy.isForwardDecl())
1737-
// FIXME - Enable this. AddSourceLine(&Buffer, *DTy);
1736+
if (!DTy.isForwardDecl())
1737+
AddSourceLine(&Buffer, &DTy);
17381738
}
17391739

17401740
/// ConstructTypeDIE - Construct type DIE from DICompositeType.
@@ -1815,20 +1815,23 @@ class DwarfDebug : public Dwarf {
18151815
// Add name if not anonymous or intermediate type.
18161816
if (!Name.empty()) AddString(&Buffer, DW_AT_name, DW_FORM_string, Name);
18171817

1818-
// Add size if non-zero (derived types might be zero-sized.)
1819-
if (Size)
1820-
AddUInt(&Buffer, DW_AT_byte_size, 0, Size);
1821-
else {
1822-
// Add zero size if it is not a forward declaration.
1823-
if (CTy.isForwardDecl())
1824-
AddUInt(&Buffer, DW_AT_declaration, DW_FORM_flag, 1);
1825-
else
1826-
AddUInt(&Buffer, DW_AT_byte_size, 0, 0);
1818+
if (Tag == DW_TAG_enumeration_type || Tag == DW_TAG_structure_type
1819+
|| Tag == DW_TAG_union_type) {
1820+
// Add size if non-zero (derived types might be zero-sized.)
1821+
if (Size)
1822+
AddUInt(&Buffer, DW_AT_byte_size, 0, Size);
1823+
else {
1824+
// Add zero size if it is not a forward declaration.
1825+
if (CTy.isForwardDecl())
1826+
AddUInt(&Buffer, DW_AT_declaration, DW_FORM_flag, 1);
1827+
else
1828+
AddUInt(&Buffer, DW_AT_byte_size, 0, 0);
1829+
}
1830+
1831+
// Add source line info if available.
1832+
if (!CTy.isForwardDecl())
1833+
AddSourceLine(&Buffer, &CTy);
18271834
}
1828-
1829-
// Add source line info if available.
1830-
if (!CTy.isForwardDecl())
1831-
AddSourceLine(&Buffer, &CTy);
18321835
}
18331836

18341837
// ConstructSubrangeDIE - Construct subrange DIE from DISubrange.
@@ -1853,7 +1856,6 @@ class DwarfDebug : public Dwarf {
18531856
AddUInt(&Buffer, DW_AT_GNU_vector, DW_FORM_flag, 1);
18541857

18551858
DIArray Elements = CTy->getTypeArray();
1856-
AddType(DW_Unit, &Buffer, CTy->getTypeDerivedFrom());
18571859

18581860
// Construct an anonymous type for index type.
18591861
DIE IdxBuffer(DW_TAG_base_type);
@@ -1906,7 +1908,7 @@ class DwarfDebug : public Dwarf {
19061908

19071909
AddSourceLine(MemberDie, &DT);
19081910

1909-
AddUInt(MemberDie, DW_AT_bit_size, 0, DT.getSizeInBits());
1911+
// FIXME _ Handle bitfields
19101912
DIEBlock *Block = new DIEBlock();
19111913
AddUInt(Block, 0, DW_FORM_data1, DW_OP_plus_uconst);
19121914
AddUInt(Block, 0, DW_FORM_udata, DT.getOffsetInBits() >> 3);

llvm/test/DebugInfo/forwardDecl.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ target triple = "i386-apple-darwin9.6"
1818
@.str3 = internal constant [4 x i8] c"foo\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1]
1919
@llvm.dbg.variable = internal constant %llvm.dbg.variable.type { i32 393473, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), i8* getelementptr ([2 x i8]* @.str4, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 3, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=1]
2020
@.str4 = internal constant [2 x i8] c"x\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1]
21-
@llvm.dbg.derivedtype = internal constant %llvm.dbg.derivedtype.type { i32 393231, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* null, i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.compositetype.type* @llvm.dbg.compositetype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1]
21+
@llvm.dbg.derivedtype = internal constant %llvm.dbg.derivedtype.type { i32 393231, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.compositetype.type* @llvm.dbg.compositetype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1]
2222
@llvm.dbg.compositetype = internal constant %llvm.dbg.compositetype.type { i32 393235, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([3 x i8]* @.str5, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 1, i64 0, i64 8, i64 0, i32 4, { }* null, { }* bitcast ([0 x { }*]* @llvm.dbg.array to { }*) }, section "llvm.metadata" ; <%llvm.dbg.compositetype.type*> [#uses=1]
2323
@.str5 = internal constant [3 x i8] c"ST\00", section "llvm.metadata" ; <[3 x i8]*> [#uses=1]
2424
@llvm.dbg.array = internal constant [0 x { }*] zeroinitializer, section "llvm.metadata" ; <[0 x { }*]*> [#uses=1]

0 commit comments

Comments
 (0)