[PATCH] D82975: [DebugInfo] Allow GNU macro extension to be emitted

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 12:27:01 PDT 2020


dblaikie added a comment.

> This patch adds the extension behind a hidden LLVM flag, -use-gnu-debug-macro. If this can be landed, I would later want to enable it by default when tuning for GDB and targeting DWARF versions earlier than 5.

When you say 'by default' - do you mean by default when the user requests macro debug info (via -fdebug-macro) or by default without any extra flag?
& what does GCC do? Does it have a way to emit the standard debug_macinfo in v4 and below? Or does it always emit the debug_macro GNU extension?



================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2980
   Asm->OutStreamer->AddComment("Macro information version");
-  Asm->emitInt16(5);
+  Asm->emitInt16(DwarfVersion >= 5 ? DwarfVersion : 4);
   // We are setting Offset and line offset flags unconditionally here,
----------------
Is this correct/necessary? Does GCC produce a version 4 debug_macro section when emitting DWARFv3?


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:3088
+    unsigned DwarfVersion = getDwarfVersion();
+    auto FormToString = [DwarfVersion](unsigned Form) {
+      return dwarf::MacroString(Form, /*GNU=*/DwarfVersion < 5);
----------------
Use default ref capture `[&]` when a lambda doesn't escape its scope like this. (possibly inline the call to getDwarfVersion() even (& let default capture capture 'this'). I'd probably even inline the lambda into the call expression - but feel free to leave that aspect as-is, sinec it's already written that way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82975/new/

https://reviews.llvm.org/D82975





More information about the llvm-commits mailing list