Skip to content

[clang][OpenMP] Simplify check for taskloop in `ActOnOpenMPLoopInitia… #98633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 15, 2024

Conversation

kparzysz
Copy link
Contributor

…lization`

Replace the explicit list of compound directives ending with taskloop with checking for the last leaf construct.

kparzysz added 8 commits July 10, 2024 14:49
The previous check was inconsistent. For example, it would allow
```
#pragma omp target
#pragma omp parallel for
  for (...) {
#pragma omp scan
  }
```
but not
```
#pragma omp target parallel for
  for (...) {
#pragma omp scan
  }
```

Make the check conform to the wording on the specification.
Express the constraints via constituent directives.
Follow-up to 81cdf94 (check for `scan` nesting).  Also, it eliminates
the mentions of combined directives in `ActOnOpenMPReductionClause`.
…lization`

Replace the explicit list of compound directives ending with taskloop
with checking for the last leaf construct.
@kparzysz kparzysz requested a review from alexey-bataev July 12, 2024 13:37
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang labels Jul 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 12, 2024

@llvm/pr-subscribers-clang

Author: Krzysztof Parzyszek (kparzysz)

Changes

…lization`

Replace the explicit list of compound directives ending with taskloop with checking for the last leaf construct.


Full diff: https://github.com/llvm/llvm-project/pull/98633.diff

1 Files Affected:

  • (modified) clang/lib/Sema/SemaOpenMP.cpp (+5-4)
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)) &&

@@ -9090,14 +9090,15 @@ void SemaOpenMP::ActOnOpenMPLoopInitialization(SourceLocation ForLoc,
isOpenMPSimdDirective(DKind)
? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : OMPC_linear)
: OMPC_private;
auto isOpenMPTaskloopDirective = [](OpenMPDirectiveKind DK) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsOpenMPTaskloopDirective

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@alexey-bataev alexey-bataev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kparzysz kparzysz changed the base branch from users/kparzysz/spr/c08-reduction-inscan to main July 15, 2024 13:52
@kparzysz kparzysz merged commit a1dfe15 into main Jul 15, 2024
6 checks passed
@kparzysz kparzysz deleted the users/kparzysz/spr/c10-simplify-taskloop branch July 15, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants