[OpenCL] Add LangAS::opencl_private to represent private address space in AST
Currently Clang uses default address space (0) to represent private address space for OpenCL
in AST. There are two issues with this:
Multiple address spaces including private address space cannot be diagnosed.
There is no mangling for default address space. For example, if private int* is emitted as
i32 addrspace(5)* in IR. It is supposed to be mangled as PUAS5i but it is mangled as
Pi instead.
This patch attempts to represent OpenCL private address space explicitly in AST. It adds
a new enum LangAS::opencl_private and adds it to the variable types which are implicitly
private:
automatic variables without address space qualifier
function parameter
pointee type without address space qualifier (OpenCL 1.2 and below)
Differential Revision: https://reviews.llvm.org/D35082
llvm-svn: 315668
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 52995a6..358f9cb 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -47,6 +47,7 @@
1, // opencl_global
3, // opencl_local
2, // opencl_constant
+ 0, // opencl_private
4, // opencl_generic
1, // cuda_device
2, // cuda_constant
@@ -58,6 +59,7 @@
1, // opencl_global
3, // opencl_local
2, // opencl_constant
+ 5, // opencl_private
0, // opencl_generic
1, // cuda_device
2, // cuda_constant
@@ -69,6 +71,7 @@
1, // opencl_global
3, // opencl_local
2, // opencl_constant
+ 0, // opencl_private
4, // opencl_generic
1, // cuda_device
2, // cuda_constant
@@ -80,6 +83,7 @@
1, // opencl_global
3, // opencl_local
2, // opencl_constant
+ 5, // opencl_private
0, // opencl_generic
1, // cuda_device
2, // cuda_constant
diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index b5c5764..a848707 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -28,6 +28,7 @@
1, // opencl_global
3, // opencl_local
4, // opencl_constant
+ 0, // opencl_private
// FIXME: generic has to be added to the target
0, // opencl_generic
1, // cuda_device
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 706449d..e64ad54 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -27,6 +27,7 @@
1, // opencl_global
3, // opencl_local
2, // opencl_constant
+ 0, // opencl_private
4, // opencl_generic
0, // cuda_device
0, // cuda_constant
diff --git a/clang/lib/Basic/Targets/TCE.h b/clang/lib/Basic/Targets/TCE.h
index 75f22ac..be43bed 100644
--- a/clang/lib/Basic/Targets/TCE.h
+++ b/clang/lib/Basic/Targets/TCE.h
@@ -35,6 +35,7 @@
3, // opencl_global
4, // opencl_local
5, // opencl_constant
+ 0, // opencl_private
// FIXME: generic has to be added to the target
0, // opencl_generic
0, // cuda_device