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

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] Debugging output for passes dereferences `nullptr` in some cases
        </td>
    </tr>

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

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

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

<pre>
    In `mlir/lib/Rewrite/PatternApplicator.cpp` the `matchAndRewrite` method gets the `dumpRootOp` in a way that may cause it to be a `nullptr` in case the original `op` already has a trait `IsIsolatedFromAbove` (e.g. `bultin.module` op).
We have encountered this in [VAST](https://github.com/trailofbits/vast) when lowering types.
It can be reproduced like this (using debug build of mlir and vast): 
`vast-front -vast-emit-mlir=hl -o - test/vast/Transform/HL/LowerTypes/strlit-a.c | vast-opt --vast-hl-lower-types --debug`.

I already have a fix that I will submit soon.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U0GPszYQ_TXmMgI5JpDkwCFfI9RUW7XartqzwQO4a2xkj5Omv76yk1UrVfpOIHvevPf8ZmQIeraIHWu-seZSyEiL891P-Hf0n64YnHp0Vwus5avRnone6IGJ_h3vXhMy0f8qidDb87YZPUpyvhq3jbUcaMEMkzQuZ6u-EC2HFWlxCmak8FWl4rq9O0e_ZKi2IOEuH0CLJFjlA0YZA4ImIAcDgkwYG43ZyL8AowyYuzmvZ22lSSUut5PGo1QPWGQACeSlpnR5DdfgjCRUvXfreXC3rI6JI1ZzlSqGaEjbanUqmnznNiZOFeMXxs9_ICzyhoB2dNESelRAiw5JDGu-_X7-7YM1FyaOC9EWWH1momeinzUtcahGtzLRJy3GTYOmwER_k4GYOMF9QQvG3dFrOwM9NgwvzivBKG16AY-bdyqOqMDoT3wyM3GMIWEUDnGGIWqjwE2QogNpFbwYWH2GZ0PW8nRWTt5ZgjL_46qpzGnXl8VA6aAEwgR8Kew_vLRhcj5Z-PGNif4tif1IQpnoA3mjqZTVCOzwQ-Ys3UZQPtsvpszeymwMyjKLZS1_eXw5_U9qtxT4pP96jsMV7toYCHFYNUFwzlaF6mp1qk-ywG534G0rTjt-KJZuJw5KHES7OzWTPA6DqBve7sf9vpmOqMRU6E5wsee7mu-a-ijaatjz_TConaj5dJiwZXuOq9SmMua2Vs7PhQ4hYnfkXOwKIwc0Ie-OEM8FEWmLfJfKyyHOge250YHCvw1Ik8n79vPb9Z01F7ikB5hTbi7SFgkm52GTIWAAhR4n9GhHDP8f-uBWzJMfiuhN951JS-yvT7l59yeOKcjsJWWW7fwTAAD__yKVUhg">