[llvm] [AMDGPU] Don't realign already allocated LDS. Point fix for 106412 (PR #106421)
Jon Chesterfield via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 10:27:44 PDT 2024
https://github.com/JonChesterfield updated https://github.com/llvm/llvm-project/pull/106421
>From 2eed1ac9a0d2c5d35818e2f80d2ee386d986ff83 Mon Sep 17 00:00:00 2001
From: Jon Chesterfield <jonathanchesterfield at gmail.com>
Date: Wed, 28 Aug 2024 17:51:20 +0100
Subject: [PATCH] [AMDGPU] Don't realign already allocated LDS. Point fix for
106412
---
.../Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp | 5 +++++
.../AMDGPU/lds-no-realign-allocated-variables.ll | 15 +++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index 92b42e27a035eb..c96ce740ce026e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -1131,6 +1131,11 @@ class AMDGPULowerModuleLDS {
continue;
}
+ if (GV.isAbsoluteSymbolRef()) {
+ // If the variable is already allocated, don't change the alignment
+ continue;
+ }
+
Align Alignment = AMDGPU::getAlign(DL, &GV);
TypeSize GVSize = DL.getTypeAllocSize(GV.getValueType());
diff --git a/llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll b/llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll
new file mode 100644
index 00000000000000..86d2412e96a6bb
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll
@@ -0,0 +1,15 @@
+; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s | FileCheck %s
+
+; Can't have a second variable without absolute_symbol showing it is realigned as
+; there is a fatal error on mixing absolute and non-absolute symbols
+
+; CHECK: @lds.dont_realign = internal addrspace(3) global i64 poison, align 2, !absolute_symbol !0
+ at lds.dont_realign = internal addrspace(3) global i64 poison, align 2, !absolute_symbol !0
+
+; CHECK: void @use_variables
+define amdgpu_kernel void @use_variables(i64 %val) {
+ store i64 %val, ptr addrspace(3) @lds.dont_realign, align 2
+ ret void
+}
+
+!0 = !{i32 2, i32 3}
More information about the llvm-commits
mailing list