[LLVMdev] Deduplication of memory allocation

François Fayard fayard.francois at icloud.com
Fri May 1 09:01:52 PDT 2015


Of course, the allocation only occurs only once in every loop in the first example, inside the f function. We have 2 copy elision happening: one when the function returns and one when w is copy constructed. But we still have one memory allocation inside f.

With reference semantics, we don’t have a single memory allocation in the i-loop.

> On 01 May 2015, at 17:48, Daniel Berlin <dberlin at dberlin.org> wrote:
> Why?
> Look up "Return value optimization".
> :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150501/a3586fa3/attachment.html>


More information about the llvm-dev mailing list