[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 12:57:48 PDT 2024


================
@@ -12053,6 +12053,10 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
   if (LangOpts.OpenMP)
     OpenMP().ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(NewFD);
 
+  if (LangOpts.isSYCL() && NewFD->hasAttr<SYCLKernelEntryPointAttr>() &&
+      !NewFD->isInvalidDecl() && !NewFD->isDependentContext())
----------------
tahonermann wrote:

The call to `llvm::report_fatal_error()` will occur at run-time for Clang, sure, but that will be compile-time for users building their SYCL source code. I would rather have Clang fail with a stack trace that clearly indicates the problem (to us) then perform code gen thinking that a kernel was registered when one wasn't (likely to manifest in some kind of "kernel not found" error at run-time) or, worse, having a duplicate registration silently rejected such that an unintended kernel gets called. I grant that these scenarios will only occur if there are missing or incorrect checks elsewhere, but these kinds of problems would be rather painful to trace back to what the problem really is.

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


More information about the cfe-commits mailing list