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

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 10:39:51 PST 2024


https://github.com/hiraditya updated https://github.com/llvm/llvm-project/pull/115104

>From d3eba098d6f0d7c1d3fdabee881b33f11462b23a Mon Sep 17 00:00:00 2001
From: AdityaK <hiraditya at msn.com>
Date: Wed, 13 Nov 2024 14:47:41 -0800
Subject: [PATCH] [LTO] Print conflicting operands between Src and Dest modules

---
 llvm/lib/Linker/IRMover.cpp               | 14 +++++++++-----
 llvm/test/LTO/X86/codemodel-3.ll          |  2 +-
 llvm/test/LTO/X86/largedatathreshold-3.ll |  2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

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"



More information about the llvm-commits mailing list