[llvm] r325427 - [DebugInfo] Removed assert on missing CountVarDIE

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 17 03:06:53 PST 2018


Author: s.desmalen
Date: Sat Feb 17 03:06:53 2018
New Revision: 325427

URL: http://llvm.org/viewvc/llvm-project?rev=325427&view=rev
Log:
[DebugInfo] Removed assert on missing CountVarDIE

Summary:
The assert for a DISubrange's CountVarDIE to be available fails
when the dbg.value() has been optimized away for any reason.
Having the assert for that is a little heavy, so instead removing
it now in favor of not generating the 'count' expression.

Addresses http://llvm.org/PR36263 .

Reviewers: aprantl, dblaikie, probinson

Reviewed By: aprantl

Subscribers: JDevlieghere, llvm-commits, dstenb

Differential Revision: https://reviews.llvm.org/D43387

Added:
    llvm/trunk/test/DebugInfo/Generic/disubrange_vla.ll
    llvm/trunk/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll
Removed:
    llvm/trunk/test/DebugInfo/Generic/disubrange.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=325427&r1=325426&r2=325427&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Sat Feb 17 03:06:53 2018
@@ -1382,14 +1382,9 @@ void DwarfUnit::constructSubrangeDIE(DIE
     addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound);
 
   if (auto *CV = SR->getCount().dyn_cast<DIVariable*>()) {
-    // 'finishVariableDefinition' that creates the types for a variable is
-    // always called _after_ the DIEs for variables are created.
-    auto *CountVarDIE = getDIE(CV);
-    assert(CountVarDIE && "DIE for count is not yet instantiated");
-    addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE);
+    if (auto *CountVarDIE = getDIE(CV))
+      addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE);
   } else if (Count != -1)
-    // FIXME: An unbounded array should reference the expression that defines
-    // the array.
     addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count);
 }
 

Removed: llvm/trunk/test/DebugInfo/Generic/disubrange.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/disubrange.ll?rev=325426&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Generic/disubrange.ll (original)
+++ llvm/trunk/test/DebugInfo/Generic/disubrange.ll (removed)
@@ -1,50 +0,0 @@
-; RUN: rm -rf %t %t2
-; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
-; RUN: llvm-dwarfdump -name=vla_expr %t > %t2
-; RUN: llvm-dwarfdump -verbose %t >> %t2
-; RUN: cat %t2 | FileCheck %s
-
-; This test runs llvm-dwarfdump twice:
-; - First to get the debug entry for 'vla_expr'.
-; - Second to check that this is the entry referenced in DW_AT_count.
-; This way the test does not depend on the order in which DW_TAG_variables
-; are emitted.
-
-; CHECK:       [[NODE:[0-9a-zA-Zx]+]]: DW_TAG_variable [4]
-; CHECK-NEXT:  DW_AT_name {{.*}} "vla_expr"
-; CHECK:       DW_AT_count [DW_FORM_ref4]  (cu + {{.*}} => {[[NODE]]})
-
-define void @foo(i32 %n) !dbg !7 {
-entry:
-  call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !12, metadata !19), !dbg !20
-  ret void, !dbg !21
-}
-
-declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5}
-!llvm.ident = !{!6}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.1", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
-!1 = !DIFile(filename: "vla.c", directory: "/path/to")
-!2 = !{}
-!3 = !{i32 2, !"Dwarf Version", i32 4}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = !{i32 1, !"wchar_size", i32 4}
-!6 = !{!"clang version 5.0.1"}
-!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 20, type: !8, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)
-!8 = !DISubroutineType(types: !9)
-!9 = !{null, !10}
-!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!11 = !{!12, !13, !15}
-!12 = !DILocalVariable(name: "n", arg: 1, scope: !7, file: !1, line: 20, type: !10)
-!13 = !DILocalVariable(name: "vla_expr", scope: !7, file: !1, line: 21, type: !14)
-!14 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
-!15 = !DILocalVariable(name: "vla", scope: !7, file: !1, line: 21, type: !16)
-!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, align: 32, elements: !17)
-!17 = !{!18, !18}
-!18 = !DISubrange(count: !13)
-!19 = !DIExpression()
-!20 = !DILocation(line: 20, column: 14, scope: !7)
-!21 = !DILocation(line: 22, column: 1, scope: !7)

Added: llvm/trunk/test/DebugInfo/Generic/disubrange_vla.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/disubrange_vla.ll?rev=325427&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Generic/disubrange_vla.ll (added)
+++ llvm/trunk/test/DebugInfo/Generic/disubrange_vla.ll Sat Feb 17 03:06:53 2018
@@ -0,0 +1,50 @@
+; RUN: rm -rf %t %t2
+; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
+; RUN: llvm-dwarfdump -name=vla_expr %t > %t2
+; RUN: llvm-dwarfdump -verbose %t >> %t2
+; RUN: cat %t2 | FileCheck %s
+
+; This test runs llvm-dwarfdump twice:
+; - First to get the debug entry for 'vla_expr'.
+; - Second to check that this is the entry referenced in DW_AT_count.
+; This way the test does not depend on the order in which DW_TAG_variables
+; are emitted.
+
+; CHECK:       [[NODE:[0-9a-zA-Zx]+]]: DW_TAG_variable [4]
+; CHECK-NEXT:  DW_AT_name {{.*}} "vla_expr"
+; CHECK:       DW_AT_count [DW_FORM_ref4]  (cu + {{.*}} => {[[NODE]]})
+
+define void @foo(i32 %n) !dbg !7 {
+entry:
+  call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !12, metadata !19), !dbg !20
+  ret void, !dbg !21
+}
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.1", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "vla.c", directory: "/path/to")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 5.0.1"}
+!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 20, type: !8, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null, !10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !{!12, !13, !15}
+!12 = !DILocalVariable(name: "n", arg: 1, scope: !7, file: !1, line: 20, type: !10)
+!13 = !DILocalVariable(name: "vla_expr", scope: !7, file: !1, line: 21, type: !14)
+!14 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
+!15 = !DILocalVariable(name: "vla", scope: !7, file: !1, line: 21, type: !16)
+!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, align: 32, elements: !17)
+!17 = !{!18, !18}
+!18 = !DISubrange(count: !13)
+!19 = !DIExpression()
+!20 = !DILocation(line: 20, column: 14, scope: !7)
+!21 = !DILocation(line: 22, column: 1, scope: !7)

Added: llvm/trunk/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll?rev=325427&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll (added)
+++ llvm/trunk/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll Sat Feb 17 03:06:53 2018
@@ -0,0 +1,48 @@
+; RUN: rm -rf %t %t2
+; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
+; RUN: llvm-dwarfdump -verbose -name=vla %t > %t2
+; RUN: llvm-dwarfdump -verbose %t >> %t2
+; RUN: cat %t2 | FileCheck %s
+
+; This test runs llvm-dwarfdump twice:
+; - First to get the debug entry for 'vla', to get the array type node.
+; - Second to check that the type entry does not contain a DW_AT_count.
+
+; CHECK:       DW_AT_type [DW_FORM_ref4]   (cu + {{.*}} => {[[NODE:0x[0-9a-z]+]]}
+; CHECK:       [[NODE]]: DW_TAG_array_type
+; CHECK:       DW_TAG_subrange_type
+; CHECK-NOT:   DW_AT_count
+; CHECK:       DW_TAG_subrange_type
+; CHECK-NOT:   DW_AT_count
+
+define void @foo(i32 %n) !dbg !7 {
+entry:
+  ret void, !dbg !21
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.1", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "vla.c", directory: "/path/to")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 5.0.1"}
+!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 20, type: !8, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null, !10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !{!12, !15}
+!12 = !DILocalVariable(name: "n", arg: 1, scope: !7, file: !1, line: 20, type: !10)
+!13 = !DILocalVariable(name: "vla_expr", scope: !7, file: !1, line: 21, type: !14)
+!14 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
+!15 = !DILocalVariable(name: "vla", scope: !7, file: !1, line: 21, type: !16)
+!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, align: 32, elements: !17)
+!17 = !{!18, !18}
+!18 = !DISubrange(count: !13)
+!19 = !DIExpression()
+!20 = !DILocation(line: 20, column: 14, scope: !7)
+!21 = !DILocation(line: 22, column: 1, scope: !7)




More information about the llvm-commits mailing list