https://github.com/elizabethandrews created 
https://github.com/llvm/llvm-project/pull/203569

These attributes were originally introduced as part of the SYCL upstreaming 
effort to enable improved performance for USM pointers on FPGA targets. 
However, subsequent evaluation indicates that they are not meaningfully used in 
practice. Additionally given the current shift in focus away from FPGAs in 
DPC++, these attributes no longer serve an active purpose. Their removal would 
simplify the codebase and reduce ongoing maintenance burden.

RFC: 
https://discourse.llvm.org/t/rfc-remove-opencl-global-device-and-opencl-global-host-address-space-attributes/90677

>From 1c79814d57c320c939617ca33a7b576a106e5376 Mon Sep 17 00:00:00 2001
From: Elizabeth Andrews <[email protected]>
Date: Fri, 12 Jun 2026 08:29:16 -0700
Subject: [PATCH] [clang][opencl][sycl] Deprecate opencl_global_device and
 opencl_global_host

These attributes were originally introduced as part of the SYCL upstreaming 
effort
to enable improved performance for USM pointers on FPGA targets. However, 
subsequent
evaluation indicates that they are not meaningfully used in practice. 
Additionally
given the current shift in focus away from FPGAs in DPC++, these attributes no 
longer
serve an active purpose. Their removal would simplify the codebase and reduce 
ongoing
maintenance burden.

RFC: 
https://discourse.llvm.org/t/rfc-remove-opencl-global-device-and-opencl-global-host-address-space-attributes/90677
---
 clang/include/clang/Basic/AttrDocs.td         |  2 ++
 .../clang/Basic/DiagnosticSemaKinds.td        |  3 +++
 clang/lib/Sema/SemaType.cpp                   |  9 +++++--
 .../address-spaces-conversions.cl             |  8 +++----
 clang/test/CodeGenOpenCL/address-spaces.cl    | 24 +++++++++----------
 .../CodeGenSYCL/address-space-conversions.cpp |  2 +-
 .../amd-address-space-conversions.cpp         |  2 +-
 .../cuda-address-space-conversions.cpp        |  2 +-
 .../usm-address-spaces-conversions.cl         | 12 +++++-----
 .../SemaSYCL/address-space-conversions.cpp    |  8 +++----
 10 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index dab778d4047aa..a85fbf3c583ba 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5187,6 +5187,8 @@ As ``global_device`` and ``global_host`` are a subset of
 ``global_device`` and ``global_host`` address spaces to
 ``__global/opencl_global`` address spaces (following ISO/IEC TR 18037 5.1.3
 "Address space nesting and rules for pointers").
+
+These attributes are deprecated and may be removed in a future version of 
Clang.
   }];
 }
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a3b575b7ee63a..b17b600521cc5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11863,6 +11863,9 @@ def err_opencl_type_not_found : Error<
   "%0 type %1 not found; include the base header with 
-finclude-default-header">;
 def warn_opencl_attr_deprecated_ignored : Warning <
   "%0 attribute is deprecated and ignored in %1">, InGroup<IgnoredAttributes>;
+def warn_deprecated_attribute : Warning<
+  "'%0' attribute is deprecated and may be removed in a future version of 
Clang">,
+  InGroup<DeprecatedAttributes>;
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index ea4a6fb208dc3..b1749eaaa484f 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -9111,8 +9111,6 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
       break;
     case ParsedAttr::AT_OpenCLPrivateAddressSpace:
     case ParsedAttr::AT_OpenCLGlobalAddressSpace:
-    case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
-    case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
     case ParsedAttr::AT_OpenCLLocalAddressSpace:
     case ParsedAttr::AT_OpenCLConstantAddressSpace:
     case ParsedAttr::AT_OpenCLGenericAddressSpace:
@@ -9120,6 +9118,13 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
       HandleAddressSpaceTypeAttribute(type, attr, state);
       attr.setUsedAsTypeAttr();
       break;
+    case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
+    case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
+      state.getSema().Diag(attr.getLoc(), diag::warn_deprecated_attribute)
+          << attr;
+      HandleAddressSpaceTypeAttribute(type, attr, state);
+      attr.setUsedAsTypeAttr();
+      break;
     case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
       HandleAddressSpaceTypeAttribute(type, attr, state);
       if (state.getDeclarator().getContext() == DeclaratorContext::Prototype) {
diff --git a/clang/test/CodeGenOpenCL/address-spaces-conversions.cl 
b/clang/test/CodeGenOpenCL/address-spaces-conversions.cl
index f3a22fe89eaeb..af0c40e1417b2 100644
--- a/clang/test/CodeGenOpenCL/address-spaces-conversions.cl
+++ b/clang/test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 
-ffake-address-space-map -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 
-ffake-address-space-map -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL2.0 
-emit-llvm -o - | FileCheck --check-prefix=CHECK-NOFAKE %s
-// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck 
--check-prefix=CHECK-NOFAKE %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 
-ffake-address-space-map -cl-std=CL2.0 -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 
-ffake-address-space-map -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL2.0 
-emit-llvm -o - -Wno-deprecated-attributes | FileCheck 
--check-prefix=CHECK-NOFAKE %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL3.0 
-cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck --check-prefix=CHECK-NOFAKE %s
 // When -ffake-address-space-map is not used, all addr space mapped to 0 for 
x86_64.
 
 // test that we generate address space casts everywhere we need conversions of
diff --git a/clang/test/CodeGenOpenCL/address-spaces.cl 
b/clang/test/CodeGenOpenCL/address-spaces.cl
index b9f01069fa26c..072ce8f922937 100644
--- a/clang/test/CodeGenOpenCL/address-spaces.cl
+++ b/clang/test/CodeGenOpenCL/address-spaces.cl
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,SPIR
-// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -cl-ext=-all -ffake-address-space-map 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
-// RUN: %clang_cc1 %s -O0 -cl-std=clc++2021 -cl-ext=-all 
-ffake-address-space-map -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,SPIR
-// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map 
-emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR
-// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -emit-llvm -o - | 
FileCheck --check-prefixes=CHECK,AMDGCN %s
-// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -cl-std=CL3.0 -emit-llvm 
-o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
-// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL2.0 
-emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN
-// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL3.0 
-emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN
-// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - | 
FileCheck --check-prefixes=CHECK,AMDGCN %s
-// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 -emit-llvm 
-o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
-// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -o - | FileCheck 
--check-prefixes=CHECK,AMDGCN %s
-// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -cl-std=CL3.0 -o - | 
FileCheck --check-prefixes=CHECK,AMDGCN %s
+// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck %s --check-prefixes=CHECK,SPIR
+// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -cl-ext=-all -ffake-address-space-map 
-emit-llvm -o - -Wno-deprecated-attributes | FileCheck %s 
--check-prefixes=CHECK,SPIR
+// RUN: %clang_cc1 %s -O0 -cl-std=clc++2021 -cl-ext=-all 
-ffake-address-space-map -emit-llvm -o - -Wno-deprecated-attributes | FileCheck 
%s --check-prefixes=CHECK,SPIR
+// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map 
-emit-llvm -o - -Wno-deprecated-attributes | FileCheck %s 
--check-prefixes=CL20,CL20SPIR
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck --check-prefixes=CHECK,AMDGCN %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-mesa3d -cl-std=CL3.0 -emit-llvm 
-o - -Wno-deprecated-attributes | FileCheck --check-prefixes=CHECK,AMDGCN %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL2.0 
-emit-llvm -o - -Wno-deprecated-attributes | FileCheck %s 
--check-prefixes=CL20,CL20AMDGCN
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL3.0 
-emit-llvm -o - -Wno-deprecated-attributes | FileCheck %s 
--check-prefixes=CL20,CL20AMDGCN
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck --check-prefixes=CHECK,AMDGCN %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 -emit-llvm 
-o - -Wno-deprecated-attributes | FileCheck --check-prefixes=CHECK,AMDGCN %s
+// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -o - 
-Wno-deprecated-attributes | FileCheck --check-prefixes=CHECK,AMDGCN %s
+// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -cl-std=CL3.0 -o - 
-Wno-deprecated-attributes | FileCheck --check-prefixes=CHECK,AMDGCN %s
 
 // SPIR: %struct.S = type { i32, i32, ptr }
 // CL20SPIR: %struct.S = type { i32, i32, ptr addrspace(4) }
diff --git a/clang/test/CodeGenSYCL/address-space-conversions.cpp 
b/clang/test/CodeGenSYCL/address-space-conversions.cpp
index 506a24fb4a3ba..138a920880161 100644
--- a/clang/test/CodeGenSYCL/address-space-conversions.cpp
+++ b/clang/test/CodeGenSYCL/address-space-conversions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes 
-emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck %s
 void bar(int &Data) {}
 // CHECK-DAG: define{{.*}} void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr addrspace(4) 
noundef align 4 dereferenceable(4) %
 void bar2(int &Data) {}
diff --git a/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp 
b/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp
index 17a98195318ad..beb675e75e5a2 100644
--- a/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp
+++ b/clang/test/CodeGenSYCL/amd-address-space-conversions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsycl-is-device 
-disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsycl-is-device 
-disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck 
%s
 void bar(int &Data) {}
 // CHECK-DAG: define {{.*}} void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr noundef 
nonnull align 4 dereferenceable(4) %
 void bar2(int &Data) {}
diff --git a/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp 
b/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp
index ffb601e62c118..ca3b7eca7cb4f 100644
--- a/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp
+++ b/clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsycl-is-device 
-disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsycl-is-device 
-disable-llvm-passes -emit-llvm %s -o - -Wno-deprecated-attributes | FileCheck 
%s
 void bar(int &Data) {}
 // CHECK-DAG: define {{.*}} void @[[RAW_REF:[a-zA-Z0-9_]+]](ptr noundef 
nonnull align 4 dereferenceable(4) %
 void bar2(int &Data) {}
diff --git a/clang/test/SemaOpenCL/usm-address-spaces-conversions.cl 
b/clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
index 668b0db70d49e..8817e1ab42ee2 100644
--- a/clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
+++ b/clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
@@ -24,14 +24,14 @@
 #endif // CONSTANT
 
 void test(AS_COMP int *arg_comp,
-          __attribute__((opencl_global_device)) int *arg_device,
-          __attribute__((opencl_global_host)) int *arg_host) {
+          __attribute__((opencl_global_device)) int *arg_device, // 
expected-warning {{''opencl_global_device'' attribute is deprecated}}
+          __attribute__((opencl_global_host)) int *arg_host) { // 
expected-warning {{''opencl_global_host'' attribute is deprecated}}
   AS_COMP int *var_glob1 = arg_device;
   AS_COMP int *var_glob2 = arg_host;
   AS_COMP int *var_glob3 = (AS_COMP int *)arg_device;
   AS_COMP int *var_glob4 = (AS_COMP int *)arg_host;
-  arg_device = (__attribute__((opencl_global_device)) int *)arg_comp;
-  arg_host = (__attribute__((opencl_global_host)) int *)arg_comp;
+  arg_device = (__attribute__((opencl_global_device)) int *)arg_comp; // 
expected-warning {{''opencl_global_device'' attribute is deprecated}}
+  arg_host = (__attribute__((opencl_global_host)) int *)arg_comp; // 
expected-warning {{''opencl_global_host'' attribute is deprecated}}
 #ifdef GENERIC
   // expected-error@+6{{assigning '__generic int *__private' to 
'__global_device int *__private' changes address space of pointer}}
   // expected-error@+6{{assigning '__generic int *__private' to '__global_host 
int *__private' changes address space of pointer}}
@@ -61,7 +61,7 @@ void test(AS_COMP int *arg_comp,
   AS_INCOMP int *var_incomp1 = arg_device;
   AS_INCOMP int *var_incomp2 = arg_host;
   AS_INCOMP int *var_incomp3 =
-      (__attribute__((opencl_global_device)) int *)arg_device;
+      (__attribute__((opencl_global_device)) int *)arg_device; // 
expected-warning {{''opencl_global_device'' attribute is deprecated}}
   AS_INCOMP int *var_incomp4 =
-      (__attribute__((opencl_global_host)) int *)arg_host;
+      (__attribute__((opencl_global_host)) int *)arg_host; // expected-warning 
{{''opencl_global_host'' attribute is deprecated}}
 }
diff --git a/clang/test/SemaSYCL/address-space-conversions.cpp 
b/clang/test/SemaSYCL/address-space-conversions.cpp
index d8758248499de..e1a078338d523 100644
--- a/clang/test/SemaSYCL/address-space-conversions.cpp
+++ b/clang/test/SemaSYCL/address-space-conversions.cpp
@@ -65,16 +65,16 @@ void usages() {
   (void)i;
   (void)v;
 
-  __attribute__((opencl_global_host)) int *GLOB_HOST;
+  __attribute__((opencl_global_host)) int *GLOB_HOST; // expected-warning 
{{''opencl_global_host'' attribute is deprecated}}
   bar(*GLOB_HOST);
   bar2(*GLOB_HOST);
   GLOB = GLOB_HOST;
   GLOB_HOST = GLOB; // expected-error {{assigning '__global int *' to 
'__global_host int *' changes address space of pointer}}
-  GLOB_HOST = static_cast<__attribute__((opencl_global_host)) int *>(GLOB); // 
expected-error {{static_cast from '__global int *' to '__global_host int *' is 
not allowed}}
-  __attribute__((opencl_global_device)) int *GLOB_DEVICE;
+  GLOB_HOST = static_cast<__attribute__((opencl_global_host)) int *>(GLOB); // 
expected-warning {{''opencl_global_host'' attribute is deprecated}} 
expected-error {{static_cast from '__global int *' to '__global_host int *' is 
not allowed}}
+  __attribute__((opencl_global_device)) int *GLOB_DEVICE; // expected-warning 
{{''opencl_global_device'' attribute is deprecated}}
   bar(*GLOB_DEVICE);
   bar2(*GLOB_DEVICE);
   GLOB = GLOB_DEVICE;
   GLOB_DEVICE = GLOB; // expected-error {{assigning '__global int *' to 
'__global_device int *' changes address space of pointer}}
-  GLOB_DEVICE = static_cast<__attribute__((opencl_global_device)) int 
*>(GLOB); // expected-error {{static_cast from '__global int *' to 
'__global_device int *' is not allowed}}
+  GLOB_DEVICE = static_cast<__attribute__((opencl_global_device)) int 
*>(GLOB); // expected-warning {{''opencl_global_device'' attribute is 
deprecated}} expected-error {{static_cast from '__global int *' to 
'__global_device int *' is not allowed}}
 }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to