[llvm] [AMDGPU] Suppress DataLayout warnings after recent change (PR #163644)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 15 14:43:38 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lto

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
Recent changes caused all AMDGPU toolchain programs to emit unhelpful
warnings since we linke a lot of external libraries. For now just accept
the old triple without warnings. We can probably remove this in the
future when these get updated.


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


3 Files Affected:

- (modified) llvm/lib/Linker/IRMover.cpp (+7) 
- (added) llvm/test/Linker/Inputs/legacy-amdgcn.ll (+2) 
- (added) llvm/test/Linker/amdgcn-triple.ll (+6) 


``````````diff
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 1bff6cd25156d..6b84fea4a4952 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1489,6 +1489,13 @@ Error IRLinker::run() {
                                   SrcTriple.getOSName() == "unknown");
     EnableTripleWarning = !SrcHasLibDeviceTriple;
     EnableDLWarning = !(SrcHasLibDeviceTriple && SrcHasLibDeviceDL);
+  } else if (SrcTriple.isAMDGPU() && DstTriple.isAMDGPU()) {
+    StringRef SrcDL = SrcM->getDataLayoutStr();
+    StringRef DstDL = DstM.getDataLayoutStr();
+
+    // Suppress the data layout warning if the old layout without ELF mangling
+    // specified is used.
+    EnableDLWarning = DstDL.drop_front(4) != SrcDL;
   }
 
   if (EnableDLWarning && (SrcM->getDataLayout() != DstM.getDataLayout())) {
diff --git a/llvm/test/Linker/Inputs/legacy-amdgcn.ll b/llvm/test/Linker/Inputs/legacy-amdgcn.ll
new file mode 100644
index 0000000000000..19d622d5f887f
--- /dev/null
+++ b/llvm/test/Linker/Inputs/legacy-amdgcn.ll
@@ -0,0 +1,2 @@
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
diff --git a/llvm/test/Linker/amdgcn-triple.ll b/llvm/test/Linker/amdgcn-triple.ll
new file mode 100644
index 0000000000000..9244277d1a1b0
--- /dev/null
+++ b/llvm/test/Linker/amdgcn-triple.ll
@@ -0,0 +1,6 @@
+; RUN: llvm-link %s %S/Inputs/legacy-amdgcn.ll -S -o - 2>&1 | FileCheck %s
+
+; CHECK-NOT: Linking two modules of different data layouts
+; CHECK: target triple = "amdgcn-amd-amdhsa"
+target datalayout = "e-m:e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"

``````````

</details>


https://github.com/llvm/llvm-project/pull/163644


More information about the llvm-commits mailing list