[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)
Tom Honermann via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 16 07:01:06 PDT 2025
================
@@ -476,6 +476,31 @@ The SYCL kernel in the previous code sample meets these expectations.
}];
}
+def SYCLExternalDocs : Documentation {
+ let Category = DocCatFunction;
+ let Heading = "sycl_external";
+ let Content = [{
+The ``sycl_external`` attribute can only be applied to external functions, and
+indicates that the function must be treated as a device function and must be
+emitted even if it has no direct uses from other device functions.
----------------
tahonermann wrote:
I think some additional details would be helpful.
```suggestion
The ``sycl_external`` attribute indicates that a function defined in another
translation unit may be called by a device function defined in the current
translation unit or, if defined in the current translation unit, the function
may be called by device functions defined in other translation units.
The attribute is intended for use in the implementation of the ``SYCL_EXTERNAL``
macro as specified in section 5.10.1, "SYCL functions and member functions
linkage", of the SYCL 2020 specification.
The attribute only appertains to functions and only those that meet the
following requirements.
* Has external linkage.
* Is not explicitly defined as deleted (the function may be an explicitly
defaulted function that is defined as deleted).
The attribute shall be present on the first declaration of a function and
may optionally be present on subsequent declarations.
When compiling for a SYCL device target that does not support the generic
address space, the function shall not specify a raw pointer or reference type
as the return type or as a parameter type.
See section 5.9, "Address-space deduction", of the SYCL 2020 specification.
```
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list