From b407f233d7c18534fbfe8f74af7f0232498fb0c4 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 8 Jan 2021 14:22:00 +0100 Subject: [PATCH] fix vectorizer memleaks This plugs two memleaks in the vectorizer. 2021-01-08 Richard Biener * tree-vect-slp.c (scalar_stmts_to_slp_tree_map_t): Fix. (vect_build_slp_tree): On cache hit release the matched scalar stmts vector. * tree-vect-stmts.c (vectorizable_store): Properly free vec_oprnds before possibly gathering them again. --- gcc/tree-vect-slp.c | 3 ++- gcc/tree-vect-stmts.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index e0f3539aa54..e7191ed3267 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1378,7 +1378,7 @@ bst_traits::equal (value_type existing, value_type candidate) return true; } -typedef hash_map , slp_tree, +typedef hash_map , slp_tree, simple_hashmap_traits > scalar_stmts_to_slp_tree_map_t; @@ -1405,6 +1405,7 @@ vect_build_slp_tree (vec_info *vinfo, { SLP_TREE_REF_COUNT (*leader)++; vect_update_max_nunits (max_nunits, (*leader)->max_nunits); + stmts.release (); } return *leader; } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 014f1aff4c1..068e4982303 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -7717,11 +7717,11 @@ vectorizable_store (vec_info *vinfo, } } next_stmt_info = DR_GROUP_NEXT_ELEMENT (next_stmt_info); + vec_oprnds.release (); if (slp) break; } - vec_oprnds.release (); return true; } -- 2.30.2