-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
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,Clangdoes 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=mipsflag 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,Clanginfers the architecture itself and does not crash, instead reporting errors like "invalid instruction mnemonic 'beql'".
Related Issues
This issue may be related to #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
Metadata
Metadata
Assignees
Labels
Type
Projects
Status