[LLVMbugs] [Bug 18415] New: Instrinsics don't honour -mregparm=3 on i386

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 7 14:35:50 PST 2014


            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: unassignedbugs at nondot.org
          Reporter: dwmw2 at infradead.org
                CC: llvmbugs at cs.uiuc.edu
    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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140107/85cced74/attachment.html>

More information about the llvm-bugs mailing list