[all-commits] [llvm/llvm-project] 75f60c: [MLIR] Cleanup mlir-tblgen error messages for cust...

stephenneuendorffer via All-commits all-commits at lists.llvm.org
Tue Apr 7 15:06:57 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 75f60c698fdfc0ea46f84b7f92d667d6e7f53f7f
      https://github.com/llvm/llvm-project/commit/75f60c698fdfc0ea46f84b7f92d667d6e7f53f7f
  Author: Stephen Neuendorffer <stephen.neuendorffer at xilinx.com>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M mlir/test/mlir-tblgen/op-format-spec.td
    M mlir/tools/mlir-tblgen/OpFormatGen.cpp

  Log Message:
  -----------
  [MLIR] Cleanup mlir-tblgen error messages for custom assembly formats.

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.

Differential Revision: https://reviews.llvm.org/D77449


  Commit: 19fec004e23adbc43b839ddf1be8bc2e22e58aca
      https://github.com/llvm/llvm-project/commit/19fec004e23adbc43b839ddf1be8bc2e22e58aca
  Author: Stephen Neuendorffer <stephen.neuendorffer at xilinx.com>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M mlir/test/mlir-tblgen/op-format-spec.td
    M mlir/tools/mlir-tblgen/OpFormatGen.cpp

  Log Message:
  -----------
  [MLIR] Add note for file-line numbers in tablegen errors for assembly formats

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
  ^

Differential Revision: https://reviews.llvm.org/D77488


Compare: https://github.com/llvm/llvm-project/compare/ff87813715ec...19fec004e23a


More information about the All-commits mailing list