[llvm-branch-commits] [clang] [clang][OpenMP] Simplify check for taskloop in `ActOnOpenMPLoopInitia… (PR #98633)

Krzysztof Parzyszek via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 12 06:58:53 PDT 2024


https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/98633

>From 08ddba05e36c6c5b6fa5b4b158fbef21b77ab415 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 11 Jul 2024 14:02:41 -0500
Subject: [PATCH 1/2] [clang][OpenMP] Simplify check for taskloop in
 `ActOnOpenMPLoopInitialization`

Replace the explicit list of compound directives ending with taskloop
with checking for the last leaf construct.
---
 clang/lib/Sema/SemaOpenMP.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2340873c8fdd9..118cda253a437 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -9090,14 +9090,15 @@ void SemaOpenMP::ActOnOpenMPLoopInitialization(SourceLocation ForLoc,
           isOpenMPSimdDirective(DKind)
               ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : OMPC_linear)
               : OMPC_private;
+      auto isOpenMPTaskloopDirective = [](OpenMPDirectiveKind DK) {
+        return getLeafConstructsOrSelf(DK).back() == OMPD_taskloop;
+      };
       if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
             DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
             (getLangOpts().OpenMP <= 45 ||
              (DVar.CKind != OMPC_lastprivate && DVar.CKind != OMPC_private))) ||
-           ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-             DKind == OMPD_master_taskloop || DKind == OMPD_masked_taskloop ||
-             DKind == OMPD_parallel_master_taskloop ||
-             DKind == OMPD_parallel_masked_taskloop ||
+           ((isOpenMPWorksharingDirective(DKind) ||
+             isOpenMPTaskloopDirective(DKind) ||
              isOpenMPDistributeDirective(DKind)) &&
             !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
             DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&

>From f38af28828a08daf3ba3a7f70104c38ccc6e4732 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Fri, 12 Jul 2024 08:58:28 -0500
Subject: [PATCH 2/2] Capitalize IsOpenMPTaskloopDirective

---
 clang/lib/Sema/SemaOpenMP.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 118cda253a437..c1a58fc7f2076 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -9090,7 +9090,7 @@ void SemaOpenMP::ActOnOpenMPLoopInitialization(SourceLocation ForLoc,
           isOpenMPSimdDirective(DKind)
               ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : OMPC_linear)
               : OMPC_private;
-      auto isOpenMPTaskloopDirective = [](OpenMPDirectiveKind DK) {
+      auto IsOpenMPTaskloopDirective = [](OpenMPDirectiveKind DK) {
         return getLeafConstructsOrSelf(DK).back() == OMPD_taskloop;
       };
       if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
@@ -9098,7 +9098,7 @@ void SemaOpenMP::ActOnOpenMPLoopInitialization(SourceLocation ForLoc,
             (getLangOpts().OpenMP <= 45 ||
              (DVar.CKind != OMPC_lastprivate && DVar.CKind != OMPC_private))) ||
            ((isOpenMPWorksharingDirective(DKind) ||
-             isOpenMPTaskloopDirective(DKind) ||
+             IsOpenMPTaskloopDirective(DKind) ||
              isOpenMPDistributeDirective(DKind)) &&
             !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
             DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&



More information about the llvm-branch-commits mailing list