From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [COMMITTED] ada: Minor generic tweaks left and and right
Date: Tue, 30 May 2023 09:21:17 +0200 [thread overview]
Message-ID: <20230530072117.2500675-1-poulhies@adacore.com> (raw)
From: Eric Botcazou <ebotcazou@adacore.com>
No functional changes.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Replace
integer_zero_node with null_pointer_node for pointer types.
* gcc-interface/trans.cc (gnat_gimplify_expr) <NULL_EXPR>: Likewise.
* gcc-interface/utils.cc (maybe_pad_type): Do not attempt to make a
packable type from a fat pointer type.
* gcc-interface/utils2.cc (build_atomic_load): Use a local variable.
(build_atomic_store): Likewise.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gcc-interface/decl.cc | 2 +-
gcc/ada/gcc-interface/trans.cc | 2 +-
gcc/ada/gcc-interface/utils.cc | 1 +
gcc/ada/gcc-interface/utils2.cc | 21 +++++++++++----------
4 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 53a11243590..456fe53737d 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -1212,7 +1212,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
&& (POINTER_TYPE_P (gnu_type) || TYPE_IS_FAT_POINTER_P (gnu_type))
&& !gnu_expr
&& !Is_Imported (gnat_entity))
- gnu_expr = integer_zero_node;
+ gnu_expr = null_pointer_node;
/* If we are defining the object and it has an Address clause, we must
either get the address expression from the saved GCC tree for the
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 4e5f26305f5..8c8a78f5d2d 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -8987,7 +8987,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
|| TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE)
*expr_p = build_unary_op (INDIRECT_REF, NULL_TREE,
convert (build_pointer_type (type),
- integer_zero_node));
+ null_pointer_node));
/* Otherwise, just make a VAR_DECL. */
else
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 337b552619e..8f1861b848e 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -1562,6 +1562,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
at the RTL level when the stand-alone object is accessed as a whole. */
if (align > 0
&& RECORD_OR_UNION_TYPE_P (type)
+ && !TYPE_IS_FAT_POINTER_P (type)
&& TYPE_MODE (type) == BLKmode
&& !TYPE_BY_REFERENCE_P (type)
&& TREE_CODE (orig_size) == INTEGER_CST
diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
index c56fccb4a98..e1737724b65 100644
--- a/gcc/ada/gcc-interface/utils2.cc
+++ b/gcc/ada/gcc-interface/utils2.cc
@@ -692,13 +692,14 @@ build_atomic_load (tree src, bool sync)
= build_int_cst (integer_type_node,
sync ? MEMMODEL_SEQ_CST : MEMMODEL_RELAXED);
tree orig_src = src;
- tree t, addr, val;
+ tree type, t, addr, val;
unsigned int size;
int fncode;
/* Remove conversions to get the address of the underlying object. */
src = remove_conversions (src, false);
- size = resolve_atomic_size (TREE_TYPE (src));
+ type = TREE_TYPE (src);
+ size = resolve_atomic_size (type);
if (size == 0)
return orig_src;
@@ -710,7 +711,7 @@ build_atomic_load (tree src, bool sync)
/* First reinterpret the loaded bits in the original type of the load,
then convert to the expected result type. */
- t = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (src), val);
+ t = fold_build1 (VIEW_CONVERT_EXPR, type, val);
return convert (TREE_TYPE (orig_src), t);
}
@@ -728,13 +729,14 @@ build_atomic_store (tree dest, tree src, bool sync)
= build_int_cst (integer_type_node,
sync ? MEMMODEL_SEQ_CST : MEMMODEL_RELAXED);
tree orig_dest = dest;
- tree t, int_type, addr;
+ tree type, t, int_type, addr;
unsigned int size;
int fncode;
/* Remove conversions to get the address of the underlying object. */
dest = remove_conversions (dest, false);
- size = resolve_atomic_size (TREE_TYPE (dest));
+ type = TREE_TYPE (dest);
+ size = resolve_atomic_size (type);
if (size == 0)
return build_binary_op (MODIFY_EXPR, NULL_TREE, orig_dest, src);
@@ -746,12 +748,11 @@ build_atomic_store (tree dest, tree src, bool sync)
then reinterpret them in the effective type. But if the original type
is a padded type with the same size, convert to the inner type instead,
as we don't want to artificially introduce a CONSTRUCTOR here. */
- if (TYPE_IS_PADDING_P (TREE_TYPE (dest))
- && TYPE_SIZE (TREE_TYPE (dest))
- == TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (dest)))))
- src = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (dest))), src);
+ if (TYPE_IS_PADDING_P (type)
+ && TYPE_SIZE (type) == TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (type))))
+ src = convert (TREE_TYPE (TYPE_FIELDS (type)), src);
else
- src = convert (TREE_TYPE (dest), src);
+ src = convert (type, src);
src = fold_build1 (VIEW_CONVERT_EXPR, int_type, src);
addr = build_unary_op (ADDR_EXPR, ptr_type, dest);
--
2.40.0
reply other threads:[~2023-05-30 7:21 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=20230530072117.2500675-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/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).