re PR middle-end/56461 (GCC is leaking lots of memory)
authorJakub Jelinek <jakub@redhat.com>
Fri, 1 Mar 2013 22:55:26 +0000 (23:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 1 Mar 2013 22:55:26 +0000 (23:55 +0100)
PR middle-end/56461
* ira-build.c (ira_loop_nodes_count): New variable.
(create_loop_tree_nodes): Initialize it.
(finish_loop_tree_nodes): Use it instead of looking at current_loops.

From-SVN: r196397

gcc/ChangeLog
gcc/ira-build.c

index ee9625cc4c0747401e727c93d57e29f1cc1550ba..133af66eaf7c2cfbb90d9eb72431402a4e9e3011 100644 (file)
@@ -1,5 +1,10 @@
 2013-03-01  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/56461
+       * ira-build.c (ira_loop_nodes_count): New variable.
+       (create_loop_tree_nodes): Initialize it.
+       (finish_loop_tree_nodes): Use it instead of looking at current_loops.
+
        PR middle-end/56461
        * tree-vect-data-refs.c (vect_permute_store_chain): Avoid using copy
        method on dr_chain and result_chain.
index dd66091a33594a9e7e42b3755cb45d79fcfbb6ed..b1e481bdb055b634bd91f43fc15585b6e9dad87b 100644 (file)
@@ -57,6 +57,9 @@ ira_loop_tree_node_t ira_bb_nodes;
    array.  */
 ira_loop_tree_node_t ira_loop_nodes;
 
+/* And size of the ira_loop_nodes array.  */
+unsigned int ira_loop_nodes_count;
+
 /* Map regno -> allocnos with given regno (see comments for
    allocno member `next_regno_allocno').  */
 ira_allocno_t *ira_regno_allocno_map;
@@ -142,14 +145,16 @@ create_loop_tree_nodes (void)
     }
   if (current_loops == NULL)
     {
+      ira_loop_nodes_count = 1;
       ira_loop_nodes = ((struct ira_loop_tree_node *)
                        ira_allocate (sizeof (struct ira_loop_tree_node)));
       init_loop_tree_node (ira_loop_nodes, 0);
       return;
     }
+  ira_loop_nodes_count = number_of_loops ();
   ira_loop_nodes = ((struct ira_loop_tree_node *)
                    ira_allocate (sizeof (struct ira_loop_tree_node)
-                                 * number_of_loops ()));
+                                 * ira_loop_nodes_count));
   FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop)
     {
       if (loop_outer (loop) != NULL)
@@ -217,13 +222,9 @@ static void
 finish_loop_tree_nodes (void)
 {
   unsigned int i;
-  loop_p loop;
 
-  if (current_loops == NULL)
-    finish_loop_tree_node (&ira_loop_nodes[0]);
-  else
-    FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop)
-      finish_loop_tree_node (&ira_loop_nodes[i]);
+  for (i = 0; i < ira_loop_nodes_count; i++)
+    finish_loop_tree_node (&ira_loop_nodes[i]);
   ira_free (ira_loop_nodes);
   for (i = 0; i < (unsigned int) last_basic_block_before_change; i++)
     {