On Sun, 11 Mar 2012 17:48:53 -0500, Timon Gehr <timon.g...@gmx.ch> wrote:

On 03/11/2012 10:57 PM, Robert Jacques wrote:
On Sun, 11 Mar 2012 15:38:21 -0500, Timon Gehr <timon.g...@gmx.ch> wrote:

On 03/11/2012 09:30 PM, Robert Jacques wrote:
Manu, why are you assuming that the struct is returned in any sort of
fixed memory layout?

Because that is what the ABI says.

* 1, 2 and 4 byte structs are returned in EAX.
* 8 byte structs are returned in EDX,EAX, where EDX gets the most
significant half.
* For other struct sizes, the return value is stored through a hidden
pointer passed as an argument to the function.

You made my point. Manu is arguing that structs small enough to be worth
passing in registers must maintain some sort of fixed memory layout;

They do.

i.e. they can't broken up across a desperate set of registers.


That was not his point. If you have:

struct S{
     float a;
     float b;
}

S foo();

Then EDX and EAX contain float data upon function return. That is not
something you want.

That's an argument for using the right register for the job. And we can / will 
be doing this on x86-64, as other compilers have already done. Manu was arguing 
that MRV were somehow special and had mystical optimization potential. That's 
simply not true.

Reply via email to