[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 30 08:20:18 PDT 2017
yaxunl marked an inline comment as done.
yaxunl added inline comments.
================
Comment at: include/clang/AST/Type.h:336-342
+ /// Get the address space value used in diagnostics.
+ unsigned getAddressSpacePrintValue() const {
+ unsigned AS = getAddressSpace();
+ if (AS >= LangAS::target_first)
+ return AS - LangAS::target_first;
+ return AS;
+ }
----------------
yaxunl wrote:
> t-tye wrote:
> > Is this the right thing to do? This is making the CLANG named address spaces have the same numbers as the target-specific address space numbers which would seem rather confusing.
> >
> > What do the diagnostics want to display? For example, they could display the address space as a human readable form such as "Default", "OpenCL-global", CUDA-device", "target-specific(5)", etc. To do that this function could take an iostream and a LangAS value and use << to write to the iostream.
> This function is used by diagnostics for address spaces specified by `__attribute__((address_space(n)))`. There are several lit tests for that, e.g.
>
> https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-newdelete.cpp
> https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-references.cpp
>
> It is desirable to use the same value as specified by the attribute, otherwise it may confuse the user.
I can change it to
```
unsigned getAddressSpacePrintValue() const {
return getAddressSpace() - LangAS::target_first;
}
```
Since the value is only used for `__attribute__((address_space(n)))`, in case the user specifies negative value to achieve language specific addr space, the diag msg will just show the same negative value they used in `__attribute__((address_space(n)))`
https://reviews.llvm.org/D31404
More information about the cfe-commits
mailing list