[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 10 06:33:49 PDT 2017


yaxunl marked an inline comment as done.
yaxunl added inline comments.


================
Comment at: lib/Sema/SemaDecl.cpp:10286
+          // these variables must be a compile time constant.
+          VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
         CheckForConstantInitializer(Init, DclT);
----------------
rjmccall wrote:
> Should this rule apply even in C++ mode?  I can't remember if there are any OpenCL/C++ hybrids.
No. This rule (static local variable needs to be initialised with compile-time constant) only applies to C and OpenCL. 
In C++ static local variable can be initialised with non-compile-time constant, in which case Clang will emit atomic instructions to make sure it is only initialised once.

Currently OpenCL 2.2 defines OpenCL C++ but clang does not support it.


https://reviews.llvm.org/D32977





More information about the cfe-commits mailing list