diff options
author | David Blaikie <dblaikie@gmail.com> | 2018-10-09 01:17:27 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2018-10-09 01:17:27 +0000 |
commit | ce7cfe00490f8abcccbd719c13dc57bc14d5ece8 (patch) | |
tree | 964b210dfdb8ce5a3efbe5ce256c6c6f12af66d1 | |
parent | 3f030a79e7f611c22138862ef6fc130baea8b9e5 (diff) |
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
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 10 | ||||
-rw-r--r-- | llvm/test/Linker/Inputs/metadata-mismatch-a.ll | 3 | ||||
-rw-r--r-- | llvm/test/Linker/Inputs/metadata-mismatch-b.ll | 2 | ||||
-rw-r--r-- | llvm/test/Linker/metadata-mismatch.test | 3 |
4 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 48b746a22fc..b304bfc401a 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -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; } diff --git a/llvm/test/Linker/Inputs/metadata-mismatch-a.ll b/llvm/test/Linker/Inputs/metadata-mismatch-a.ll new file mode 100644 index 00000000000..742ae5ca3ef --- /dev/null +++ b/llvm/test/Linker/Inputs/metadata-mismatch-a.ll @@ -0,0 +1,3 @@ + +!llvm.module.flags = !{!1} +!1 = !{i32 2, !"Dwarf Version", i32 4} diff --git a/llvm/test/Linker/Inputs/metadata-mismatch-b.ll b/llvm/test/Linker/Inputs/metadata-mismatch-b.ll new file mode 100644 index 00000000000..198c479c981 --- /dev/null +++ b/llvm/test/Linker/Inputs/metadata-mismatch-b.ll @@ -0,0 +1,2 @@ +!llvm.module.flags = !{!1} +!1 = !{i32 2, !"Dwarf Version", i32 5} diff --git a/llvm/test/Linker/metadata-mismatch.test b/llvm/test/Linker/metadata-mismatch.test new file mode 100644 index 00000000000..9767f8d2e4c --- /dev/null +++ b/llvm/test/Linker/metadata-mismatch.test @@ -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) |