[Mlir-commits] [mlir] [mlir][IR] Make `RewriterBase::replaceOp` non-virtual (PR #160529)

Matthias Springer llvmlistbot at llvm.org
Thu Sep 25 05:03:42 PDT 2025


================
@@ -900,7 +900,7 @@ class ConversionPatternRewriter final : public PatternRewriter {
   /// RewriterBase APIs, (3) may be removed in the future.
   void replaceAllUsesWith(Value from, ValueRange to);
   void replaceAllUsesWith(Value from, Value to) override {
-    replaceAllUsesWith(from, ValueRange{to});
+    replaceAllUsesWith(from, to ? ValueRange{to} : ValueRange{});
----------------
matthias-springer wrote:

This function is the 1:1 version of `replaceAllUsesWith`. It dispatches to the 1:N version. Replacing with a "null" value means dropping all uses of the value. You cannot do that with a regular rewriter, but the dialect conversion API allows it and existing code relies on it. (We may want to change this at some point.) When you drop a value that still has uses, an out-of-thin-air source materialization is inserted.

The problem with "null" is that we would insert "null" values into the `ConversionValueMapping`. This "null" check that you're seeing here used to be part of `ConversionPatternRewriter::replaceOp` in the original code.


https://github.com/llvm/llvm-project/pull/160529


More information about the Mlir-commits mailing list