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

    <tr>
        <th>Summary</th>
        <td>
            stackmaps can exhaust the register pool.
        </td>
    </tr>

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

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

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

<pre>
    On today's main branch, this program:
```
declare void @llvm.experimental.stackmap(i64, i32, ...)

define void @main(
  i32 %a1,
  i32 %a2,
  i32 %a3,
  i32 %a4,
  i32 %a5,
  i32 %a6,
  i32 %a7,
  i32 %a8,
  i32 %a9,
  i32 %a10,
  i32 %a11,
  i32 %a12,
  i32 %a13,
  i32 %a14,
  i32 %a15,
  i32 %a16,
  i32 %a17,
  i32 %a18,
  i32 %a19,
  i32 %a20)
{
  call void (i64, i32, ...) @llvm.experimental.stackmap(i64 0, i32 0,
    i32 %a1,
    i32 %a2,
    i32 %a3,
    i32 %a4,
    i32 %a5,
    i32 %a6,
    i32 %a7,
    i32 %a8,
    i32 %a9,
    i32 %a10,
    i32 %a11,
    i32 %a12,
    i32 %a13,
    i32 %a14,
    i32 %a15,
    i32 %a16,
    i32 %a17,
    i32 %a18,
    i32 %a19,
    i32 %a20)
  ret void
}
```

Can crash LLVM, like this:
```
$ llc -O0 lots.ll 
error: ran out of registers during register allocation
error: ran out of registers during register allocation
error: ran out of registers during register allocation
error: ran out of registers during register allocation
error: ran out of registers during register allocation
error: ran out of registers during register allocation
error: ran out of registers during register allocation
```

But note that `-O1` is fine:
```
$ llc -O1 lots.ll                                                                                                                                                                                     
$
```

My theory: the custom lowering code for stackmaps doesn't spill things like a normal call would.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztlktvnDAQgH8NXKwg28ACBw55qKdEufVubC-4MXhlmyT77zuwr6oa2t6qSkUI8FgzmsfnGTqnju3rRKJT4pjwKpBRmIl0XkxySPgjiYMJ5OBd78WY5PcJfUrofbKj53tdKi2t8Jq8O6NIUlBr38dMfx60N6OeorBZiEK-jeKQ8NrsisWuyfnyyrIs4c3Z6tnY3kw3W4s7oHXaI4saSXgpGCj_LOOILEdkBSIrEdkOkVWIrEZkDSJjFBNikTAsFIbFwrBgGBYNw8JhWDwMC4hhEXF6K171cNmVwtpz_fBy_wkjhJ7VyI9ZwwHAEcAhwDHAQcBRwGHAccCB2EBiA4oNLDbA2EBjA44NPDYA2UBkAxIUE0K8jiscF2ye0JZyej6KiUgvwkCen7--LEBY86bXnrTVixJeEGsluXulxLoYMmDxtKO9dx7UCPQ24uZI3B6c6U2I2geiZm-m_iogwLCTIho3_df-W9ooEw9gZXJxoUBEApt3rwyeBMbUMjh-zwW7cvEvXtdofpGilyMkRzt_XDIPX0TOIboR4v7Qa8alU5rsnSeXngu1cDrAoK0iCQcDuYEzNvXhdN4EJNyPwp46-4ebrcpS3bJd2RQlKwqeqjZXTd6INJpodXszK6Hu-nMQ4MDqybXWB-dsls7etkOMh_U48y9w9yYOc5dJN8JiGRLn1x38g3zTMsLShDDrAB_lrq5pOoAjdVPoRjVVyXZdp6pO1blo6npfUN5omVrRaRvapHxIyqfUtJxyTmvKwfe8bLJa5pUqVaHzHVe8kDCeNPx32GwdUs73qW9XH7q5D8vsghDCbVOEYPpJ64t9McfB-fZdf0bK0tXbdnX1O4qjgvc">