[flang-commits] [flang] 5ee500a - [mlir][OpenMP] Remove clauses that are not being handled

Shraiysh Vaishay via flang-commits flang-commits at lists.llvm.org
Fri Feb 18 11:43:17 PST 2022


Author: Shraiysh Vaishay
Date: 2022-02-19T01:13:05+05:30
New Revision: 5ee500acbbe7eadc1b46a289c8f7fc86a4be4af5

URL: https://github.com/llvm/llvm-project/commit/5ee500acbbe7eadc1b46a289c8f7fc86a4be4af5
DIFF: https://github.com/llvm/llvm-project/commit/5ee500acbbe7eadc1b46a289c8f7fc86a4be4af5.diff

LOG: [mlir][OpenMP] Remove clauses that are not being handled

This patch removes the following clauses from OpenMP Dialect:

 - private
 - firstprivate
 - lastprivate
 - shared
 - default
 - copyin
 - copyprivate

The privatization clauses are being handled in the flang frontend. The
data copying clauses are not being handled anywhere for now. Once
we have a better picture of how to handle these clauses in OpenMP
Dialect, we can add these. For the time being, removing unneeded
clauses.

For detailed discussion about this refer to [[ https://discourse.llvm.org/t/rfc-privatisation-in-openmp-dialect/3526 | Privatisation in OpenMP dialect ]]

Reviewed By: kiranchandramohan, clementval

Differential Revision: https://reviews.llvm.org/D120029

Added: 
    

Modified: 
    flang/lib/Lower/OpenMP.cpp
    mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
    mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
    mlir/test/Dialect/OpenMP/invalid.mlir
    mlir/test/Dialect/OpenMP/ops.mlir
    mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 0d713b320ce01..bf02f577cc408 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -143,9 +143,7 @@ genOMP(Fortran::lower::AbstractConverter &converter,
   if (blockDirective.v == llvm::omp::OMPD_parallel) {
 
     mlir::Value ifClauseOperand, numThreadsClauseOperand;
-    SmallVector<Value, 4> privateClauseOperands, firstprivateClauseOperands,
-        sharedClauseOperands, copyinClauseOperands;
-    Attribute defaultClauseOperand, procBindClauseOperand;
+    Attribute procBindClauseOperand;
 
     const auto &parallelOpClauseList =
         std::get<Fortran::parser::OmpClauseList>(beginBlockDirective.t);
@@ -162,59 +160,17 @@ genOMP(Fortran::lower::AbstractConverter &converter,
         // OMPIRBuilder expects `NUM_THREAD` clause as a `Value`.
         numThreadsClauseOperand = fir::getBase(converter.genExprValue(
             *Fortran::semantics::GetExpr(numThreadsClause->v)));
-      } else if (const auto &privateClause =
-                     std::get_if<Fortran::parser::OmpClause::Private>(
-                         &clause.u)) {
-        const Fortran::parser::OmpObjectList &ompObjectList = privateClause->v;
-        genObjectList(ompObjectList, converter, privateClauseOperands);
-      } else if (const auto &firstprivateClause =
-                     std::get_if<Fortran::parser::OmpClause::Firstprivate>(
-                         &clause.u)) {
-        const Fortran::parser::OmpObjectList &ompObjectList =
-            firstprivateClause->v;
-        genObjectList(ompObjectList, converter, firstprivateClauseOperands);
-      } else if (const auto &sharedClause =
-                     std::get_if<Fortran::parser::OmpClause::Shared>(
-                         &clause.u)) {
-        const Fortran::parser::OmpObjectList &ompObjectList = sharedClause->v;
-        genObjectList(ompObjectList, converter, sharedClauseOperands);
-      } else if (const auto &copyinClause =
-                     std::get_if<Fortran::parser::OmpClause::Copyin>(
-                         &clause.u)) {
-        const Fortran::parser::OmpObjectList &ompObjectList = copyinClause->v;
-        genObjectList(ompObjectList, converter, copyinClauseOperands);
       }
+      // TODO: Handle private, firstprivate, shared and copyin
     }
     // Create and insert the operation.
     auto parallelOp = firOpBuilder.create<mlir::omp::ParallelOp>(
         currentLocation, argTy, ifClauseOperand, numThreadsClauseOperand,
-        defaultClauseOperand.dyn_cast_or_null<omp::ClauseDefaultAttr>(),
-        privateClauseOperands, firstprivateClauseOperands, sharedClauseOperands,
-        copyinClauseOperands, ValueRange(), ValueRange(),
+        ValueRange(), ValueRange(),
         procBindClauseOperand.dyn_cast_or_null<omp::ClauseProcBindKindAttr>());
     // Handle attribute based clauses.
     for (const auto &clause : parallelOpClauseList.v) {
-      if (const auto &defaultClause =
-              std::get_if<Fortran::parser::OmpClause::Default>(&clause.u)) {
-        const auto &ompDefaultClause{defaultClause->v};
-        omp::ClauseDefault clause;
-        switch (ompDefaultClause.v) {
-        case Fortran::parser::OmpDefaultClause::Type::Private:
-          clause = omp::ClauseDefault::defprivate;
-          break;
-        case Fortran::parser::OmpDefaultClause::Type::Firstprivate:
-          clause = omp::ClauseDefault::deffirstprivate;
-          break;
-        case Fortran::parser::OmpDefaultClause::Type::Shared:
-          clause = omp::ClauseDefault::defshared;
-          break;
-        case Fortran::parser::OmpDefaultClause::Type::None:
-          clause = omp::ClauseDefault::defnone;
-          break;
-        }
-        parallelOp.default_valAttr(
-            omp::ClauseDefaultAttr::get(firOpBuilder.getContext(), clause));
-      }
+      // TODO: Handle default clause
       if (const auto &procBindClause =
               std::get_if<Fortran::parser::OmpClause::ProcBind>(&clause.u)) {
         const auto &ompProcBindClause{procBindClause->v};

diff  --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 51ae0dc5bea2b..5933326489dd3 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -63,25 +63,8 @@ def OpenMP_PointerLikeType : Type<
 // 2.6 parallel Construct
 //===----------------------------------------------------------------------===//
 
-// Possible values for the default clause
-def ClauseDefaultPrivate      : I32EnumAttrCase<"defprivate",      0>;
-def ClauseDefaultFirstPrivate : I32EnumAttrCase<"deffirstprivate", 1>;
-def ClauseDefaultShared       : I32EnumAttrCase<"defshared",       2>;
-def ClauseDefaultNone         : I32EnumAttrCase<"defnone",         3>;
-
-def ClauseDefault : I32EnumAttr<
-    "ClauseDefault",
-    "default clause",
-    [ClauseDefaultPrivate, ClauseDefaultFirstPrivate, ClauseDefaultShared,
-     ClauseDefaultNone]> {
-  let genSpecializedAttr = 0;
-  let cppNamespace = "::mlir::omp";
-}
-def ClauseDefaultAttr : EnumAttr<OpenMP_Dialect, ClauseDefault,
-                                 "clause_default">;
-
-def ParallelOp : OpenMP_Op<"parallel", [AutomaticAllocationScope, 
-                                        AttrSizedOperandSegments,
+def ParallelOp : OpenMP_Op<"parallel", [
+                 AutomaticAllocationScope, AttrSizedOperandSegments,
                  DeclareOpInterfaceMethods<OutlineableOpenMPOpInterface>]> {
   let summary = "parallel construct";
   let description = [{
@@ -96,14 +79,6 @@ def ParallelOp : OpenMP_Op<"parallel", [AutomaticAllocationScope,
     The optional $num_threads_var parameter specifies the number of threads which
     should be used to execute the parallel region.
 
-    The optional $default_val attribute specifies the default data sharing attribute
-    of values used in the parallel region that are not passed explicitly as parameters
-    to the operation.
-
-    The $private_vars, $firstprivate_vars, $shared_vars and $copyin_vars parameters
-    are a variadic list of values that specify the data sharing attribute of
-    those values.
-
     The $allocators_vars and $allocate_vars parameters are a variadic list of values
     that specify the memory allocator to be used to obtain storage for private values.
 
@@ -113,11 +88,6 @@ def ParallelOp : OpenMP_Op<"parallel", [AutomaticAllocationScope,
 
   let arguments = (ins Optional<AnyType>:$if_expr_var,
              Optional<AnyType>:$num_threads_var,
-             OptionalAttr<ClauseDefaultAttr>:$default_val,
-             Variadic<AnyType>:$private_vars,
-             Variadic<AnyType>:$firstprivate_vars,
-             Variadic<AnyType>:$shared_vars,
-             Variadic<AnyType>:$copyin_vars,
              Variadic<AnyType>:$allocate_vars,
              Variadic<AnyType>:$allocators_vars,
              OptionalAttr<ProcBindKindAttr>:$proc_bind_val);
@@ -182,10 +152,6 @@ def SectionsOp : OpenMP_Op<"sections", [AttrSizedOperandSegments]> {
     is executed once by one of the threads in the team in the context of its
     implicit task.
 
-    `private_vars`, `firstprivate_vars` and`lastprivate_vars` arguments are
-    variadic list of operands that specify the data sharing attributes of the
-    list of values. They are optional.
-
     Reductions can be performed in a sections construct by specifying reduction
     accumulator variables in `reduction_vars` and symbols referring to reduction
     declarations in the `reductions` attribute. Each reduction is identified
@@ -204,10 +170,7 @@ def SectionsOp : OpenMP_Op<"sections", [AttrSizedOperandSegments]> {
     The `nowait` attribute, when present, signifies that there should be no
     implicit barrier at the end of the construct.
   }];
-  let arguments = (ins Variadic<AnyType>:$private_vars,
-                       Variadic<AnyType>:$firstprivate_vars,
-                       Variadic<AnyType>:$lastprivate_vars,
-                       Variadic<OpenMP_PointerLikeType>:$reduction_vars,
+  let arguments = (ins Variadic<OpenMP_PointerLikeType>:$reduction_vars,
                        OptionalAttr<SymbolRefArrayAttr>:$reductions,
                        Variadic<AnyType>:$allocate_vars,
                        Variadic<AnyType>:$allocators_vars,
@@ -247,12 +210,10 @@ def WsLoopOp : OpenMP_Op<"wsloop", [AttrSizedOperandSegments,
     }
     ```
 
-    `private_vars`, `firstprivate_vars`, `lastprivate_vars` and `linear_vars`
-    arguments are variadic list of operands that specify the data sharing
-    attributes of the list of values. The `linear_step_vars` operand
-    additionally specifies the step for each associated linear operand. Note
-    that the `linear_vars` and `linear_step_vars` variadic lists should contain
-    the same number of elements.
+    The `linear_step_vars` operand additionally specifies the step for each
+    associated linear operand. Note that the `linear_vars` and
+    `linear_step_vars` variadic lists should contain the same number of
+    elements.
 
     Reductions can be performed in a workshare loop by specifying reduction
     accumulator variables in `reduction_vars` and symbols referring to reduction
@@ -288,9 +249,6 @@ def WsLoopOp : OpenMP_Op<"wsloop", [AttrSizedOperandSegments,
   let arguments = (ins Variadic<IntLikeType>:$lowerBound,
              Variadic<IntLikeType>:$upperBound,
              Variadic<IntLikeType>:$step,
-             Variadic<AnyType>:$private_vars,
-             Variadic<AnyType>:$firstprivate_vars,
-             Variadic<AnyType>:$lastprivate_vars,
              Variadic<AnyType>:$linear_vars,
              Variadic<AnyType>:$linear_step_vars,
              Variadic<OpenMP_PointerLikeType>:$reduction_vars,
@@ -313,13 +271,12 @@ def WsLoopOp : OpenMP_Op<"wsloop", [AttrSizedOperandSegments,
                CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>,
     OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$lowerBound,
                "ValueRange":$upperBound, "ValueRange":$step,
-               "ValueRange":$privateVars, "ValueRange":$firstprivateVars,
-               "ValueRange":$lastprivate_vars, "ValueRange":$linear_vars,
-               "ValueRange":$linear_step_vars, "ValueRange":$reduction_vars,
-               "StringAttr":$schedule_val, "Value":$schedule_chunk_var,
-               "IntegerAttr":$collapse_val, "UnitAttr":$nowait,
-               "IntegerAttr":$ordered_val, "StringAttr":$order_val,
-               "UnitAttr":$inclusive, CArg<"bool", "true">:$buildBody)>,
+               "ValueRange":$linear_vars, "ValueRange":$linear_step_vars,
+               "ValueRange":$reduction_vars, "StringAttr":$schedule_val,
+               "Value":$schedule_chunk_var, "IntegerAttr":$collapse_val,
+               "UnitAttr":$nowait, "IntegerAttr":$ordered_val,
+               "StringAttr":$order_val, "UnitAttr":$inclusive,
+               CArg<"bool", "true">:$buildBody)>,
     OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$operands,
                CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>
   ];
@@ -404,7 +361,7 @@ def TargetOp : OpenMP_Op<"target",[AttrSizedOperandSegments]> {
     The optional $nowait elliminates the implicit barrier so the parent task can make progress
     even if the target task is not yet completed.
 
-    TODO:  private, map, is_device_ptr, firstprivate, depend, defaultmap, in_reduction
+    TODO:  map, is_device_ptr, depend, defaultmap, in_reduction
 
   }];
 

diff  --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 4ff38e2b455a1..b6f45bf044f06 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -66,56 +66,11 @@ void ParallelOp::build(OpBuilder &builder, OperationState &state,
                        ArrayRef<NamedAttribute> attributes) {
   ParallelOp::build(
       builder, state, /*if_expr_var=*/nullptr, /*num_threads_var=*/nullptr,
-      /*default_val=*/nullptr, /*private_vars=*/ValueRange(),
-      /*firstprivate_vars=*/ValueRange(), /*shared_vars=*/ValueRange(),
-      /*copyin_vars=*/ValueRange(), /*allocate_vars=*/ValueRange(),
-      /*allocators_vars=*/ValueRange(), /*proc_bind_val=*/nullptr);
+      /*allocate_vars=*/ValueRange(), /*allocators_vars=*/ValueRange(),
+      /*proc_bind_val=*/nullptr);
   state.addAttributes(attributes);
 }
 
-//===----------------------------------------------------------------------===//
-// Parser and printer for Operand and type list
-//===----------------------------------------------------------------------===//
-
-/// Parse a list of operands with types.
-///
-/// operand-and-type-list ::= `(` ssa-id-and-type-list `)`
-/// ssa-id-and-type-list ::= ssa-id-and-type |
-///                          ssa-id-and-type `,` ssa-id-and-type-list
-/// ssa-id-and-type ::= ssa-id `:` type
-static ParseResult
-parseOperandAndTypeList(OpAsmParser &parser,
-                        SmallVectorImpl<OpAsmParser::OperandType> &operands,
-                        SmallVectorImpl<Type> &types) {
-  return parser.parseCommaSeparatedList(
-      OpAsmParser::Delimiter::Paren, [&]() -> ParseResult {
-        OpAsmParser::OperandType operand;
-        Type type;
-        if (parser.parseOperand(operand) || parser.parseColonType(type))
-          return failure();
-        operands.push_back(operand);
-        types.push_back(type);
-        return success();
-      });
-}
-
-/// Print an operand and type list with parentheses
-static void printOperandAndTypeList(OpAsmPrinter &p, OperandRange operands) {
-  p << "(";
-  llvm::interleaveComma(
-      operands, p, [&](const Value &v) { p << v << " : " << v.getType(); });
-  p << ") ";
-}
-
-/// Print data variables corresponding to a data-sharing clause `name`
-static void printDataVars(OpAsmPrinter &p, OperandRange operands,
-                          StringRef name) {
-  if (!operands.empty()) {
-    p << name;
-    printOperandAndTypeList(p, operands);
-  }
-}
-
 //===----------------------------------------------------------------------===//
 // Parser and printer for Allocate Clause
 //===----------------------------------------------------------------------===//
@@ -180,17 +135,9 @@ void ParallelOp::print(OpAsmPrinter &p) {
   if (auto threads = num_threads_var())
     p << "num_threads(" << threads << " : " << threads.getType() << ") ";
 
-  printDataVars(p, private_vars(), "private");
-  printDataVars(p, firstprivate_vars(), "firstprivate");
-  printDataVars(p, shared_vars(), "shared");
-  printDataVars(p, copyin_vars(), "copyin");
-
   if (!allocate_vars().empty())
     printAllocateAndAllocator(p, allocate_vars(), allocators_vars());
 
-  if (auto def = default_val())
-    p << "default(" << stringifyClauseDefault(*def).drop_front(3) << ") ";
-
   if (auto bind = proc_bind_val())
     p << "proc_bind(" << stringifyClauseProcBindKind(*bind) << ") ";
 
@@ -542,13 +489,7 @@ enum ClauseType {
   numThreadsClause,
   deviceClause,
   threadLimitClause,
-  privateClause,
-  firstprivateClause,
-  lastprivateClause,
-  sharedClause,
-  copyinClause,
   allocateClause,
-  defaultClause,
   procBindClause,
   reductionClause,
   nowaitClause,
@@ -589,19 +530,11 @@ static ParseResult parseClauseAttr(AsmParser &parser, OperationState &state,
 /// `clauses` list. The operand segments are added over the prevSegments
 
 /// clause-list ::= clause clause-list | empty
-/// clause ::= if | num-threads | private | firstprivate | lastprivate |
-///            shared | copyin | allocate | default | proc-bind | reduction |
-///            nowait | linear | schedule | collapse | order | ordered |
-///            inclusive
+/// clause ::= if | num-threads | allocate | proc-bind | reduction | nowait
+///          | linear | schedule | collapse | order | ordered | inclusive
 /// if ::= `if` `(` ssa-id-and-type `)`
 /// num-threads ::= `num_threads` `(` ssa-id-and-type `)`
-/// private ::= `private` operand-and-type-list
-/// firstprivate ::= `firstprivate` operand-and-type-list
-/// lastprivate ::= `lastprivate` operand-and-type-list
-/// shared ::= `shared` operand-and-type-list
-/// copyin ::= `copyin` operand-and-type-list
 /// allocate ::= `allocate` `(` allocate-operand-list `)`
-/// default ::= `default` `(` (`private` | `firstprivate` | `shared` | `none`)
 /// proc-bind ::= `proc_bind` `(` (`master` | `close` | `spread`) `)`
 /// reduction ::= `reduction` `(` reduction-entry-list `)`
 /// nowait ::= `nowait`
@@ -633,11 +566,6 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result,
   std::pair<OpAsmParser::OperandType, Type> device;
   std::pair<OpAsmParser::OperandType, Type> threadLimit;
 
-  SmallVector<OpAsmParser::OperandType> privates, firstprivates, lastprivates,
-      shareds, copyins;
-  SmallVector<Type> privateTypes, firstprivateTypes, lastprivateTypes,
-      sharedTypes, copyinTypes;
-
   SmallVector<OpAsmParser::OperandType> allocates, allocators;
   SmallVector<Type> allocateTypes, allocatorTypes;
 
@@ -660,9 +588,9 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result,
 
     // Skip the following clauses - they do not take any position in operand
     // segments
-    if (clause == defaultClause || clause == procBindClause ||
-        clause == nowaitClause || clause == collapseClause ||
-        clause == orderClause || clause == orderedClause)
+    if (clause == procBindClause || clause == nowaitClause ||
+        clause == collapseClause || clause == orderClause ||
+        clause == orderedClause)
       continue;
 
     pos[clause] = currPos++;
@@ -714,31 +642,6 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result,
           parser.parseColonType(threadLimit.second) || parser.parseRParen())
         return failure();
       clauseSegments[pos[threadLimitClause]] = 1;
-    } else if (clauseKeyword == "private") {
-      if (checkAllowed(privateClause) ||
-          parseOperandAndTypeList(parser, privates, privateTypes))
-        return failure();
-      clauseSegments[pos[privateClause]] = privates.size();
-    } else if (clauseKeyword == "firstprivate") {
-      if (checkAllowed(firstprivateClause) ||
-          parseOperandAndTypeList(parser, firstprivates, firstprivateTypes))
-        return failure();
-      clauseSegments[pos[firstprivateClause]] = firstprivates.size();
-    } else if (clauseKeyword == "lastprivate") {
-      if (checkAllowed(lastprivateClause) ||
-          parseOperandAndTypeList(parser, lastprivates, lastprivateTypes))
-        return failure();
-      clauseSegments[pos[lastprivateClause]] = lastprivates.size();
-    } else if (clauseKeyword == "shared") {
-      if (checkAllowed(sharedClause) ||
-          parseOperandAndTypeList(parser, shareds, sharedTypes))
-        return failure();
-      clauseSegments[pos[sharedClause]] = shareds.size();
-    } else if (clauseKeyword == "copyin") {
-      if (checkAllowed(copyinClause) ||
-          parseOperandAndTypeList(parser, copyins, copyinTypes))
-        return failure();
-      clauseSegments[pos[copyinClause]] = copyins.size();
     } else if (clauseKeyword == "allocate") {
       if (checkAllowed(allocateClause) ||
           parseAllocateAndAllocator(parser, allocates, allocateTypes,
@@ -746,21 +649,6 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result,
         return failure();
       clauseSegments[pos[allocateClause]] = allocates.size();
       clauseSegments[pos[allocateClause] + 1] = allocators.size();
-    } else if (clauseKeyword == "default") {
-      StringRef defval;
-      SMLoc loc = parser.getCurrentLocation();
-      if (checkAllowed(defaultClause) || parser.parseLParen() ||
-          parser.parseKeyword(&defval) || parser.parseRParen())
-        return failure();
-      // The def prefix is required for the attribute as "private" is a keyword
-      // in C++.
-      if (Optional<ClauseDefault> def =
-              symbolizeClauseDefault(("def" + defval).str())) {
-        result.addAttribute("default_val",
-                            ClauseDefaultAttr::get(parser.getContext(), *def));
-      } else {
-        return parser.emitError(loc, "invalid default clause");
-      }
     } else if (clauseKeyword == "proc_bind") {
       if (checkAllowed(procBindClause) ||
           parseClauseAttr<ClauseProcBindKindAttr>(parser, result,
@@ -857,37 +745,6 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result,
                                    result.operands)))
     return failure();
 
-  // Add private parameters.
-  if (done[privateClause] && clauseSegments[pos[privateClause]] &&
-      failed(parser.resolveOperands(privates, privateTypes,
-                                    privates[0].location, result.operands)))
-    return failure();
-
-  // Add firstprivate parameters.
-  if (done[firstprivateClause] && clauseSegments[pos[firstprivateClause]] &&
-      failed(parser.resolveOperands(firstprivates, firstprivateTypes,
-                                    firstprivates[0].location,
-                                    result.operands)))
-    return failure();
-
-  // Add lastprivate parameters.
-  if (done[lastprivateClause] && clauseSegments[pos[lastprivateClause]] &&
-      failed(parser.resolveOperands(lastprivates, lastprivateTypes,
-                                    lastprivates[0].location, result.operands)))
-    return failure();
-
-  // Add shared parameters.
-  if (done[sharedClause] && clauseSegments[pos[sharedClause]] &&
-      failed(parser.resolveOperands(shareds, sharedTypes, shareds[0].location,
-                                    result.operands)))
-    return failure();
-
-  // Add copyin parameters.
-  if (done[copyinClause] && clauseSegments[pos[copyinClause]] &&
-      failed(parser.resolveOperands(copyins, copyinTypes, copyins[0].location,
-                                    result.operands)))
-    return failure();
-
   // Add allocate parameters.
   if (done[allocateClause] && clauseSegments[pos[allocateClause]] &&
       failed(parser.resolveOperands(allocates, allocateTypes,
@@ -967,14 +824,11 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result,
 ///
 /// operation ::= `omp.parallel` clause-list
 /// clause-list ::= clause | clause clause-list
-/// clause ::= if | num-threads | private | firstprivate | shared | copyin |
-///            allocate | default | proc-bind
+/// clause ::= if | num-threads | allocate | proc-bind
 ///
 ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) {
-  SmallVector<ClauseType> clauses = {
-      ifClause,           numThreadsClause, privateClause,
-      firstprivateClause, sharedClause,     copyinClause,
-      allocateClause,     defaultClause,    procBindClause};
+  SmallVector<ClauseType> clauses = {ifClause, numThreadsClause, allocateClause,
+                                     procBindClause};
 
   SmallVector<int> segments;
 
@@ -1027,12 +881,10 @@ ParseResult TargetOp::parse(OpAsmParser &parser, OperationState &result) {
 ///
 /// sections ::= `omp.sections` clause-list
 /// clause-list ::= clause clause-list | empty
-/// clause ::= private | firstprivate | lastprivate | reduction | allocate |
-///            nowait
+/// clause ::= reduction | allocate | nowait
 ParseResult SectionsOp::parse(OpAsmParser &parser, OperationState &result) {
-  SmallVector<ClauseType> clauses = {privateClause,     firstprivateClause,
-                                     lastprivateClause, reductionClause,
-                                     allocateClause,    nowaitClause};
+  SmallVector<ClauseType> clauses = {reductionClause, allocateClause,
+                                     nowaitClause};
 
   SmallVector<int> segments;
 
@@ -1051,9 +903,6 @@ ParseResult SectionsOp::parse(OpAsmParser &parser, OperationState &result) {
 
 void SectionsOp::print(OpAsmPrinter &p) {
   p << " ";
-  printDataVars(p, private_vars(), "private");
-  printDataVars(p, firstprivate_vars(), "firstprivate");
-  printDataVars(p, lastprivate_vars(), "lastprivate");
 
   if (!reduction_vars().empty())
     printReductionVarList(p, reductions(), reduction_vars());
@@ -1069,18 +918,6 @@ void SectionsOp::print(OpAsmPrinter &p) {
 }
 
 LogicalResult SectionsOp::verify() {
-  // A list item may not appear in more than one clause on the same directive,
-  // except that it may be specified in both firstprivate and lastprivate
-  // clauses.
-  for (auto var : private_vars()) {
-    if (llvm::is_contained(firstprivate_vars(), var))
-      return emitOpError()
-             << "operand used in both private and firstprivate clauses";
-    if (llvm::is_contained(lastprivate_vars(), var))
-      return emitOpError()
-             << "operand used in both private and lastprivate clauses";
-  }
-
   if (allocate_vars().size() != allocators_vars().size())
     return emitError(
         "expected equal sizes for allocate and allocator variables");
@@ -1102,8 +939,8 @@ LogicalResult SectionsOp::verify() {
 /// loop-bounds := `(` ssa-id-list `)` to `(` ssa-id-list `)` inclusive? steps
 /// steps := `step` `(`ssa-id-list`)`
 /// clause-list ::= clause clause-list | empty
-/// clause ::= private | firstprivate | lastprivate | linear | schedule |
-//             collapse | nowait | ordered | order | reduction
+/// clause ::= linear | schedule | collapse | nowait | ordered | order
+///          | reduction
 ParseResult WsLoopOp::parse(OpAsmParser &parser, OperationState &result) {
   // Parse an opening `(` followed by induction variables followed by `)`
   SmallVector<OpAsmParser::OperandType> ivs;
@@ -1142,9 +979,8 @@ ParseResult WsLoopOp::parse(OpAsmParser &parser, OperationState &result) {
     return failure();
 
   SmallVector<ClauseType> clauses = {
-      privateClause,   firstprivateClause, lastprivateClause, linearClause,
-      reductionClause, collapseClause,     orderClause,       orderedClause,
-      nowaitClause,    scheduleClause};
+      linearClause,  reductionClause, collapseClause, orderClause,
+      orderedClause, nowaitClause,    scheduleClause};
   SmallVector<int> segments{numIVs, numIVs, numIVs};
   if (failed(parseClauses(parser, result, clauses, segments)))
     return failure();
@@ -1170,10 +1006,6 @@ void WsLoopOp::print(OpAsmPrinter &p) {
   }
   p << "step (" << step() << ") ";
 
-  printDataVars(p, private_vars(), "private");
-  printDataVars(p, firstprivate_vars(), "firstprivate");
-  printDataVars(p, lastprivate_vars(), "lastprivate");
-
   if (!linear_vars().empty())
     printLinearClause(p, linear_vars(), linear_step_vars());
 
@@ -1288,8 +1120,6 @@ void WsLoopOp::build(OpBuilder &builder, OperationState &state,
                      ValueRange lowerBound, ValueRange upperBound,
                      ValueRange step, ArrayRef<NamedAttribute> attributes) {
   build(builder, state, TypeRange(), lowerBound, upperBound, step,
-        /*privateVars=*/ValueRange(),
-        /*firstprivateVars=*/ValueRange(), /*lastprivate_vars=*/ValueRange(),
         /*linear_vars=*/ValueRange(), /*linear_step_vars=*/ValueRange(),
         /*reduction_vars=*/ValueRange(), /*schedule_val=*/nullptr,
         /*schedule_chunk_var=*/nullptr, /*collapse_val=*/nullptr,
@@ -1310,18 +1140,14 @@ void WsLoopOp::build(OpBuilder &, OperationState &state, TypeRange resultTypes,
 void WsLoopOp::build(OpBuilder &builder, OperationState &result,
                      TypeRange typeRange, ValueRange lowerBounds,
                      ValueRange upperBounds, ValueRange steps,
-                     ValueRange privateVars, ValueRange firstprivateVars,
-                     ValueRange lastprivateVars, ValueRange linearVars,
-                     ValueRange linearStepVars, ValueRange reductionVars,
-                     StringAttr scheduleVal, Value scheduleChunkVar,
-                     IntegerAttr collapseVal, UnitAttr nowait,
-                     IntegerAttr orderedVal, StringAttr orderVal,
-                     UnitAttr inclusive, bool buildBody) {
+                     ValueRange linearVars, ValueRange linearStepVars,
+                     ValueRange reductionVars, StringAttr scheduleVal,
+                     Value scheduleChunkVar, IntegerAttr collapseVal,
+                     UnitAttr nowait, IntegerAttr orderedVal,
+                     StringAttr orderVal, UnitAttr inclusive, bool buildBody) {
   result.addOperands(lowerBounds);
   result.addOperands(upperBounds);
   result.addOperands(steps);
-  result.addOperands(privateVars);
-  result.addOperands(firstprivateVars);
   result.addOperands(linearVars);
   result.addOperands(linearStepVars);
   if (scheduleChunkVar)
@@ -1345,9 +1171,6 @@ void WsLoopOp::build(OpBuilder &builder, OperationState &result,
           {static_cast<int32_t>(lowerBounds.size()),
            static_cast<int32_t>(upperBounds.size()),
            static_cast<int32_t>(steps.size()),
-           static_cast<int32_t>(privateVars.size()),
-           static_cast<int32_t>(firstprivateVars.size()),
-           static_cast<int32_t>(lastprivateVars.size()),
            static_cast<int32_t>(linearVars.size()),
            static_cast<int32_t>(linearStepVars.size()),
            static_cast<int32_t>(reductionVars.size()),

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 4b44197c4366f..40d8582d91287 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -580,15 +580,12 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
 
   // TODO: Support the following clauses: private, firstprivate, lastprivate,
   // reduction, allocate
-  if (!sectionsOp.private_vars().empty() ||
-      !sectionsOp.firstprivate_vars().empty() ||
-      !sectionsOp.lastprivate_vars().empty() ||
-      !sectionsOp.reduction_vars().empty() || sectionsOp.reductions() ||
+  if (!sectionsOp.reduction_vars().empty() || sectionsOp.reductions() ||
       !sectionsOp.allocate_vars().empty() ||
       !sectionsOp.allocators_vars().empty())
     return emitError(sectionsOp.getLoc())
-           << "private, firstprivate, lastprivate, reduction and allocate "
-              "clauses are not supported for sections construct";
+           << "reduction and allocate clauses are not supported for sections "
+              "construct";
 
   LogicalResult bodyGenStatus = success();
   SmallVector<StorableBodyGenCallbackTy> sectionCBs;

diff  --git a/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir b/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
index 460ea9045ae07..f9aa110d815ed 100644
--- a/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
+++ b/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
@@ -57,7 +57,7 @@ func @wsloop(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4: inde
       // CHECK: "test.payload"(%[[CAST_ARG6]], %[[CAST_ARG7]]) : (index, index) -> ()
       "test.payload"(%arg6, %arg7) : (index, index) -> ()
       omp.yield
-    }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 0, 0, 0, 0]> : vector<10xi32>} : (index, index, index, index, index, index) -> ()
+    }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 0]> : vector<7xi32>} : (index, index, index, index, index, index) -> ()
     omp.terminator
   }
   return

diff  --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index e2dbd0f7e7268..6646410183c74 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -30,54 +30,6 @@ func @num_threads_once(%n : si32) {
 
 // -----
 
-func @private_once(%n : memref<i32>) {
-  // expected-error at +1 {{at most one private clause can appear on the omp.parallel operation}}
-  omp.parallel private(%n : memref<i32>) private(%n : memref<i32>) {
-  }
-
-  return
-}
-
-// -----
-
-func @firstprivate_once(%n : memref<i32>) {
-  // expected-error at +1 {{at most one firstprivate clause can appear on the omp.parallel operation}}
-  omp.parallel firstprivate(%n : memref<i32>) firstprivate(%n : memref<i32>) {
-  }
-
-  return
-}
-
-// -----
-
-func @shared_once(%n : memref<i32>) {
-  // expected-error at +1 {{at most one shared clause can appear on the omp.parallel operation}}
-  omp.parallel shared(%n : memref<i32>) shared(%n : memref<i32>) {
-  }
-
-  return
-}
-
-// -----
-
-func @copyin_once(%n : memref<i32>) {
-  // expected-error at +1 {{at most one copyin clause can appear on the omp.parallel operation}}
-  omp.parallel copyin(%n : memref<i32>) copyin(%n : memref<i32>) {
-  }
-
-  return
-}
-
-// -----
-
-func @lastprivate_not_allowed(%n : memref<i32>) {
-  // expected-error at +1 {{lastprivate is not a valid clause for the omp.parallel operation}}
-  omp.parallel lastprivate(%n : memref<i32>) {}
-  return
-}
-
-// -----
-
 func @nowait_not_allowed(%n : memref<i32>) {
   // expected-error at +1 {{nowait is not a valid clause for the omp.parallel operation}}
   omp.parallel nowait {}
@@ -125,16 +77,6 @@ func @ordered_not_allowed() {
 
 // -----
 
-func @default_once() {
-  // expected-error at +1 {{at most one default clause can appear on the omp.parallel operation}}
-  omp.parallel default(private) default(firstprivate) {
-  }
-
-  return
-}
-
-// -----
-
 func @proc_bind_once() {
   // expected-error at +1 {{at most one proc_bind clause can appear on the omp.parallel operation}}
   omp.parallel proc_bind(close) proc_bind(spread) {
@@ -163,24 +105,6 @@ func @order_value(%lb : index, %ub : index, %step : index) {
 
 // -----
 
-func @shared_not_allowed(%lb : index, %ub : index, %step : index, %var : memref<i32>) {
-  // expected-error @below {{shared is not a valid clause for the omp.wsloop operation}}
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) shared(%var) {
-    omp.yield
-  }
-}
-
-// -----
-
-func @copyin(%lb : index, %ub : index, %step : index, %var : memref<i32>) {
-  // expected-error @below {{copyin is not a valid clause for the omp.wsloop operation}}
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) copyin(%var) {
-    omp.yield
-  }
-}
-
-// -----
-
 func @if_not_allowed(%lb : index, %ub : index, %step : index, %bool_var : i1) {
   // expected-error @below {{if is not a valid clause for the omp.wsloop operation}}
   omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) if(%bool_var: i1) {
@@ -199,15 +123,6 @@ func @num_threads_not_allowed(%lb : index, %ub : index, %step : index, %int_var
 
 // -----
 
-func @default_not_allowed(%lb : index, %ub : index, %step : index) {
-  // expected-error @below {{default is not a valid clause for the omp.wsloop operation}}
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) default(private) {
-    omp.yield
-  }
-}
-
-// -----
-
 func @proc_bind_not_allowed(%lb : index, %ub : index, %step : index) {
   // expected-error @below {{proc_bind is not a valid clause for the omp.wsloop operation}}
   omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) proc_bind(close) {
@@ -847,41 +762,11 @@ func @omp_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %exp
 
 // -----
 
-func @omp_sections(%data_var1 : memref<i32>, %data_var2 : memref<i32>, %data_var3 : memref<i32>) -> () {
-  // expected-error @below {{operand used in both private and firstprivate clauses}}
-  omp.sections private(%data_var1 : memref<i32>) firstprivate(%data_var1 : memref<i32>) {
-    omp.terminator
-  }
-  return
-}
-
-// -----
-
-func @omp_sections(%data_var1 : memref<i32>, %data_var2 : memref<i32>, %data_var3 : memref<i32>) -> () {
-  // expected-error @below {{operand used in both private and lastprivate clauses}}
-  omp.sections private(%data_var1 : memref<i32>) lastprivate(%data_var1 : memref<i32>) {
-    omp.terminator
-  }
-  return
-}
-
-// -----
-
-func @omp_sections(%data_var1 : memref<i32>, %data_var2 : memref<i32>, %data_var3 : memref<i32>) -> () {
-  // expected-error @below {{operand used in both private and lastprivate clauses}}
-  omp.sections private(%data_var1 : memref<i32>, %data_var2 : memref<i32>) lastprivate(%data_var3 : memref<i32>, %data_var2 : memref<i32>) {
-    omp.terminator
-  }
-  return
-}
-
-// -----
-
 func @omp_sections(%data_var : memref<i32>) -> () {
   // expected-error @below {{expected equal sizes for allocate and allocator variables}}
   "omp.sections" (%data_var) ({
     omp.terminator
-  }) {operand_segment_sizes = dense<[0,0,0,0,1,0]> : vector<6xi32>} : (memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[0,1,0]> : vector<3xi32>} : (memref<i32>) -> ()
   return
 }
 
@@ -891,7 +776,7 @@ func @omp_sections(%data_var : memref<i32>) -> () {
   // expected-error @below {{expected as many reduction symbol references as reduction variables}}
   "omp.sections" (%data_var) ({
     omp.terminator
-  }) {operand_segment_sizes = dense<[0,0,0,1,0,0]> : vector<6xi32>} : (memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[1,0,0]> : vector<3xi32>} : (memref<i32>) -> ()
   return
 }
 
@@ -927,36 +812,6 @@ func @omp_sections() {
 
 // -----
 
-func @omp_sections(%datavar : memref<i32>) {
-  // expected-error @below {{shared is not a valid clause for the omp.sections operation}}
-  omp.sections shared(%datavar : memref<i32>) {
-    omp.terminator
-  }
-  return
-}
-
-// -----
-
-func @omp_sections(%datavar : memref<i32>) {
-  // expected-error @below {{copyin is not a valid clause for the omp.sections operation}}
-  omp.sections copyin(%datavar : memref<i32>) {
-    omp.terminator
-  }
-  return
-}
-
-// -----
-
-func @omp_sections() {
-  // expected-error @below {{default is not a valid clause for the omp.sections operation}}
-  omp.sections default(private) {
-    omp.terminator
-  }
-  return
-}
-
-// -----
-
 func @omp_sections() {
   // expected-error @below {{proc_bind is not a valid clause for the omp.sections operation}}
   omp.sections proc_bind(close) {

diff  --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index 5732712a2c056..1c16ae75c68af 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -52,38 +52,38 @@ func @omp_terminator() -> () {
 }
 
 func @omp_parallel(%data_var : memref<i32>, %if_cond : i1, %num_threads : si32) -> () {
-  // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
-  "omp.parallel" (%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({
+  // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
+  "omp.parallel" (%if_cond, %num_threads, %data_var, %data_var) ({
 
   // test without if condition
-  // CHECK: omp.parallel num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
-    "omp.parallel"(%num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({
+  // CHECK: omp.parallel num_threads(%{{.*}} : si32) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
+    "omp.parallel"(%num_threads, %data_var, %data_var) ({
       omp.terminator
-    }) {operand_segment_sizes = dense<[0,1,1,1,1,1,1,1]>: vector<8xi32>, default_val = #omp<"clause_default defshared">} : (si32, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> ()
+    }) {operand_segment_sizes = dense<[0,1,1,1]>: vector<4xi32>} : (si32, memref<i32>, memref<i32>) -> ()
 
   // CHECK: omp.barrier
     omp.barrier
 
   // test without num_threads
-  // CHECK: omp.parallel if(%{{.*}}) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
-    "omp.parallel"(%if_cond, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({
+  // CHECK: omp.parallel if(%{{.*}}) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
+    "omp.parallel"(%if_cond, %data_var, %data_var) ({
       omp.terminator
-    }) {operand_segment_sizes = dense<[1,0,1,1,1,1,1,1]> : vector<8xi32>} : (i1, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> ()
+    }) {operand_segment_sizes = dense<[1,0,1,1]> : vector<4xi32>} : (i1, memref<i32>, memref<i32>) -> ()
 
   // test without allocate
-  // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>)
-    "omp.parallel"(%if_cond, %num_threads, %data_var, %data_var, %data_var, %data_var) ({
+  // CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32)
+    "omp.parallel"(%if_cond, %num_threads) ({
       omp.terminator
-    }) {operand_segment_sizes = dense<[1,1,1,1,1,1,0,0]> : vector<8xi32>} : (i1, si32, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> ()
+    }) {operand_segment_sizes = dense<[1,1,0,0]> : vector<4xi32>} : (i1, si32) -> ()
 
     omp.terminator
-  }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1]> : vector<8xi32>, proc_bind_val = #omp<"procbindkind spread">} : (i1, si32, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[1,1,1,1]> : vector<4xi32>, proc_bind_val = #omp<"procbindkind spread">} : (i1, si32, memref<i32>, memref<i32>) -> ()
 
   // test with multiple parameters for single variadic argument
-  // CHECK: omp.parallel private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
-  "omp.parallel" (%data_var, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({
+  // CHECK: omp.parallel allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
+  "omp.parallel" (%data_var, %data_var) ({
     omp.terminator
-  }) {operand_segment_sizes = dense<[0,0,1,2,1,1,1,1]> : vector<8xi32>} : (memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>, memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[0,0,1,1]> : vector<4xi32>} : (memref<i32>, memref<i32>) -> ()
 
   return
 }
@@ -104,13 +104,9 @@ func @omp_parallel_pretty(%data_var : memref<i32>, %if_cond : i1, %num_threads :
    omp.terminator
  }
 
- // CHECK: omp.parallel private(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>)
- omp.parallel private(%data_var : memref<i32>, %data_var : memref<i32>) firstprivate(%data_var : memref<i32>) {
-   omp.terminator
- }
-
- // CHECK omp.parallel shared(%{{.*}} : memref<i32>) copyin(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>)
- omp.parallel shared(%data_var : memref<i32>) copyin(%data_var : memref<i32>, %data_var : memref<i32>) {
+ // CHECK: omp.parallel
+ // CHECK-NEXT: omp.parallel if(%{{.*}} : i1)
+ omp.parallel {
    omp.parallel if(%if_cond: i1) {
      omp.terminator
    }
@@ -118,71 +114,50 @@ func @omp_parallel_pretty(%data_var : memref<i32>, %if_cond : i1, %num_threads :
  }
 
  // CHECK omp.parallel if(%{{.*}}) num_threads(%{{.*}} : si32) private(%{{.*}} : memref<i32>) proc_bind(close)
- omp.parallel num_threads(%num_threads : si32) if(%if_cond: i1)
-              private(%data_var : memref<i32>) proc_bind(close) {
+ omp.parallel num_threads(%num_threads : si32) if(%if_cond: i1) proc_bind(close) {
    omp.terminator
  }
 
-  // CHECK: omp.parallel default(private)
-  omp.parallel default(private) {
-    omp.terminator
-  }
-
-  // CHECK: omp.parallel default(firstprivate)
-  omp.parallel default(firstprivate) {
-    omp.terminator
-  }
-
-  // CHECK: omp.parallel default(shared)
-  omp.parallel default(shared) {
-    omp.terminator
-  }
-
-  // CHECK: omp.parallel default(none)
-  omp.parallel default(none) {
-    omp.terminator
-  }
-
   return
 }
 
 // CHECK-LABEL: omp_wsloop
 func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref<i32>, %linear_var : i32, %chunk_var : i32) -> () {
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) collapse(2) ordered(1)
-  "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var) ({
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) collapse(2) ordered(1)
+  "omp.wsloop" (%lb, %ub, %step) ({
     ^bb0(%iv: index):
       omp.yield
-  }) {operand_segment_sizes = dense<[1,1,1,2,0,0,0,0,0,0]> : vector<10xi32>, collapse_val = 2, ordered_val = 1} :
-    (index, index, index, memref<i32>, memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[1,1,1,0,0,0,0]> : vector<7xi32>, collapse_val = 2, ordered_val = 1} :
+    (index, index, index) -> ()
 
   // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(static)
   "omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var) ({
     ^bb0(%iv: index):
       omp.yield
-  }) {operand_segment_sizes = dense<[1,1,1,0,0,0,1,1,0,0]> : vector<10xi32>, schedule_val = #omp<"schedulekind Static">} :
+  }) {operand_segment_sizes = dense<[1,1,1,1,1,0,0]> : vector<7xi32>, schedule_val = #omp<"schedulekind Static">} :
     (index, index, index, memref<i32>, i32) -> ()
 
   // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>, %{{.*}} = %{{.*}} : memref<i32>) schedule(static)
   "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %linear_var, %linear_var) ({
     ^bb0(%iv: index):
       omp.yield
-  }) {operand_segment_sizes = dense<[1,1,1,0,0,0,2,2,0,0]> : vector<10xi32>, schedule_val = #omp<"schedulekind Static">} :
+  }) {operand_segment_sizes = dense<[1,1,1,2,2,0,0]> : vector<7xi32>, schedule_val = #omp<"schedulekind Static">} :
     (index, index, index, memref<i32>, memref<i32>, i32, i32) -> ()
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}}) collapse(3) ordered(2)
-  "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %data_var, %data_var, %linear_var, %chunk_var) ({
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}}) collapse(3) ordered(2)
+  "omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var, %chunk_var) ({
     ^bb0(%iv: index):
       omp.yield
-  }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1,0,1]> : vector<10xi32>, schedule_val = #omp<"schedulekind Dynamic">, collapse_val = 3, ordered_val = 2} :
-    (index, index, index, memref<i32>, memref<i32>, memref<i32>, memref<i32>, i32, i32) -> ()
+  }) {operand_segment_sizes = dense<[1,1,1,1,1,0,1]> : vector<7xi32>, schedule_val = #omp<"schedulekind Dynamic">, collapse_val = 3, ordered_val = 2} :
+    (index, index, index, memref<i32>, i32, i32) -> ()
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>) schedule(auto) nowait
-  "omp.wsloop" (%lb, %ub, %step, %data_var) ({
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) schedule(auto) nowait
+  "omp.wsloop" (%lb, %ub, %step) ({
     ^bb0(%iv: index):
       omp.yield
-  }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0,0]> : vector<10xi32>, nowait, schedule_val = #omp<"schedulekind Auto">} :
-    (index, index, index, memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[1,1,1,0,0,0,0]> : vector<7xi32>, nowait, schedule_val = #omp<"schedulekind Auto">} :
+    (index, index, index) -> ()
 
   return
 }
@@ -190,39 +165,36 @@ func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memref<i32
 // CHECK-LABEL: omp_wsloop_pretty
 func @omp_wsloop_pretty(%lb : index, %ub : index, %step : index, %data_var : memref<i32>, %linear_var : i32, %chunk_var : i32, %chunk_var2 : i16) -> () {
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>)
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) private(%data_var : memref<i32>) collapse(2) ordered(2) {
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
+  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) collapse(2) ordered(2) {
     omp.yield
   }
 
   // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(static)
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) schedule(static) lastprivate(%data_var : memref<i32>) linear(%data_var = %linear_var : memref<i32>) {
+  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) schedule(static) linear(%data_var = %linear_var : memref<i32>) {
     omp.yield
   }
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(static = %{{.*}} : i32) collapse(3) ordered(2)
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) ordered(2) private(%data_var : memref<i32>)
-     firstprivate(%data_var : memref<i32>) lastprivate(%data_var : memref<i32>) linear(%data_var = %linear_var : memref<i32>)
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(static = %{{.*}} : i32) collapse(3) ordered(2)
+  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) ordered(2) linear(%data_var = %linear_var : memref<i32>)
      schedule(static = %chunk_var : i32) collapse(3) {
     omp.yield
   }
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}} : i32, nonmonotonic) collapse(3) ordered(2)
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) ordered(2) private(%data_var : memref<i32>)
-     firstprivate(%data_var : memref<i32>) lastprivate(%data_var : memref<i32>) linear(%data_var = %linear_var : memref<i32>)
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}} : i32, nonmonotonic) collapse(3) ordered(2)
+  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) ordered(2) linear(%data_var = %linear_var : memref<i32>)
      schedule(dynamic = %chunk_var : i32, nonmonotonic) collapse(3) {
     omp.yield
   }
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}} : i16, monotonic) collapse(3) ordered(2)
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) ordered(2) private(%data_var : memref<i32>)
-     firstprivate(%data_var : memref<i32>) lastprivate(%data_var : memref<i32>) linear(%data_var = %linear_var : memref<i32>)
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}} : i16, monotonic) collapse(3) ordered(2)
+  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) ordered(2) linear(%data_var = %linear_var : memref<i32>)
      schedule(dynamic = %chunk_var2 : i16, monotonic) collapse(3) {
     omp.yield
   }
 
-  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private({{.*}} : memref<i32>)
-  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) private(%data_var : memref<i32>) {
+  // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
+  omp.wsloop (%iv) : index = (%lb) to (%ub) step (%step) {
     omp.yield
   }
 
@@ -648,81 +620,20 @@ func @omp_atomic_capture(%v: memref<i32>, %x: memref<i32>, %expr: i32) {
 // CHECK-LABEL: omp_sectionsop
 func @omp_sectionsop(%data_var1 : memref<i32>, %data_var2 : memref<i32>,
                      %data_var3 : memref<i32>, %redn_var : !llvm.ptr<f32>) {
-
-  // CHECK: omp.sections private(%{{.*}} : memref<i32>) {
-  "omp.sections" (%data_var1) ({
-    // CHECK: omp.terminator
-    omp.terminator
-  }) {operand_segment_sizes = dense<[1,0,0,0,0,0]> : vector<6xi32>} : (memref<i32>) -> ()
-
-  // CHECK: omp.sections firstprivate(%{{.*}} : memref<i32>) {
-  "omp.sections" (%data_var1) ({
-    // CHECK: omp.terminator
-    omp.terminator
-  }) {operand_segment_sizes = dense<[0,1,0,0,0,0]> : vector<6xi32>} : (memref<i32>) -> ()
-
-  // CHECK: omp.sections lastprivate(%{{.*}} : memref<i32>) {
-  "omp.sections" (%data_var1) ({
-    // CHECK: omp.terminator
-    omp.terminator
-  }) {operand_segment_sizes = dense<[0,0,1,0,0,0]> : vector<6xi32>} : (memref<i32>) -> ()
-
-  // CHECK: omp.sections private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) {
-  "omp.sections" (%data_var1, %data_var2, %data_var3) ({
-    // CHECK: omp.terminator
-    omp.terminator
-  }) {operand_segment_sizes = dense<[1,1,1,0,0,0]> : vector<6xi32>} : (memref<i32>, memref<i32>, memref<i32>) -> ()
-
   // CHECK: omp.sections allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
   "omp.sections" (%data_var1, %data_var1) ({
     // CHECK: omp.terminator
     omp.terminator
-  }) {operand_segment_sizes = dense<[0,0,0,0,1,1]> : vector<6xi32>} : (memref<i32>, memref<i32>) -> ()
+  }) {operand_segment_sizes = dense<[0,1,1]> : vector<3xi32>} : (memref<i32>, memref<i32>) -> ()
 
     // CHECK: omp.sections reduction(@add_f32 -> %{{.*}} : !llvm.ptr<f32>)
   "omp.sections" (%redn_var) ({
     // CHECK: omp.terminator
     omp.terminator
-  }) {operand_segment_sizes = dense<[0,0,0,1,0,0]> : vector<6xi32>, reductions=[@add_f32]} : (!llvm.ptr<f32>) -> ()
-
-  // CHECK: omp.sections private(%{{.*}} : memref<i32>) {
-  omp.sections private(%data_var1 : memref<i32>) {
-    // CHECK: omp.terminator
-    omp.terminator
-  }
+  }) {operand_segment_sizes = dense<[1,0,0]> : vector<3xi32>, reductions=[@add_f32]} : (!llvm.ptr<f32>) -> ()
 
-  // CHECK: omp.sections firstprivate(%{{.*}} : memref<i32>)
-  omp.sections firstprivate(%data_var1 : memref<i32>) {
-    // CHECK: omp.terminator
-    omp.terminator
-  }
-
-  // CHECK: omp.sections lastprivate(%{{.*}} : memref<i32>)
-  omp.sections lastprivate(%data_var1 : memref<i32>) {
-    // CHECK: omp.terminator
-    omp.terminator
-  }
-
-  // CHECK: omp.sections private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) {
-  omp.sections private(%data_var1 : memref<i32>) firstprivate(%data_var2 : memref<i32>) lastprivate(%data_var3 : memref<i32>) {
-    // CHECK: omp.terminator
-    omp.terminator
-  }
-
-  // CHECK: omp.sections private(%{{.*}} : memref<i32>) firstprivate(%{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) {
-  omp.sections lastprivate(%data_var1 : memref<i32>) firstprivate(%data_var2 : memref<i32>) private(%data_var3 : memref<i32>) {
-    // CHECK: omp.terminator
-    omp.terminator
-  }
-
-  // CHECK: omp.sections private(%{{.*}} : memref<i32>) nowait {
-  omp.sections nowait private(%data_var1 : memref<i32>) {
-    // CHECK: omp.terminator
-    omp.terminator
-  }
-
-  // CHECK: omp.sections firstprivate(%{{.*}} : memref<i32>, %{{.*}} : memref<i32>) lastprivate(%{{.*}} : memref<i32>) {
-  omp.sections firstprivate(%data_var1 : memref<i32>, %data_var2 : memref<i32>) lastprivate(%data_var1 : memref<i32>) {
+  // CHECK: omp.sections nowait {
+  omp.sections nowait {
     // CHECK: omp.terminator
     omp.terminator
   }

diff  --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index 94a0e0b3ae376..0de8c4d4e019a 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -379,7 +379,7 @@ llvm.func @wsloop_simple(%arg0: !llvm.ptr<f32>) {
       llvm.store %3, %4 : !llvm.ptr<f32>
       omp.yield
       // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* @[[$wsloop_loc_struct]],
-    }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0, 0]> : vector<10xi32>} : (i64, i64, i64) -> ()
+    }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0]> : vector<7xi32>} : (i64, i64, i64) -> ()
     omp.terminator
   }
   llvm.return
@@ -399,7 +399,7 @@ llvm.func @wsloop_inclusive_1(%arg0: !llvm.ptr<f32>) {
     %4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
     llvm.store %3, %4 : !llvm.ptr<f32>
     omp.yield
-  }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0, 0]> : vector<10xi32>} : (i64, i64, i64) -> ()
+  }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0]> : vector<7xi32>} : (i64, i64, i64) -> ()
   llvm.return
 }
 
@@ -417,7 +417,7 @@ llvm.func @wsloop_inclusive_2(%arg0: !llvm.ptr<f32>) {
     %4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
     llvm.store %3, %4 : !llvm.ptr<f32>
     omp.yield
-  }) {inclusive, operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0, 0, 0, 0]> : vector<10xi32>} : (i64, i64, i64) -> ()
+  }) {inclusive, operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0]> : vector<7xi32>} : (i64, i64, i64) -> ()
   llvm.return
 }
 


        


More information about the flang-commits mailing list