[flang] [llvm] [mlir] [flang] Add support for workdistribute construct in flang frontend (PR #146029)

Tom Eccles via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 05:41:37 PDT 2025


================
@@ -3017,3 +3017,26 @@ func.func @invalid_allocate_allocator(%arg0 : memref<i32>) -> () {
 
   return
 }
+
+// -----
+func.func @invalid_workdistribute() -> () {
+// expected-error @below {{workdistribute must be nested under teams}}
+  omp.workdistribute {
+    omp.terminator
+  }
+  return
+}
+
+// -----
+func.func @invalid_workdistribute_with_multiple_blocks() -> () {
+  omp.teams {
+  // expected-error @below {{region must contain exactly one block}}
----------------
tblah wrote:

I think this is too strict. For example,
```
!$omp teams workdistribute
  if (.true.) stop 1
!$omp end teams workdistribute
```

More importantly, the operation verifier needs to pass after each pass. For example, if this body contained an array assignment which was lowered to a loop, that would initially be all one block containing fir.do_loop, but eventually fir.do_loop would be lowered to multiple blocks with cf.cond_br and cf.br.

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


More information about the llvm-commits mailing list