[PATCH] D47900: AMDGPU: Error on LDS global address in functions
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 7 12:18:38 PDT 2018
arsenm created this revision.
arsenm added reviewers: rampitec, t-tye, kzhuravl.
Herald added subscribers: tpr, dstuttard, yaxunl, nhaehnle, wdng.
These won't work as expected now, so error on them to avoid
wasting time debugging this in the future.
Not sure what the best terminology to use in the error message is
https://reviews.llvm.org/D47900
Files:
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
test/CodeGen/AMDGPU/lds-global-non-entry-func.ll
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
+
+ at lds = internal addrspace(3) global float undef, align 4
+
+; CHECK: error: <unknown>: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
+}
Index: lib/Target/AMDGPU/AMDGPUISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -1276,7 +1276,14 @@
GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(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");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47900.150382.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180607/1e3f5664/attachment.bin>
More information about the llvm-commits
mailing list