fix memory leaks
authorRichard Biener <rguenther@suse.de>
Tue, 2 Feb 2021 18:21:02 +0000 (19:21 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 2 Feb 2021 19:07:30 +0000 (20:07 +0100)
This fixes various vec<> memory leaks as discovered compiling 521.wrf_r.

2021-02-02  Richard Biener  <rguenther@suse.de>

* gimple-loop-interchange.cc (prepare_data_references):
Release vectors.
* gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise.
* tree-ssa-loop-im.c (hoist_memory_references): Likewise.
* tree-vect-stmts.c (vectorizable_condition): Do not
allocate vectors.
(vectorizable_comparison): Likewise.

gcc/gimple-loop-interchange.cc
gcc/gimple-loop-jam.c
gcc/tree-ssa-loop-im.c
gcc/tree-vect-stmts.c

index a1dadd8e5d477d0275663a67490b6cc6fb3f3f5f..f45b9364644413d0502ca1313a2fbf7e230d28d6 100644 (file)
@@ -1940,7 +1940,10 @@ prepare_data_references (class loop *loop, vec<data_reference_p> *datarefs)
           delete bb_refs;
         }
       else if (bb_refs->is_empty ())
-       delete bb_refs;
+       {
+         bb_refs->release ();
+         delete bb_refs;
+       }
       else
        bb->aux = bb_refs;
     }
@@ -1954,7 +1957,10 @@ prepare_data_references (class loop *loop, vec<data_reference_p> *datarefs)
 
       bb_refs = (vec<data_reference_p> *) bb->aux;
       if (loop_nest && flow_bb_inside_loop_p (loop_nest, bb))
-       datarefs->safe_splice (*bb_refs);
+       {
+         datarefs->safe_splice (*bb_refs);
+         bb_refs->release ();
+       }
       else
        free_data_refs (*bb_refs);
 
index 485f5a9bf613b0e757f6ffbf6f6ff23f83ff7267..69dbaeb6cb9cabdb8900fd57a1b93fd716d30e46 100644 (file)
@@ -505,15 +505,13 @@ tree_loop_unroll_and_jam (void)
       if (!unroll_jam_possible_p (outer, loop))
        continue;
 
-      vec<data_reference_p> datarefs;
-      vec<ddr_p> dependences;
+      vec<data_reference_p> datarefs = vNULL;
+      vec<ddr_p> dependences = vNULL;
       unsigned unroll_factor, profit_unroll, removed;
       class tree_niter_desc desc;
       bool unroll = false;
 
       auto_vec<loop_p, 3> loop_nest;
-      dependences.create (10);
-      datarefs.create (10);
       if (!compute_data_dependences_for_loop (outer, true, &loop_nest,
                                              &datarefs, &dependences))
        {
index 445b93f79790c3762381626fbbe6cdc0f2926780..8034cf68d276f45f1b2bccacb6d6122a31a03541 100644 (file)
@@ -2508,6 +2508,7 @@ hoist_memory_references (class loop *loop, bitmap mem_refs,
       if (res != 1)
        {
          bitmap_copy (refs_not_supported, mem_refs);
+         seq.release ();
          break;
        }
       sms.safe_push (std::make_pair (e, seq));
index f180ced312443ba1e698932d5e8362208690b3fc..5eb7b2d1d6e14151031b126dae82b27503443f8f 100644 (file)
@@ -10085,14 +10085,6 @@ vectorizable_condition (vec_info *vinfo,
 
   /* Transform.  */
 
-  if (!slp_node)
-    {
-      vec_oprnds0.create (1);
-      vec_oprnds1.create (1);
-      vec_oprnds2.create (1);
-      vec_oprnds3.create (1);
-    }
-
   /* Handle def.  */
   scalar_dest = gimple_assign_lhs (stmt);
   if (reduction_type != EXTRACT_LAST_REDUCTION)
@@ -10480,11 +10472,6 @@ vectorizable_comparison (vec_info *vinfo,
     }
 
   /* Transform.  */
-  if (!slp_node)
-    {
-      vec_oprnds0.create (1);
-      vec_oprnds1.create (1);
-    }
 
   /* Handle def.  */
   lhs = gimple_assign_lhs (stmt);