https://bugs.llvm.org/show_bug.cgi?id=39048
Reid Kleckner <r...@google.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |r...@google.com
Resolution|--- |INVALID
Status|NEW |RESOLVED
--- Comment #1 from Reid Kleckner <r...@google.com> ---
The optimization applies to C in cases like this:
struct BigStruct { long x, y, z, w; };
struct BigStruct foo(int a) {
struct BigStruct rv = {};
return rv;
}
You can see the LLVM IR difference by adding and removing the flag more clearly
on godbolt: https://gcc.godbolt.org/z/TuzhSJ
In this case, the optimization will avoid allocating memory for rv in foo, and
will use the out parameter allocated in the caller's stack frame.
It is by design that we do this by default in C as well as C++. It has nothing
to do with constructors, really. My understanding of the history is that Clang
implemented NRVO by default, and then someone came along and added the
non-default -fno-elide-constructors option for code bases that needed it.
Marking "invalid" to mean "working as intended".
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs