https://github.com/sarnex updated 
https://github.com/llvm/llvm-project/pull/163859

>From d75ca9397236946d25642fe186e7092bd74e5e45 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <[email protected]>
Date: Thu, 16 Oct 2025 13:40:28 -0700
Subject: [PATCH 1/2] [clang] Ensure we don't process OpenCL kernels as CUDA
 kernels

Signed-off-by: Sarnie, Nick <[email protected]>
---
 clang/lib/Sema/SemaDeclAttr.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e6f8748db7644..6978299734ece 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5206,7 +5206,8 @@ static void handleCallConvAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 static void handleDeviceKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
   bool IsFunctionTemplate = FD && FD->getDescribedFunctionTemplate();
-  if (S.getASTContext().getTargetInfo().getTriple().isNVPTX()) {
+  if (S.getASTContext().getTargetInfo().getTriple().isNVPTX() &&
+      !DeviceKernelAttr::isOpenCLSpelling(AL)) {
     handleGlobalAttr(S, D, AL);
   } else {
     // OpenCL C++ will throw a more specific error.

>From 158e676969f7b49d2716038f8aac3f49d2e81650 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <[email protected]>
Date: Tue, 21 Oct 2025 15:24:36 -0700
Subject: [PATCH 2/2] swap order

Signed-off-by: Sarnie, Nick <[email protected]>
---
 clang/lib/Sema/SemaDeclAttr.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 6978299734ece..db7f6839a3326 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5205,17 +5205,17 @@ static void handleCallConvAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 
 static void handleDeviceKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
-  bool IsFunctionTemplate = FD && FD->getDescribedFunctionTemplate();
-  if (S.getASTContext().getTargetInfo().getTriple().isNVPTX() &&
-      !DeviceKernelAttr::isOpenCLSpelling(AL)) {
-    handleGlobalAttr(S, D, AL);
-  } else {
+  if (DeviceKernelAttr::isOpenCLSpelling(AL) ||
+      !S.getASTContext().getTargetInfo().getTriple().isNVPTX()) {
+    bool IsFunctionTemplate = FD && FD->getDescribedFunctionTemplate();
     // OpenCL C++ will throw a more specific error.
     if (!S.getLangOpts().OpenCLCPlusPlus && (!FD || IsFunctionTemplate)) {
       S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type_str)
           << AL << AL.isRegularKeywordAttribute() << "functions";
     }
     handleSimpleAttribute<DeviceKernelAttr>(S, D, AL);
+  } else {
+    handleGlobalAttr(S, D, AL);
   }
   // Make sure we validate the CC with the target
   // and warn/error if necessary.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to