[Mlir-commits] [mlir] [mlir][Transforms] Dialect conversion: Context-aware type conversions (PR #140434)

Hongren Zheng llvmlistbot at llvm.org
Tue May 20 02:03:10 PDT 2025


ZenithalHourlyRate wrote:

> > we had to ensure all our patterns copied over the context attribute
> 
> Have you thought about turning your context attribute into a non-discardable attribute? Or wrapping SSA values in an `assume` op instead of attaching discardable attributes?

Our downstream project heavily use `arith`/`tensor` dialect and attach context attribute to them so we are unable to convert them into non-discardable attribute. The `assume` op approach would prevent canonicalizer/cse for `arith`/`tensor` to happen, which we also rely on.

> >  when a region-bearing op is converted today, the block is unlinked and "analyzing the defining op of an SSA value" crashes when the value is a block argument of the old block. To get around this I had to ensure the block arguments were remapped properly,

> So at the point of time when the type converter is called, the block is already detached? I thought this happens after type conversion and after the replacement block has been added... How did you work around the issue exactly?

Technically this happens at the legality check stage, see workaround [here](https://github.com/google/heir/blob/c2ee3176d26b6b7d21c75cb278a2e768cacaafbf/lib/Utils/ContextAwareTypeConversion.cpp#L159-L177)

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


More information about the Mlir-commits mailing list