This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Cleanup mlir-tblgen error messages for custom assembly formats.
ClosedPublic

Authored by stephenneuendorffer on Apr 3 2020, 6:21 PM.

Details

Summary

The messages are somewhat cryptic, since they are not complete sentences,
include lots of ambiguous words, like 'format' which are hard to parse,
and include names from the users code which may, or may not make sense in
the context of the message. Start to clean this up and provide some
guidance for fixes.

Also, add a test for one of the messages which didn't have a test at all.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2020, 6:21 PM
rriddle requested changes to this revision.Apr 3 2020, 7:12 PM
rriddle added inline comments.
mlir/tools/mlir-tblgen/OpFormatGen.cpp
1376–1377

Remove the punctuation.

1433–1462

Diagnostics should start with lower case letters.

1436

If we are going to have suggestions, they should likely be notes instead of lumped together with the error message.

This revision now requires changes to proceed.Apr 3 2020, 7:12 PM
stephenneuendorffer marked an inline comment as done.Apr 3 2020, 10:14 PM
stephenneuendorffer added inline comments.
mlir/tools/mlir-tblgen/OpFormatGen.cpp
1436

This is in Tablegen, which doesn't have the normal reporting infrastructure. Are you suggesting changing that?

rriddle added inline comments.Apr 4 2020, 12:52 AM
mlir/tools/mlir-tblgen/OpFormatGen.cpp
1436

Notes are a builtin concept, we just need to use DK_Note as the message type when printing the message to the source manager. We could add an optional Twine for a note diagnostic to the emitError function.

https://github.com/llvm/llvm-project/blob/62f3a9650a9f289a07a5f480764fb655178c2334/mlir/tools/mlir-tblgen/OpFormatGen.cpp#L1092

Thanks for improving these BTW, they look much better. (my fault)

Is this along the lines of what you were thinking? I'm not necessarily wild about having the location described twice (once in the error and once in the note).

Separately, I'm annoyed by the lack of line numbers. I looked at this, but it seems like there is no good way to create a MemoryBuffer such that it has a Loc relative to an outer file. The include mechanism does something similar, but is probably a little misleading.

stephenneuendorffer marked 4 inline comments as done.Apr 4 2020, 10:53 PM
rriddle accepted this revision.Apr 5 2020, 10:41 PM

Please run clang-format before submitting.

This revision is now accepted and ready to land.Apr 5 2020, 10:41 PM
This revision was automatically updated to reflect the committed changes.