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

    <tr>
        <th>Summary</th>
        <td>
            opt -passes=codegenprepare crashes on a null TargetMachine
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            crash-on-valid
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            aeubanks,
            paperchalice,
            optimisan
      </td>
    </tr>

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

<pre>
    The new pass manager just crashes on CodeGenPrepare (and probably other IR codegen passes) if there is no target machine: https://godbolt.org/z/qoP6qTKG8

The old pass manager version does not crash, but it explicitly checks in the pass and fatal errors if the TargetMachine is null. The new PM could maybe guard this for all codegen passes?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxcktFunDwQhZ_G3Ix2BQNL4IKL_RMR_aoiRdW-wNieBSfGJrbZdvv0FRvSNrmyNJbPfOf4UIxmcMydOPwnEIkXSe41CkSB9wJxppmDGskaxX-Gfk5mMpHcOjk8ZLSk0YeOQmQ3ZdLra3caGRz_gJlihIkcDRzgZYkJVKA4cgTv4N5rfmT3HHimwCCwIadhDl6StFfwaeQA_38H5TUP7G5iHAW2YM6wXjKYCM5DojBwgonUaByL8ghjSnMU5VFgL7AfvJbepr0Pg8D-l8D-zT_Xb6dvj43IjyI_rrje6s-4Fw7ReAfa87plQxd4D3JJYBLwz9kaZZK9ghpZvUYwbuV6l1m9nCmRBQ7Bh7hBw-kG-_TOejOwWLuHj8Sen0D5xWqY6CoZhoWChjSaCGcfgKz9GkfZZ7ordVu2lHFX3FVNXSC2mI2dbpRCjWfWlZaKtGpbwvKgqhrrUrZFZjrM8ZAfyrwoy6Yo9o2q7-qGVV6osm0PZ1HlPJGxe2sv05pfZmJcuCsqLKo6syTZxq08t3h23u0uZI3euhG69eVOLkMUVW5NTPGvVjLJcufnBLsPMw-bu3krxT91oVtSn_PLlmC7L59t0rjIvfKTwH5dtR27OfgXVklgf_MQBfabjUuHvwMAAP__afYEgg">