[llvm] 9418c40 - [amdgpu][lds] Raise an explicit unimplemented error on absolute address LDS variables

Jon Chesterfield via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 03:32:26 PDT 2023


Author: Jon Chesterfield
Date: 2023-07-13T11:32:03+01:00
New Revision: 9418c40af7ec6913112b82d6f1d6e8a8c43af6c0

URL: https://github.com/llvm/llvm-project/commit/9418c40af7ec6913112b82d6f1d6e8a8c43af6c0
DIFF: https://github.com/llvm/llvm-project/commit/9418c40af7ec6913112b82d6f1d6e8a8c43af6c0.diff

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

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 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.

Reviewed By: jmmartinez

Differential Revision: https://reviews.llvm.org/D155132

Added: 
    llvm/test/CodeGen/AMDGPU/lds-reject-absolute-addresses.ll

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index 4cd138e3f6fbce..0c9a44bce502df 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -354,6 +354,11 @@ class AMDGPULowerModuleLDS : public ModulePass {
         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();

diff  --git a/llvm/test/CodeGen/AMDGPU/lds-reject-absolute-addresses.ll b/llvm/test/CodeGen/AMDGPU/lds-reject-absolute-addresses.ll
new file mode 100644
index 00000000000000..753f4a8a06fe9f
--- /dev/null
+++ b/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}
+


        


More information about the llvm-commits mailing list