[PATCH] D76903: Add a flag on the context to protect against creation of operations in unregistered dialects

Uday Bondhugula via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 01:36:57 PDT 2020


bondhugula added a comment.

In D76903#1954105 <https://reviews.llvm.org/D76903#1954105>, @mehdi_amini wrote:

> In D76903#1954082 <https://reviews.llvm.org/D76903#1954082>, @bondhugula wrote:
>
> > In D76903#1948918 <https://reviews.llvm.org/D76903#1948918>, @mehdi_amini wrote:
> >
> > > (I don't even know why we allow such operation name in the first place to be honest, other than saving a few chars when writing tests there isn't much interest)
> >
> >
> > One advantage has been in writing test cases where you need an op with a side-effect so that it just doesn't become dead code (when canonicalization is being run as part of the pass/utility you are testing). These unknown ops provided the easiest/shortest IR for it - we would have otherwise had to think of another side-effecting op (like creating a memref type and a load/store on it). Any other quick shortcut replacements?
>
>
> Using a name with a dot?
>  `foo.myop` instead of ˋmyop` should give the same effect I expect.


You mean 'foo' is a registered dialect? Won't you still still get an error if 'myop' isn't registered and we disallow all unregistered ops. Or you were suggesting something else?

> (Could also use the test dialect to avoid using the new flag moving forward)

Sure.

>> Another use case of allowing such unknown ops is a need to continue / allow transformation in their presence before the output goes to another tool that is able to finally deal with those ops. Why force a dialect to be registered when an mlir-opt transform can meaningfully work in the presence of a mix of registered and unregistered ops?
> 
> mlir-opt is really a testing tool, I expect any « real » compiler built with MLIR to always register their dialects.

Even for testing, I meant if one wanted to run:
`.... | mlir-opt  ... | <another-mlir-based-tool> ...`

If mlir-opt errors out on unregistered dialect operations, one can't test a mix of mlir registered dialect ops and other ops mid-way in the pipeline there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76903/new/

https://reviews.llvm.org/D76903





More information about the llvm-commits mailing list