[clang] [Clang][SYCL] Kernel parameter reification for SYCL run-time library types (PR #243349)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 15:06:32 PST 2026


https://github.com/tahonermann updated https://github.com/llvm/llvm-project/pull/243349

>From 6c6a8fb76de8bf5c73277332401ab576804082d7 Mon Sep 17 00:00:00 2001
From: Tom Honermann <tom.honermann at intel.com>
Date: Fri, 30 Oct 2026 22:14:08 -0700
Subject: [PATCH] [Clang][SYCL] Kernel parameter reification for SYCL run-time
 library types

SYCL 2020 requires some SYCL run-time library types to be passed to kernels
as a capture in a lambda expression or a data member of a function object
type even if they do not satisfy the requirements of a device copyable type.

`sycl::local_accessor` is an example. Objects of this type are created in
host function contexts, but their associated dynamic local memory is not
allocated until a kernel invocation occurs. When these objects are used
within a kernel, they must hold a pointer to their associated dynamic
local memory. But that pointer is not available until the kernel starts
executing on a device. Objects of these types therefore cannot be simply
copied to a device as they require an update before they can actually be
used to access local memory in device code.

Updates to objects of such types at the start of kernel execution is
referred to as kernel parameter reification. These types are intended to
logically hold the same value on both the host and the device, but may
differ in their value representation.

SYCL run-time types that require reification are declared with the
[[clang::sycl_reified_kernel_parameter]] attribute. For example:
  class [[clang::sycl_reified_kernel_parameter]] local_accessor { ... };

When a SYCL kernel object contains a subobject of such a type, the
`sycl_kernel_launch()` function that is implicitly called when a function
declared with the [[clang::sycl_kernel_entry_point]] attribute is called
is required to return a function object that is callable with a reference
for each such subobject passed as an argument. Consider the following
example.
  template<typename KN, typename KT>
  [[clang::sycl_kernel_entry_point(KN)]]
  void kernel_entry_point(const KT &k) {
    k();
  }
  void f() {
    sycl::local_accessor la1;
    sycl::local_accessor la2;
    kernel_entry_point<struct KN>([la1, la2] {});
  }

The SYCL kernel object is the result of the lambda expression in the call
to `kernel_entry_point`. The lambda captures both `la1` and `la2` which
have types declared with the [[clang::sycl_reified_kernel_parameter]]
attribute. These captures therefore require the involvement of the SYCL
run-time library to prepare them to be copied to a device and to receive
them at the start of kernel execution. The call to `kernel_entry_point()`
will result in an implicit call to `sycl_kernel_launch()` that looks as
follows.
  sycl_kernel_launch(k)(k.la1, k.la2)

`k`, `k.la1`, and `k.la2` are all passed as lvalues and the object passed
as 'k' is guaranteed to have a lifetime that survives the call to the
function object returned. This enables the returned function object to be
the result of a lambda expression that captures `k` by reference in which
case, the lvalues passed as `k.la1` and `k.la2` will reference the captures
held in `k`.
  template<typename KI, typename KT>
  auto sycl_kernel_launch(KT &k) {
    return [&k](auto&... special_subobjects) {
      // special_subobjects is a function parameter pack that contains a
      // sequence of parameters that reference members of k; inspect or
      // update as needed.
    }
  }

The function object returned by `sycl_kernel_launch()` must return `void`
when called. If there are no subobjects that require reification, then
`sycl_kernel_launch()` may return `void` or may return a function object
that accepts no arguments. If `KT` is not a `const` type, `k`, `k.la1`,
and `k.la2` may be modified.

The above allows the SYCL run-time library to inspect and/or mutate these
objects as part of its preparation for kernel launch. Support for
inspecting and/or mutating these objects at the start of kernel execution
is provided through an implicit call to a function template named
`sycl_reify_kernel_parameters()`. This function works just like
`sycl_kernel_launch()`. Kernel execution begins with an invocation of a
generated offload kernel entry point function with the SYCL kernel object
passed as an argument. The generated function looks similar to this where
`kernel-entry-point-for-KN` is an exposition only representing the name
of the generated function.
  void kernel-entry-point-for-KN(KT &k) {
    sycl_reify_kernel_parameters(k)(k.la1, k.la2);
    k();
  }

A declaration of `sycl_reify_kernel_parameters()` might look as follows:
  template<typename KI, typename KT>
  auto sycl_reify_kernel_parameters(KT &k) {
    return [&k](auto&... special_subobjects) {
      // special_subobjects is a function parameter pack that contains a
      // sequence of parameters that reference members of k; inspect or
      // update as needed.
    }
  }

If the SYCL kernel object has no subobjects that require reification, then
`sycl_reify_kernel_parameters()` is not called. The function object returned
by `sycl_reify_kernel_parameters()` must return `void` when called.
---
 clang/include/clang/AST/ASTNodeTraverser.h    |   4 +-
 clang/include/clang/AST/RecursiveASTVisitor.h |   1 +
 clang/include/clang/AST/StmtSYCL.h            |  29 +-
 clang/include/clang/Basic/Attr.td             |   7 +
 clang/include/clang/Basic/AttrDocs.td         |  39 ++
 .../clang/Basic/DiagnosticSemaKinds.td        |  14 +-
 clang/include/clang/Sema/Sema.h               |  16 +
 clang/include/clang/Sema/SemaSYCL.h           |   8 +-
 clang/lib/AST/ODRHash.cpp                     |   5 +
 clang/lib/Sema/SemaDeclAttr.cpp               |   3 +
 clang/lib/Sema/SemaSYCL.cpp                   | 368 +++++++++++++++---
 clang/lib/Sema/SemaTemplateInstantiate.cpp    |  78 +++-
 clang/lib/Sema/TreeTransform.h                |  13 +-
 clang/lib/Serialization/ASTReaderStmt.cpp     |   1 +
 clang/lib/Serialization/ASTWriterStmt.cpp     |   1 +
 .../ast-dump-sycl-kernel-call-stmt.cpp        |  30 +-
 ...ast-dump-sycl-reified-kernel-parameter.cpp | 153 ++++++++
 .../CodeGenSYCL/reify-kernel-parameters.cpp   |  71 ++++
 ...a-attribute-supported-attributes-list.test |   1 +
 clang/test/SemaSYCL/sycl-kernel-launch.cpp    |  52 +++
 ...ed-kernel-parameter-attr-appertainment.cpp | 238 +++++++++++
 ...-reified-kernel-parameter-attr-grammar.cpp |  45 +++
 ...-reified-kernel-parameter-attr-ignored.cpp |  11 +
 ...l-reified-kernel-parameter-attr-module.cpp | 138 +++++++
 ...sycl-reified-kernel-parameter-attr-pch.cpp |  39 ++
 .../sycl-reified-kernel-parameters.cpp        | 193 +++++++++
 26 files changed, 1486 insertions(+), 72 deletions(-)
 create mode 100644 clang/test/ASTSYCL/ast-dump-sycl-reified-kernel-parameter.cpp
 create mode 100644 clang/test/CodeGenSYCL/reify-kernel-parameters.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-appertainment.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-grammar.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-ignored.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-module.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-pch.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-reified-kernel-parameters.cpp

diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
index e3314e99d9ad69..61d4e15e68aebd 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -872,8 +872,10 @@ class ASTNodeTraverser
   void
   VisitUnresolvedSYCLKernelCallStmt(const UnresolvedSYCLKernelCallStmt *Node) {
     Visit(Node->getOriginalStmt());
-    if (Traversal != TK_IgnoreUnlessSpelledInSource)
+    if (Traversal != TK_IgnoreUnlessSpelledInSource) {
       Visit(Node->getKernelLaunchIdExpr());
+      Visit(Node->getReifyKernelParamsIdExpr());
+    }
   }
 
   void VisitOMPExecutableDirective(const OMPExecutableDirective *Node) {
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index de1ffafc01df20..0b9b69adfbd4bf 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3056,6 +3056,7 @@ DEF_TRAVERSE_STMT(UnresolvedSYCLKernelCallStmt, {
   if (getDerived().shouldVisitImplicitCode()) {
     TRY_TO(TraverseStmt(S->getOriginalStmt()));
     TRY_TO(TraverseStmt(S->getKernelLaunchIdExpr()));
+    TRY_TO(TraverseStmt(S->getReifyKernelParamsIdExpr()));
     ShouldVisitChildren = false;
   }
 })
diff --git a/clang/include/clang/AST/StmtSYCL.h b/clang/include/clang/AST/StmtSYCL.h
index aebbfcffeb84f7..3aefd2ae8d0e06 100644
--- a/clang/include/clang/AST/StmtSYCL.h
+++ b/clang/include/clang/AST/StmtSYCL.h
@@ -108,22 +108,36 @@ class UnresolvedSYCLKernelCallStmt : public Stmt {
   // lookup of 'sycl_kernel_launch'.
   Expr *KernelLaunchIdExpr = nullptr;
 
-  UnresolvedSYCLKernelCallStmt(CompoundStmt *CS, Expr *IdExpr)
+  // ReifyKernelParamsIdExpr stores an UnresolvedLookupExpr or
+  // UnresolvedMemberExpr for the function to be called within a kernel entry
+  // point to reify kernel parameters that require special handling.
+  Expr *ReifyKernelParamsIdExpr = nullptr;
+
+  UnresolvedSYCLKernelCallStmt(CompoundStmt *CS, Expr *LaunchIdExpr,
+                               Expr *ReifyParamsIdExpr)
       : Stmt(UnresolvedSYCLKernelCallStmtClass), OriginalStmt(CS),
-        KernelLaunchIdExpr(IdExpr) {}
+        KernelLaunchIdExpr(LaunchIdExpr),
+        ReifyKernelParamsIdExpr(ReifyParamsIdExpr) {}
 
   void setOriginalStmt(CompoundStmt *CS) { OriginalStmt = CS; }
 
   void setKernelLaunchIdExpr(Expr *IdExpr) { KernelLaunchIdExpr = IdExpr; }
 
+  void setReifyKernelParamsIdExpr(Expr *IdExpr) {
+    ReifyKernelParamsIdExpr = IdExpr;
+  }
+
 public:
   static UnresolvedSYCLKernelCallStmt *Create(const ASTContext &C,
-                                              CompoundStmt *CS, Expr *IdExpr) {
-    return new (C) UnresolvedSYCLKernelCallStmt(CS, IdExpr);
+                                              CompoundStmt *CS,
+                                              Expr *LaunchIdExpr,
+                                              Expr *ReifyParamsIdExpr) {
+    return new (C)
+        UnresolvedSYCLKernelCallStmt(CS, LaunchIdExpr, ReifyParamsIdExpr);
   }
 
   static UnresolvedSYCLKernelCallStmt *CreateEmpty(const ASTContext &C) {
-    return new (C) UnresolvedSYCLKernelCallStmt(nullptr, nullptr);
+    return new (C) UnresolvedSYCLKernelCallStmt(nullptr, nullptr, nullptr);
   }
 
   CompoundStmt *getOriginalStmt() { return cast<CompoundStmt>(OriginalStmt); }
@@ -134,6 +148,11 @@ class UnresolvedSYCLKernelCallStmt : public Stmt {
   Expr *getKernelLaunchIdExpr() { return KernelLaunchIdExpr; }
   const Expr *getKernelLaunchIdExpr() const { return KernelLaunchIdExpr; }
 
+  Expr *getReifyKernelParamsIdExpr() { return ReifyKernelParamsIdExpr; }
+  const Expr *getReifyKernelParamsIdExpr() const {
+    return ReifyKernelParamsIdExpr;
+  }
+
   SourceLocation getBeginLoc() const LLVM_READONLY {
     return getOriginalStmt()->getBeginLoc();
   }
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 806debfe13cda8..496329f5a4153e 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1736,6 +1736,13 @@ def SYCLKernelEntryPoint : InheritableAttr {
   }];
 }
 
+def SYCLReifiedKernelParameter : InheritableAttr {
+  let Spellings = [CXX11<"clang", "sycl_reified_kernel_parameter">];
+  let Subjects = SubjectList<[CXXRecord]>;
+  let LangOpts = [SYCLHost, SYCLDevice];
+  let Documentation = [SYCLReifiedKernelParameterDocs];
+}
+
 def SYCLSpecialClass: InheritableAttr {
   let Spellings = [Clang<"sycl_special_class">];
   let Subjects = SubjectList<[CXXRecord]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 5ff48c25d4e7db..e0505ffc71cfa5 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -864,6 +864,45 @@ expression.
   }];
 }
 
+def SYCLReifiedKernelParameterDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+The `sycl_reified_kernel_parameter` attribute is used to mark a class type
+whose objects require special handling when passed as kernel arguments to a
+function declared with the `sycl_kernel_entry_point` attribute. This attribute
+is intended for use by SYCL library implementations to annotate types such as
+`sycl::accessor` and `sycl::stream` that are not trivially copyable and
+therefore cannot be copied to device memory as if by `memcpy()`.
+
+The attribute only appertains to C++ class or struct types and is only valid
+in SYCL host or device compilation modes.
+
+When a parameter of a function declared with the `sycl_kernel_entry_point`
+attribute contains a subobject whose type is marked with this attribute, the
+synthesized call to `sycl_kernel_launch` is expected to return a callable
+object. This callable is then invoked with references to the subobjects that
+require reification (found by traversing the kernel function object's members)
+so that the SYCL runtime can process them. The return type of that second call
+must be `void`. The synthesized host code looks approximately as follows:
+
+```c++
+sycl_kernel_launch<KI>(kernelFunc)(kernelFunc.member);
+```
+
+Where `member` is a subobject of the kernel function object whose type
+is marked with `sycl_reified_kernel_parameter`.
+
+Use of this attribute might look as follows:
+
+```c++
+class [[clang::sycl_reified_kernel_parameter]] accessor {
+  int *ptr;
+  size_t range;
+};
+```
+  }];
+}
+
 def SYCLAddressSpaceDocs : Documentation {
   let Category = DocCatType;
   let Heading = "SYCL Address Spaces";
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d2c1128d92c253..1715bdff41d4f2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -13813,12 +13813,14 @@ def err_sycl_entry_point_deduced_return_type : Error<
 def note_sycl_runtime_defect : Note<
   "this indicates a problem with the SYCL runtime header files; please consider"
   " reporting this to your SYCL runtime provider">;
-def note_sycl_kernel_launch_lookup_here : Note<
-  "in implicit call to 'sycl_kernel_launch' with template argument %0 required"
-  " here">;
-def note_sycl_kernel_launch_overload_resolution_here : Note<
-  "in implicit call to 'sycl_kernel_launch' with template argument %0 and"
-  " function arguments %1 required here">;
+def note_sycl_implicit_runtime_call_lookup_here : Note<
+  "in implicit call to '%0' with template argument %1 required here">;
+def note_sycl_implicit_runtime_call_overload_resolution_here : Note<
+  "in implicit call to '%0' with template argument %1 and function arguments"
+  " %2 required here">;
+def note_sycl_implicit_runtime_callback_call : Note<
+  "in implicit call to the callable returned by '%0' with function arguments"
+  " %1 required here">;
 def err_sycl_entry_point_device_use : Error<
   "function %0 cannot be used in device code because it is declared with the"
   " %1 attribute">;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1042cb17aa65ac..4afbcbafea1605 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13572,10 +13572,26 @@ class Sema final : public SemaBase {
       /// template named 'sycl_kernel_launch'.
       SYCLKernelLaunchLookup,
 
+      /// We are performing name lookup for a function template or variable
+      /// template named 'sycl_reify_kernel_parameters'.
+      SYCLReifyKernelParamsLookup,
+
       /// We are performing overload resolution for a call to a function
       /// template or variable template named 'sycl_kernel_launch'.
       SYCLKernelLaunchOverloadResolution,
 
+      /// We are performing overload resolution for a call to a function
+      /// template or variable template named 'sycl_reify_kernel_parameters'.
+      SYCLReifyKernelParamsOverloadResolution,
+
+      /// We are performing overload resolution for a call to the result of
+      /// a call to 'sycl_kernel_launch'.
+      SYCLKernelLaunchCallbackOverloadResolution,
+
+      /// We are performing overload resolution for a call to the result of
+      /// a call to 'sycl_reify_kernel_parameters'.
+      SYCLReifyKernelParamsCallbackOverloadResolution,
+
       /// We are instantiating an expansion statement.
       ExpansionStmtInstantiation,
     } Kind;
diff --git a/clang/include/clang/Sema/SemaSYCL.h b/clang/include/clang/Sema/SemaSYCL.h
index a4e1fbc8f3f745..7ca86aecb6a092 100644
--- a/clang/include/clang/Sema/SemaSYCL.h
+++ b/clang/include/clang/Sema/SemaSYCL.h
@@ -109,10 +109,12 @@ class SemaSYCL : public SemaBase {
   /// Sema::FunctionScopeInfo for later use in synthesized calls to the
   /// SYCL runtime library after the function body has been parsed.
   ///
-  /// KernelLaunchIdExpr stores an expression for the (probably unresolved)
-  /// lookup of 'sycl_kernel_launch'.
+  /// KernelLaunchIdExpr and ReifyKernelParamsIdExpr store an expression for
+  /// the (probably unresolved) lookup of 'sycl_kernel_launch' and
+  /// 'sycl_reify_kernel_parameters'.
   struct SYCLKernelCallStmtASTFragments {
-    Expr *KernelLaunchIdExpr;
+    Expr *KernelLaunchIdExpr = nullptr;
+    Expr *ReifyKernelParamsIdExpr = nullptr;
   };
 
   /// BuildSYCLKernelCallStmtASTFragments builds portions of the AST needed
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 789a0d0de470a2..fc0ee85d4f699f 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/AST/ODRHash.h"
 
+#include "clang/AST/Attr.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TypeVisitor.h"
@@ -629,6 +630,10 @@ void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Record) {
     }
   }
 
+  // Require matching SYCL attributes.
+  AddBoolean(
+      Record->getMostRecentDecl()->hasAttr<SYCLReifiedKernelParameterAttr>());
+
   ID.AddInteger(Decls.size());
   for (auto SubDecl : Decls) {
     AddSubDecl(SubDecl);
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 9bf629229f0f79..cfcc242271f4fb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7947,6 +7947,9 @@ ProcessDeclAttribute(Sema &S, Decl *D, const ParsedAttr &AL,
   case ParsedAttr::AT_SYCLKernelEntryPoint:
     S.SYCL().handleKernelEntryPointAttr(D, AL);
     break;
+  case ParsedAttr::AT_SYCLReifiedKernelParameter:
+    handleSimpleAttribute<SYCLReifiedKernelParameterAttr>(S, D, AL);
+    break;
   case ParsedAttr::AT_SYCLSpecialClass:
     handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL);
     break;
diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp
index b6c6dde23befee..93ecdae1822a56 100644
--- a/clang/lib/Sema/SemaSYCL.cpp
+++ b/clang/lib/Sema/SemaSYCL.cpp
@@ -696,12 +696,95 @@ ExprResult BuildSYCLKernelLaunchIdExpr(Sema &SemaRef, FunctionDecl *FD,
   return IdExpr;
 }
 
+/// BuildSYCLReifyKernelParamsIdExpr performs lookup for a
+/// 'sycl_reify_kernel_parameters' template with 'KIT' used as an explicit
+/// type template argument. If lookup fails, no diagnostic is issued, but
+/// an error expression is returned. Otherwise, an UnresolvedLookupExpr,
+/// UnresolvedMemberExpr, DeclRefExpr, or MemberExpr will be returned.
+/// The resulting expression is intended to be passed as the 'IdExpr'
+/// argument to BuildSYCLReifyKernelParamsCallStmt() after the function
+/// body has been parsed.
+///
+/// 'FD' must be a function declared with a valid sycl_kernel_entry_point
+/// attribute and the current Sema context must match 'FD' so that scopes
+/// are properly in place such that lookup is performed as if from the first
+/// statement of the function body.
+///
+/// 'KIT' is the SYCL kernel info type to be used for lookup and it may
+/// be a dependent type.
+ExprResult BuildSYCLReifyKernelParamsIdExpr(Sema &SemaRef, FunctionDecl *FD,
+                                            QualType KIT) {
+  // The current context must be the function definition context to ensure
+  // that name lookup is performed within the correct scope.
+  assert(SemaRef.CurContext == FD && "The current declaration context does not "
+                                     "match the requested function context");
+
+  // An appropriate source location is required to emit diagnostics if
+  // lookup fails to produce an overload set. The desired location is the
+  // start of the function body, but that is not yet available since the
+  // body of the function has not yet been set when this function is called.
+  // The general location of the function is used instead.
+  SourceLocation Loc = FD->getLocation();
+
+  ASTContext &Ctx = SemaRef.getASTContext();
+  IdentifierInfo &SYCLReifyKernelParamsID = Ctx.Idents.get(
+      "sycl_reify_kernel_parameters", tok::TokenKind::identifier);
+
+  // Establish a code synthesis context for the implicit name lookup of
+  // a template named 'sycl_reify_kernel_parameters'. In the event of an error,
+  // this ensures an appropriate diagnostic note is issued to explain why the
+  // lookup was performed.
+  Sema::CodeSynthesisContext CSC;
+  CSC.Kind = Sema::CodeSynthesisContext::SYCLReifyKernelParamsLookup;
+  CSC.Entity = FD;
+  Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
+
+  // Perform ordinary name lookup for a function or variable template that
+  // accepts a single type template argument.
+  LookupResult Result(SemaRef, &SYCLReifyKernelParamsID, Loc,
+                      Sema::LookupOrdinaryName);
+  CXXScopeSpec EmptySS;
+  if (SemaRef.LookupTemplateName(Result, SemaRef.getCurScope(), EmptySS,
+                                 /*ObjectType*/ QualType(),
+                                 /*EnteringContext*/ false,
+                                 Sema::TemplateNameIsRequired))
+    return ExprError();
+  if (Result.isAmbiguous())
+    return ExprError();
+
+  TemplateArgumentListInfo TALI{Loc, Loc};
+  TemplateArgument KITA = TemplateArgument(KIT);
+  TemplateArgumentLoc TAL =
+      SemaRef.getTrivialTemplateArgumentLoc(KITA, QualType(), Loc);
+  TALI.addArgument(TAL);
+
+  ExprResult IdExpr;
+  if (SemaRef.isPotentialImplicitMemberAccess(EmptySS, Result,
+                                              /*IsAddressOfOperand*/ false)) {
+    // The lookup result allows for a possible implicit member access that
+    // would require an implicit or explicit 'this' argument.
+    IdExpr = SemaRef.BuildPossibleImplicitMemberExpr(
+        EmptySS, SourceLocation(), Result, &TALI, SemaRef.getCurScope());
+  } else {
+    IdExpr = SemaRef.BuildTemplateIdExpr(EmptySS, SourceLocation(), Result,
+                                         /*RequiresADL*/ true, &TALI);
+  }
+
+  // The resulting expression may be invalid if, for example, 'FD' is a
+  // non-static member function and name lookup selects a member function
+  // (which would require a 'this' argument which is not available).
+  if (IdExpr.isInvalid())
+    return ExprError();
+
+  return IdExpr;
+}
+
 // Constructs the arguments to be passed for the SYCL kernel launch call.
-// The arguments are the parameters of 'FD' passed as move-eligible xvalues.
 // Returns true on error and false otherwise.
-bool BuildSYCLKernelLaunchCallArgs(Sema &SemaRef, FunctionDecl *FD,
-                                   SmallVectorImpl<Expr *> &Args,
-                                   SourceLocation Loc) {
+bool BuildSYCLKernelParamsForwardingArgs(Sema &SemaRef, FunctionDecl *FD,
+                                         SourceLocation Loc,
+                                         SmallVectorImpl<Expr *> &Args,
+                                         SmallVectorImpl<Expr *> &SRKPExprs) {
   // The current context must be the function definition context to ensure
   // that parameter references occur within the correct scope.
   assert(SemaRef.CurContext == FD && "The current declaration context does not "
@@ -714,12 +797,19 @@ bool BuildSYCLKernelLaunchCallArgs(Sema &SemaRef, FunctionDecl *FD,
     ExprResult E = SemaRef.BuildDeclRefExpr(PVD, ParamType, VK_LValue, Loc);
     if (E.isInvalid())
       return true;
-    if (!PVD->getType()->isLValueReferenceType())
-      E = ImplicitCastExpr::Create(SemaRef.Context, E.get()->getType(), CK_NoOp,
-                                   E.get(), nullptr, VK_XValue,
-                                   FPOptionsOverride());
-    if (E.isInvalid())
-      return true;
+    if (SRKPExprs.empty()) {
+      // If no kernel parameters require reification, then by-value parameters
+      // can be forwarded as xvalues. Otherwise, lvalues are required so that
+      // they can be captured by reference by the callback lambda which will
+      // then be called with lvalues referencing subobjects that require
+      // reification.
+      if (!PVD->getType()->isLValueReferenceType())
+        E = ImplicitCastExpr::Create(SemaRef.Context, E.get()->getType(),
+                                     CK_NoOp, E.get(), nullptr, VK_XValue,
+                                     FPOptionsOverride());
+      if (E.isInvalid())
+        return true;
+    }
     Args.push_back(E.get());
   }
 
@@ -728,11 +818,12 @@ bool BuildSYCLKernelLaunchCallArgs(Sema &SemaRef, FunctionDecl *FD,
 
 // Constructs the SYCL kernel launch call.
 StmtResult BuildSYCLKernelLaunchCallStmt(Sema &SemaRef, FunctionDecl *FD,
-                                         Expr *IdExpr, SourceLocation Loc) {
+                                         SourceLocation Loc, Expr *IdExpr,
+                                         SmallVectorImpl<Expr *> &SRKPExprs) {
   SmallVector<Stmt *> Stmts;
   // IdExpr may be null if name lookup failed.
   if (IdExpr) {
-    llvm::SmallVector<Expr *, 12> Args;
+    SmallVector<Expr *, 12> Args;
 
     // Establish a code synthesis context for construction of the arguments
     // for the implicit call to 'sycl_kernel_launch'.
@@ -742,12 +833,14 @@ StmtResult BuildSYCLKernelLaunchCallStmt(Sema &SemaRef, FunctionDecl *FD,
       CSC.Entity = FD;
       Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
 
-      if (BuildSYCLKernelLaunchCallArgs(SemaRef, FD, Args, Loc))
+      if (BuildSYCLKernelParamsForwardingArgs(SemaRef, FD, Loc, Args,
+                                              SRKPExprs))
         return StmtError();
     }
 
     // Establish a code synthesis context for the implicit call to
     // 'sycl_kernel_launch'.
+    ExprResult LaunchResult;
     {
       Sema::CodeSynthesisContext CSC;
       CSC.Kind = Sema::CodeSynthesisContext::SYCLKernelLaunchOverloadResolution;
@@ -756,13 +849,97 @@ StmtResult BuildSYCLKernelLaunchCallStmt(Sema &SemaRef, FunctionDecl *FD,
       CSC.NumCallArgs = Args.size();
       Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
 
-      ExprResult LaunchResult =
+      LaunchResult =
+          SemaRef.BuildCallExpr(SemaRef.getCurScope(), IdExpr, Loc, Args, Loc);
+      if (LaunchResult.isInvalid())
+        return StmtError();
+    }
+
+    // If kernel parameter reification is required or if 'sycl_kernel_launch'
+    // doesn't return void, establish a code synthesis context for the implicit
+    // call to the returned callable.
+    if (!SRKPExprs.empty() || !LaunchResult.get()->getType()->isVoidType()) {
+      Sema::CodeSynthesisContext CSC;
+      CSC.Kind = Sema::CodeSynthesisContext::
+          SYCLKernelLaunchCallbackOverloadResolution;
+      CSC.Entity = FD;
+      CSC.CallArgs = SRKPExprs.data();
+      CSC.NumCallArgs = SRKPExprs.size();
+      Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
+
+      LaunchResult = SemaRef.BuildCallExpr(
+          SemaRef.getCurScope(), LaunchResult.get(), Loc, SRKPExprs, Loc);
+      if (LaunchResult.isInvalid())
+        return StmtError();
+    }
+
+    Stmts.push_back(SemaRef.MaybeCreateExprWithCleanups(LaunchResult).get());
+  }
+
+  return CompoundStmt::Create(SemaRef.getASTContext(), Stmts,
+                              FPOptionsOverride(), Loc, Loc);
+}
+
+// Constructs the SYCL reify kernel parameters call.
+StmtResult
+BuildSYCLReifyKernelParamsCallStmt(Sema &SemaRef, FunctionDecl *FD,
+                                   SourceLocation Loc, Expr *IdExpr,
+                                   SmallVectorImpl<Expr *> &SRKPExprs) {
+  SmallVector<Stmt *> Stmts;
+  // IdExpr may be null if name lookup failed.
+  if (IdExpr) {
+    SmallVector<Expr *, 12> Args;
+
+    // Establish a code synthesis context for construction of the arguments
+    // for the implicit call to 'sycl_reify_kernel_parameters'.
+    {
+      Sema::CodeSynthesisContext CSC;
+      CSC.Kind = Sema::CodeSynthesisContext::SYCLReifyKernelParamsLookup;
+      CSC.Entity = FD;
+      Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
+
+      if (BuildSYCLKernelParamsForwardingArgs(SemaRef, FD, Loc, Args,
+                                              SRKPExprs))
+        return StmtError();
+    }
+
+    // Establish a code synthesis context for the implicit call to
+    // 'sycl_reify_kernel_parameters'.
+    ExprResult LaunchResult;
+    {
+      Sema::CodeSynthesisContext CSC;
+      CSC.Kind =
+          Sema::CodeSynthesisContext::SYCLReifyKernelParamsOverloadResolution;
+      CSC.Entity = FD;
+      CSC.CallArgs = Args.data();
+      CSC.NumCallArgs = Args.size();
+      Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
+
+      LaunchResult =
           SemaRef.BuildCallExpr(SemaRef.getCurScope(), IdExpr, Loc, Args, Loc);
       if (LaunchResult.isInvalid())
         return StmtError();
+    }
 
-      Stmts.push_back(SemaRef.MaybeCreateExprWithCleanups(LaunchResult).get());
+    // If kernel parameter reification is required or if 'sycl_kernel_launch'
+    // doesn't return void, establish a code synthesis context for the implicit
+    // call to the returned callable.
+    if (!SRKPExprs.empty() || !LaunchResult.get()->getType()->isVoidType()) {
+      Sema::CodeSynthesisContext CSC;
+      CSC.Kind = Sema::CodeSynthesisContext::
+          SYCLReifyKernelParamsCallbackOverloadResolution;
+      CSC.Entity = FD;
+      CSC.CallArgs = SRKPExprs.data();
+      CSC.NumCallArgs = SRKPExprs.size();
+      Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
+
+      LaunchResult = SemaRef.BuildCallExpr(
+          SemaRef.getCurScope(), LaunchResult.get(), Loc, SRKPExprs, Loc);
+      if (LaunchResult.isInvalid())
+        return StmtError();
     }
+
+    Stmts.push_back(SemaRef.MaybeCreateExprWithCleanups(LaunchResult).get());
   }
 
   return CompoundStmt::Create(SemaRef.getASTContext(), Stmts,
@@ -824,14 +1001,34 @@ class OutlinedFunctionDeclBodyInstantiator
   FunctionDecl *FD;
 };
 
-OutlinedFunctionDecl *BuildSYCLKernelEntryPointOutline(Sema &SemaRef,
-                                                       FunctionDecl *FD,
-                                                       CompoundStmt *Body) {
-  using ParmDeclMap = OutlinedFunctionDeclBodyInstantiator::ParmDeclMap;
-  ParmDeclMap ParmMap;
+DeclResult BuildSYCLKernelEntryPointOutline(Sema &SemaRef, FunctionDecl *FD,
+                                            SourceLocation Loc,
+                                            Expr *ReifyKernelParamsIdExpr,
+                                            SmallVectorImpl<Expr *> &SRKPExprs,
+                                            CompoundStmt *Body) {
+  // If any of the kernel parameter types have a subobject type that requires
+  // reification, then a call to sycl_reify_kernel_parameters() is synthesized
+  // to provide the SYCL RT an opportunity to update them.
+  if (!SRKPExprs.empty()) {
+    StmtResult ReifyParamsResult = BuildSYCLReifyKernelParamsCallStmt(
+        SemaRef, FD, Loc, ReifyKernelParamsIdExpr, SRKPExprs);
+    if (ReifyParamsResult.isInvalid())
+      return DeclResult(true);
+
+    SmallVector<Stmt *> Stmts;
+    Stmts.push_back(ReifyParamsResult.get());
+    Stmts.push_back(Body);
+    Body = CompoundStmt::Create(SemaRef.getASTContext(), Stmts,
+                                FPOptionsOverride(), Loc, Loc);
+  }
 
   OutlinedFunctionDecl *OFD = OutlinedFunctionDecl::Create(
       SemaRef.getASTContext(), FD, FD->getNumParams());
+
+  // Create a map from the function parameters to the replacement set of
+  // implicit parameters that will substitute for them in the outlined function
+  // declaration.
+  OutlinedFunctionDeclBodyInstantiator::ParmDeclMap ParmMap;
   unsigned i = 0;
   for (ParmVarDecl *PVD : FD->parameters()) {
     ImplicitParamDecl *IPD = ImplicitParamDecl::Create(
@@ -851,13 +1048,21 @@ OutlinedFunctionDecl *BuildSYCLKernelEntryPointOutline(Sema &SemaRef,
   return OFD;
 }
 
+bool isReifiedKernelParameterType(QualType Ty) {
+  if (const auto *RT = Ty->getAsRecordDecl())
+    return RT->getMostRecentDecl()->hasAttr<SYCLReifiedKernelParameterAttr>();
+  return false;
+}
+
 class KernelParamsChecker : public ConstSubobjectVisitor<KernelParamsChecker> {
   SemaSYCL &SemaSYCLRef;
-  bool IsValid = true;
+  SourceLocation Loc;
   using ObjectAccess =
       llvm::PointerUnion<const ParmVarDecl *, const CXXBaseSpecifier *,
                          const FieldDecl *>;
   SmallVector<ObjectAccess, 4> ObjectAccessPath;
+  SmallVectorImpl<Expr *> &SRKPExprs;
+  bool IsValid = true;
 
   void emitObjectAccessPathNotes() {
     for (auto Parent : llvm::reverse(ObjectAccessPath)) {
@@ -884,10 +1089,60 @@ class KernelParamsChecker : public ConstSubobjectVisitor<KernelParamsChecker> {
     }
   }
 
+  Expr *BuildParmVarDeclAccessExpr(const ParmVarDecl *PVD) {
+    QualType Ty = PVD->getType().getNonReferenceType();
+    return SemaSYCLRef.SemaRef.BuildDeclRefExpr(const_cast<ParmVarDecl *>(PVD),
+                                                Ty, VK_LValue, Loc);
+  }
+
+  Expr *BuildDerivedToBaseCastExpr(Expr *E, const CXXBaseSpecifier *BS) {
+    QualType DerivedTy = E->getType();
+    QualType BaseTy = BS->getType();
+    CXXCastPath BasePath;
+    SemaSYCLRef.SemaRef.CheckDerivedToBaseConversion(DerivedTy, BaseTy, Loc,
+                                                     SourceRange(), &BasePath,
+                                                     /*IgnoreBaseAccess*/ true);
+    auto *ICE = ImplicitCastExpr::Create(
+        SemaSYCLRef.getASTContext(), BaseTy, CK_DerivedToBase, E,
+        /* CXXCastPath=*/&BasePath, VK_LValue, FPOptionsOverride());
+    return ICE;
+  }
+
+  Expr *BuildFieldDeclAccessExpr(Expr *E, const FieldDecl *FD) {
+    DeclAccessPair DAP =
+        DeclAccessPair::make(const_cast<FieldDecl *>(FD), AS_none);
+    MemberExpr *ME = SemaSYCLRef.SemaRef.BuildMemberExpr(
+        E, /*IsArrow */ false, Loc, NestedNameSpecifierLoc(), Loc,
+        const_cast<FieldDecl *>(FD), DAP, /*HadMultipleCandidates*/ false,
+        DeclarationNameInfo(FD->getDeclName(), Loc), FD->getType(), VK_LValue,
+        OK_Ordinary);
+    return ME;
+  }
+
+  void BuildSRKPObjectAccessExpr() {
+    Expr *E = nullptr;
+    for (auto OA : ObjectAccessPath) {
+      if (auto *PVD = OA.dyn_cast<const ParmVarDecl *>()) {
+        assert(!E && "No base expression should exist yet");
+        E = BuildParmVarDeclAccessExpr(PVD);
+      } else if (auto *BS = OA.dyn_cast<const CXXBaseSpecifier *>()) {
+        assert(E && "A base expression should already exist");
+        E = BuildDerivedToBaseCastExpr(E, BS);
+      } else if (auto *FD = OA.dyn_cast<const FieldDecl *>()) {
+        assert(E && "A base expression should already exist");
+        E = BuildFieldDeclAccessExpr(E, FD);
+      } else {
+        llvm_unreachable("Unhandled object access kind");
+      }
+    }
+    SRKPExprs.push_back(E);
+  }
+
 public:
-  KernelParamsChecker(SemaSYCL &SR, SourceLocation Loc)
+  KernelParamsChecker(SemaSYCL &SR, SourceLocation Loc,
+                      SmallVectorImpl<Expr *> &SRKPExprs)
       : ConstSubobjectVisitor<KernelParamsChecker>(SR.getASTContext()),
-        SemaSYCLRef(SR) {}
+        SemaSYCLRef(SR), Loc(Loc), SRKPExprs(SRKPExprs) {}
 
   void checkParameter(const ParmVarDecl *PVD) {
     QualType ParamTy = PVD->getType();
@@ -923,16 +1178,24 @@ class KernelParamsChecker : public ConstSubobjectVisitor<KernelParamsChecker> {
 
   // Returns true if subobjects should be visited and false otherwise.
   bool checkType(QualType Ty) {
-    if (Ty->isReferenceType()) {
+    if (isReifiedKernelParameterType(Ty)) {
+      BuildSRKPObjectAccessExpr();
+      // Don't visit subobjects of SRKP types; the SYCL RT takes full
+      // responsibility for them.
+      return false;
+    }
+
+    if (const auto *RT = Ty->getAs<const ReferenceType>()) {
       auto DirectParent = ObjectAccessPath.back();
-      // Reference cannot be a base, so just assume we came via a FieldDecl.
       if (isa<const ParmVarDecl *>(DirectParent)) {
-        // If reference is a kernel parameter, there is nothing to do. We allow
-        // references in direct kernel parameters for better performance of the
-        // host code and we eliminate them when building actual kernel.
-        return true;
+        // If the reference is for a kernel parameter, treat it like a value
+        // parameter type. Reference parameter types are replaced by value
+        // parameter types when the kernel entry point is generated.
+        visit(RT->getPointeeType());
+        return false;
       }
 
+      assert(isa<const FieldDecl *>(DirectParent));
       auto *DirectFieldParent = cast<const FieldDecl *>(DirectParent);
       SemaSYCLRef.Diag(DirectFieldParent->getLocation(),
                        diag::err_bad_kernel_param_type)
@@ -946,6 +1209,7 @@ class KernelParamsChecker : public ConstSubobjectVisitor<KernelParamsChecker> {
       IsValid = false;
       return false;
     }
+
     return true;
   }
 
@@ -957,13 +1221,6 @@ class KernelParamsChecker : public ConstSubobjectVisitor<KernelParamsChecker> {
   bool isInvalid() { return !IsValid; }
 };
 
-bool verifyKernelParams(FunctionDecl *FD, SemaSYCL &SemaSYCLRef) {
-  KernelParamsChecker KAC(SemaSYCLRef, FD->getLocation());
-  for (auto Param : FD->parameters())
-    KAC.checkParameter(Param);
-  return KAC.isInvalid();
-}
-
 /// BuildResolvedSYCLKernelCallStmt builds a SYCLKernelCallStmt to serve as
 /// the body of 'FD'. If construction fails, a diagnostic is issued and an
 /// error statement is returned.
@@ -996,27 +1253,37 @@ StmtResult BuildResolvedSYCLKernelCallStmt(
   assert(declaresSameEntity(SKI.getKernelEntryPointDecl(), FD) &&
          "SYCL kernel name conflict");
 
-  if (verifyKernelParams(FD, SemaRef.SYCL()))
+  // Check the function parameters for invalid parameter types and types that
+  // require special handling.
+  SmallVector<Expr *, 12> SRKPObjectAccessExprs;
+  KernelParamsChecker KAC(SemaRef.SYCL(), FD->getLocation(),
+                          SRKPObjectAccessExprs);
+  for (auto P : FD->parameters())
+    KAC.checkParameter(P);
+  if (KAC.isInvalid())
     return StmtError();
 
   // Inject an explicit specialization definition for a specialization
   // of __sycl_kernel_info parameterized by the kernel name type.
   BuildSYCLKernelInfoClassSpecializationDefn(SemaRef, SKI.getKernelNameType());
 
-  // Build the outline of the synthesized device entry point function.
-  OutlinedFunctionDecl *OFD =
-      BuildSYCLKernelEntryPointOutline(SemaRef, FD, Body);
-  assert(OFD);
-
   // Build the host kernel launch statement. An appropriate source location
   // is required to emit diagnostics.
   SourceLocation Loc = Body->getLBracLoc();
   StmtResult LaunchResult = BuildSYCLKernelLaunchCallStmt(
-      SemaRef, FD, ASTFragments.KernelLaunchIdExpr, Loc);
+      SemaRef, FD, Loc, ASTFragments.KernelLaunchIdExpr, SRKPObjectAccessExprs);
   if (LaunchResult.isInvalid())
     return StmtError();
 
-  Stmt *NewBody = new (Ctx) SYCLKernelCallStmt(Body, LaunchResult.get(), OFD);
+  // Build the outline of the synthesized device entry point function.
+  DeclResult OFD = BuildSYCLKernelEntryPointOutline(
+      SemaRef, FD, Loc, ASTFragments.ReifyKernelParamsIdExpr,
+      SRKPObjectAccessExprs, Body);
+  if (OFD.isInvalid())
+    return StmtError();
+
+  Stmt *NewBody = new (Ctx) SYCLKernelCallStmt(
+      Body, LaunchResult.get(), cast<OutlinedFunctionDecl>(OFD.get()));
 
   return NewBody;
 }
@@ -1032,8 +1299,9 @@ StmtResult BuildResolvedSYCLKernelCallStmt(
 StmtResult BuildUnresolvedSYCLKernelCallStmt(
     Sema &SemaRef, CompoundStmt *Body,
     const SemaSYCL::SYCLKernelCallStmtASTFragments &ASTFragments) {
-  return UnresolvedSYCLKernelCallStmt::Create(SemaRef.getASTContext(), Body,
-                                              ASTFragments.KernelLaunchIdExpr);
+  return UnresolvedSYCLKernelCallStmt::Create(
+      SemaRef.getASTContext(), Body, ASTFragments.KernelLaunchIdExpr,
+      ASTFragments.ReifyKernelParamsIdExpr);
 }
 
 } // unnamed namespace
@@ -1058,7 +1326,13 @@ SemaSYCL::BuildSYCLKernelCallStmtASTFragments(FunctionDecl *FD) {
   if (KernelLaunchIdER.isInvalid())
     return {};
 
-  return SemaSYCL::SYCLKernelCallStmtASTFragments{KernelLaunchIdER.get()};
+  // Perform lookup for the sycl_reify_kernel_parameters template. This
+  // lookup is not required to succeed.
+  ExprResult ReifyKernelParamsIdER =
+      BuildSYCLReifyKernelParamsIdExpr(SemaRef, FD, KernelInfoType);
+
+  return SemaSYCL::SYCLKernelCallStmtASTFragments{KernelLaunchIdER.get(),
+                                                  ReifyKernelParamsIdER.get()};
 }
 
 StmtResult SemaSYCL::BuildSYCLKernelCallStmt(
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 08fb64bb2f81ab..544e63fd44ff65 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -592,7 +592,11 @@ bool Sema::CodeSynthesisContext::isInstantiationRecord() const {
   case TypeAliasTemplateInstantiation:
   case PartialOrderingTTP:
   case SYCLKernelLaunchLookup:
+  case SYCLReifyKernelParamsLookup:
   case SYCLKernelLaunchOverloadResolution:
+  case SYCLReifyKernelParamsOverloadResolution:
+  case SYCLKernelLaunchCallbackOverloadResolution:
+  case SYCLReifyKernelParamsCallbackOverloadResolution:
     return false;
 
   // This function should never be called when Kind's value is Memoization.
@@ -1286,12 +1290,13 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
              "sycl_kernel_entry_point attribute is invalid");
       DiagFunc(SKEPAttr->getLocation(), PDiag(diag::note_sycl_runtime_defect));
       DiagFunc(SKEPAttr->getLocation(),
-               PDiag(diag::note_sycl_kernel_launch_lookup_here)
+               PDiag(diag::note_sycl_implicit_runtime_call_lookup_here)
+                   << "sycl_kernel_launch"
                    << SYCL().GetSYCLKernelInfoClassSpecializationType(
                           SKEPAttr->getKernelName()));
       break;
     }
-    case CodeSynthesisContext::SYCLKernelLaunchOverloadResolution: {
+    case CodeSynthesisContext::SYCLReifyKernelParamsLookup: {
       const auto *SKEPAttr =
           Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
       assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
@@ -1299,9 +1304,74 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
              "sycl_kernel_entry_point attribute is invalid");
       DiagFunc(SKEPAttr->getLocation(), PDiag(diag::note_sycl_runtime_defect));
       DiagFunc(SKEPAttr->getLocation(),
-               PDiag(diag::note_sycl_kernel_launch_overload_resolution_here)
+               PDiag(diag::note_sycl_implicit_runtime_call_lookup_here)
+                   << "sycl_reify_kernel_parameters"
                    << SYCL().GetSYCLKernelInfoClassSpecializationType(
-                          SKEPAttr->getKernelName())
+                          SKEPAttr->getKernelName()));
+      break;
+    }
+    case CodeSynthesisContext::SYCLKernelLaunchOverloadResolution: {
+      const auto *SKEPAttr =
+          Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
+      assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+      assert(!SKEPAttr->isInvalidAttr() &&
+             "sycl_kernel_entry_point attribute is invalid");
+      DiagFunc(SKEPAttr->getLocation(), PDiag(diag::note_sycl_runtime_defect));
+      DiagFunc(
+          SKEPAttr->getLocation(),
+          PDiag(diag::note_sycl_implicit_runtime_call_overload_resolution_here)
+              << "sycl_kernel_launch"
+              << SYCL().GetSYCLKernelInfoClassSpecializationType(
+                     SKEPAttr->getKernelName())
+              << convertCallArgsValueCategoryAndTypeToString(
+                     *this,
+                     llvm::ArrayRef(Active->CallArgs, Active->NumCallArgs)));
+      break;
+    }
+    case CodeSynthesisContext::SYCLReifyKernelParamsOverloadResolution: {
+      const auto *SKEPAttr =
+          Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
+      assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+      assert(!SKEPAttr->isInvalidAttr() &&
+             "sycl_kernel_entry_point attribute is invalid");
+      DiagFunc(SKEPAttr->getLocation(), PDiag(diag::note_sycl_runtime_defect));
+      DiagFunc(
+          SKEPAttr->getLocation(),
+          PDiag(diag::note_sycl_implicit_runtime_call_overload_resolution_here)
+              << "sycl_reify_kernel_parameters"
+              << SYCL().GetSYCLKernelInfoClassSpecializationType(
+                     SKEPAttr->getKernelName())
+              << convertCallArgsValueCategoryAndTypeToString(
+                     *this,
+                     llvm::ArrayRef(Active->CallArgs, Active->NumCallArgs)));
+      break;
+    }
+    case CodeSynthesisContext::SYCLKernelLaunchCallbackOverloadResolution: {
+      const auto *SKEPAttr =
+          Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
+      assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+      assert(!SKEPAttr->isInvalidAttr() &&
+             "sycl_kernel_entry_point attribute is invalid");
+      DiagFunc(SKEPAttr->getLocation(), PDiag(diag::note_sycl_runtime_defect));
+      DiagFunc(SKEPAttr->getLocation(),
+               PDiag(diag::note_sycl_implicit_runtime_callback_call)
+                   << "sycl_kernel_launch"
+                   << convertCallArgsValueCategoryAndTypeToString(
+                          *this, llvm::ArrayRef(Active->CallArgs,
+                                                Active->NumCallArgs)));
+      break;
+    }
+    case CodeSynthesisContext::
+        SYCLReifyKernelParamsCallbackOverloadResolution: {
+      const auto *SKEPAttr =
+          Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
+      assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+      assert(!SKEPAttr->isInvalidAttr() &&
+             "sycl_kernel_entry_point attribute is invalid");
+      DiagFunc(SKEPAttr->getLocation(), PDiag(diag::note_sycl_runtime_defect));
+      DiagFunc(SKEPAttr->getLocation(),
+               PDiag(diag::note_sycl_implicit_runtime_callback_call)
+                   << "sycl_reify_kernel_parameters"
                    << convertCallArgsValueCategoryAndTypeToString(
                           *this, llvm::ArrayRef(Active->CallArgs,
                                                 Active->NumCallArgs)));
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 352e51009cd359..691cc204abbeaf 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13738,15 +13738,22 @@ StmtResult TreeTransform<Derived>::TransformUnresolvedSYCLKernelCallStmt(
   (void)InfoType;
   assert(!InfoType.isNull());
 
-  ExprResult IdExpr = getDerived().TransformExpr(S->getKernelLaunchIdExpr());
-  if (IdExpr.isInvalid())
+  ExprResult LaunchIdExpr =
+      getDerived().TransformExpr(S->getKernelLaunchIdExpr());
+  if (LaunchIdExpr.isInvalid())
+    return StmtError();
+
+  ExprResult ReifyParamsIdExpr =
+      getDerived().TransformExpr(S->getReifyKernelParamsIdExpr());
+  if (ReifyParamsIdExpr.isInvalid())
     return StmtError();
 
   StmtResult Body = getDerived().TransformStmt(S->getOriginalStmt());
   if (Body.isInvalid())
     return StmtError();
 
-  SemaSYCL::SYCLKernelCallStmtASTFragments ASTFragments{IdExpr.get()};
+  SemaSYCL::SYCLKernelCallStmtASTFragments ASTFragments{
+      LaunchIdExpr.get(), ReifyParamsIdExpr.get()};
   StmtResult SR = SemaRef.SYCL().BuildSYCLKernelCallStmt(
       FD, cast<CompoundStmt>(Body.get()), ASTFragments);
   if (SR.isInvalid())
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 09afd26cc3e8d9..49088fcf748414 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -631,6 +631,7 @@ void ASTStmtReader::VisitUnresolvedSYCLKernelCallStmt(
 
   S->setOriginalStmt(cast<CompoundStmt>(Record.readSubStmt()));
   S->setKernelLaunchIdExpr(Record.readExpr());
+  S->setReifyKernelParamsIdExpr(Record.readExpr());
 }
 
 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index cee791fd970a4e..7630ebcf7278f5 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -717,6 +717,7 @@ void ASTStmtWriter::VisitUnresolvedSYCLKernelCallStmt(
 
   Record.AddStmt(S->getOriginalStmt());
   Record.AddStmt(S->getKernelLaunchIdExpr());
+  Record.AddStmt(S->getReifyKernelParamsIdExpr());
 
   Code = serialization::STMT_UNRESOLVED_SYCL_KERNEL_CALL;
 }
diff --git a/clang/test/ASTSYCL/ast-dump-sycl-kernel-call-stmt.cpp b/clang/test/ASTSYCL/ast-dump-sycl-kernel-call-stmt.cpp
index 15744ff6fe4f5c..668d334f7de97a 100644
--- a/clang/test/ASTSYCL/ast-dump-sycl-kernel-call-stmt.cpp
+++ b/clang/test/ASTSYCL/ast-dump-sycl-kernel-call-stmt.cpp
@@ -67,7 +67,15 @@ void skep2<KN<2>>(K<2>);
 // CHECK-NEXT: | | | |-CompoundStmt {{.*}}
 // CHECK-NEXT: | | | | `-CallExpr {{.*}} '<dependent type>'
 // CHECK-NEXT: | | | |   `-DeclRefExpr {{.*}} 'KT' lvalue ParmVar {{.*}} 'k' 'KT'
-// CHECK-NEXT: | | | `-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_kernel_launch' {{.*}}
+// CHECK-NEXT: | | | |-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_kernel_launch' {{.*}}
+// CHECK-NEXT: | | | | `-TemplateArgument type '__sycl_kernel_info<KNT>':'__sycl_kernel_info<type-parameter-0-0>'
+// CHECK-NEXT: | | | |   `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KNT>' dependent
+// CHECK-NEXT: | | | |     |-name: '__sycl_kernel_info'
+// CHECK-NEXT: | | | |     | `-ClassTemplateDecl {{.*}} referenced __sycl_kernel_info external-linkage
+// CHECK-NEXT: | | | |     `-TemplateArgument type 'KNT':'type-parameter-0-0'
+// CHECK-NEXT: | | | |       `-TemplateTypeParmType {{.*}} 'KNT' dependent depth 0 index 0
+// CHECK-NEXT: | | | |         `-TemplateTypeParm {{.*}} 'KNT'
+// CHECK-NEXT: | | | `-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_reify_kernel_parameters' empty
 // CHECK-NEXT: | | |   `-TemplateArgument type '__sycl_kernel_info<KNT>':'__sycl_kernel_info<type-parameter-0-0>'
 // CHECK-NEXT: | | |     `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KNT>' dependent
 // CHECK-NEXT: | | |       |-name: '__sycl_kernel_info'
@@ -128,7 +136,15 @@ void skep3<KN<3>>(K<3> k) {
 // CHECK-NEXT: | | | |-CompoundStmt {{.*}}
 // CHECK-NEXT: | | | | `-CallExpr {{.*}} '<dependent type>'
 // CHECK-NEXT: | | | |   `-DeclRefExpr {{.*}} 'KT' lvalue ParmVar {{.*}} 'k' 'KT'
-// CHECK-NEXT: | | | `-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_kernel_launch' {{.*}}
+// CHECK-NEXT: | | | |-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_kernel_launch' {{.*}}
+// CHECK-NEXT: | | | | `-TemplateArgument type '__sycl_kernel_info<KNT>':'__sycl_kernel_info<type-parameter-0-0>'
+// CHECK-NEXT: | | | |   `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KNT>' dependent
+// CHECK-NEXT: | | | |     |-name: '__sycl_kernel_info'
+// CHECK-NEXT: | | | |     | `-ClassTemplateDecl {{.*}} referenced __sycl_kernel_info external-linkage
+// CHECK-NEXT: | | | |     `-TemplateArgument type 'KNT':'type-parameter-0-0'
+// CHECK-NEXT: | | | |       `-TemplateTypeParmType {{.*}} 'KNT' dependent depth 0 index 0
+// CHECK-NEXT: | | | |         `-TemplateTypeParm {{.*}} 'KNT'
+// CHECK-NEXT: | | | `-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_reify_kernel_parameters' empty
 // CHECK-NEXT: | | |   `-TemplateArgument type '__sycl_kernel_info<KNT>':'__sycl_kernel_info<type-parameter-0-0>'
 // CHECK-NEXT: | | |     `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KNT>' dependent
 // CHECK-NEXT: | | |       |-name: '__sycl_kernel_info'
@@ -407,7 +423,15 @@ void foo() {
 // CHECK-NEXT: | | | | |   |-DeclRefExpr {{.*}} 'KT' lvalue ParmVar {{.*}} 'k' 'KT'
 // CHECK-NEXT: | | | | |   |-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'a' 'int'
 // CHECK-NEXT: | | | | |   `-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'b' 'int'
-// CHECK-NEXT: | | | | `-UnresolvedMemberExpr {{.*}} '<bound member function type>' lvalue
+// CHECK-NEXT: | | | | |-UnresolvedMemberExpr {{.*}} '<bound member function type>' lvalue
+// CHECK-NEXT: | | | | `-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_reify_kernel_parameters' empty
+// CHECK-NEXT: | | | |   `-TemplateArgument type '__sycl_kernel_info<KNT>':'__sycl_kernel_info<type-parameter-0-0>'
+// CHECK-NEXT: | | | |     `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KNT>' dependent
+// CHECK-NEXT: | | | |       |-name: '__sycl_kernel_info'
+// CHECK-NEXT: | | | |       | `-ClassTemplateDecl {{.*}} referenced __sycl_kernel_info external-linkage
+// CHECK-NEXT: | | | |       `-TemplateArgument type 'KNT':'type-parameter-0-0'
+// CHECK-NEXT: | | | |         `-TemplateTypeParmType {{.*}} 'KNT' dependent depth 0 index 0
+// CHECK-NEXT: | | | |           `-TemplateTypeParm {{.*}} 'KNT'
 // CHECK-NEXT: | | | `-SYCLKernelEntryPointAttr {{.*}} KNT
 // CHECK-NEXT: | | `-CXXMethodDecl {{.*}} used skep9 {{.*}} implicit_instantiation implicit-inline instantiated_from 0x{{.*}}
 // CHECK-NEXT: | |   |-TemplateArgument type 'KN<9>'
diff --git a/clang/test/ASTSYCL/ast-dump-sycl-reified-kernel-parameter.cpp b/clang/test/ASTSYCL/ast-dump-sycl-reified-kernel-parameter.cpp
new file mode 100644
index 00000000000000..f916064e534328
--- /dev/null
+++ b/clang/test/ASTSYCL/ast-dump-sycl-reified-kernel-parameter.cpp
@@ -0,0 +1,153 @@
+// Tests without serialization:
+// RUN: %clang_cc1 -std=c++17 -triple spirv64-unknown-unknown -fsycl-is-device \
+// RUN:   -ast-dump %s \
+// RUN:   | FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -fsycl-is-host \
+// RUN:   -ast-dump %s \
+// RUN:   | FileCheck %s
+//
+// Tests with serialization:
+// RUN: %clang_cc1 -std=c++17 -triple spirv64-unknown-unknown -fsycl-is-device \
+// RUN:   -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -std=c++17 -triple spirv64-unknown-unknown -fsycl-is-device \
+// RUN:   -include-pch %t -ast-dump-all /dev/null \
+// RUN:   | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
+// RUN:   | FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -fsycl-is-host \
+// RUN:   -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -std=c++17 -triple x86_64-unknown-unknown -fsycl-is-host \
+// RUN:   -include-pch %t -ast-dump-all /dev/null \
+// RUN:   | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
+// RUN:   | FileCheck %s
+
+// These tests validate the AST produced for functions declared with the
+// sycl_kernel_entry_point attribute when one of the function parameters has a
+// type declared with the sycl_reified_kernel_parameter attribute.
+
+// CHECK: TranslationUnitDecl {{.*}}
+
+template <typename KI, typename... Ts>
+auto sycl_kernel_launch(Ts...) {
+  return [](auto&&... special_subobjects) { };
+}
+
+template <typename KI, typename... Ts>
+auto sycl_reify_kernel_parameters(Ts...) {
+  return [](auto&&... special_subobjects) { };
+}
+
+template <typename KN, typename KT>
+[[clang::sycl_kernel_entry_point(KN)]] void skep(const KT &k) {
+  k();
+}
+
+// A unique kernel name type is required for each declared kernel entry point.
+template<int> struct KN;
+
+// A type that requires reification as a kernel parameter.
+struct [[clang::sycl_reified_kernel_parameter]] SRKP {};
+struct SRKPDerived : SRKP {};
+struct SRKPArray {
+  SRKP a[2];
+};
+
+// A kernel object type with subobjects that require reification as a kernel
+// parameter.
+struct K : SRKP {
+  void operator()() const {}
+  SRKP srkp;
+  SRKPDerived srkp_derived;
+  SRKPArray skrp_array;
+};
+
+template void skep<KN<1>>(const K&);
+
+// CHECK:      |-FunctionTemplateDecl {{.*}} skep{{.*}}
+// CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 KN
+// CHECK-NEXT: | |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 1 KT
+// CHECK-NEXT: | |-FunctionDecl {{.*}} skep 'void (const KT &)'
+// CHECK-NEXT: | | |-ParmVarDecl {{.*}} referenced k 'const KT &'
+// CHECK-NEXT: | | |-UnresolvedSYCLKernelCallStmt {{.*}}
+// CHECK-NEXT: | | | |-CompoundStmt {{.*}}
+// CHECK-NEXT: | | | | `-CallExpr {{.*}} '<dependent type>'
+// CHECK-NEXT: | | | |  `-DeclRefExpr {{.*}} 'const KT' lvalue ParmVar {{.*}} 'k' 'const KT &'
+// CHECK-NEXT: | | | |-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_kernel_launch' {{.*}}
+// CHECK-NEXT: | | | | `-TemplateArgument type '__sycl_kernel_info<KN>':'__sycl_kernel_info<type-parameter-0-0>'
+// CHECK-NEXT: | | | |   `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KN>' dependent
+// CHECK-NEXT: | | | |     |-name: '__sycl_kernel_info'
+// CHECK-NEXT: | | | |     | `-ClassTemplateDecl {{.*}} referenced __sycl_kernel_info external-linkage
+// CHECK-NEXT: | | | |     `-TemplateArgument type 'KN':'type-parameter-0-0'
+// CHECK-NEXT: | | | |       `-TemplateTypeParmType {{.*}} 'KN' dependent depth 0 index 0
+// CHECK-NEXT: | | | |         `-TemplateTypeParm {{.*}} 'KN'
+// CHECK-NEXT: | | | `-UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (ADL) = 'sycl_reify_kernel_parameters' {{.*}}
+// CHECK-NEXT: | | |   `-TemplateArgument type '__sycl_kernel_info<KN>':'__sycl_kernel_info<type-parameter-0-0>'
+// CHECK-NEXT: | | |     `-TemplateSpecializationType {{.*}} '__sycl_kernel_info<KN>' dependent
+// CHECK-NEXT: | | |       |-name: '__sycl_kernel_info'
+// CHECK-NEXT: | | |       | `-ClassTemplateDecl {{.*}} referenced __sycl_kernel_info external-linkage
+// CHECK-NEXT: | | |       `-TemplateArgument type 'KN':'type-parameter-0-0'
+// CHECK-NEXT: | | |         `-TemplateTypeParmType {{.*}} 'KN' dependent depth 0 index 0
+// CHECK-NEXT: | | |           `-TemplateTypeParm {{.*}} 'KN'
+// CHECK-NEXT: | | `-SYCLKernelEntryPointAttr {{.*}} KN
+// CHECK-NEXT: | `-FunctionDecl {{.*}} skep {{.*}} explicit_instantiation_definition instantiated_from {{.*}}
+// CHECK-NEXT: |   |-TemplateArgument type 'KN<1>'
+// CHECK-NEXT: |   | `-RecordType {{.*}} 'KN<1>' canonical
+// CHECK-NEXT: |   |   `-ClassTemplateSpecialization {{.*}} 'KN'
+// CHECK-NEXT: |   |-TemplateArgument type '{{.*}}'
+// CHECK-NEXT: |   | `-RecordType {{.*}} canonical
+// CHECK-NEXT: |   |   `-CXXRecord {{.*}}
+// CHECK-NEXT: |   |-ParmVarDecl {{.*}} used k {{.*}}
+// CHECK-NEXT: |   |-SYCLKernelCallStmt {{.*}}
+// CHECK-NEXT: |   | |-CompoundStmt {{.*}}
+// CHECK-NEXT: |   | | `-CXXOperatorCallExpr {{.*}} 'void' '()'
+// CHECK-NEXT: |   | |   |-ImplicitCastExpr {{.*}} 'void (*)() const' <FunctionToPointerDecay>
+// CHECK-NEXT: |   | |   | `-DeclRefExpr {{.*}} 'void () const' lvalue CXXMethod {{.*}} 'operator()' 'void () const'
+// CHECK-NEXT: |   | |   `-DeclRefExpr {{.*}} lvalue ParmVar {{.*}} 'k' {{.*}}
+// CHECK-NEXT: |   | |-CompoundStmt {{.*}}
+// CHECK-NEXT: |   | | `-ExprWithCleanups {{.*}} 'void'
+// CHECK-NEXT: |   | |   `-CXXOperatorCallExpr {{.*}} 'void' '()'
+// CHECK-NEXT: |   | |     |-ImplicitCastExpr {{.*}} 'void (*)(SRKP &, SRKP &, SRKP &) const' <FunctionToPointerDecay>
+// CHECK-NEXT: |   | |     | `-DeclRefExpr {{.*}} 'void (SRKP &, SRKP &, SRKP &) const' lvalue CXXMethod {{.*}} 'operator()' 'void (SRKP &, SRKP &, SRKP &) const' {{.*}}
+// CHECK-NEXT: |   | |     |-ImplicitCastExpr {{.*}} 'const (lambda at {{.*}})' lvalue <NoOp>
+// CHECK-NEXT: |   | |     | `-MaterializeTemporaryExpr {{.*}} '(lambda at {{.*}})' lvalue
+// CHECK-NEXT: |   | |     |   `-CallExpr {{.*}} '(lambda at {{.*}})'
+// CHECK-NEXT: |   | |     |     |-ImplicitCastExpr {{.*}} '(lambda at {{.*}}) (*)(K)' <FunctionToPointerDecay>
+// CHECK-NEXT: |   | |     |     | `-DeclRefExpr {{.*}} '(lambda at {{.*}}) (K)' lvalue Function {{.*}} 'sycl_kernel_launch' {{.*}}
+// CHECK-NEXT: |   | |     |     `-CXXConstructExpr {{.*}} 'K' 'void (const K &) noexcept'
+// CHECK-NEXT: |   | |     |       `-DeclRefExpr {{.*}} 'const K' lvalue ParmVar {{.*}} 'k' 'const K &'
+// CHECK-NEXT: |   | |     |-ImplicitCastExpr {{.*}} 'SRKP' lvalue <DerivedToBase (SRKP)>
+// CHECK-NEXT: |   | |     | `-DeclRefExpr {{.*}} 'const K' lvalue ParmVar {{.*}} 'k' 'const K &'
+// CHECK-NEXT: |   | |     |-MemberExpr {{.*}} 'SRKP' lvalue .srkp {{.*}}
+// CHECK-NEXT: |   | |     | `-DeclRefExpr {{.*}} 'const K' lvalue ParmVar {{.*}} 'k' 'const K &'
+// CHECK-NEXT: |   | |     `-ImplicitCastExpr {{.*}} 'SRKP' lvalue <DerivedToBase (SRKP)>
+// CHECK-NEXT: |   | |       `-MemberExpr {{.*}} 'SRKPDerived' lvalue .srkp_derived {{.*}}
+// CHECK-NEXT: |   | |         `-DeclRefExpr {{.*}} 'const K' lvalue ParmVar {{.*}} 'k' 'const K &'
+// CHECK-NEXT: |   | `-OutlinedFunctionDecl {{.*}}
+// CHECK-NEXT: |   |   |-ImplicitParamDecl {{.*}} implicit used k 'const K'
+// CHECK-NEXT: |   |   `-CompoundStmt {{.*}}
+// CHECK-NEXT: |   |     |-CompoundStmt {{.*}}
+// CHECK-NEXT: |   |     | `-ExprWithCleanups {{.*}} 'void'
+// CHECK-NEXT: |   |     |   `-CXXOperatorCallExpr {{.*}} 'void' '()'
+// CHECK-NEXT: |   |     |     |-ImplicitCastExpr {{.*}} 'void (*)(const K &, const SRKP &, const SRKPDerived &) const' <FunctionToPointerDecay>
+// CHECK-NEXT: |   |     |     | `-DeclRefExpr {{.*}} 'void (const K &, const SRKP &, const SRKPDerived &) const' lvalue CXXMethod {{.*}} 'operator()' 'void (const K &, const SRKP &, const SRKPDerived &) const' {{.*}}
+// CHECK-NEXT: |   |     |     |-ImplicitCastExpr {{.*}} 'const (lambda at {{.*}})' lvalue <NoOp>
+// CHECK-NEXT: |   |     |     | `-MaterializeTemporaryExpr {{.*}} '(lambda at {{.*}})' lvalue
+// CHECK-NEXT: |   |     |     |   `-CallExpr {{.*}} '(lambda at {{.*}})'
+// CHECK-NEXT: |   |     |     |     |-ImplicitCastExpr {{.*}} '(lambda at {{.*}}) (*)(K)' <FunctionToPointerDecay>
+// CHECK-NEXT: |   |     |     |     | `-DeclRefExpr {{.*}} '(lambda at {{.*}}) (K)' lvalue Function {{.*}} 'sycl_reify_kernel_parameters' {{.*}}
+// CHECK-NEXT: |   |     |     |     `-CXXConstructExpr {{.*}} 'K' 'void (const K &) noexcept'
+// CHECK-NEXT: |   |     |     |       `-DeclRefExpr {{.*}} 'const K' lvalue ImplicitParam {{.*}} 'k' 'const K'
+// CHECK-NEXT: |   |     |     |-DeclRefExpr {{.*}} 'const K' lvalue ImplicitParam {{.*}} 'k' 'const K'
+// CHECK-NEXT: |   |     |     |-MemberExpr {{.*}} 'const SRKP' lvalue .srkp {{.*}}
+// CHECK-NEXT: |   |     |     | `-DeclRefExpr {{.*}} 'const K' lvalue ImplicitParam {{.*}} 'k' 'const K'
+// CHECK-NEXT: |   |     |     `-MemberExpr {{.*}} 'const SRKPDerived' lvalue .srkp_derived {{.*}}
+// CHECK-NEXT: |   |     |       `-DeclRefExpr {{.*}} 'const K' lvalue ImplicitParam {{.*}} 'k' 'const K'
+// CHECK-NEXT: |   |     `-CompoundStmt {{.*}}
+// CHECK-NEXT: |   |       `-CXXOperatorCallExpr {{.*}} 'void' '()'
+// CHECK-NEXT: |   |         |-ImplicitCastExpr {{.*}} 'void (*)() const' <FunctionToPointerDecay>
+// CHECK-NEXT: |   |         | `-DeclRefExpr {{.*}} 'void () const' lvalue CXXMethod {{.*}} 'operator()' 'void () const'
+// CHECK-NEXT: |   |         `-DeclRefExpr {{.*}} 'const K' lvalue ImplicitParam {{.*}} 'k' 'const K'
+// CHECK-NEXT: |   `-SYCLKernelEntryPointAttr {{.*}} struct KN<1>
+
+
+void the_end() {}
+// CHECK:      `-FunctionDecl {{.*}} the_end 'void ()' external-linkage
diff --git a/clang/test/CodeGenSYCL/reify-kernel-parameters.cpp b/clang/test/CodeGenSYCL/reify-kernel-parameters.cpp
new file mode 100644
index 00000000000000..de5b17e51fe7a4
--- /dev/null
+++ b/clang/test/CodeGenSYCL/reify-kernel-parameters.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsycl-is-host -emit-llvm -triple x86_64-unknown-linux-gnu -std=c++17 %s -o - | FileCheck --check-prefixes=CHECK-HOST %s
+
+// A unique kernel name type is required for each declared kernel entry point.
+template<int> struct KN;
+
+struct [[clang::sycl_reified_kernel_parameter]] EmptySpecial {
+  int data;
+};
+
+template<typename T>
+struct Wrapper {
+ T data;
+ int *data1;
+};
+
+template <typename KernelInfo, typename... Ts>
+auto sycl_kernel_launch(Ts&&...) {
+    return [](auto&&... special_subobjects) { };
+}
+
+template <typename KernelInfo, typename... Ts>
+auto sycl_reify_kernel_parameters(Ts&&...) {
+    return [](auto&&... special_subobjects) { };
+}
+
+
+template <typename KN, typename KT>
+[[clang::sycl_kernel_entry_point(KN)]]
+void kernel_entry_point(KT Kernel) {
+  Kernel();
+}
+
+void case1() {
+    Wrapper<EmptySpecial> KernelArg;
+    kernel_entry_point<KN<0>>([KernelArg](){});
+}
+
+struct [[clang::sycl_reified_kernel_parameter]] SpecialBase {
+  int data;
+};
+
+struct DerivedFromSpecial : SpecialBase {
+  int extra;
+};
+
+void case2() {
+    DerivedFromSpecial DFS;
+    kernel_entry_point<KN<1>>([DFS](){});
+}
+
+// CHECK-HOST-LABEL:   define internal void @_Z18kernel_entry_pointI2KNILi0EEZ5case1vEUlvE_EvT0_(
+// CHECK-HOST-SAME:      i32 [[KERNEL_COERCE0:%.*]], ptr [[KERNEL_COERCE1:%.*]])
+// CHECK-HOST:         entry:
+// CHECK-HOST:          call void @_Z18sycl_kernel_launchI18__sycl_kernel_infoI2KNILi0EEEJRZ5case1vEUlvE_EEDaDpOT0_(ptr noundef nonnull align 8 dereferenceable(16) %Kernel)
+// CHECK-HOST-NEXT:     %2 = getelementptr inbounds nuw %class.anon, ptr %Kernel, i32 0, i32 0
+// CHECK-HOST-NEXT:     %data = getelementptr inbounds nuw %struct.Wrapper, ptr %2, i32 0, i32 0
+// CHECK-HOST-NEXT:     call void @_ZZ18sycl_kernel_launchI18__sycl_kernel_infoI2KNILi0EEEJRZ5case1vEUlvE_EEDaDpOT0_ENKUlDpOT_E_clIJR12EmptySpecialEEEDaSB_(
+// CHECK-HOST-SAME:       ptr noundef nonnull align 1 dereferenceable(1) %ref.tmp, ptr noundef nonnull align 4 dereferenceable(4) %data)
+// CHECK-HOST-NEXT:     ret void
+
+// Test that a class inheriting from a sycl_reified_kernel_parameter type
+// accesses the SpecialBase via DerivedToBase cast.
+
+// CHECK-HOST-LABEL:   define internal void @_Z18kernel_entry_pointI2KNILi1EEZ5case2vEUlvE_EvT0_(
+// CHECK-HOST-SAME:      i64 %Kernel.coerce)
+// CHECK-HOST:         entry:
+// CHECK-HOST:          call void @_Z18sycl_kernel_launchI18__sycl_kernel_infoI2KNILi1EEEJRZ5case2vEUlvE_EEDaDpOT0_(ptr noundef nonnull align 4 dereferenceable(8) %Kernel)
+// CHECK-HOST:          %0 = getelementptr inbounds nuw %class.anon.0, ptr %Kernel, i32 0, i32 0
+// CHECK-HOST-NEXT:     call void @_ZZ18sycl_kernel_launchI18__sycl_kernel_infoI2KNILi1EEEJRZ5case2vEUlvE_EEDaDpOT0_ENKUlDpOT_E_clIJR11SpecialBaseEEEDaSB_(
+// CHECK-HOST-SAME:       ptr noundef nonnull align 1 dereferenceable(1) %ref.tmp, ptr noundef nonnull align 4 dereferenceable(4) %0)
+// CHECK-HOST-NEXT:     ret void
diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 452406bcaba9dd..7614b2720fe683 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -202,6 +202,7 @@
 // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
 // CHECK-NEXT: SYCLExternal (SubjectMatchRule_function)
 // CHECK-NEXT: SYCLKernelEntryPoint (SubjectMatchRule_function)
+// CHECK-NEXT: SYCLReifiedKernelParameter (SubjectMatchRule_record)
 // CHECK-NEXT: SYCLSpecialClass (SubjectMatchRule_record)
 // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
diff --git a/clang/test/SemaSYCL/sycl-kernel-launch.cpp b/clang/test/SemaSYCL/sycl-kernel-launch.cpp
index 50a185cb336ccf..2ebe01a2230d5e 100644
--- a/clang/test/SemaSYCL/sycl-kernel-launch.cpp
+++ b/clang/test/SemaSYCL/sycl-kernel-launch.cpp
@@ -220,6 +220,20 @@ namespace ok13 {
   template void skep<KN<13>>(KT<13>, nested::S13);
 }
 
+// sycl_kernel_launch returns a callable.
+namespace ok14 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts...) {
+    return []{};
+  }
+  template<typename KN, typename KT>
+  [[clang::sycl_kernel_entry_point(KN)]]
+  void skep(KT k) {
+    k();
+  }
+  template void skep<KN<14>>(KT<14>);
+}
+
 
 ////////////////////////////////////////////////////////////////////////////////
 // Invalid declarations.
@@ -558,3 +572,41 @@ namespace bad18 {
   // expected-note at +1 {{in instantiation of function template specialization 'bad18::skep<BADKN<18>, BADKT<18>>' requested here}}
   template void skep<BADKN<18>>(BADKT<18>);
 }
+
+// sycl_kernel_launch returns non-void, but not a callable.
+namespace bad19 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts...) {
+    return 19;
+  }
+  // expected-error at +5 {{called object type 'int' is not a function or function pointer}}
+  // expected-note at +3  {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +2  {{in implicit call to the callable returned by 'sycl_kernel_launch' with function arguments () required here}}
+  template<typename KN, typename KT>
+  [[clang::sycl_kernel_entry_point(KN)]]
+  void skep(KT k) {
+    k();
+  }
+  // expected-note at +1 {{in instantiation of function template specialization 'bad19::skep<BADKN<19>, BADKT<19>>' requested here}}
+  template void skep<BADKN<19>>(BADKT<19>);
+}
+
+// sycl_kernel_launch returns a callable, but overload resolution fails.
+namespace bad20 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts...) {
+    // expected-note at +2   {{candidate function not viable: requires 1 argument, but 0 were provided}}
+    // expected-note at +1   {{conversion candidate of type 'void (*)(int)'}}
+    return [](int){};
+  }
+  // expected-error-re at +5 {{no matching function for call to object of type '(lambda at {{.*}})'}}
+  // expected-note at +3     {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +2     {{in implicit call to the callable returned by 'sycl_kernel_launch' with function arguments () required here}}
+  template<typename KN, typename KT>
+  [[clang::sycl_kernel_entry_point(KN)]]
+  void skep(KT k) {
+    k();
+  }
+  // expected-note at +1 {{in instantiation of function template specialization 'bad20::skep<BADKN<20>, BADKT<20>>' requested here}}
+  template void skep<BADKN<20>>(BADKT<20>);
+}
diff --git a/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-appertainment.cpp b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-appertainment.cpp
new file mode 100644
index 00000000000000..daf3c277ef4437
--- /dev/null
+++ b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-appertainment.cpp
@@ -0,0 +1,238 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -fsycl-is-host -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++17 -fsyntax-only -fsycl-is-device -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -fsyntax-only -fsycl-is-host -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++20 -fsyntax-only -fsycl-is-device -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -fsycl-is-host -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++23 -fsyntax-only -fsycl-is-device -fcxx-exceptions -verify %s
+
+// These tests validate appertainment for the sycl_reified_kernel_parameter
+// attribute.
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Ignored declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+// Class declaration with GNU attribute spelling.
+// expected-warning at +1 {{unknown attribute 'sycl_reified_kernel_parameter' ignored}}
+struct __attribute__((sycl_reified_kernel_parameter)) ignored1 {};
+
+// Class declaration with GNU attribute spelling.
+// expected-warning at +1 {{unknown attribute 'sycl_reified_kernel_parameter' ignored}}
+struct ignored2 {} __attribute__((sycl_reified_kernel_parameter));
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Valid declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+// Class declaration at global scope.
+struct [[clang::sycl_reified_kernel_parameter]] ok1;
+
+// Class definition at global scope.
+struct [[clang::sycl_reified_kernel_parameter]] ok2 {};
+
+// Class redeclaration at global scope.
+struct [[clang::sycl_reified_kernel_parameter]] ok3;
+struct [[clang::sycl_reified_kernel_parameter]] ok3 {};
+
+// Class redeclaration after declaration without the attribute at global scope.
+struct ok4;
+struct [[clang::sycl_reified_kernel_parameter]] ok4 {};
+
+// Class definition without the attribute after a declaration with it at global
+// scope.
+struct [[clang::sycl_reified_kernel_parameter]] ok5;
+struct ok5 {};
+
+// Class template definition at global scope.
+template<typename>
+struct [[clang::sycl_reified_kernel_parameter]] ok6 {};
+
+// Class template partial specialization at global scope.
+template<typename>
+struct ok7;
+template<typename T>
+struct [[clang::sycl_reified_kernel_parameter]] ok7<T*> {};
+
+// Class template explicit specialization at global scope.
+template<typename>
+struct ok8;
+template<>
+struct [[clang::sycl_reified_kernel_parameter]] ok8<int> {};
+
+// Class template explicit instantiation at global scope.
+template<typename>
+struct [[clang::sycl_reified_kernel_parameter]] ok9 {};
+template struct ok9<int>;
+
+// Class declaration at namespace scope.
+namespace NS10 {
+struct [[clang::sycl_reified_kernel_parameter]] ok10 {};
+}
+
+// Member class declaration.
+struct S11 {
+  struct [[clang::sycl_reified_kernel_parameter]] ok11 {};
+};
+
+// Dependent member class declaration.
+template<typename T>
+struct S12 {
+  struct [[clang::sycl_reified_kernel_parameter]] ok12 { T dm; };
+};
+template struct S12<int>::ok12;
+
+// Member class template declaration.
+struct S13 {
+  template<typename T>
+  struct [[clang::sycl_reified_kernel_parameter]] ok13 { T dm; };
+};
+template struct S13::ok13<int>;
+
+#if __cplusplus >= 202002L
+// Constrained class template declaration.
+template<typename>
+struct ok14;
+template<typename T>
+requires (T{} == 0)
+struct [[clang::sycl_reified_kernel_parameter]] ok14<T> {};
+template struct ok14<int>;
+
+// Constrained member class template declaration.
+struct S15 {
+  template<typename>
+  struct ok15;
+  template<typename T>
+  requires (T{} == 0)
+  struct [[clang::sycl_reified_kernel_parameter]] ok15<T> {};
+};
+template struct S15::ok15<int>;
+#endif
+
+// Union declaration at global scope.
+union [[clang::sycl_reified_kernel_parameter]] ok16 {};
+
+// Defining typedef declaration.
+typedef struct [[clang::sycl_reified_kernel_parameter]] ok17 {} ok17;
+
+// Defining type alias declaration.
+using ok18 = struct [[clang::sycl_reified_kernel_parameter]] ok18 {};
+
+// Declaration with other standard attributes.
+struct [[clang::sycl_reified_kernel_parameter]] [[deprecated]] [[maybe_unused]] [[nodiscard]] ok19 {};
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Invalid declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+// Empty declaration.
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+[[clang::sycl_reified_kernel_parameter]];
+
+// Class redeclaration after definition without the attribute at global scope.
+// expected-note at +1 {{previous definition is here}}
+struct bad1 {};
+// expected-warning at +1 {{attribute declaration must precede definition}}
+struct [[clang::sycl_reified_kernel_parameter]] bad1;
+
+// Typedef declaration.
+struct B2;
+// expected-error at +1 {{'clang::sycl_reified_kernel_parameter' attribute cannot be applied to types}}
+typedef B2 [[clang::sycl_reified_kernel_parameter]] bad2;
+
+// Type alias declaration.
+struct B3;
+// expected-error at +1 {{'clang::sycl_reified_kernel_parameter' attribute cannot be applied to types}}
+using bad3 = [[clang::sycl_reified_kernel_parameter]] B3;
+
+// Enum declaration.
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+enum [[clang::sycl_reified_kernel_parameter]] bad4 {};
+
+// Function declaration.
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+[[clang::sycl_reified_kernel_parameter]]
+void bad5();
+
+// Variable declaration.
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+[[clang::sycl_reified_kernel_parameter]]
+int bad6;
+
+#if __cplusplus >= 202002L
+// Concept declaration.
+// expected-warning at +2 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+template<typename>
+concept bad7 [[clang::sycl_reified_kernel_parameter]] = true;
+#endif
+
+// Data member declaration.
+struct B8 {
+  // expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+  [[clang::sycl_reified_kernel_parameter]]
+  int bad8;
+};
+
+// Member function declaration.
+struct B9 {
+  // expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+  [[clang::sycl_reified_kernel_parameter]]
+  void bad9();
+};
+
+// Member enum declaration.
+struct B10 {
+  // expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+  enum [[clang::sycl_reified_kernel_parameter]] bad10 {};
+};
+
+// Namespace declaration.
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+namespace [[clang::sycl_reified_kernel_parameter]] bad11 {}
+
+// Enumerator declaration.
+enum B12 {
+  // expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+  bad12 [[clang::sycl_reified_kernel_parameter]]
+};
+
+// Function parameter declaration.
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+void b13(int bad13 [[clang::sycl_reified_kernel_parameter]]);
+
+// Function template parameter declaration.
+// FIXME: Clang currently ignores attributes that appear in template parameters
+// FIXME: and the C++ standard is unclear regarding whether such attributes are
+// FIXME: permitted. P3324 (Attributes for namespace aliases, template
+// FIXME: parameters, and lambda captures) seeks to clarify the situation.
+// FIXME-expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+template<int bad14 [[clang::sycl_reified_kernel_parameter]]>
+void b14();
+
+// Constructor declaration.
+struct B15 {
+  // expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+  [[clang::sycl_reified_kernel_parameter]]
+  B15();
+};
+
+// Destructor declaration.
+struct B16 {
+  // expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute only applies to classes}}
+  [[clang::sycl_reified_kernel_parameter]]
+  ~B16();
+};
+
+// Statement.
+void b17() {
+  // expected-error at +1 {{'clang::sycl_reified_kernel_parameter' attribute cannot be applied to a statement}}
+  [[clang::sycl_reified_kernel_parameter]];
+}
+
+// Empty declaration at class scope.
+struct B18 {
+  // expected-warning at +1 {{declaration does not declare anything}}
+  [[clang::sycl_reified_kernel_parameter]];
+};
diff --git a/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-grammar.cpp b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-grammar.cpp
new file mode 100644
index 00000000000000..fbda67b82b1c91
--- /dev/null
+++ b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-grammar.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -fsycl-is-host -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++17 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -fsyntax-only -fsycl-is-host -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++20 -fsyntax-only -fsycl-is-device -verify %s
+
+// These tests validate parsing of the sycl_reified_kernel_parameter
+// attribute.
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Valid declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+struct [[clang::sycl_reified_kernel_parameter]] ok1;
+
+struct [[clang::sycl_reified_kernel_parameter()]] ok2;
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Invalid declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+// expected-error at +1 {{'clang::sycl_reified_kernel_parameter' attribute takes no arguments}}
+struct [[clang::sycl_reified_kernel_parameter(1)]] bad1;
+
+// expected-error at +1 {{'clang::sycl_reified_kernel_parameter' attribute takes no arguments}}
+struct [[clang::sycl_reified_kernel_parameter("2")]] bad2;
+
+// expected-error at +1 {{expected '(' for function-style cast or type construction}}
+struct [[clang::sycl_reified_kernel_parameter(int,)]] bad3;
+
+// expected-error at +1 {{expected '(' for function-style cast or type construction}}
+struct [[clang::sycl_reified_kernel_parameter(int, 4)]] bad4;
+
+// expected-error at +1 {{use of undeclared identifier 'X'}}
+struct [[clang::sycl_reified_kernel_parameter(X)]] bad5;
+
+// expected-note at +1 {{declared here}}
+struct B6;
+// expected-error at +1 {{'B6' does not refer to a value}}
+struct [[clang::sycl_reified_kernel_parameter(B6)]] bad6;
+
+constexpr int b7 = 7;
+// expected-error at +1 {{'clang::sycl_reified_kernel_parameter' attribute takes no arguments}}
+struct [[clang::sycl_reified_kernel_parameter(b7)]] bad7;
diff --git a/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-ignored.cpp b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-ignored.cpp
new file mode 100644
index 00000000000000..b0afc35e01e792
--- /dev/null
+++ b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-ignored.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -verify %s
+
+// These tests validate that the sycl_reified_kernel_parameter attribute is
+// ignored when SYCL support is not enabled.
+
+// expected-warning at +1 {{'clang::sycl_reified_kernel_parameter' attribute ignored}}
+struct [[clang::sycl_reified_kernel_parameter]] ok1 {};
+
+// expected-warning at +2 {{'clang::sycl_reified_kernel_parameter' attribute ignored}}
+template<typename>
+struct [[clang::sycl_reified_kernel_parameter]] ok2 {};
diff --git a/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-module.cpp b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-module.cpp
new file mode 100644
index 00000000000000..9a2ab0dd1e58e3
--- /dev/null
+++ b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-module.cpp
@@ -0,0 +1,138 @@
+// Test that the sycl_reified_kernel_parameter attribute is appropriately
+// handled across module boundaries.
+
+// This test exercises ODR violations involving classes inconsistently
+// declared with the sycl_reified_kernel_parameter attribute across modules.
+// The resulting behavior depends on the order in which modules are imported.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:   -std=c++17 -fsycl-is-host %t/test1.cpp -verify
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:   -std=c++17 -fsycl-is-device %t/test1.cpp -verify
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:   -std=c++17 -fsycl-is-host %t/test2.cpp -verify
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN:   -std=c++17 -fsycl-is-device %t/test2.cpp -verify
+
+#--- module.modulemap
+module M1 { header "m1.h" }
+module M2 { header "m2.h" }
+
+
+#--- common.h
+struct [[clang::sycl_reified_kernel_parameter]] SRKP {};
+
+
+#--- m1.h
+#include "common.h"
+
+struct [[clang::sycl_reified_kernel_parameter]] SRKP1 {};
+struct SRKP2 {};
+
+
+#--- m2.h
+#include "common.h"
+
+struct SRKP1 {};
+struct [[clang::sycl_reified_kernel_parameter]] SRKP2 {};
+
+
+#--- test.h
+namespace ns {
+template<typename KI, typename... Ts>
+auto sycl_kernel_launch(Ts&...) {
+  return [](SRKP& srkp) {};
+}
+template<typename KI, typename... Ts>
+auto sycl_reify_kernel_parameters(Ts&...) {
+  return [](SRKP& srkp) {};
+}
+template<typename KN, typename KT>
+[[clang::sycl_kernel_entry_point(KN)]]
+void skep(KT k) {
+  k();
+}
+void test(SRKP srkp) {
+  skep<struct KN>([=] { (void)srkp; });
+}
+} // ns1 namespace
+
+namespace ns1 {
+template<typename KI, typename... Ts>
+// expected {{candidate function}} for test1.cpp
+auto sycl_kernel_launch(Ts&...) {
+  return [](SRKP1& srkp) {};
+}
+template<typename KI, typename... Ts>
+auto sycl_reify_kernel_parameters(Ts&...) {
+  return [](SRKP1& srkp) {};
+}
+template<typename KN, typename KT>
+// expected {{in implicit call to 'sycl_kernel_launch' with template argument}} for test1.cpp
+// expected {{this indicates a problem with the SYCL runtime header files}} for test1.cpp
+[[clang::sycl_kernel_entry_point(KN)]]
+// expected {{no matching function for call to 'sycl_kernel_launch'}} for test1.cpp.
+void skep(KT k) {
+  k();
+}
+void test1(SRKP1 srkp) {
+  // expected {{in instantiation of function template specialization 'ns1::skep<KN, (lambda at {{.*}})>' requested here}} for test1.cpp
+  skep<struct KN>([=] { (void)srkp; });
+}
+} // ns1 namespace
+
+namespace ns2 {
+template<typename KI, typename... Ts>
+// expected {{candidate function}} for test1.cpp
+auto sycl_kernel_launch(Ts&...) {
+  return [](SRKP1& srkp) {};
+}
+template<typename KI, typename... Ts>
+auto sycl_reify_kernel_parameters(Ts&...) {
+  return [](SRKP1& srkp) {};
+}
+template<typename KN, typename KT>
+// expected {{in implicit call to 'sycl_kernel_launch' with template argument}} for test1.cpp
+// expected {{this indicates a problem with the SYCL runtime header files}} for test1.cpp
+[[clang::sycl_kernel_entry_point(KN)]]
+// expected {{no matching function for call to 'sycl_kernel_launch'}} for test1.cpp.
+void skep(KT k) {
+  k();
+}
+void test2(SRKP1 srkp) {
+  // expected {{in instantiation of function template specialization 'ns2::skep<KN, (lambda at {{.*}})>' requested here}} for test1.cpp
+  skep<struct KN>([=] { (void)srkp; });
+}
+} // ns2 namespace
+
+
+#--- test1.cpp
+#include "m1.h"
+#include "m2.h"
+#include "test.h"
+
+// expected-error at m1.h:3 {{'SRKP1' has different definitions in different modules; definition in module 'M1' is here}}
+// expected-note at m2.h:3  {{definition in module 'M2' is here}}
+
+// expected-note-re at test.h:23  {{candidate function {{.*}} not viable: expects an lvalue for 1st argument}}
+// expected-note at test.h:33     {{in implicit call to 'sycl_kernel_launch' with template argument}}
+// expected-note at test.h:33     {{this indicates a problem with the SYCL runtime header files}}
+// expected-error at test.h:35    {{no matching function for call to 'sycl_kernel_launch'}}
+// expected-note-re at test.h:40  {{in instantiation of function template specialization 'ns1::skep<KN, (lambda at {{.*}})>' requested here}}
+
+// expected-note-re at test.h:47  {{candidate function {{.*}} not viable: expects an lvalue for 1st argument}}
+// expected-note at test.h:57     {{in implicit call to 'sycl_kernel_launch' with template argument}}
+// expected-note at test.h:57     {{this indicates a problem with the SYCL runtime header files}}
+// expected-error at test.h:59    {{no matching function for call to 'sycl_kernel_launch'}}
+// expected-note-re at test.h:64  {{in instantiation of function template specialization 'ns2::skep<KN, (lambda at {{.*}})>' requested here}}
+
+
+#--- test2.cpp
+#include "m2.h"
+#include "m1.h"
+#include "test.h"
+
+// expected-error at m2.h:3 {{'SRKP1' has different definitions in different modules; definition in module 'M2' is here}}
+// expected-note at m1.h:3  {{definition in module 'M1' is here}}
diff --git a/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-pch.cpp b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-pch.cpp
new file mode 100644
index 00000000000000..af9c5f7dca0839
--- /dev/null
+++ b/clang/test/SemaSYCL/sycl-reified-kernel-parameter-attr-pch.cpp
@@ -0,0 +1,39 @@
+// Test that the sycl_reified_kernel_parameter attribute is appropriately
+// handled across PCH boundaries.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -std=c++17 -fsycl-is-host -emit-pch -x c++-header \
+// RUN:   %t/pch.h -o %t/pch.h.host.pch
+// RUN: %clang_cc1 -std=c++17 -fsycl-is-host -verify \
+// RUN:   -include-pch %t/pch.h.host.pch %t/test.cpp
+// RUN: %clang_cc1 -std=c++17 -fsycl-is-device -emit-pch -x c++-header \
+// RUN:   %t/pch.h -o %t/pch.h.device.pch
+// RUN: %clang_cc1 -std=c++17 -fsycl-is-device -verify \
+// RUN:   -include-pch %t/pch.h.device.pch %t/test.cpp
+
+#--- pch.h
+struct [[clang::sycl_reified_kernel_parameter]] SRKP {};
+
+#--- test.cpp
+// expected-no-diagnostics
+
+template<typename KI, typename... Ts>
+auto sycl_kernel_launch(Ts&...) {
+  return [](SRKP&) {};
+}
+
+template<typename KI, typename... Ts>
+auto sycl_reify_kernel_parameters(Ts&...) {
+  return [](SRKP&) {};
+}
+
+template<typename KN, typename KT>
+[[clang::sycl_kernel_entry_point(KN)]]
+void skep(KT k) {
+  k();
+}
+
+void f(SRKP srkp) {
+  skep<struct KN>([=] { (void)srkp; });
+}
diff --git a/clang/test/SemaSYCL/sycl-reified-kernel-parameters.cpp b/clang/test/SemaSYCL/sycl-reified-kernel-parameters.cpp
new file mode 100644
index 00000000000000..3d58011ebcb07f
--- /dev/null
+++ b/clang/test/SemaSYCL/sycl-reified-kernel-parameters.cpp
@@ -0,0 +1,193 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -fsycl-is-host -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++17 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -fsyntax-only -fsycl-is-host -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++20 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -fsycl-is-host -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -triple spirv64-unknown-unknown -std=c++23 -fsyntax-only -fsycl-is-device -verify %s
+
+// Test overload resolution for implicit calls to sycl_kernel_launch<KI>(...)
+// and sycl_reify_kernel_parameters<KI>(...) synthesized for functions declared
+// with the sycl_kernel_entry_point attribute which have a parameter, or a
+// parameter with a subobject, with a type that was declared with the
+// sycl_reified_kernel_parameter attribute.
+
+////////////////////////////////////////////////////////////////////////////////
+// Valid declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+// A unique kernel name type is required for each declared kernel entry point.
+template<int, int = 0> struct KN;
+
+// A generic sycl_reified_kernel_parameter attributed class type.
+struct [[clang::sycl_reified_kernel_parameter]] SRKP {};
+
+// A generic kernel object type.
+template<int, int = 0>
+struct KT {
+  void operator()() const;
+  SRKP srkp;
+};
+
+
+// sycl_reify_kernel_parameters as function template at namespace scope.
+namespace ok1 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  template<typename KI, typename... Ts>
+  auto sycl_reify_kernel_parameters(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  [[clang::sycl_kernel_entry_point(KN<1>)]]
+  void skep(KT<1> k) {
+    k();
+  }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Invalid declarations.
+////////////////////////////////////////////////////////////////////////////////
+
+// A unique kernel name type is required for each declared kernel entry point.
+template<int, int = 0> struct BADKN;
+
+
+// A generic kernel object type.
+template<int, int = 0>
+struct BADKT {
+  void operator()() const;
+  SRKP srkp;
+};
+
+
+// Undeclared sycl_reify_kernel_parameters identifier.
+namespace bad1 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  // expected-error at +4 {{use of undeclared identifier 'sycl_reify_kernel_parameters'}}
+  // expected-note at +2  {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +1  {{in implicit call to 'sycl_reify_kernel_parameters' with template argument '__sycl_kernel_info<BADKN<1>>' and function arguments (lvalue of type 'BADKT<1>') required here}}
+  [[clang::sycl_kernel_entry_point(BADKN<1>)]]
+  void skep(BADKT<1> k) {
+    k();
+  }
+}
+
+// sycl_kernel_launch returns void when a callable object is required.
+namespace bad2 {
+  template<typename KI, typename... Ts>
+  void sycl_kernel_launch(Ts&... args) {}
+  template<typename KI, typename... Ts>
+  auto sycl_reify_kernel_parameters(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  // expected-error at +4 {{called object type 'void' is not a function or function pointer}}
+  // expected-note at +2  {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +1  {{in implicit call to the callable returned by 'sycl_kernel_launch' with function arguments (lvalue of type 'SRKP') required here}}
+  [[clang::sycl_kernel_entry_point(BADKN<2>)]]
+  void skep(BADKT<2> k) {
+    k();
+  }
+}
+
+// sycl_reify_kernel_parameters returns void, but a callable object is required.
+namespace bad3 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  template<typename KI, typename... Ts>
+  void sycl_reify_kernel_parameters(Ts&... args) {}
+  // expected-error at +4 {{called object type 'void' is not a function or function pointer}}
+  // expected-note at +2  {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +1  {{in implicit call to the callable returned by 'sycl_reify_kernel_parameters' with function arguments (lvalue of type 'SRKP') required here}}
+  [[clang::sycl_kernel_entry_point(BADKN<3>)]]
+  void skep(BADKT<3> k) {
+    k();
+  }
+}
+
+// sycl_kernel_launch returns non-void but does not return a callable object.
+namespace bad4 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return nullptr;
+  }
+  template<typename KI, typename... Ts>
+  auto sycl_reify_kernel_parameters(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  // expected-error at +4 {{called object type 'std::nullptr_t' is not a function or function pointer}}
+  // expected-note at +2  {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +1  {{in implicit call to the callable returned by 'sycl_kernel_launch' with function arguments (lvalue of type 'SRKP') required here}}
+  [[clang::sycl_kernel_entry_point(BADKN<4>)]]
+  void skep(BADKT<4> k) {
+    k();
+  }
+}
+
+// sycl_reify_kernel_parameters returns non-void but does not return a callable object.
+namespace bad5 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  template<typename KI, typename... Ts>
+  auto sycl_reify_kernel_parameters(Ts&... args) {
+    return 5;
+  }
+  // expected-error at +4 {{called object type 'int' is not a function or function pointer}}
+  // expected-note at +2  {{this indicates a problem with the SYCL runtime header files; please consider reporting this to your SYCL runtime provider}}
+  // expected-note at +1  {{in implicit call to the callable returned by 'sycl_reify_kernel_parameters' with function arguments (lvalue of type 'SRKP') required here}}
+  [[clang::sycl_kernel_entry_point(BADKN<5>)]]
+  void skep(BADKT<5> k) {
+    k();
+  }
+}
+
+// sycl_kernel_launch returns a callable that does not return void.
+namespace bad6 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return [&] (auto&... subobjects) {
+      return 6;
+    };
+  }
+  template<typename KI, typename... Ts>
+  auto sycl_reify_kernel_parameters(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  // FIXME: not yet diagnosed.
+  [[clang::sycl_kernel_entry_point(BADKN<6>)]]
+  void skep(BADKT<6> k) {
+    k();
+  }
+}
+
+// sycl_reify_kernel_parameters returns a callable that does not return void.
+namespace bad7 {
+  template<typename KI, typename... Ts>
+  auto sycl_kernel_launch(Ts&... args) {
+    return [&] (auto&... subobjects) {};
+  }
+  template<typename KI, typename... Ts>
+  auto sycl_reify_kernel_parameters(Ts&... args) {
+    return [&] (auto&... subobjects) {
+      return 7;
+    };
+  }
+  // FIXME: not yet diagnosed.
+  [[clang::sycl_kernel_entry_point(BADKN<7>)]]
+  void skep(BADKT<7> k) {
+    k();
+  }
+}
+
+
+// FIXME: Unlike sycl_kernel_launch(), sycl_reify_kernel_parameters() cannot be
+// FIXME: a non-static member function since 'this' is not available. Can it be
+// FIXME: a namespace scope (const) variable template?



More information about the cfe-commits mailing list