#
804d3c4c |
| 13-Nov-2024 |
Matthias Springer <me@m-sp.org> |
[mlir][IR] Add `Block::isReachable` helper function (#114928)
Add a new helper function `isReachable` to `Block`. This function
traverses all successors of a block to determine if another block is
[mlir][IR] Add `Block::isReachable` helper function (#114928)
Add a new helper function `isReachable` to `Block`. This function
traverses all successors of a block to determine if another block is
reachable from the current block.
This functionality has been reimplemented in multiple places in MLIR.
Possibly additional copies in downstream projects. Therefore, moving it
to a common place.
show more ...
|
#
da784a25 |
| 31-Jan-2024 |
Matthias Springer <me@m-sp.org> |
[mlir][IR] Add `RewriterBase::moveBlockBefore` and fix bug in `moveOpBefore` (#79579)
This commit adds a new method to the rewriter API: `moveBlockBefore`.
This op is utilized by `inlineRegionBefor
[mlir][IR] Add `RewriterBase::moveBlockBefore` and fix bug in `moveOpBefore` (#79579)
This commit adds a new method to the rewriter API: `moveBlockBefore`.
This op is utilized by `inlineRegionBefore` and covered by dialect
conversion test cases.
Also fixes a bug in `moveOpBefore`, where the previous op location was
not passed correctly. Adds a test case to
`test-strict-pattern-driver.mlir`.
show more ...
|
#
02981c96 |
| 21-Sep-2023 |
vic <victor.perez@codeplay.com> |
[MLIR][IR] Rename `Block::hasTerminator` to `mightHaveTerminator` (#66870)
This `Block` member function introduced in
87d77d3cfb5049b3b3714f95b2e48bbc78d8c5f9 may be misleading to users as
the las
[MLIR][IR] Rename `Block::hasTerminator` to `mightHaveTerminator` (#66870)
This `Block` member function introduced in
87d77d3cfb5049b3b3714f95b2e48bbc78d8c5f9 may be misleading to users as
the last operation in the block might have not been registered, so there
would be no way to ensure that is a terminator.
---------
Signed-off-by: Victor Perez <victor.perez@codeplay.com>
show more ...
|
#
87d77d3c |
| 15-Sep-2023 |
vic <victor.perez@codeplay.com> |
[mlir][IR] Insert operations before `SingleBlock`'s terminator (#65959)
Change `SingleBlock::{insert,push_back}` to avoid inserting the argument
operation after the block's terminator. This allows
[mlir][IR] Insert operations before `SingleBlock`'s terminator (#65959)
Change `SingleBlock::{insert,push_back}` to avoid inserting the argument
operation after the block's terminator. This allows removing
`SingleBlockImplicitTerminator`'s functions with the same name.
Define `Block::hasTerminator` checking whether the block has a
terminator operation.
Signed-off-by: Victor Perez <victor.perez@codeplay.com>
show more ...
|
#
3b45fe2e |
| 02-Aug-2023 |
Markus Böck <markus.bock+llvm@nextsilicon.com> |
[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
[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
show more ...
|
#
68f58812 |
| 26-May-2023 |
Tres Popp <tpopp@google.com> |
[mlir] Move casting calls from methods to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionali
[mlir] Move casting calls from methods to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent.
Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call.
Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Implementation: This patch updates all remaining uses of the deprecated functionality in mlir/. This was done with clang-tidy as described below and further modifications to GPUBase.td and OpenMPOpsInterfaces.td.
Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state.
``` ninja -C $BUILD_DIR clang-tidy
run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix
rm -rf $BUILD_DIR/tools/mlir/**/*.inc ```
Differential Revision: https://reviews.llvm.org/D151542
show more ...
|
#
f55ed889 |
| 18-Sep-2022 |
Kazu Hirata <kazu@google.com> |
[mlir] Use x.empty() instead of llvm::empty(x) (NFC)
I'm planning to deprecate and eventually remove llvm::empty.
Note that no use of llvm::empty requires the ability of llvm::empty to determine th
[mlir] Use x.empty() instead of llvm::empty(x) (NFC)
I'm planning to deprecate and eventually remove llvm::empty.
Note that no use of llvm::empty requires the ability of llvm::empty to determine the emptiness from begin/end only.
show more ...
|
#
27e8ee20 |
| 29-Aug-2022 |
Jeff Niu <jeff@modular.com> |
[mlir] Remove a not very useful `eraseArguments` overload
This overload just wraps a bitvector, and in most cases a bitvector could be used directly instead of a list.
Reviewed By: rriddle
Differe
[mlir] Remove a not very useful `eraseArguments` overload
This overload just wraps a bitvector, and in most cases a bitvector could be used directly instead of a list.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D132896
show more ...
|
#
5b569ed2 |
| 29-Aug-2022 |
Jeff Niu <jeff@modular.com> |
[mlir] Add `Block::eraseArguments` that erases a subrange
This patch adds a an `eraseArguments` function that erases a subrange of a block's arguments. This can be used inplace of the terrible patte
[mlir] Add `Block::eraseArguments` that erases a subrange
This patch adds a an `eraseArguments` function that erases a subrange of a block's arguments. This can be used inplace of the terrible pattern
``` block->eraseArguments(llvm::to_vector(llvm::seq(...))); ```
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D132890
show more ...
|
#
b7f93c28 |
| 14-Jul-2022 |
Jeff Niu <jeff@modular.com> |
[mlir] (NFC) run clang-format on all files
|
#
d10d49dc |
| 26-Jan-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir][NFC] Add a using for llvm::BitVector to LLVM.h
BitVector is becoming widespread enough that we should add a proper using.
Differential Revision: https://reviews.llvm.org/D118290
|
#
e084679f |
| 19-Jan-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir] Make locations required when adding/creating block arguments
BlockArguments gained the ability to have locations attached a while ago, but they have always been optional. This goes against th
[mlir] Make locations required when adding/creating block arguments
BlockArguments gained the ability to have locations attached a while ago, but they have always been optional. This goes against the core tenant of MLIR where location information is a requirement, so this commit updates the API to require locations.
Fixes #53279
Differential Revision: https://reviews.llvm.org/D117633
show more ...
|
#
02b6fb21 |
| 20-Dec-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Fix clang-tidy issues in mlir/ (NFC)
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D115956
|
#
066b3207 |
| 16-Jun-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Use early exist and simplify a condition in Block SuccessorRange (NFC)
|
#
a6559b42 |
| 16-Jun-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Fix verifier crashing on some invalid IR
In a region with multiple blocks the verifier will try to look for dominance and may get successor list for blocks, even though a block may be empty or does
Fix verifier crashing on some invalid IR
In a region with multiple blocks the verifier will try to look for dominance and may get successor list for blocks, even though a block may be empty or does not end with a terminator.
Differential Revision: https://reviews.llvm.org/D104411
show more ...
|
#
81467f50 |
| 23-May-2021 |
Chris Lattner <clattner@nondot.org> |
[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 precis
[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.
This is a reapply of the patch here: https://reviews.llvm.org/D102567 with an additional change: we now never defer block argument locations, guaranteeing that we can round trip correctly.
This isn't required in all cases, but allows us to hill climb here and works around unrelated bugs like https://bugs.llvm.org/show_bug.cgi?id=50451
Differential Revision: https://reviews.llvm.org/D102991
show more ...
|
#
80d981ed |
| 19-May-2021 |
Richard Smith <richard@metafoo.co.uk> |
Revert "[IR] Add a Location to BlockArgument." and follow-on commit "[mlir] Speed up Lexer::getEncodedSourceLocation"
This reverts commit 3043be9d2db4d0cdf079adb5e1bdff032405e941 and commit 861d69a5
Revert "[IR] Add a Location to BlockArgument." and follow-on commit "[mlir] Speed up Lexer::getEncodedSourceLocation"
This reverts commit 3043be9d2db4d0cdf079adb5e1bdff032405e941 and commit 861d69a5259653f60d59795597493a7939b794fe.
This change resulted in printing textual MLIR that can't be parsed; see review thread https://reviews.llvm.org/D102567 for details.
show more ...
|
#
3043be9d |
| 16-May-2021 |
Chris Lattner <clattner@nondot.org> |
[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 preci
[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
show more ...
|
#
fcdf142e |
| 25-Mar-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Remove unused function, fix warning (NFC)
The `mayNotHaveTerminator` was initially on Block but moved to the verifier before landing and wasn't removed from its original place where it is unused.
|
#
973ddb7d |
| 11-Mar-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Define a `NoTerminator` traits that allows operations with a single block region to not provide a terminator
In particular for Graph Regions, the terminator needs is just a historical artifact of th
Define a `NoTerminator` traits that allows operations with a single block region to not provide a terminator
In particular for Graph Regions, the terminator needs is just a historical artifact of the generalization of MLIR from CFG region. Operations like Module don't need a terminator, and before Module migrated to be an operation with region there wasn't any needed.
To validate the feature, the ModuleOp is migrated to use this trait and the ModuleTerminator operation is deleted.
This patch is likely to break clients, if you're in this case:
- you may iterate on a ModuleOp with `getBody()->without_terminator()`, the solution is simple: just remove the ->without_terminator! - you created a builder with `Builder::atBlockTerminator(module_body)`, just use `Builder::atBlockEnd(module_body)` instead. - you were handling ModuleTerminator: it isn't needed anymore. - for generic code, a `Block::mayNotHaveTerminator()` may be used.
Differential Revision: https://reviews.llvm.org/D98468
show more ...
|
#
4e02eb80 |
| 11-Mar-2021 |
River Riddle <riddleriver@gmail.com> |
[mlir] Optimize the implementation of RegionDCE
The current implementation has some inefficiencies that become noticeable when running on large modules. This revision optimizes the code, and updates
[mlir] Optimize the implementation of RegionDCE
The current implementation has some inefficiencies that become noticeable when running on large modules. This revision optimizes the code, and updates some out-dated idioms with newer utilities. The main components of this optimization include:
* Add an overload of Block::eraseArguments that allows for O(N) erasure of disjoint arguments. * Don't process entry block arguments given that we don't erase them at this point. * Don't track individual operation results, given that we don't erase them. We can just track the parent operation.
Differential Revision: https://reviews.llvm.org/D98309
show more ...
|
#
01457593 |
| 27-Feb-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Fix Block::eraseArguments: keep track the first removed element while removing
Not only this is likely more efficient than BitVector::find_first(), but also if the BitVector is empty find_first() re
Fix Block::eraseArguments: keep track the first removed element while removing
Not only this is likely more efficient than BitVector::find_first(), but also if the BitVector is empty find_first() returns -1, which llvm::drop_begin isn't robust against.
show more ...
|
#
7b06786d |
| 27-Feb-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Fix Block::eraseArguments to properly update the cached positions
This is fixing correctness and ASAN failure post-ee90bb3486948.
|
#
ee90bb34 |
| 27-Feb-2021 |
Mehdi Amini <joker.eph@gmail.com> |
Store (cache) the Argument number (index in the argument list) inside the BlockArgumentImpl
This avoids linear search in BlockArgument::getArgNumber().
Differential Revision: https://reviews.llvm.o
Store (cache) the Argument number (index in the argument list) inside the BlockArgumentImpl
This avoids linear search in BlockArgument::getArgNumber().
Differential Revision: https://reviews.llvm.org/D97596
show more ...
|
#
fe7c0d90 |
| 09-Feb-2021 |
River Riddle <riddleriver@gmail.com> |
[mlir][IR] Remove the concept of `OperationProperties`
These properties were useful for a few things before traits had a better integration story, but don't really carry their weight well these days
[mlir][IR] Remove the concept of `OperationProperties`
These properties were useful for a few things before traits had a better integration story, but don't really carry their weight well these days. Most of these properties are already checked via traits in most of the code. It is better to align the system around traits, and improve the performance/cost of traits in general.
Differential Revision: https://reviews.llvm.org/D96088
show more ...
|