[Mlir-commits] [flang] [mlir] [RFC][mlir] Introduced unit SideEffects::Resource. (PR #178291)

Matthias Springer llvmlistbot at llvm.org
Thu Jan 29 04:24:14 PST 2026


================
@@ -110,10 +149,68 @@ class Resource {
   /// Return a string name of the resource.
   virtual StringRef getName() = 0;
 
+  /// Return true if the resource is a "unit resource",
+  /// which means it cannot be partitioned and can only
+  /// be read/written as a whole. As such, none of the values
+  /// can legally point to this resource, i.e. all the side
+  /// effects affecting such a resource are operation-wide.
+  ///
+  /// Unit resources may be used for establishing ordering
+  /// constraints on specific operations, which otherwise
+  /// may be hard to preserve during MLIR transformations.
+  ///
+  /// Two operations may be reordered relative to each other
+  /// if they both only read a unit resource.
+  /// An operation may be erased if it writes a unit resource
+  /// and it is postdominated by another operation that writes
+  /// a unit resource (without first reading it).
+  ///
+  /// A unit resource should be always allocated, so Allocate/Free
----------------
matthias-springer wrote:

Why this restriction? Why is Allocate/Free not allowed for unit resources? This seems a bit artificial.

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


More information about the Mlir-commits mailing list