[PATCH] D155132: [amdgpu][lds] Raise an explicit unimplemented error on absolute address LDS variables

Jon Chesterfield via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 15:36:25 PDT 2023


JonChesterfield created this revision.
JonChesterfield added reviewers: arsenm, jmmartinez, jhuber6.
Herald added subscribers: foad, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
JonChesterfield requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

These aren't implemented. They could be at moderate implementation
complexity. Raising an error is better than silently miscompiling.

Patching now because the patch at D155125 <https://reviews.llvm.org/D155125> is a step towards using this metadata
more extensively as part of the lowering path and that will interact badly with
input variables with this annotation.

Lowering user defined variables at specific addresses would drop this error,
put them at the requested position in the frame during this pass, and then
use the same codegen that will be used for the kernel specific struct shortly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155132

Files:
  llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
  llvm/test/CodeGen/AMDGPU/lds-reject-absolute-addresses.ll


Index: llvm/test/CodeGen/AMDGPU/lds-reject-absolute-addresses.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/lds-reject-absolute-addresses.ll
@@ -0,0 +1,15 @@
+; RUN: not --crash opt -S -mtriple=amdgcn-- -amdgpu-lower-module-lds < %s 2>&1 | FileCheck %s
+; RUN: not --crash opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s 2>&1 | FileCheck %s
+
+ at var1 = addrspace(3) global i32 undef, !absolute_symbol !0
+
+; CHECK: LLVM ERROR: LDS variables with absolute addresses are unimplemented.
+define amdgpu_kernel void @kern() {
+  %val0 = load i32, ptr addrspace(3) @var1
+  %val1 = add i32 %val0, 4
+  store i32 %val1, ptr addrspace(3) @var1
+  ret void
+}
+
+!0 = !{i64 0, i64 1}
+
Index: llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -354,6 +354,11 @@
         continue;
       }
 
+      if (GV.isAbsoluteSymbolRef()) {
+        report_fatal_error(
+            "LDS variables with absolute addresses are unimplemented.");
+      }
+
       for (User *V : GV.users()) {
         if (auto *I = dyn_cast<Instruction>(V)) {
           Function *F = I->getFunction();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155132.539773.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230712/ffaf6209/attachment.bin>


More information about the llvm-commits mailing list