[all-commits] [llvm/llvm-project] 5b0075: [mlir][Conversion] Generalize and fix crash in `re...
Matthias Springer via All-commits
all-commits at lists.llvm.org
Wed Jun 19 07:23:49 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5b007582bb9142ccab47134e5d2de0dd451338af
https://github.com/llvm/llvm-project/commit/5b007582bb9142ccab47134e5d2de0dd451338af
Author: Matthias Springer <me at m-sp.org>
Date: 2024-06-19 (Wed, 19 Jun 2024)
Changed paths:
M mlir/include/mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h
M mlir/lib/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.cpp
M mlir/test/Conversion/FuncToLLVM/calling-convention.mlir
R mlir/test/Conversion/ReconcileUnrealizedCasts/reconcile-unrealized-casts-failure.mlir
M mlir/test/Conversion/ReconcileUnrealizedCasts/reconcile-unrealized-casts.mlir
M mlir/test/Dialect/LLVM/lower-to-llvm-e2e-with-target-tag.mlir
M mlir/test/Dialect/LLVM/lower-to-llvm-e2e-with-top-level-named-sequence.mlir
Log Message:
-----------
[mlir][Conversion] Generalize and fix crash in `reconcile-unrealized-casts` (#95700)
This commit fixes a crash in `-reconcile-unrealized-casts` when cast ops
have multiple operands:
```
DialectConversion.cpp:1583: virtual void mlir::ConversionPatternRewriter::replaceOp(mlir::Operation *, mlir::ValueRange): Assertion `op->getNumResults() == newValues.size() && "incorrect # of replacement values"' failed.
```
This commit also generalizes the pass such that more ops are folded. In
particular (letters indicate types):
```
A
/ \
B C
|
A
```
Previously, such IR was not folded at all. The `A -> B -> A` type cast
cycle is now folded away. (The `A -> C` cast stays in place.)
This commit also turns the pass from a dialect conversion into a simple
IR walk. The pattern and its `populate` function are removed. The
pattern was a (non-conversion) rewrite pattern, but used in a dialect
conversion, which is generally not safe. In particular, the rewrite
pattern may traverse IR that was already scheduled for erasure by the
dialect conversion.
Note: Some test cases changed slightly (NFC) because the new pass
implementation no longer attempts to fold ops.
Note for LLVM integration: If your pipeline uses the removed `populate`
function, try to simply remove that function call. Chances are you may
not need it at all. If it is in fact needed, run the
`-reconcile-unrealized-casts` pass right after the pass that used to
populate the pattern.
---------
Co-authored-by: Maksim Levental <maksim.levental at gmail.com>
Co-authored-by: Markus Böck <markus.boeck02 at gmail.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list