diff mbox

Fix minor memory leak in jump threader

Message ID 555BEF9F.3010107@redhat.com
State New
Headers show

Commit Message

Jeff Law May 20, 2015, 2:21 a.m. UTC
Honza pointed out we were leaking some memory in the jump threading 
code.  There's at least two leaks, this fixes the first.

Bootstrapped and regression tested on x86_64-unknown-linux-gnu. 
Installed on the trunk.
commit f4517a9d2f17b0890d9fe1159a3981985bed5672
Author: Jeff Law <law@redhat.com>
Date:   Tue May 19 20:20:57 2015 -0600

           * tree-ssa-threadupdate.c (thread_single_edge): Use delete_jump_thread
            instead of open-coded version.  Also delete the jump thread created
            within this function.
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 95326a3..95114fa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@ 
+2015-05-20  Jeff Law  <law@redhat.com>
+
+	* tree-ssa-threadupdate.c (thread_single_edge): Use delete_jump_thread
+	instead of open-coded version.  Also delete the jump thread created
+	within this function.
+
 2015-05-20  Alan Modra  <amodra@gmail.com>
 
 	* config/rs6000/rs6000.c (rs6000_emit_allocate_stack): Return
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 0d61c18..c5b78a4 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -1647,9 +1647,7 @@  thread_single_edge (edge e)
   vec<jump_thread_edge *> *path = THREAD_PATH (e);
   edge eto = (*path)[1]->e;
 
-  for (unsigned int i = 0; i < path->length (); i++)
-    delete (*path)[i];
-  delete path;
+  delete_jump_thread_path (path);
   e->aux = NULL;
 
   thread_stats.num_threaded_edges++;
@@ -1693,6 +1691,7 @@  thread_single_edge (edge e)
   redirect_edge_and_branch (e, rd.dup_blocks[0]);
   flush_pending_stmts (e);
 
+  delete_jump_thread_path (npath);
   return rd.dup_blocks[0];
 }