diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp @@ -162,7 +162,8 @@ bool Changed = processUsedLDS(M); for (Function &F : M.functions()) { - if (!AMDGPU::isKernelCC(&F)) + // Only lower compute kernels' LDS. + if (!AMDGPU::isKernel(F.getCallingConv())) continue; Changed |= processUsedLDS(M, &F); } diff --git a/llvm/test/CodeGen/AMDGPU/lower-kernel-lds.ll b/llvm/test/CodeGen/AMDGPU/lower-kernel-lds.ll --- a/llvm/test/CodeGen/AMDGPU/lower-kernel-lds.ll +++ b/llvm/test/CodeGen/AMDGPU/lower-kernel-lds.ll @@ -12,6 +12,7 @@ ;. ; CHECK: @lds.size.8.align.8 = internal unnamed_addr addrspace(3) global [8 x i8] undef, align 8 +; CHECK: @lds.k2 = addrspace(3) global [1 x i8] undef, align 1 ; CHECK: @llvm.amdgcn.kernel.k0.lds = internal addrspace(3) global %llvm.amdgcn.kernel.k0.lds.t undef, align 16 ; CHECK: @llvm.amdgcn.kernel.k1.lds = internal addrspace(3) global %llvm.amdgcn.kernel.k1.lds.t undef, align 16 ;. @@ -63,3 +64,19 @@ ret void } + +; Do not lower LDS for graphics shaders. + +@lds.k2 = addrspace(3) global [1 x i8] undef, align 1 + +define amdgpu_ps void @k2() { +; CHECK-LABEL: @k2( +; CHECK-NEXT: %lds.k2.bc = bitcast [1 x i8] addrspace(3)* @lds.k2 to i8 addrspace(3)* +; CHECK-NEXT: store i8 1, i8 addrspace(3)* %lds.k2.bc, align 1 +; CHECK-NEXT: ret void +; + %lds.k2.bc = bitcast [1 x i8] addrspace(3)* @lds.k2 to i8 addrspace(3)* + store i8 1, i8 addrspace(3)* %lds.k2.bc, align 1 + + ret void +}