Patchwork [C++] Remove last use of can_trust_pointer_alignment

login
register
mail settings
Submitter Richard Guenther
Date Aug. 10, 2011, 3:43 p.m.
Message ID <alpine.LNX.2.00.1108101743360.810@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/109390/
State New
Headers show

Comments

Richard Guenther - Aug. 10, 2011, 3:43 p.m.
On Wed, 10 Aug 2011, Richard Guenther wrote:

> On Wed, 10 Aug 2011, Jason Merrill wrote:
> 
> > On 08/10/2011 08:35 AM, Richard Guenther wrote:
> > > 	* call.c (build_over_call): Call memcpy unconditionally.
> > 
> > OK.  Have you tested the MEM_REF patch?
> 
> No, not yet.  I'll throw it to testing now.

The following is what passed bootstrap sofar and is in testing now.

Richard.

Patch

Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c	(revision 177625)
+++ gcc/cp/call.c	(working copy)
@@ -6766,19 +6766,22 @@  build_over_call (struct z_candidate *can
 	}
       else
 	{
-	  /* We must only copy the non-tail padding parts.
-	     Use __builtin_memcpy for the bitwise copy.  */
-	  tree arg0, arg1, arg2, t;
+	  /* We must only copy the non-tail padding parts.  */
+	  tree arg0, arg2, t;
+	  tree array_type, alias_set;
 
 	  arg2 = TYPE_SIZE_UNIT (as_base);
-	  arg1 = arg;
 	  arg0 = cp_build_addr_expr (to, complain);
 
-	  t = implicit_built_in_decls[BUILT_IN_MEMCPY];
-	  t = build_call_n (t, 3, arg0, arg1, arg2);
-
-	  t = convert (TREE_TYPE (arg0), t);
-	  val = cp_build_indirect_ref (t, RO_NULL, complain);
+	  array_type = build_array_type (char_type_node,
+					 build_index_type
+					   (size_binop (MINUS_EXPR,
+							arg2, size_int (1))));
+	  alias_set = build_int_cst (build_pointer_type (type), 0);
+	  t = build2 (MODIFY_EXPR, void_type_node,
+		      build2 (MEM_REF, array_type, arg0, alias_set),
+		      build2 (MEM_REF, array_type, arg, alias_set));
+	  val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to);
           TREE_NO_WARNING (val) = 1;
 	}