[llvm-branch-commits] [flang] [mlir] [mlir][OpenMP] Move taskloop clauses to the context op (PR #188070)

Sergio Afonso via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 1 09:02:32 PDT 2026


================
@@ -3278,17 +3278,19 @@ static mlir::omp::TaskloopContextOp genStandaloneTaskloop(
   taskloopArgs.inReduction.vars = taskloopClauseOps.inReductionVars;
 
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
-  auto taskLoopContextOp =
-      mlir::omp::TaskloopContextOp::create(firOpBuilder, loc);
+  auto taskLoopContextOp = mlir::omp::TaskloopContextOp::create(
+      firOpBuilder, loc, taskloopClauseOps);
+  // Create entry block with arguments.
+  genEntryBlock(firOpBuilder, taskloopArgs, taskLoopContextOp.getRegion());
 
   mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
-  firOpBuilder.createBlock(&taskLoopContextOp.getRegion());
   firOpBuilder.setInsertionPointToStart(&taskLoopContextOp.getRegion().front());
+  mlir::omp::TaskloopOperands wrapperClauseOps;
   auto taskLoopOp = genWrapperOp<mlir::omp::TaskloopOp>(
-      converter, loc, taskloopClauseOps, taskloopArgs);
+      converter, loc, wrapperClauseOps, taskloopArgs);
----------------
skatrak wrote:

There's something I'm missing here. If we pass the same `taskloopArgs` to the wrapper, how is that not causing the resulting wrapper to have unused entry block arguments?

My guess is that it does, it's just that they're not being printed by the custom printer because there are no associated clause operands (this could be checked by emitting the generic MLIR format). We probably want to pass an empty list here now.

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


More information about the llvm-branch-commits mailing list