parseResourceHandle not supported from bytecode

Hi – I think I ran into something glitchy when defining a custom attribute that uses parseResourceHandle as part of its parser. This works fine when parsing MLIR asm but not bytecode. The issue is that the resource renaming map doe not appear to be shared between the BytecodeReader and the Parser used for parsing attributes within the bytecode. The result is that the BytecodeReader first does a declareResource for every resource it finds in the resource table. Then when it encounters an attribute with a resource handle, parseResourceHandle does not have access to the bytecode renaming map and will version a new handle every time.

It would seem that parseAsmEntry in the BytecodeReader needs to patch the renaming state to ::parseAttribute in some way to make this work right.

However, I suspect that the right answer is to not fall back to generic ASM printing/parsing for Bytecode for such ops. There are no real examples in tree of such attributes (DenseResourceElementsAttr, being a builtin attribute, is wired in somewhat differently from how one would do it in a dialect).

Am I on the right track with the analysis?


Confirmed: Implementing BytecodeDialectInterface and providing a custom serialization causes this to work. It would appear the ASM fallback serialization of attribtutes with resource handles is not supported.