[Mlir-commits] [flang] [mlir] [mlir][OpenMP] Separate OutlinableInterface from taskloop LoopWrapper (PR #188068)

Kaviya Rajendiran llvmlistbot at llvm.org
Tue Mar 24 10:54:28 PDT 2026


================
@@ -3232,6 +3232,32 @@ LogicalResult TaskgroupOp::verify() {
                                 getTaskReductionByref());
 }
 
+//===----------------------------------------------------------------------===//
+// TaskloopContextOp
+//===----------------------------------------------------------------------===//
+
+TaskloopOp TaskloopContextOp::getLoopOp() {
+  for (mlir::Operation &op : getRegion().front())
+    if (auto taskloopOp = dyn_cast<TaskloopOp>(&op))
+      return taskloopOp;
+  return nullptr;
+}
+
+LogicalResult TaskloopContextOp::verifyRegions() {
+  Region &region = getRegion();
+  if (region.empty())
+    return emitOpError() << "expected non-empty region";
+
+  auto count = llvm::count_if(
+      region.front(), [](mlir::Operation &op) { return isa<TaskloopOp>(op); });
+  if (count != 1)
+    return emitOpError()
----------------
kaviya2510 wrote:

```mlir
module {
  func.func @parallel_taskloop(%lb : i32, %ub : i32, %step : i32) {
   omp.taskloop.context  {
      omp.parallel {
        omp.taskloop {
          omp.loop_nest (%iv) : i32 = (%lb) to (%ub) inclusive step (%step) {
            omp.yield
          }
        }
        omp.terminator
      }
      omp.terminator
    }
    return
  }
}

error: unexpected error: 'omp.taskloop.context' op expected exactly one TaskloopOp in the region, but 0 were found
   omp.taskloop.context  {
```

The error message for above testcase is misleading. Please add a check indicating that omp.taskloop.context expects an omp.taskloop region.

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


More information about the Mlir-commits mailing list