From 57ec9b687b0c1d83e477b7b7433c11d814489259 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 29 Oct 2020 17:02:13 +0100 Subject: [PATCH] Fix some memleaks This fixes some memleaks, one older, one recently introduced. 2020-10-29 Richard Biener * tree-ssa-pre.c (compute_avail): Free operands consistently. * tree-vect-loop.c (vectorizable_phi): Make sure all operand defs vectors are released. --- gcc/tree-ssa-pre.c | 5 ++++- gcc/tree-vect-loop.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 63f3a81e94c..bcef9720095 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3953,7 +3953,10 @@ compute_avail (void) adding the reference to EXP_GEN. */ if (BB_MAY_NOTRETURN (block) && vn_reference_may_trap (ref)) - continue; + { + operands.release (); + continue; + } /* If the value of the reference is not invalidated in this block until it is computed, add the expression diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 75b731407ba..5ab125d15c6 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -7570,7 +7570,6 @@ vectorizable_phi (vec_info *, tree scalar_dest = gimple_phi_result (stmt_info->stmt); basic_block bb = gimple_bb (stmt_info->stmt); tree vec_dest = vect_create_destination_var (scalar_dest, vectype); - auto_vec vec_oprnds; auto_vec new_phis; for (unsigned i = 0; i < gimple_phi_num_args (stmt_info->stmt); ++i) { @@ -7581,6 +7580,7 @@ vectorizable_phi (vec_info *, && SLP_TREE_VEC_STMTS (child).is_empty ()) continue; + auto_vec vec_oprnds; vect_get_slp_defs (SLP_TREE_CHILDREN (slp_node)[i], &vec_oprnds); if (!new_phis.exists ()) { -- 2.30.2