[Mlir-commits] [mlir] [MLIR][Python] Add a function to register python-defined passes (PR #157850)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 15 01:26:39 PDT 2025
PragmaTwice wrote:
> signal_pass_failure could just be a method that an instance of a Pass calls on its base class
Ahh if you look at the [first edition of this PR](https://github.com/llvm/llvm-project/pull/157613/commits/8d17e5b831de56237324c34aefabf608b6d639b2), you will find that it can be a method bound to `self` (although not as a method from base class). It is then refactored since the design is not so straightforward (attaching additional attributes to a callable).
The "base class" form looks good at first, but you know that, the "base class" cannot be a real `mlir::Pass`-derived class (the `Pass` will be passed as `std::unique_ptr<Pass>` to the pass manager and `delete passPtr` will be called by the pass manager for destructing), and instead it can only be a wrapper class so finally it is not so attractive as I initially thought. (I think all lifetime related issues still exist in that form.)
> this could just be a static property of the class that inherits `Pass`
Yup. I think the advantage of class is that we can have a "factory object" to generate pass objects (instead of deepcopying the callable), and also static properties/methods that may benefit users. But in the current design we can also have non-static properties in the callable objects and we can use these as the input of pass descriptions/argument/name.. .
https://github.com/llvm/llvm-project/pull/157850
More information about the Mlir-commits
mailing list