[Mlir-commits] [mlir] [mlir][OpenMP] Model memory effects of omp.critical (PR #230455)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 9 04:26:03 PDT 2026


https://github.com/JRP-arm created https://github.com/llvm/llvm-project/pull/230455

Model synchronisation as reads and writes of unspecified memory and expose recursive effects. Test the read and write effects of an empty critical region.

Assisted by: AI (ChatGPT)

>From cd512325c5017951c5d708ce37213ca9f4a944b8 Mon Sep 17 00:00:00 2001
From: "Jamie.Rowlinson-Patel at arm.com"
 <jamrow01 at ip-10-252-16-38.eu-west-1.compute.internal>
Date: Fri, 2 Oct 2026 10:16:31 +0000
Subject: [PATCH] [mlir][OpenMP] Model memory effects of omp.critical

Model synchronisation as reads and writes of unspecified memory and expose recursive effects.
Test the read and write effects of an empty critical region.
---
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td         |  4 +++-
 mlir/test/Dialect/OpenMP/memory-effects-critical.mlir | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 mlir/test/Dialect/OpenMP/memory-effects-critical.mlir

diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 6bc99cf7656992..d1a86859c0825c 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -1777,7 +1777,9 @@ def CriticalDeclareOp : OpenMP_Op<"critical.declare", clauses = [
 
 
 def CriticalOp : OpenMP_Op<"critical", [
-    DeclareOpInterfaceMethods<SymbolUserOpInterface>
+    DeclareOpInterfaceMethods<SymbolUserOpInterface>,
+    MemoryEffects<[MemRead, MemWrite]>,
+    RecursiveMemoryEffects
   ], singleRegion = 1> {
   let summary = "critical construct";
   let description = [{
diff --git a/mlir/test/Dialect/OpenMP/memory-effects-critical.mlir b/mlir/test/Dialect/OpenMP/memory-effects-critical.mlir
new file mode 100644
index 00000000000000..cbac8beb7b4495
--- /dev/null
+++ b/mlir/test/Dialect/OpenMP/memory-effects-critical.mlir
@@ -0,0 +1,10 @@
+// RUN: mlir-opt %s --test-side-effects --verify-diagnostics
+
+func.func @critical_effects() {
+  // expected-remark at +2 {{found an instance of 'read' on resource '<Default>'}}
+  // expected-remark at +1 {{found an instance of 'write' on resource '<Default>'}}
+  omp.critical {
+    omp.terminator
+  }
+  return
+}



More information about the Mlir-commits mailing list