[Mlir-commits] [mlir] [mlir] [memref] Elevate `AllocOp`s to `GlobalOp`s pass (PR #211141)
ioana ghiban
llvmlistbot at llvm.org
Mon Jul 27 03:43:08 PDT 2026
ioghiban wrote:
> That transform is specifically for AllocaOps which allocates memory on the stack. My use case targets AllocOps which the transform you linked doesn't cover. MemRefAllocaToGlobalOp is also a transform op while I need the elevation to be a part of a lowering pipeline.
I agree that `memref.alloca_to_global` is not directly applicable here, but for reasons beyond it being used in a lowering pipeline:
* `memref.alloca_to_global` is a Transform dialect operation intended to be invoked from a Transform IR program. In contrast, IIUC `elevate-allocs-to-globals` is meant to be a pass over bufferized MemRef IR, that discovers and rewrites eligible `memref.alloc` operations itself, so the two have different roles.
* `memref.alloca_to_global` performs essentially no semantic legality analysis - it relies on the Transform dialect user to select only allocations for which changing the storage class is valid. An automatic pass has to establish that legality itself (or clearly document the assumptions under which the transformation is valid).
That said, there is some implementation overlap. The common mechanics - finding the enclosing symbol table, creating and inserting a `memref.global`, and creating the corresponding `memref.get_global` - are independent of the Transform dialect and could be factored into a shared MemRef utility used by both implementations.
However, that shared portion is fairly small, while the pass still needs its own candidate discovery, legality checks, and `memref.dealloc` handling. I’m therefore not convinced that extracting a utility for this would improve the overall implementation.
https://github.com/llvm/llvm-project/pull/211141
More information about the Mlir-commits
mailing list