[PATCH] D52952: [IR][Modules] Improve quality of diagnostic messages for non-fatal warnings during module linking.

Kristina Brooks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 5 15:20:11 PDT 2018


kristina created this revision.
kristina added reviewers: ruiu, echristo, pcc.
Herald added subscribers: llvm-commits, JDevlieghere, aprantl.

Currently when a non-fatal warning is emitted, linking of modules can typically continue, however, the user is flooded with non-helpful warnings that do not hint at the possible source of the warning. This is especially relevant when DWARFv4 and DWARFv5 modules are linked which can happen when migrating to newer debug info.

This produces a flurry of messages along the lines of:

  ld.lld: warning: linking module flags 'Dwarf Version': IDs have conflicting values
  ld.lld: warning: linking module flags 'Dwarf Version': IDs have conflicting values 
  ld.lld: warning: linking module flags 'Dwarf Version': IDs have conflicting values 

That kind of output is not especially helpful when trying to pinpoint the culprit source modules. This relatively simple patch improves the quality of non-fatal warnings from `IRMover` by emitting names of the source modules and in case of DWARF version mismatches, the mismatching versions (common case being 4 and 5).

That diagnostics code lack any test coverage and I can't think of a way to easily and deliberately produce mismatching modules using lit tests, and this diagnostic is not used as part of any current lit test in all of LLVM. Adding test coverage to all such diagnostics would be a much bigger task in itself and should likely be addressed separately since currently all of them lack any coverage.


Repository:
  rL LLVM

https://reviews.llvm.org/D52952

Files:
  lib/Linker/IRMover.cpp


Index: lib/Linker/IRMover.cpp
===================================================================
--- lib/Linker/IRMover.cpp
+++ lib/Linker/IRMover.cpp
@@ -1230,8 +1230,20 @@
     case Module::Warning: {
       // Emit a warning if the values differ.
       if (SrcOp->getOperand(2) != DstOp->getOperand(2)) {
-        emitWarning("linking module flags '" + ID->getString() +
-                    "': IDs have conflicting values");
+        StringRef IDS = ID->getString();
+        if (IDS == "Dwarf Version")
+          // For conflicting DWARF metadata, print the actual versions
+          // in addition to module names.
+          emitWarning("linking conflicting DWARF versions: v" +
+                      Twine(SrcM->getDwarfVersion()) +
+                      " from " + SrcM->getModuleIdentifier() + " to v" +
+                      Twine(DstM.getDwarfVersion()) + " in "+
+                      DstM.getModuleIdentifier());
+        else
+          emitWarning("linking module flags '" + IDS +
+                      "': IDs have conflicting values (from " +
+                      SrcM->getModuleIdentifier() + " to " +
+                      DstM.getModuleIdentifier() + ")");
       }
       continue;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52952.168538.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181005/6dabb497/attachment.bin>


More information about the llvm-commits mailing list