[PATCH] D53885: MachineModuleInfo: Initialize DbgInfoAvailable depending on debug_cus existing

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 30 17:56:56 PDT 2018


MatzeB updated this revision to Diff 171851.
MatzeB added a comment.
Herald added a subscriber: javed.absar.

- Use empty implementation from https://reviews.llvm.org/D53909
- Add a test (I wish writing minimal debug info tests was simpler than this...)


Repository:
  rL LLVM

https://reviews.llvm.org/D53885

Files:
  lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  lib/CodeGen/MachineModuleInfo.cpp
  test/CodeGen/AArch64/fast-isel-dbg.ll


Index: test/CodeGen/AArch64/fast-isel-dbg.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AArch64/fast-isel-dbg.ll
@@ -0,0 +1,27 @@
+; RUN: llc -o - %s -fast-isel -stop-before=expand-isel-pseudos | FileCheck %s
+; Make sure fast-isel produces DBG_VALUE instructions even if no debug printer
+; is scheduled because of -stop-before.
+target triple="aarch64--"
+
+!0 = !DIFile(filename: "fast-isel-dbg.ll", directory: "/")
+!1 = distinct !DICompileUnit(file: !0, language: DW_LANG_C, emissionKind: LineTablesOnly)
+!2 = distinct !DISubprogram(name: "func", unit: !1)
+!3 = !DILocation(line: 17, scope: !2)
+!4 = !DILocation(line: 42, scope: !2)
+!5 = !DILocalVariable(name: "a", arg: 1, scope: !2, file: !0, line: 17, type: !6)
+!6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+
+!llvm.dbg.cu = !{!1}
+!llvm.module.flags = !{!10, !11}
+!10 = !{i32 2, !"Dwarf Version", i32 4}
+!11 = !{i32 2, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: name: func
+; CHECK: DBG_VALUE
+define void @func(i32 %a) !dbg !2 {
+  call void @llvm.dbg.declare(metadata i32 %a, metadata !5, metadata !DIExpression()), !dbg !3
+  ret void
+}
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+attributes #1 = { nounwind readnone speculatable }
Index: lib/CodeGen/MachineModuleInfo.cpp
===================================================================
--- lib/CodeGen/MachineModuleInfo.cpp
+++ lib/CodeGen/MachineModuleInfo.cpp
@@ -206,10 +206,11 @@
 bool MachineModuleInfo::doInitialization(Module &M) {
   ObjFileMMI = nullptr;
   CurCallSite = 0;
-  DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false;
+  UsesVAFloatArgument = UsesMorestackAddr = false;
   HasSplitStack = HasNosplitStack = false;
   AddrLabelSymbols = nullptr;
   TheModule = &M;
+  DbgInfoAvailable = !empty(M.debug_compile_units());
   return false;
 }
 
Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -701,15 +701,18 @@
 void DwarfDebug::beginModule() {
   NamedRegionTimer T(DbgTimerName, DbgTimerDescription, DWARFGroupName,
                      DWARFGroupDescription, TimePassesIsEnabled);
-  if (DisableDebugInfoPrinting)
+  if (DisableDebugInfoPrinting) {
+    MMI->setDebugInfoAvailability(false);
     return;
+  }
 
   const Module *M = MMI->getModule();
 
   unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
                                        M->debug_compile_units_end());
   // Tell MMI whether we have debug info.
-  MMI->setDebugInfoAvailability(NumDebugCUs > 0);
+  assert(MMI->hasDebugInfo() == (NumDebugCUs > 0) &&
+         "DebugInfoAvailabilty initialized unexpectedly");
   SingleCU = NumDebugCUs == 1;
   DenseMap<DIGlobalVariable *, SmallVector<DwarfCompileUnit::GlobalExpr, 1>>
       GVMap;
Index: lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -117,6 +117,7 @@
   if (!MMI->getModule()->getNamedMetadata("llvm.dbg.cu") ||
       !AP->getObjFileLowering().getCOFFDebugSymbolsSection()) {
     Asm = nullptr;
+    MMI->setDebugInfoAvailability(false);
     return;
   }
   // Tell MMI that we have debug info.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53885.171851.patch
Type: text/x-patch
Size: 3433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181031/59bf50f3/attachment.bin>


More information about the llvm-commits mailing list