Commit b35c8160 by Jason Merrill Committed by Jason Merrill

builtins.c (can_trust_pointer_alignment): New fn.

	* builtins.c (can_trust_pointer_alignment): New fn.
	(get_pointer_alignment): Factor it out from here.
	* tree.h: Declare it.
	* cp/call.c (build_over_call): Use it.

From-SVN: r149635
parent e02e8e58
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
......
......@@ -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)))
......
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
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment