[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 28 08:03:08 PDT 2024
================
@@ -14296,6 +14296,31 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
}
}
+static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context,
+ CanQualType KernelNameType,
+ const FunctionDecl *FD) {
+ return { KernelNameType, FD };
+}
+
+void ASTContext::registerSYCLEntryPointFunction(FunctionDecl *FD) {
+ assert(!FD->isInvalidDecl());
+ assert(!FD->isDependentContext());
+
+ const auto *SKEPAttr = FD->getAttr<SYCLKernelEntryPointAttr>();
+ assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+
+ CanQualType KernelNameType = getCanonicalType(SKEPAttr->getKernelName());
+ auto IT = SYCLKernels.find(KernelNameType);
+ if (IT != SYCLKernels.end()) {
+ if (!declaresSameEntity(FD, IT->second.GetKernelEntryPointDecl()))
+ llvm::report_fatal_error("SYCL kernel name conflict");
----------------
erichkeane wrote:
I'm really not a fan of 'temporary' fatal errors, but I can withhold judgement until later I guess.
That said, why is THIS function where the diagnostic should happen? Should this be an assert instead? It would be weird for `ASTContext` to diagnose. I would expect the diagnostic to happen earlier, so an 'assert' seems more reasonable here. Also, it would allow us to then only check the `declaresSameEntity` (a reasonably expensive function) fewer times.
https://github.com/llvm/llvm-project/pull/111389
More information about the cfe-commits
mailing list