Skip to content

Commit 3ae54b6

Browse files
committed
fix review comments
1 parent 9398247 commit 3ae54b6

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
218218
for (auto *GV : GVs) {
219219
bool IsAbsolute = GV->isAbsoluteSymbolRef();
220220
bool IsDirectMapDynLDSGV = AMDGPU::isDynamicLDS(*GV) && DirectMapKernel.contains(Fn);
221+
if (IsDirectMapDynLDSGV)
222+
continue;
221223
if (HasAbsoluteGVs.has_value()) {
222-
if (*HasAbsoluteGVs != IsAbsolute ) {
223-
if(IsDirectMapDynLDSGV)
224-
continue;
224+
if (*HasAbsoluteGVs != IsAbsolute) {
225225
report_fatal_error(
226226
"Module cannot mix absolute and non-absolute LDS GVs");
227227
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -mtriple=amdgcn-- -amdgpu-lower-module-lds < %s 2>&1 | FileCheck %s
3+
; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s 2>&1 | FileCheck %s
4+
5+
; Dynamic LDS that are direct mapped are not lowered in LowerModuleLDS pass.
6+
; In such cases, LowerModuleLDS is free to leave it in and ignore it, and we want to make sure
7+
; LowerModuleLDS doesn't crash if it re-runs on such modules.
8+
9+
@loweredlds = addrspace(3) global i32 poison, !absolute_symbol !0
10+
@dynlds = external addrspace(3) global [0 x i32]
11+
12+
define amdgpu_kernel void @kern(i32 %val0) {
13+
; CHECK-LABEL: define amdgpu_kernel void @kern(
14+
; CHECK-SAME: i32 [[VAL0:%.*]]) {
15+
; CHECK-NEXT: store i32 0, ptr addrspace(3) @loweredlds, align 4
16+
; CHECK-NEXT: store i32 1, ptr addrspace(3) @dynlds, align 4
17+
; CHECK-NEXT: ret void
18+
;
19+
store i32 0, ptr addrspace(3) @loweredlds
20+
store i32 1, ptr addrspace(3) @dynlds
21+
ret void
22+
}
23+
24+
25+
!0 = !{i32 0, i32 1}

llvm/test/CodeGen/AMDGPU/lds-run-twice.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
; Check AMDGPULowerModuleLDS can run more than once on the same module, and that
88
; the second run is a no-op.
99

10+
@dynlds = external addrspace(3) global [0 x i32], align 4
1011
@lds = internal unnamed_addr addrspace(3) global i32 undef, align 4
1112

1213
define amdgpu_kernel void @test() {
1314
entry:
15+
store i32 0, ptr addrspace(3) @dynlds
1416
store i32 1, ptr addrspace(3) @lds
1517
ret void
1618
}

llvm/test/CodeGen/AMDGPU/lto-lower-module-lds.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@
3939
; CHECK: Lower uses of LDS variables from non-kernel functions
4040

4141
@lds = internal unnamed_addr addrspace(3) global i32 poison, align 4
42-
@dynlds = external addrspace(3) global [0 x i32]
42+
4343
define amdgpu_kernel void @test() {
4444
entry:
4545
store i32 1, ptr addrspace(3) @lds
46-
store i32 0, ptr addrspace(3) @dynlds
4746
ret void
4847
}

0 commit comments

Comments
 (0)