cgraph.c (cgraph_remove_node): Avoid loop in code deciding whether function body...
authorJan Hubicka <jh@suse.cz>
Fri, 18 Mar 2005 10:00:53 +0000 (11:00 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 18 Mar 2005 10:00:53 +0000 (10:00 +0000)
* cgraph.c (cgraph_remove_node): Avoid loop in code deciding whether
function body should be released; do not proactively release function
bodies in non-unit-at-a-time mode.

From-SVN: r96654

gcc/ChangeLog
gcc/cgraph.c

index 1d3b7c49d580790e8694a640573057049638efe2..68cfec2386320a73fd06da4a98d5a530ec4d0de7 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-18  Jan Hubicka  <jh@suse.cz>
+
+       * cgraph.c (cgraph_remove_node): Avoid loop in code deciding whether 
+       function body should be released; do not proactively release function
+       bodies in non-unit-at-a-time mode.
+
 2005-03-18  Ralf Corsepius  <ralf.corsepius@rtems.org>
 
        * config/i386/t-rtems-i386 (MULTILIBS): Remove k6, athlon,
index 11953b46f85a898304c57a6363051e1bf5c9e181..dacc70dfb30b026744972006a8ccca7f2e7111c8 100644 (file)
@@ -398,7 +398,7 @@ void
 cgraph_remove_node (struct cgraph_node *node)
 {
   void **slot;
-  bool check_dead = 1;
+  bool kill_body = false;
 
   cgraph_node_remove_callers (node);
   cgraph_node_remove_callees (node);
@@ -426,12 +426,7 @@ cgraph_remove_node (struct cgraph_node *node)
       else
        {
           htab_clear_slot (cgraph_hash, slot);
-         if (!dump_enabled_p (TDI_tree_all))
-           {
-              DECL_SAVED_TREE (node->decl) = NULL;
-             DECL_STRUCT_FUNCTION (node->decl) = NULL;
-           }
-         check_dead = false;
+         kill_body = true;
        }
     }
   else
@@ -443,23 +438,23 @@ cgraph_remove_node (struct cgraph_node *node)
       n->next_clone = node->next_clone;
     }
 
-  /* Work out whether we still need a function body (either there is inline
-     clone or there is out of line function whose body is not written).  */
-  if (check_dead && flag_unit_at_a_time)
+  /* While all the clones are removed after being proceeded, the function 
+     itself is kept in the cgraph even after it is compiled.  Check whether
+     we are done with this body and reclaim it proactively if this is the case.
+     */
+  if (!kill_body && *slot)
     {
-      struct cgraph_node *n;
+      struct cgraph_node *n = *slot;
+      if (!n->next_clone && !n->global.inlined_to
+         && (TREE_ASM_WRITTEN (n->decl) || DECL_EXTERNAL (n->decl)))
+       kill_body = true;
+    }
 
-      for (n = *slot; n; n = n->next_clone)
-       if (n->global.inlined_to
-           || (!n->global.inlined_to
-               && !TREE_ASM_WRITTEN (n->decl) && !DECL_EXTERNAL (n->decl)))
-         break;
-      if (!n && !dump_enabled_p (TDI_tree_all))
-       {
-         DECL_SAVED_TREE (node->decl) = NULL;
-         DECL_STRUCT_FUNCTION (node->decl) = NULL;
-          DECL_INITIAL (node->decl) = error_mark_node;
-       }
+  if (kill_body && !dump_enabled_p (TDI_tree_all) && flag_unit_at_a_time)
+    {
+      DECL_SAVED_TREE (node->decl) = NULL;
+      DECL_STRUCT_FUNCTION (node->decl) = NULL;
+      DECL_INITIAL (node->decl) = error_mark_node;
     }
   cgraph_n_nodes--;
   /* Do not free the structure itself so the walk over chain can continue.  */