Skip to content

[LTO] Print conflicting operands between Src and Dest modules #115104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

hiraditya
Copy link
Collaborator

@hiraditya hiraditya commented Nov 6, 2024

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

Copy link

github-actions bot commented Nov 6, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@hiraditya hiraditya force-pushed the hiraditya-patch-1 branch 2 times, most recently from 78aad1c to d3eba09 Compare November 13, 2024 22:49
@hiraditya hiraditya marked this pull request as ready for review November 13, 2024 22:49
@llvmbot llvmbot added the LTO Link time optimization (regular/full LTO or ThinLTO) label Nov 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2024

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-lto

Author: AdityaK (hiraditya)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/115104.diff

3 Files Affected:

  • (modified) llvm/lib/Linker/IRMover.cpp (+9-5)
  • (modified) llvm/test/LTO/X86/codemodel-3.ll (+1-1)
  • (modified) llvm/test/LTO/X86/largedatathreshold-3.ll (+1-1)
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 0d54c534590ca9..f94b30801ab142 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1445,11 +1445,15 @@ Error IRLinker::linkModuleFlagsMetadata() {
       llvm_unreachable("not possible");
     case Module::Error: {
       // 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 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"

@hiraditya hiraditya changed the title [WIP-LTO] Print conflicting operands between Src and Dest modules [LTO] Print conflicting operands between Src and Dest modules Nov 13, 2024
@hiraditya hiraditya merged commit 391bf06 into llvm:main Nov 21, 2024
8 checks passed
@hiraditya hiraditya deleted the hiraditya-patch-1 branch November 21, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:transforms LTO Link time optimization (regular/full LTO or ThinLTO)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants