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

    <tr>
        <th>Summary</th>
        <td>
            Segfault compiling inline asm for wrong arch: `llc  …/X86/callbr-asm-outputs.ll` “couldn't allocate output register for constraint” after `SelectionDAGBuilder::visitCallBrLandingPad`
        </td>
    </tr>

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

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

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

<pre>
    # Step to Reproduce (Reduced):

`build/bin/llc -march=arm64 reduced-Upstream-callbr-asm-outputs.ll`

[reduced-Upstream-callbr-asm-outputs.ll.txt](https://github.com/user-attachments/files/16168029/reduced-Upstream-callbr-asm-outputs.ll.txt)


# Actual Result
> error: couldn't allocate output register for constraint '{si}'
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
> Stack dump:
> 0. Program arguments: build/bin/llc -march=arm64 reduced-Upstream-callbr-asm-outputs.ll
> 1. Running pass 'Function Pass Manager' on module 'reduced-Upstream-callbr-asm-outputs.ll'.
> 2. Running pass _'AArch64 Instruction Selection'_ on function '@test2'
> …
>  \#\4 0x000000010a5d2e3c _llvm::SelectionDAGBuilder::visitCallBrLandingPad_(llvm::CallInst const&) …
> …
> zsh: segmentation fault  build/bin/llc -march=arm64 reduced-Upstream-callbr-asm-outputs.ll



Similarly on Linux, also on 37 of the 42 available `arch`s.


# Step to Reproduce (Unreduced):
`build/bin/llc  -march=arm64 llvm/test/CodeGen/X86/callbr-asm-outputs.ll`
[callbr-asm-outputs.ll.txt](https://github.com/user-attachments/files/16168325/callbr-asm-outputs.ll.txt)

# Expected Result
Compiling assembly for the wrong architecture is an odd thing to do, though plausible when porting existing code or including someone else’s library.  (I was running other vendors’ tests against our fork.)  So an assertion failure, or (if assertions are disabled) just `abort(ICE_EXIT_CODE)`, would be acceptable.  But reading, writing, or executing unowned memory suggests complacent code.


# Configuration:

MacOS 13.6.7 22G720

Ubuntu 22.04.2 LTS (Jammy Jellyfish)

LLVM commit: a38d5e06326fff, built with `--enable-assertions` (plus my branch [flash-CPR-1707-force-tests](https://github.com/matter-labs/era-compiler-llvm/tree/flash-CPR-1707-force-tests), relevant for how I found it, but not in isolation.  Cp. https://github.com/llvm/llvm-project/pull/98299).  

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vk1v4zgS_TX0pWCBpmzJOvjgOHajB2lMEE8v5hZQVEniNEUK_Eji_fWLkp1k0pPenixmfZAJflXVq1evKEPQnUXcsNUVW13PZIq985uDkaE_9uh1I-2sds1pw0QOx4gjRAd3OHrXJIXAxPoOadQwUbF8y_g148_fgtdJm4aJQ60tEwdjFMwH6VXP8mvph2IJ_nx4_nUM0aMc5koaU_u5DMPcpTimGDJjWMHfXLy6-nvnsvgU2eqaiXUf4xjIP3Fg4tDp2Kc6U25g4pAC-rmMUap-QBsDE4dWG6T_RbEo1lxUTBw-YFBUb5w9f0UOWxWTNHCHIZl4mc73gN47z_ItKJdMY5koI0hjnJIR4Xw1eOx0iOihdR6UsyF6qW0EJkpWXgXNymsavtx5e7PfHvcQUj3oCBLq1IHH0flI6fsvYBjz8Pw3H737A1Vk4qBDSBMgIG0D2iqTGoTYIygvQw-1VN-ilwqzVxeOUapv0KRhfKVFvgeeMV7detd5OYD0XTpjnm_hn-LKi6kFmbpL1mrbwShDILgOyaqonYVbmvgirezQM1GCszC4JhnidPk3TYnyTwGLv5i7Z6Lcbr3qiyV8ppyls-kjGpxGTJT3ZLh9doqSuOQRQxRv8sn2gq052xavU8BWOyZyttotgT_x82_B5aoRmCu4nzKZb1m-fTF3vf10RSCjPy886KDjThpz5W-kbbTtbmVzz8T69Sytkutn0jFRMFG95807U_8OPaU1YEcpllN8rUwmwj-c6r98j3rQRnpzImxvtE1PTOxAmuBoIi_BtRN5lwLk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