aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-slp.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-12-02 14:43:59 +0100
committerRichard Biener <rguenther@suse.de>2020-12-02 15:55:18 +0100
commitfeb93adf76eda52385a73eb57c5bef7c870a2564 (patch)
treeab341ac008fc8dbb5f504d4850d989a1f09bf142 /gcc/tree-vect-slp.c
parentbad800c03d00a57fc21718c160459d9a1e8d747a (diff)
downloadgcc-feb93adf76eda52385a73eb57c5bef7c870a2564.zip
gcc-feb93adf76eda52385a73eb57c5bef7c870a2564.tar.gz
gcc-feb93adf76eda52385a73eb57c5bef7c870a2564.tar.bz2
tree-optimization/97630 - fix SLP cycle memory leak
This fixes SLP cycles leaking memory by maintaining a double-linked list of allocatd SLP nodes we can zap when we free the alloc pool. 2020-12-02 Richard Biener <rguenther@suse.de> PR tree-optimization/97630 * tree-vectorizer.h (_slp_tree::next_node, _slp_tree::prev_node): New. (vect_slp_init): Declare. (vect_slp_fini): Likewise. * tree-vectorizer.c (vectorize_loops): Call vect_slp_init/fini. (pass_slp_vectorize::execute): Likewise. * tree-vect-slp.c (vect_slp_init): New. (vect_slp_fini): Likewise. (slp_first_node): New global. (_slp_tree::_slp_tree): Link node into the SLP tree list. (_slp_tree::~_slp_tree): Delink node from the SLP tree list.
Diffstat (limited to 'gcc/tree-vect-slp.c')
-rw-r--r--gcc/tree-vect-slp.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index da3ef43..3bd40cb 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -48,11 +48,28 @@ along with GCC; see the file COPYING3. If not see
#include "cfganal.h"
#include "tree-eh.h"
#include "tree-cfg.h"
+#include "alloc-pool.h"
static bool vectorizable_slp_permutation (vec_info *, gimple_stmt_iterator *,
slp_tree, stmt_vector_for_cost *);
-object_allocator<_slp_tree> *slp_tree_pool;
+static object_allocator<_slp_tree> *slp_tree_pool;
+static slp_tree slp_first_node;
+
+void
+vect_slp_init (void)
+{
+ slp_tree_pool = new object_allocator<_slp_tree> ("SLP nodes");
+}
+
+void
+vect_slp_fini (void)
+{
+ while (slp_first_node)
+ delete slp_first_node;
+ delete slp_tree_pool;
+ slp_tree_pool = NULL;
+}
void *
_slp_tree::operator new (size_t n)
@@ -73,6 +90,11 @@ _slp_tree::operator delete (void *node, size_t n)
_slp_tree::_slp_tree ()
{
+ this->prev_node = NULL;
+ if (slp_first_node)
+ slp_first_node->prev_node = this;
+ this->next_node = slp_first_node;
+ slp_first_node = this;
SLP_TREE_SCALAR_STMTS (this) = vNULL;
SLP_TREE_SCALAR_OPS (this) = vNULL;
SLP_TREE_VEC_STMTS (this) = vNULL;
@@ -94,6 +116,12 @@ _slp_tree::_slp_tree ()
_slp_tree::~_slp_tree ()
{
+ if (this->prev_node)
+ this->prev_node->next_node = this->next_node;
+ else
+ slp_first_node = this->next_node;
+ if (this->next_node)
+ this->next_node->prev_node = this->prev_node;
SLP_TREE_CHILDREN (this).release ();
SLP_TREE_SCALAR_STMTS (this).release ();
SLP_TREE_SCALAR_OPS (this).release ();