On Fri, 10 Jan 2025, Richard Biener wrote: > The following were found compiling SPEC CPU 2017 with valgrind. > > Bootstrap and regtest pending on x86_64-unknown-linux-gnu. > > * tree-vect-slp.cc (vect_analyze_slp): Release saved_stmts > vector. > (vect_build_slp_tree_2): Release new_oprnds_info when not > used.
I sneaked in one more fix, pushed as follows after bootstrapping and regtesting on x86_64-unknown-linux-gnu. >From 0b0a460f80b16c0d7dba402a0f5dfa2cff7a8a56 Mon Sep 17 00:00:00 2001 From: Richard Biener <rguent...@suse.de> Date: Fri, 10 Jan 2025 16:25:35 +0100 Subject: [PATCH] More memory leak fixes To: gcc-patches@gcc.gnu.org The following were found compiling SPEC CPU 2017 with valgrind. * tree-vect-slp.cc (vect_analyze_slp): Release saved_stmts vector. (vect_build_slp_tree_2): Release new_oprnds_info when not used. (vect_analyze_slp): Release root_stmts when gcond SLP build fails. --- gcc/tree-vect-slp.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 337506419d9..02e7f5c4d58 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -2678,6 +2678,8 @@ out: nops = 1; has_two_operators_perm = true; } + else + vect_free_oprnd_info (new_oprnds_info); } auto_vec<slp_tree, 4> children; @@ -4951,8 +4953,8 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size, max_tree_size, &limit, bst_map, NULL, force_single_lane); } - saved_stmts.release (); } + saved_stmts.release (); } /* Make sure to vectorize only-live stmts, usually inductions. */ @@ -5013,10 +5015,11 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size, stmts.create (1); stmts.quick_push (vect_stmt_to_vectorize (varg)); - vect_build_slp_instance (vinfo, slp_inst_kind_gcond, - stmts, roots, remain, - max_tree_size, &limit, - bst_map, NULL, force_single_lane); + if (! vect_build_slp_instance (vinfo, slp_inst_kind_gcond, + stmts, roots, remain, + max_tree_size, &limit, + bst_map, NULL, force_single_lane)) + roots.release (); } /* Find and create slp instances for inductions that have been forced -- 2.43.0