Index: lib/Target/AMDGPU/AMDGPUISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -1276,7 +1276,14 @@ GlobalAddressSDNode *G = cast(Op); const GlobalValue *GV = G->getGlobal(); - if (G->getAddressSpace() == AMDGPUASI.LOCAL_ADDRESS) { + if (G->getAddressSpace() == AMDGPUASI.LOCAL_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"); Index: test/CodeGen/AMDGPU/lds-global-non-entry-func.ll =================================================================== --- /dev/null +++ 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 +}