Skip to content

Conversation

@jmmartinez
Copy link
Contributor

@jmmartinez jmmartinez commented Oct 28, 2025

This tests show how type-checking is performed for __builtin_amdgcn_load_to_lds,
but not for __builtin_amdgcn_raw_ptr_buffer_load_lds, __builtin_amdgcn_struct_ptr_buffer_load_lds and __builtin_amdgcn_global_load_lds since they are declared with the 't'
attribute.

Stacked on top of: #165387

@jmmartinez jmmartinez force-pushed the users/jmmartinez/fix/load_lds_typesignature/2 branch from d70fd59 to 8d08a6e Compare October 28, 2025 13:23
@jmmartinez jmmartinez force-pushed the users/jmmartinez/fix/load_lds_typesignature/1 branch from dac020c to ed2f606 Compare October 28, 2025 13:23
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:AMDGPU labels Oct 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-amdgpu

Author: Juan Manuel Martinez Caamaño (jmmartinez)

Changes

[NFC][HIP] Add _builtin*_load_lds type check test cases

This tests show how typechecking is performed for
__builtin_amdgcn_load_to_lds, but not for
__builtin_amdgcn_raw_ptr_buffer_load_lds,
__builtin_amdgcn_struct_ptr_buffer_load_lds and
__builtin_amdgcn_global_load_lds since they are declared with the 't'
attribute.


Full diff: https://github.com/llvm/llvm-project/pull/165388.diff

1 Files Affected:

  • (modified) clang/test/SemaHIP/amdgpu-gfx950-load-to-lds.hip (+26-1)
diff --git a/clang/test/SemaHIP/amdgpu-gfx950-load-to-lds.hip b/clang/test/SemaHIP/amdgpu-gfx950-load-to-lds.hip
index b49c1866caa1c..ad8342b9fddb5 100644
--- a/clang/test/SemaHIP/amdgpu-gfx950-load-to-lds.hip
+++ b/clang/test/SemaHIP/amdgpu-gfx950-load-to-lds.hip
@@ -1,7 +1,6 @@
 // REQUIRES: amdgpu-registered-target
 // RUN: %clang_cc1 -fsyntax-only -triple amdgcn -target-cpu gfx950 -verify %s -fcuda-is-device
 // RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify %s
-// expected-no-diagnostics
 
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))
@@ -58,3 +57,29 @@ __global__ void i_am_kernel(void* src, __amdgpu_buffer_rsrc_t rsrc, __shared__ v
     __builtin_amdgcn_global_load_lds(src, dst, 12, 0 , 0);
     __builtin_amdgcn_global_load_lds(src, dst, 16, 0 , 0);
 }
+
+__device__ void i_am_wrong(void* src, __amdgpu_buffer_rsrc_t rsrc, __shared__ void* dst, int vindex, int voffset, int soffset) {
+    __builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 1, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 2, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 4, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 12, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_raw_ptr_buffer_load_lds(rsrc, dst, 16, voffset, soffset, 0, 0, 4);
+
+    __builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 1, vindex, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 2, vindex, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 4, vindex, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 12, vindex, voffset, soffset, 0, 0, 4);
+    __builtin_amdgcn_struct_ptr_buffer_load_lds(rsrc, dst, 16, vindex, voffset, soffset, 0, 0, 4);
+
+    __builtin_amdgcn_load_to_lds(src, dst, 1, 0, 0, 4); // expected-error{{too many arguments to function call}}
+    __builtin_amdgcn_load_to_lds(src, dst, 2, 0, 0, 4); // expected-error{{too many arguments to function call}}
+    __builtin_amdgcn_load_to_lds(src, dst, 4, 0, 0, 4); // expected-error{{too many arguments to function call}}
+    __builtin_amdgcn_load_to_lds(src, dst, 12, 0, 0, 4); // expected-error{{too many arguments to function call}}
+    __builtin_amdgcn_load_to_lds(src, dst, 16, 0, 0, 4); // expected-error{{too many arguments to function call}}
+
+    __builtin_amdgcn_global_load_lds(src, dst, 1, 0 , 0, 4);
+    __builtin_amdgcn_global_load_lds(src, dst, 2, 0 , 0, 4);
+    __builtin_amdgcn_global_load_lds(src, dst, 4, 0 , 0, 4);
+    __builtin_amdgcn_global_load_lds(src, dst, 12, 0 , 0, 4);
+    __builtin_amdgcn_global_load_lds(src, dst, 16, 0 , 0, 4);
+}

kraj pushed a commit to kraj/llvm-project that referenced this pull request Oct 28, 2025
This tests show how typechecking is performed for
__builtin_amdgcn_load_to_lds, but not for
__builtin_amdgcn_raw_ptr_buffer_load_lds,
__builtin_amdgcn_struct_ptr_buffer_load_lds and
__builtin_amdgcn_global_load_lds since they are declared with the 't'
attribute.

stack-info: PR: llvm#165388, branch: users/jmmartinez/fix/load_lds_typesignature/2
@jmmartinez jmmartinez force-pushed the users/jmmartinez/fix/load_lds_typesignature/1 branch 2 times, most recently from 011550b to cf96a53 Compare November 25, 2025 16:48
Base automatically changed from users/jmmartinez/fix/load_lds_typesignature/1 to main November 26, 2025 13:03
This tests show how typechecking is performed for
__builtin_amdgcn_load_to_lds, but not for
__builtin_amdgcn_raw_ptr_buffer_load_lds,
__builtin_amdgcn_struct_ptr_buffer_load_lds and
__builtin_amdgcn_global_load_lds since they are declared with the 't'
attribute.

stack-info: PR: #165388, branch: users/jmmartinez/fix/load_lds_typesignature/2
@jmmartinez jmmartinez force-pushed the users/jmmartinez/fix/load_lds_typesignature/2 branch from 8d08a6e to 13ee271 Compare November 26, 2025 13:08
@jmmartinez jmmartinez merged commit c28c99f into main Nov 27, 2025
10 checks passed
@jmmartinez jmmartinez deleted the users/jmmartinez/fix/load_lds_typesignature/2 branch November 27, 2025 09:38
jmmartinez added a commit that referenced this pull request Nov 28, 2025
)

Allows for type checking depending on the builtin signature.

Stacked on top of: #165387 and
#165388
aahrun pushed a commit to aahrun/llvm-project that referenced this pull request Dec 1, 2025
…#165389)

Allows for type checking depending on the builtin signature.

Stacked on top of: llvm#165387 and
llvm#165388
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Dec 1, 2025
…ltins (#165389)

Allows for type checking depending on the builtin signature.

Stacked on top of: llvm/llvm-project#165387 and
llvm/llvm-project#165388
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Dec 3, 2025
This tests show how type-checking is performed for
`__builtin_amdgcn_load_to_lds`,
but not for `__builtin_amdgcn_raw_ptr_buffer_load_lds`,
`__builtin_amdgcn_struct_ptr_buffer_load_lds` and
`__builtin_amdgcn_global_load_lds` since they are declared with the 't'
attribute.


Stacked on top of: llvm#165387
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Dec 3, 2025
…#165389)

Allows for type checking depending on the builtin signature.

Stacked on top of: llvm#165387 and
llvm#165388
kcloudy0717 pushed a commit to kcloudy0717/llvm-project that referenced this pull request Dec 4, 2025
This tests show how type-checking is performed for
`__builtin_amdgcn_load_to_lds`,
but not for `__builtin_amdgcn_raw_ptr_buffer_load_lds`,
`__builtin_amdgcn_struct_ptr_buffer_load_lds` and
`__builtin_amdgcn_global_load_lds` since they are declared with the 't'
attribute.


Stacked on top of: llvm#165387
kcloudy0717 pushed a commit to kcloudy0717/llvm-project that referenced this pull request Dec 4, 2025
…#165389)

Allows for type checking depending on the builtin signature.

Stacked on top of: llvm#165387 and
llvm#165388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AMDGPU clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants