Fix various memory leaks
authorMartin Liska <mliska@suse.cz>
Wed, 11 Nov 2015 11:21:44 +0000 (12:21 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 11 Nov 2015 11:21:44 +0000 (11:21 +0000)
* gimple-ssa-strength-reduction.c (create_phi_basis):
Use auto_vec.
* passes.c (release_dump_file_name): New function.
(pass_init_dump_file): Used from this function.
(pass_fini_dump_file): Likewise.
* tree-sra.c (convert_callers_for_node): Use xstrdup_for_dump.
* var-tracking.c (vt_initialize): Use pool_allocator.

From-SVN: r230152

gcc/ChangeLog
gcc/gimple-ssa-strength-reduction.c
gcc/passes.c
gcc/tree-sra.c
gcc/var-tracking.c

index ad69a402d51da9b47b31e291cb4b44d4ee87dbe3..13ed0d8256c768e6934f8044e6f43720c6949533 100644 (file)
@@ -1,3 +1,13 @@
+2015-11-11  Martin Liska  <mliska@suse.cz>
+
+       * gimple-ssa-strength-reduction.c (create_phi_basis):
+       Use auto_vec.
+       * passes.c (release_dump_file_name): New function.
+       (pass_init_dump_file): Used from this function.
+       (pass_fini_dump_file): Likewise.
+       * tree-sra.c (convert_callers_for_node): Use xstrdup_for_dump.
+       * var-tracking.c (vt_initialize): Use pool_allocator.
+
 2015-11-11  Richard Biener  <rguenth@gcc.gnu.org>
            Jiong Wang      <jiong.wang@arm.com>
 
index ce32ad33e94bff884c17f3772415bae5f531c99d..b8078230f340241b030f48a6fade564a22859b40 100644 (file)
@@ -2226,12 +2226,11 @@ create_phi_basis (slsr_cand_t c, gimple *from_phi, tree basis_name,
   int i;
   tree name, phi_arg;
   gphi *phi;
-  vec<tree> phi_args;
   slsr_cand_t basis = lookup_cand (c->basis);
   int nargs = gimple_phi_num_args (from_phi);
   basic_block phi_bb = gimple_bb (from_phi);
   slsr_cand_t phi_cand = base_cand_from_table (gimple_phi_result (from_phi));
-  phi_args.create (nargs);
+  auto_vec<tree> phi_args (nargs);
 
   /* Process each argument of the existing phi that represents
      conditionally-executed add candidates.  */
index 7a10cb6334c2c770ef3f3ab7e646f4b9323cb342..dd8d00ad36af11ad728a2adf975d326acc6d716e 100644 (file)
@@ -2058,6 +2058,18 @@ verify_curr_properties (function *fn, void *data)
   gcc_assert ((fn->curr_properties & props) == props);
 }
 
+/* Release dump file name if set.  */
+
+static void
+release_dump_file_name (void)
+{
+  if (dump_file_name)
+    {
+      free (CONST_CAST (char *, dump_file_name));
+      dump_file_name = NULL;
+    }
+}
+
 /* Initialize pass dump file.  */
 /* This is non-static so that the plugins can use it.  */
 
@@ -2071,6 +2083,7 @@ pass_init_dump_file (opt_pass *pass)
       gcc::dump_manager *dumps = g->get_dumps ();
       bool initializing_dump =
        !dumps->dump_initialized_p (pass->static_pass_number);
+      release_dump_file_name ();
       dump_file_name = dumps->get_dump_file_name (pass->static_pass_number);
       dumps->dump_start (pass->static_pass_number, &dump_flags);
       if (dump_file && current_function_decl)
@@ -2098,11 +2111,7 @@ pass_fini_dump_file (opt_pass *pass)
   timevar_push (TV_DUMP);
 
   /* Flush and close dump file.  */
-  if (dump_file_name)
-    {
-      free (CONST_CAST (char *, dump_file_name));
-      dump_file_name = NULL;
-    }
+  release_dump_file_name ();
 
   g->get_dumps ()->dump_finish (pass->static_pass_number);
   timevar_pop (TV_DUMP);
index 30aee19aae746377ebd38eac877d9dd4d845463e..2835c993588bc73491d193e105109172d95cd5ae 100644 (file)
@@ -4996,9 +4996,9 @@ convert_callers_for_node (struct cgraph_node *node,
 
       if (dump_file)
        fprintf (dump_file, "Adjusting call %s/%i -> %s/%i\n",
-                xstrdup (cs->caller->name ()),
+                xstrdup_for_dump (cs->caller->name ()),
                 cs->caller->order,
-                xstrdup (cs->callee->name ()),
+                xstrdup_for_dump (cs->callee->name ()),
                 cs->callee->order);
 
       ipa_modify_call_arguments (cs, cs->call_stmt, *adjustments);
index 388b5348e5b535eeadbb280e8e99c0bbaba79655..9185bfd39cf5c033ecf77a16a8894f36a1d52490 100644 (file)
@@ -9814,7 +9814,7 @@ vt_initialize (void)
 
   alloc_aux_for_blocks (sizeof (variable_tracking_info));
 
-  empty_shared_hash = new shared_hash;
+  empty_shared_hash = shared_hash_pool.allocate ();
   empty_shared_hash->refcount = 1;
   empty_shared_hash->htab = new variable_table_type (1);
   changed_variables = new variable_table_type (10);