<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 --- - [x86-64 Itanium ABI] clang uses wrong return location for class with head padding"
   href="http://llvm.org/bugs/show_bug.cgi?id=19675">19675</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[x86-64 Itanium ABI] clang uses wrong return location for class with head padding
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.4
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>greened@obbligato.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, 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=12488" name="attach_12488" title="Testcase">attachment 12488</a> <a href="attachment.cgi?id=12488&action=edit" title="Testcase">[details]</a></span>
Testcase

clang appears to use the wrong sequence for returning an object with head
padding.

For the attached testcase, clang -O2 generates the following code for function
foo:

    .globl    _Z3fooR1Y
    .align    16, 0x90
    .type    _Z3fooR1Y,@function
_Z3fooR1Y:                              # @_Z3fooR1Y
    .cfi_startproc
# BB#0:                                 # %entry
    movq    8(%rdi), %rax
    ret
.Ltmp0:
    .size    _Z3fooR1Y, .Ltmp0-_Z3fooR1Y
    .cfi_endproc

The class Y should be classified INTEGER under the x86-64 ABI.  It has eight
bytes of head padding because it inherits from an empty base class and has a
member that also inherits from the same empty base class.  By my reading of the
ABI, foo should return the Y object in (RAX, RDX), with RDX containing the
meaningful bits (the long value).

The Intel compiler generates the code I would expect for this testcase.

gcc produces code similar to clang and I have also filed a bug there:

<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61082">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61082</a>

There at least seems to be some disagreement as to the interpretation of the
x86-64 and/or Itanium ABIs.  I would like to get some clarity on this because
it's an interoperability issue.  Can someone point to wording in one or both of
the ABI documents that specifies clang's behavior here?  I have looked for a
good long while and haven't come up with anything.</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>