================
@@ -484,6 +484,88 @@ non-constexpr function, which is by default a host 
function.
 Users can override the inferred host and device attributes of default
 destructors by adding explicit host and device attributes to them.
 
+Deferred Diagnostics
+====================
+
+In HIP (and CUDA), a ``__host__ __device__`` function can be called from both
+host and device code. Certain operations are not allowed on the device (e.g.,
+calling a host-only function, using variable-length arrays, or throwing
+exceptions). However, a ``__host__ __device__`` function containing such
+operations is only ill-formed if it is actually called from device code.
+
+Clang handles this through *deferred diagnostics*: errors and warnings in
+``__host__ __device__`` functions are recorded during parsing but not emitted
+immediately. They are only emitted if the function turns out to be reachable
+from code that must run on the device.
+
+Device-Promoted Functions
----------------
Artem-B wrote:

Nit: IIt looks more of a `__host__ __device__` promotion to me, as that's what 
we do. The fact that makes the code usefun on the device is coincidental. If 
the default for unattributed functions would be `__device__` the same HD 
promotion would make them usable on the host. The promotion itself does not 
care from which side we end up calling the functions.
So while we technically add an implicit `__device__` attribute to an implicit 
`__host__` attribute, I think using HD in the nomenclature would better reflect 
what we're promoting the functions to, and that determines how they can be 
used. Using "device" makes a wrong impression that it's for device us only.

https://github.com/llvm/llvm-project/pull/185926
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to