r248696 - [OPENMP 4.1] Add 'simd' clause for 'ordered' directive.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 27 23:39:38 PDT 2015


Author: abataev
Date: Mon Sep 28 01:39:35 2015
New Revision: 248696

URL: http://llvm.org/viewvc/llvm-project?rev=248696&view=rev
Log:
[OPENMP 4.1] Add 'simd' clause for 'ordered' directive.
Parsing and sema analysis for 'simd' clause in 'ordered' directive.
Description
If the simd clause is specified, the ordered regions encountered by any thread will use only a single SIMD lane to execute the ordered
regions in the order of the loop iterations.
Restrictions
An ordered construct with the simd clause is the only OpenMP construct that can appear in the simd region


Modified:
    cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
    cfe/trunk/include/clang/AST/OpenMPClause.h
    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
    cfe/trunk/include/clang/Basic/OpenMPKinds.def
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/lib/AST/StmtProfile.cpp
    cfe/trunk/lib/Basic/OpenMPKinds.cpp
    cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
    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/test/OpenMP/ordered_ast_print.cpp
    cfe/trunk/test/OpenMP/ordered_messages.cpp
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Mon Sep 28 01:39:35 2015
@@ -2540,6 +2540,11 @@ bool RecursiveASTVisitor<Derived>::Visit
 }
 
 template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPSIMDClause(OMPSIMDClause *) {
+  return true;
+}
+
+template <typename Derived>
 template <typename T>
 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
   for (auto *E : Node->varlists()) {

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Sep 28 01:39:35 2015
@@ -2561,6 +2561,36 @@ public:
   }
 };
 
+/// \brief This represents 'simd' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp ordered simd
+/// \endcode
+/// In this example directive '#pragma omp ordered' has simple 'simd' clause.
+///
+class OMPSIMDClause : public OMPClause {
+public:
+  /// \brief Build 'simd' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  ///
+  OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc)
+      : OMPClause(OMPC_simd, StartLoc, EndLoc) {}
+
+  /// \brief Build an empty clause.
+  ///
+  OMPSIMDClause() : OMPClause(OMPC_simd, SourceLocation(), SourceLocation()) {}
+
+  static bool classof(const OMPClause *T) {
+    return T->getClauseKind() == OMPC_simd;
+  }
+
+  child_range children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+};
+
 } // end namespace clang
 
 #endif

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Sep 28 01:39:35 2015
@@ -2572,6 +2572,11 @@ bool RecursiveASTVisitor<Derived>::Visit
 }
 
 template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPSIMDClause(OMPSIMDClause *) {
+  return true;
+}
+
+template <typename Derived>
 template <typename T>
 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
   for (auto *E : Node->varlists()) {

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Mon Sep 28 01:39:35 2015
@@ -145,6 +145,7 @@ OPENMP_CLAUSE(seq_cst, OMPSeqCstClause)
 OPENMP_CLAUSE(depend, OMPDependClause)
 OPENMP_CLAUSE(device, OMPDeviceClause)
 OPENMP_CLAUSE(threads, OMPThreadsClause)
+OPENMP_CLAUSE(simd, OMPSIMDClause)
 
 // Clauses allowed for OpenMP directive 'parallel'.
 OPENMP_PARALLEL_CLAUSE(if)
@@ -318,6 +319,7 @@ OPENMP_TEAMS_CLAUSE(reduction)
 // Clauses allowed for OpenMP directive 'ordered'.
 // TODO More clauses for 'ordered' directive.
 OPENMP_ORDERED_CLAUSE(threads)
+OPENMP_ORDERED_CLAUSE(simd)
 
 #undef OPENMP_LINEAR_KIND
 #undef OPENMP_DEPEND_KIND

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Sep 28 01:39:35 2015
@@ -7997,7 +7997,10 @@ public:
                                      SourceLocation EndLoc);
   /// \brief Called on well-formed 'threads' clause.
   OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc,
-                                     SourceLocation EndLoc);
+                                      SourceLocation EndLoc);
+  /// \brief Called on well-formed 'simd' clause.
+  OMPClause *ActOnOpenMPSIMDClause(SourceLocation StartLoc,
+                                   SourceLocation EndLoc);
 
   OMPClause *ActOnOpenMPVarListClause(
       OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr,

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Sep 28 01:39:35 2015
@@ -701,6 +701,8 @@ void OMPClausePrinter::VisitOMPThreadsCl
   OS << "threads";
 }
 
+void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
+
 void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
   OS << "device(";
   Node->getDevice()->printPretty(OS, nullptr, Policy, 0);

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Sep 28 01:39:35 2015
@@ -335,6 +335,8 @@ void OMPClauseProfiler::VisitOMPSeqCstCl
 
 void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
 
+void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
+
 template<typename T>
 void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
   for (auto *E : Node->varlists()) {

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Mon Sep 28 01:39:35 2015
@@ -129,6 +129,7 @@ unsigned clang::getOpenMPSimpleClauseTyp
   case OMPC_seq_cst:
   case OMPC_device:
   case OMPC_threads:
+  case OMPC_simd:
     break;
   }
   llvm_unreachable("Invalid OpenMP simple clause kind");
@@ -214,6 +215,7 @@ const char *clang::getOpenMPSimpleClause
   case OMPC_seq_cst:
   case OMPC_device:
   case OMPC_threads:
+  case OMPC_simd:
     break;
   }
   llvm_unreachable("Invalid OpenMP simple clause kind");

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Sep 28 01:39:35 2015
@@ -2210,6 +2210,7 @@ static void EmitOMPAtomicExpr(CodeGenFun
   case OMPC_mergeable:
   case OMPC_device:
   case OMPC_threads:
+  case OMPC_simd:
     llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
 }

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Mon Sep 28 01:39:35 2015
@@ -394,7 +394,7 @@ bool Parser::ParseOpenMPSimpleVarList(Op
 ///       schedule-clause | copyin-clause | copyprivate-clause | untied-clause |
 ///       mergeable-clause | flush-clause | read-clause | write-clause |
 ///       update-clause | capture-clause | seq_cst-clause | device-clause |
-///       simdlen-clause | threads-clause
+///       simdlen-clause | threads-clause | simd-clause
 ///
 OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
                                      OpenMPClauseKind CKind, bool FirstClause) {
@@ -473,6 +473,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
   case OMPC_capture:
   case OMPC_seq_cst:
   case OMPC_threads:
+  case OMPC_simd:
     // OpenMP [2.7.1, Restrictions, p. 9]
     //  Only one ordered clause can appear on a loop directive.
     // OpenMP [2.7.1, Restrictions, C/C++, p. 4]
@@ -605,6 +606,9 @@ OMPClause *Parser::ParseOpenMPSimpleClau
 ///    threads-clause:
 ///         'threads'
 ///
+///    simd-clause:
+///         'simd'
+///
 OMPClause *Parser::ParseOpenMPClause(OpenMPClauseKind Kind) {
   SourceLocation Loc = Tok.getLocation();
   ConsumeAnyToken();

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Sep 28 01:39:35 2015
@@ -1547,7 +1547,7 @@ static bool CheckNestingOfRegions(Sema &
   // | simd             | taskwait        |                                    |
   // | simd             | taskgroup       |                                    |
   // | simd             | flush           |                                    |
-  // | simd             | ordered         |                                    |
+  // | simd             | ordered         | + (with simd clause)               |
   // | simd             | atomic          |                                    |
   // | simd             | target          |                                    |
   // | simd             | teams           |                                    |
@@ -1573,7 +1573,7 @@ static bool CheckNestingOfRegions(Sema &
   // | for simd         | taskwait        |                                    |
   // | for simd         | taskgroup       |                                    |
   // | for simd         | flush           |                                    |
-  // | for simd         | ordered         |                                    |
+  // | for simd         | ordered         | + (with simd clause)               |
   // | for simd         | atomic          |                                    |
   // | for simd         | target          |                                    |
   // | for simd         | teams           |                                    |
@@ -1599,7 +1599,7 @@ static bool CheckNestingOfRegions(Sema &
   // | parallel for simd| taskwait        |                                    |
   // | parallel for simd| taskgroup       |                                    |
   // | parallel for simd| flush           |                                    |
-  // | parallel for simd| ordered         |                                    |
+  // | parallel for simd| ordered         | + (with simd clause)               |
   // | parallel for simd| atomic          |                                    |
   // | parallel for simd| target          |                                    |
   // | parallel for simd| teams           |                                    |
@@ -1877,9 +1877,12 @@ static bool CheckNestingOfRegions(Sema &
       ShouldBeInOrderedRegion,
       ShouldBeInTargetRegion
     } Recommend = NoRecommend;
-    if (isOpenMPSimdDirective(ParentRegion)) {
+    if (isOpenMPSimdDirective(ParentRegion) && CurrentRegion != OMPD_ordered) {
       // OpenMP [2.16, Nesting of Regions]
       // OpenMP constructs may not be nested inside a simd region.
+      // OpenMP [2.8.1,simd Construct, Restrictions]
+      // An ordered construct with the simd clause is the only OpenMP construct
+      // that can appear in the simd region.
       SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_simd);
       return true;
     }
@@ -1987,9 +1990,13 @@ static bool CheckNestingOfRegions(Sema &
       // atomic, or explicit task region.
       // An ordered region must be closely nested inside a loop region (or
       // parallel loop region) with an ordered clause.
+      // OpenMP [2.8.1,simd Construct, Restrictions]
+      // An ordered construct with the simd clause is the only OpenMP construct
+      // that can appear in the simd region.
       NestingProhibited = ParentRegion == OMPD_critical ||
                           ParentRegion == OMPD_task ||
-                          !Stack->isParentOrderedRegion();
+                          !(isOpenMPSimdDirective(ParentRegion) ||
+                            Stack->isParentOrderedRegion());
       Recommend = ShouldBeInOrderedRegion;
     } else if (isOpenMPTeamsDirective(CurrentRegion)) {
       // OpenMP [2.16, Nesting of Regions]
@@ -4146,9 +4153,12 @@ StmtResult Sema::ActOnOpenMPOrderedDirec
   getCurFunction()->setHasBranchProtectedScope();
 
   OMPThreadsClause *TC = nullptr;
+  OMPSIMDClause *SC = nullptr;
   for (auto *C: Clauses) {
     if (C->getClauseKind() == OMPC_threads)
       TC = cast<OMPThreadsClause>(C);
+    else if (C->getClauseKind() == OMPC_simd)
+      SC = cast<OMPSIMDClause>(C);
   }
 
   // TODO: this must happen only if 'threads' clause specified or if no clauses
@@ -4159,6 +4169,13 @@ StmtResult Sema::ActOnOpenMPOrderedDirec
     Diag(Param->getLocStart(), diag::note_omp_ordered_param);
     return StmtError();
   }
+  if (!SC && isOpenMPSimdDirective(DSAStack->getParentDirective())) {
+    // OpenMP [2.8.1,simd Construct, Restrictions]
+    // An ordered construct with the simd clause is the only OpenMP construct
+    // that can appear in the simd region.
+    Diag(StartLoc, diag::err_omp_prohibited_region_simd);
+    return StmtError();
+  }
 
   return OMPOrderedDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
 }
@@ -5009,6 +5026,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprCl
   case OMPC_seq_cst:
   case OMPC_depend:
   case OMPC_threads:
+  case OMPC_simd:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -5270,6 +5288,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause
   case OMPC_depend:
   case OMPC_device:
   case OMPC_threads:
+  case OMPC_simd:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -5398,6 +5417,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWi
   case OMPC_depend:
   case OMPC_device:
   case OMPC_threads:
+  case OMPC_simd:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -5504,6 +5524,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenM
   case OMPC_threads:
     Res = ActOnOpenMPThreadsClause(StartLoc, EndLoc);
     break;
+  case OMPC_simd:
+    Res = ActOnOpenMPSIMDClause(StartLoc, EndLoc);
+    break;
   case OMPC_if:
   case OMPC_final:
   case OMPC_num_threads:
@@ -5578,6 +5601,11 @@ OMPClause *Sema::ActOnOpenMPThreadsClaus
   return new (Context) OMPThreadsClause(StartLoc, EndLoc);
 }
 
+OMPClause *Sema::ActOnOpenMPSIMDClause(SourceLocation StartLoc,
+                                       SourceLocation EndLoc) {
+  return new (Context) OMPSIMDClause(StartLoc, EndLoc);
+}
+
 OMPClause *Sema::ActOnOpenMPVarListClause(
     OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
     SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
@@ -5644,6 +5672,7 @@ OMPClause *Sema::ActOnOpenMPVarListClaus
   case OMPC_seq_cst:
   case OMPC_device:
   case OMPC_threads:
+  case OMPC_simd:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
   }

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Sep 28 01:39:35 2015
@@ -7373,6 +7373,12 @@ TreeTransform<Derived>::TransformOMPThre
 }
 
 template <typename Derived>
+OMPClause *TreeTransform<Derived>::TransformOMPSIMDClause(OMPSIMDClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
+template <typename Derived>
 OMPClause *
 TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
   llvm::SmallVector<Expr *, 16> Vars;

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Mon Sep 28 01:39:35 2015
@@ -1780,6 +1780,9 @@ OMPClause *OMPClauseReader::readClause()
   case OMPC_threads:
     C = new (Context) OMPThreadsClause();
     break;
+  case OMPC_simd:
+    C = new (Context) OMPSIMDClause();
+    break;
   case OMPC_private:
     C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
     break;
@@ -1904,6 +1907,8 @@ void OMPClauseReader::VisitOMPSeqCstClau
 
 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
 
+void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
+
 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
   unsigned NumVars = C->varlist_size();

Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Mon Sep 28 01:39:35 2015
@@ -1812,6 +1812,8 @@ void OMPClauseWriter::VisitOMPSeqCstClau
 
 void OMPClauseWriter::VisitOMPThreadsClause(OMPThreadsClause *) {}
 
+void OMPClauseWriter::VisitOMPSIMDClause(OMPSIMDClause *) {}
+
 void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
   Record.push_back(C->varlist_size());
   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);

Modified: cfe/trunk/test/OpenMP/ordered_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/ordered_ast_print.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/ordered_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/ordered_ast_print.cpp Mon Sep 28 01:39:35 2015
@@ -24,6 +24,24 @@ T tmain (T argc) {
   {
     a=2;
   }
+  #pragma omp simd
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered simd
+  {
+    a=2;
+  }
+  #pragma omp for simd
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered simd
+  {
+    a=2;
+  }
+  #pragma omp parallel for simd
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered simd
+  {
+    a=2;
+  }
   return (0);
 }
 
@@ -40,6 +58,24 @@ T tmain (T argc) {
 // CHECK-NEXT: {
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp for simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp parallel for simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
 
 // CHECK: static T a;
 // CHECK-NEXT: #pragma omp for ordered
@@ -54,6 +90,24 @@ T tmain (T argc) {
 // CHECK-NEXT: {
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp for simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp parallel for simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
 
 int main (int argc, char **argv) {
   int b = argc, c, d, e, f, g;
@@ -71,6 +125,24 @@ int main (int argc, char **argv) {
   {
     a=2;
   }
+  #pragma omp simd
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered simd
+  {
+    a=2;
+  }
+  #pragma omp for simd
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered simd
+  {
+    a=2;
+  }
+  #pragma omp parallel for simd
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered simd
+  {
+    a=2;
+  }
 // CHECK-NEXT: #pragma omp for ordered
 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
 // CHECK-NEXT: #pragma omp ordered
@@ -83,6 +155,24 @@ int main (int argc, char **argv) {
 // CHECK-NEXT: {
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp for simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp parallel for simd
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered simd
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
   return tmain(argc);
 }
 

Modified: cfe/trunk/test/OpenMP/ordered_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/ordered_messages.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/ordered_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/ordered_messages.cpp Mon Sep 28 01:39:35 2015
@@ -45,6 +45,52 @@ T foo() {
       foo();
     }
   }
+  #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
+  {
+    foo();
+  }
+  #pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
 
   return T();
 }
@@ -90,6 +136,52 @@ int foo() {
     {
       foo();
     }
+  }
+  #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
+  {
+    foo();
+  }
+  #pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
+  }
+  #pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+    #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      foo();
+    }
   }
 
   return foo<int>();

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=248696&r1=248695&r2=248696&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Sep 28 01:39:35 2015
@@ -2068,6 +2068,8 @@ void OMPClauseEnqueue::VisitOMPSeqCstCla
 
 void OMPClauseEnqueue::VisitOMPThreadsClause(const OMPThreadsClause *) {}
 
+void OMPClauseEnqueue::VisitOMPSIMDClause(const OMPSIMDClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }




More information about the cfe-commits mailing list