This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add note for file-line numbers in tablegen errors for assembly formats
ClosedPublic

Authored by stephenneuendorffer on Apr 4 2020, 11:00 PM.

Details

Summary

Error messages for the custom assembly format are difficult to understand
because there are no line numbers. This happens because the assembly format
is parsed as a standalone line, separate from it's parent file, with no useful
location information. Fixing this properly probably requires quite a bit
of invasive plumbing through the SourceMgr, similar to how included files
are handled

This proposal is a less invasive short term solution. When generating an
error message we generate an additional note which at least properly describes
the operation definition the error occured in, if not the actual line number
of the assemblyFormat definition.

A typical message is like:

error: type of operand #0, named 'operand', is not buildable and a buildable type cannot be inferred

$operand type($result) attr-dict
^

/src/llvm-project/mlir/test/mlir-tblgen/op-format-spec.td:296:1: note: in custom assembly format for this operation
def ZCoverageInvalidC : TestFormat_Op<"variable_invalid_c", [{
^
note: suggest adding a type constraint to the operation or adding a 'type($operand)' directive to the custom assembly format

$operand type($result) attr-dict
^

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2020, 11:00 PM

This would need to be extended to other emitError calls.....

rriddle requested changes to this revision.Apr 5 2020, 1:00 AM

Thanks!

mlir/tools/mlir-tblgen/OpFormatGen.cpp
1058

Can you populate the location in the constructor so that we can use it for all errors?

1105

nit: Can you move this to after the note below, and add a slightly more descriptive message?

"see the operation defining the assembly format" or something better

This revision now requires changes to proceed.Apr 5 2020, 1:00 AM
stephenneuendorffer retitled this revision from [MLIR] Proposal for file-line numbers in tablegen errors. to [MLIR] Add note for file-line numbers in tablegen errors for assembly formats.
stephenneuendorffer edited the summary of this revision. (Show Details)
stephenneuendorffer marked an inline comment as done.Apr 5 2020, 2:51 PM

Yes, of course, that makes much more sense!

rriddle accepted this revision.Apr 5 2020, 2:58 PM
This revision is now accepted and ready to land.Apr 5 2020, 2:58 PM
This revision was automatically updated to reflect the committed changes.