llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.7k stars 11.87k forks source link

error: couldn't allocate input reg for constraint 'r' on MIPS when building some wasm2c-generated code #63632

Open glandium opened 1 year ago

glandium commented 1 year ago

This is similar to #52638, but for floats.

Reduced C reproducer:

float a;
void foo() {
    __asm__("" :: "r"(a));
}
$ clang --target=mips64el-linux-gnuabi64 -c test.c
test.c:3:13: error: couldn't allocate input reg for constraint 'r'
    __asm__("" :: "r"(a));
            ^
1 error generated.

Reduced LLVM IR reproducer:

target triple = "mips64el-unknown-linux-gnuabi64"

define void @foo() {
  call void asm sideeffect "", "r,~{$1}"(float 0.000000e+00)
  ret void
}
$ llc test.ll
error: couldn't allocate input reg for constraint 'r'
llvmbot commented 1 year ago

@llvm/issue-subscribers-backend-mips

glandium commented 1 year ago

(yes, technically, the r constraint is wrong because r is supposed to be for GPRs, but GCC is happy with this)