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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 06:48:36 PST 2024


================
@@ -14296,6 +14296,34 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
   }
 }
 
+static SYCLKernelInfo BuildSYCLKernelInfo(CanQualType KernelNameType,
+                                          const FunctionDecl *FD) {
+  return {KernelNameType, FD};
+}
+
+void ASTContext::registerSYCLEntryPointFunction(FunctionDecl *FD) {
+  // If the function declaration to register is invalid or dependent, the
+  // registration attempt is ignored.
+  if (FD->isInvalidDecl() || FD->isTemplated())
+    return;
+
+  const auto *SKEPAttr = FD->getAttr<SYCLKernelEntryPointAttr>();
+  assert(SKEPAttr && "Missing sycl_kernel_entry_point attribute");
+
+  // Be tolerant of multiple registration attempts so long as each attempt
+  // is for the same entity. Callers are obligated to detect and diagnose
+  // conflicting kernel names prior to calling this function.
+  CanQualType KernelNameType = getCanonicalType(SKEPAttr->getKernelName());
+  auto IT = SYCLKernels.find(KernelNameType);
+  if (IT != SYCLKernels.end()) {
+    assert(declaresSameEntity(FD, IT->second.getKernelEntryPointDecl()) &&
----------------
erichkeane wrote:

```suggestion
    assert((IT == SYCLKernels.end() || declaresSameEntity(FD, IT->second.getKernelEntryPointDecl())) &&
```

Then just kill the whole branch.

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


More information about the cfe-commits mailing list