[PATCH] Option to suppress the DWARF entries DW_AT_MIPS_linkage_name and DW_AT_linkage_name.

David Blaikie dblaikie at gmail.com
Fri Sep 26 14:59:10 PDT 2014


================
Comment at: lib/CodeGen/AsmPrinter/DwarfUnit.cpp:45
@@ +44,3 @@
+static cl::opt<bool>
+SuppressLinkageNames("suppress-dwarf-linkage-names", cl::Hidden,
+                     cl::desc("Suppress the DWARF DW_AT_(MIPS_)?linkage_name entries"),
----------------
I believe we're trying to move away from surfacing command line flags in this way for user-facing features. (see Chris Bieneman's work).

I'm not sure what the right answner is these days - this could be a flag on the compile_unit metadata - in which case it could be properly respected under LTO (if one CU was built with the flag and one built without it, it'd be possible/practical/easy to respect those differences, emitting linkage name for one CU and omitting it in another).

================
Comment at: lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1470
@@ -1464,9 +1469,3 @@
 
-  // Add the linkage name if we have one and it isn't in the Decl.
-  StringRef LinkageName = SP.getLinkageName();
-  assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
-          LinkageName == DeclLinkageName) &&
-         "decl has a linkage name and it is different");
-  if (!LinkageName.empty() && DeclLinkageName.empty())
-    addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
-              GlobalValue::getRealLinkageName(LinkageName));
+  if (!SuppressLinkageNames) {
+    // Add the linkage name if we have one and it isn't in the Decl.
----------------
I'd consider sinking the condition down into line 1476 so that we still check the metadata invariants around linkage names, if they're present, even if we're not emitting them.

================
Comment at: test/DebugInfo/suppress-linkage-entry-3.ll:4
@@ +3,3 @@
+; RUN: %llc_dwarf -suppress-dwarf-linkage-names -dwarf-version=3 -O0 -filetype=obj < %s > %t
+; RUN: llvm-dwarfdump %t | FileCheck %s
+
----------------
I usually skip the temporary file and pipe the result of llc straight into llvm-dwarfdump (use '-' as the file name for llvm-dwarfdump to read standard input).

================
Comment at: test/DebugInfo/suppress-linkage-entry-4.ll:8
@@ +7,3 @@
+; The test checks whether the DWARF linkage name attributes are suppressed (DWARF 4).
+; The IR was generated with 'clang -gdwarf-4' from the following source:
+
----------------
What's the important distinction between this test and the previous one? It looks like we've only got one codepath so I'm not sure if we need two test cases.

http://reviews.llvm.org/D5510






More information about the llvm-commits mailing list