Commit e88ebf86 by Alexandre Oliva Committed by Alexandre Oliva

re PR libmudflap/53952 (FAIL: libmudflap.c++/pass55-frag.cxx ( -O[123]) execution test)

PR libmudflap/53952
* expr.c (mem_ref_refers_to_non_mem_p): Factor out
implementation into...
(addr_expr_of_non_mem_decl_p_1): ... this new function.
(addr_expr_of_non_mem_decl_p): New.
* tree.h (addr_expr_of_non_mem_decl_p): Declare.
* tree-mudflap.c (mf_xform_derefs_1): Don't change MEM_REFs
and TARGET_MEM_REFs that have an ADDR_EXPR of a non-mem DECL
as base operand.

From-SVN: r194519
parent 5a6fe810
2012-12-15 Alexandre Oliva <aoliva@redhat.com>
PR libmudflap/53952
* expr.c (mem_ref_refers_to_non_mem_p): Factor out
implementation into...
(addr_expr_of_non_mem_decl_p_1): ... this new function.
(addr_expr_of_non_mem_decl_p): New.
* tree.h (addr_expr_of_non_mem_decl_p): Declare.
* tree-mudflap.c (mf_xform_derefs_1): Don't change MEM_REFs
and TARGET_MEM_REFs that have an ADDR_EXPR of a non-mem DECL
as base operand.
2012-12-14 Yvan Roux <yvan.roux@linaro.org> 2012-12-14 Yvan Roux <yvan.roux@linaro.org>
* optabs.c (expand_atomic_store): Elide redundant model test. * optabs.c (expand_atomic_store): Elide redundant model test.
...@@ -4557,21 +4557,48 @@ get_bit_range (unsigned HOST_WIDE_INT *bitstart, ...@@ -4557,21 +4557,48 @@ get_bit_range (unsigned HOST_WIDE_INT *bitstart,
*bitend = *bitstart + tree_low_cst (DECL_SIZE (repr), 1) - 1; *bitend = *bitstart + tree_low_cst (DECL_SIZE (repr), 1) - 1;
} }
/* Returns true if ADDR is an ADDR_EXPR of a DECL that does not reside
in memory and has non-BLKmode. DECL_RTL must not be a MEM; if
DECL_RTL was not set yet, return NORTL. */
static inline bool
addr_expr_of_non_mem_decl_p_1 (tree addr, bool nortl)
{
if (TREE_CODE (addr) != ADDR_EXPR)
return false;
tree base = TREE_OPERAND (addr, 0);
if (!DECL_P (base)
|| TREE_ADDRESSABLE (base)
|| DECL_MODE (base) == BLKmode)
return false;
if (!DECL_RTL_SET_P (base))
return nortl;
return (!MEM_P (DECL_RTL (base)));
}
/* Returns true if the MEM_REF REF refers to an object that does not /* Returns true if the MEM_REF REF refers to an object that does not
reside in memory and has non-BLKmode. */ reside in memory and has non-BLKmode. */
static bool static inline bool
mem_ref_refers_to_non_mem_p (tree ref) mem_ref_refers_to_non_mem_p (tree ref)
{ {
tree base = TREE_OPERAND (ref, 0); tree base = TREE_OPERAND (ref, 0);
if (TREE_CODE (base) != ADDR_EXPR) return addr_expr_of_non_mem_decl_p_1 (base, false);
return false; }
base = TREE_OPERAND (base, 0);
return (DECL_P (base) /* Return TRUE iff OP is an ADDR_EXPR of a DECL that's not
&& !TREE_ADDRESSABLE (base) addressable. This is very much like mem_ref_refers_to_non_mem_p,
&& DECL_MODE (base) != BLKmode but instead of the MEM_REF, it takes its base, and it doesn't
&& DECL_RTL_SET_P (base) assume a DECL is in memory just because its RTL is not set yet. */
&& !MEM_P (DECL_RTL (base)));
bool
addr_expr_of_non_mem_decl_p (tree op)
{
return addr_expr_of_non_mem_decl_p_1 (op, true);
} }
/* Expand an assignment that stores the value of FROM into TO. If NONTEMPORAL /* Expand an assignment that stores the value of FROM into TO. If NONTEMPORAL
......
...@@ -877,6 +877,9 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, ...@@ -877,6 +877,9 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp,
break; break;
case MEM_REF: case MEM_REF:
if (addr_expr_of_non_mem_decl_p (TREE_OPERAND (t, 0)))
return;
addr = fold_build_pointer_plus_loc (location, TREE_OPERAND (t, 0), addr = fold_build_pointer_plus_loc (location, TREE_OPERAND (t, 0),
TREE_OPERAND (t, 1)); TREE_OPERAND (t, 1));
base = addr; base = addr;
...@@ -886,6 +889,9 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, ...@@ -886,6 +889,9 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp,
break; break;
case TARGET_MEM_REF: case TARGET_MEM_REF:
if (addr_expr_of_non_mem_decl_p (TMR_BASE (t)))
return;
addr = tree_mem_ref_addr (ptr_type_node, t); addr = tree_mem_ref_addr (ptr_type_node, t);
base = addr; base = addr;
limit = fold_build_pointer_plus_hwi_loc (location, limit = fold_build_pointer_plus_hwi_loc (location,
......
...@@ -6304,6 +6304,9 @@ extern unsigned HOST_WIDE_INT compute_builtin_object_size (tree, int); ...@@ -6304,6 +6304,9 @@ extern unsigned HOST_WIDE_INT compute_builtin_object_size (tree, int);
succeed. */ succeed. */
extern int can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int); extern int can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int);
/* Is it an ADDR_EXPR of a DECL that's not in memory? */
extern bool addr_expr_of_non_mem_decl_p (tree);
extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree); extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);
extern tree build_personality_function (const char *); extern tree build_personality_function (const char *);
......
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