[PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 19 Oct 2016 10:48:46 +0000 (12:48 +0200)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Wed, 19 Oct 2016 10:48:46 +0000 (12:48 +0200)
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.

From-SVN: r241338

gcc/ChangeLog
gcc/tree-core.h
gcc/tree-streamer.c

index 59b00d164f944303d6bbf0362532ab72da2e89ef..b50e2e4004e7e01a904df1b960cbba5cc8513458 100644 (file)
@@ -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):
index 1bfe682361083a5b2cb495251806e2240a913507..3e3f31e272649a34f70d3d121b553062e859f458 100644 (file)
@@ -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,
index 2139e96634e0331fa01e7ee88cdb12bbaf376e2b..70054b1f2c171893a30f7ebae14134b9a777e744 100644 (file)
@@ -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.