diff options
author | Mike Rice <michael.p.rice@intel.com> | 2021-10-25 15:03:42 -0700 |
---|---|---|
committer | Mike Rice <michael.p.rice@intel.com> | 2021-10-28 07:44:27 -0700 |
commit | b663278e084c9fff51275a670631784d3b9f730f (patch) | |
tree | eafc08b2a17314b00a875eef6ee8ad145a26a0a7 /clang/lib | |
parent | bf87294cd4fa5781aa2fc0954e117712befedf87 (diff) | |
download | llvm-omp-loop.tar.gz |
[OpenMP] Initial parsing/sema for the 'omp loop' constructomp-loop
Adds basic parsing/sema/serialization support for the #pragma omp loop
directive.
Differential Revision: https://reviews.llvm.org/D112499
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/StmtOpenMP.cpp | 42 | ||||
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 5 | ||||
-rw-r--r-- | clang/lib/AST/StmtProfile.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Basic/OpenMPKinds.cpp | 10 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 10 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 1 | ||||
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExceptionSpec.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 89 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 11 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 5 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 1 |
14 files changed, 191 insertions, 6 deletions
diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp index 014274f46cae..aa28cd193736 100644 --- a/clang/lib/AST/StmtOpenMP.cpp +++ b/clang/lib/AST/StmtOpenMP.cpp @@ -2086,3 +2086,45 @@ OMPMaskedDirective *OMPMaskedDirective::CreateEmpty(const ASTContext &C, return createEmptyDirective<OMPMaskedDirective>(C, NumClauses, /*HasAssociatedStmt=*/true); } + +OMPGenericLoopDirective *OMPGenericLoopDirective::Create( + const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, + const HelperExprs &Exprs) { + auto *Dir = createDirective<OMPGenericLoopDirective>( + C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_loop), + StartLoc, EndLoc, CollapsedNum); + Dir->setIterationVariable(Exprs.IterationVarRef); + Dir->setLastIteration(Exprs.LastIteration); + Dir->setCalcLastIteration(Exprs.CalcLastIteration); + Dir->setPreCond(Exprs.PreCond); + Dir->setCond(Exprs.Cond); + Dir->setInit(Exprs.Init); + Dir->setInc(Exprs.Inc); + Dir->setIsLastIterVariable(Exprs.IL); + Dir->setLowerBoundVariable(Exprs.LB); + Dir->setUpperBoundVariable(Exprs.UB); + Dir->setStrideVariable(Exprs.ST); + Dir->setEnsureUpperBound(Exprs.EUB); + Dir->setNextLowerBound(Exprs.NLB); + Dir->setNextUpperBound(Exprs.NUB); + Dir->setNumIterations(Exprs.NumIterations); + Dir->setCounters(Exprs.Counters); + Dir->setPrivateCounters(Exprs.PrivateCounters); + Dir->setInits(Exprs.Inits); + Dir->setUpdates(Exprs.Updates); + Dir->setFinals(Exprs.Finals); + Dir->setDependentCounters(Exprs.DependentCounters); + Dir->setDependentInits(Exprs.DependentInits); + Dir->setFinalsConditions(Exprs.FinalsConditions); + Dir->setPreInits(Exprs.PreInits); + return Dir; +} + +OMPGenericLoopDirective * +OMPGenericLoopDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses, + unsigned CollapsedNum, EmptyShell) { + return createEmptyDirective<OMPGenericLoopDirective>( + C, NumClauses, /*HasAssociatedStmt=*/true, + numLoopChildren(CollapsedNum, OMPD_loop), CollapsedNum); +} diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index ce0b3bf62eb4..12af5bfa2013 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1000,6 +1000,11 @@ void StmtPrinter::VisitOMPMaskedDirective(OMPMaskedDirective *Node) { PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *Node) { + Indent() << "#pragma omp loop"; + PrintOMPExecutableDirective(Node); +} + //===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index 2184eb7aa010..4ea4322bfd0f 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -1190,6 +1190,11 @@ void StmtProfiler::VisitOMPMaskedDirective(const OMPMaskedDirective *S) { VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPGenericLoopDirective( + const OMPGenericLoopDirective *S) { + VisitOMPLoopDirective(S); +} + void StmtProfiler::VisitExpr(const Expr *S) { VisitStmt(S); } diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index d9ddb7ea0fc3..5b01bf863bb0 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -474,7 +474,7 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) { DKind == OMPD_target_teams_distribute_parallel_for || DKind == OMPD_target_teams_distribute_parallel_for_simd || DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile || - DKind == OMPD_unroll; + DKind == OMPD_unroll || DKind == OMPD_loop; } bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) { @@ -577,6 +577,10 @@ bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) { Kind == OMPD_target_teams_distribute_simd; } +bool clang::isOpenMPGenericLoopDirective(OpenMPDirectiveKind Kind) { + return Kind == OMPD_loop; +} + bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) { return Kind == OMPC_private || Kind == OMPC_firstprivate || Kind == OMPC_lastprivate || Kind == OMPC_linear || @@ -675,6 +679,10 @@ void clang::getOpenMPCaptureRegions( CaptureRegions.push_back(OMPD_teams); CaptureRegions.push_back(OMPD_parallel); break; + case OMPD_loop: + // TODO: 'loop' may require different capture regions depending on the bind + // clause or the parent directive when there is no bind clause. Use + // OMPD_unknown for now. case OMPD_simd: case OMPD_for: case OMPD_for_simd: diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 2aa3bfc76d84..6768a72319b0 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -393,6 +393,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) { case Stmt::OMPMaskedDirectiveClass: EmitOMPMaskedDirective(cast<OMPMaskedDirective>(*S)); break; + case Stmt::OMPGenericLoopDirectiveClass: + EmitOMPGenericLoopDirective(cast<OMPGenericLoopDirective>(*S)); + break; } } diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 991c9573f897..b80f663a50a5 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -7239,6 +7239,16 @@ void CodeGenFunction::EmitOMPTargetUpdateDirective( CGM.getOpenMPRuntime().emitTargetDataStandAloneCall(*this, S, IfCond, Device); } +void CodeGenFunction::EmitOMPGenericLoopDirective( + const OMPGenericLoopDirective &S) { + // Unimplemented, just inline the underlying statement for now. + auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) { + CGF.EmitStmt(cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt()); + }; + OMPLexicalScope Scope(*this, S, OMPD_unknown); + CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_loop, CodeGen); +} + void CodeGenFunction::EmitSimpleOMPExecutableDirective( const OMPExecutableDirective &D) { if (const auto *SD = dyn_cast<OMPScanDirective>(&D)) { diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index b996585d5f27..dd60e21b0ce1 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -3529,6 +3529,7 @@ public: const OMPTargetTeamsDistributeParallelForSimdDirective &S); void EmitOMPTargetTeamsDistributeSimdDirective( const OMPTargetTeamsDistributeSimdDirective &S); + void EmitOMPGenericLoopDirective(const OMPGenericLoopDirective &S); /// Emit device code for the target directive. static void EmitOMPTargetDeviceFunction(CodeGenModule &CGM, diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index d38e088a4706..d0114b8fdae7 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2375,6 +2375,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( case OMPD_dispatch: case OMPD_masked: case OMPD_metadirective: + case OMPD_loop: Diag(Tok, diag::err_omp_unexpected_directive) << 1 << getOpenMPDirectiveName(DKind); break; @@ -2724,6 +2725,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) { case OMPD_target_data: case OMPD_target_parallel: case OMPD_target_parallel_for: + case OMPD_loop: case OMPD_taskloop: case OMPD_taskloop_simd: case OMPD_master_taskloop: diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index f32bb0d298ba..3af4c6f4bc41 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -1497,6 +1497,7 @@ CanThrowResult Sema::canThrow(const Stmt *S) { case Stmt::OMPDispatchDirectiveClass: case Stmt::OMPMaskedDirectiveClass: case Stmt::OMPMetaDirectiveClass: + case Stmt::OMPGenericLoopDirectiveClass: case Stmt::ReturnStmtClass: case Stmt::SEHExceptStmtClass: case Stmt::SEHFinallyStmtClass: diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index f5937df17d82..fa55f925d117 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -4013,6 +4013,9 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) { case OMPD_tile: case OMPD_unroll: break; + case OMPD_loop: + // TODO: 'loop' may require additional parameters depending on the binding. + // Treat similar to OMPD_simd/OMPD_for for now. case OMPD_simd: case OMPD_for: case OMPD_for_simd: @@ -4788,6 +4791,7 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack, // A masked region may not be closely nested inside a worksharing, loop, // atomic, task, or taskloop region. NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) || + isOpenMPGenericLoopDirective(ParentRegion) || isOpenMPTaskingDirective(ParentRegion); } else if (CurrentRegion == OMPD_critical && CurrentName.getName()) { // OpenMP [2.16, Nesting of Regions] @@ -4821,6 +4825,7 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack, // task, taskloop, critical, ordered, atomic, or masked region. NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) || + isOpenMPGenericLoopDirective(ParentRegion) || isOpenMPTaskingDirective(ParentRegion) || ParentRegion == OMPD_master || ParentRegion == OMPD_masked || ParentRegion == OMPD_parallel_master || @@ -4834,6 +4839,7 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack, // critical, ordered, atomic, or masked region. NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) || + isOpenMPGenericLoopDirective(ParentRegion) || isOpenMPTaskingDirective(ParentRegion) || ParentRegion == OMPD_master || ParentRegion == OMPD_masked || ParentRegion == OMPD_parallel_master || @@ -4879,12 +4885,16 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack, !isOpenMPTargetExecutionDirective(CurrentRegion) && !isOpenMPTargetDataManagementDirective(CurrentRegion) && (ParentRegion == OMPD_teams || ParentRegion == OMPD_target_teams)) { - // OpenMP [2.16, Nesting of Regions] - // distribute, parallel, parallel sections, parallel workshare, and the - // parallel loop and parallel loop SIMD constructs are the only OpenMP - // constructs that can be closely nested in the teams region. + // OpenMP [5.1, 2.22, Nesting of Regions] + // distribute, distribute simd, distribute parallel worksharing-loop, + // distribute parallel worksharing-loop SIMD, loop, parallel regions, + // including any parallel regions arising from combined constructs, + // omp_get_num_teams() regions, and omp_get_team_num() regions are the + // only OpenMP regions that may be strictly nested inside the teams + // region. NestingProhibited = !isOpenMPParallelDirective(CurrentRegion) && - !isOpenMPDistributeDirective(CurrentRegion); + !isOpenMPDistributeDirective(CurrentRegion) && + CurrentRegion != OMPD_loop; Recommend = ShouldBeInParallelRegion; } if (!NestingProhibited && @@ -6231,6 +6241,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( Res = ActOnOpenMPDispatchDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); break; + case OMPD_loop: + Res = ActOnOpenMPGenericLoopDirective(ClausesWithImplicit, AStmt, StartLoc, + EndLoc, VarsWithInheritedDSA); + break; case OMPD_declare_target: case OMPD_end_declare_target: case OMPD_threadprivate: @@ -8817,6 +8831,7 @@ static bool checkOpenMPIterationSpace( ResultIterSpaces[CurrentNestedLoopCount].NumIterations = ISC.buildNumIterations(DSA.getCurScope(), ResultIterSpaces, (isOpenMPWorksharingDirective(DKind) || + isOpenMPGenericLoopDirective(DKind) || isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind) || isOpenMPLoopTransformationDirective(DKind)), @@ -9300,6 +9315,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, ExprResult LB, UB, IL, ST, EUB, CombLB, CombUB, PrevLB, PrevUB, CombEUB; if (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind) || + isOpenMPGenericLoopDirective(DKind) || isOpenMPLoopTransformationDirective(DKind)) { // Lower bound variable, initialized with zero. VarDecl *LBDecl = buildVarDecl(SemaRef, InitLoc, VType, ".omp.lb"); @@ -9399,6 +9415,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, VarDecl *IVDecl = buildVarDecl(SemaRef, InitLoc, RealVType, ".omp.iv"); IV = buildDeclRefExpr(SemaRef, IVDecl, RealVType, InitLoc); Expr *RHS = (isOpenMPWorksharingDirective(DKind) || + isOpenMPGenericLoopDirective(DKind) || isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind) || isOpenMPLoopTransformationDirective(DKind)) @@ -9410,6 +9427,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, if (isOpenMPLoopBoundSharingDirective(DKind)) { Expr *CombRHS = (isOpenMPWorksharingDirective(DKind) || + isOpenMPGenericLoopDirective(DKind) || isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind)) ? CombLB.get() @@ -9441,6 +9459,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, } ExprResult Cond = (isOpenMPWorksharingDirective(DKind) || + isOpenMPGenericLoopDirective(DKind) || isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind) || isOpenMPLoopTransformationDirective(DKind)) ? SemaRef.BuildBinOp(CurScope, CondLoc, @@ -9490,6 +9509,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, // base variables for the update ExprResult NextLB, NextUB, CombNextLB, CombNextUB; if (isOpenMPWorksharingDirective(DKind) || isOpenMPTaskLoopDirective(DKind) || + isOpenMPGenericLoopDirective(DKind) || isOpenMPDistributeDirective(DKind) || isOpenMPLoopTransformationDirective(DKind)) { // LB + ST @@ -10044,6 +10064,57 @@ StmtResult Sema::ActOnOpenMPDispatchDirective(ArrayRef<OMPClause *> Clauses, TargetCallLoc); } +StmtResult Sema::ActOnOpenMPGenericLoopDirective( + ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA) { + if (!AStmt) + return StmtError(); + + // OpenMP 5.1 [2.11.7, loop construct] + // A list item may not appear in a lastprivate clause unless it is the + // loop iteration variable of a loop that is associated with the construct. + for (OMPClause *C : Clauses) { + if (auto *LPC = dyn_cast<OMPLastprivateClause>(C)) { + for (Expr *RefExpr : LPC->varlists()) { + SourceLocation ELoc; + SourceRange ERange; + Expr *SimpleRefExpr = RefExpr; + auto Res = getPrivateItem(*this, SimpleRefExpr, ELoc, ERange); + if (ValueDecl *D = Res.first) { + auto &&Info = DSAStack->isLoopControlVariable(D); + if (!Info.first) { + Diag(ELoc, diag::err_omp_lastprivate_loop_var_non_loop_iteration); + return StmtError(); + } + } + } + } + } + + auto *CS = cast<CapturedStmt>(AStmt); + // 1.2.2 OpenMP Language Terminology + // Structured block - An executable statement with a single entry at the + // top and a single exit at the bottom. + // The point of exit cannot be a branch out of the structured block. + // longjmp() and throw() must not violate the entry/exit criteria. + CS->getCapturedDecl()->setNothrow(); + + OMPLoopDirective::HelperExprs B; + // In presence of clause 'collapse', it will define the nested loops number. + unsigned NestedLoopCount = checkOpenMPLoop( + OMPD_loop, getCollapseNumberExpr(Clauses), getOrderedNumberExpr(Clauses), + AStmt, *this, *DSAStack, VarsWithImplicitDSA, B); + if (NestedLoopCount == 0) + return StmtError(); + + assert((CurContext->isDependentContext() || B.builtAll()) && + "omp loop exprs were not built"); + + setFunctionHasBranchProtectedScope(); + return OMPGenericLoopDirective::Create(Context, StartLoc, EndLoc, + NestedLoopCount, Clauses, AStmt, B); +} + StmtResult Sema::ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, @@ -13529,6 +13600,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_teams: case OMPD_tile: case OMPD_unroll: @@ -13608,6 +13680,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_teams: case OMPD_simd: case OMPD_tile: @@ -13692,6 +13765,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_simd: case OMPD_tile: case OMPD_unroll: @@ -13773,6 +13847,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_simd: case OMPD_tile: case OMPD_unroll: @@ -13855,6 +13930,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_simd: case OMPD_tile: case OMPD_unroll: @@ -13936,6 +14012,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_simd: case OMPD_tile: case OMPD_unroll: @@ -14018,6 +14095,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_simd: case OMPD_tile: case OMPD_unroll: @@ -14101,6 +14179,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPD_end_declare_variant: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_loop: case OMPD_simd: case OMPD_tile: case OMPD_unroll: diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 3f6c84acaff1..cfc6e608bc59 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -9172,6 +9172,17 @@ TreeTransform<Derived>::TransformOMPMaskedDirective(OMPMaskedDirective *D) { return Res; } +template <typename Derived> +StmtResult TreeTransform<Derived>::TransformOMPGenericLoopDirective( + OMPGenericLoopDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_loop, DirName, nullptr, + D->getBeginLoc()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + //===----------------------------------------------------------------------===// // OpenMP clause transformation //===----------------------------------------------------------------------===// diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 4e6eaf77ff56..02910b763800 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -2632,6 +2632,10 @@ void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective *D) { VisitOMPExecutableDirective(D); } +void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) { + VisitOMPLoopDirective(D); +} + //===----------------------------------------------------------------------===// // ASTReader Implementation //===----------------------------------------------------------------------===// @@ -3578,6 +3582,14 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { Context, Record[ASTStmtReader::NumStmtFields], Empty); break; + case STMT_OMP_GENERIC_LOOP_DIRECTIVE: { + unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields]; + unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1]; + S = OMPGenericLoopDirective::CreateEmpty(Context, NumClauses, + CollapsedNum, Empty); + break; + } + case EXPR_CXX_OPERATOR_CALL: S = CXXOperatorCallExpr::CreateEmpty( Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 0e87bcce0e43..9fdd86765c5a 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -2589,6 +2589,11 @@ void ASTStmtWriter::VisitOMPMaskedDirective(OMPMaskedDirective *D) { Code = serialization::STMT_OMP_MASKED_DIRECTIVE; } +void ASTStmtWriter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective *D) { + VisitOMPLoopDirective(D); + Code = serialization::STMT_OMP_GENERIC_LOOP_DIRECTIVE; +} + //===----------------------------------------------------------------------===// // ASTWriter Implementation //===----------------------------------------------------------------------===// diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 2229dbf83500..df27069baadd 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1297,6 +1297,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred, case Stmt::OMPInteropDirectiveClass: case Stmt::OMPDispatchDirectiveClass: case Stmt::OMPMaskedDirectiveClass: + case Stmt::OMPGenericLoopDirectiveClass: case Stmt::CapturedStmtClass: case Stmt::OMPUnrollDirectiveClass: case Stmt::OMPMetaDirectiveClass: { |