[all-commits] [llvm/llvm-project] ebcc02: [mlir][AsmPrinter] Refactor printing to only print...

River Riddle via All-commits all-commits at lists.llvm.org
Mon Nov 9 22:03:45 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ebcc022507a2c25fedcb06b3ec74b98447f218ba
      https://github.com/llvm/llvm-project/commit/ebcc022507a2c25fedcb06b3ec74b98447f218ba
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2020-11-09 (Mon, 09 Nov 2020)

  Changed paths:
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/test/Conversion/LinalgToVector/linalg-to-vector.mlir
    M mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_3d.mlir
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_2d.mlir
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_outer_loop_transpose_2d.mlir
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_transpose_2d.mlir
    M mlir/test/Dialect/Affine/affine-loop-invariant-code-motion.mlir
    M mlir/test/Dialect/Affine/canonicalize.mlir
    M mlir/test/Dialect/Affine/dma-generate.mlir
    M mlir/test/Dialect/Affine/dma.mlir
    M mlir/test/Dialect/Affine/load-store.mlir
    M mlir/test/Dialect/Affine/loop-tiling-parametric.mlir
    M mlir/test/Dialect/Affine/loop-tiling-validity.mlir
    M mlir/test/Dialect/Affine/loop-tiling.mlir
    M mlir/test/Dialect/Affine/parallelize.mlir
    M mlir/test/Dialect/Affine/simplify-affine-structures.mlir
    M mlir/test/Dialect/GPU/mapping.mlir
    M mlir/test/Dialect/Linalg/roundtrip.mlir
    M mlir/test/Dialect/Linalg/standard.mlir
    M mlir/test/Dialect/Vector/ops.mlir
    M mlir/test/Dialect/Vector/vector-distribution.mlir
    M mlir/test/Dialect/Vector/vector-transforms.mlir
    M mlir/test/Transforms/cse.mlir
    M mlir/test/Transforms/loop-fusion.mlir
    M mlir/test/Transforms/loop-invariant-code-motion.mlir
    M mlir/test/Transforms/normalize-memrefs-ops.mlir

  Log Message:
  -----------
  [mlir][AsmPrinter] Refactor printing to only print aliases for attributes/types that will exist in the output.

This revision refactors the way that attributes/types are considered when generating aliases. Instead of considering all of the attributes/types of every operation, we perform a "fake" print step that prints the operations using a dummy printer to collect the attributes and types that would actually be printed during the real process. This removes a lot of attributes/types from consideration that generally won't end up in the final output, e.g. affine map attributes in an `affine.apply`/`affine.for`.

This resolves a long standing TODO w.r.t aliases, and helps to have a much cleaner textual output format. As a datapoint to the latter, as part of this change several tests were identified as testing for the presence of attributes aliases that weren't actually referenced by the custom form of any operation.

To ensure that this wouldn't cause a large degradation in compile time due to the second full print, I benchmarked this change on a very large module with a lot of operations(The file is ~673M/~4.7 million lines long). This file before this change take ~6.9 seconds to print in the custom form, and ~7 seconds after this change. In the custom assembly case, this added an average of a little over ~100 miliseconds to the compile time. This increase was due to the way that argument attributes on functions are structured and how they get printed; i.e. with a better representation the negative impact here can be greatly decreased. When printing in the generic form, this revision had no observable impact on the compile time. This benchmarking leads me to believe that the impact of this change on compile time w.r.t printing is closely related to `print` methods that perform a lot of additional/complex processing outside of the OpAsmPrinter.

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


  Commit: 892605b449f8375c62227df2eac2b8f1d7180af6
      https://github.com/llvm/llvm-project/commit/892605b449f8375c62227df2eac2b8f1d7180af6
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2020-11-09 (Mon, 09 Nov 2020)

  Changed paths:
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/MLIRContext.cpp
    M mlir/lib/Parser/AttributeParser.cpp
    M mlir/lib/Parser/LocationParser.cpp
    M mlir/lib/Parser/Parser.h
    M mlir/test/Dialect/SPIRV/Serialization/debug.mlir
    M mlir/test/IR/invalid-locations.mlir
    M mlir/test/IR/locations.mlir
    M mlir/test/IR/module-op.mlir
    M mlir/test/IR/opaque_locations.mlir
    M mlir/test/IR/parser.mlir
    M mlir/test/IR/wrapping_op.mlir
    M mlir/test/Transforms/inlining.mlir
    M mlir/test/Transforms/location-snapshot.mlir
    M mlir/test/Transforms/strip-debuginfo.mlir
    M mlir/test/mlir-tblgen/pattern.mlir

  Log Message:
  -----------
  [mlir][Asm] Add support for using an alias for trailing operation locations

Locations often get very long and clutter up operations when printed inline with them. This revision adds support for using aliases with trailing operation locations, and makes printing with aliases the default behavior. Aliases in the trailing location take the form `loc(<alias>)`, such as `loc(#loc0)`. As with all aliases, using `mlir-print-local-scope` can be used to disable them and get the inline behavior.

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


Compare: https://github.com/llvm/llvm-project/compare/6022a8b7e8d1...892605b449f8


More information about the All-commits mailing list