<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 - GCC does a better job with returning large structs"
   href="https://bugs.llvm.org/show_bug.cgi?id=35134">35134</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>GCC does a better job with returning large structs
          </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>All
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jmuizelaar@mozilla.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>struct Foo {
   int o[200];
};

struct Bar {
        char p;
        Foo f;
};

__attribute__((noinline))
Foo moo()
{
        return {0};
}

void goo(Bar *f)
{
        f->f = moo();
}

with  -O3 -fno-exceptions -fomit-frame-pointer gives:

moo(): # @moo()
  push rbx
  mov rbx, rdi
  xor esi, esi
  mov edx, 800
  call memset
  mov rax, rbx
  pop rbx
  ret
goo(Bar*): # @goo(Bar*)
  push r14
  push rbx
  sub rsp, 808
  mov rbx, rdi
  lea r14, [rsp + 8]
  mov rdi, r14
  call moo()
  add rbx, 4
  mov edx, 800
  mov rdi, rbx
  mov rsi, r14
  call memcpy
  add rsp, 808
  pop rbx
  pop r14
  ret

in clang vs gcc's:

moo():
  mov rdx, rdi
  mov QWORD PTR [rdi], 0
  mov QWORD PTR [rdi+792], 0
  lea rdi, [rdi+8]
  mov rcx, rdx
  xor eax, eax
  and rdi, -8
  sub rcx, rdi
  add ecx, 800
  shr ecx, 3
  rep stosq
  mov rax, rdx
  ret
goo(Bar*):
  add rdi, 4
  call moo()
  rep ret

Notice the elided memcpy in goo()</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>