| Issue |
239086
|
| Summary |
[AArch64][SystemZ] Crash on an inline asm "r" operand of a 24-byte struct (MVT::Other)
|
| Labels |
backend:AArch64,
backend:SystemZ,
crash,
inline-asm
|
| Assignees |
|
| Reporter |
isanbard
|
*(Written by Claude, Bill's AI coding assistant; Bill reviewed and approved this before it was posted.)*
On AArch64 and SystemZ, instruction selection crashes on an inline asm `r` operand whose type is an aggregate that isn't 1, 8, 16, 32, 64, or 128 bits wide, such as a 24-byte struct or a `_Complex long double`. Other targets (x86-64, RISC-V, PowerPC, ...) report `cannot handle indirect register inputs yet for constraint 'r'`.
```c
struct S { long a, b, c; };
void f(struct S *p) { asm("" : : "r"(*p)); }
```
Clang passes `*p` as `"*r"(ptr elementtype(%struct.S) %p)`. Reduced:
```llvm
define void @f(ptr %p) {
call void asm sideeffect "", "*r"(ptr elementtype({ i64, i64, i64 }) %p)
ret void
}
```
`llc -mtriple=aarch64-linux-gnu` (`-mtriple=s390x-linux-gnu` is the same, with `SystemZTargetLowering`):
```
Value type is non-standard value, Other.
UNREACHABLE executed at llvm/include/llvm/CodeGenTypes/MachineValueType.h:392!
...
#9 llvm::AArch64TargetLowering::getRegForInlineAsmConstraint(...)
#10 getRegistersForValue(...) SelectionDAGBuilder.cpp
#11 llvm::SelectionDAGBuilder::visitInlineAsm(...)
```
`TargetLowering::ParseConstraints` turns an aggregate operand into an integer only for those six sizes, so `ConstraintVT` is `MVT::Other` here. `getRegistersForValue` passes it to `getRegForInlineAsmConstraint` before `visitInlineAsm` reaches the indirect-input error, and these cases ask for `VT`'s size without checking for `MVT::Other`:
- AArch64: `r` and `x` (`w` already checks)
- SystemZ: `r`, `d`, `f`, and `v` with the vector facility (the `{...}` case already checks)
`"=*r"` outputs crash the same way. Clang currently emits those for `_Complex` outputs, e.g. `_Complex long double` with `"=r"`.
Seen on main 3d534989cdf0 at `-O0` and `-O2`. Related: #238926 (the same `r` case gives an `i128` 32-bit registers).
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs