Issue |
151453
|
Summary |
[MC][MIPS]`llvm-mc` Crashes with SIGSEGV When Parsing Invalid MIPS beql Instructions with `--arch=mips`
|
Labels |
new issue
|
Assignees |
|
Reporter |
venkyqz
|
# Description
When using the latest trunk version `Clang` with the `--arch=mips` option to assemble MIPS assembly code containing invalid `beql` instructions (e.g., using floating-point registers, memory references, or invalid syntax as operands), the assembler crashes with a `SIGSEGV` due to an assertion failure in `MipsAsmParser::expandBranchImm`. This issue was discovered in Compiler Explorer using `x86-64 clang (assertions trunk)`.
# Interesting Facts
+ **Clang Versions Before 4.0.1**: In Clang versions before `4.0.1`, `Clang` does not crash and correctly reports invalid MIPS instructions with errors like "invalid operand for instruction". This suggests the crash is a regression or issue introduced in later versions.
+ **Crash Triggered by `--arch=mips`**: The crash only occurs when the `--arch=mips` flag is explicitly set. The MIPS backend seems to fail to handle invalid operands, leading to a SIGSEGV.
+ **No Crash When Architecture Is Inferred**: Without the `--arch=mips flag`, `Clang` infers the architecture itself and does not crash, instead reporting errors like "invalid instruction mnemonic 'beql'".
# Related Issues
This issue may be related to [#22763](https://github.com/llvm/llvm-project/issues/22763), which addressed incomplete support for immediate branch pseudo-instructions in the MIPS integrated assembler.
# Steps to Reproduce
Here is the comprehensive reproduce link in compiler explorer: https://godbolt.org/z/xf4WavzxE
<img width="3000" height="1577" alt="Image" src="" />
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs