[llvm] 391bf06 - [LTO] Print conflicting operands between Src and Dest modules (#115104)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 10:07:43 PST 2024


Author: AdityaK
Date: 2024-11-21T10:07:39-08:00
New Revision: 391bf068f2c124e98e18bbc027f4cfc6f0b413d6

URL: https://github.com/llvm/llvm-project/commit/391bf068f2c124e98e18bbc027f4cfc6f0b413d6
DIFF: https://github.com/llvm/llvm-project/commit/391bf068f2c124e98e18bbc027f4cfc6f0b413d6.diff

LOG: [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
```

Added: 
    

Modified: 
    llvm/lib/Linker/IRMover.cpp
    llvm/test/LTO/X86/codemodel-3.ll
    llvm/test/LTO/X86/largedatathreshold-3.ll
    llvm/test/Linker/module-flags-6-a.ll
    llvm/test/Transforms/FunctionImport/module-flags.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 4bb0ddf891744b..a0c3f2c5b0baf6 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1430,11 +1430,15 @@ Error IRLinker::linkModuleFlagsMetadata() {
       llvm_unreachable("not possible");
     case Module::Error: {
       // Emit an error if the values 
diff er.
-      if (SrcOp->getOperand(2) != DstOp->getOperand(2))
-        return stringErr("linking module flags '" + ID->getString() +
-                         "': IDs have conflicting values in '" +
-                         SrcM->getModuleIdentifier() + "' and '" +
-                         DstM.getModuleIdentifier() + "'");
+      if (SrcOp->getOperand(2) != DstOp->getOperand(2)) {
+        std::string Str;
+        raw_string_ostream(Str)
+            << "linking module flags '" << ID->getString()
+            << "': IDs have conflicting values: '" << *SrcOp->getOperand(2)
+            << "' from " << SrcM->getModuleIdentifier() << ", and '"
+            << *DstOp->getOperand(2) << "' from " + DstM.getModuleIdentifier();
+        return stringErr(Str);
+      }
       continue;
     }
     case Module::Warning: {

diff  --git a/llvm/test/LTO/X86/codemodel-3.ll b/llvm/test/LTO/X86/codemodel-3.ll
index 13702dfbca2da4..8ae601c43cb29f 100644
--- a/llvm/test/LTO/X86/codemodel-3.ll
+++ b/llvm/test/LTO/X86/codemodel-3.ll
@@ -18,4 +18,4 @@ entry:
     ret ptr @data
 }
 
-; CHECK: 'Code Model': IDs have conflicting values
+; CHECK: 'Code Model': IDs have conflicting values: 'i32 1' from {{.*}}, and 'i32 4' from {{.*}}

diff  --git a/llvm/test/LTO/X86/largedatathreshold-3.ll b/llvm/test/LTO/X86/largedatathreshold-3.ll
index fea7987ff15566..496b71ea0ca005 100644
--- a/llvm/test/LTO/X86/largedatathreshold-3.ll
+++ b/llvm/test/LTO/X86/largedatathreshold-3.ll
@@ -3,7 +3,7 @@
 ; RUN: not llvm-lto2 run -r %t0.o,_start,px -r %t1.o,bar,px -r %t0.o,_GLOBAL_OFFSET_TABLE_, \
 ; RUN:   -r %t1.o,_GLOBAL_OFFSET_TABLE_, %t0.o %t1.o -o %t2.s 2>&1 | FileCheck %s
 
-; CHECK: 'Large Data Threshold': IDs have conflicting values
+; CHECK: 'Large Data Threshold': IDs have conflicting values: 'i32 101' from {{.*}}, and 'i32 100' from {{.*}}
 
 target triple = "x86_64-unknown-linux-gnu"
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

diff  --git a/llvm/test/Linker/module-flags-6-a.ll b/llvm/test/Linker/module-flags-6-a.ll
index dd6519727f241c..47f46d4d1889e8 100644
--- a/llvm/test/Linker/module-flags-6-a.ll
+++ b/llvm/test/Linker/module-flags-6-a.ll
@@ -2,7 +2,7 @@
 
 ; Test module flags error messages.
 
-; CHECK: linking module flags 'foo': IDs have conflicting values in '{{.*}}module-flags-6-b.ll' and 'llvm-link'
+; CHECK: linking module flags 'foo': IDs have conflicting values: 'i32 38' from {{.*}}module-flags-6-b.ll, and 'i32 37' from llvm-link
 
 !0 = !{ i32 1, !"foo", i32 37 }
 

diff  --git a/llvm/test/Transforms/FunctionImport/module-flags.ll b/llvm/test/Transforms/FunctionImport/module-flags.ll
index 662df3065b30f5..2fc2b8ea972754 100644
--- a/llvm/test/Transforms/FunctionImport/module-flags.ll
+++ b/llvm/test/Transforms/FunctionImport/module-flags.ll
@@ -4,7 +4,7 @@
 ; RUN: llvm-lto -thinlto -o 3 1.bc 2.bc
 ; RUN: opt -S -passes=function-import -summary-file 3.thinlto.bc 1.bc 2>&1 | FileCheck %s
 
-; CHECK: Function Import: link error: linking module flags 'Error': IDs have conflicting values in '2.bc' and '1.bc'
+; CHECK: Function Import: link error: linking module flags 'Error': IDs have conflicting values: 'i32 1' from 2.bc, and 'i32 0' from 1.bc
 
 ;--- 1.ll
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"


        


More information about the llvm-commits mailing list