This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] various memory leak fixes


Hi, 

bootstrapped, regtested with no new regressions using default languages on 
x86_64-suse-linux. I've not managed to bootstrap/regtest ada, which the 
reload patch affects. Eric, could you test this part, please?

Ok for mainline?

Thanks,
Dirk

2007-06-22  Dirk Mueller  <dmueller@suse.de>

        * omega.c (coalesce): Fix memory leak on early exit.
        * matrix-reorg.c (check_allocation_function): Likewise.
        * tree-vect-transform.c (vect_get_new_vect_var): free result
        of concat().
        * bb-reorder.c (find_rarely_executed_basic_blocks_and_crossing_edges):
        pass pointer to edge vector
        (partition_hot_cold_basic_blocks): Fix memory leak.
        * collect2.c (prefix_from_string): Free temporary storage.
        * reload1.c (fixup_abnormal_edges): Free sbitmap.

--- omega.c
+++ omega.c
@@ -2454,7 +2454,7 @@ coalesce (omega_pb pb)
 {
   int e, e2;
   int colors = 0;
-  bool *is_dead = XNEWVEC (bool, OMEGA_MAX_GEQS);
+  bool *is_dead;
   int found_something = 0;
 
   for (e = 0; e < pb->num_geqs; e++)
@@ -2464,6 +2464,8 @@ coalesce (omega_pb pb)
   if (colors < 2)
     return;
 
+  is_dead = XNEWVEC (bool, OMEGA_MAX_GEQS);
+
   for (e = 0; e < pb->num_geqs; e++)
     is_dead[e] = false;
 
--- matrix-reorg.c
+++ matrix-reorg.c
@@ -1481,10 +1481,13 @@ check_allocation_function (void **slot, 
   block_stmt_iterator bsi;
   basic_block bb_level_0;
   struct matrix_info *mi = *slot;
-  sbitmap visited = sbitmap_alloc (num_ssa_names);
+  sbitmap visited;
 
   if (!mi->malloc_for_level)
     return 1;
+
+  visited = sbitmap_alloc (num_ssa_names);
+
   /* Do nothing if the current function is not the allocation
      function of MI.  */
   if (mi->allocation_function_decl != current_function_decl
--- tree-vect-transform.c
+++ tree-vect-transform.c
@@ -587,7 +587,11 @@ vect_get_new_vect_var (tree type, enum v
   }
 
   if (name)
-    new_vect_var = create_tmp_var (type, concat (prefix, name, NULL));
+    {
+      char* tmp = concat (prefix, name, NULL);
+      new_vect_var = create_tmp_var (type, tmp);
+      free (tmp);
+    }
   else
     new_vect_var = create_tmp_var (type, prefix);
 
@@ -4277,7 +4281,7 @@ vect_transform_strided_load (tree stmt, 
      corresponds the order of data-refs in RESULT_CHAIN.  */
   next_stmt = first_stmt;
   gap_count = 1;
-  for (i = 0; VEC_iterate(tree, result_chain, i, tmp_data_ref); i++)
+  for (i = 0; VEC_iterate (tree, result_chain, i, tmp_data_ref); i++)
     {
       if (!next_stmt)
 	break;
--- bb-reorder.c
+++ bb-reorder.c
@@ -180,7 +180,7 @@ static void connect_traces (int, struct 
 static bool copy_bb_p (basic_block, int);
 static int get_uncond_jump_length (void);
 static bool push_to_next_round_p (basic_block, int, int, int, gcov_type);
-static void find_rarely_executed_basic_blocks_and_crossing_edges (edge *,
+static void find_rarely_executed_basic_blocks_and_crossing_edges (edge **,
 								  int *,
 								  int *);
 static void add_labels_and_missing_jumps (edge *, int);
@@ -1219,7 +1219,7 @@ get_uncond_jump_length (void)
    cache locality).  */
 
 static void
-find_rarely_executed_basic_blocks_and_crossing_edges (edge *crossing_edges,
+find_rarely_executed_basic_blocks_and_crossing_edges (edge **crossing_edges,
 						      int *n_crossing_edges,
 						      int *max_idx)
 {
@@ -1256,10 +1256,10 @@ find_rarely_executed_basic_blocks_and_cr
 	  if (i == *max_idx)
 	    {
 	      *max_idx *= 2;
-	      crossing_edges = xrealloc (crossing_edges,
+	      *crossing_edges = xrealloc (*crossing_edges,
 					 (*max_idx) * sizeof (edge));
 	    }
-	  crossing_edges[i++] = e;
+	  (*crossing_edges)[i++] = e;
 	}
       else
 	e->flags &= ~EDGE_CROSSING;
@@ -2168,7 +2168,7 @@ partition_hot_cold_basic_blocks (void)
 	&& cur_bb->next_bb->index >= NUM_FIXED_BLOCKS)
       cur_bb->aux = cur_bb->next_bb;
 
-  find_rarely_executed_basic_blocks_and_crossing_edges (crossing_edges,
+  find_rarely_executed_basic_blocks_and_crossing_edges (&crossing_edges,
 							&n_crossing_edges,
 							&max_edges);
 
--- collect2.c
+++ collect2.c
@@ -737,6 +737,7 @@ prefix_from_string (const char *p, struc
       else
 	endp++;
     }
+  free (nstore);
 }
 
 /* Main program.  */
--- reload1.c
+++ reload1.c
@@ -8632,6 +8632,7 @@ fixup_abnormal_edges (void)
       blocks = sbitmap_alloc (last_basic_block);
       sbitmap_ones (blocks);
       find_many_sub_basic_blocks (blocks);
+      sbitmap_free (blocks);
     }
 
   if (inserted)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]