[Mlir-commits] [mlir] [mlir][OpenMP] Convert omp.cancel parallel to LLVMIR (PR #137192)

Sergio Afonso llvmlistbot at llvm.org
Wed Apr 30 05:45:23 PDT 2025


================
@@ -1580,6 +1587,21 @@ cleanupPrivateVars(llvm::IRBuilderBase &builder,
   return success();
 }
 
+/// Returns true if the construct contains omp.cancel or omp.cancellation_point
+static bool constructIsCancellable(Operation *op) {
+  // omp.cancel must be "closely nested" so it will be visible and not inside of
+  // funcion calls. This is enforced by the verifier.
+  bool containsCancel = false;
+  op->walk([&containsCancel](Operation *child) {
+    if (mlir::isa<omp::CancelOp>(child)) {
----------------
skatrak wrote:

What I'm thinking is that if something like this is legal, we'd probably need to update verifiers and this function would need to know what type of `omp.cancel` we're looking for:
```f90
!$omp parallel
  ! ...
  !$omp do
  do i = 1, N
    ! ...
    !$omp cancel parallel
    ! ...
  end do
  ! ...
!$omp end parallel
```
I'm not familiar with `cancel` directives, so maybe this isn't even legal. In that case, I wouldn't have any concerns with this.

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


More information about the Mlir-commits mailing list