[LLVMbugs] [Bug 20847] New: variadic function with AMD64 abi and windows calling convention

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 4 09:35:34 PDT 2014


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

            Bug ID: 20847
           Summary: variadic function with AMD64 abi and windows calling
                    convention
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: maxime.madau at hp.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12986
  --> http://llvm.org/bugs/attachment.cgi?id=12986&action=edit
test code

Hi,

Architecture: linux x86-64.

Compilation command line : clang hello.c -o hello

expected output: 1 2 3 4 5 6 7 8 9 10

output: 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10

When using __attribute__((ms_abi)) on a variadic function with more than 6
arguments, the program will reiterate at the beginning of the argument passed
on the stack (test code attached).

Firstly, clang pushes all arguments after the first 6 arguments (creates the
register save area) in the stack before the base pointer. Then clang emits the
va_arg and va_list for System V AMD64 and thus instead of going on the stack
and accessing all arguments one-by-one like Microsoft calling convention does,
it  goes through the stack until gp_offset is > 48 (e.g until the end of the
register save area, which is located before the base pointer in my program).
Finally, it reiterates starting from the beginning of the register save area.

-- 
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/20140904/85277f14/attachment.html>


More information about the llvm-bugs mailing list