Skip to content

Commit 44241ab

Browse files
committed
[clang][OpenMP] 6.0: Add defaultmap implicit-behavior 'private'
Per OpenMP 6.0 specification, section 7.9.9 Argument keywords, page 291, L17 Semantics, page 292, L15-16 The behavior of 'private' should be described in the same manner as that of 'firstprivate' 15 ... If implicit-behavior is firstprivate, 16 the attribute is a data-sharing attribute of firstprivate. Relevant OpenMP 6.0 issues defaultmap clause new implicit-behavior 'private' should be documented OpenMP/spec#4571 Issue 4571: Add missing sentence about private to defaultmap OpenMP/spec#4577 Testing: Updated 'defaultmap' error message and codegen LIT tests to verify behavior of 'private' in OpenMP 6.0.
1 parent f4eab92 commit 44241ab

File tree

6 files changed

+783
-11
lines changed

6 files changed

+783
-11
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ OpenMP Support
533533
- Properly handle array section/assumed-size array privatization in C/C++.
534534
- Added support for ``variable-category`` modifier in ``default clause``.
535535
- Added support for ``defaultmap`` directive implicit-behavior ``storage``.
536+
- Added support for ``defaultmap`` directive implicit-behavior ``private``.
536537

537538
Improvements
538539
^^^^^^^^^^^^

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ OPENMP_DEFAULTMAP_MODIFIER(none)
138138
OPENMP_DEFAULTMAP_MODIFIER(default)
139139
OPENMP_DEFAULTMAP_MODIFIER(present)
140140
OPENMP_DEFAULTMAP_MODIFIER(storage)
141+
OPENMP_DEFAULTMAP_MODIFIER(private)
141142

142143
// Static attributes for 'depend' clause.
143144
OPENMP_DEPEND_KIND(in)

clang/lib/Basic/OpenMPKinds.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
118118
.Case(#Name, static_cast<unsigned>(OMPC_DEFAULTMAP_MODIFIER_##Name))
119119
#include "clang/Basic/OpenMPKinds.def"
120120
.Default(OMPC_DEFAULTMAP_unknown);
121-
if (LangOpts.OpenMP < 60 && Type == OMPC_DEFAULTMAP_MODIFIER_storage)
121+
if (LangOpts.OpenMP < 60 && (Type == OMPC_DEFAULTMAP_MODIFIER_storage ||
122+
Type == OMPC_DEFAULTMAP_MODIFIER_private))
122123
return OMPC_DEFAULTMAP_MODIFIER_unknown;
123124
return Type;
124125
}

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,7 @@ getMapClauseKindFromModifier(OpenMPDefaultmapClauseModifier M,
37703770
Kind = OMPC_MAP_alloc;
37713771
break;
37723772
case OMPC_DEFAULTMAP_MODIFIER_firstprivate:
3773+
case OMPC_DEFAULTMAP_MODIFIER_private:
37733774
case OMPC_DEFAULTMAP_MODIFIER_last:
37743775
llvm_unreachable("Unexpected defaultmap implicit behavior");
37753776
case OMPC_DEFAULTMAP_MODIFIER_none:
@@ -4006,9 +4007,13 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
40064007
} else {
40074008
OpenMPDefaultmapClauseModifier M =
40084009
Stack->getDefaultmapModifier(ClauseKind);
4009-
OpenMPMapClauseKind Kind = getMapClauseKindFromModifier(
4010-
M, ClauseKind == OMPC_DEFAULTMAP_aggregate || Res);
4011-
ImpInfo.Mappings[ClauseKind][Kind].insert(E);
4010+
if (M == OMPC_DEFAULTMAP_MODIFIER_private) {
4011+
ImpInfo.Privates.insert(E);
4012+
} else {
4013+
OpenMPMapClauseKind Kind = getMapClauseKindFromModifier(
4014+
M, ClauseKind == OMPC_DEFAULTMAP_aggregate || Res);
4015+
ImpInfo.Mappings[ClauseKind][Kind].insert(E);
4016+
}
40124017
}
40134018
return;
40144019
}
@@ -23118,7 +23123,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPDefaultmapClause(
2311823123
? "'alloc', 'from', 'to', 'tofrom', "
2311923124
"'firstprivate', 'none', 'default', 'present'"
2312023125
: "'storage', 'from', 'to', 'tofrom', "
23121-
"'firstprivate', 'none', 'default', 'present'";
23126+
"'firstprivate', 'private', 'none', 'default', 'present'";
2312223127
if (!isDefaultmapKind && isDefaultmapModifier) {
2312323128
Diag(KindLoc, diag::err_omp_unexpected_clause_value)
2312423129
<< KindValue << getOpenMPClauseNameForDiag(OMPC_defaultmap);

0 commit comments

Comments
 (0)