From: Richard Biener Date: Fri, 9 Oct 2020 07:47:44 +0000 (+0200) Subject: random memory leak fixes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a0e6e49ddedb05e2e112e5c19a2228efd016e871;p=gcc.git random memory leak fixes This fixes leaks discovered checking whether I introduced new ones with the last vectorizer changes. 2020-10-09 Richard Biener * 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. --- diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index bedb6e2eea1..19ae8763373 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -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. */ diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index 5868aa97484..c22c0d233f7 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -1748,6 +1748,7 @@ pass_ipa_modref::execute (function *) } ((modref_summaries *)summaries)->ipa = false; ipa_free_postorder_info (); + free (order); return 0; } diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 45747e150f4..697d30fb989 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -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); diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 5bf93e2942b..676182c0888 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -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 (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. */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index ce5d95d7277..0a315e22226 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -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 diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index dbe76ac7251..77ea4d0eb51 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3783,7 +3783,7 @@ static bool vect_slp_bbs (vec bbs) { vec datarefs = vNULL; - vec dataref_groups = vNULL; + auto_vec dataref_groups; int insns = 0; int current_group = 0;