[llvm] r340646 - DebugInfo: Fix skipping CUs in DWARFv5 debug_names table

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 13:31:05 PDT 2018


Author: dblaikie
Date: Fri Aug 24 13:31:05 2018
New Revision: 340646

URL: http://llvm.org/viewvc/llvm-project?rev=340646&view=rev
Log:
DebugInfo: Fix skipping CUs in DWARFv5 debug_names table

My previoust test case had skipped CUs from one TU out of a two-TU LTO
scenario, which meant the CU index wasn't needed (as it was unambiguous
which CU a table entry applied to) - expanding the test to use 3 TUs,
skipping one (so long as it's not the last one) shows the indexes are
miscomputed. Fix that with a little indirection for the index.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
    llvm/trunk/test/DebugInfo/X86/debug-names-partial.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp?rev=340646&r1=340645&r2=340646&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp Fri Aug 24 13:31:05 2018
@@ -554,10 +554,13 @@ void llvm::emitDWARF5AccelTable(
     AsmPrinter *Asm, AccelTable<DWARF5AccelTableData> &Contents,
     const DwarfDebug &DD, ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs) {
   std::vector<MCSymbol *> CompUnits;
+  SmallVector<unsigned, 1> CUIndex(CUs.size());
+  int Count = 0;
   for (const auto &CU : enumerate(CUs)) {
     if (CU.value()->getCUNode()->getNameTableKind() ==
         DICompileUnit::DebugNameTableKind::None)
       continue;
+    CUIndex[CU.index()] = Count++;
     assert(CU.index() == CU.value()->getUniqueID());
     const DwarfCompileUnit *MainCU =
         DD.useSplitDwarf() ? CU.value()->getSkeleton() : CU.value().get();
@@ -573,9 +576,9 @@ void llvm::emitDWARF5AccelTable(
   Contents.finalize(Asm, "names");
   Dwarf5AccelTableWriter<DWARF5AccelTableData>(
       Asm, Contents, CompUnits,
-      [&DD](const DWARF5AccelTableData &Entry) {
+      [&](const DWARF5AccelTableData &Entry) {
         const DIE *CUDie = Entry.getDie().getUnitDie();
-        return DD.lookupCU(CUDie)->getUniqueID();
+        return CUIndex[DD.lookupCU(CUDie)->getUniqueID()];
       })
       .emit();
 }

Modified: llvm/trunk/test/DebugInfo/X86/debug-names-partial.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-names-partial.ll?rev=340646&r1=340645&r2=340646&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/debug-names-partial.ll (original)
+++ llvm/trunk/test/DebugInfo/X86/debug-names-partial.ll Fri Aug 24 13:31:05 2018
@@ -2,45 +2,63 @@
 
 ; Verify that DWARF v5 debug_names omit names from CUs that opt-out.
 ; RUN: llc -mtriple x86_64-pc-linux -filetype=obj < %s \
-; RUN:   | llvm-dwarfdump -debug-names - | FileCheck %s
+; RUN:   | llvm-dwarfdump -debug-info -debug-names - | FileCheck %s
 
-; CHECK: CU count: 1
 
 ; Check that the one CU that is indexed has a non-zero.
 ; Avoid checking for a specific offset to make the test more resilient.
+; CHECK: [[CU1OFF:0x00000000]]: Compile Unit:
+; CHECK: [[CU2OFF:0x[0-9a-f]{8}]]: Compile Unit:
+; CHECK: [[CU3OFF:0x[0-9a-f]{8}]]: Compile Unit:
+
+; CHECK: CU count: 2
 ; CHECK: Compilation Unit offsets [
-; CHECK-NEXT: CU[0]: 0x{{[0-9]*[1-9][0-9]*}}
+; CHECK-NEXT: CU[0]: [[CU1OFF]]
+; CHECK-NEXT: CU[1]: [[CU3OFF]]
 ; CHECK-NEXT: ]
+; CHECK-NOT: DW_IDX_compile_unit: 0x02
+; CHECK: String: {{.*}} "f3"
+; CHECK-NOT: DW_IDX_compile_unit
+; CHECK: DW_IDX_compile_unit: 0x01
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @_Z2f1v() !dbg !11 {
+entry:
+  ret void, !dbg !14
+}
 
-define dso_local i32 @main() !dbg !9 {
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @_Z2f2v() !dbg !15 {
 entry:
-  ret i32 0, !dbg !13
+  ret void, !dbg !16
 }
 
-define dso_local void @_Z2f1v() !dbg !14 {
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @_Z2f3v() !dbg !17 {
 entry:
-  ret void, !dbg !17
+  ret void, !dbg !18
 }
 
-!llvm.dbg.cu = !{!0, !3}
-!llvm.ident = !{!5, !5}
-!llvm.module.flags = !{!6, !7, !8}
+!llvm.dbg.cu = !{!0, !3, !5}
+!llvm.ident = !{!7, !7, !7}
+!llvm.module.flags = !{!8, !9, !10}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 339438) (llvm/trunk 339448)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
-!1 = !DIFile(filename: "foo.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "f881137628fc8dd673b761eb7a1e2432")
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 340586) (llvm/trunk 340588)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: Default)
+!1 = !DIFile(filename: "f1.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "5cf4a85ae773dd04a42282b1a708a179")
 !2 = !{}
-!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 8.0.0 (trunk 339438) (llvm/trunk 339448)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
-!4 = !DIFile(filename: "bar.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "ba8dae3bceaf6ef87728337164565a87")
-!5 = !{!"clang version 8.0.0 (trunk 339438) (llvm/trunk 339448)"}
-!6 = !{i32 2, !"Dwarf Version", i32 5}
-!7 = !{i32 2, !"Debug Info Version", i32 3}
-!8 = !{i32 1, !"wchar_size", i32 4}
-!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
-!10 = !DISubroutineType(types: !11)
-!11 = !{!12}
-!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!13 = !DILocation(line: 1, column: 13, scope: !9)
-!14 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !4, file: !4, line: 1, type: !15, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2)
-!15 = !DISubroutineType(types: !16)
-!16 = !{null}
-!17 = !DILocation(line: 1, column: 12, scope: !14)
+!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 8.0.0 (trunk 340586) (llvm/trunk 340588)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!4 = !DIFile(filename: "f2.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "17efa328ddcbb22a3043feeec3190783")
+!5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "clang version 8.0.0 (trunk 340586) (llvm/trunk 340588)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: Default)
+!6 = !DIFile(filename: "f3.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch", checksumkind: CSK_MD5, checksum: "73ed062a3b287e0193c695c550d2cef2")
+!7 = !{!"clang version 8.0.0 (trunk 340586) (llvm/trunk 340588)"}
+!8 = !{i32 2, !"Dwarf Version", i32 5}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{i32 1, !"wchar_size", i32 4}
+!11 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !12, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
+!12 = !DISubroutineType(types: !13)
+!13 = !{null}
+!14 = !DILocation(line: 2, column: 1, scope: !11)
+!15 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !4, file: !4, line: 1, type: !12, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2)
+!16 = !DILocation(line: 2, column: 1, scope: !15)
+!17 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !6, file: !6, line: 1, type: !12, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !5, retainedNodes: !2)
+!18 = !DILocation(line: 2, column: 1, scope: !17)




More information about the llvm-commits mailing list