<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - __int128 stack calling conventions are incorrect on x86-64"
   href="https://bugs.llvm.org/show_bug.cgi?id=42439">42439</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__int128 stack calling conventions are incorrect on x86-64
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>srhines@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a bug report that was posted internally at Google, since the user can't
register here on bugs.llvm.org:

Clang violates x86-64 calling convention in the obscure case when __int128 is
passed on stack.

Conside the following two functions:

__int128 foo(__int128 x, __int128 y, __int128 z, uint64_t a, __int128 c) {
   return x + y + z + a + c;
}

__int128 foo(__int128 x, __int128 y, __int128 z, uint64_t a, uint64_t b,
__int128 c) {
   return x + y + z + a + c;
}

Gcc generates identical code for these because __int128 have to be stored
aligned on stack (psABI says:

  Arguments of type __int128 offer the same operations as INTEGERs, yet they do
not fit into one general purpose register but require two registers.

For classification purposes __int128 is treated as if it were implemented as:
  typedef struct {
    long low, high;
  } __int128;
with the exception that arguments of type __int128 that are stored in memory
must be aligned on a 16-byte boundary.

Clang generates different code for these two functions:
  <a href="https://godbolt.org/z/ZKjb4Z">https://godbolt.org/z/ZKjb4Z</a>

Note that both GCC and Clang show the alignment of __int128 properly as 16
bytes, but this is only getting ignored when the variable is passed on the
stack.</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>