[PATCH] D104505: [HIP] Defer operator overloading errors
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 21 14:25:05 PDT 2021
yaxunl added a comment.
In D104505#2831555 <https://reviews.llvm.org/D104505#2831555>, @tra wrote:
> In NVCC's compilation only device-side compilation is aware of "semantics' of `__host__`/`__device__` attributes. HOST-side compilation is not aware of GPU existence. `cudafe++` massages the input source to create that fiction for the host compilation, but AFAICT, it does not care about semantics of what can be called from where but just strips deive-side code from the sources passed to the host compilation. Essentially, its diagnostics is limited to syntax errors. AFAICT, semantics is only checked by `cicc` during device-side compilation.
>
> So, in the end it may look that nvcc decided to ignore errors in device code, but in reality, host-side compilation is a regular GPU-unaware C++ compilation that does not see the code with the error.
That explains why nvcc does not allow overloaded functions differing only by `__host__` or `__device__` attributes, since they all become host functions in host compilations.
However, this does cause source level incompatibilities, i.e. CUDA code that passes nvcc does not pass clang. This patch somehow addresses that without compromising clang's more sophisticated `__host__/__device__` overloading resolution capabilities.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104505/new/
https://reviews.llvm.org/D104505
More information about the cfe-commits
mailing list