* builtins.c (can_trust_pointer_alignment): New fn.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Jul 2009 18:15:22 +0000 (18:15 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Jul 2009 18:15:22 +0000 (18:15 +0000)
(get_pointer_alignment): Factor it out from here.
* tree.h: Declare it.
* cp/call.c (build_over_call): Use it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149635 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/tree.h

index 306ddc4..a57eb8a 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-13  Jason Merrill  <jason@redhat.com>
+
+       * builtins.c (can_trust_pointer_alignment): New fn.
+       (get_pointer_alignment): Factor it out from here.
+       * tree.h: Declare it.
+
 2009-07-14  David Edelsohn  <edelsohn@gnu.org>
 
        * config/rs6000/predicates.md (offsettable_mem_operand): Test
index de1984e..a5f41fc 100644 (file)
@@ -344,6 +344,16 @@ get_object_alignment (tree exp, unsigned int align, unsigned int max_align)
   return MIN (align, max_align);
 }
 
+/* Returns true iff we can trust that alignment information has been
+   calculated properly.  */
+
+bool
+can_trust_pointer_alignment (void)
+{
+  /* We rely on TER to compute accurate alignment information.  */
+  return (optimize && flag_tree_ter);
+}
+
 /* Return the alignment in bits of EXP, a pointer valued expression.
    But don't return more than MAX_ALIGN no matter what.
    The alignment returned is, by default, the alignment of the thing that
@@ -357,8 +367,7 @@ get_pointer_alignment (tree exp, unsigned int max_align)
 {
   unsigned int align, inner;
 
-  /* We rely on TER to compute accurate alignment information.  */
-  if (!(optimize && flag_tree_ter))
+  if (!can_trust_pointer_alignment ())
     return 0;
 
   if (!POINTER_TYPE_P (TREE_TYPE (exp)))
index db1bc36..8123494 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-13  Jason Merrill  <jason@redhat.com>
+
+       * call.c (build_over_call): Use can_trust_pointer_alignment.
+
 2009-07-14  Dodji Seketeli  <dodji@redhat.com>
 
        PR debug/40705
index 5edeb3a..588c997 100644 (file)
@@ -5669,11 +5669,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
          arg1 = arg;
          arg0 = cp_build_unary_op (ADDR_EXPR, to, 0, complain);
 
-         if (!(optimize && flag_tree_ter))
+         if (!can_trust_pointer_alignment ())
            {
-             /* When TER is off get_pointer_alignment returns 0, so a call
+             /* If we can't be sure about pointer alignment, a call
                 to __builtin_memcpy is expanded as a call to memcpy, which
-                is invalid with identical args.  When TER is on it is
+                is invalid with identical args.  Otherwise it is
                 expanded as a block move, which should be safe.  */
              arg0 = save_expr (arg0);
              arg1 = save_expr (arg1);
index 2f2a65a..809c6e6 100644 (file)
@@ -4797,6 +4797,7 @@ extern tree build_va_arg_indirect_ref (tree);
 extern tree build_string_literal (int, const char *);
 extern bool validate_arglist (const_tree, ...);
 extern rtx builtin_memset_read_str (void *, HOST_WIDE_INT, enum machine_mode);
+extern bool can_trust_pointer_alignment (void);
 extern int get_pointer_alignment (tree, unsigned int);
 extern bool is_builtin_name (const char*);
 extern int get_object_alignment (tree, unsigned int, unsigned int);