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

llvm-svn: 344011
This commit is contained in:
David Blaikie 2018-10-09 01:17:27 +00:00
parent 63a8b6c304
commit 40a64c4c08
4 changed files with 16 additions and 2 deletions

View File

@ -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;
}

View File

@ -0,0 +1,3 @@
!llvm.module.flags = !{!1}
!1 = !{i32 2, !"Dwarf Version", i32 4}

View File

@ -0,0 +1,2 @@
!llvm.module.flags = !{!1}
!1 = !{i32 2, !"Dwarf Version", i32 5}

View File

@ -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)