From cfd3faacbfa0ba6b08d75b41f7f876961f70337b Mon Sep 17 00:00:00 2001 From: spop Date: Thu, 7 Jan 2010 18:32:51 +0000 Subject: [PATCH] Fix memory leaks. 2010-01-06 Sebastian Pop * graphite-clast-to-gimple.c (save_clast_name_index): Free slot before allocating a new one. (copy_renames): Check that slot is not NULL. (mark_bb_with_pbb): Same. (compute_cloog_iv_types_1): Same. * graphite-interchange.c (lst_perfect_nestify): Free the before, nest, and after LSTs. (lst_try_interchange_loops): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155702 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.graphite | 11 +++++++++++ gcc/graphite-clast-to-gimple.c | 13 +++++++++---- gcc/graphite-interchange.c | 18 +++++++++++++++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 882dc39b404..780f23eac1e 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,14 @@ +2010-01-06 Sebastian Pop + + * graphite-clast-to-gimple.c (save_clast_name_index): Free slot + before allocating a new one. + (copy_renames): Check that slot is not NULL. + (mark_bb_with_pbb): Same. + (compute_cloog_iv_types_1): Same. + * graphite-interchange.c (lst_perfect_nestify): Free the before, + nest, and after LSTs. + (lst_try_interchange_loops): Same. + 2010-01-05 Sebastian Pop PR middle-end/42178 diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 93138b6bd89..41094614f10 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -117,7 +117,12 @@ save_clast_name_index (htab_t index_table, const char *name, int index) slot = htab_find_slot (index_table, &tmp, INSERT); if (slot) - *slot = new_clast_name_index (name, index); + { + if (*slot) + free (*slot); + + *slot = new_clast_name_index (name, index); + } } /* Print to stderr the element ELT. */ @@ -629,7 +634,7 @@ copy_renames (void **slot, void *s) tmp.old_name = old_name; x = htab_find_slot (res, &tmp, INSERT); - if (!*x) + if (x && !*x) *x = new_rename_map_elt (old_name, expr); return 1; @@ -660,7 +665,7 @@ mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, htab_t bb_pbb_mapping) tmp.bb = bb; x = htab_find_slot (bb_pbb_mapping, &tmp, INSERT); - if (!*x) + if (x && !*x) *x = new_bb_pbb_def (bb, pbb); } @@ -1026,7 +1031,7 @@ compute_cloog_iv_types_1 (poly_bb_p pbb, struct clast_user_stmt *user_stmt) slot = htab_find_slot (GBB_CLOOG_IV_TYPES (gbb), &tmp, INSERT); - if (!*slot) + if (slot && !*slot) { tree oldiv = pbb_to_depth_to_oldiv (pbb, index); tree type = oldiv ? TREE_TYPE (oldiv) : integer_type_node; diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c index a0f84a76510..7ec7fead2f9 100644 --- a/gcc/graphite-interchange.c +++ b/gcc/graphite-interchange.c @@ -587,11 +587,20 @@ lst_perfect_nestify (lst_p loop1, lst_p loop2, lst_p *before, lst_remove_all_before_excluding_pbb (*nest, last, false); if (lst_empty_p (*before)) - *before = NULL; + { + free_lst (*before); + *before = NULL; + } if (lst_empty_p (*after)) - *after = NULL; + { + free_lst (*after); + *after = NULL; + } if (lst_empty_p (*nest)) - *nest = NULL; + { + free_lst (*nest); + *nest = NULL; + } } /* Try to interchange LOOP1 with LOOP2 for all the statements of the @@ -646,6 +655,9 @@ lst_try_interchange_loops (scop_p scop, lst_p loop1, lst_p loop2) } /* Undo the transform. */ + free_lst (before); + free_lst (nest); + free_lst (after); lst_apply_interchange (loop2, depth2, depth1); return false; } -- 2.11.0