diff options
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 13 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
5 files changed, 25 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 306ddc46c96..a57eb8a5e9e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/builtins.c b/gcc/builtins.c index de1984e5ab5..a5f41fc91f8 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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))) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index db1bc36cde0..812349486ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5edeb3a4cd8..588c997a34b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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); diff --git a/gcc/tree.h b/gcc/tree.h index 2f2a65aedee..809c6e68ab8 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -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); |