[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:07 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.
+
+The following examples demonstrate the use of this attribute:
+
+.. code-block:: c++
+
+[[clang::sycl_external]] void Foo();
+
+[[clang::sycl_external]] void Bar() { /* ... */ }
+
+[[clang::sycl_external]] extern void Baz();
+
+[[nodiscard]] [[clang::sycl_external]] void Important();
+
+[[clang::sycl_external]] [[nodiscard]] void AlsoImportant();
----------------
tahonermann wrote:
I see these examples were extracted from section 5.10.1 of the SYCL 2020 specification. Some of these are intended to illustrate that the `SYCL_EXTERNAL` macro can be interleaved with C++ attributes. I don't think we need to illustrate that here since the semantics of `sycl_external` are independent of other attributes.
https://github.com/llvm/llvm-project/pull/140282
More information about the cfe-commits
mailing list