<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVNuO2zYQ_Rr5hbChu6wHPdhON3GzRYKtWyB9WYzEkcQuRQokZcf5-gylvTgFGqAoYIu34cyZM2dYa36tTr2wrJ46RoMd4aKQM9229Ge9c6MNkl0Q39GvE66f6k2jB1qYybq1BNU9z2kQ1k5oaVJGeREFcTJvkPmAyq2jMEzLMIqSbRC-C8Ld8j31yHY70_R5elTWmalxQqvfUWLjtNk048gazZH1YJnzQKVQ6BHd-PgJSinPL8N6NPpv8krLWuqahpynWbxN82jbhtsW4i1vsihroC7zFrIiadImTYsSb_wIf-8EpkPv5xk4zd4fCfLbzr-kQpTcl3H2z_wJWC1x8Py7Hhx72B83FOABuz2oJ9aAYgbdZBRTk6QoBwaKM66R6qUZn4xQHfM1aIK4sGyy6Gt3f__nb5vbUF_0NPuyiBTnNSw40bAaezgLbRg4PS5EOwMNLoCO5PeMbBqlBk7qcJoF2X5Eo7Qloj2iHg0G2bsg3v5YjRujO46kMhof_vqQ2z8-ffhsotOx-BaGSf5l7Q-E4vh107uBkkzaoNgPFMb8SpI67HaP9HW03pPl4f3T-ew3vBHORr_Q6u6q_aalTWjTsNPtjmAc6jt_ZfqIw9b5tf7YRp_h8vj4OGMsN-zks1wSpsw5GnGmNFujh0V9tyyMk2NCEQVAhlw04MjU4KitoDJfX8lIdj9rn1E9tSjF15e2Wc89s4Y8XXPdOLSuBSGXwjF2W8Yj9QLBUNqxKzo2gIJuqYkCY_Rlrq13QMUmJXB9Uf7Q6gGprqSUJZlnWY1yzmCpe5CHUjb0ZaQEGvTo_AKkpp6jvOrJX7yAcktA68AsvD0tjj19lMxMAJE073gdkr8OlPgGviO8aGcM8wnHM0pNMrFE9SQ53ZUjG_AtG18Rn0Q7GfJnftD0ilcJL5MSVjC5XpvqhdfVZGT1nx-G1xcsS5IoW_VV0UKRhW1Y1lEMbR01eYphEZYtbMMMQr6SUKO0FUkwiGOFl4UAmlMzrP4_AlHFYRyHEf3SNI6STcyLEMoij8scecJ5kIbUwkJuvJ8N0bwy1eySWs3SoRTW2bdDsFZ0CnEGTAidcBIri10Lk3SL4u38Yh30eGVUrOcXjV0IO7s_fVrNCKsZ3nfsBQcM>53315</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            segfault from selectCopy on AArch64 with LTO
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    This bug is spawned off of https://github.com/rust-lang/rust/issues/91671#issuecomment-1004901138

The AArch64InstructionSelector.cpp code has this line:

https://github.com/llvm/llvm-project/blob/6d45284618f08fa28dc515cab96fa573c4c4479e/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp#L925

The problem is that RBI.getRegBank can return null, and does so during rustc's use of LLVM.

You can see the problematic behavior atop this trace that I've uploaded to [pernos.co, here](https://pernos.co/debug/RZH6sUOHPr1TI7z0036Y-g/index.html#f{m[rJs,AA_,t[Bg,Gkvv_,f{e[rJE,Fyo_,s{af40gofAA,bFg,uKem8tA,oKf1Paw___/). That trace is derived from code that I've put into a dedicated repository, here: https://github.com/pnkfelix/issue-91671-a64-doctestfail
  

I have not yet managed to narrow the test case down to something that I can replicate atop `llc` or `opt` alone, but I wanted to start tracking the issue here in the LLVM organization so that LLVM developers could help me narrow this down further.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVNuO2zYQ_Rr5hbChu6wHPdhON3GzRYKtWyB9WYzEkcQuRQokZcf5-g6lvTgBEqCGLN6GM2fOmVGt-bU69cKyeuoYDXaEi0LOdNvSn_XOjTZIdkF8R08nXD_Vm0YPtDCTdWsJqnue0yCsndDSpIzyIgriZN4g8wGVW0dhmJZhFCXbIHwXhLvlfeqR7Xam6fP0qKwzU-OEVn-ix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