[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
Fri Oct 6 05:06:42 PDT 2017


Anastasia added a comment.

In https://reviews.llvm.org/D35082#890162, @rjmccall wrote:

> Okay.  I think I see your point about why it would be better to have a canonical __private address space that is different from the implicit address space 0.  I assume this means that there should basically never be pointers, references, or l-values in address space 0 in OpenCL.


If you mean 0 is `private` address space then no. There can be private AS pointers. But if you mean 0 is no address space then this doesn't exist in OpenCL. I think the right design in the first place  would have been to keep address spaces in AST just as they are in the source code and add explicit address spaces to all types in IR instead. In this case absence of any address spaces in AST would signal implicit AS to be used. This would make some Sema checks a bit more complicated though, but the design would become a lot cleaner. Unfortunately I think it would not be worth doing this big change now.

> You will lose a significant amount of representational efficiency by doing this, but it's probably not overwhelming.
> 
> I know you aren't implementing OpenCL C++ yet, so most of the cases where temporaries are introduced aren't meaningful to you, but you will at least need to consider compound literals.  I suspect the right rule is that file-scope literals should be inferred as being in __global or __constant memory, depending on whether they're const, and local-scope literals should be inferred as __private.
> 
> I'll try to review your patch tomorrow.


https://reviews.llvm.org/D35082





More information about the cfe-commits mailing list