Hello.
I would like to report how I solved a strange parser issue I encountered last week on which I spent more than 1 day.
During this time I tried to figure out why the parser was silently failing at OpAsmParser::parseTypeList().
I had added a new SectionType type in my new MLIR dialect and my specified assemblyFormat in TableGen was basically:
let assemblyFormat = [{
attr-dict
->
type(results)
}];
Since I was using the release version of my MLIR project, I decided to build the debug version to be able to use GDB on it.
After building the debug version of my project, when I ran the compiler on my input it provided the following error:
"LLVM ERROR: can't create type 'MyType' because storage uniquer isn't initialized: the dialect was likely not loaded."
Therefore, I checked if I am registering my dialect with the DialectRegistry::insert() method.
Spent also about 1 hour to debug with gdb --tui my compiler project, but wasn't able to figure out why my compiler says when it fails that the storage uniquer isn't initialized.
In the end it turned out, with some help, after more than 1 day of work, that I forgot to register my new type in Dialect::Initialize() with the addTypes<>() function.
Now, it is true that information about registering a new type with its dialect can be found at least in these 2 documents:
- https://mlir.llvm.org/docs/Tutorials/DefiningAttributesAndTypes/#registering-types-with-a-dialect
- https://mlir.llvm.org/docs/Tutorials/Toy/Ch-7/#defining-the-type-class-2
But I didn't remember about these documents and I forgot to register the new type with the dialect, hence all my trouble for more than 1 day.
Even if it might be a small detail, I'm wondering if it's possible to change this error message that I received, which comes from the source file llvm/mlir/include/mlir/IR/TypeSupport.h:
"LLVM ERROR: can't create type 'MyType' because storage uniquer isn't initialized: the dialect was likely not loaded."
to say also that the error might be also because the type was not registered with the dialect.
Anyhow, I hope this will help others with similar issues with mine.
Best regards,
Alex