[llvm] 1bde8e0 - [AMDGPU] Don't realign already allocated LDS. Point fix for 106412 (#106421)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 10:30:52 PDT 2024
Author: Jon Chesterfield
Date: 2024-08-28T18:30:48+01:00
New Revision: 1bde8e0b80860743fcd55da28f0ba9acb7a26a9c
URL: https://github.com/llvm/llvm-project/commit/1bde8e0b80860743fcd55da28f0ba9acb7a26a9c
DIFF: https://github.com/llvm/llvm-project/commit/1bde8e0b80860743fcd55da28f0ba9acb7a26a9c.diff
LOG: [AMDGPU] Don't realign already allocated LDS. Point fix for 106412 (#106421)
Fixes 106412. The logic that skips the pass on already-lowered variables
doesn't cover the path that increases alignment of variables. If a
variable is allocated at 24 and then given 16 byte alignment, the
backend notices and fatal-errors on the inconsistency.
Added:
llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll
Modified:
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index 92b42e27a035eb..38f0b6dda1997b 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