OSDN Git Service

* configure.ac (gcc_cv_nm): Don't use an in-tree nm if
[pf3gnuchains/gcc-fork.git] / gcc / cgraphunit.c
index 995bcb9..030f868 100644 (file)
@@ -171,6 +171,7 @@ static void cgraph_expand_all_functions (void);
 static void cgraph_mark_functions_to_output (void);
 static void cgraph_expand_function (struct cgraph_node *);
 static tree record_reference (tree *, int *, void *);
+static void cgraph_output_pending_asms (void);
 
 /* Records tree nodes seen in record_reference.  Simply using
    walk_tree_without_duplicates doesn't guarantee each node is visited
@@ -338,6 +339,8 @@ cgraph_assemble_pending_functions (void)
   if (flag_unit_at_a_time)
     return false;
 
+  cgraph_output_pending_asms ();
+
   while (cgraph_nodes_queue)
     {
       struct cgraph_node *n = cgraph_nodes_queue;
@@ -353,8 +356,22 @@ cgraph_assemble_pending_functions (void)
        }
     }
 
+  /* Process CGRAPH_EXPAND_QUEUE, these are functions created during
+     the expansion process.  Note that this queue may grow as its
+     being processed, as the new functions may generate new ones.  */
+  while (cgraph_expand_queue)
+    {
+      struct cgraph_node *n = cgraph_expand_queue;
+      cgraph_expand_queue = cgraph_expand_queue->next_needed;
+      n->next_needed = NULL;
+      cgraph_finalize_function (n->decl, false);
+      output = true;
+    }
+
   return output;
 }
+
+
 /* As an GCC extension we allow redefinition of the function.  The
    semantics when both copies of bodies differ is not well defined.
    We replace the old body with new body so in unit at a time mode
@@ -418,20 +435,6 @@ cgraph_lower_function (struct cgraph_node *node)
   node->lowered = true;
 }
 
-static void
-cgraph_finalize_pending_functions (void)
-{
-  struct cgraph_node *next, *node = cgraph_analyze_queue;
-
-  cgraph_analyze_queue = NULL;
-  for (; node ; node = next)
-    {
-      next = node->next_needed;
-      node->next_needed = NULL;
-      cgraph_finalize_function (node->decl, true);
-    }
-}
-
 /* DECL has been parsed.  Take it, queue it, compile it at the whim of the
    logic in effect.  If NESTED is true, then our caller cannot stand to have
    the garbage collector run at the moment.  We would need to either create
@@ -458,7 +461,6 @@ cgraph_finalize_function (tree decl, bool nested)
   if (!flag_unit_at_a_time)
     {
       cgraph_analyze_function (node);
-      cgraph_finalize_pending_functions ();
       cgraph_decide_inlining_incrementally (node, false);
     }
 
@@ -616,7 +618,7 @@ initialize_inline_failed (struct cgraph_node *node)
 
 /* Rebuild call edges from current function after a passes not aware
    of cgraph updating.  */
-static void
+static unsigned int
 rebuild_cgraph_edges (void)
 {
   basic_block bb;
@@ -641,6 +643,7 @@ rebuild_cgraph_edges (void)
       }
   initialize_inline_failed (node);
   gcc_assert (!node->global.inlined_to);
+  return 0;
 }
 
 struct tree_opt_pass pass_rebuild_cgraph_edges =
@@ -982,7 +985,6 @@ cgraph_finalize_compilation_unit (void)
       gcc_assert (DECL_SAVED_TREE (decl));
 
       cgraph_analyze_function (node);
-      cgraph_finalize_pending_functions ();
 
       for (edge = node->callees; edge; edge = edge->next_callee)
        if (!edge->callee->reachable)
@@ -1142,8 +1144,7 @@ static void
 cgraph_expand_all_functions (void)
 {
   struct cgraph_node *node;
-  struct cgraph_node **order =
-    xcalloc (cgraph_n_nodes, sizeof (struct cgraph_node *));
+  struct cgraph_node **order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
   int order_pos = 0, new_order_pos = 0;
   int i;
 
@@ -1166,7 +1167,21 @@ cgraph_expand_all_functions (void)
          cgraph_expand_function (node);
        }
     }
+
   free (order);
+
+  /* Process CGRAPH_EXPAND_QUEUE, these are functions created during
+     the expansion process.  Note that this queue may grow as its
+     being processed, as the new functions may generate new ones.  */
+  while (cgraph_expand_queue)
+    {
+      node = cgraph_expand_queue;
+      cgraph_expand_queue = cgraph_expand_queue->next_needed;
+      node->next_needed = NULL;
+      node->output = 0;
+      node->lowered = DECL_STRUCT_FUNCTION (node->decl)->cfg != NULL;
+      cgraph_expand_function (node);
+    }
 }
 
 /* This is used to sort the node types by the cgraph order number.  */
@@ -1232,7 +1247,6 @@ cgraph_output_in_order (void)
       nodes[i].kind = ORDER_ASM;
       nodes[i].u.a = pa;
     }
-  cgraph_asm_nodes = NULL;
 
   for (i = 0; i < max; ++i)
     {
@@ -1258,6 +1272,8 @@ cgraph_output_in_order (void)
          gcc_unreachable ();
        }
     }
+
+  cgraph_asm_nodes = NULL;
 }
 
 /* Mark visibility of all functions.
@@ -1559,7 +1575,8 @@ update_call_expr (struct cgraph_node *new_version)
 
 static struct cgraph_node *
 cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
-                                tree new_decl, varray_type redirect_callers)
+                                tree new_decl,
+                                VEC(cgraph_edge_p,heap) *redirect_callers)
  {
    struct cgraph_node *new_version;
    struct cgraph_edge *e, *new_e;
@@ -1598,14 +1615,12 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
        if (!next_callee)
         break;
      }
-   if (redirect_callers)
-     for (i = 0; i < VARRAY_ACTIVE_SIZE (redirect_callers); i++)
-       {
-         e = VARRAY_GENERIC_PTR (redirect_callers, i);
-        /* Redirect calls to the old version node
-           to point to it's new version.  */
-         cgraph_redirect_edge_callee (e, new_version);
-       }
+   for (i = 0; VEC_iterate (cgraph_edge_p, redirect_callers, i, e); i++)
+     {
+       /* Redirect calls to the old version node to point to its new
+         version.  */
+       cgraph_redirect_edge_callee (e, new_version);
+     }
 
    return new_version;
  }
@@ -1625,7 +1640,7 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
 
 struct cgraph_node *
 cgraph_function_versioning (struct cgraph_node *old_version_node,
-                           varray_type redirect_callers,
+                           VEC(cgraph_edge_p,heap) *redirect_callers,
                            varray_type tree_map)
 {
   tree old_decl = old_version_node->decl;
@@ -1676,7 +1691,7 @@ save_inline_function_body (struct cgraph_node *node)
   cgraph_lower_function (node);
 
   /* In non-unit-at-a-time we construct full fledged clone we never output to
-     assembly file.  This clone is pointed out by inline_decl of orginal function
+     assembly file.  This clone is pointed out by inline_decl of original function
      and inlining infrastructure knows how to deal with this.  */
   if (!flag_unit_at_a_time)
     {