diff mbox

Free redirect_callers vector in tree-sra.c

Message ID alpine.LNX.2.00.1208161615080.28649@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Aug. 16, 2012, 2:17 p.m. UTC
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  <rguenther@suse.de>

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

Comments

Richard Biener Aug. 16, 2012, 3:21 p.m. UTC | #1
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  <rguenther@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));
>  
>
diff mbox

Patch

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));