OSDN Git Service

* config/cris/cris.md ("movsi"): Fix typo in last change.
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssanames.c
index 9cbe352..899ac82 100644 (file)
@@ -266,7 +266,7 @@ duplicate_ssa_name_ptr_info (tree name, struct ptr_info_def *ptr_info)
   if (!ptr_info)
     return;
 
-  new_ptr_info = ggc_alloc (sizeof (struct ptr_info_def));
+  new_ptr_info = GGC_NEW (struct ptr_info_def);
   *new_ptr_info = *ptr_info;
 
   if (ptr_info->pt_vars)
@@ -318,17 +318,27 @@ release_dead_ssa_names (void)
   referenced_var_iterator rvi;
 
   /* Current defs point to various dead SSA names that in turn points to dead
-     statements so bunch of dead memory is holded from releasing.  */
+     statements so bunch of dead memory is held from releasing.  */
   FOR_EACH_REFERENCED_VAR (t, rvi)
     set_current_def (t, NULL);
   /* Now release the freelist.  */
   for (t = FREE_SSANAMES (cfun); t; t = next)
     {
       next = TREE_CHAIN (t);
-      ggc_free (t);
+      /* Dangling pointers might make GGC to still see dead SSA names, so it is
+        important to unlink the list and avoid GGC from seeing all subsequent
+        SSA names.  In longer run we want to have all dangling pointers here
+        removed (since they usually go through dead statements that consume
+        considerable amounts of memory).  */
+      TREE_CHAIN (t) = NULL_TREE;
       n++;
     }
   FREE_SSANAMES (cfun) = NULL;
+
+  /* Cgraph edges has been invalidated and point to dead statement.  We need to
+     remove them now and will rebuild it before next IPA pass.  */
+  cgraph_node_remove_callees (cgraph_node (current_function_decl));
+
   if (dump_file)
     fprintf (dump_file, "Released %i names, %.2f%%\n", n, n * 100.0 / num_ssa_names);
   return 0;