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]

[PATCH] Fix up aliasing violations in src/ia64/ffi.c (PR rtl-optimization/48496)


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?

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


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