This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types
- 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: Wed, 19 Oct 2016 12:57:51 +0200
- Subject: Re: [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types
- 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> <87shsi7sl3.fsf@hertz.schwinge.homeip.net> <87mvi30xwr.fsf@hertz.schwinge.homeip.net>
Hi!
On Mon, 17 Oct 2016 17:59:16 +0200, I wrote:
> On Thu, 29 Sep 2016 15:18:00 +0200, 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)
> > > >> > + {
> > > >> > + /* Assert that complex types' component types have already been handled
> > > >> > + (and we thus don't need to recurse here). See PR lto/77458. */
> > > >> > +[...]
> >
> > > >> So I very much like to go forward with this kind of change as well
> >
> > > > [patch]
> >
> > > Ok with [changes]
> >
> > Like this? (I'll then continue to replicate this for other tree codes.)
> --- gcc/tree-streamer.c
> +++ gcc/tree-streamer.c
> +/* Verify that NODE is in CACHE. */
> +
> +static void
> +verify_common_node_recorded (struct streamer_tree_cache_d *cache, tree node)
> +{
> + /* Restrict this to flag_checking only because in general violating it is
> + harmless plus we never know what happens on all targets/frontend/flag(!)
> + combinations. */
> + if (!flag_checking)
> + return;
> +
> + bool found = false;
> + if (cache->node_map)
> + gcc_assert (streamer_tree_cache_lookup (cache, node, NULL));
> + else
> + {
> + gcc_assert (cache->nodes.exists ());
> + /* Linear search... */
> + for (unsigned i = 0; !found && i < cache->nodes.length (); ++i)
> + if (cache->nodes[i] == node)
> + found = true;
> + gcc_assert (found);
> + }
> +}
With the "bool found" definition moved into the else branch, committed to
trunk in r241338:
commit 2ba42fa30f9ea5bb8ade209d7ff40229fd574856
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed Oct 19 10:48:46 2016 +0000
[PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types
gcc/
PR lto/77458
* tree-core.h (enum tree_index): Put the complex types after their
component types.
* tree-streamer.c (verify_common_node_recorded): New function.
(preload_common_nodes) <TREE_CODE (node) == COMPLEX_TYPE>: Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241338 138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog | 8 ++++++++
gcc/tree-core.h | 31 +++++++++++++++++--------------
gcc/tree-streamer.c | 32 +++++++++++++++++++++++++++++++-
3 files changed, 56 insertions(+), 15 deletions(-)
diff --git gcc/ChangeLog gcc/ChangeLog
index 59b00d16..b50e2e4 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-10-19 Thomas Schwinge <thomas@codesourcery.com>
+
+ PR lto/77458
+ * tree-core.h (enum tree_index): Put the complex types after their
+ component types.
+ * tree-streamer.c (verify_common_node_recorded): New function.
+ (preload_common_nodes) <TREE_CODE (node) == COMPLEX_TYPE>: Use it.
+
2016-10-19 Martin Liska <mliska@suse.cz>
* cgraph.h (cgraph_edge::binds_to_current_def_p):
diff --git gcc/tree-core.h gcc/tree-core.h
index 1bfe682..3e3f31e 100644
--- gcc/tree-core.h
+++ gcc/tree-core.h
@@ -556,20 +556,6 @@ enum tree_index {
TI_BOOLEAN_FALSE,
TI_BOOLEAN_TRUE,
- TI_COMPLEX_INTEGER_TYPE,
- TI_COMPLEX_FLOAT_TYPE,
- TI_COMPLEX_DOUBLE_TYPE,
- TI_COMPLEX_LONG_DOUBLE_TYPE,
-
- TI_COMPLEX_FLOAT16_TYPE,
- TI_COMPLEX_FLOATN_NX_TYPE_FIRST = TI_COMPLEX_FLOAT16_TYPE,
- TI_COMPLEX_FLOAT32_TYPE,
- TI_COMPLEX_FLOAT64_TYPE,
- TI_COMPLEX_FLOAT128_TYPE,
- TI_COMPLEX_FLOAT32X_TYPE,
- TI_COMPLEX_FLOAT64X_TYPE,
- TI_COMPLEX_FLOAT128X_TYPE,
-
TI_FLOAT_TYPE,
TI_DOUBLE_TYPE,
TI_LONG_DOUBLE_TYPE,
@@ -599,6 +585,23 @@ enum tree_index {
- TI_FLOATN_NX_TYPE_FIRST \
+ 1)
+ /* Put the complex types after their component types, so that in (sequential)
+ tree streaming we can assert that their component types have already been
+ handled (see tree-streamer.c:record_common_node). */
+ TI_COMPLEX_INTEGER_TYPE,
+ TI_COMPLEX_FLOAT_TYPE,
+ TI_COMPLEX_DOUBLE_TYPE,
+ TI_COMPLEX_LONG_DOUBLE_TYPE,
+
+ TI_COMPLEX_FLOAT16_TYPE,
+ TI_COMPLEX_FLOATN_NX_TYPE_FIRST = TI_COMPLEX_FLOAT16_TYPE,
+ TI_COMPLEX_FLOAT32_TYPE,
+ TI_COMPLEX_FLOAT64_TYPE,
+ TI_COMPLEX_FLOAT128_TYPE,
+ TI_COMPLEX_FLOAT32X_TYPE,
+ TI_COMPLEX_FLOAT64X_TYPE,
+ TI_COMPLEX_FLOAT128X_TYPE,
+
TI_FLOAT_PTR_TYPE,
TI_DOUBLE_PTR_TYPE,
TI_LONG_DOUBLE_PTR_TYPE,
diff --git gcc/tree-streamer.c gcc/tree-streamer.c
index 2139e96..70054b1 100644
--- gcc/tree-streamer.c
+++ gcc/tree-streamer.c
@@ -248,6 +248,32 @@ streamer_tree_cache_lookup (struct streamer_tree_cache_d *cache, tree t,
}
+/* Verify that NODE is in CACHE. */
+
+static void
+verify_common_node_recorded (struct streamer_tree_cache_d *cache, tree node)
+{
+ /* Restrict this to flag_checking only because in general violating it is
+ harmless plus we never know what happens on all targets/frontend/flag(!)
+ combinations. */
+ if (!flag_checking)
+ return;
+
+ if (cache->node_map)
+ gcc_assert (streamer_tree_cache_lookup (cache, node, NULL));
+ else
+ {
+ bool found = false;
+ gcc_assert (cache->nodes.exists ());
+ /* Linear search... */
+ for (unsigned i = 0; !found && i < cache->nodes.length (); ++i)
+ if (cache->nodes[i] == node)
+ found = true;
+ gcc_assert (found);
+ }
+}
+
+
/* Record NODE in CACHE. */
static void
@@ -293,11 +319,15 @@ record_common_node (struct streamer_tree_cache_d *cache, tree node)
/* 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 COMPLEX_TYPE:
+ /* Verify that a complex type's component type (node_type) has been
+ handled already (and we thus don't need to recurse here). */
+ verify_common_node_recorded (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.
Grüße
Thomas