This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix crash in RewriterGen when a `TypeConstraint` is not given an argument
ClosedPublic

Authored by zero9178 on Feb 2 2022, 2:17 AM.

Details

Summary

The code assumes that a TypeConstraint in the additional constraints list specifies precisely one argument.
If the user were to not specify any, it'd result in a crash. If given more than one, the additional ones were ignored.

This patch fixes the crash and disallows user errors by adding a check that a single argument is supplied to the TypeConstraint

Diff Detail

Event Timeline

zero9178 created this revision.Feb 2 2022, 2:17 AM
zero9178 requested review of this revision.Feb 2 2022, 2:17 AM
Mogball accepted this revision.Feb 2 2022, 3:05 PM

+1 I have stepped on this crash before

This revision is now accepted and ready to land.Feb 2 2022, 3:05 PM
jpienaar accepted this revision.Feb 2 2022, 3:26 PM

Thanks!

Chia-hungDuan accepted this revision.Feb 2 2022, 3:29 PM
Chia-hungDuan added inline comments.
mlir/tools/mlir-tblgen/RewriterGen.cpp
856–858

Lint: Simple single-statement body doesn't need bracket

zero9178 marked an inline comment as done.Feb 3 2022, 12:09 AM
zero9178 added inline comments.
mlir/tools/mlir-tblgen/RewriterGen.cpp
856–858

Thank you! Fixed it in the final commit