[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 19 05:40:54 PDT 2025
================
@@ -18933,12 +18945,35 @@ static bool actOnOMPReductionKindClause(
reportOriginalDsa(S, Stack, D, DVar);
continue;
}
+ // OpenMP 6.0 [ 7.6.10 ]
+ // Support Reduction over private variables with reduction clause.
+ // A list item in a reduction clause can now be private in the enclosing
+ // context. For orphaned constructs it is assumed to be shared unless the
+ // original(private) modifier appears in the clause.
+ DVar = Stack->getImplicitDSA(D, true);
+ bool IsOrphaned = false;
+ OpenMPDirectiveKind CurrDir = Stack->getCurrentDirective();
+ OpenMPDirectiveKind ParentDir = Stack->getParentDirective();
+ // Check if the construct is orphaned (has no enclosing OpenMP context)
+ IsOrphaned = (ParentDir == OMPD_unknown);
+ IsPrivate =
+ ((isOpenMPPrivate(DVar.CKind) && DVar.CKind != OMPC_reduction &&
+ isOpenMPWorksharingDirective(CurrDir) &&
+ !isOpenMPParallelDirective(CurrDir) &&
+ !isOpenMPTeamsDirective(CurrDir) &&
+ !isOpenMPSimdDirective(ParentDir)) ||
+ (IsOrphaned && DVar.CKind == OMPC_unknown) ||
+ RD.OrigSharingModifier != OMPC_ORIGINAL_SHARING_shared);
+ // Disable private handling for OpenMP versions <= 5.2
+ if (S.getLangOpts().OpenMP <= 52)
+ IsPrivate = false;
----------------
alexey-bataev wrote:
Shall it report an error, if DSA is private for version <= 52? If so, it should not change the value of IsPrivate here, instead it shall return IsPrivate or, if it cannot be private at all, add an assertion.
https://github.com/llvm/llvm-project/pull/129938
More information about the cfe-commits
mailing list