Skip to content

clang rejects asm code accepted by gcc and icc #3717

@llvmbot

Description

@llvmbot
Bugzilla Link 3345
Resolution FIXED
Resolved on Mar 12, 2010 00:57
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

This code comes straight from the Linux kernel.

$ cat /tmp/bug2.c
unsigned long __clear_user(void *addr, unsigned long size)
{
long __d0;

asm volatile(
" testq %[size8],%[size8]\n"
" jz 4f\n"
"0: movq %[zero],(%[dst])\n"
" addq %[eight],%[dst]\n"
" decl %%ecx ; jnz 0b\n"
"4: movq %[size1],%%rcx\n"
" testl %%ecx,%%ecx\n"
" jz 2f\n"
"1: movb %b[zero],(%[dst])\n"
" incq %[dst]\n"
" decl %%ecx ; jnz 1b\n"
"2:\n"
".section .fixup,"ax"\n"
"3: lea 0(%[size1],%[size8],8),%[size8]\n"
" jmp 2b\n"
".previous\n"
".section __ex_table,"a"\n"
" .align 8\n"
" .quad 0b,3b\n"
" .quad 1b,2b\n"
".previous"
: [size8] "=c"(size), [dst] "=&D" (__d0)
: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
[zero] "r" (0UL), [eight] "r" (8UL));
return size;
}
$ gcc -w -c /tmp/bug2.c
$ icc -w -c /tmp/bug2.c
$ clang /tmp/bug2.c
/tmp/bug2.c:29:28: error: invalid input constraint '[size8]' in asm
: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
^
1 diagnostic generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions