[llvm-commits] [llvm] r63077 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfWriter.cpp test/DebugInfo/forwardDecl.ll

Devang Patel dpatel at apple.com
Mon Jan 26 16:45:05 PST 2009


Author: dpatel
Date: Mon Jan 26 18:45:04 2009
New Revision: 63077

URL: http://llvm.org/viewvc/llvm-project?rev=63077&view=rev
Log:

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.


Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
    llvm/trunk/test/DebugInfo/forwardDecl.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=63077&r1=63076&r2=63077&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Mon Jan 26 18:45:04 2009
@@ -1733,8 +1733,8 @@
 
     // Add source line info if available and TyDesc is not a forward
     // declaration.
-    // FIXME - Enable this. if (!DTy.isForwardDecl())
-    // FIXME - Enable this.     AddSourceLine(&Buffer, *DTy);
+    if (!DTy.isForwardDecl())
+      AddSourceLine(&Buffer, &DTy);
   }
 
   /// ConstructTypeDIE - Construct type DIE from DICompositeType.
@@ -1815,20 +1815,23 @@
     // Add name if not anonymous or intermediate type.
     if (!Name.empty()) AddString(&Buffer, DW_AT_name, DW_FORM_string, Name);
 
-    // Add size if non-zero (derived types might be zero-sized.)
-    if (Size)
-      AddUInt(&Buffer, DW_AT_byte_size, 0, Size);
-    else {
-      // Add zero size if it is not a forward declaration.
-      if (CTy.isForwardDecl())
-        AddUInt(&Buffer, DW_AT_declaration, DW_FORM_flag, 1);
-      else
-        AddUInt(&Buffer, DW_AT_byte_size, 0, 0); 
+    if (Tag == DW_TAG_enumeration_type || Tag == DW_TAG_structure_type
+        || Tag == DW_TAG_union_type) {
+      // Add size if non-zero (derived types might be zero-sized.)
+      if (Size)
+        AddUInt(&Buffer, DW_AT_byte_size, 0, Size);
+      else {
+        // Add zero size if it is not a forward declaration.
+        if (CTy.isForwardDecl())
+          AddUInt(&Buffer, DW_AT_declaration, DW_FORM_flag, 1);
+        else
+          AddUInt(&Buffer, DW_AT_byte_size, 0, 0); 
+      }
+      
+      // Add source line info if available.
+      if (!CTy.isForwardDecl())
+        AddSourceLine(&Buffer, &CTy);
     }
-
-    // Add source line info if available.
-    if (!CTy.isForwardDecl())
-      AddSourceLine(&Buffer, &CTy);
   }
   
   // ConstructSubrangeDIE - Construct subrange DIE from DISubrange.
@@ -1853,7 +1856,6 @@
       AddUInt(&Buffer, DW_AT_GNU_vector, DW_FORM_flag, 1);
     
     DIArray Elements = CTy->getTypeArray();
-    AddType(DW_Unit, &Buffer, CTy->getTypeDerivedFrom());
 
     // Construct an anonymous type for index type.
     DIE IdxBuffer(DW_TAG_base_type);
@@ -1906,7 +1908,7 @@
 
     AddSourceLine(MemberDie, &DT);
 
-    AddUInt(MemberDie, DW_AT_bit_size, 0, DT.getSizeInBits());
+    // FIXME _ Handle bitfields
     DIEBlock *Block = new DIEBlock();
     AddUInt(Block, 0, DW_FORM_data1, DW_OP_plus_uconst);
     AddUInt(Block, 0, DW_FORM_udata, DT.getOffsetInBits() >> 3);

Modified: llvm/trunk/test/DebugInfo/forwardDecl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/forwardDecl.ll?rev=63077&r1=63076&r2=63077&view=diff

==============================================================================
--- llvm/trunk/test/DebugInfo/forwardDecl.ll (original)
+++ llvm/trunk/test/DebugInfo/forwardDecl.ll Mon Jan 26 18:45:04 2009
@@ -18,7 +18,7 @@
 @.str3 = internal constant [4 x i8] c"foo\00", section "llvm.metadata"		; <[4 x i8]*> [#uses=1]
 @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]
 @.str4 = internal constant [2 x i8] c"x\00", section "llvm.metadata"		; <[2 x i8]*> [#uses=1]
- at 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]
+ at 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]
 @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]
 @.str5 = internal constant [3 x i8] c"ST\00", section "llvm.metadata"		; <[3 x i8]*> [#uses=1]
 @llvm.dbg.array = internal constant [0 x { }*] zeroinitializer, section "llvm.metadata"		; <[0 x { }*]*> [#uses=1]





More information about the llvm-commits mailing list