Skip to content

Commit 1bde8e0

Browse files
[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.
1 parent b40677c commit 1bde8e0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,11 @@ class AMDGPULowerModuleLDS {
11311131
continue;
11321132
}
11331133

1134+
if (GV.isAbsoluteSymbolRef()) {
1135+
// If the variable is already allocated, don't change the alignment
1136+
continue;
1137+
}
1138+
11341139
Align Alignment = AMDGPU::getAlign(DL, &GV);
11351140
TypeSize GVSize = DL.getTypeAllocSize(GV.getValueType());
11361141

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s | FileCheck %s
2+
3+
; Can't have a second variable without absolute_symbol showing it is realigned as
4+
; there is a fatal error on mixing absolute and non-absolute symbols
5+
6+
; CHECK: @lds.dont_realign = internal addrspace(3) global i64 poison, align 2, !absolute_symbol !0
7+
@lds.dont_realign = internal addrspace(3) global i64 poison, align 2, !absolute_symbol !0
8+
9+
; CHECK: void @use_variables
10+
define amdgpu_kernel void @use_variables(i64 %val) {
11+
store i64 %val, ptr addrspace(3) @lds.dont_realign, align 2
12+
ret void
13+
}
14+
15+
!0 = !{i32 2, i32 3}

0 commit comments

Comments
 (0)