[Mlir-commits] [mlir] [mlir] Refactor opaque properties to make them type-safe (PR #185157)

Fabian Mora llvmlistbot at llvm.org
Tue Mar 24 06:20:46 PDT 2026


fabianmcg wrote:

> I actually disagree with both those removals. The nullptr conversion works by analogy with `Attribute attr = nullptr;`, which is a valid and reasonable pattern, and the `void *` constructor allows for both `PropertyRef(TypeID::get<...>(), nullptr);` and for `PropertyRef::get(TypeID::get<...>(), [result of malloc() and such]);`

We can add `operator=(nullptr_t)`, what I want is avoiding adding redundant constructors. However, I don't feel that strong about this point, and I can be swayed.

The idea of `PropRef` is to act as a reference to an object in memory that happens to be a prop (think of it as an opaque https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper.html that we can type safe cast). Therefore, something like `PropRef(..., malloc(...))` is something we definitely don't want, we always something like `PropRef(myObjectWithLifetime)`, which is the case for all properties (the lifetime is bound to the op's lifetime). This is to me is blocking without more discussion.

> And re `PropDescriptor`, I'd want to do that refactoring independent of interface support, so that we're not repeating parsing/printing code in operations all the time and so on ... and with an eye towards enabling generic parsing of properties ... which would probably involve registering instances of `PropertyDesc` with a `nullptr` in the value field into the context.

This sounds like the right direction, but it's a future step.


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


More information about the Mlir-commits mailing list