[LLVMbugs] [Bug 19801] New: Larger temporaries not optimized away when passing by value

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 20 01:08:38 PDT 2014


            Bug ID: 19801
           Summary: Larger temporaries not optimized away when passing by
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan.sauer at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12543
  --> http://llvm.org/bugs/attachment.cgi?id=12543&action=edit
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.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140520/417eabf6/attachment.html>

More information about the llvm-bugs mailing list