Author: elizabethandrews Date: 2026-06-25T10:36:23-04:00 New Revision: 84c42fe09e0521b565b938411f30397df663e2bc
URL: https://github.com/llvm/llvm-project/commit/84c42fe09e0521b565b938411f30397df663e2bc DIFF: https://github.com/llvm/llvm-project/commit/84c42fe09e0521b565b938411f30397df663e2bc.diff LOG: [clang][opencl][sycl] Deprecate opencl_global_device and opencl_global_host (#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 Added: Modified: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/AttrDocs.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaType.cpp clang/test/CodeGenOpenCL/address-spaces-conversions.cl clang/test/CodeGenOpenCL/address-spaces.cl clang/test/CodeGenSYCL/address-space-conversions.cpp clang/test/CodeGenSYCL/amd-address-space-conversions.cpp clang/test/CodeGenSYCL/cuda-address-space-conversions.cpp clang/test/SemaOpenCL/usm-address-spaces-conversions.cl clang/test/SemaSYCL/address-space-conversions.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d4c286644033b..a2439ccb0452a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -519,7 +519,11 @@ Attribute Changes in Clang about pointer lifetimes. It may be used to power optimizations in the future, however there are no concrete plans to do so at the moment. -* The ``modular_format`` attribute now supports the ``fixed`` aspect for C +- The attributes ``[[clang::opencl_global_device]]`` and ``[[clang::opencl_global_host]]`` + are now deprecated. Clang emits a ``-Wdeprecated-attributes`` warning when + they are used. + +- The ``modular_format`` attribute now supports the ``fixed`` aspect for C ISO 18037 fixed-point ``printf`` specifiers. Improvements to Clang's diagnostics diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 7c1c88241aaa8..d806adb4be4b8 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -5214,6 +5214,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 e3aa1c7bfeb5b..7e20630708312 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -11878,6 +11878,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 d2bb312feadc1..7d9fff1051068 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -9109,10 +9109,13 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, // it it breaks large amounts of Linux software. attr.setUsedAsTypeAttr(); break; - case ParsedAttr::AT_OpenCLPrivateAddressSpace: - case ParsedAttr::AT_OpenCLGlobalAddressSpace: case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace: case ParsedAttr::AT_OpenCLGlobalHostAddressSpace: + state.getSema().Diag(attr.getLoc(), diag::warn_deprecated_attribute) + << attr; + [[fallthrough]]; + case ParsedAttr::AT_OpenCLPrivateAddressSpace: + case ParsedAttr::AT_OpenCLGlobalAddressSpace: case ParsedAttr::AT_OpenCLLocalAddressSpace: case ParsedAttr::AT_OpenCLConstantAddressSpace: case ParsedAttr::AT_OpenCLGenericAddressSpace: 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
