[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 09:57:47 PDT 2017


Anastasia added inline comments.


================
Comment at: lib/Sema/SemaType.cpp:6872
+      ImpAddr = LangAS::opencl_private;
+    else if (IsStatic)
+      ImpAddr = LangAS::opencl_global;
----------------
yaxunl wrote:
> Anastasia wrote:
> > I think we can't have this case for CL1.2 see s6.8. But I think it could happen for `extern` though.
> Right. I will remove setting implicit addr space for static var for CL1.2.
> 
> For extern var, for CL2.0 I will set implicit addr space to global.
> 
> However, for CL1.2 since only constant addr space is supported for file-scope var, I can only set the implicit addr space of an extern var to be constant. However I feel this may cause more confusion than convenience, therefore I will not set implicit addr space for extern var for CL1.2. If user does not use constant addr space with extern var explicitly, they will see diagnostics that extern var must have constant addr space. This is also the current behavior before my change.
Makes sense!


================
Comment at: test/SemaOpenCL/storageclass.cl:63
+  static float l_implicit_static_var = 0;          // expected-error {{variables in function scope cannot be declared static}}
+  static constant float l_constant_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
+  static global float l_global_static_var = 0;     // expected-error {{variables in function scope cannot be declared static}}
----------------
Does it make sense to put different address spaces here since this code is rejected earlier anyway?


https://reviews.llvm.org/D35082





More information about the cfe-commits mailing list