[PATCH] Fix small structure passing on x86-64

Jan Hubicka hubicka@ucw.cz
Tue Nov 11 18:41:00 GMT 2008


> > the test here is still bit confused.  It should test if the whole array
> > fits in lower 4 bytes that would be somehting like
> > (bit_offset + 7) / 8 + bytes <= 4
> 
> The change was the minimal one and this was done on purpose.  It's clear that 
> forcing a full word for 3 bytes is a little surprising, but that's what the 
> pre-existing code was doing.

Yes, I understand it. In fact I was just about to write mail that patch
is OK for stage3 and at stage1 we can make the test more tight, but
surprisingly we get many cases wrong:
struct S { char c; char arr[3];  } s;
will result in 8 byte read from s that might segfault.
struct S { char c; char arr[3]; double foo;  } s;
will get 64bit move for lower half that is suboptimal
struct S { char arr[3]; } s;
needs to be generated using two moves since missaligned 32bit move will
read past end of buffer.

those are all generated by generic code...
> 
> > There are very intersting problems related to this and reading past end
> > of the structure possibly causing segfault.  I am working on more
> > complette patch.
> 
> Thanks.  The patch has already been applied on the mainline though.

I noticed that, it is not problem, since it is incremental improvement
anyway :)

Honza
> 
> -- 
> Eric Botcazou



More information about the Gcc-patches mailing list