Skip to content

Commit

Permalink
[IRMover] Improve diagnostic messages for conflicting metadata
Browse files Browse the repository at this point in the history
This does the similar for error messages as rL344011 has done for warnings.

With llvm::lto::LTO, the error might appear when LTO::run() is executed.
In that case, the calling code cannot know which module causes the error
and, subsequently, cannot hint the user.

Differential Revision: https://reviews.llvm.org/D61880


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360857 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
igorkudrin committed May 16, 2019
1 parent 974b698 commit c41e268
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/Linker/IRMover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,9 @@ Error IRLinker::linkModuleFlagsMetadata() {
if (SrcBehaviorValue == Module::Override &&
SrcOp->getOperand(2) != DstOp->getOperand(2))
return stringErr("linking module flags '" + ID->getString() +
"': IDs have conflicting override values");
"': IDs have conflicting override values in '" +
SrcM->getModuleIdentifier() + "' and '" +
DstM.getModuleIdentifier() + "'");
continue;
} else if (SrcBehaviorValue == Module::Override) {
// Update the destination flag to that of the source.
Expand All @@ -1234,7 +1236,9 @@ Error IRLinker::linkModuleFlagsMetadata() {
// Diagnose inconsistent merge behavior types.
if (SrcBehaviorValue != DstBehaviorValue)
return stringErr("linking module flags '" + ID->getString() +
"': IDs have conflicting behaviors");
"': IDs have conflicting behaviors in '" +
SrcM->getModuleIdentifier() + "' and '" +
DstM.getModuleIdentifier() + "'");

auto replaceDstValue = [&](MDNode *New) {
Metadata *FlagOps[] = {DstOp->getOperand(0), ID, New};
Expand All @@ -1252,7 +1256,9 @@ Error IRLinker::linkModuleFlagsMetadata() {
// Emit an error if the values differ.
if (SrcOp->getOperand(2) != DstOp->getOperand(2))
return stringErr("linking module flags '" + ID->getString() +
"': IDs have conflicting values");
"': IDs have conflicting values in '" +
SrcM->getModuleIdentifier() + "' and '" +
DstM.getModuleIdentifier() + "'");
continue;
}
case Module::Warning: {
Expand Down
2 changes: 1 addition & 1 deletion test/Linker/module-flags-5-a.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

; Test the 'override' error.

; CHECK: linking module flags 'foo': IDs have conflicting override values
; CHECK: linking module flags 'foo': IDs have conflicting override values in '{{.*}}module-flags-5-b.ll' and 'llvm-link'

!0 = !{ i32 4, !"foo", i32 927 }

Expand Down
2 changes: 1 addition & 1 deletion test/Linker/module-flags-6-a.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

; Test module flags error messages.

; CHECK: linking module flags 'foo': IDs have conflicting values
; CHECK: linking module flags 'foo': IDs have conflicting values in '{{.*}}module-flags-6-b.ll' and 'llvm-link'

!0 = !{ i32 1, !"foo", i32 37 }

Expand Down
2 changes: 1 addition & 1 deletion test/Linker/module-flags-7-a.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

; Test module flags error messages.

; CHECK: linking module flags 'foo': IDs have conflicting behaviors
; CHECK: linking module flags 'foo': IDs have conflicting behaviors in '{{.*}}module-flags-7-b.ll' and 'llvm-link'

!0 = !{ i32 1, !"foo", i32 37 }

Expand Down

0 comments on commit c41e268

Please sign in to comment.