r213360 - [OPENMP] Initial parsing and sema analysis for 'barrier' directive.
Alexey Bataev
a.bataev at hotmail.com
Fri Jul 18 02:11:52 PDT 2014
Author: abataev
Date: Fri Jul 18 04:11:51 2014
New Revision: 213360
URL: http://llvm.org/viewvc/llvm-project?rev=213360&view=rev
Log:
[OPENMP] Initial parsing and sema analysis for 'barrier' directive.
Added:
cfe/trunk/test/OpenMP/barrier_ast_print.cpp (with props)
cfe/trunk/test/OpenMP/barrier_messages.cpp (with props)
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jul 18 04:11:51 2014
@@ -2175,9 +2175,13 @@ enum CXCursorKind {
*/
CXCursor_OMPTaskyieldDirective = 242,
+ /** \brief OpenMP barrier directive.
+ */
+ CXCursor_OMPBarrierDirective = 243,
+
/** \brief Windows Structured Exception Handling's leave statement.
*/
- CXCursor_SEHLeaveStmt = 243,
+ CXCursor_SEHLeaveStmt = 244,
CXCursor_LastStmt = CXCursor_SEHLeaveStmt,
Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Fri Jul 18 04:11:51 2014
@@ -2312,6 +2312,9 @@ DEF_TRAVERSE_STMT(OMPTaskDirective,
DEF_TRAVERSE_STMT(OMPTaskyieldDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
+DEF_TRAVERSE_STMT(OMPBarrierDirective,
+ { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jul 18 04:11:51 2014
@@ -2334,6 +2334,9 @@ DEF_TRAVERSE_STMT(OMPTaskDirective,
DEF_TRAVERSE_STMT(OMPTaskyieldDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
+DEF_TRAVERSE_STMT(OMPBarrierDirective,
+ { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Jul 18 04:11:51 2014
@@ -818,6 +818,50 @@ public:
}
};
+/// \brief This represents '#pragma omp barrier' directive.
+///
+/// \code
+/// #pragma omp barrier
+/// \endcode
+///
+class OMPBarrierDirective : public OMPExecutableDirective {
+ friend class ASTStmtReader;
+ /// \brief Build directive with the given start and end location.
+ ///
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending location of the directive.
+ ///
+ OMPBarrierDirective(SourceLocation StartLoc, SourceLocation EndLoc)
+ : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
+ StartLoc, EndLoc, 0, 0) {}
+
+ /// \brief Build an empty directive.
+ ///
+ explicit OMPBarrierDirective()
+ : OMPExecutableDirective(this, OMPBarrierDirectiveClass, OMPD_barrier,
+ SourceLocation(), SourceLocation(), 0, 0) {}
+
+public:
+ /// \brief Creates directive.
+ ///
+ /// \param C AST context.
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending Location of the directive.
+ ///
+ static OMPBarrierDirective *
+ Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc);
+
+ /// \brief Creates an empty directive.
+ ///
+ /// \param C AST context.
+ ///
+ static OMPBarrierDirective *CreateEmpty(const ASTContext &C, EmptyShell);
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == OMPBarrierDirectiveClass;
+ }
+};
+
} // end namespace clang
#endif
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Fri Jul 18 04:11:51 2014
@@ -66,6 +66,7 @@ OPENMP_DIRECTIVE(section)
OPENMP_DIRECTIVE(single)
OPENMP_DIRECTIVE(master)
OPENMP_DIRECTIVE(taskyield)
+OPENMP_DIRECTIVE(barrier)
OPENMP_DIRECTIVE_EXT(parallel_for, "parallel for")
OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections")
Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/StmtNodes.td (original)
+++ cfe/trunk/include/clang/Basic/StmtNodes.td Fri Jul 18 04:11:51 2014
@@ -189,3 +189,4 @@ def OMPParallelForDirective : DStmt<OMPE
def OMPParallelSectionsDirective : DStmt<OMPExecutableDirective>;
def OMPTaskDirective : DStmt<OMPExecutableDirective>;
def OMPTaskyieldDirective : DStmt<OMPExecutableDirective>;
+def OMPBarrierDirective : DStmt<OMPExecutableDirective>;
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jul 18 04:11:51 2014
@@ -7368,10 +7368,12 @@ public:
StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc);
- /// \brief Called on well-formed '\#pragma omp taskyield' after parsing of the
- /// associated statement.
+ /// \brief Called on well-formed '\#pragma omp taskyield'.
StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc,
SourceLocation EndLoc);
+ /// \brief Called on well-formed '\#pragma omp barrier'.
+ StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
+ SourceLocation EndLoc);
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
Expr *Expr,
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Fri Jul 18 04:11:51 2014
@@ -1351,6 +1351,7 @@ namespace clang {
STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE,
STMT_OMP_TASK_DIRECTIVE,
STMT_OMP_TASKYIELD_DIRECTIVE,
+ STMT_OMP_BARRIER_DIRECTIVE,
// ARC
EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Fri Jul 18 04:11:51 2014
@@ -1589,3 +1589,17 @@ OMPTaskyieldDirective *OMPTaskyieldDirec
return new (Mem) OMPTaskyieldDirective();
}
+OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
+ SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
+ OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
+ return Dir;
+}
+
+OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
+ EmptyShell) {
+ void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
+ return new (Mem) OMPBarrierDirective();
+}
+
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Fri Jul 18 04:11:51 2014
@@ -855,6 +855,11 @@ void StmtPrinter::VisitOMPTaskyieldDirec
PrintOMPExecutableDirective(Node);
}
+void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) {
+ Indent() << "#pragma omp barrier";
+ PrintOMPExecutableDirective(Node);
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Jul 18 04:11:51 2014
@@ -411,6 +411,10 @@ void StmtProfiler::VisitOMPTaskyieldDire
VisitOMPExecutableDirective(S);
}
+void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
+ VisitOMPExecutableDirective(S);
+}
+
void StmtProfiler::VisitExpr(const Expr *S) {
VisitStmt(S);
}
Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Fri Jul 18 04:11:51 2014
@@ -258,6 +258,7 @@ bool clang::isAllowedClauseForDirective(
case OMPD_section:
case OMPD_master:
case OMPD_taskyield:
+ case OMPD_barrier:
break;
}
return false;
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Jul 18 04:11:51 2014
@@ -209,6 +209,9 @@ void CodeGenFunction::EmitStmt(const Stm
case Stmt::OMPTaskyieldDirectiveClass:
EmitOMPTaskyieldDirective(cast<OMPTaskyieldDirective>(*S));
break;
+ case Stmt::OMPBarrierDirectiveClass:
+ EmitOMPBarrierDirective(cast<OMPBarrierDirective>(*S));
+ break;
}
}
Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Jul 18 04:11:51 2014
@@ -112,3 +112,7 @@ void CodeGenFunction::EmitOMPTaskyieldDi
llvm_unreachable("CodeGen for 'omp taskyield' is not supported yet.");
}
+void CodeGenFunction::EmitOMPBarrierDirective(const OMPBarrierDirective &) {
+ llvm_unreachable("CodeGen for 'omp barrier' is not supported yet.");
+}
+
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Jul 18 04:11:51 2014
@@ -1932,6 +1932,7 @@ public:
void EmitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &S);
void EmitOMPTaskDirective(const OMPTaskDirective &S);
void EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &S);
+ void EmitOMPBarrierDirective(const OMPBarrierDirective &S);
//===--------------------------------------------------------------------===//
// LValue Expression Emission
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Fri Jul 18 04:11:51 2014
@@ -84,6 +84,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen
case OMPD_simd:
case OMPD_task:
case OMPD_taskyield:
+ case OMPD_barrier:
case OMPD_for:
case OMPD_sections:
case OMPD_section:
@@ -108,7 +109,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen
/// executable-directive:
/// annot_pragma_openmp 'parallel' | 'simd' | 'for' | 'sections' |
/// 'section' | 'single' | 'master' | 'parallel for' |
-/// 'parallel sections' | 'task' | 'taskyield' {clause}
+/// 'parallel sections' | 'task' | 'taskyield' | 'barrier' {clause}
/// annot_pragma_openmp_end
///
StmtResult
@@ -146,6 +147,7 @@ Parser::ParseOpenMPDeclarativeOrExecutab
SkipUntil(tok::annot_pragma_openmp_end);
break;
case OMPD_taskyield:
+ case OMPD_barrier:
if (!StandAloneAllowed) {
Diag(Tok, diag::err_omp_immediate_directive)
<< getOpenMPDirectiveName(DKind);
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jul 18 04:11:51 2014
@@ -1044,6 +1044,14 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
Params);
break;
}
+ case OMPD_barrier: {
+ Sema::CapturedParamNameType Params[] = {
+ std::make_pair(StringRef(), QualType()) // __context with shared vars
+ };
+ ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP,
+ Params);
+ break;
+ }
case OMPD_threadprivate:
llvm_unreachable("OpenMP Directive is not allowed");
case OMPD_unknown:
@@ -1069,6 +1077,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | parallel |parallel sections| * |
// | parallel | task | * |
// | parallel | taskyield | * |
+ // | parallel | barrier | * |
// +------------------+-----------------+------------------------------------+
// | for | parallel | * |
// | for | for | + |
@@ -1081,6 +1090,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | for |parallel sections| * |
// | for | task | * |
// | for | taskyield | * |
+ // | for | barrier | + |
// +------------------+-----------------+------------------------------------+
// | master | parallel | * |
// | master | for | + |
@@ -1093,6 +1103,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | master |parallel sections| * |
// | master | task | * |
// | master | taskyield | * |
+ // | master | barrier | + |
// +------------------+-----------------+------------------------------------+
// | simd | parallel | |
// | simd | for | |
@@ -1105,6 +1116,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | simd |parallel sections| |
// | simd | task | |
// | simd | taskyield | |
+ // | simd | barrier | |
// +------------------+-----------------+------------------------------------+
// | sections | parallel | * |
// | sections | for | + |
@@ -1117,6 +1129,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | sections |parallel sections| * |
// | sections | task | * |
// | sections | taskyield | * |
+ // | sections | barrier | + |
// +------------------+-----------------+------------------------------------+
// | section | parallel | * |
// | section | for | + |
@@ -1129,6 +1142,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | section |parallel sections| * |
// | section | task | * |
// | section | taskyield | * |
+ // | section | barrier | + |
// +------------------+-----------------+------------------------------------+
// | single | parallel | * |
// | single | for | + |
@@ -1141,6 +1155,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | single |parallel sections| * |
// | single | task | * |
// | single | taskyield | * |
+ // | single | barrier | + |
// +------------------+-----------------+------------------------------------+
// | parallel for | parallel | * |
// | parallel for | for | + |
@@ -1153,6 +1168,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | parallel for |parallel sections| * |
// | parallel for | task | * |
// | parallel for | taskyield | * |
+ // | parallel for | barrier | + |
// +------------------+-----------------+------------------------------------+
// | parallel sections| parallel | * |
// | parallel sections| for | + |
@@ -1165,6 +1181,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | parallel sections|parallel sections| * |
// | parallel sections| task | * |
// | parallel sections| taskyield | * |
+ // | parallel sections| barrier | + |
// +------------------+-----------------+------------------------------------+
// | task | parallel | * |
// | task | for | + |
@@ -1177,6 +1194,7 @@ bool CheckNestingOfRegions(Sema &SemaRef
// | task |parallel sections| * |
// | task | task | * |
// | task | taskyield | * |
+ // | task | barrier | + |
// +------------------+-----------------+------------------------------------+
if (Stack->getCurScope()) {
auto ParentRegion = Stack->getParentDirective();
@@ -1209,6 +1227,14 @@ bool CheckNestingOfRegions(Sema &SemaRef
// atomic (TODO), or explicit task region.
NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) ||
ParentRegion == OMPD_task;
+ } else if (CurrentRegion == OMPD_barrier) {
+ // OpenMP [2.16, Nesting of Regions]
+ // A barrier region may not be closely nested inside a worksharing,
+ // explicit task, critical(TODO), ordered(TODO), atomic(TODO), or master
+ // region.
+ NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) ||
+ ParentRegion == OMPD_task ||
+ ParentRegion == OMPD_master;
} else if (isOpenMPWorksharingDirective(CurrentRegion) &&
!isOpenMPParallelDirective(CurrentRegion) &&
!isOpenMPSimdDirective(CurrentRegion)) {
@@ -1318,6 +1344,13 @@ StmtResult Sema::ActOnOpenMPExecutableDi
"No associated statement allowed for 'omp taskyield' directive");
Res = ActOnOpenMPTaskyieldDirective(StartLoc, EndLoc);
break;
+ case OMPD_barrier:
+ assert(ClausesWithImplicit.empty() &&
+ "No clauses are allowed for 'omp barrier' directive");
+ assert(AStmt == nullptr &&
+ "No associated statement allowed for 'omp barrier' directive");
+ Res = ActOnOpenMPBarrierDirective(StartLoc, EndLoc);
+ break;
case OMPD_threadprivate:
llvm_unreachable("OpenMP Directive is not allowed");
case OMPD_unknown:
@@ -2066,6 +2099,11 @@ StmtResult Sema::ActOnOpenMPTaskyieldDir
return OMPTaskyieldDirective::Create(Context, StartLoc, EndLoc);
}
+StmtResult Sema::ActOnOpenMPBarrierDirective(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ return OMPBarrierDirective::Create(Context, StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
SourceLocation StartLoc,
SourceLocation LParenLoc,
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Jul 18 04:11:51 2014
@@ -6568,6 +6568,17 @@ StmtResult TreeTransform<Derived>::Trans
return Res;
}
+template <typename Derived>
+StmtResult
+TreeTransform<Derived>::TransformOMPBarrierDirective(OMPBarrierDirective *D) {
+ DeclarationNameInfo DirName;
+ getDerived().getSema().StartOpenMPDSABlock(OMPD_barrier, DirName, nullptr,
+ D->getLocStart());
+ StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
+ getDerived().getSema().EndOpenMPDSABlock(Res.get());
+ return Res;
+}
+
//===----------------------------------------------------------------------===//
// OpenMP clause transformation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Fri Jul 18 04:11:51 2014
@@ -1995,6 +1995,11 @@ void ASTStmtReader::VisitOMPTaskyieldDir
VisitOMPExecutableDirective(D);
}
+void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
+ VisitStmt(D);
+ VisitOMPExecutableDirective(D);
+}
+
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
@@ -2533,6 +2538,10 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
break;
+ case STMT_OMP_BARRIER_DIRECTIVE:
+ S = OMPBarrierDirective::CreateEmpty(Context, Empty);
+ break;
+
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Fri Jul 18 04:11:51 2014
@@ -1897,6 +1897,12 @@ void ASTStmtWriter::VisitOMPTaskyieldDir
Code = serialization::STMT_OMP_TASKYIELD_DIRECTIVE;
}
+void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
+ VisitStmt(D);
+ VisitOMPExecutableDirective(D);
+ Code = serialization::STMT_OMP_BARRIER_DIRECTIVE;
+}
+
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Jul 18 04:11:51 2014
@@ -742,6 +742,7 @@ void ExprEngine::Visit(const Stmt *S, Ex
case Stmt::OMPParallelSectionsDirectiveClass:
case Stmt::OMPTaskDirectiveClass:
case Stmt::OMPTaskyieldDirectiveClass:
+ case Stmt::OMPBarrierDirectiveClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
case Stmt::ObjCSubscriptRefExprClass:
Added: cfe/trunk/test/OpenMP/barrier_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/barrier_ast_print.cpp?rev=213360&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/barrier_ast_print.cpp (added)
+++ cfe/trunk/test/OpenMP/barrier_ast_print.cpp Fri Jul 18 04:11:51 2014
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+T tmain(T argc) {
+ static T a;
+#pragma omp barrier
+ return a + argc;
+}
+// CHECK: static int a;
+// CHECK-NEXT: #pragma omp barrier
+// CHECK: static char a;
+// CHECK-NEXT: #pragma omp barrier
+// CHECK: static T a;
+// CHECK-NEXT: #pragma omp barrier
+
+int main(int argc, char **argv) {
+ static int a;
+// CHECK: static int a;
+#pragma omp barrier
+ // CHECK-NEXT: #pragma omp barrier
+ return tmain(argc) + tmain(argv[0][0]) + a;
+}
+
+#endif
Propchange: cfe/trunk/test/OpenMP/barrier_ast_print.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/OpenMP/barrier_ast_print.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: cfe/trunk/test/OpenMP/barrier_ast_print.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cfe/trunk/test/OpenMP/barrier_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/barrier_messages.cpp?rev=213360&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/barrier_messages.cpp (added)
+++ cfe/trunk/test/OpenMP/barrier_messages.cpp Fri Jul 18 04:11:51 2014
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+template <class T>
+T tmain(T argc) {
+#pragma omp barrier
+ ;
+#pragma omp barrier untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp barrier'}}
+#pragma omp barrier unknown // expected-warning {{extra tokens at the end of '#pragma omp barrier' are ignored}}
+ if (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ if (argc) {
+#pragma omp barrier
+ }
+ while (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ while (argc) {
+#pragma omp barrier
+ }
+ do
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ while (argc)
+ ;
+ do {
+#pragma omp barrier
+ } while (argc);
+ switch (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ switch (argc)
+ case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ switch (argc)
+ case 1: {
+#pragma omp barrier
+ }
+ switch (argc) {
+#pragma omp barrier
+ case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ break;
+ default: {
+#pragma omp barrier
+ } break;
+ }
+ for (;;)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ for (;;) {
+#pragma omp barrier
+ }
+label:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+label1 : {
+#pragma omp barrier
+}
+
+ return T();
+}
+
+int main(int argc, char **argv) {
+#pragma omp barrier
+ ;
+#pragma omp barrier untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp barrier'}}
+#pragma omp barrier unknown // expected-warning {{extra tokens at the end of '#pragma omp barrier' are ignored}}
+ if (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ if (argc) {
+#pragma omp barrier
+ }
+ while (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ while (argc) {
+#pragma omp barrier
+ }
+ do
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ while (argc)
+ ;
+ do {
+#pragma omp barrier
+ } while (argc);
+ switch (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ switch (argc)
+ case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ switch (argc)
+ case 1: {
+#pragma omp barrier
+ }
+ switch (argc) {
+#pragma omp barrier
+ case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ break;
+ default: {
+#pragma omp barrier
+ } break;
+ }
+ for (;;)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+ for (;;) {
+#pragma omp barrier
+ }
+label:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+label1 : {
+#pragma omp barrier
+}
+
+ return tmain(argc);
+}
Propchange: cfe/trunk/test/OpenMP/barrier_messages.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/OpenMP/barrier_messages.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: cfe/trunk/test/OpenMP/barrier_messages.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Fri Jul 18 04:11:51 2014
@@ -51,6 +51,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp parallel
+ {
+#pragma omp barrier
+ bar();
+ }
// SIMD DIRECTIVE
#pragma omp simd
@@ -124,6 +129,11 @@ void foo() {
#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
bar();
}
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ bar();
+ }
// FOR DIRECTIVE
#pragma omp for
@@ -216,6 +226,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}}
+ bar();
+ }
// SECTIONS DIRECTIVE
#pragma omp sections
@@ -310,6 +325,10 @@ void foo() {
{
#pragma omp taskyield
}
+#pragma omp sections
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}}
+ }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
@@ -430,6 +449,14 @@ void foo() {
bar();
}
}
+#pragma omp sections
+ {
+#pragma omp section
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}}
+ bar();
+ }
+ }
// SINGLE DIRECTIVE
#pragma omp single
@@ -513,6 +540,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp single
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}}
+ bar();
+ }
// MASTER DIRECTIVE
#pragma omp master
@@ -596,6 +628,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp master
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}}
+ bar();
+ }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@@ -688,6 +725,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}}
+ bar();
+ }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
@@ -779,6 +821,10 @@ void foo() {
{
#pragma omp taskyield
}
+#pragma omp parallel sections
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}}
+ }
// TASK DIRECTIVE
#pragma omp task
@@ -824,6 +870,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp task
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}}
+ bar();
+ }
}
void foo() {
@@ -876,6 +927,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp parallel
+ {
+#pragma omp barrier
+ bar();
+ }
// SIMD DIRECTIVE
#pragma omp simd
@@ -942,6 +998,11 @@ void foo() {
#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
bar();
}
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ bar();
+ }
// FOR DIRECTIVE
#pragma omp for
@@ -1025,6 +1086,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}}
+ bar();
+ }
// SECTIONS DIRECTIVE
#pragma omp sections
@@ -1105,7 +1171,11 @@ void foo() {
}
#pragma omp sections
{
-#pragma omp task
+#pragma omp taskyield
+ }
+#pragma omp sections
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}}
bar();
}
@@ -1228,6 +1298,14 @@ void foo() {
bar();
}
}
+#pragma omp sections
+ {
+#pragma omp section
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}}
+ bar();
+ }
+ }
// SINGLE DIRECTIVE
#pragma omp single
@@ -1306,6 +1384,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp single
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}}
+ bar();
+ }
// MASTER DIRECTIVE
#pragma omp master
@@ -1389,6 +1472,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp master
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}}
+ bar();
+ }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
@@ -1480,6 +1568,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}}
+ bar();
+ }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
@@ -1569,6 +1662,10 @@ void foo() {
{
#pragma omp taskyield
}
+#pragma omp parallel sections
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}}
+ }
// TASK DIRECTIVE
#pragma omp task
@@ -1614,6 +1711,11 @@ void foo() {
#pragma omp taskyield
bar();
}
+#pragma omp task
+ {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}}
+ bar();
+ }
return foo<int>();
}
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jul 18 04:11:51 2014
@@ -1865,6 +1865,7 @@ public:
void VisitOMPParallelSectionsDirective(const OMPParallelSectionsDirective *D);
void VisitOMPTaskDirective(const OMPTaskDirective *D);
void VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *D);
+ void VisitOMPBarrierDirective(const OMPBarrierDirective *D);
private:
void AddDeclarationNameInfo(const Stmt *S);
@@ -2347,6 +2348,10 @@ EnqueueVisitor::VisitOMPTaskyieldDirecti
VisitOMPExecutableDirective(D);
}
+void EnqueueVisitor::VisitOMPBarrierDirective(const OMPBarrierDirective *D) {
+ VisitOMPExecutableDirective(D);
+}
+
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {
EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);
}
@@ -4041,6 +4046,8 @@ CXString clang_getCursorKindSpelling(enu
return cxstring::createRef("OMPTaskDirective");
case CXCursor_OMPTaskyieldDirective:
return cxstring::createRef("OMPTaskyieldDirective");
+ case CXCursor_OMPBarrierDirective:
+ return cxstring::createRef("OMPBarrierDirective");
}
llvm_unreachable("Unhandled CXCursorKind");
Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=213360&r1=213359&r2=213360&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Fri Jul 18 04:11:51 2014
@@ -550,6 +550,9 @@ CXCursor cxcursor::MakeCXCursor(const St
case Stmt::OMPTaskyieldDirectiveClass:
K = CXCursor_OMPTaskyieldDirective;
break;
+ case Stmt::OMPBarrierDirectiveClass:
+ K = CXCursor_OMPBarrierDirective;
+ break;
}
CXCursor C = { K, 0, { Parent, S, TU } };
More information about the cfe-commits
mailing list