[clang] [SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute. (PR #152403)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 5 20:21:47 PST 2025


================
@@ -17,6 +17,21 @@
 using namespace clang;
 using namespace CodeGen;
 
+void CodeGenFunction::EmitSYCLKernelCallStmt(const SYCLKernelCallStmt &S) {
+  if (getLangOpts().SYCLIsDevice) {
+    // A sycl_kernel_entry_point attributed function is unlikely to be emitted
+    // during device compilation, but might be if it is ODR-used from device
+    // code that is emitted. In these cases, the function is emitted with an
+    // empty body; the original body is emitted in the offload kernel entry
+    // point and the synthesized kernel launch code is only relevant for host
+    // compilation.
+    return;
----------------
erichkeane wrote:

I find myself wondering whether we should insert some sort of 'halt' instruction here.  It seems that this is an 'error' case, but we're emitting it if it is ODR used (since we don't have a way of determining reachability).

however, since we're skipping the body, this is obviously just a case where it is UB to actually EXECUTE this function.  I know we can now do device asserts, so some sort of panic/terminate/etc would be appropriate here.

https://github.com/llvm/llvm-project/pull/152403


More information about the cfe-commits mailing list