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

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Fri Apr 12 07:13:20 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;
----------------
kparzysz wrote:

I think you can have multiple `lastprivate` clauses if they contain different variables.  Please double check.

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


More information about the flang-commits mailing list