Skip to content

Commit 391bf06

Browse files
authored
[LTO] Print conflicting operands between Src and Dest modules (#115104)
The current error message doesn't give sufficient details to help with debugging. This patch will log the operand values that are conflicting. After this patch the output is of the form: ``` 'Large Data Threshold': IDs have conflicting values: 'i32 101' from /usr/local/home/llvm-project/build/test/LTO/X86/Output/largedatathreshold-3.ll.tmp1.o, and 'i32 100' from ld-temp.o ```
1 parent b22c3c1 commit 391bf06

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

llvm/lib/Linker/IRMover.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -1430,11 +1430,15 @@ Error IRLinker::linkModuleFlagsMetadata() {
14301430
llvm_unreachable("not possible");
14311431
case Module::Error: {
14321432
// Emit an error if the values differ.
1433-
if (SrcOp->getOperand(2) != DstOp->getOperand(2))
1434-
return stringErr("linking module flags '" + ID->getString() +
1435-
"': IDs have conflicting values in '" +
1436-
SrcM->getModuleIdentifier() + "' and '" +
1437-
DstM.getModuleIdentifier() + "'");
1433+
if (SrcOp->getOperand(2) != DstOp->getOperand(2)) {
1434+
std::string Str;
1435+
raw_string_ostream(Str)
1436+
<< "linking module flags '" << ID->getString()
1437+
<< "': IDs have conflicting values: '" << *SrcOp->getOperand(2)
1438+
<< "' from " << SrcM->getModuleIdentifier() << ", and '"
1439+
<< *DstOp->getOperand(2) << "' from " + DstM.getModuleIdentifier();
1440+
return stringErr(Str);
1441+
}
14381442
continue;
14391443
}
14401444
case Module::Warning: {

llvm/test/LTO/X86/codemodel-3.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ entry:
1818
ret ptr @data
1919
}
2020

21-
; CHECK: 'Code Model': IDs have conflicting values
21+
; CHECK: 'Code Model': IDs have conflicting values: 'i32 1' from {{.*}}, and 'i32 4' from {{.*}}

llvm/test/LTO/X86/largedatathreshold-3.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: not llvm-lto2 run -r %t0.o,_start,px -r %t1.o,bar,px -r %t0.o,_GLOBAL_OFFSET_TABLE_, \
44
; RUN: -r %t1.o,_GLOBAL_OFFSET_TABLE_, %t0.o %t1.o -o %t2.s 2>&1 | FileCheck %s
55

6-
; CHECK: 'Large Data Threshold': IDs have conflicting values
6+
; CHECK: 'Large Data Threshold': IDs have conflicting values: 'i32 101' from {{.*}}, and 'i32 100' from {{.*}}
77

88
target triple = "x86_64-unknown-linux-gnu"
99
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

llvm/test/Linker/module-flags-6-a.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
; Test module flags error messages.
44

5-
; CHECK: linking module flags 'foo': IDs have conflicting values in '{{.*}}module-flags-6-b.ll' and 'llvm-link'
5+
; CHECK: linking module flags 'foo': IDs have conflicting values: 'i32 38' from {{.*}}module-flags-6-b.ll, and 'i32 37' from llvm-link
66

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

llvm/test/Transforms/FunctionImport/module-flags.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; RUN: llvm-lto -thinlto -o 3 1.bc 2.bc
55
; RUN: opt -S -passes=function-import -summary-file 3.thinlto.bc 1.bc 2>&1 | FileCheck %s
66

7-
; CHECK: Function Import: link error: linking module flags 'Error': IDs have conflicting values in '2.bc' and '1.bc'
7+
; CHECK: Function Import: link error: linking module flags 'Error': IDs have conflicting values: 'i32 1' from 2.bc, and 'i32 0' from 1.bc
88

99
;--- 1.ll
1010
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

0 commit comments

Comments
 (0)