]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/lto-streamer-in.c
PR fortran/95090 - ICE: identifier overflow
[thirdparty/gcc.git] / gcc / lto-streamer-in.c
index 93ec8be535163fc61e7745d4f989c7e197c623e9..d0532c5ac51ab61c87f95ca2a14f825b8d90ee75 100644 (file)
@@ -1,6 +1,6 @@
 /* Read the GIMPLE representation from a file stream.
 
-   Copyright (C) 2009-2019 Free Software Foundation, Inc.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
    Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
    Re-implemented by Diego Novillo <dnovillo@google.com>
 
@@ -821,6 +821,7 @@ input_cfg (class lto_input_block *ib, class data_in *data_in,
       loop->owned_clique = streamer_read_hwi (ib);
       loop->dont_vectorize = streamer_read_hwi (ib);
       loop->force_vectorize = streamer_read_hwi (ib);
+      loop->finite_p = streamer_read_hwi (ib);
       loop->simduid = stream_read_tree (ib, data_in);
 
       place_new_loop (fn, loop);
@@ -892,6 +893,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple **stmts,
         fatal_error (input_location,
                     "Cgraph edge statement index out of range");
       cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]);
+      cedge->lto_stmt_uid = 0;
       if (!cedge->call_stmt)
         fatal_error (input_location,
                     "Cgraph edge statement index not found");
@@ -902,6 +904,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple **stmts,
         fatal_error (input_location,
                     "Cgraph edge statement index out of range");
       cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]);
+      cedge->lto_stmt_uid = 0;
       if (!cedge->call_stmt)
         fatal_error (input_location, "Cgraph edge statement index not found");
     }
@@ -912,6 +915,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple **stmts,
          fatal_error (input_location,
                       "Reference statement index out of range");
        ref->stmt = stmts[ref->lto_stmt_uid - 1];
+       ref->lto_stmt_uid = 0;
        if (!ref->stmt)
          fatal_error (input_location, "Reference statement index not found");
       }
@@ -1022,13 +1026,13 @@ input_struct_function_base (struct function *fn, class data_in *data_in,
 
 static void
 input_function (tree fn_decl, class data_in *data_in,
-               class lto_input_block *ib, class lto_input_block *ib_cfg)
+               class lto_input_block *ib, class lto_input_block *ib_cfg,
+               cgraph_node *node)
 {
   struct function *fn;
   enum LTO_tags tag;
   gimple **stmts;
   basic_block bb;
-  struct cgraph_node *node;
 
   tag = streamer_read_record_start (ib);
   lto_tag_check (tag, LTO_function);
@@ -1064,9 +1068,6 @@ input_function (tree fn_decl, class data_in *data_in,
 
   gimple_register_cfg_hooks ();
 
-  node = cgraph_node::get (fn_decl);
-  if (!node)
-    node = cgraph_node::create (fn_decl);
   input_struct_function_base (fn, data_in, ib);
   input_cfg (ib_cfg, data_in, fn);
 
@@ -1138,8 +1139,9 @@ input_function (tree fn_decl, class data_in *data_in,
                 we'd later ICE on.  */
              tree block;
              if (gimple_debug_inline_entry_p (stmt)
-                 && (block = gimple_block (stmt))
-                 && !inlined_function_outer_scope_p (block))
+                 && (((block = gimple_block (stmt))
+                      && !inlined_function_outer_scope_p (block))
+                     || !debug_inline_points))
                remove = true;
              if (is_gimple_call (stmt)
                  && gimple_call_internal_p (stmt))
@@ -1223,7 +1225,6 @@ input_function (tree fn_decl, class data_in *data_in,
   fixup_call_stmt_edges (node, stmts);
   execute_all_ipa_stmt_fixups (node, stmts);
 
-  update_ssa (TODO_update_ssa_only_virtuals);
   free_dominance_info (CDI_DOMINATORS);
   free_dominance_info (CDI_POST_DOMINATORS);
   free (stmts);
@@ -1294,7 +1295,8 @@ lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symta
        {
          lto_input_block ib_cfg (data + cfg_offset, header->cfg_size,
                                  file_data->mode_table);
-         input_function (fn_decl, data_in, &ib_main, &ib_cfg);
+         input_function (fn_decl, data_in, &ib_main, &ib_cfg,
+                         dyn_cast <cgraph_node *>(node));
        }
       else
         input_constructor (fn_decl, data_in, &ib_main);
@@ -1415,25 +1417,30 @@ lto_read_tree (class lto_input_block *ib, class data_in *data_in,
 
   lto_read_tree_1 (ib, data_in, result);
 
-  /* end_marker = */ streamer_read_uchar (ib);
-
   return result;
 }
 
 
 /* Populate the reader cache with trees materialized from the SCC
-   following in the IB, DATA_IN stream.  */
+   following in the IB, DATA_IN stream.
+   If SHARED_SCC is true we input LTO_tree_scc.  */
 
 hashval_t
 lto_input_scc (class lto_input_block *ib, class data_in *data_in,
-              unsigned *len, unsigned *entry_len)
+              unsigned *len, unsigned *entry_len, bool shared_scc)
 {
-  /* A blob of unnamed tree nodes, fill the cache from it and
-     recurse.  */
   unsigned size = streamer_read_uhwi (ib);
-  hashval_t scc_hash = streamer_read_uhwi (ib);
+  hashval_t scc_hash = 0;
   unsigned scc_entry_len = 1;
 
+  if (shared_scc)
+    {
+      if (size & 1)
+       scc_entry_len = streamer_read_uhwi (ib);
+      size /= 2;
+      scc_hash = streamer_read_uhwi (ib);
+    }
+
   if (size == 1)
     {
       enum LTO_tags tag = streamer_read_record_start (ib);
@@ -1444,8 +1451,6 @@ lto_input_scc (class lto_input_block *ib, class data_in *data_in,
       unsigned int first = data_in->reader_cache->nodes.length ();
       tree result;
 
-      scc_entry_len = streamer_read_uhwi (ib);
-
       /* Materialize size trees by reading their headers.  */
       for (unsigned i = 0; i < size; ++i)
        {
@@ -1454,7 +1459,8 @@ lto_input_scc (class lto_input_block *ib, class data_in *data_in,
              || (tag >= LTO_field_decl_ref && tag <= LTO_global_decl_ref)
              || tag == LTO_tree_pickle_reference
              || tag == LTO_integer_cst
-             || tag == LTO_tree_scc)
+             || tag == LTO_tree_scc
+             || tag == LTO_trees)
            gcc_unreachable ();
 
          result = streamer_alloc_tree (ib, data_in, tag);
@@ -1467,7 +1473,6 @@ lto_input_scc (class lto_input_block *ib, class data_in *data_in,
          result = streamer_tree_cache_get_tree (data_in->reader_cache,
                                                 first + i);
          lto_read_tree_1 (ib, data_in, result);
-         /* end_marker = */ streamer_read_uchar (ib);
        }
     }
 
@@ -1520,7 +1525,7 @@ lto_input_tree_1 (class lto_input_block *ib, class data_in *data_in,
                                 (a, len, TYPE_PRECISION (type)));
       streamer_tree_cache_append (data_in->reader_cache, result, hash);
     }
-  else if (tag == LTO_tree_scc)
+  else if (tag == LTO_tree_scc || tag == LTO_trees)
     gcc_unreachable ();
   else
     {
@@ -1536,11 +1541,11 @@ lto_input_tree (class lto_input_block *ib, class data_in *data_in)
 {
   enum LTO_tags tag;
 
-  /* Input and skip SCCs.  */
-  while ((tag = streamer_read_record_start (ib)) == LTO_tree_scc)
+  /* Input pickled trees needed to stream in the reference.  */
+  while ((tag = streamer_read_record_start (ib)) == LTO_trees)
     {
       unsigned len, entry_len;
-      lto_input_scc (ib, data_in, &len, &entry_len);
+      lto_input_scc (ib, data_in, &len, &entry_len, false);
 
       /* Register DECLs with the debuginfo machinery.  */
       while (!dref_queue.is_empty ())
@@ -1549,7 +1554,15 @@ lto_input_tree (class lto_input_block *ib, class data_in *data_in)
          debug_hooks->register_external_die (e.decl, e.sym, e.off);
        }
     }
-  return lto_input_tree_1 (ib, data_in, tag, 0);
+  tree t = lto_input_tree_1 (ib, data_in, tag, 0);
+
+  if (!dref_queue.is_empty ())
+    {
+      dref_entry e = dref_queue.pop ();
+      debug_hooks->register_external_die (e.decl, e.sym, e.off);
+      gcc_checking_assert (dref_queue.is_empty ());
+    }
+  return t;
 }
 
 
@@ -1701,7 +1714,31 @@ lto_input_mode_table (struct lto_file_decl_data *file_data)
                }
              /* FALLTHRU */
            default:
-             fatal_error (UNKNOWN_LOCATION, "unsupported mode %qs", mname);
+             /* This is only used for offloading-target compilations and
+                is a user-facing error.  Give a better error message for
+                the common modes; see also mode-classes.def.   */
+             if (mclass == MODE_FLOAT)
+               fatal_error (UNKNOWN_LOCATION,
+                            "%s - %u-bit-precision floating-point numbers "
+                            "unsupported (mode %qs)", TARGET_MACHINE,
+                            prec.to_constant (), mname);
+             else if (mclass == MODE_DECIMAL_FLOAT)
+               fatal_error (UNKNOWN_LOCATION,
+                            "%s - %u-bit-precision decimal floating-point "
+                            "numbers unsupported (mode %qs)", TARGET_MACHINE,
+                            prec.to_constant (), mname);
+             else if (mclass == MODE_COMPLEX_FLOAT)
+               fatal_error (UNKNOWN_LOCATION,
+                            "%s - %u-bit-precision complex floating-point "
+                            "numbers unsupported (mode %qs)", TARGET_MACHINE,
+                            prec.to_constant (), mname);
+             else if (mclass == MODE_INT)
+               fatal_error (UNKNOWN_LOCATION,
+                            "%s - %u-bit integer numbers unsupported (mode "
+                            "%qs)", TARGET_MACHINE, prec.to_constant (), mname);
+             else
+               fatal_error (UNKNOWN_LOCATION, "%s - unsupported mode %qs",
+                            TARGET_MACHINE, mname);
              break;
            }
        }