This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR target/18916; Function arg passing mem align fixes.


On Wed, Jan 05, 2005 at 02:05:42AM -0800, Richard Henderson wrote:
> I think this fixes nothing.  Or not much.

I didn't consider taking the address of these wretched misaligned
params.  :-(  Still, the patch has some merit in that at least you
now can use misaligned params in their functions, whereas previously
you were liable to get a segfault.

>  The parameter is still misaligned
> for its type, which means that the following should continue to fail:
> 
> 	typedef struct { _Complex long double a; } Scld1;
> 	static Scld1 g1sScld1 = { 1 }, g1sScld2;
> 
> 	void __attribute__((noinline)) copy(Scld1 *p)
> 	{
> 	  g1sScld2 = *p;
> 	}
> 
> 	void __attribute__((noinline)) test(int n, Scld1 t)
> 	{   
> 	  copy (&t);
> 	}
> 
> 	int main ()
> 	{
> 	  test (1, g1sScld1);
> 	  if (g1sScld1.a != g1sScld2.a)
> 	    abort ();
> 	  return 0;
> 	}
> 

Yes, I guess this will still fail.  It's not much different from
creating a misaligned structure pointer some other way, though.  So you
might be able to argue that this failure is expected.  'Twould be better
of course to have "test" copy "t" to an aligned temp.

> The way Sparc fixes the misaligned double problem in varargs is to
> allocate a local stack temporary and copy the pieces into it.  You
> could (now) also use a MISALIGNED_INDIRECT_REF.
> 
> For the above case, you'd also need to add something to
> assign_parm_setup_block and assign_parm_setup_stack to allocate new
> local stack storage in the case of misaligned input.
> 
> That is, unless you don't wanna call the abi broken and fix it...

I've been discussing that with David for powerpc64-linux.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]