[all-commits] [llvm/llvm-project] 5b29f8: [mlir] Fix verifier of `RegionBranchOpInterface`
Markus Böck via All-commits
all-commits at lists.llvm.org
Thu Aug 10 03:52:31 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5b29f86b42bab223ed8b9f2738802138aade74e0
https://github.com/llvm/llvm-project/commit/5b29f86b42bab223ed8b9f2738802138aade74e0
Author: Markus Böck <markus.bock+llvm at nextsilicon.com>
Date: 2023-08-10 (Thu, 10 Aug 2023)
Changed paths:
M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
M mlir/lib/Dialect/SCF/IR/SCF.cpp
M mlir/lib/Interfaces/ControlFlowInterfaces.cpp
A mlir/test/IR/test-region-branch-op-verifier.mlir
M mlir/test/lib/Dialect/Test/TestDialect.cpp
M mlir/test/lib/Dialect/Test/TestOps.td
Log Message:
-----------
[mlir] Fix verifier of `RegionBranchOpInterface`
The verifier incorrectly passed the region number of the predecessor region instead of the successor region to `getSuccessorOperands`. This went unnoticed since all upstream `RegionBranchTerminatorOpInterface` implementations did not make use of the `index` parameter.
Adding an assert to e.g. `scf.condition` to make sure the index is valid or adding a region terminator that passes different operands to different successors immediately causes the verifier to fail as it suddenly gets incorrect types.
This patch fixes the implementation to correctly pass the successor region index.
Differential Revision: https://reviews.llvm.org/D157507
Commit: f3b1361f35fcbd2b551f224bebc4068d7de8c3d2
https://github.com/llvm/llvm-project/commit/f3b1361f35fcbd2b551f224bebc4068d7de8c3d2
Author: Markus Böck <markus.bock+llvm at nextsilicon.com>
Date: 2023-08-10 (Thu, 10 Aug 2023)
Changed paths:
M mlir/include/mlir/Conversion/LLVMCommon/Pattern.h
M mlir/include/mlir/IR/OpDefinition.h
M mlir/include/mlir/TableGen/Class.h
M mlir/include/mlir/Transforms/DialectConversion.h
M mlir/include/mlir/Transforms/OneToNTypeConversion.h
M mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
M mlir/lib/Dialect/SCF/IR/SCF.cpp
M mlir/lib/TableGen/Class.cpp
M mlir/test/mlir-tblgen/op-decl-and-defs.td
M mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Log Message:
-----------
[mlir] Generate constructor in generic adaptors allowing construction from an op instance
In essentially all occurrences of adaptor constructions in the codebase, an instance of the op is available and only a different value range is being used. Nevertheless, one had to perform the ritual of calling and pass `getAttrDictionary()`, `getProperties` and `getRegions` manually.
This patch changes that by teaching TableGen to generate a new constructor in the adaptor that is constructable using `GenericAdaptor(valueRange, op)`. The (discardable) attr dictionary, properties and the regions are then taken directly from the passed op, with only the value range being taken from the first parameter.
This simplifies a lot of code and also guarantees that all the various getters of the adaptor work in all scenarios.
Differential Revision: https://reviews.llvm.org/D157516
Commit: 3b45fe2e0a5f78ac068a60718528a3f74948fea2
https://github.com/llvm/llvm-project/commit/3b45fe2e0a5f78ac068a60718528a3f74948fea2
Author: Markus Böck <markus.bock+llvm at nextsilicon.com>
Date: 2023-08-10 (Thu, 10 Aug 2023)
Changed paths:
M llvm/include/llvm/ADT/STLExtras.h
A mlir/include/mlir/Conversion/ControlFlowToSCF/ControlFlowToSCF.h
M mlir/include/mlir/Conversion/Passes.h
M mlir/include/mlir/Conversion/Passes.td
M mlir/include/mlir/IR/Block.h
M mlir/include/mlir/IR/ValueRange.h
M mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
A mlir/include/mlir/Transforms/CFGToSCF.h
M mlir/lib/Conversion/CMakeLists.txt
A mlir/lib/Conversion/ControlFlowToSCF/CMakeLists.txt
A mlir/lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp
M mlir/lib/IR/Block.cpp
A mlir/lib/Transforms/Utils/CFGToSCF.cpp
M mlir/lib/Transforms/Utils/CMakeLists.txt
A mlir/test/Conversion/ControlFlowToSCF/test.mlir
Log Message:
-----------
[mlir][cf] Add ControlFlow to SCF lifting pass
Structured control flow ops have proven very useful for many transformations doing analysis on conditional flow and loops. Doing these transformations on CFGs requires repeated analysis of the IR possibly leading to more complicated or less capable implementations. With structured control flow, a lot of the information is already present in the structure.
This patch therefore adds a transformation making it possible to lift arbitrary control flow graphs to structured control flow operations. The algorithm used is outlined in https://dl.acm.org/doi/10.1145/2693261. The complexity in implementing the algorithm was mostly spent correctly handling block arguments in MLIR (the paper only addresses the control flow graph part of it).
Note that the transformation has been implemented fully generically and does not depend on any dialect. An interface implemented by the caller is used to construct any operation necessary for the transformation, making it possible to create an interface implementation purpose fit for ones IR.
For the purpose of testing and due to likely being a very common scenario, this patch adds an interface implementation lifting the control flow dialect to the SCF dialect.
Note the use of the word "lifting". Unlike other conversion passes, this pass is not 100% guaranteed to convert all ControlFlow ops.
Only if the input region being transformed contains a single kind of return-like operations is it guaranteed to replace all control flow ops. If that is not the case, exactly one control flow op will remain branching to regions terminating with a given return-like operation (e.g. one region terminates with `llvm.return` the other with `llvm.unreachable`).
Differential Revision: https://reviews.llvm.org/D156889
Compare: https://github.com/llvm/llvm-project/compare/8dd6c7aa2ce8...3b45fe2e0a5f
More information about the All-commits
mailing list