[flang-commits] [flang] [Flang][OpenMP]Support for lowering task_reduction and in_reduction to MLIR (PR #111155)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Thu Jan 9 09:00:30 PST 2025


================
@@ -1904,22 +1906,27 @@ genTaskOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
   EntryBlockArgs taskArgs;
   taskArgs.priv.syms = dsp.getDelayedPrivSymbols();
   taskArgs.priv.vars = clauseOps.privateVars;
+  taskArgs.inReduction.syms = inReductionSyms;
+  taskArgs.inReduction.vars = clauseOps.inReductionVars;
 
   auto genRegionEntryCB = [&](mlir::Operation *op) {
     genEntryBlock(converter.getFirOpBuilder(), taskArgs, op->getRegion(0));
     bindEntryBlockArgs(converter,
                        llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op),
                        taskArgs);
-    return llvm::to_vector(taskArgs.priv.syms);
+    return llvm::to_vector(taskArgs.getSyms());
   };
 
-  return genOpWithBody<mlir::omp::TaskOp>(
+  OpWithBodyGenInfo genInfo =
       OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
                         llvm::omp::Directive::OMPD_task)
           .setClauses(&item->clauses)
           .setDataSharingProcessor(&dsp)
-          .setGenRegionEntryCb(genRegionEntryCB),
-      queue, item, clauseOps);
+          .setGenRegionEntryCb(genRegionEntryCB);
+
+  auto taskOp =
+      genOpWithBody<mlir::omp::TaskOp>(genInfo, queue, item, clauseOps);
+  return taskOp;
----------------
skatrak wrote:

Nit: It doesn't look like this change is necessary. Since the general convention in this file is to return the result of `genOpWithBody` directly and construct the `OpWithBodyGenInfo` structure parameter inside of the call whenever possible, I think this should be left as it was.

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


More information about the flang-commits mailing list