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  <ja...@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 <rguent...@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer

Reply via email to