diff options
author | Martin Liska <mliska@suse.cz> | 2015-11-27 10:36:20 +0100 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2015-11-27 09:36:20 +0000 |
commit | b58d3df29fd0c37a2d5115fc9c708cffcc379ffc (patch) | |
tree | dd1adb68f7048a3707687ccc46f906e3f92b822d /gcc/cp/cp-array-notation.c | |
parent | 4d95edca1212e23855e4f613b588cbc6dac89999 (diff) | |
download | gcc-b58d3df29fd0c37a2d5115fc9c708cffcc379ffc.zip gcc-b58d3df29fd0c37a2d5115fc9c708cffcc379ffc.tar.gz gcc-b58d3df29fd0c37a2d5115fc9c708cffcc379ffc.tar.bz2 |
Fix memory leak in cilk
PR c++/68312
* c-array-notation.c (fix_builtin_array_notation_fn):
Use release_vec_vec instead of vec::release.
(build_array_notation_expr): Likewise.
(fix_conditional_array_notations_1): Likewise.
(fix_array_notation_expr): Likewise.
(fix_array_notation_call_expr): Likewise.
PR c++/68312
* cp-array-notation.c (expand_sec_reduce_builtin):
Likewise.
(create_array_refs): Replace argument with const reference.
(expand_an_in_modify_expr): Likewise.
(cp_expand_cond_array_notations): Likewise.
(expand_unary_array_notation_exprs): Likewise.
PR c++/68312
* array-notation-common.c (cilkplus_extract_an_triplets):
Release vector of vectors.
* cilk.c (gimplify_cilk_spawn): Free allocated memory.
PR c++/68312
* vec.h (release_vec_vec): New function.
From-SVN: r231001
Diffstat (limited to 'gcc/cp/cp-array-notation.c')
-rw-r--r-- | gcc/cp/cp-array-notation.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 84d7925..8862af1 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -210,7 +210,7 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var) enum tree_code code = NOP_EXPR; location_t location = UNKNOWN_LOCATION; vec<vec<an_parts> > an_info = vNULL; - vec<an_loop_parts> an_loop_info = vNULL; + auto_vec<an_loop_parts> an_loop_info; enum built_in_function an_type = is_cilkplus_reduce_builtin (CALL_EXPR_FN (an_builtin_fn)); vec <tree, va_gc> *func_args; @@ -494,8 +494,7 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var) } append_to_statement_list (body, &loop_with_init); - an_info.release (); - an_loop_info.release (); + release_vec_vec (an_info); return loop_with_init; } @@ -512,7 +511,7 @@ expand_an_in_modify_expr (location_t location, tree lhs, tree array_expr_lhs = NULL_TREE, array_expr_rhs = NULL_TREE; tree array_expr = NULL_TREE; tree body = NULL_TREE; - vec<tree> cond_expr = vNULL; + auto_vec<tree> cond_expr; vec<tree, va_gc> *lhs_array_operand = NULL, *rhs_array_operand = NULL; size_t lhs_rank = 0, rhs_rank = 0, ii = 0; vec<tree, va_gc> *rhs_list = NULL, *lhs_list = NULL; @@ -521,7 +520,8 @@ expand_an_in_modify_expr (location_t location, tree lhs, bool found_builtin_fn = false; tree an_init, loop_with_init = alloc_stmt_list (); vec<vec<an_parts> > lhs_an_info = vNULL, rhs_an_info = vNULL; - vec<an_loop_parts> lhs_an_loop_info = vNULL, rhs_an_loop_info = vNULL; + auto_vec<an_loop_parts> lhs_an_loop_info, rhs_an_loop_info; + tree lhs_len, rhs_len; if (!find_rank (location, rhs, rhs, false, &rhs_rank)) return error_mark_node; @@ -645,11 +645,11 @@ expand_an_in_modify_expr (location_t location, tree lhs, rhs_an_info))) { pop_stmt_list (an_init); - return error_mark_node; + goto error; } - tree rhs_len = ((rhs_list_size > 0 && rhs_rank > 0) ? + rhs_len = ((rhs_list_size > 0 && rhs_rank > 0) ? rhs_an_info[0][0].length : NULL_TREE); - tree lhs_len = ((lhs_list_size > 0 && lhs_rank > 0) ? + lhs_len = ((lhs_list_size > 0 && lhs_rank > 0) ? lhs_an_info[0][0].length : NULL_TREE); if (lhs_list_size > 0 && rhs_list_size > 0 && lhs_rank > 0 && rhs_rank > 0 && TREE_CODE (lhs_len) == INTEGER_CST && rhs_len @@ -658,7 +658,7 @@ expand_an_in_modify_expr (location_t location, tree lhs, { error_at (location, "length mismatch between LHS and RHS"); pop_stmt_list (an_init); - return error_mark_node; + goto error; } for (ii = 0; ii < lhs_rank; ii++) { @@ -676,7 +676,7 @@ expand_an_in_modify_expr (location_t location, tree lhs, lhs_an_loop_info, lhs_rank, lhs); if (!rhs_array_operand) - return error_mark_node; + goto error; } replace_array_notations (&rhs, true, rhs_list, rhs_array_operand); rhs_list_size = 0; @@ -717,7 +717,7 @@ expand_an_in_modify_expr (location_t location, tree lhs, rhs_an_loop_info, rhs_rank, rhs); if (!rhs_array_operand) - return error_mark_node; + goto error; replace_array_notations (&rhs, true, rhs_list, rhs_array_operand); } @@ -768,16 +768,16 @@ expand_an_in_modify_expr (location_t location, tree lhs, } append_to_statement_list (body, &loop_with_init); - lhs_an_info.release (); - lhs_an_loop_info.release (); - if (rhs_rank) - { - rhs_an_info.release (); - rhs_an_loop_info.release (); - } - cond_expr.release (); + release_vec_vec (lhs_an_info); + release_vec_vec (rhs_an_info); return loop_with_init; + +error: + release_vec_vec (lhs_an_info); + release_vec_vec (rhs_an_info); + + return error_mark_node; } /* Helper function for expand_conditonal_array_notations. Encloses the @@ -796,7 +796,7 @@ cp_expand_cond_array_notations (tree orig_stmt) tree loop_with_init = alloc_stmt_list (); location_t location = UNKNOWN_LOCATION; vec<vec<an_parts> > an_info = vNULL; - vec<an_loop_parts> an_loop_info = vNULL; + auto_vec<an_loop_parts> an_loop_info; if (TREE_CODE (orig_stmt) == COND_EXPR) { @@ -957,8 +957,7 @@ cp_expand_cond_array_notations (tree orig_stmt) } append_to_statement_list (body, &loop_with_init); - an_info.release (); - an_loop_info.release (); + release_vec_vec (an_info); return loop_with_init; } @@ -977,7 +976,7 @@ expand_unary_array_notation_exprs (tree orig_stmt) location_t location = EXPR_LOCATION (orig_stmt); tree an_init, loop_with_init = alloc_stmt_list (); vec<vec<an_parts> > an_info = vNULL; - vec<an_loop_parts> an_loop_info = vNULL; + auto_vec<an_loop_parts> an_loop_info; if (!find_rank (location, orig_stmt, orig_stmt, true, &rank)) return error_mark_node; @@ -1060,8 +1059,7 @@ expand_unary_array_notation_exprs (tree orig_stmt) } append_to_statement_list (body, &loop_with_init); - an_info.release (); - an_loop_info.release (); + release_vec_vec (an_info); return loop_with_init; } |