On 9/17/14, 3:03 AM, IgorStepanov wrote:
BTW. About r-values:

void fun(S s)
{
     fun2(s); //pass s by value.
}

Now, compiler inserts postblit call before func2 call and dtor before
end of fun.

Is the call to dtor part of fun(), or part of fun()'s call sequence? I've always meant to look at that. LMK if you know for sure.

However, it is able to doesn't it, because after fun2 call,
s isn't used.
Thus, we can implement last postblit optimization:
If compiler want to insert postblit, and object is't used after this
postblit, compiler is able to doesn't generate postblit and last dtor
calls.
Is there limitation of this optimization?
It may 90 percent to solve a r-value ref task.

I think rvalues are already not postblitted into functions. Indeed more postblits can be optimized away for variables are are last used in a function call.


Andrei

Reply via email to