[clang] [Clang][HIP][CUDA] Validate that variable type fits in address spaces (PR #178909)
Steffen Larsen via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 30 07:56:44 PST 2026
================
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -triple amdgcn -target-cpu gfx90a -verify %s -fcuda-is-device
+
+#define __global__ __attribute__((global))
+#define __device__ __attribute__((device))
+#define __shared__ __attribute__((shared))
+
+__shared__ short global_arr[2147483647]; // expected-error {{'short[2147483647]' is too large for the address space (maximum allowed size of 4'294'967'295 bytes)}}
+
+__device__ void func() {
+ __shared__ int arr[1073741823]; // expected-error {{'int[1073741823]' is too large for the address space (maximum allowed size of 4'294'967'295 bytes)}}
+}
+
+__global__ void kernel() {
+ __shared__ char arr[4294967295]; // expected-error {{'char[4294967295]' is too large for the address space (maximum allowed size of 4'294'967'295 bytes)}}
+}
+
+// TODO: The implementation of the __shared__ attribute doesn't check the
+// instantiation of dependent variables.
----------------
steffenlarsen wrote:
If preferred, I can do the investigation and fix for this in this patch.
https://github.com/llvm/llvm-project/pull/178909
More information about the cfe-commits
mailing list