[PATCH] Free redirect_callers vector in tree-sra.c

2012-08-16 Thread Richard Guenther

I noticed we leak the redirect_callers vector in SRA and also noticed
we compute it and then immediately re-compute cgraph edges which
looks weird to me.

Thus the following patch which frees the vector and makes its lifetime
more obvious.

Queued for testing.

Richard.

2012-08-16  Richard Guenther  rguent...@suse.de

* tree-sra.c (modify_function): Collect callers after rebuilding
cgraph edges.  Free caller vector.

Index: gcc/tree-sra.c
===
--- gcc/tree-sra.c  (revision 190442)
+++ gcc/tree-sra.c  (working copy)
@@ -4689,15 +4689,18 @@ modify_function (struct cgraph_node *nod
 {
   struct cgraph_node *new_node;
   bool cfg_changed;
-  VEC (cgraph_edge_p, heap) * redirect_callers = collect_callers_of_node 
(node);
+  VEC (cgraph_edge_p, heap) * redirect_callers;
 
   rebuild_cgraph_edges ();
   free_dominance_info (CDI_DOMINATORS);
   pop_cfun ();
   current_function_decl = NULL_TREE;
 
+  redirect_callers = collect_callers_of_node (node);
   new_node = cgraph_function_versioning (node, redirect_callers, NULL, NULL,
 false, NULL, NULL, isra);
+  VEC_free (cgraph_edge_p, heap, redirect_callers);
+
   current_function_decl = new_node-symbol.decl;
   push_cfun (DECL_STRUCT_FUNCTION (new_node-symbol.decl));
 


Re: [PATCH] Free redirect_callers vector in tree-sra.c

2012-08-16 Thread Richard Guenther
On Thu, 16 Aug 2012, Richard Guenther wrote:

 
 I noticed we leak the redirect_callers vector in SRA and also noticed
 we compute it and then immediately re-compute cgraph edges which
 looks weird to me.
 
 Thus the following patch which frees the vector and makes its lifetime
 more obvious.
 
 Queued for testing.

The re-ordering fails gcc.dg/ipa/ipa-sra-6.c, I'll re-do without that.

Richard.

 Richard.
 
 2012-08-16  Richard Guenther  rguent...@suse.de
 
   * tree-sra.c (modify_function): Collect callers after rebuilding
   cgraph edges.  Free caller vector.
 
 Index: gcc/tree-sra.c
 ===
 --- gcc/tree-sra.c(revision 190442)
 +++ gcc/tree-sra.c(working copy)
 @@ -4689,15 +4689,18 @@ modify_function (struct cgraph_node *nod
  {
struct cgraph_node *new_node;
bool cfg_changed;
 -  VEC (cgraph_edge_p, heap) * redirect_callers = collect_callers_of_node 
 (node);
 +  VEC (cgraph_edge_p, heap) * redirect_callers;
  
rebuild_cgraph_edges ();
free_dominance_info (CDI_DOMINATORS);
pop_cfun ();
current_function_decl = NULL_TREE;
  
 +  redirect_callers = collect_callers_of_node (node);
new_node = cgraph_function_versioning (node, redirect_callers, NULL, NULL,
false, NULL, NULL, isra);
 +  VEC_free (cgraph_edge_p, heap, redirect_callers);
 +
current_function_decl = new_node-symbol.decl;
push_cfun (DECL_STRUCT_FUNCTION (new_node-symbol.decl));
  
 

-- 
Richard Guenther rguent...@suse.de
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend