[Mlir-commits] [mlir] [mlir][py] invalidate nested operations when parent is deleted (PR #93339)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Mon May 27 10:09:31 PDT 2024


ftynse wrote:

I was thinking to have a hook in `Operation::erase`, with the callback itself stored in the context, that could be used to update an externalized weak reference table. When not in use, the cost is just one pointer in the context + a branch in the destructor. When in use, the cost would be higher than just having references in the operation I suppose, depending on the actual implementaiton of the table but an indirect call is also not free.

On the Python side, having a scoped arena or a generation counter in all ops (large mutations bump the counter, ops with lower counter value than the current are considered invalid) would work for me. I'd really prefer having at least some safety mechanism, can be opt in. Unlike attributes and types, which are owned by the context and have a natural scope to them, there is more possibility for operations to get out of scope and deleted. For example, I've seen op parsing + deletion after certain pieces (regions, attributes) are extracted and copied over.

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


More information about the Mlir-commits mailing list