[2/2] middle-end/112830 - avoid gimplifying non-default addr-space assign to memcpy
Checks
Commit Message
The following avoids turning aggregate copy or initialization involving
non-default address-spaces to memcpy or memset since they are not
prepared for that.
GIMPLE verification no longer(?) accepts WITH_SIZE_EXPR in aggregate
copies, the following re-allows that.
Sofar untested, will test on x86_64-unknown-linux-gnu. This is
the variant I prefer.
Richard.
PR middle-end/112830
* gimplify.cc (gimplify_modify_expr): Avoid turning aggregate
copy or initialization non-default address-spaces to memcpy or
memset.
* tree-cfg.cc (verify_gimple_assign_single): Allow
WITH_SIZE_EXPR as part of the RHS of an assignment.
---
gcc/gimplify.cc | 11 +++++++----
gcc/tree-cfg.cc | 16 ++++++++++------
2 files changed, 17 insertions(+), 10 deletions(-)
@@ -6331,7 +6331,8 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
&& TYPE_SIZE_UNIT (TREE_TYPE (*from_p))
&& !poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (*from_p)))
&& TREE_CODE (*from_p) == CONSTRUCTOR
- && CONSTRUCTOR_NELTS (*from_p) == 0)
+ && CONSTRUCTOR_NELTS (*from_p) == 0
+ && ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (*to_p))))
{
maybe_with_size_expr (from_p);
gcc_assert (TREE_CODE (*from_p) == WITH_SIZE_EXPR);
@@ -6464,10 +6465,12 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
tree from = TREE_OPERAND (*from_p, 0);
tree size = TREE_OPERAND (*from_p, 1);
- if (TREE_CODE (from) == CONSTRUCTOR)
+ if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (*to_p)))
+ || !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (from))))
+ ;
+ else if (TREE_CODE (from) == CONSTRUCTOR)
return gimplify_modify_expr_to_memset (expr_p, size, want_value, pre_p);
-
- if (is_gimple_addressable (from))
+ else if (is_gimple_addressable (from))
{
*from_p = from;
return gimplify_modify_expr_to_memcpy (expr_p, size, want_value,
@@ -4673,6 +4673,16 @@ verify_gimple_assign_single (gassign *stmt)
error ("%qs in gimple IL", code_name);
return true;
+ case WITH_SIZE_EXPR:
+ if (!is_gimple_val (TREE_OPERAND (rhs1, 1)))
+ {
+ error ("invalid WITH_SIZE_EXPR size argument in load");
+ debug_generic_stmt (lhs);
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ rhs1 = TREE_OPERAND (rhs1, 0);
+ /* Fallthru. */
case COMPONENT_REF:
case BIT_FIELD_REF:
case ARRAY_REF:
@@ -4810,12 +4820,6 @@ verify_gimple_assign_single (gassign *stmt)
}
return res;
- case WITH_SIZE_EXPR:
- error ("%qs RHS in assignment statement",
- get_tree_code_name (rhs_code));
- debug_generic_expr (rhs1);
- return true;
-
case OBJ_TYPE_REF:
/* FIXME. */
return res;