<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - variadic function with AMD64 abi and windows calling convention"
   href="http://llvm.org/bugs/show_bug.cgi?id=20847">20847</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>variadic function with AMD64 abi and windows calling convention
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>maxime.madau@hp.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12986" name="attach_12986" title="test code">attachment 12986</a> <a href="attachment.cgi?id=12986&action=edit" title="test code">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>