This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node
- From: Thomas Schwinge <thomas at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, GCC Development <gcc at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>, Bernd Schmidt <bschmidt at redhat dot com>
- Date: Mon, 17 Oct 2016 17:57:27 +0200
- Subject: Re: Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.1606211202040.4526@digraph.polyomino.org.uk> <alpine.DEB.2.20.1606211738200.31330@digraph.polyomino.org.uk> <alpine.DEB.2.20.1606231418120.21240@digraph.polyomino.org.uk> <alpine.DEB.2.20.1606271720270.7438@digraph.polyomino.org.uk> <alpine.DEB.2.20.1607191347340.9265@digraph.polyomino.org.uk> <alpine.DEB.2.20.1607222158330.22448@digraph.polyomino.org.uk> <20160817154244.GA39270@arm.com> <alpine.DEB.2.20.1608171641000.7156@digraph.polyomino.org.uk> <alpine.DEB.2.20.1608172015080.27199@digraph.polyomino.org.uk> <CAFiYyc3xqcqJ1rK2X0rC+wwpx3akHbULVG1G47PRmtk4wTk=7A@mail.gmail.com> <alpine.DEB.2.20.1608191101110.30687@digraph.polyomino.org.uk> <87h99s53ls.fsf@kepler.schwinge.homeip.net> <CAFiYyc3X46eeodD3sTCXDsx1zbfmF_He2AL6CC6BuE6urh4SGw@mail.gmail.com> <87d1kefwgt.fsf@hertz.schwinge.homeip.net> <87twdgb9zi.fsf@hertz.schwinge.homeip.net> <CAFiYyc22Gg_=kdjuT8jKLcOyxhU8ugrxri15jTPTnunDC+4EUA@mail.gmail.com> <87poo4as2j.fsf@hertz.schwinge.homeip.net> <CAFiYyc0ik7JkzvnWMyztNm=8UPhivrj-aRffT0vCUCV1qxoaHQ@mail.gmail.com> <87bmzkb0h5.fsf@hertz.schwinge.homeip.net> <CAFiYyc3Arcmw4hzjUmT15CG7vsCbih49F3-LXvpfsNjuj4cDqQ@mail.gmail.com> <87lgya7odk.fsf@hertz.schwinge.homeip.net> <CAFiYyc0fqYEfAjJKRpECdznYZVfPsKdVq0Uq6czYBCKbH0u2=w@mail.gmail.com>
Hi!
On Fri, 30 Sep 2016 09:47:56 +0200, Richard Biener <richard.guenther@gmail.com> wrote:
> On Thu, Sep 29, 2016 at 4:48 PM, Thomas Schwinge
> <thomas@codesourcery.com> wrote:
> > On Mon, 19 Sep 2016 13:25:01 +0200, Richard Biener <richard.guenther@gmail.com> wrote:
> >> On Mon, Sep 19, 2016 at 1:19 PM, Thomas Schwinge
> >> <thomas@codesourcery.com> wrote:
> >> > On Mon, 19 Sep 2016 10:18:35 +0200, Richard Biener <richard.guenther@gmail.com> wrote:
> >> >> On Fri, Sep 16, 2016 at 3:32 PM, Thomas Schwinge
> >> >> <thomas@codesourcery.com> wrote:
> >> >> > --- gcc/tree-streamer.c
> >> >> > +++ gcc/tree-streamer.c
> >> >> > @@ -278,9 +278,23 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
> >> >> > streamer_tree_cache_append (cache, node, cache->nodes.length ());
> >> >> >
> >> >> > if (POINTER_TYPE_P (node)
> >> >> > - || TREE_CODE (node) == COMPLEX_TYPE
> >> >> > || TREE_CODE (node) == ARRAY_TYPE)
> >> >> > record_common_node (cache, TREE_TYPE (node));
> >> >> > + else if (TREE_CODE (node) == COMPLEX_TYPE)
> >> >> > [...]
> >> >> > else if (TREE_CODE (node) == RECORD_TYPE)
> >
> >> [looks to me we miss handling of vector type components alltogether,
> >> maybe there are no global vector type trees ...]
> >
> > Looks like it, yes. Would a patch like the following be reasonable,
> > which explicitly lists/handles all expected tree codes, or is something
> > like that not feasible? (That's a subset of tree codes I gathered by a
> > partial run of the GCC testsuite, and libgomp testsuite; not claiming
> > this is complete.)
>
> I think it would be a nice thing to have indeed.
>
> So -- I'm inclined to approve this patch ;)
After quite a bit of testing (contrib/config-list.mk, modified to run
-fself-test with -flto, to exercise the code I'm modifying), I have now
committed this to trunk in r241246:
commit 29cfc397b0ec2c953ff929d0ba57001c7018ec0c
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon Oct 17 15:56:22 2016 +0000
Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node
gcc/
* tree-streamer.c (record_common_node): Explicitly list expected
tree codes.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241246 138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog | 5 +++++
gcc/tree-streamer.c | 30 +++++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git gcc/ChangeLog gcc/ChangeLog
index 86df616..9acc738 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-17 Thomas Schwinge <thomas@codesourcery.com>
+
+ * tree-streamer.c (record_common_node): Explicitly list expected
+ tree codes.
+
2016-10-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/77988
diff --git gcc/tree-streamer.c gcc/tree-streamer.c
index 7ea7096..2139e96 100644
--- gcc/tree-streamer.c
+++ gcc/tree-streamer.c
@@ -277,12 +277,28 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
in the cache as hash value. */
streamer_tree_cache_append (cache, node, cache->nodes.length ());
- if (POINTER_TYPE_P (node)
- || TREE_CODE (node) == COMPLEX_TYPE
- || TREE_CODE (node) == ARRAY_TYPE)
- record_common_node (cache, TREE_TYPE (node));
- else if (TREE_CODE (node) == RECORD_TYPE)
+ switch (TREE_CODE (node))
{
+ case ERROR_MARK:
+ case FIELD_DECL:
+ case FIXED_POINT_TYPE:
+ case IDENTIFIER_NODE:
+ case INTEGER_CST:
+ case INTEGER_TYPE:
+ case POINTER_BOUNDS_TYPE:
+ case REAL_TYPE:
+ case TREE_LIST:
+ case VOID_CST:
+ case VOID_TYPE:
+ /* No recursive trees. */
+ break;
+ case ARRAY_TYPE:
+ case COMPLEX_TYPE:
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ record_common_node (cache, TREE_TYPE (node));
+ break;
+ case RECORD_TYPE:
/* The FIELD_DECLs of structures should be shared, so that every
COMPONENT_REF uses the same tree node when referencing a field.
Pointer equality between FIELD_DECLs is used by the alias
@@ -291,6 +307,10 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
nonoverlapping_component_refs_of_decl_p). */
for (tree f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
record_common_node (cache, f);
+ break;
+ default:
+ /* Unexpected tree code. */
+ gcc_unreachable ();
}
}
Grüße
Thomas