]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix dr_chain memleak in vectorizable_load
authorRichard Biener <rguenther@suse.de>
Wed, 19 Nov 2025 10:27:43 +0000 (11:27 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 19 Nov 2025 13:00:03 +0000 (14:00 +0100)
Figured while running a leak check on some new SLP code.

* tree-vect-stmts.cc (vectorizable_load): Make dr_chain
an auto_vec, move down to where we use it to avoid creating
it twice.

gcc/tree-vect-stmts.cc

index 07d476ac44f9a05dc9c900fecdf117abbbe34380..748b3bcb0ab038e602394c05a7b6eb526961ba8d 100644 (file)
@@ -9632,7 +9632,6 @@ vectorizable_load (vec_info *vinfo,
   tree msq = NULL_TREE, lsq;
   tree realignment_token = NULL_TREE;
   gphi *phi = NULL;
-  vec<tree> dr_chain = vNULL;
   bool grouped_load = false;
   stmt_vec_info first_stmt_info;
   stmt_vec_info first_stmt_info_for_drptr = NULL;
@@ -10428,7 +10427,6 @@ vectorizable_load (vec_info *vinfo,
        {
          group_gap_adj = group_size - scalar_lanes;
        }
-      dr_chain.create (vec_num);
 
       ref_type = get_group_alias_ptr_type (first_stmt_info);
     }
@@ -10764,6 +10762,8 @@ vectorizable_load (vec_info *vinfo,
     {
       gcc_assert ((!grouped_load && !ls.slp_perm) || ls.ls_type);
 
+      auto_vec<tree> dr_chain (vec_num);
+
       /* If we pun the original vectype the loads as well as costing, length,
         etc. is performed with the new type.  After loading we VIEW_CONVERT
         the data to the original vectype.  */
@@ -11261,6 +11261,7 @@ vectorizable_load (vec_info *vinfo,
                                       stmt_info, bump);
     }
 
+  auto_vec<tree> dr_chain;
   if (grouped_load || ls.slp_perm)
     dr_chain.create (vec_num);
 
@@ -11820,7 +11821,6 @@ vectorizable_load (vec_info *vinfo,
                                                  nullptr, true);
          gcc_assert (ok && ls.n_perms == n_perms2);
        }
-      dr_chain.release ();
     }
 
   if (costing_p)