Skip to content

error: couldn't allocate input reg for constraint 'r' on MIPS when building the Linux kernel #52638

@nathanchance

Description

@nathanchance

When compiling the Linux kernel for ARCH=mips, there is an error in drivers/misc/xilinx_sdfec.c:

drivers/misc/xilinx_sdfec.c:787:8: error: couldn't allocate input reg for constraint 'r'
        err = put_user(is_active, arg);
              ^
./arch/mips/include/asm/uaccess.h:112:33: note: expanded from macro 'put_user'
        access_ok(__p, sizeof(*__p)) ? __put_user((x), __p) : -EFAULT;  \
                                       ^
./arch/mips/include/asm/uaccess.h:171:3: note: expanded from macro '__put_user'
                __put_data_asm(user_sb, __pu_ptr);                      \
                ^
./arch/mips/include/asm/uaccess.h:344:2: note: expanded from macro '__put_data_asm'
        "1:     "insn("%z2", "%3")"     # __put_data_asm        \n"     \
        ^
1 error generated.

Reduced C reproducer (thanks to @telans):

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

Reduced LLVM IR reproducer:

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

define void @b() {
entry:
  tail call void asm sideeffect "", "Jr,~{$1}"(i1 true)
  ret void
}
$ llc test.ll
error: couldn't allocate input reg for constraint 'r'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions