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

    <tr>
        <th>Summary</th>
        <td>
            [MC][ARM] `Clang` Crashes When Assembling Invalid ARM `ldrexd` Instructions with `--triple=armv7-none-eabi`
        </td>
    </tr>

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

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

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

<pre>
    ## Description

When using the latest **trunk assertions build** of Clang/`llvm-mc` with the `--triple=armv7-none-eabi` option to assemble ARM assembly code containing invalid `ldrexd` instructions `ldrexd h0,r0,[r8]`, the assembler crashes with a **SIGSEGV** due to an assertion failure in `ARMAsmParser::parseInstruction` / `ARMOperand::getReg`.  

Expected behavior is to emit diagnostics (e.g., “invalid instruction”, “destination operands must be sequential”), not to crash.
---

## Interesting Facts

- **Clang 18.1.0**:  
  - Clang **18.1.0** with the same triple/inputs produces correct error messages and exits cleanly (**no crash**).  
  - This is the latest version that still works, indicating a bug introduced after 18.1.0.

- **ARM gcc 15.1**:  
  With `arm-linux-gnueabi-gcc -march=armv7-a`, GNU `as` correctly diagnoses the invalid instructions with errors such as:  
  - ARM register expected -- `ldrexd h0,r0,[r8]'
  It does **not crash**.
---

## Steps to reproduce

This issue was reproduced in Compiler Explorer using `x86-64 Clang (trunk with assertions)`,`x86-64 Clang 18.1.0`, and `arm gcc 15.1`
Comprehensive reproduce link: [https://godbolt.org/z/TW6WcqKWj](https://godbolt.org/z/TW6WcqKWj)

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVUFz4jgT_TXi0mWXkLExBw4OhCnqq3y7lZndnGWrsTWRJY8kEzK_fkuyCUl2ancvgFG3_N7r193cOdlqxC3J70i-X_DRd8Zuz6ifX3_8XNRGvG4JywjLYI-usXLw0mhCK0Krpw41jE7qFny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