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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Crash reproducer gets created twice
        </td>
    </tr>

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

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

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

<pre>
    It looks like reproducers are getting created multiple times:
```console
$ echo | mlir-opt --test-pass-failure --mlir-pass-pipeline-crash-reproducer=-
module {
}

{-#
  external_resources: {
    mlir_reproducer: {
      pipeline: "test-pass-failure",
      disable_threading: false,
      verify_each: true
    }
  }
#-}
<stdin>:0:0: error: Failures have been detected while processing an MLIR pass pipeline
<stdin>:0:0: note: Pipeline failed while executing [`(anonymous namespace)::TestFailurePass` on 'builtin.module' operation]: reproducer generated at `-`
module {
}

{-#
  external_resources: {
    mlir_reproducer: {
      pipeline: "test-pass-failure",
      disable_threading: false,
      verify_each: true
    }
  }
#-}
<stdin>:0:0: error: Failures have been detected while processing an MLIR pass pipeline
<stdin>:0:0: note: Pipeline failed while executing [`(anonymous namespace)::TestFailurePass` on 'builtin.module' operation]: reproducer generated at `-`
```

When outputting to a file the reproducer can be used just fine, but the "Failures have been detected" error still gets shown twice which is confusing.
```console
$ echo | mlir-opt --test-pass-failure --mlir-pass-pipeline-crash-reproducer=/tmp/repro.mlir
<stdin>:0:0: error: Failures have been detected while processing an MLIR pass pipeline
<stdin>:0:0: note: Pipeline failed while executing [`(anonymous namespace)::TestFailurePass` on 'builtin.module' operation]: reproducer generated at `/tmp/repro.mlir`
<stdin>:0:0: error: Failures have been detected while processing an MLIR pass pipeline
<stdin>:0:0: note: Pipeline failed while executing [`(anonymous namespace)::TestFailurePass` on 'builtin.module' operation]: reproducer generated at `/tmp/repro.mlir`

$ cat /tmp/repro.mlir 
module {
}

{-#
  external_resources: {
    mlir_reproducer: {
      pipeline: "test-pass-failure",
      disable_threading: false,
      verify_each: true
    }
  }
#-}

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVk1v2zAM_TX2hXDg2I2THHxIkwUosAHDMGDHQpbpWK0sGfpom38_SkmTrB2KYQN2Sj4tkSIfHx9oN7rd13cOpNaPFqR4RDA4Gt16jsYCMwg7dE6oHXCDzGELg5dOjBLBiQFtUq6SfJPkq6TKDx-uldUSj7vFDSDvNSTzNQxSmEyPDrLMoXXZyKzNOiakpzRZFs1xbxQjSqEw44bZPjsjSspNdgg80AZhSOa3x0TzzfHiuLzNkqI8LADwxaFRTN4btNobHnGfDwO9Qvb7y0xv7ACvqKKpKN6VQHtJsb480QrLGon3rifuWiIxHO2YtPjG8QmN6Pb3yHgfXJzxeDafSru4pNqy86JcW0fhk_ITnc6PX0BjdKxje8BnoWdPCA2ighYd8tDN514QjVQ1cWJDm5mCL5_vvkGo7FzyR3mUdpGTr0dnCHycQuMLch8FlMxug0KKBVNa7QftLShGEhoZJz6WQUnl6juxesT7lRDQAdCK6J43XpDu1OTQeNoAPaJhTmiVzDYh_7l5pFkVbASCOaAYWUh81c1VN3-tm9N4u1TLj54o0d6N_jAinQYGXUDv-stBCpzYaRC8pcgP3jpyUqGX0HgXfUkDH7BN1kNXwDohZRjJFmyvnxW4Z8ExUMZ7EBZo-HY-9GPyf6dyUmzdMNJv3J2EQ1eN_ZnGfkfdSWZX9v6FvZPYeXB-7wnXe8Lbe0KK9bSqimqxmFXTtK3LdlkuWeqEk1hTnyPBsw2swwz4tTE0k16fEeNUSr2Rde_cGB8Siy19dsL1vplwPdBCyqfXv4zCPJBsaSms9URpsZ3Nq3KZ9jV2LS_ZlPMqbxtelvMGWbNo2mlXFM284alkDUobwBFrEV-54vrA4WyTirrIiyJf0ns6q_LpZHlTTjtWThd00eZNm9zkOBDtk4Bkos0uNXUE1fidJaMU1tmzkbokdgojGyE-867XpjaPbM-ovDQWUEf0PwG0H4wa">