Re: [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types

2016-09-29 Thread Thomas Schwinge
Hi Richard!

On Mon, 19 Sep 2016 13:25:01 +0200, Richard Biener  
wrote:
> On Mon, Sep 19, 2016 at 1:19 PM, Thomas Schwinge
>  wrote:
> > On Mon, 19 Sep 2016 10:18:35 +0200, Richard Biener 
> >  wrote:
> >> On Fri, Sep 16, 2016 at 3:32 PM, Thomas Schwinge
> >>  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.)

commit b304f88f7226d93c8e13584a916cc713a989a635
Author: Thomas Schwinge 
Date:   Wed Sep 28 12:36:59 2016 +0200

[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) : Use it.
---
 gcc/tree-core.h | 31 +--
 gcc/tree-streamer.c | 33 -
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git gcc/tree-core.h gcc/tree-core.h
index 353a625..35b67c9 100644
--- gcc/tree-core.h
+++ gcc/tree-core.h
@@ -553,20 +553,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,
@@ -596,6 +582,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 7ea7096..6ada89a 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;
+
+  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);
+}
+}
+
+
 /* Record NODE in CACHE.  */
 
 static void
@@ -278,9 +304,14 @@ 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)
+{
+  /* 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));
+}
   else if (TREE_CODE (node) == RECORD_TYPE)
 {
   /* The FIELD_DECLs of structures should be shared, so that every


Grüße
 Thomas


Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node (was: [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types)

2016-09-29 Thread Thomas Schwinge
Hi Richard!

On Mon, 19 Sep 2016 13:25:01 +0200, Richard Biener  
wrote:
> On Mon, Sep 19, 2016 at 1:19 PM, Thomas Schwinge
>  wrote:
> > On Mon, 19 Sep 2016 10:18:35 +0200, Richard Biener 
> >  wrote:
> >> On Fri, Sep 16, 2016 at 3:32 PM, Thomas Schwinge
> >>  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.)

commit f28dd9618be8a26c6a75ee089f1755e4e0281106
Author: Thomas Schwinge 
Date:   Thu Sep 29 16:35:19 2016 +0200

Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node
---
 gcc/tree-streamer.c | 32 +---
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git gcc/tree-streamer.c gcc/tree-streamer.c
index 6ada89a..8567a81 100644
--- gcc/tree-streamer.c
+++ gcc/tree-streamer.c
@@ -303,17 +303,32 @@ 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) == ARRAY_TYPE)
-record_common_node (cache, TREE_TYPE (node));
-  else if (TREE_CODE (node) == COMPLEX_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 recursion.  */
+  break;
+case POINTER_TYPE:
+case REFERENCE_TYPE:
+case ARRAY_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));
-}
-  else if (TREE_CODE (node) == RECORD_TYPE)
-{
+  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
@@ -322,6 +337,9 @@ 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:
+  gcc_unreachable ();
 }
 }
 


Grüße
 Thomas


Re: Calling convention for "Routines for floating point emulation"

2016-09-29 Thread Joseph Myers
On Thu, 29 Sep 2016, Saleem Abdulrasool wrote:

> The calling convention agreements for the libgcc interfaces has been
> vague.  It has been often observed that at least with certain versions of
> gcc that the interfaces uses the base ABI.  This was the behavior that

That should not be the case, for libgcc functions that are not in RTABI.  
They should use the ABI of the multilib they are compiled for, which may 
be base ABI or VFP ABI depending on the options used for compiling that 
multilib.

> The current belief is that the floating point routines in libgcc are to
> conform to the base ABI.  Given the description "The software floating
> point library is used on machines which do not have hardware support for
> floating point. It is also used whenever -msoft-float is used to disable
> generation of floating point instructions." it stands to reason to believe
> that the base ABI be used for these routines.

Functions such as __powidf2 and __mulsc3 are not part of the software 
floating-point library.  They use the same ABI as any other C functions 
with their type.

-- 
Joseph S. Myers
jos...@codesourcery.com


gcc-6-20160929 is now available

2016-09-29 Thread gccadmin
Snapshot gcc-6-20160929 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/6-20160929/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 6 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/branches/gcc-6-branch 
revision 240640

You'll find:

 gcc-6-20160929.tar.bz2   Complete GCC

  MD5=6f955955a8a134a38ebe6eec1c9403a8
  SHA1=19aa0936d1d1419e8cfb251f254b0857470f5fdd

Diffs from 6-20160922 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-6
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.