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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Pass statistics of dynamically run pipeline gets lost
        </td>
    </tr>

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

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

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

<pre>
    It would be nice if statistics of any passes that were run dynamically as a result of `Pass::runPipeline` could also be displayed when printing statistics. These are currently completely discarded. 

Small reproducer using test passes:
```
===-------------------------------------------------------------------------===
                         ... Pass statistics report ...
===-------------------------------------------------------------------------===
func.func @f() {
   return
}
```
Run with `mlir-opt test.mlir --test-stats-pass --mlir-pass-statistics` produces
```
`anonymous-namespace'::TestStatisticPass
  (S) 3 num-ops  - Number of operations counted
  (S) 3 num-ops2 - Number of operations counted one more time
```
but running with `mlir-opt test.mlir -pass-pipeline="any(test-dynamic-pipeline{dynamic-pipeline=test-stats-pass})" --mlir-pass-statistics`
produces just:
```
===-------------------------------------------------------------------------===
                         ... Pass statistics report ...
===-------------------------------------------------------------------------===
'any' Pipeline
  `anonymous-namespace'::TestDynamicPipelinePass
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVE1v2zAM_TX2hbDhyN8HH1IEBXYZirV_QLaZRIUsGfpYkf36UXbSFG26XoadZgi2ZInk4-Ojej2eum8OXrSXI_QISgwIYg_WcSesE4MFvQeuTjBza9GCO3I6jgbBeAXjSfFJDFzKE3ALHAxaL12wiarsgUyifEuDzj6IGaVQSP9hWMJxaXWIOQo7S37CEV6OqGA2QjmhDm8wpPB0RIvAKezgjUHlKOCgp1miQ5qSi4GbEccUomwXZdv1_TgRMsI0Gz36AQ14Gxw7tO6cT4C3GlTZeazLfLeO5G89rx7XAPDZk6YpBOLeloAy0MaFrX-Ebu_VkIYXREW2j1gTsRai-u4Vu0HnjTqjqXc3OfxBAnkR7hikMElhEj27hfs0rCBJwjwJadokVIP-LMfCPLlmHwRzLqC9Xasq40qr06S9TUiPaGc-YMTqVXtPFOXx4m2R5DkJSusx5JWD8hOBswAJfPdTT0IhAesZDVlpZYNelcPxU0P2hSFohTBpUq8TE95MovcudJQK-vwTaQs586WXqF6MUXcSooXMcz9eD9R3H37lu3e8h_qxlhx9XoAV46UK8Oyt-985N9GR7JZ61PB64V1U87VMd2utLpZXsb7jOMZuU1WsyouibuKxy8c2b3nshJPYReVdqGJU7j6wQeJ8e2OHG_wiCzigsyC1dbE3sjs6Ny-XI7uncSBB-j6lC5cWUv68fBJSxDMOjpbCWk_9ye7LumIsPnaMZWXW4zg2rNlXRZlVfYa8zou2rQvWt7HkPUob4JL0FsT5dqAeoRVhj0XHMvLRZs0mK4u8SftN2Tf7uilZUbK2GehmwokLmQYkqTaH2HQLqN4fLG1KStpeN4kKcVC48BP8c--O2nS_0Oh2QywuCXQL-t9D1Aff">