[llvm] r344011 - llvm-link: Improve diagnostic for module-level metadata mismatch
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 8 18:17:28 PDT 2018
Author: dblaikie
Date: Mon Oct 8 18:17:27 2018
New Revision: 344011
URL: http://llvm.org/viewvc/llvm-project?rev=344011&view=rev
Log:
llvm-link: Improve diagnostic for module-level metadata mismatch
This might produce hard to read/illegible diagnostics for especially
weird/non-trivial module metadata but integers are about all we are
using these days, so seems more useful than not.
Patch based on work by Kristina Brooks - thanks!
Differential Revision: https://reviews.llvm.org/D52952
Added:
llvm/trunk/test/Linker/Inputs/metadata-mismatch-a.ll
llvm/trunk/test/Linker/Inputs/metadata-mismatch-b.ll
llvm/trunk/test/Linker/metadata-mismatch.test
Modified:
llvm/trunk/lib/Linker/IRMover.cpp
Modified: llvm/trunk/lib/Linker/IRMover.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=344011&r1=344010&r2=344011&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp (original)
+++ llvm/trunk/lib/Linker/IRMover.cpp Mon Oct 8 18:17:27 2018
@@ -1230,8 +1230,14 @@ Error IRLinker::linkModuleFlagsMetadata(
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");
+ std::string str;
+ raw_string_ostream(str)
+ << "linking module flags '" << ID->getString()
+ << "': IDs have conflicting values ('" << *SrcOp->getOperand(2)
+ << "' from " << SrcM->getModuleIdentifier() << " with '"
+ << *DstOp->getOperand(2) << "' from " << DstM.getModuleIdentifier()
+ << ')';
+ emitWarning(str);
}
continue;
}
Added: llvm/trunk/test/Linker/Inputs/metadata-mismatch-a.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/metadata-mismatch-a.ll?rev=344011&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/metadata-mismatch-a.ll (added)
+++ llvm/trunk/test/Linker/Inputs/metadata-mismatch-a.ll Mon Oct 8 18:17:27 2018
@@ -0,0 +1,3 @@
+
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"Dwarf Version", i32 4}
Added: llvm/trunk/test/Linker/Inputs/metadata-mismatch-b.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/metadata-mismatch-b.ll?rev=344011&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/metadata-mismatch-b.ll (added)
+++ llvm/trunk/test/Linker/Inputs/metadata-mismatch-b.ll Mon Oct 8 18:17:27 2018
@@ -0,0 +1,2 @@
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"Dwarf Version", i32 5}
Added: llvm/trunk/test/Linker/metadata-mismatch.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/metadata-mismatch.test?rev=344011&view=auto
==============================================================================
--- llvm/trunk/test/Linker/metadata-mismatch.test (added)
+++ llvm/trunk/test/Linker/metadata-mismatch.test Mon Oct 8 18:17:27 2018
@@ -0,0 +1,3 @@
+; RUN: llvm-link %p/Inputs/metadata-mismatch-a.ll %p/Inputs/metadata-mismatch-b.ll -S 2>&1 | FileCheck %s
+
+; CHECK: warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 5' from {{.*}}/metadata-mismatch-b.ll with 'i32 4' from llvm-link)
More information about the llvm-commits
mailing list