random memory leak fixes
authorRichard Biener <rguenther@suse.de>
Fri, 9 Oct 2020 07:47:44 +0000 (09:47 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 9 Oct 2020 08:40:44 +0000 (10:40 +0200)
This fixes leaks discovered checking whether I introduced new ones
with the last vectorizer changes.

2020-10-09  Richard Biener  <rguenther@suse.de>

* cgraphunit.c (expand_all_functions): Free tp_first_run_order.
* ipa-modref.c (pass_ipa_modref::execute): Free order.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations): Free
loop body.
* tree-vect-data-refs.c (vect_find_stmt_data_reference): Free
data references upon failure.
* tree-vect-loop.c (update_epilogue_loop_vinfo): Free BBs
array of the original loop.
* tree-vect-slp.c (vect_slp_bbs): Use an auto_vec for
dataref_groups to release its memory.

gcc/cgraphunit.c
gcc/ipa-modref.c
gcc/tree-ssa-loop-niter.c
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop.c
gcc/tree-vect-slp.c

index bedb6e2..19ae876 100644 (file)
@@ -2494,6 +2494,7 @@ expand_all_functions (void)
   delete ipa_saved_clone_sources;
   ipa_saved_clone_sources = NULL;
   free (order);
+  free (tp_first_run_order);
 }
 
 /* This is used to sort the node types by the cgraph order number.  */
index 5868aa9..c22c0d2 100644 (file)
@@ -1748,6 +1748,7 @@ pass_ipa_modref::execute (function *)
     }
   ((modref_summaries *)summaries)->ipa = false;
   ipa_free_postorder_info ();
+  free (order);
   return 0;
 }
 
index 45747e1..697d30f 100644 (file)
@@ -4305,6 +4305,7 @@ estimate_numbers_of_iterations (class loop *loop)
 
   if (flag_aggressive_loop_optimizations)
     infer_loop_bounds_from_undefined (loop, body);
+  free (body);
 
   discover_iteration_bound_by_body_walk (loop);
 
index 5bf93e2..676182c 100644 (file)
@@ -4045,29 +4045,42 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt,
     return opt_result::success ();
 
   if (refs.length () > 1)
-    return opt_result::failure_at (stmt,
-                                  "not vectorized:"
-                                  " more than one data ref in stmt: %G", stmt);
+    {
+      while (!refs.is_empty ())
+       free_data_ref (refs.pop ());
+      return opt_result::failure_at (stmt,
+                                    "not vectorized: more than one "
+                                    "data ref in stmt: %G", stmt);
+    }
 
+  data_reference_p dr = refs.pop ();
   if (gcall *call = dyn_cast <gcall *> (stmt))
     if (!gimple_call_internal_p (call)
        || (gimple_call_internal_fn (call) != IFN_MASK_LOAD
            && gimple_call_internal_fn (call) != IFN_MASK_STORE))
-      return opt_result::failure_at (stmt,
-                                    "not vectorized: dr in a call %G", stmt);
+      {
+       free_data_ref (dr);
+       return opt_result::failure_at (stmt,
+                                      "not vectorized: dr in a call %G", stmt);
+      }
 
-  data_reference_p dr = refs.pop ();
   if (TREE_CODE (DR_REF (dr)) == COMPONENT_REF
       && DECL_BIT_FIELD (TREE_OPERAND (DR_REF (dr), 1)))
-    return opt_result::failure_at (stmt,
-                                  "not vectorized:"
-                                  " statement is bitfield access %G", stmt);
+    {
+      free_data_ref (dr);
+      return opt_result::failure_at (stmt,
+                                    "not vectorized:"
+                                    " statement is bitfield access %G", stmt);
+    }
 
   if (DR_BASE_ADDRESS (dr)
       && TREE_CODE (DR_BASE_ADDRESS (dr)) == INTEGER_CST)
-    return opt_result::failure_at (stmt,
-                                  "not vectorized:"
-                                  " base addr of dr is a constant\n");
+    {
+      free_data_ref (dr);
+      return opt_result::failure_at (stmt,
+                                    "not vectorized:"
+                                    " base addr of dr is a constant\n");
+    }
 
   /* Check whether this may be a SIMD lane access and adjust the
      DR to make it easier for us to handle it.  */
index ce5d95d..0a315e2 100644 (file)
@@ -8817,6 +8817,7 @@ update_epilogue_loop_vinfo (class loop *epilogue, tree advance)
   basic_block *epilogue_bbs = get_loop_body (epilogue);
   unsigned i;
 
+  free (LOOP_VINFO_BBS (epilogue_vinfo));
   LOOP_VINFO_BBS (epilogue_vinfo) = epilogue_bbs;
 
   /* Advance data_reference's with the number of iterations of the previous
index dbe76ac..77ea4d0 100644 (file)
@@ -3783,7 +3783,7 @@ static bool
 vect_slp_bbs (vec<basic_block> bbs)
 {
   vec<data_reference_p> datarefs = vNULL;
-  vec<int> dataref_groups = vNULL;
+  auto_vec<int> dataref_groups;
   int insns = 0;
   int current_group = 0;