https://github.com/tahonermann created https://github.com/llvm/llvm-project/pull/185522
Commit cf6cc662eeee2b1416430f517850be9032788e39 ([OpenMP][SYCL] Improve diagnosing of unsupported types usage) customized `Sema::getEmissionStatus()` to return `Emitted` for a function declared with the `sycl_kernel` attribute during device compilation. That change is appropriate, but was inserted before a check for a dependent context and resulted in `Emitted` being returned instead of `TemplateDiscarded` for templated functions declared with the attribute. That appears to be incorrect; templated functions are still discarded. The customization was extended to include the `sycl_kernel_entry_point` and `sycl_external` attributes in commit 23e4fe040b67e2dd419652830a87093a93ea1a97 ([SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute). Those additions are appropriate, but the effect on templated functions (as opposed to their instantiations) resulted in the incorrect status being observed in a downstream fork of Clang. This change corrects `Sema::getEmissionStatus()` to once again unconditionally return `TemplateDiscarded` for templated functions. >From 7318065a28317ebb7ee5ca893f318315fa846000 Mon Sep 17 00:00:00 2001 From: Tom Honermann <[email protected]> Date: Mon, 9 Mar 2026 14:28:17 -0700 Subject: [PATCH] [SYCL] Correct emission status reporting for function templates declared with SYCL attributes. Commit cf6cc662eeee2b1416430f517850be9032788e39 ([OpenMP][SYCL] Improve diagnosing of unsupported types usage) customized `Sema::getEmissionStatus()` to return `Emitted` for a function declared with the `sycl_kernel` attribute during device compilation. That change is appropriate, but was inserted before a check for a dependent context and resulted in `Emitted` being returned instead of `TemplateDiscarded` for templated functions declared with the attribute. That appears to be incorrect; templated functions are still discarded. The customization was extended to include the `sycl_kernel_entry_point` and `sycl_external` attributes in commit 23e4fe040b67e2dd419652830a87093a93ea1a97 ([SYCL] SYCL host kernel launch support for the sycl_kernel_entry_point attribute). Those additions are appropriate, but the effect on templated functions (as opposed to their instantiations) resulted in the incorrect status being observed in a downstream fork of Clang. This change corrects `Sema::getEmissionStatus()` to once again unconditionally return `TemplateDiscarded` for templated functions. --- clang/lib/Sema/SemaDecl.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 405832a446e10..fc95b9beffe7d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -21086,17 +21086,15 @@ Sema::FunctionEmissionStatus Sema::getEmissionStatus(const FunctionDecl *FD, bool Final) { assert(FD && "Expected non-null FunctionDecl"); - // SYCL functions can be template, so we check if they have appropriate - // attribute prior to checking if it is a template. + // Templates are emitted when they're instantiated. + if (FD->isDependentContext()) + return FunctionEmissionStatus::TemplateDiscarded; + if (LangOpts.SYCLIsDevice && (FD->hasAttr<SYCLKernelAttr>() || FD->hasAttr<SYCLKernelEntryPointAttr>() || FD->hasAttr<SYCLExternalAttr>())) return FunctionEmissionStatus::Emitted; - // Templates are emitted when they're instantiated. - if (FD->isDependentContext()) - return FunctionEmissionStatus::TemplateDiscarded; - // Check whether this function is an externally visible definition. auto IsEmittedForExternalSymbol = [this, FD]() { // We have to check the GVA linkage of the function's *definition* -- if we _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
