* [PATCH 2/2] middle-end/112830 - avoid gimplifying non-default addr-space assign to memcpy
@ 2023-12-04 9:35 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-12-04 9:35 UTC (permalink / raw)
To: gcc-patches; +Cc: Joseph S. Myers
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(-)
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 02f85e7109b..a1d5ee28cbe 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -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,
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index a30a2de33a1..3917bee5a92 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -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;
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-04 9:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04 9:35 [PATCH 2/2] middle-end/112830 - avoid gimplifying non-default addr-space assign to memcpy Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).