[all-commits] [llvm/llvm-project] 3043be: [IR] Add a Location to BlockArgument.

Chris Lattner via All-commits all-commits at lists.llvm.org
Tue May 18 10:18:30 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3043be9d2db4d0cdf079adb5e1bdff032405e941
      https://github.com/llvm/llvm-project/commit/3043be9d2db4d0cdf079adb5e1bdff032405e941
  Author: Chris Lattner <clattner at nondot.org>
  Date:   2021-05-18 (Tue, 18 May 2021)

  Changed paths:
    M mlir/include/mlir/IR/Block.h
    M mlir/include/mlir/IR/Builders.h
    M mlir/include/mlir/IR/OpImplementation.h
    M mlir/include/mlir/IR/Value.h
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/Block.cpp
    M mlir/lib/IR/Builders.cpp
    M mlir/lib/IR/FunctionImplementation.cpp
    M mlir/lib/IR/Value.cpp
    M mlir/lib/Parser/Parser.cpp
    M mlir/test/IR/locations.mlir
    M mlir/test/Transforms/test-legalize-type-conversion.mlir
    M mlir/test/mlir-tblgen/pattern.mlir

  Log Message:
  -----------
  [IR] Add a Location to BlockArgument.

This adds the ability to specify a location when creating BlockArguments.
Notably Value::getLoc() will return this correctly, which makes diagnostics
more precise (e.g. the example in test-legalize-type-conversion.mlir).

This is currently optional to avoid breaking any existing code - if
absent, the BlockArgument defaults to using the location of its enclosing
operation (preserving existing behavior).

The bulk of this change is plumbing location tracking through the parser
and printer to make sure it can round trip (in -mlir-print-debuginfo
mode).  This is complete for generic operations, but requires manual
adoption for custom ops.

I added support for function-like ops to round trip their argument
locations - they print correctly, but when parsing the locations are
dropped on the floor.  I intend to fix this, but it will require more
invasive plumbing through "function_like_impl" stuff so I think it
best to split it out to its own patch.

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




More information about the All-commits mailing list