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/3] [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/3] 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.

>From 78217b519b1a3f80c753c38618a5975bed380d08 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" <[email protected]>
Date: Thu, 23 Oct 2025 09:15:20 -0700
Subject: [PATCH 3/3] format

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

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 2f1692ca63e93..4c5c45e34231b 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5214,8 +5214,7 @@ static void handleDeviceKernelAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
     AL.setInvalid();
     return;
   }
-  if(DeviceKernelAttr::isOpenCLSpelling(AL) ||
-     !Triple.isNVPTX()) {
+  if (DeviceKernelAttr::isOpenCLSpelling(AL) || !Triple.isNVPTX()) {
     // OpenCL C++ will throw a more specific error.
     if (!LangOpts.OpenCLCPlusPlus && (!FD || IsFunctionTemplate)) {
       S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type_str)
@@ -5224,8 +5223,7 @@ static void handleDeviceKernelAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
       return;
     }
     handleSimpleAttribute<DeviceKernelAttr>(S, D, AL);
-  }
-  else {
+  } else {
     handleGlobalAttr(S, D, AL);
   }
   // TODO: isGPU() should probably return true for SPIR.

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

Reply via email to