<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/119500>119500</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] `OneToNPatternRewriter` doesn't support `startOpModification`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            matthias-springer
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          makslevental
      </td>
    </tr>
</table>

<pre>
    Which means `OneToNPatternRewriter` can't be used with `applyPartialConversion` because `applyPartialConversion` checks whether the root has been updated/replaced:

https://github.com/llvm/llvm-project/blob/58389b220a9354ed6c34bdb9310a35165579c5e3/mlir/lib/Transforms/Utils/DialectConversion.cpp#L2244-L2251

Now I know all the doc strings say that `OneToNPatternRewriter` should only be used with `applyPartialOneToNConversion` but that's unfortunate because 

1. Sometimes you want `1:N` during dialect conversion;
2. it seems like it could work? I commented out that `assert` and it worked for me (specifically [populateOneToNFunctionOpInterfaceTypeConversionPattern](https://github.com/llvm/llvm-project/blob/8c4bc1e75de27adfbaead34b895b0efbaf17bd02/mlir/include/mlir/Transforms/OneToNTypeConversion.h#L266)).


Possibly that assert/check could be behind a `ConversionConfig` flag instead of `NDEBUG`?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVN9q6zgTfxrlRjTYku3YF75oTz9_FM62ZbeHvR5J41gbWTLSuCFvv8jJIZy9KOyCQchoRr9_GkjJHj1iz-onJsQMRJOF9JCWaP0RIxOC1c87WGkKsZ_hlBx-oidwOxXMpf9zsnriM4JPnDXFm8eP8PoORBj973iOljCypuAaPBMH4gr5mtDws6UpF8CyuMs7RLLgvgX_iTHZ4HOFQg1rwq8P6Qn1KfHzhDRh5DQhjyEQnyBxhej5uhggNEwMERcHGg2Tj6zI30S0pLwTAxPD0dK0qr0OMxODc58_l4clhr9QExODckExMdStbDslRAGdrCs0jZaVMqq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