[llvm-bugs] [Bug 46186] New: invalid operand in inline asm from Linux kernel's fs/readdir.c

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 3 14:46:12 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46186

            Bug ID: 46186
           Summary: invalid operand in inline asm from Linux kernel's
                    fs/readdir.c
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: natechancellor at gmail.com
                CC: llvm-bugs at lists.llvm.org, nemanja.i.ibm at gmail.com

After Linux kernel commit
https://git.kernel.org/powerpc/c/334710b1496af8a0960e70121f850e209c20958f, the
kernel no longer builds with clang:

$ make -skj64 ARCH=powerpc CC=clang CROSS_COMPILE=powerpc-linux-gnu- O=out
distclean allnoconfig all
../fs/readdir.c:332:2: error: invalid operand in inline asm: '1:       
stw${1:X} $0, $12:      stw${1:X} ${0:L}, ${1:L}.section __ex_table,"a";
.balign 4; .long (1b) - . ; .long (${2:l}) - . ; .previous .section
__ex_table,"a"; .balign 4; .long (2b) - . ; .long (${2:l}) - . ; .previous '
        unsafe_put_user(offset, &prev->d_off, efault_end);
        ^
../arch/powerpc/include/asm/uaccess.h:604:34: note: expanded from macro
'unsafe_put_user'
#define unsafe_put_user(x, p, e) __put_user_goto(x, p, e)
                                 ^
../arch/powerpc/include/asm/uaccess.h:98:2: note: expanded from macro
'__put_user_goto'
        __put_user_nocheck_goto((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)),
label)
        ^
../arch/powerpc/include/asm/uaccess.h:295:2: note: expanded from macro
'__put_user_nocheck_goto'
        __put_user_size_goto((x), __pu_addr, (size), label);    \
        ^
../arch/powerpc/include/asm/uaccess.h:284:10: note: expanded from macro
'__put_user_size_goto'
        case 8: __put_user_asm2_goto(x, ptr, label); break;     \
                ^
../arch/powerpc/include/asm/uaccess.h:268:3: note: expanded from macro
'__put_user_asm2_goto'
                "1:     stw%X1 %0, %1\n"                        \
                ^
../fs/readdir.c:333:2: error: invalid operand in inline asm: '1:       
stw${1:X} $0, $12:      stw${1:X} ${0:L}, ${1:L}.section __ex_table,"a";
.balign 4; .long (1b) - . ; .long (${2:l}) - . ; .previous .section
__ex_table,"a"; .balign 4; .long (2b) - . ; .long (${2:l}) - . ; .previous '
        unsafe_put_user(ino, &dirent->d_ino, efault_end);
        ^
../arch/powerpc/include/asm/uaccess.h:604:34: note: expanded from macro
'unsafe_put_user'
#define unsafe_put_user(x, p, e) __put_user_goto(x, p, e)
                                 ^
../arch/powerpc/include/asm/uaccess.h:98:2: note: expanded from macro
'__put_user_goto'
        __put_user_nocheck_goto((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)),
label)
        ^
../arch/powerpc/include/asm/uaccess.h:295:2: note: expanded from macro
'__put_user_nocheck_goto'
        __put_user_size_goto((x), __pu_addr, (size), label);    \
        ^
../arch/powerpc/include/asm/uaccess.h:284:10: note: expanded from macro
'__put_user_size_goto'
        case 8: __put_user_asm2_goto(x, ptr, label); break;     \
                ^
../arch/powerpc/include/asm/uaccess.h:268:3: note: expanded from macro
'__put_user_asm2_goto'
                "1:     stw%X1 %0, %1\n"                        \
                ^
2 errors generated.

Reducing it down with cvise spits out:

$ cat readdir.i
int a;
void b() {
  __typeof__(a) c;
  asm goto("2:  stw%X1 %L0, %L1\n" : : "r"(0), "m"(c) : : d);
d:;
}

$ clang --target=powerpc-linux-gnu --prefix=${CBL}/toolchains/binutils/bin/
--gcc-toolchain=${CBL}/toolchains/binutils/ -no-integrated-as -m32 -mbig-endian
-O2 -c -o /dev/null readdir.i
readdir.i:4:12: error: invalid operand in inline asm: '2:       stw${1:X}
${0:L}, ${1:L}'
  asm goto("2:  stw%X1 %L0, %L1\n" : : "r"(0), "m"(c) : : d);
           ^
readdir.i:4:12: error: invalid operand in inline asm: '2:       stw${1:X}
${0:L}, ${1:L}'
2 errors generated.

$ clang --target=powerpc-linux-gnu -m32 -mbig-endian -O2 -c -o /dev/null
readdir.
readdir.i:4:12: error: invalid operand in inline asm: '2:       stw${1:X}
${0:L}, ${1:L}'
  asm goto("2:  stw%X1 %L0, %L1\n" : : "r"(0), "m"(c) : : d);
           ^
readdir.i:4:12: error: invalid operand in inline asm: '2:       stw${1:X}
${0:L}, ${1:L}'
readdir.i:4:12: error: unknown operand
<inline asm>:1:9: note: instantiated into assembly here
        2:      stw ,
                    ^
3 errors generated.

$ powerpc-linux-gcc -m32 -mbig-endian -O2 -c readdir.i

$ echo $?
0

Full files available here:
https://github.com/nathanchance/creduce-files/tree/f91938b8d1a5ace818c0be8c649d806730d9c702/334710b1496af8a0960e70121f850e209c20958f

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200603/35092d28/attachment-0001.html>


More information about the llvm-bugs mailing list