]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix leak of SLP nodes when building store interleaving
authorRichard Biener <rguenther@suse.de>
Wed, 28 Aug 2024 09:04:07 +0000 (11:04 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 28 Aug 2024 10:44:46 +0000 (12:44 +0200)
The following fixes a leak of the discovered single-lane store
SLP nodes from which we only use their children.  This uncovers
a latent reference counting issue in the interleaving build where
we fail to increment their reference count.

* tree-vect-slp.cc (vect_build_slp_store_interleaving):
Fix reference counting.
(vect_build_slp_instance): Release rhs_nodes.

gcc/tree-vect-slp.cc

index 79d83efb01598f809431d834410c5eb2d81c4630..d110c992b046d4d89ffc77a70fecf98510fadb3b 100644 (file)
@@ -3486,6 +3486,7 @@ vect_build_slp_store_interleaving (vec<slp_tree> &rhs_nodes,
        {
          SLP_TREE_CHILDREN (perm)
            .quick_push (SLP_TREE_CHILDREN (rhs_nodes[j])[l]);
+         SLP_TREE_CHILDREN (rhs_nodes[j])[l]->refcnt++;
          for (unsigned k = 0;
               k < SLP_TREE_SCALAR_STMTS (rhs_nodes[j]).length (); ++k)
            {
@@ -3949,6 +3950,9 @@ vect_build_slp_instance (vec_info *vinfo,
          /* Now we assume we can build the root SLP node from all stores.  */
          node = vect_build_slp_store_interleaving (rhs_nodes, scalar_stmts);
 
+         while (!rhs_nodes.is_empty ())
+           vect_free_slp_tree (rhs_nodes.pop ());
+
          /* Create a new SLP instance.  */
          slp_instance new_instance = XNEW (class _slp_instance);
          SLP_INSTANCE_TREE (new_instance) = node;