[clang] 6553dc3 - [NVPTX] Support the OpenCL generic addrspace feature by default (#137940)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 21 01:55:15 PDT 2025


Author: Fraser Cormack
Date: 2025-05-21T09:55:11+01:00
New Revision: 6553dc30b8e760ae8e11f6c1d635c34d0232e2c3

URL: https://github.com/llvm/llvm-project/commit/6553dc30b8e760ae8e11f6c1d635c34d0232e2c3
DIFF: https://github.com/llvm/llvm-project/commit/6553dc30b8e760ae8e11f6c1d635c34d0232e2c3.diff

LOG: [NVPTX] Support the OpenCL generic addrspace feature by default (#137940)

As best as I can see, all NVPTX architectures support the generic
address space.

I note there's a FIXME in the target's address space map about 'generic'
still having to be added to the target but we haven't observed any
issues with it downstream. The generic address space is mapped to the
same target address space as default/private (0), but this isn't
necessarily a problem for users.

Added: 
    

Modified: 
    clang/lib/Basic/Targets/NVPTX.h
    clang/test/Misc/nvptx.languageOptsOpenCL.cl

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index dc1ecc30980b7..fbb46001b0f90 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -170,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
     Opts["cl_khr_global_int32_extended_atomics"] = true;
     Opts["cl_khr_local_int32_base_atomics"] = true;
     Opts["cl_khr_local_int32_extended_atomics"] = true;
+
+    Opts["__opencl_c_generic_address_space"] = true;
   }
 
   const llvm::omp::GV &getGridValue() const override {

diff  --git a/clang/test/Misc/nvptx.languageOptsOpenCL.cl b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
index f479dddffb3ab..2610cfafc257b 100644
--- a/clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -132,3 +132,11 @@
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
 // expected-warning at -1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 300)
+#ifndef __opencl_c_generic_address_space
+#error "Missing __opencl_c_generic_address_space define"
+#else
+#error "Incorrect __opencl_c_generic_address_space define"
+#endif
+#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
+#endif


        


More information about the cfe-commits mailing list