From 0aedafefd12cbc1d260858e5024d33d0a74261c8 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 8 Jun 2018 08:05:54 +0000 Subject: [PATCH] AMDGPU: Error on LDS global address in functions These won't work as expected now, so error on them to avoid wasting time debugging this in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334269 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 10 +++++++++- test/CodeGen/AMDGPU/lds-global-non-entry-func.ll | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/AMDGPU/lds-global-non-entry-func.ll diff --git a/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/lib/Target/AMDGPU/AMDGPUISelLowering.cpp index bc888dad67b..81d1b4abfa3 100644 --- a/lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ b/lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -1272,7 +1272,15 @@ SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI, GlobalAddressSDNode *G = cast(Op); const GlobalValue *GV = G->getGlobal(); - if (G->getAddressSpace() == AMDGPUASI.LOCAL_ADDRESS) { + if (G->getAddressSpace() == AMDGPUASI.LOCAL_ADDRESS || + G->getAddressSpace() == AMDGPUASI.REGION_ADDRESS) { + if (!MFI->isEntryFunction()) { + const Function &Fn = DAG.getMachineFunction().getFunction(); + DiagnosticInfoUnsupported BadLDSDecl( + Fn, "local memory global used by non-kernel function", SDLoc(Op).getDebugLoc()); + DAG.getContext()->diagnose(BadLDSDecl); + } + // XXX: What does the value of G->getOffset() mean? assert(G->getOffset() == 0 && "Do not know what to do with an non-zero offset"); diff --git a/test/CodeGen/AMDGPU/lds-global-non-entry-func.ll b/test/CodeGen/AMDGPU/lds-global-non-entry-func.ll new file mode 100644 index 00000000000..d797466f068 --- /dev/null +++ b/test/CodeGen/AMDGPU/lds-global-non-entry-func.ll @@ -0,0 +1,9 @@ +; RUN: not llc -mtriple=amdgcn-amd-amdhsa -o /dev/null %s 2>&1 | FileCheck %s + +@lds = internal addrspace(3) global float undef, align 4 + +; CHECK: error: :0:0: in function func_use_lds_global void (): local memory global used by non-kernel function +define void @func_use_lds_global() { + store float 0.0, float addrspace(3)* @lds, align 4 + ret void +}