This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix vectorizer memory leak
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Dec 2015 09:19:35 +0100 (CET)
- Subject: [PATCH] Fix vectorizer memory leak
- Authentication-results: sourceware.org; auth=none
This fixes the observed memory leak in the correct way, asserting that
overwriting of a vinfo doesn't happen.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2015-12-09 Richard Biener <rguenther@suse.de>
* tree-vect-stmts.c (vectorizable_load): Set new vinfo only
if it was not yet set.
* tree-vectorizer.h (set_vinfo_for_stmt): Assert we don't
overwrite an existing entry.
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c (revision 231355)
+++ gcc/tree-vect-stmts.c (working copy)
@@ -7276,6 +7337,9 @@ vectorizable_load (gimple *stmt, gimple_
unshare_expr
(gimple_assign_rhs1 (stmt))));
new_temp = vect_init_vector (stmt, tem, vectype, NULL);
+ new_stmt = SSA_NAME_DEF_STMT (new_temp);
+ set_vinfo_for_stmt (new_stmt,
+ new_stmt_vec_info (new_stmt, vinfo));
}
else
{
@@ -7283,10 +7347,8 @@ vectorizable_load (gimple *stmt, gimple_
gsi_next (&gsi2);
new_temp = vect_init_vector (stmt, scalar_dest,
vectype, &gsi2);
+ new_stmt = SSA_NAME_DEF_STMT (new_temp);
}
- new_stmt = SSA_NAME_DEF_STMT (new_temp);
- set_vinfo_for_stmt (new_stmt,
- new_stmt_vec_info (new_stmt, vinfo));
}
if (negative)
Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h (revision 231355)
+++ gcc/tree-vectorizer.h (working copy)
@@ -715,7 +715,10 @@ set_vinfo_for_stmt (gimple *stmt, stmt_v
stmt_vec_info_vec.safe_push (info);
}
else
- stmt_vec_info_vec[uid - 1] = info;
+ {
+ gcc_checking_assert (info == NULL);
+ stmt_vec_info_vec[uid - 1] = info;
+ }
}
/* Return the earlier statement between STMT1 and STMT2. */