[llvm] [AMDGPU] Suppress DataLayout warnings after recent change (PR #163644)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 15 14:43:05 PDT 2025
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/163644
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.
>From f4f613b8df9576956101225b1d97515d838b39a7 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 15 Oct 2025 16:41:11 -0500
Subject: [PATCH] [AMDGPU] Suppress DataLayout warnings after recent change
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.
---
llvm/lib/Linker/IRMover.cpp | 7 +++++++
llvm/test/Linker/Inputs/legacy-amdgcn.ll | 2 ++
llvm/test/Linker/amdgcn-triple.ll | 6 ++++++
3 files changed, 15 insertions(+)
create mode 100644 llvm/test/Linker/Inputs/legacy-amdgcn.ll
create mode 100644 llvm/test/Linker/amdgcn-triple.ll
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"
More information about the llvm-commits
mailing list