On Sun, 11 Mar 2012 18:15:31 -0500, Timon Gehr <timon.g...@gmx.ch> wrote:

On 03/11/2012 11:58 PM, Robert Jacques wrote:
Manu was arguing that MRV were somehow special and had mystical
optimization potential. That's simply not true.

Not exactly mystical, but it is certainly there.

void main(){
     auto a = foo(); // MRV/struct return
     bar(&a.x); // defined in a different compilation unit
}

struct return has to write out the whole struct on the stack because of
layout guarantees, probably making the optimized struct return calling
convention somewhat slower for this case. The same does not hold for MRV.

The layout of the struct only has to exist _when_ the address is taken. Before 
that, the compiler/language/optimizer is free to (and does) do whatever it 
want. Besides, in your example only the address of a field is taken, the 
compiler will optimize away all the other pieces a (dead variable elimination).

Reply via email to