[Mlir-commits] [mlir] [mlir][mem2reg] Promote memory slots through transparent view operations (PR #196924)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu May 21 02:57:00 PDT 2026


================
@@ -44,4 +46,62 @@ enum class DeletionKind {
 #include "mlir/Interfaces/MemorySlotOpInterfaces.h.inc"
 #include "mlir/Interfaces/MemorySlotTypeInterfaces.h.inc"
 
+namespace mlir {
+
+/// An entry in a `PromotableAliasMap`: the memory slot exposed by an aliaser
+/// operation, along with the operand it aliases from.
+struct PromotableSlotAliasInfo {
+  /// The slot exposed by the aliaser (its `ptr` is a result of the aliaser
+  /// and equals the map key).
+  MemorySlot slot;
+  /// The aliaser operand whose value is the parent slot's pointer.
+  OpOperand *aliasedSlotPointerOperand;
+};
+
+/// Maps an alias value (a result of a `PromotableAliaserInterface` op)
+/// reachable from a root slot to its `PromotableSlotAliasInfo`.
+using PromotableAliasMap =
+    llvm::SmallDenseMap<Value, PromotableSlotAliasInfo, 4>;
+
+/// Populates `aliasMap` with alias entries produced by `aliaser` for operands
+/// that already alias `rootSlot`. This should be called during a forward slice
+/// traversal from `rootSlot.ptr` to ensure topological ordering.
+void populatePromotableAliasMap(PromotableAliaserInterface aliaser,
+                                const MemorySlot &rootSlot,
+                                PromotableAliasMap &aliasMap);
+
+/// Returns a `MemorySlot` representing the operand of `op` that aliases
+/// `rootSlot.ptr`, using the alias's element type. Returns `nullopt` if no
+/// operand is an alias of `rootSlot`.
+std::optional<MemorySlot> getOpAliasSlot(Operation *op,
+                                         const MemorySlot &rootSlot,
+                                         const PromotableAliasMap &aliasMap);
+
+/// Returns true if at most one of `op`'s operands aliases `rootSlot`.
+/// This is useful to guard `getOpAliasSlot` calls, as operations reaching
+/// the root through multiple distinct aliases (e.g., memcpy between aliases)
+/// cannot be handled by interfaces expecting a single slot.
+bool isUsingAtMostOneSlotAlias(Operation *op, const MemorySlot &rootSlot,
----------------
jeanPerier wrote:

Helper has been removed as per other comment.

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


More information about the Mlir-commits mailing list