[Mlir-commits] [flang] [mlir] [mlir][Transforms] Add support for `ConversionPatternRewriter::replaceAllUsesWith` (PR #155244)
Rahul Kayaith
llvmlistbot at llvm.org
Tue Sep 9 12:09:07 PDT 2025
rkayaith wrote:
@matthias-springer we have a downstream pattern that is broken by this change: https://github.com/llvm/torch-mlir/blob/b8f742b2aa0fafa065d37198f574c4d23aabd886/lib/Dialect/Torch/Transforms/ReduceOpVariants.cpp#L256-L257
The rewrite does:
- `rewriter.replaceAllUsesWith` to replace one result of a 2-result op. the other result is checked earlier to have no uses.
- `rewriter.eraseOp` to erase the op
This fails the assert here during the `eraseOp` step, as one of the results was replaced earlier, but `eraseOp` is [implemented as `replaceOp` with no replacements](https://github.com/llvm/llvm-project/blob/9bc42009b9eae23d9ae7bc4986b6a09755d0eb28/mlir/lib/Transforms/Utils/DialectConversion.cpp#L2131-L2132):
https://github.com/llvm/llvm-project/blob/b6be44ad0deeb86e920873de87875d2eaa6c2d8b/mlir/lib/Transforms/Utils/DialectConversion.cpp#L1885-L1886
Is this considered an invalid use of the rewriter APIs? Or is this a bug in the implementation of the checks?
There are downstream repro instructions here if you're interested: https://github.com/iree-org/iree/issues/21908#issuecomment-3271755416
https://github.com/llvm/llvm-project/pull/155244
More information about the Mlir-commits
mailing list