When an attribute is optional and if it's missing, a mlir::Attribute() is
created to signal the missing state. In this case, it is a nullptr. This patch
adds a pre-check before checking constraints because there are bunch of
tblgen_attr.isa<...> in a condition template. Otherwise, it fails with an
assertion because it is not valid to apply isa method on a nullptr.
Details
Details
- Reviewers
rriddle mehdi_amini jpienaar antiagainst
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/tools/mlir-tblgen/RewriterGen.cpp | ||
---|---|---|
385 | What happens if I have a matcher like IntValueIsFive but an op instance does not have the attribute? I would expect the match to fail but per the implementation here, it will succeed because of the check is not performed? |
Comment Actions
Had a quick chat with @antiagainst , this is too aggressive. A proper fix might be using isa_and_nonnull for optional attribute.
With Lei's suggestion, this no longer blocks me. I'm going to close the patch. Thank you, Lei. :)
What happens if I have a matcher like IntValueIsFive but an op instance does not have the attribute? I would expect the match to fail but per the implementation here, it will succeed because of the check is not performed?