[flang-commits] [flang] [flang][OpenMP] Move privatizations out of sections (PR #88191)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Mon Apr 15 12:54:12 PDT 2024


================
@@ -1997,40 +1997,39 @@ genOMP(Fortran::lower::AbstractConverter &converter,
       /*reductions=*/nullptr, allocateOperands, allocatorOperands,
       nowaitClauseOperand);
 
+  const auto &sectionBlocks =
+      std::get<Fortran::parser::OmpSectionBlocks>(sectionsConstruct.t);
+  auto &firOpBuilder = converter.getFirOpBuilder();
+  auto ip = firOpBuilder.saveInsertionPoint();
+  mlir::omp::SectionOp lastSectionOp;
+  for (const auto &[nblock, neval] :
+       llvm::zip(sectionBlocks.v, eval.getNestedEvaluations())) {
+    lastSectionOp = genSectionOp(converter, semaCtx, neval, /*genNested=*/true,
+                                 currentLocation);
+    firOpBuilder.restoreInsertionPoint(ip);
+  }
+
+  // For `omp.sections`, lastprivatized variables occur in
+  // lexically final `omp.section` operation.
   std::optional<Clause> lastPrivateClause;
   for (const Fortran::parser::OmpClause &clause : sectionsClauseList.v) {
     if (std::holds_alternative<Fortran::parser::OmpClause::Lastprivate>(
             clause.u)) {
       lastPrivateClause = makeClause(clause, semaCtx);
+      break;
----------------
luporl wrote:

Indeed, multiple `lastprivate` clauses are allowed in this case.

https://github.com/llvm/llvm-project/pull/88191


More information about the flang-commits mailing list