[PATCH] D47154: Try to make builtin address space declarations not useless

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 10:26:42 PDT 2018


yaxunl added a comment.

In https://reviews.llvm.org/D47154#1108813, @tra wrote:

> CUDA does not expose explicit AS on clang size. All pointers are treated as generic and we infer specific address space only in LLVM.
>  `__nvvm_atom_*_[sg]_*` builtins should probably be removed as they are indeed useless without pointers with explicit AS and NVCC itself does not have such builtins either.  Instead, we should convert the generic AS builtin to address-space specific instruction somewhere in LLVM.
>
> Using `attribute((address_space())` should probably produce an error during CUDA compilation.


Sometimes we need to call functions defined in our device library which is written in OpenCL. Some function have pointer arguments in non-zero address space. To declare these functions in CUDA/HIP we need to use `__attribute__((address_space()))`. We use C-style cast to cast pointers in CUDA/HIP to a non-zero address space and pass them to the functions. I think `__attribute__((address_space()))` is still needed for this situation.


https://reviews.llvm.org/D47154





More information about the cfe-commits mailing list