[PATCH] D45435: [CodeGen/AccelTable] Don't emit zero-CU name indexes

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 07:41:58 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL329575: [CodeGen/AccelTable] Don't emit zero-CU name indexes (authored by labath, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45435?vs=141616&id=141646#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45435

Files:
  llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
  llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/trunk/test/DebugInfo/Generic/debug-names-empty-cu.ll


Index: llvm/trunk/test/DebugInfo/Generic/debug-names-empty-cu.ll
===================================================================
--- llvm/trunk/test/DebugInfo/Generic/debug-names-empty-cu.ll
+++ llvm/trunk/test/DebugInfo/Generic/debug-names-empty-cu.ll
@@ -0,0 +1,19 @@
+; REQUIRES: object-emission
+; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
+; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
+; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
+
+; CHECK-NOT: CU count: 0
+; VERIFY: No errors.
+
+!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 7.0.0 (trunk 329543) (llvm/trunk 329551)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "-", directory: "/tmp")
+!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 7.0.0 (trunk 329543) (llvm/trunk 329551)"}
Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1468,6 +1468,10 @@
 }
 
 void DwarfDebug::emitAccelDebugNames() {
+  // Don't emit anything if we have no compilation units to index.
+  if (getUnits().empty())
+    return;
+
   Asm->OutStreamer->SwitchSection(
       Asm->getObjFileLowering().getDwarfDebugNamesSection());
   emitDWARF5AccelTable(Asm, AccelDebugNames, *this, getUnits());
Index: llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AccelTable.cpp
@@ -356,6 +356,8 @@
 
 void Dwarf5AccelTableEmitter::Header::emit(
     const Dwarf5AccelTableEmitter &Ctx) const {
+  assert(CompUnitCount > 0 && "Index must have at least one CU.");
+
   AsmPrinter *Asm = Ctx.Asm;
   Asm->OutStreamer->AddComment("Header: unit length");
   Asm->EmitLabelDifference(Ctx.ContributionEnd, Ctx.ContributionStart,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45435.141646.patch
Type: text/x-patch
Size: 2240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180409/4dcf9418/attachment.bin>


More information about the llvm-commits mailing list