[llvm-branch-commits] [clang] [clang][OpenMP] Update validity check for reduction with `inscan` (PR #98500)
Krzysztof Parzyszek via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jul 12 06:35:31 PDT 2024
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/98500
>From b58e4fae4b0c22c11e8a0d0e29b6f21c28d4da86 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 11 Jul 2024 10:47:41 -0500
Subject: [PATCH] [clang][OpenMP] Update validity check for reduction with
`inscan`
Follow-up to 81cdf9472c (check for `scan` nesting). Also, it eliminates
the mentions of combined directives in `ActOnOpenMPReductionClause`.
---
clang/lib/Sema/SemaOpenMP.cpp | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 7ca89b0d4eb70..dc77a51b6569e 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -18603,14 +18603,22 @@ OMPClause *SemaOpenMP::ActOnOpenMPReductionClause(
// worksharing-loop construct, a worksharing-loop SIMD construct, a simd
// construct, a parallel worksharing-loop construct or a parallel
// worksharing-loop SIMD construct.
- if (Modifier == OMPC_REDUCTION_inscan &&
- (DSAStack->getCurrentDirective() != OMPD_for &&
- DSAStack->getCurrentDirective() != OMPD_for_simd &&
- DSAStack->getCurrentDirective() != OMPD_simd &&
- DSAStack->getCurrentDirective() != OMPD_parallel_for &&
- DSAStack->getCurrentDirective() != OMPD_parallel_for_simd)) {
- Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
- return nullptr;
+ // [5.2:136:1-4] A reduction clause with the inscan reduction-modifier may
+ // only appear on a worksharing-loop construct, a simd construct or a
+ // combined or composite construct for which any of the aforementioned
+ // constructs is a constituent construct and distribute is not a constituent
+ // construct.
+ if (Modifier == OMPC_REDUCTION_inscan) {
+ SmallVector<OpenMPDirectiveKind, 4> LeafOrComposite;
+ ArrayRef<OpenMPDirectiveKind> CurrentLOC = getLeafOrCompositeConstructs(
+ DSAStack->getCurrentDirective(), LeafOrComposite);
+ bool Valid = llvm::any_of(CurrentLOC, [](OpenMPDirectiveKind DK) {
+ return llvm::is_contained({OMPD_for, OMPD_simd, OMPD_for_simd}, DK);
+ });
+ if (!Valid) {
+ Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
+ return nullptr;
+ }
}
ReductionData RD(VarList.size(), Modifier);
More information about the llvm-branch-commits
mailing list