fix vectorizer memleaks
authorRichard Biener <rguenther@suse.de>
Fri, 8 Jan 2021 13:22:00 +0000 (14:22 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 8 Jan 2021 13:23:44 +0000 (14:23 +0100)
This plugs two memleaks in the vectorizer.

2021-01-08  Richard Biener  <rguenther@suse.de>

* 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
gcc/tree-vect-stmts.c

index e0f3539aa54e8a5165acdb75fd222bae628d3f33..e7191ed3267378638e45ddb02b88af0c50ecb116 100644 (file)
@@ -1378,7 +1378,7 @@ bst_traits::equal (value_type existing, value_type candidate)
   return true;
 }
 
-typedef hash_map <vec <gimple *>, slp_tree,
+typedef hash_map <vec <stmt_vec_info>, slp_tree,
                  simple_hashmap_traits <bst_traits, slp_tree> >
   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;
     }
index 014f1aff4c1bbda55c431635f72e0382ff77401e..068e49823035f9223cada9e4162e777aa56d1f2e 100644 (file)
@@ -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;
     }