diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -4746,14 +4746,24 @@ friend OMPVarListClause; friend TrailingObjects; - /// Dependency type (one of in, out, inout). - OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown; +public: + struct DependDataTy final { + /// Dependency type (one of in, out, inout). + OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown; - /// Dependency type location. - SourceLocation DepLoc; + /// Dependency type location. + SourceLocation DepLoc; - /// Colon location. - SourceLocation ColonLoc; + /// Colon location. + SourceLocation ColonLoc; + + /// Location of 'omp_all_memory'. + SourceLocation OmpAllMemoryLoc; + }; + +private: + /// Dependency type and source locations. + DependDataTy Data; /// Number of loops, associated with the depend clause. unsigned NumLoops = 0; @@ -4784,13 +4794,16 @@ NumLoops(NumLoops) {} /// Set dependency kind. - void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; } + void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; } /// Set dependency kind and its location. - void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; } + void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; } /// Set colon location. - void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } + void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; } + + /// Set the 'omp_all_memory' location. + void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; } /// Sets optional dependency modifier. void setModifier(Expr *DepModifier); @@ -4802,18 +4815,15 @@ /// \param StartLoc Starting location of the clause. /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. - /// \param DepKind Dependency type. - /// \param DepLoc Location of the dependency type. - /// \param ColonLoc Colon location. + /// \param Data Dependency type and source locations. /// \param VL List of references to the variables. /// \param NumLoops Number of loops that is associated with this depend /// clause. static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc, Expr *DepModifier, - OpenMPDependClauseKind DepKind, - SourceLocation DepLoc, SourceLocation ColonLoc, - ArrayRef VL, unsigned NumLoops); + SourceLocation EndLoc, DependDataTy Data, + Expr *DepModifier, ArrayRef VL, + unsigned NumLoops); /// Creates an empty clause with \a N variables. /// @@ -4825,7 +4835,16 @@ unsigned NumLoops); /// Get dependency type. - OpenMPDependClauseKind getDependencyKind() const { return DepKind; } + OpenMPDependClauseKind getDependencyKind() const { return Data.DepKind; } + + /// Get dependency type location. + SourceLocation getDependencyLoc() const { return Data.DepLoc; } + + /// Get colon location. + SourceLocation getColonLoc() const { return Data.ColonLoc; } + + /// Get 'omp_all_memory' location. + SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; } /// Return optional depend modifier. Expr *getModifier(); @@ -4833,12 +4852,6 @@ return const_cast(this)->getModifier(); } - /// Get dependency type location. - SourceLocation getDependencyLoc() const { return DepLoc; } - - /// Get colon location. - SourceLocation getColonLoc() const { return ColonLoc; } - /// Get number of loops associated with the clause. unsigned getNumLoops() const { return NumLoops; } diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1464,6 +1464,12 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_requires_out_inout_depend_type : Error< + "reserved locator 'omp_all_memory' requires 'out' or 'inout' " + "dependency types">; +def warn_omp_more_one_omp_all_memory : Warning< + "reserved locator 'omp_all_memory' cannot be specified more than once">, + InGroup; // Pragma loop support. def err_pragma_loop_missing_argument : Error< diff --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def --- a/clang/include/clang/Basic/OpenMPKinds.def +++ b/clang/include/clang/Basic/OpenMPKinds.def @@ -106,6 +106,8 @@ OPENMP_DEPEND_KIND(source) OPENMP_DEPEND_KIND(sink) OPENMP_DEPEND_KIND(inoutset) +OPENMP_DEPEND_KIND(outallmemory) +OPENMP_DEPEND_KIND(inoutallmemory) // Modifiers for 'linear' clause. OPENMP_LINEAR_KIND(val) diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3332,30 +3332,14 @@ ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand = false); - /// Data used for parsing list of variables in OpenMP clauses. - struct OpenMPVarListDataTy { - Expr *DepModOrTailExpr = nullptr; - SourceLocation ColonLoc; - SourceLocation RLoc; - CXXScopeSpec ReductionOrMapperIdScopeSpec; - DeclarationNameInfo ReductionOrMapperId; - int ExtraModifier = -1; ///< Additional modifier for linear, map, depend or - ///< lastprivate clause. - SmallVector - MapTypeModifiers; - SmallVector - MapTypeModifiersLoc; - SmallVector - MotionModifiers; - SmallVector MotionModifiersLoc; - bool IsMapTypeImplicit = false; - SourceLocation ExtraModifierLoc; - }; - + /// Parses a reserved locator like 'omp_all_memory'. + bool ParseOpenMPReservedLocator(OpenMPClauseKind Kind, + Sema::OpenMPVarListDataTy &Data, + const LangOptions &LangOpts); /// Parses clauses with list. bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl &Vars, - OpenMPVarListDataTy &Data); + Sema::OpenMPVarListDataTy &Data); bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, @@ -3363,11 +3347,11 @@ SourceLocation *TemplateKWLoc, UnqualifiedId &Result); /// Parses the mapper modifier in map, to, and from clauses. - bool parseMapperModifier(OpenMPVarListDataTy &Data); + bool parseMapperModifier(Sema::OpenMPVarListDataTy &Data); /// Parses map-type-modifiers in map clause. /// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) - bool parseMapTypeModifiers(OpenMPVarListDataTy &Data); + bool parseMapTypeModifiers(Sema::OpenMPVarListDataTy &Data); private: //===--------------------------------------------------------------------===// diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -11435,16 +11435,31 @@ OpenMPAtomicDefaultMemOrderClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); - OMPClause *ActOnOpenMPVarListClause( - OpenMPClauseKind Kind, ArrayRef Vars, Expr *DepModOrTailExpr, - const OMPVarListLocTy &Locs, SourceLocation ColonLoc, - CXXScopeSpec &ReductionOrMapperIdScopeSpec, - DeclarationNameInfo &ReductionOrMapperId, int ExtraModifier, - ArrayRef MapTypeModifiers, - ArrayRef MapTypeModifiersLoc, bool IsMapTypeImplicit, - SourceLocation ExtraModifierLoc, - ArrayRef MotionModifiers, - ArrayRef MotionModifiersLoc); + /// Data used for processing a list of variables in OpenMP clauses. + struct OpenMPVarListDataTy final { + Expr *DepModOrTailExpr = nullptr; + SourceLocation ColonLoc; + SourceLocation RLoc; + CXXScopeSpec ReductionOrMapperIdScopeSpec; + DeclarationNameInfo ReductionOrMapperId; + int ExtraModifier = -1; ///< Additional modifier for linear, map, depend or + ///< lastprivate clause. + SmallVector + MapTypeModifiers; + SmallVector + MapTypeModifiersLoc; + SmallVector + MotionModifiers; + SmallVector MotionModifiersLoc; + bool IsMapTypeImplicit = false; + SourceLocation ExtraModifierLoc; + SourceLocation OmpAllMemoryLoc; + }; + + OMPClause *ActOnOpenMPVarListClause(OpenMPClauseKind Kind, + ArrayRef Vars, + const OMPVarListLocTy &Locs, + OpenMPVarListDataTy &Data); /// Called on well-formed 'inclusive' clause. OMPClause *ActOnOpenMPInclusiveClause(ArrayRef VarList, SourceLocation StartLoc, @@ -11535,11 +11550,12 @@ SourceLocation LParenLoc, SourceLocation EndLoc); /// Called on well-formed 'depend' clause. - OMPClause * - ActOnOpenMPDependClause(Expr *DepModifier, OpenMPDependClauseKind DepKind, - SourceLocation DepLoc, SourceLocation ColonLoc, - ArrayRef VarList, SourceLocation StartLoc, - SourceLocation LParenLoc, SourceLocation EndLoc); + OMPClause *ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, + Expr *DepModifier, + ArrayRef VarList, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// Called on well-formed 'device' clause. OMPClause *ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp --- a/clang/lib/AST/OpenMPClause.cpp +++ b/clang/lib/AST/OpenMPClause.cpp @@ -1040,19 +1040,19 @@ OMPDependClause * OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, - Expr *DepModifier, OpenMPDependClauseKind DepKind, - SourceLocation DepLoc, SourceLocation ColonLoc, + DependDataTy Data, Expr *DepModifier, ArrayRef VL, unsigned NumLoops) { void *Mem = C.Allocate( totalSizeToAlloc(VL.size() + /*depend-modifier*/ 1 + NumLoops), alignof(OMPDependClause)); OMPDependClause *Clause = new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops); - Clause->setVarRefs(VL); - Clause->setDependencyKind(DepKind); - Clause->setDependencyLoc(DepLoc); - Clause->setColonLoc(ColonLoc); + Clause->setDependencyKind(Data.DepKind); + Clause->setDependencyLoc(Data.DepLoc); + Clause->setColonLoc(Data.ColonLoc); + Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc); Clause->setModifier(DepModifier); + Clause->setVarRefs(VL); for (unsigned I = 0 ; I < NumLoops; ++I) Clause->setLoopData(I, nullptr); return Clause; @@ -2183,11 +2183,23 @@ DepModifier->printPretty(OS, nullptr, Policy); OS << ", "; } - OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), - Node->getDependencyKind()); - if (!Node->varlist_empty()) { + OpenMPDependClauseKind DepKind = Node->getDependencyKind(); + OpenMPDependClauseKind PrintKind = DepKind; + bool IsOmpAllMemory = false; + if (PrintKind == OMPC_DEPEND_outallmemory) { + PrintKind = OMPC_DEPEND_out; + IsOmpAllMemory = true; + } else if (PrintKind == OMPC_DEPEND_inoutallmemory) { + PrintKind = OMPC_DEPEND_inout; + IsOmpAllMemory = true; + } + OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), PrintKind); + if (!Node->varlist_empty() || IsOmpAllMemory) OS << " :"; - VisitOMPClauseList(Node, ' '); + VisitOMPClauseList(Node, ' '); + if (IsOmpAllMemory) { + OS << (Node->varlist_empty() ? " " : ","); + OS << "omp_all_memory"; } OS << ")"; } diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -4534,6 +4534,8 @@ case OMPC_DEPEND_source: case OMPC_DEPEND_sink: case OMPC_DEPEND_depobj: + case OMPC_DEPEND_outallmemory: + case OMPC_DEPEND_inoutallmemory: case OMPC_DEPEND_unknown: llvm_unreachable("Unknown task dependence type"); } diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -744,7 +744,7 @@ OpenMPClauseKind CKind = getOpenMPClauseKind(ClauseName); if (CKind == OMPC_uniform || CKind == OMPC_aligned || CKind == OMPC_linear) { - Parser::OpenMPVarListDataTy Data; + Sema::OpenMPVarListDataTy Data; SmallVectorImpl *Vars = &Uniforms; if (CKind == OMPC_aligned) { Vars = &Aligneds; @@ -1437,7 +1437,7 @@ case OMPC_adjust_args: { AdjustArgsLoc = Tok.getLocation(); ConsumeToken(); - Parser::OpenMPVarListDataTy Data; + Sema::OpenMPVarListDataTy Data; SmallVector Vars; IsError = ParseOpenMPVarList(OMPD_declare_variant, OMPC_adjust_args, Vars, Data); @@ -3893,7 +3893,7 @@ } /// Parse the mapper modifier in map, to, and from clauses. -bool Parser::parseMapperModifier(OpenMPVarListDataTy &Data) { +bool Parser::parseMapperModifier(Sema::OpenMPVarListDataTy &Data) { // Parse '('. BalancedDelimiterTracker T(*this, tok::l_paren, tok::colon); if (T.expectAndConsume(diag::err_expected_lparen_after, "mapper")) { @@ -3925,7 +3925,7 @@ /// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) | /// present -bool Parser::parseMapTypeModifiers(OpenMPVarListDataTy &Data) { +bool Parser::parseMapTypeModifiers(Sema::OpenMPVarListDataTy &Data) { while (getCurToken().isNot(tok::colon)) { OpenMPMapModifierKind TypeModifier = isMapModifier(*this); if (TypeModifier == OMPC_MAP_MODIFIER_always || @@ -3981,7 +3981,7 @@ /// Parse map-type in map clause. /// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) /// where, map-type ::= to | from | tofrom | alloc | release | delete -static void parseMapType(Parser &P, Parser::OpenMPVarListDataTy &Data) { +static void parseMapType(Parser &P, Sema::OpenMPVarListDataTy &Data) { Token Tok = P.getCurToken(); if (Tok.is(tok::colon)) { P.Diag(Tok, diag::err_omp_map_type_missing); @@ -4100,11 +4100,38 @@ Data); } +bool Parser::ParseOpenMPReservedLocator(OpenMPClauseKind Kind, + Sema::OpenMPVarListDataTy &Data, + const LangOptions &LangOpts) { + // Currently the only reserved locator is 'omp_all_memory' which is only + // allowed on a depend clause. + if (Kind != OMPC_depend || LangOpts.OpenMP < 51) + return false; + + if (Tok.is(tok::identifier) && + Tok.getIdentifierInfo()->isStr("omp_all_memory")) { + + if (Data.ExtraModifier == OMPC_DEPEND_outallmemory || + Data.ExtraModifier == OMPC_DEPEND_inoutallmemory) + Diag(Tok, diag::warn_omp_more_one_omp_all_memory); + else if (Data.ExtraModifier != OMPC_DEPEND_out && + Data.ExtraModifier != OMPC_DEPEND_inout) + Diag(Tok, diag::err_omp_requires_out_inout_depend_type); + else + Data.ExtraModifier = Data.ExtraModifier == OMPC_DEPEND_out + ? OMPC_DEPEND_outallmemory + : OMPC_DEPEND_inoutallmemory; + ConsumeToken(); + return true; + } + return false; +} + /// Parses clauses with list. bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl &Vars, - OpenMPVarListDataTy &Data) { + Sema::OpenMPVarListDataTy &Data) { UnqualifiedId UnqualifiedReductionId; bool InvalidReductionId = false; bool IsInvalidMapperModifier = false; @@ -4360,14 +4387,16 @@ Tok.isNot(tok::annot_pragma_openmp_end))) { ParseScope OMPListScope(this, Scope::OpenMPDirectiveScope); ColonProtectionRAIIObject ColonRAII(*this, MayHaveTail); - // Parse variable - ExprResult VarExpr = - Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()); - if (VarExpr.isUsable()) { - Vars.push_back(VarExpr.get()); - } else { - SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end, - StopBeforeMatch); + if (!ParseOpenMPReservedLocator(Kind, Data, getLangOpts())) { + // Parse variable + ExprResult VarExpr = + Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()); + if (VarExpr.isUsable()) { + Vars.push_back(VarExpr.get()); + } else { + SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end, + StopBeforeMatch); + } } // Skip ',' if any IsComma = Tok.is(tok::comma); @@ -4476,7 +4505,7 @@ SourceLocation Loc = Tok.getLocation(); SourceLocation LOpen = ConsumeToken(); SmallVector Vars; - OpenMPVarListDataTy Data; + Sema::OpenMPVarListDataTy Data; if (ParseOpenMPVarList(DKind, Kind, Vars, Data)) return nullptr; @@ -4484,10 +4513,5 @@ if (ParseOnly) return nullptr; OMPVarListLocTy Locs(Loc, LOpen, Data.RLoc); - return Actions.ActOnOpenMPVarListClause( - Kind, Vars, Data.DepModOrTailExpr, Locs, Data.ColonLoc, - Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId, - Data.ExtraModifier, Data.MapTypeModifiers, Data.MapTypeModifiersLoc, - Data.IsMapTypeImplicit, Data.ExtraModifierLoc, Data.MotionModifiers, - Data.MotionModifiersLoc); + return Actions.ActOnOpenMPVarListClause(Kind, Vars, Locs, Data); } diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -16158,8 +16158,9 @@ SourceLocation EndLoc) { if (Kind == OMPC_DEPEND_unknown || Kind == OMPC_DEPEND_source || Kind == OMPC_DEPEND_sink || Kind == OMPC_DEPEND_depobj) { - SmallVector Except = {OMPC_DEPEND_source, OMPC_DEPEND_sink, - OMPC_DEPEND_depobj}; + SmallVector Except = { + OMPC_DEPEND_source, OMPC_DEPEND_sink, OMPC_DEPEND_depobj, + OMPC_DEPEND_outallmemory, OMPC_DEPEND_inoutallmemory}; if (LangOpts.OpenMP < 51) Except.push_back(OMPC_DEPEND_inoutset); Diag(KindKwLoc, diag::err_omp_unexpected_clause_value) @@ -16969,20 +16970,17 @@ StartLoc, LParenLoc, EndLoc); } -OMPClause *Sema::ActOnOpenMPVarListClause( - OpenMPClauseKind Kind, ArrayRef VarList, Expr *DepModOrTailExpr, - const OMPVarListLocTy &Locs, SourceLocation ColonLoc, - CXXScopeSpec &ReductionOrMapperIdScopeSpec, - DeclarationNameInfo &ReductionOrMapperId, int ExtraModifier, - ArrayRef MapTypeModifiers, - ArrayRef MapTypeModifiersLoc, bool IsMapTypeImplicit, - SourceLocation ExtraModifierLoc, - ArrayRef MotionModifiers, - ArrayRef MotionModifiersLoc) { +OMPClause *Sema::ActOnOpenMPVarListClause(OpenMPClauseKind Kind, + ArrayRef VarList, + const OMPVarListLocTy &Locs, + OpenMPVarListDataTy &Data) { SourceLocation StartLoc = Locs.StartLoc; SourceLocation LParenLoc = Locs.LParenLoc; SourceLocation EndLoc = Locs.EndLoc; OMPClause *Res = nullptr; + int ExtraModifier = Data.ExtraModifier; + SourceLocation ExtraModifierLoc = Data.ExtraModifierLoc; + SourceLocation ColonLoc = Data.ColonLoc; switch (Kind) { case OMPC_private: Res = ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc, EndLoc); @@ -17006,28 +17004,28 @@ Res = ActOnOpenMPReductionClause( VarList, static_cast(ExtraModifier), StartLoc, LParenLoc, ExtraModifierLoc, ColonLoc, EndLoc, - ReductionOrMapperIdScopeSpec, ReductionOrMapperId); + Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId); break; case OMPC_task_reduction: - Res = ActOnOpenMPTaskReductionClause(VarList, StartLoc, LParenLoc, ColonLoc, - EndLoc, ReductionOrMapperIdScopeSpec, - ReductionOrMapperId); + Res = ActOnOpenMPTaskReductionClause( + VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, + Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId); break; case OMPC_in_reduction: - Res = ActOnOpenMPInReductionClause(VarList, StartLoc, LParenLoc, ColonLoc, - EndLoc, ReductionOrMapperIdScopeSpec, - ReductionOrMapperId); + Res = ActOnOpenMPInReductionClause( + VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, + Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId); break; case OMPC_linear: assert(0 <= ExtraModifier && ExtraModifier <= OMPC_LINEAR_unknown && "Unexpected linear modifier."); Res = ActOnOpenMPLinearClause( - VarList, DepModOrTailExpr, StartLoc, LParenLoc, + VarList, Data.DepModOrTailExpr, StartLoc, LParenLoc, static_cast(ExtraModifier), ExtraModifierLoc, ColonLoc, EndLoc); break; case OMPC_aligned: - Res = ActOnOpenMPAlignedClause(VarList, DepModOrTailExpr, StartLoc, + Res = ActOnOpenMPAlignedClause(VarList, Data.DepModOrTailExpr, StartLoc, LParenLoc, ColonLoc, EndLoc); break; case OMPC_copyin: @@ -17043,26 +17041,30 @@ assert(0 <= ExtraModifier && ExtraModifier <= OMPC_DEPEND_unknown && "Unexpected depend modifier."); Res = ActOnOpenMPDependClause( - DepModOrTailExpr, static_cast(ExtraModifier), - ExtraModifierLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc); + {static_cast(ExtraModifier), ExtraModifierLoc, + ColonLoc, Data.OmpAllMemoryLoc}, + Data.DepModOrTailExpr, VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_map: assert(0 <= ExtraModifier && ExtraModifier <= OMPC_MAP_unknown && "Unexpected map modifier."); Res = ActOnOpenMPMapClause( - MapTypeModifiers, MapTypeModifiersLoc, ReductionOrMapperIdScopeSpec, - ReductionOrMapperId, static_cast(ExtraModifier), - IsMapTypeImplicit, ExtraModifierLoc, ColonLoc, VarList, Locs); + Data.MapTypeModifiers, Data.MapTypeModifiersLoc, + Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId, + static_cast(ExtraModifier), Data.IsMapTypeImplicit, + ExtraModifierLoc, ColonLoc, VarList, Locs); break; case OMPC_to: - Res = ActOnOpenMPToClause(MotionModifiers, MotionModifiersLoc, - ReductionOrMapperIdScopeSpec, ReductionOrMapperId, - ColonLoc, VarList, Locs); + Res = + ActOnOpenMPToClause(Data.MotionModifiers, Data.MotionModifiersLoc, + Data.ReductionOrMapperIdScopeSpec, + Data.ReductionOrMapperId, ColonLoc, VarList, Locs); break; case OMPC_from: - Res = ActOnOpenMPFromClause(MotionModifiers, MotionModifiersLoc, - ReductionOrMapperIdScopeSpec, - ReductionOrMapperId, ColonLoc, VarList, Locs); + Res = ActOnOpenMPFromClause(Data.MotionModifiers, Data.MotionModifiersLoc, + Data.ReductionOrMapperIdScopeSpec, + Data.ReductionOrMapperId, ColonLoc, VarList, + Locs); break; case OMPC_use_device_ptr: Res = ActOnOpenMPUseDevicePtrClause(VarList, Locs); @@ -17077,7 +17079,7 @@ Res = ActOnOpenMPHasDeviceAddrClause(VarList, Locs); break; case OMPC_allocate: - Res = ActOnOpenMPAllocateClause(DepModOrTailExpr, VarList, StartLoc, + Res = ActOnOpenMPAllocateClause(Data.DepModOrTailExpr, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc); break; case OMPC_nontemporal: @@ -17091,7 +17093,7 @@ break; case OMPC_affinity: Res = ActOnOpenMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, - DepModOrTailExpr, VarList); + Data.DepModOrTailExpr, VarList); break; case OMPC_if: case OMPC_depobj: @@ -19684,10 +19686,12 @@ } OMPClause * -Sema::ActOnOpenMPDependClause(Expr *DepModifier, OpenMPDependClauseKind DepKind, - SourceLocation DepLoc, SourceLocation ColonLoc, - ArrayRef VarList, SourceLocation StartLoc, - SourceLocation LParenLoc, SourceLocation EndLoc) { +Sema::ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, + Expr *DepModifier, ArrayRef VarList, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) { + OpenMPDependClauseKind DepKind = Data.DepKind; + SourceLocation DepLoc = Data.DepLoc; if (DSAStack->getCurrentDirective() == OMPD_ordered && DepKind != OMPC_DEPEND_source && DepKind != OMPC_DEPEND_sink) { Diag(DepLoc, diag::err_omp_unexpected_clause_value) @@ -19706,9 +19710,9 @@ ((LangOpts.OpenMP < 50 || DSAStack->getCurrentDirective() == OMPD_depobj) && DepKind == OMPC_DEPEND_depobj))) { - SmallVector Except; - Except.push_back(OMPC_DEPEND_source); - Except.push_back(OMPC_DEPEND_sink); + SmallVector Except = {OMPC_DEPEND_source, OMPC_DEPEND_sink, + OMPC_DEPEND_outallmemory, + OMPC_DEPEND_inoutallmemory}; if (LangOpts.OpenMP < 50 || DSAStack->getCurrentDirective() == OMPD_depobj) Except.push_back(OMPC_DEPEND_depobj); if (LangOpts.OpenMP < 51) @@ -19934,12 +19938,14 @@ << 1 << DSAStack->getParentLoopControlVariable(VarList.size() + 1); } if (DepKind != OMPC_DEPEND_source && DepKind != OMPC_DEPEND_sink && - Vars.empty()) + DepKind != OMPC_DEPEND_outallmemory && + DepKind != OMPC_DEPEND_inoutallmemory && Vars.empty()) return nullptr; - auto *C = OMPDependClause::Create(Context, StartLoc, LParenLoc, EndLoc, - DepModifier, DepKind, DepLoc, ColonLoc, - Vars, TotalDepCount.getZExtValue()); + auto *C = OMPDependClause::Create( + Context, StartLoc, LParenLoc, EndLoc, + {DepKind, DepLoc, Data.ColonLoc, Data.OmpAllMemoryLoc}, DepModifier, Vars, + TotalDepCount.getZExtValue()); if ((DepKind == OMPC_DEPEND_sink || DepKind == OMPC_DEPEND_source) && DSAStack->isParentOrderedRegion()) DSAStack->addDoacrossDependClause(C, OpsOffs); diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1919,14 +1919,13 @@ /// /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. - OMPClause * - RebuildOMPDependClause(Expr *DepModifier, OpenMPDependClauseKind DepKind, - SourceLocation DepLoc, SourceLocation ColonLoc, - ArrayRef VarList, SourceLocation StartLoc, - SourceLocation LParenLoc, SourceLocation EndLoc) { - return getSema().ActOnOpenMPDependClause(DepModifier, DepKind, DepLoc, - ColonLoc, VarList, StartLoc, - LParenLoc, EndLoc); + OMPClause *RebuildOMPDependClause(OMPDependClause::DependDataTy Data, + Expr *DepModifier, ArrayRef VarList, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPDependClause(Data, DepModifier, VarList, + StartLoc, LParenLoc, EndLoc); } /// Build a new OpenMP 'device' clause. @@ -10040,9 +10039,9 @@ Vars.push_back(EVar.get()); } return getDerived().RebuildOMPDependClause( - DepModifier, C->getDependencyKind(), C->getDependencyLoc(), - C->getColonLoc(), Vars, C->getBeginLoc(), C->getLParenLoc(), - C->getEndLoc()); + {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(), + C->getOmpAllMemoryLoc()}, + DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); } template diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -12490,6 +12490,7 @@ static_cast(Record.readInt())); C->setDependencyLoc(Record.readSourceLocation()); C->setColonLoc(Record.readSourceLocation()); + C->setOmpAllMemoryLoc(Record.readSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -6592,6 +6592,7 @@ Record.push_back(C->getDependencyKind()); Record.AddSourceLocation(C->getDependencyLoc()); Record.AddSourceLocation(C->getColonLoc()); + Record.AddSourceLocation(C->getOmpAllMemoryLoc()); for (auto *VE : C->varlists()) Record.AddStmt(VE); for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I) diff --git a/clang/test/OpenMP/task_ast_print.cpp b/clang/test/OpenMP/task_ast_print.cpp --- a/clang/test/OpenMP/task_ast_print.cpp +++ b/clang/test/OpenMP/task_ast_print.cpp @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s -// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s -// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s -// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s // expected-no-diagnostics #ifndef HEADER @@ -188,6 +188,18 @@ // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp task in_reduction(+: arr1) #pragma omp task in_reduction(+: arr1) + foo(); + // CHECK-NEXT: foo(); + // CHECK-NEXT: #pragma omp task depend(out : arr,omp_all_memory) +#pragma omp task depend(out: omp_all_memory, arr) + foo(); + // CHECK-NEXT: foo(); + // CHECK-NEXT: #pragma omp task depend(inout : b,arr,a,x,omp_all_memory) +#pragma omp task depend(inout: b, arr, omp_all_memory, a, x) + foo(); + // CHECK-NEXT: foo(); + // CHECK-NEXT: #pragma omp task depend(inout : omp_all_memory) +#pragma omp task depend(inout: omp_all_memory) foo(); // CHECK-NEXT: foo(); return tmain(b, &b) + tmain(x, &x); diff --git a/clang/test/OpenMP/task_depend_messages.cpp b/clang/test/OpenMP/task_depend_messages.cpp --- a/clang/test/OpenMP/task_depend_messages.cpp +++ b/clang/test/OpenMP/task_depend_messages.cpp @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized -// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-version=51 -fopenmp -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized +// RUN: %clang_cc1 -verify=expected,omp51,omp51warn -fopenmp-version=51 -fopenmp -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp-simd -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized -// RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-version=51 -fopenmp-simd -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized +// RUN: %clang_cc1 -verify=expected,omp51,omp51warn -fopenmp-version=51 -fopenmp-simd -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized typedef void *omp_depend_t; @@ -85,6 +85,10 @@ argc = 0; #pragma omp task depend(iterator(i = 0:10, i = 0:10), in : argv[i]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp45-error {{use of undeclared identifier 'i'}} omp50-error {{redefinition of 'i'}} omp50-note {{previous definition is here}} omp51-error {{redefinition of 'i'}} omp51-note {{previous definition is here}} i = 0; // expected-error {{use of undeclared identifier 'i'}} - +#pragma omp task depend(in: argc, omp_all_memory) // omp45-error {{use of undeclared identifier 'omp_all_memory'}} omp50-error {{use of undeclared identifier 'omp_all_memory'}} omp51-error {{reserved locator 'omp_all_memory' requires 'out' or 'inout' dependency types}} +#pragma omp task depend(out: omp_all_memory, argc, omp_all_memory) // omp45-error {{use of undeclared identifier 'omp_all_memory'}} omp45-error {{use of undeclared identifier 'omp_all_memory'}} omp50-error {{use of undeclared identifier 'omp_all_memory'}} omp50-error {{use of undeclared identifier 'omp_all_memory'}} omp51warn-warning {{reserved locator 'omp_all_memory' cannot be specified more than once}} + // expected-error@+1 {{use of undeclared identifier 'omp_all_memory'}} +#pragma omp task depend(out: argc) private(argc) allocate(argc, omp_all_memory) + argc = 0; return 0; }