@@ -797,7 +797,9 @@ static void populateIntHeader(SYCLIntegrationHeader &H, const StringRef Name,
797
797
798
798
ASTContext &Ctx = KernelObjTy->getASTContext ();
799
799
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout (KernelObjTy);
800
- H.startKernel (Name, NameType);
800
+ const std::string StableName = PredefinedExpr::ComputeName (
801
+ Ctx, PredefinedExpr::UniqueStableNameExpr, NameType);
802
+ H.startKernel (Name, NameType, StableName);
801
803
802
804
auto populateHeaderForAccessor = [&](const QualType &ArgTy, uint64_t Offset) {
803
805
// The parameter is a SYCL accessor object.
@@ -1112,7 +1114,7 @@ void SYCLIntegrationHeader::emitFwdDecl(raw_ostream &O, const Decl *D) {
1112
1114
// defined class constituting the kernel name is not globally
1113
1115
// accessible - contradicts the spec
1114
1116
Diag.Report (D->getSourceRange ().getBegin (),
1115
- diag::err_sycl_kernel_name_class_not_top_level );
1117
+ diag::warn_sycl_kernel_name_class_not_top_level );
1116
1118
}
1117
1119
}
1118
1120
break ;
@@ -1238,12 +1240,14 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
1238
1240
O << " #include <CL/sycl/detail/kernel_desc.hpp>\n " ;
1239
1241
1240
1242
O << " \n " ;
1243
+ O << " #ifndef UNNAMED_LAMBDA_EXT\n " ;
1241
1244
O << " // Forward declarations of templated kernel function types:\n " ;
1242
1245
1243
1246
llvm::SmallPtrSet<const void *, 4 > Printed;
1244
1247
for (const KernelDesc &K : KernelDescs) {
1245
1248
emitForwardClassDecls (O, K.NameType , Printed);
1246
1249
}
1250
+ O << " #endif\n " ;
1247
1251
O << " \n " ;
1248
1252
1249
1253
O << " namespace cl {\n " ;
@@ -1305,19 +1309,21 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
1305
1309
}
1306
1310
O << " };\n\n " ;
1307
1311
1308
- O << " // Specializations of this template class encompasses information\n " ;
1309
- O << " // about a kernel. The kernel is identified by the template\n " ;
1310
- O << " // parameter type.\n " ;
1311
- O << " template <class KernelNameType> struct KernelInfo;\n " ;
1312
- O << " \n " ;
1313
-
1314
1312
O << " // Specializations of KernelInfo for kernel function types:\n " ;
1315
1313
CurStart = 0 ;
1316
1314
1317
1315
for (const KernelDesc &K : KernelDescs) {
1318
1316
const size_t N = K.Params .size ();
1317
+ O << " #ifdef UNNAMED_LAMBDA_EXT\n " ;
1318
+ O << " template <> struct KernelInfoData<" ;
1319
+ O << " '" << K.StableName .front ();
1320
+ for (char c : StringRef (K.StableName ).substr (1 ))
1321
+ O << " ', '" << c;
1322
+ O << " '> {\n " ;
1323
+ O << " #else\n " ;
1319
1324
O << " template <> struct KernelInfo<"
1320
1325
<< eraseAnonNamespace (K.NameType .getAsString ()) << " > {\n " ;
1326
+ O << " #endif\n " ;
1321
1327
O << " DLL_LOCAL\n " ;
1322
1328
O << " static constexpr const char* getName() { return \" " << K.Name
1323
1329
<< " \" ; }\n " ;
@@ -1355,10 +1361,12 @@ bool SYCLIntegrationHeader::emit(const StringRef &IntHeaderName) {
1355
1361
}
1356
1362
1357
1363
void SYCLIntegrationHeader::startKernel (StringRef KernelName,
1358
- QualType KernelNameType) {
1364
+ QualType KernelNameType,
1365
+ StringRef KernelStableName) {
1359
1366
KernelDescs.resize (KernelDescs.size () + 1 );
1360
1367
KernelDescs.back ().Name = KernelName;
1361
1368
KernelDescs.back ().NameType = KernelNameType;
1369
+ KernelDescs.back ().StableName = KernelStableName;
1362
1370
}
1363
1371
1364
1372
void SYCLIntegrationHeader::addParamDesc (kernel_param_kind_t Kind, int Info,
0 commit comments