Skip to content

incorrect handling of __inline #4394

@llvmbot

Description

@llvmbot
Bugzilla Link 4022
Resolution INVALID
Resolved on Mar 06, 2010 13:59
Version unspecified
OS other
Reporter LLVM Bugzilla Contributor

Extended Description

It seems that clang handles __inline incorrectly and generates incorrect assembly. The following test case demonstrates the problem. The output of clang and gcc when compiling this can also be found further down.

As a matter of fact I ran across a similar problem also today, but I couldn't narrow it down to a proper test case. It was related to having a static variable at file scope and accessing it from inline assembly. For some reason at a later time the linker said it couldn't resolve the symbol (the static variable at file scope). Is it possible that it is related to whatever is causing the __inline problem?

Test Case:

__inline int
vm_page_bits(int base, int size)
{
int i = 5;
return (i);
}

void
vm_page_clear_dirty(int m, int base, int size)
{
m &= ~vm_page_bits(base, size);
}

int main(void)
{
return 0;
}

Compilation with gcc:

bash-3.2# gcc test8.c

Compilation with clang:

bash-3.2# clang test8.c
/tmp/cc-M5jSDr.o: In function vm_page_clear_dirty': test8.c:(.text+0x2c): undefined reference to vm_page_bits'

Assembly generated by clang:

vm_page_clear_dirty:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl 8(%ebp), %eax
movl 12(%ebp), %ecx
movl 16(%ebp), %edx
movl %eax, -4(%ebp)
movl %ecx, -8(%ebp)
movl %edx, -12(%ebp)
movl -4(%ebp), %eax
movl -8(%ebp), %ecx
movl -12(%ebp), %edx
movl %ecx, (%esp)
movl %edx, 4(%esp)
movl %eax, -16(%ebp)
call vm_page_bits
xorl $4294967295, %eax
movl -16(%ebp), %ecx
andl %eax, %ecx
movl %ecx, -4(%ebp)
addl $24, %esp
popl %ebp
ret

Assembly generated by gcc:

vm_page_clear_dirty:
pushl %ebp
movl %esp, %ebp
pushl 16(%ebp)
pushl 12(%ebp)
call vm_page_bits
addl $8, %esp
notl %eax
andl %eax, 8(%ebp)
leave
ret

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other categoryinvalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions