[Mlir-commits] [mlir] [mlir][Transforms] Dialect conversion: Context-aware type conversions (PR #140434)
Matthias Springer
llvmlistbot at llvm.org
Mon May 19 07:08:05 PDT 2025
matthias-springer wrote:
> * Block Return Type (should find Block Terminator, looking "down" in the hierarchy; or should it find parent Block?)
What is a block return type?
> Also, typically the context is actually an Attribute, which now may be arbitrarily discarded (some discussion in https://github.com/llvm/llvm-project/pull/127772).
You may be interested in [this](https://m-sp.org/downloads/mlir_workshop_2025.pdf) presentation from the last MLIR workshop.
> I am a little bit concerned about the safety of accessing the context for Value during dialect conversion. The context finding behavior, ought to be safe (theoretically a Value should only find the original IR during conversion),
We have a similar situation in conversion patterns: What kind of IR traversals are safe? The problem is that you are seeing a mixture of old and new IR. I'd say that analyzing the defining op of an SSA value is fine. If that is not enough context, you're getting on thin ice.
Btw, as part of the One-Shot Dialect Conversion refactoring, I plan to immediately materialize all IR changes. I.e., you would no longer see old IR. But there is still a long way to go for this refactoring...
> For Operations we kept both copies during conversion so a Value should find the original Op, but Block are not so well maintained in that things inside a block may not access the original Block depending on the conversion order.
With a One-Shot Dialect Conversion, we would no longer maintain the original ops. There would also be no unlinked/old blocks anymore.
> The order of conversion now matters because the context is defined both up/down the hierarchy.
The traversal order is well-defined for a dialect conversion. (In contrast to a greedy pattern rewrite.)
> ParentOp (like function signature) converted the first or child (like block signature) converted the first will affect whether a Value is able to find its context.
Is that because once you converted an operation, it can no longer serve as "context"?
https://github.com/llvm/llvm-project/pull/140434
More information about the Mlir-commits
mailing list