http://llvm.org/bugs/show_bug.cgi?id=18415

            Bug ID: 18415
           Summary: Instrinsics don't honour -mregparm=3 on i386
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Target Description Classes
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Consider the following test case.

void *foo(void *dest, const void *src, int n);
void *memcpy(void *dest, const void *src, int n);

void  use_foo(void *dest, const void *src, int n)
{
    foo(dest, src, n);
}
void use_builtin(void *dest, const void *src, int n)
{
    __builtin_memcpy(dest, src, n);
}
int use_memcpy(void *dest, const void *src, int n)
{
    memcpy(dest, src, n);
}

Compile with:
clang -S -o- -m32 foo.c -Os -mregparm=3 

We expect each function to look something like this:

use_foo:                                # @use_foo
# BB#0:                                 # %entry
    jmp    foo                     # TAILCALL

But the call to __builtin_memcpy() will put its arguments on the *stack*,
ignoring the fact that it was told mregparm=3:

use_builtin:                            # @use_builtin
# BB#0:                                 # %entry
    subl    $12, %esp
    movl    %ecx, 8(%esp)
    movl    %edx, 4(%esp)
    movl    %eax, (%esp)
    calll    memcpy
    addl    $12, %esp
    retl

Depending on whether we add -ffreestanding/-fno-builtin, the call to plain
"memcpy" may do one or the other.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to