OSDN Git Service

PR bootstrap/43403
[pf3gnuchains/gcc-fork.git] / gcc / cgraphunit.c
index c811d49..c41477b 100644 (file)
@@ -382,7 +382,6 @@ cgraph_process_new_functions (void)
   tree fndecl;
   struct cgraph_node *node;
 
-  varpool_analyze_pending_decls ();
   /*  Note that this queue may grow as its being processed, as the new
       functions may generate new ones.  */
   while (cgraph_new_nodes)
@@ -438,7 +437,6 @@ cgraph_process_new_functions (void)
          break;
        }
       cgraph_call_function_insertion_hooks (node);
-      varpool_analyze_pending_decls ();
     }
   return output;
 }
@@ -609,24 +607,6 @@ verify_cgraph_node (struct cgraph_node *node)
       error ("Inline clone is needed");
       error_found = true;
     }
-  for (e = node->indirect_calls; e; e = e->next_callee)
-    {
-      if (e->aux)
-       {
-         error ("aux field set for indirect edge from %s",
-                identifier_to_locale (cgraph_node_name (e->caller)));
-         error_found = true;
-       }
-      if (!e->indirect_unknown_callee
-         || !e->indirect_info)
-       {
-         error ("An indirect edge from %s is not marked as indirect or has "
-                "associated indirect_info, the corresponding statement is: ",
-                identifier_to_locale (cgraph_node_name (e->caller)));
-         debug_gimple_stmt (e->call_stmt);
-         error_found = true;
-       }
-    }
   for (e = node->callers; e; e = e->next_caller)
     {
       if (e->count < 0)
@@ -734,32 +714,6 @@ verify_cgraph_node (struct cgraph_node *node)
       error ("double linked list of clones corrupted");
       error_found = true;
     }
-  if (node->same_comdat_group)
-    {
-      struct cgraph_node *n = node->same_comdat_group;
-
-      if (!DECL_ONE_ONLY (node->decl))
-       {
-         error ("non-DECL_ONE_ONLY node in a same_comdat_group list");
-         error_found = true;
-       }
-      if (n == node)
-       {
-         error ("node is alone in a comdat group");
-         error_found = true;
-       }
-      do
-       {
-         if (!n->same_comdat_group)
-           {
-             error ("same_comdat_group is not a circular list");
-             error_found = true;
-             break;
-           }
-         n = n->same_comdat_group;
-       }
-      while (n != node);
-    }
 
   if (node->analyzed && gimple_has_body_p (node->decl)
       && !TREE_ASM_WRITTEN (node->decl)
@@ -779,10 +733,10 @@ verify_cgraph_node (struct cgraph_node *node)
                  gsi_next (&gsi))
              {
                gimple stmt = gsi_stmt (gsi);
-               if (is_gimple_call (stmt))
+               tree decl;
+               if (is_gimple_call (stmt) && (decl = gimple_call_fndecl (stmt)))
                  {
                    struct cgraph_edge *e = cgraph_edge (node, stmt);
-                   tree decl = gimple_call_fndecl (stmt);
                    if (e)
                      {
                        if (e->aux)
@@ -791,38 +745,25 @@ verify_cgraph_node (struct cgraph_node *node)
                            debug_gimple_stmt (stmt);
                            error_found = true;
                          }
-                       if (!e->indirect_unknown_callee)
+                       if (e->callee->same_body_alias)
                          {
-                           if (e->callee->same_body_alias)
-                             {
-                               error ("edge points to same body alias:");
-                               debug_tree (e->callee->decl);
-                               error_found = true;
-                             }
-                           else if (!node->global.inlined_to
-                                    && !e->callee->global.inlined_to
-                                    && decl
-                                    && !clone_of_p (cgraph_node (decl),
-                                                    e->callee))
-                             {
-                               error ("edge points to wrong declaration:");
-                               debug_tree (e->callee->decl);
-                               fprintf (stderr," Instead of:");
-                               debug_tree (decl);
-                               error_found = true;
-                             }
+                           error ("edge points to same body alias:");
+                           debug_tree (e->callee->decl);
+                           error_found = true;
                          }
-                       else if (decl)
+                       else if (!node->global.inlined_to
+                                && !e->callee->global.inlined_to
+                                && !clone_of_p (cgraph_node (decl), e->callee))
                          {
-                           error ("an indirect edge with unknown callee "
-                                  "corresponding to a call_stmt with "
-                                  "a known declaration:");
+                           error ("edge points to wrong declaration:");
+                           debug_tree (e->callee->decl);
+                           fprintf (stderr," Instead of:");
+                           debug_tree (decl);
                            error_found = true;
-                           debug_gimple_stmt (e->call_stmt);
                          }
                        e->aux = (void *)1;
                      }
-                   else if (decl)
+                   else
                      {
                        error ("missing callgraph edge for call stmt:");
                        debug_gimple_stmt (stmt);
@@ -838,7 +779,7 @@ verify_cgraph_node (struct cgraph_node *node)
 
       for (e = node->callees; e; e = e->next_callee)
        {
-         if (!e->aux)
+         if (!e->aux && !e->indirect_call)
            {
              error ("edge %s->%s has no corresponding call_stmt",
                     identifier_to_locale (cgraph_node_name (e->caller)),
@@ -848,17 +789,6 @@ verify_cgraph_node (struct cgraph_node *node)
            }
          e->aux = 0;
        }
-      for (e = node->indirect_calls; e; e = e->next_callee)
-       {
-         if (!e->aux)
-           {
-             error ("an indirect edge from %s has no corresponding call_stmt",
-                    identifier_to_locale (cgraph_node_name (e->caller)));
-             debug_gimple_stmt (e->call_stmt);
-             error_found = true;
-           }
-         e->aux = 0;
-       }
     }
   if (error_found)
     {
@@ -959,7 +889,11 @@ process_function_and_variable_attributes (struct cgraph_node *first,
     {
       tree decl = node->decl;
       if (DECL_PRESERVE_P (decl))
-       cgraph_mark_needed_node (node);
+       {
+         mark_decl_referenced (decl);
+         if (node->local.finalized)
+            cgraph_mark_needed_node (node);
+       }
       if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
        {
          if (! TREE_PUBLIC (node->decl))
@@ -975,6 +909,7 @@ process_function_and_variable_attributes (struct cgraph_node *first,
       tree decl = vnode->decl;
       if (DECL_PRESERVE_P (decl))
        {
+         mark_decl_referenced (decl);
          vnode->force_output = true;
          if (vnode->finalized)
            varpool_mark_needed_node (vnode);
@@ -1195,8 +1130,7 @@ cgraph_mark_functions_to_output (void)
         outside the current compilation unit.  */
       if (node->analyzed
          && !node->global.inlined_to
-         && (node->needed || node->reachable_from_other_partition
-             || node->address_taken
+         && (node->needed
              || (e && node->reachable))
          && !TREE_ASM_WRITTEN (decl)
          && !DECL_EXTERNAL (decl))
@@ -1223,10 +1157,6 @@ cgraph_mark_functions_to_output (void)
 #ifdef ENABLE_CHECKING
          if (!node->global.inlined_to
              && gimple_has_body_p (decl)
-             /* FIXME: in ltrans unit when offline copy is outside partition but inline copies
-                are inside partition, we can end up not removing the body since we no longer
-                have analyzed node pointing to it.  */
-             && !node->in_other_partition
              && !DECL_EXTERNAL (decl))
            {
              dump_cgraph_node (stderr, node);
@@ -1235,7 +1165,6 @@ cgraph_mark_functions_to_output (void)
 #endif
          gcc_assert (node->global.inlined_to
                      || !gimple_has_body_p (decl)
-                     || node->in_other_partition
                      || DECL_EXTERNAL (decl));
 
        }
@@ -1249,10 +1178,6 @@ cgraph_mark_functions_to_output (void)
          tree decl = node->decl;
          if (!node->global.inlined_to
              && gimple_has_body_p (decl)
-             /* FIXME: in ltrans unit when offline copy is outside partition but inline copies
-                are inside partition, we can end up not removing the body since we no longer
-                have analyzed node pointing to it.  */
-             && !node->in_other_partition
              && !DECL_EXTERNAL (decl))
            {
              dump_cgraph_node (stderr, node);
@@ -1597,6 +1522,7 @@ assemble_thunk (struct cgraph_node *node)
       cgraph_remove_same_body_alias (node);
       /* Since we want to emit the thunk, we explicitly mark its name as
         referenced.  */
+      mark_decl_referenced (thunk_fndecl);
       cgraph_add_new_function (thunk_fndecl, true);
       bitmap_obstack_release (NULL);
     }
@@ -1738,6 +1664,7 @@ static void
 cgraph_output_in_order (void)
 {
   int max;
+  size_t size;
   struct cgraph_order_sort *nodes;
   int i;
   struct cgraph_node *pf;
@@ -1745,7 +1672,9 @@ cgraph_output_in_order (void)
   struct cgraph_asm_node *pa;
 
   max = cgraph_order;
-  nodes = XCNEWVEC (struct cgraph_order_sort, max);
+  size = max * sizeof (struct cgraph_order_sort);
+  nodes = (struct cgraph_order_sort *) alloca (size);
+  memset (nodes, 0, size);
 
   varpool_analyze_pending_decls ();
 
@@ -1812,7 +1741,6 @@ cgraph_output_in_order (void)
     }
 
   cgraph_asm_nodes = NULL;
-  free (nodes);
 }
 
 /* Return true when function body of DECL still needs to be kept around
@@ -1861,19 +1789,11 @@ ipa_passes (void)
       execute_ipa_summary_passes
        ((struct ipa_opt_pass_d *) all_regular_ipa_passes);
     }
-
-  /* Some targets need to handle LTO assembler output specially.  */
-  if (flag_generate_lto)
-    targetm.asm_out.lto_start ();
-
   execute_ipa_summary_passes ((struct ipa_opt_pass_d *) all_lto_gen_passes);
 
   if (!in_lto_p)
     ipa_write_summaries ();
 
-  if (flag_generate_lto)
-    targetm.asm_out.lto_end ();
-
   if (!flag_ltrans)
     execute_ipa_pass_list (all_regular_ipa_passes);
   invoke_plugin_callbacks (PLUGIN_ALL_IPA_PASSES_END, NULL);
@@ -2026,11 +1946,7 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
   DECL_ARTIFICIAL (decl) = 1;
   DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
   DECL_SAVED_TREE (decl) = body;
-  if (!targetm.have_ctors_dtors)
-    {
-      TREE_PUBLIC (decl) = 1;
-      DECL_PRESERVE_P (decl) = 1;
-    }
+  TREE_PUBLIC (decl) = ! targetm.have_ctors_dtors;
   DECL_UNINLINABLE (decl) = 1;
 
   DECL_INITIAL (decl) = make_node (BLOCK);
@@ -2100,7 +2016,7 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
                                 VEC(cgraph_edge_p,heap) *redirect_callers)
  {
    struct cgraph_node *new_version;
-   struct cgraph_edge *e;
+   struct cgraph_edge *e, *new_e;
    struct cgraph_edge *next_callee;
    unsigned i;
 
@@ -2119,10 +2035,10 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
       also cloned.  */
    for (e = old_version->callees;e; e=e->next_callee)
      {
-       cgraph_clone_edge (e, new_version, e->call_stmt,
-                         e->lto_stmt_uid, REG_BR_PROB_BASE,
-                         CGRAPH_FREQ_BASE,
-                         e->loop_nest, true);
+       new_e = cgraph_clone_edge (e, new_version, e->call_stmt,
+                                 e->lto_stmt_uid, 0, e->frequency,
+                                 e->loop_nest, true);
+       new_e->count = e->count;
      }
    /* Fix recursive calls.
       If OLD_VERSION has a recursive call after the
@@ -2342,7 +2258,6 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
 
   gsi = gsi_for_stmt (e->call_stmt);
   gsi_replace (&gsi, new_stmt, true);
-  update_stmt (new_stmt);
 
   /* Update EH information too, just in case.  */
   maybe_clean_or_replace_eh_stmt (e->call_stmt, new_stmt);
@@ -2425,8 +2340,9 @@ cgraph_materialize_all_clones (void)
                        }
                    }
                  cgraph_materialize_clone (node);
-                 stabilized = false;
                }
+             else
+               stabilized = false;
            }
        }
     }
@@ -2445,7 +2361,6 @@ cgraph_materialize_all_clones (void)
         push_cfun (DECL_STRUCT_FUNCTION (node->decl));
        for (e = node->callees; e; e = e->next_callee)
          cgraph_redirect_edge_call_stmt_to_callee (e);
-       gcc_assert (!need_ssa_update_p (cfun));
        pop_cfun ();
        current_function_decl = NULL;
 #ifdef ENABLE_CHECKING