This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Use TYPE_NEXT_VARIANT instead of TREE_CHAIN as chain_next for types during GC (PR c++/46400)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jason Merrill <jason at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Jun 2011 18:42:41 +0200
- Subject: Re: [PATCH] Use TYPE_NEXT_VARIANT instead of TREE_CHAIN as chain_next for types during GC (PR c++/46400)
- References: <20110624144358.GX16443@tyan-ft48-01.lab.bos.redhat.com> <4E050DD3.3060201@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jun 24, 2011 at 03:21:07PM -0700, Richard Henderson wrote:
> On 06/24/2011 07:43 AM, Jakub Jelinek wrote:
> > + chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_TYPE_COMMON) ? ((union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic)) : CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node {
>
> Is it possible to break this out into an inline (or, i suppose, out of line)
> function? This is getting fairly unreadable...
Like this? Bootstrapped/regtested on x86_64-linux and i686-linux.
2011-06-27 Jakub Jelinek <jakub@redhat.com>
* c-common.h (c_tree_chain_next): New static inline function.
* c-decl.c (union lang_tree_node): Use it in chain_next expression.
* cp-tree.h (union lang_tree_node): Use it in chain_next expression.
--- gcc/c-family/c-common.h.jj 2011-05-31 08:02:51.000000000 +0200
+++ gcc/c-family/c-common.h 2011-06-27 15:58:21.000000000 +0200
@@ -1016,4 +1016,19 @@ extern bool c_omp_sharing_predetermined
extern tree c_omp_remap_decl (tree, bool);
extern void record_types_used_by_current_var_decl (tree);
+/* Return next tree in the chain for chain_next walking of tree nodes. */
+static inline tree
+c_tree_chain_next (tree t)
+{
+ /* TREE_CHAIN of a type is TYPE_STUB_DECL, which is different
+ kind of object, never a long chain of nodes. Prefer
+ TYPE_NEXT_VARIANT for types. */
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPE_COMMON))
+ return TYPE_NEXT_VARIANT (t);
+ /* Otherwise, if there is TREE_CHAIN, return it. */
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_COMMON))
+ return TREE_CHAIN (t);
+ return NULL;
+}
+
#endif /* ! GCC_C_COMMON_H */
--- gcc/c-decl.c.jj 2011-06-26 09:55:31.000000000 +0200
+++ gcc/c-decl.c 2011-06-27 16:00:18.000000000 +0200
@@ -238,7 +238,7 @@ extern char C_SIZEOF_STRUCT_LANG_IDENTIF
/* The resulting tree type. */
union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
- chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_TYPE_COMMON) ? (union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic) : CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node
+ chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node
{
union tree_node GTY ((tag ("0"),
desc ("tree_node_structure (&%h)")))
--- gcc/cp/cp-tree.h.jj 2011-06-26 09:55:24.000000000 +0200
+++ gcc/cp/cp-tree.h 2011-06-27 16:01:09.000000000 +0200
@@ -729,7 +729,7 @@ enum cp_tree_node_structure_enum {
/* The resulting tree type. */
union GTY((desc ("cp_tree_node_structure (&%h)"),
- chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_TYPE_COMMON) ? ((union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic)) : CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) lang_tree_node {
+ chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node {
union tree_node GTY ((tag ("TS_CP_GENERIC"),
desc ("tree_node_structure (&%h)"))) generic;
struct template_parm_index_s GTY ((tag ("TS_CP_TPI"))) tpi;
Jakub