[clang] [llvm] [Clang][SYCL] Call sycl_kernel_launch with a kernel info type rather than a kernel name type. (PR #208958)
Tom Honermann via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 12 19:00:00 PST 2026
================
@@ -71,31 +82,69 @@ class SemaSYCL : public SemaBase {
void CheckSYCLExternalFunctionDecl(FunctionDecl *FD);
void CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD);
- /// Builds an expression for the lookup of a 'sycl_kernel_launch' template
- /// with 'KernelName' as an explicit template argument. Lookup is performed
- /// as if from the first statement of the body of 'FD' and thus requires
- /// searching the scopes that exist at parse time. This function therefore
- /// requires the current semantic context to be the definition of 'FD'. In a
- /// dependent context, the returned expression will be an UnresolvedLookupExpr
- /// or an UnresolvedMemberExpr. In a non-dependent context, the returned
- /// expression will be a DeclRefExpr or MemberExpr. If lookup fails, a null
- /// error result is returned. The resulting expression is intended to be
- /// passed as the 'LaunchIdExpr' argument in a call to either
- /// BuildSYCLKernelCallStmt() or BuildUnresolvedSYCLKernelCallStmt() after
- /// the function body has been parsed.
- ExprResult BuildSYCLKernelLaunchIdExpr(FunctionDecl *FD, QualType KernelName);
-
- /// Builds a SYCLKernelCallStmt to wrap 'Body' and to be used as the body of
- /// 'FD'. 'LaunchIdExpr' specifies the lookup result returned by a previous
- /// call to BuildSYCLKernelLaunchIdExpr().
- StmtResult BuildSYCLKernelCallStmt(FunctionDecl *FD, CompoundStmt *Body,
- Expr *LaunchIdExpr);
-
- /// Builds an UnresolvedSYCLKernelCallStmt to wrap 'Body'. 'LaunchIdExpr'
- /// specifies the lookup result returned by a previous call to
- /// BuildSYCLKernelLaunchIdExpr().
- StmtResult BuildUnresolvedSYCLKernelCallStmt(CompoundStmt *Body,
- Expr *LaunchIdExpr);
+ /// GetSYCLKernelInfoClassTemplate builds a class template used to pass SYCL
+ /// kernel information in synthesized calls to SYCL runtime library functions.
+ /// The class template has an unspecified name, is an incomplete class
+ /// (explicit specializations are synthesized as needed), built on first call,
+ /// and cached for return in subsequent calls.
+ ClassTemplateDecl *GetSYCLKernelInfoClassTemplate();
+
+ /// GetSYCLKernelInfoClassSpecializationType returns a type for the class
+ /// template returned by GetSYCLKernelInfoClassTemplate() specialized for
+ /// 'KNT'. 'KNT' may be a dependent type. If 'KNT' is not a dependent type,
+ /// an explicit specialization declaration for the specialization is
+ /// synthesized and a canonical type returned. A definition for the explicit
+ /// specialization is synthesized when SYCLKernelCallStmt is constructed for
+ /// 'KNT'.
+ QualType GetSYCLKernelInfoClassSpecializationType(QualType KNT);
+
+ /// SYCLKernelCallStmtASTFragments holds portions of the AST used for lookup
+ /// of SYCL runtime library functions. These are constructed at the beginning
+ /// of a function definition and later used in synthesized calls to the
+ /// SYCL runtime library. In a dependent context, these are used to construct
+ /// an UnresolvedSYCLKernelCallStmt. During template instantiation, or in a
+ /// non-dependent context, these are used to construct a SYCLKernelCallStmt.
+ ///
+ /// KernelInfoType is the type to be passed as the explicit template argument
+ /// to SYCL runtime libraries.
+ ///
+ /// KernelLaunchIdExpr is an UnresolvedLookupExpr or UnresolvedMemberExpr
----------------
tahonermann wrote:
Good question! I had to jump into a debugger to check, but as far as I can tell, it is. Unqualified lookup is performed with the kernel name type as an explicit template argument, but without function arguments. Since the lookup is unqualified, ADL applies and it is therefore not possible to resolve the lookup to a particular overload. Even if there is only one overload candidate, it can't be selected since the function arguments are needed to determine if that candidate is viable.
https://github.com/llvm/llvm-project/pull/208958
More information about the cfe-commits
mailing list