<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 --- - Larger temporaries not optimized away when passing by value"
   href="http://llvm.org/bugs/show_bug.cgi?id=19801">19801</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Larger temporaries not optimized away when passing by value
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>jonathan.sauer@gmx.de
          </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=12543" name="attach_12543" title="Assembly code generated by clang">attachment 12543</a> <a href="attachment.cgi?id=12543&action=edit" title="Assembly code generated by clang">[details]</a></span>
Assembly code generated by clang

In the following program "foo" is called with three temporary instances of Foo.
However as can be seen from the attached assembly code, the temporaries are
first created on the stack and then copied to another stack position instead of
being created in the correct position right away.

struct Foo {
    Foo(int i) : type(23), sint(i) { }

    int type;
    int sint;
    const char* string;
    unsigned long length;
};

void foo(Foo, Foo, Foo);

int main()
{
    foo(1, 2, 3);
}

Compiled with:

% ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++11 -O3 -S -o - clang.cpp

Clang version is: r209002. Target: x86_64-apple-darwin13.1.0


When removing the (unused in this case) field length and thus reducing the size
of Foo the temporaries are not copied anymore.</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>