From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: "Joseph S. Myers" <joseph@codesourcery.com>
Subject: [PATCH 2/2] middle-end/112830 - avoid gimplifying non-default addr-space assign to memcpy
Date: Mon, 4 Dec 2023 10:35:38 +0100 (CET) [thread overview]
Message-ID: <20231204093538.661DF13588@imap2.dmz-prg2.suse.org> (raw)
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
reply other threads:[~2023-12-04 9:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231204093538.661DF13588@imap2.dmz-prg2.suse.org \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).