This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: [PATCH] Fix up aliasing violations in src/ia64/ffi.c (PR rtl-optimization/48496)
- From: Richard Guenther <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Steve Ellcey <sje at cup dot hp dot com>, libffi-discuss at sourceware dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 19 Jan 2012 10:37:08 +0100 (CET)
- Subject: Re: [PATCH] Fix up aliasing violations in src/ia64/ffi.c (PR rtl-optimization/48496)
- References: <20120119092028.GT18768@tyan-ft48-01.lab.bos.redhat.com>
On Thu, 19 Jan 2012, Jakub Jelinek wrote:
> Hi!
>
> For FFI_TYPE_FLOAT and FFI_TYPE_DOUBLE, I think src/ia64/ffi.c violates
> aliasing by accessing the same object through incompatible lvalues
> (in an asm operand through float resp. double lvalue and on the next
> line through UINT32 resp. UINT64 lvalue.
> GCC apparently errors out on this while reloading the asm, but only
> without -fno-strict-aliasing, which it shouldn't, nevertheless IMHO
> libffi shouldn't violate aliasing in the first place, which I'd say
> would demote that PR from P1 to P2.
> For FFI_TYPE_LONGDOUBLE we already do the right thing.
> Ok for trunk?
Ok.
Thanks,
Richard.
> 2012-01-19 Jakub Jelinek <jakub@redhat.com>
>
> PR rtl-optimization/48496
> * src/ia64/ffi.c (ffi_call): Fix up aliasing violations.
>
> --- libffi/src/ia64/ffi.c 2010-08-11 21:08:14.000000000 +0200
> +++ libffi/src/ia64/ffi.c 2012-01-14 18:43:35.652923850 +0100
> @@ -324,13 +324,17 @@ ffi_call(ffi_cif *cif, void (*fn)(void),
> case FFI_TYPE_FLOAT:
> if (gpcount < 8 && fpcount < 8)
> stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]);
> - stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i];
> + {
> + UINT32 tmp;
> + memcpy (&tmp, avalue[i], sizeof (UINT32));
> + stack->gp_regs[gpcount++] = tmp;
> + }
> break;
>
> case FFI_TYPE_DOUBLE:
> if (gpcount < 8 && fpcount < 8)
> stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]);
> - stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i];
> + memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64));
> break;
>
> case FFI_TYPE_LONGDOUBLE:
>
> Jakub
>
>
--
Richard Guenther <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer