diff mbox

[1/n] Fix minor SSA_NAME leaks

Message ID 5616ACF5.80902@redhat.com
State New
Headers show

Commit Message

Jeff Law Oct. 8, 2015, 5:50 p.m. UTC
This is the first of several patches to fix various SSA_NAME leaks 
throughout the compiler.  I'm hoping we'll get to the point where 
they're all plugged and we institute a no-leak policy in the SSA_NAME 
manager.

Until then, I'll be plugging leaks.  This one is pretty obvious.  We 
call gsi_remove to remove the statement, but never release the 
definitions back to the manager.  In this case we know the statements 
don't have any virtual operands, so gsi_remove;release_defs is the 
proper sequencing.

Bootstrapped and regression tested on x86_64-linux-gnu.  I've got a 
minimized test for the leak.  I pondered adding some debugging dump info 
for released names and could still do that and scan the debugging dumps 
to ensure things are released.  I figured that would bloat the debugging 
dumps horribly, so I didn't implement it.  I'm open to suggestions here.

Installed on the trunk.

Jeff
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b2e4f6a..9f84b6e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2015-10-08  Jeff Law  <law@redhat.com>
+
+	* tree-ssa-phiopt.c (factor_out_conversion): Add missing calls to
+	release_ssa_name.  Fix typo in comment.
+
 2015-10-08  Nathan Sidwell  <nathan@acm.org>
 
 	* config/nvptx/nvptx.h (struct machine_function): Add comment.
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index f33ca5c..cfa3868 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -511,10 +511,13 @@  factor_out_conditional_conversion (edge e0, edge e1, gphi *phi,
   /* Remove the old cast(s) that has single use.  */
   gsi_for_def = gsi_for_stmt (arg0_def_stmt);
   gsi_remove (&gsi_for_def, true);
+  release_defs (arg0_def_stmt);
+
   if (arg1_def_stmt)
     {
       gsi_for_def = gsi_for_stmt (arg1_def_stmt);
       gsi_remove (&gsi_for_def, true);
+      release_defs (arg1_def_stmt);
     }
 
   add_phi_arg (newphi, new_arg0, e0, locus);
@@ -527,7 +530,7 @@  factor_out_conditional_conversion (edge e0, edge e1, gphi *phi,
   gsi = gsi_after_labels (gimple_bb (phi));
   gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT);
 
-  /* Remove he original PHI stmt.  */
+  /* Remove the original PHI stmt.  */
   gsi = gsi_for_stmt (phi);
   gsi_remove (&gsi, true);
   return true;