Skip to content

[Flang] [OpenMP] Allow any type as argument to the FlushOp #143844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2025

Conversation

Thirumalai-Shaktivel
Copy link
Member

Fixes: #143842

@llvmbot llvmbot added mlir flang Flang issues not falling into any other category mlir:openmp flang:openmp labels Jun 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 12, 2025

@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-flang-openmp

@llvm/pr-subscribers-mlir

Author: Thirumalai Shaktivel (Thirumalai-Shaktivel)

Changes

Fixes: #143842


Full diff: https://github.com/llvm/llvm-project/pull/143844.diff

2 Files Affected:

  • (modified) flang/test/Fir/fir-ops.fir (+8)
  • (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (+1-1)
diff --git a/flang/test/Fir/fir-ops.fir b/flang/test/Fir/fir-ops.fir
index 9c444d2f4e0bc..56c5220487f5e 100644
--- a/flang/test/Fir/fir-ops.fir
+++ b/flang/test/Fir/fir-ops.fir
@@ -1015,3 +1015,11 @@ func.func @test_box_total_elements(%arg0: !fir.class<!fir.type<sometype{i:i32}>>
   %6 = arith.addi %2, %5 : index
   return %6 : index
 }
+
+// omp.flush operation
+// CHECK-LABEL: func.func @omp_flush
+func.func @omp_flush(%arg0: !fir.class<!fir.type<_QMmymodTmyt1{t:i32}>>) {
+  // CHECK: omp.flush(%{{.*}} : !fir.class<!fir.type<_QMmymodTmyt1{t:i32}>>)
+  omp.flush(%arg0 : !fir.class<!fir.type<_QMmymodTmyt1{t:i32}>>)
+  return
+}
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 036c6a6e350a8..ac80926053a2d 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -889,7 +889,7 @@ def FlushOp : OpenMP_Op<"flush", clauses = [
     specified or implied.
   }] # clausesDescription;
 
-  let arguments = !con((ins Variadic<OpenMP_PointerLikeType>:$varList),
+  let arguments = !con((ins Variadic<AnyType>:$varList),
                        clausesArgs);
 
   // Override inherited assembly format to include `varList`.

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks good but see my comment. The codegen for FlushOp doesn't use the argument list anyway so it doesn't matter what is in it

ompBuilder->createFlush(builder.saveIP());

Comment on lines 1019 to 1025
// omp.flush operation
// CHECK-LABEL: func.func @omp_flush
func.func @omp_flush(%arg0: !fir.class<!fir.type<_QMmymodTmyt1{t:i32}>>) {
// CHECK: omp.flush(%{{.*}} : !fir.class<!fir.type<_QMmymodTmyt1{t:i32}>>)
omp.flush(%arg0 : !fir.class<!fir.type<_QMmymodTmyt1{t:i32}>>)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is for checking operations in the fir dialect. Please move this to mlir/test/Dialect/OpenMP/ops.mlir

Copy link
Member Author

@Thirumalai-Shaktivel Thirumalai-Shaktivel Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For LLVM dialect, we already have a test for !llvm.ptr type as an argument to FlushOp.

I wanted to add a test for fir.class<...>, which place would be the correct to add this test, @tblah? (I suppose I can't add it to mlir/test/Dialect/OpenMP/ops.mlir?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh good point. Add a lowering test for this example and check that the flush op was created successfully.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update

@Thirumalai-Shaktivel
Copy link
Member Author

Thanks for the review, @tblah !

@Thirumalai-Shaktivel Thirumalai-Shaktivel merged commit 4268360 into llvm:main Jun 13, 2025
8 checks passed
@Thirumalai-Shaktivel Thirumalai-Shaktivel deleted the llvm/flush_01 branch June 13, 2025 04:05
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang:openmp flang Flang issues not falling into any other category mlir:openmp mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'omp.flush' op operand #0 must be variadic of OpenMP-compatible variable type
3 participants