This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix memory leak in tree-data-ref.c
- From: "Sebastian Pop" <sebpop at gmail dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 16 Jan 2008 01:14:46 -0600
- Subject: [patch] Fix memory leak in tree-data-ref.c
Hi,
Using the testcase from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23821
there is a memory leak when compiled with -O3:
valgrind --leak-check=full cc1 -O3 pr23821.c
==16671== 24 bytes in 2 blocks are definitely lost in loss record 1 of 6
==16671== at 0x401C6CA: calloc (vg_replace_malloc.c:279)
==16671== by 0x8A36277: xcalloc (xmalloc.c:162)
==16671== by 0x84CC080: conflict_fn_not_known (tree-data-ref.c:1064)
==16671== by 0x84CD698: initialize_data_dependence_relation
(tree-data-ref.c:1321)
==16671== by 0x84D8EEA: compute_all_dependences (tree-data-ref.c:3939)
==16671== by 0x84DA22A: compute_data_dependences_for_loop
(tree-data-ref.c:4169)
==16671== by 0x8538F2D: tree_predictive_commoning_loop (tree-predcom.c:2496)
==16671== by 0x85392F9: tree_predictive_commoning (tree-predcom.c:2605)
==16671== by 0x86061EA: run_tree_predictive_commoning (tree-ssa-loop.c:183)
==16671== by 0x83DB9F9: execute_one_pass (passes.c:1118)
==16671== by 0x83DBB49: execute_pass_list (passes.c:1171)
==16671== by 0x83DBB65: execute_pass_list (passes.c:1172)
Fixed by the attached patch. I'm regstrapping the patch on i686-linux.
--
Sebastian
AMD - GNU Tools
* tree-data-ref.c (subscript_dependence_tester_1): Call
free_conflict_function.
(compute_self_dependence): Same.
Index: tree-data-ref.c
===================================================================
--- tree-data-ref.c (revision 131555)
+++ tree-data-ref.c (working copy)
@@ -3205,6 +3205,11 @@ subscript_dependence_tester_1 (struct da
else
{
+ if (SUB_CONFLICTS_IN_A (subscript))
+ free_conflict_function (SUB_CONFLICTS_IN_A (subscript));
+ if (SUB_CONFLICTS_IN_B (subscript))
+ free_conflict_function (SUB_CONFLICTS_IN_B (subscript));
+
SUB_CONFLICTS_IN_A (subscript) = overlaps_a;
SUB_CONFLICTS_IN_B (subscript) = overlaps_b;
SUB_LAST_CONFLICT (subscript) = last_conflicts;
@@ -3896,11 +3901,16 @@ compute_self_dependence (struct data_dep
for (i = 0; VEC_iterate (subscript_p, DDR_SUBSCRIPTS (ddr), i, subscript);
i++)
{
+ if (SUB_CONFLICTS_IN_A (subscript))
+ free_conflict_function (SUB_CONFLICTS_IN_A (subscript));
+ if (SUB_CONFLICTS_IN_B (subscript))
+ free_conflict_function (SUB_CONFLICTS_IN_B (subscript));
+
/* The accessed index overlaps for each iteration. */
SUB_CONFLICTS_IN_A (subscript)
- = conflict_fn (1, affine_fn_cst (integer_zero_node));
+ = conflict_fn (1, affine_fn_cst (integer_zero_node));
SUB_CONFLICTS_IN_B (subscript)
- = conflict_fn (1, affine_fn_cst (integer_zero_node));
+ = conflict_fn (1, affine_fn_cst (integer_zero_node));
SUB_LAST_CONFLICT (subscript) = chrec_dont_know;
}