[all-commits] [llvm/llvm-project] 024f56: [mlir] Use a type for representing branch points i...

Markus Böck via All-commits all-commits at lists.llvm.org
Tue Aug 29 11:05:23 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 024f562da67180b7be1663048c960b26c2cc16f8
      https://github.com/llvm/llvm-project/commit/024f562da67180b7be1663048c960b26c2cc16f8
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2023-08-29 (Tue, 29 Aug 2023)

  Changed paths:
    M mlir/include/mlir/Analysis/DataFlow/DenseAnalysis.h
    M mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
    M mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
    M mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
    M mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp
    M mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp
    M mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
    M mlir/lib/Dialect/Affine/IR/AffineOps.cpp
    M mlir/lib/Dialect/Async/IR/Async.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/lib/Dialect/SCF/IR/SCF.cpp
    M mlir/lib/Dialect/Shape/IR/Shape.cpp
    M mlir/lib/Dialect/Transform/IR/TransformOps.cpp
    M mlir/lib/Dialect/Vector/IR/VectorOps.cpp
    M mlir/lib/Interfaces/ControlFlowInterfaces.cpp
    M mlir/lib/Transforms/RemoveDeadValues.cpp
    M mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp
    M mlir/test/lib/Dialect/Test/TestDialect.cpp
    M mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp

  Log Message:
  -----------
  [mlir] Use a type for representing branch points in `RegionBranchOpInterface`

The current implementation is not very ergonomic or descriptive: It uses `std::optional<unsigned>` where `std::nullopt` represents the parent op and `unsigned` is the region number.
This doesn't give us any useful methods specific to region control flow and makes the code fragile to changes due to now taking the region number into account.

This patch introduces a new type called `RegionBranchPoint`, replacing all uses of `std::optional<unsigned>` in the interface. It can be implicitly constructed from a region or a `RegionSuccessor`, can be compared with a region to check whether the branch point is branching from the parent, adds `isParent` to check whether we are coming from a parent op and adds `RegionSuccessor::parent` as a descriptive way to indicate branching from the parent.

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




More information about the All-commits mailing list