[clang] [OpenCL] No need to check array of struct for kernel arguments (PR #138894)

2025-05-07 Thread Jiefeng Wang via cfe-commits

https://github.com/jiefwo created 
https://github.com/llvm/llvm-project/pull/138894

Since arrays decay into pointers, no need to check them for arguments. This 
commit reverts part of the changes from the commit "[OpenCL] Check for invalid 
kernel arguments in array types" 3b238ed6626983beb238b95eada4172184fb2d29.



  



Rate limit ยท GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support โ€”
https://githubstatus.com";>GitHub Status โ€”
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenCL] No need to check array of struct for kernel arguments (PR #138894)

2025-05-16 Thread Jiefeng Wang via cfe-commits

https://github.com/jiefwo updated 
https://github.com/llvm/llvm-project/pull/138894

>From 78e6da1b9f49e23afe77878b81a0aafde8108976 Mon Sep 17 00:00:00 2001
From: Jiefeng Wang 
Date: Wed, 7 May 2025 23:02:03 +0800
Subject: [PATCH] [OpenCL] No need to check array of struct for kernel
 arguments

Since arrays decay into pointers, no need to check them for arguments.
This commit reverts part of the changes from the commit
"[OpenCL] Check for invalid kernel arguments in array types"
3b238ed6626983beb238b95eada4172184fb2d29.
---
 clang/lib/Sema/SemaDecl.cpp | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6b561d7bfc6e7..364fb064ccc2d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9717,14 +9717,10 @@ static void checkIsValidOpenCLKernelParameter(
   SmallVector HistoryStack;
   HistoryStack.push_back(nullptr);
 
-  // At this point we already handled everything except of a RecordType or
-  // an ArrayType of a RecordType.
-  assert((PT->isArrayType() || PT->isRecordType()) && "Unexpected type.");
-  const RecordType *RecTy =
-  PT->getPointeeOrArrayElementType()->getAs();
-  const RecordDecl *OrigRecDecl = RecTy->getDecl();
-
-  VisitStack.push_back(RecTy->getDecl());
+  // At this point we already handled everything except of a RecordType.
+  assert(PT->isRecordType() && "Unexpected type.");
+  const RecordDecl *PD = PT->castAs()->getDecl();
+  VisitStack.push_back(PD);
   assert(VisitStack.back() && "First decl null?");
 
   do {
@@ -9789,8 +9785,8 @@ static void checkIsValidOpenCLKernelParameter(
 S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
   }
 
-  S.Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
-  << OrigRecDecl->getDeclName();
+  S.Diag(PD->getLocation(), diag::note_within_field_of_type)
+  << PD->getDeclName();
 
   // We have an error, now let's go back up through history and show where
   // the offending field came from

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenCL] No need to check array of struct for kernel arguments (PR #138894)

2025-05-15 Thread Jiefeng Wang via cfe-commits

https://github.com/jiefwo updated 
https://github.com/llvm/llvm-project/pull/138894

>From 78e6da1b9f49e23afe77878b81a0aafde8108976 Mon Sep 17 00:00:00 2001
From: Jiefeng Wang 
Date: Wed, 7 May 2025 23:02:03 +0800
Subject: [PATCH] [OpenCL] No need to check array of struct for kernel
 arguments

Since arrays decay into pointers, no need to check them for arguments.
This commit reverts part of the changes from the commit
"[OpenCL] Check for invalid kernel arguments in array types"
3b238ed6626983beb238b95eada4172184fb2d29.
---
 clang/lib/Sema/SemaDecl.cpp | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6b561d7bfc6e7..364fb064ccc2d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9717,14 +9717,10 @@ static void checkIsValidOpenCLKernelParameter(
   SmallVector HistoryStack;
   HistoryStack.push_back(nullptr);
 
-  // At this point we already handled everything except of a RecordType or
-  // an ArrayType of a RecordType.
-  assert((PT->isArrayType() || PT->isRecordType()) && "Unexpected type.");
-  const RecordType *RecTy =
-  PT->getPointeeOrArrayElementType()->getAs();
-  const RecordDecl *OrigRecDecl = RecTy->getDecl();
-
-  VisitStack.push_back(RecTy->getDecl());
+  // At this point we already handled everything except of a RecordType.
+  assert(PT->isRecordType() && "Unexpected type.");
+  const RecordDecl *PD = PT->castAs()->getDecl();
+  VisitStack.push_back(PD);
   assert(VisitStack.back() && "First decl null?");
 
   do {
@@ -9789,8 +9785,8 @@ static void checkIsValidOpenCLKernelParameter(
 S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
   }
 
-  S.Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
-  << OrigRecDecl->getDeclName();
+  S.Diag(PD->getLocation(), diag::note_within_field_of_type)
+  << PD->getDeclName();
 
   // We have an error, now let's go back up through history and show where
   // the offending field came from

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenCL] No need to check array of struct for kernel arguments (PR #138894)

2025-05-22 Thread Jiefeng Wang via cfe-commits

jiefwo wrote:

Hi! The patch is approved โ€” is there a committer who could help merge it? This 
is my first contribution.

https://github.com/llvm/llvm-project/pull/138894
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits