[llvm] [AMDGPU] Don't realign already allocated LDS. Point fix for 106412 (PR #106421)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 10:13:31 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Jon Chesterfield (JonChesterfield)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/106421.diff
2 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp (+5)
- (added) llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll (+15)
``````````diff
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..5acc5cefbbd9c6
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/lds-no-realign-allocated-variables.ll
@@ -0,0 +1,15 @@
+; RUN: opt -S -mtriple=amdgcn-- -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 undef, align 2, !absolute_symbol !0
+ at lds.dont_realign = internal addrspace(3) global i64 undef, 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}
``````````
</details>
https://github.com/llvm/llvm-project/pull/106421
More information about the llvm-commits
mailing list