From patchwork Fri Nov 13 12:50:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 544273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3755C14141E for ; Fri, 13 Nov 2015 23:51:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=pbt3kJfY; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:message-id:date:mime-version:in-reply-to :content-type; q=dns; s=default; b=Nk0gYBHi6JeRzGA8l/qrlHQm8ywiP MVOjW9XCA3XTJnGLj/4TFiJ8nE9KFFMu/inmaiBgg+rsgOHX2mUtB8REdPPIQ5xc 5IguqW2bgNQxWW1cqsHe+4Zgryjv3BDPHNS/AzttIv32Lg6ZpePJlb9r4oEfPVvl zPTpz/cgdLyc8g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:message-id:date:mime-version:in-reply-to :content-type; s=default; bh=OkPduGv8LZv6Gb+svSUWKp7Nf5k=; b=pbt 3kJfY/18/osIjCPl+LI0EA311T7/x8I4YaX3ZT2kDWP990KzuOkC2X0eMp2azr3m HDlPWD2sxd3/lLq0OuyrupD60sP135rWpA5EQ2UPXkNiyLkw404SKQQB2R7SAyLG iAwFg7QFty+k5DFYtDthwTzR6wkI+m4W6c3IPumM= Received: (qmail 122629 invoked by alias); 13 Nov 2015 12:51:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 122611 invoked by uid 89); 13 Nov 2015 12:51:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 13 Nov 2015 12:51:03 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8E4B1AC8C for ; Fri, 13 Nov 2015 12:50:35 +0000 (UTC) From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: Re: [PATCH] Fix memory leaks in tree-ssa-uninit.c To: GCC Patches References: <564081EF.7030003@suse.cz> Message-ID: <5645DCB1.6070309@suse.cz> Date: Fri, 13 Nov 2015 13:50:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <564081EF.7030003@suse.cz> X-IsSubscribed: yes Hello. Patch survives regbootstrap on x86_64-linux-gnu. Ready for trunk? Thanks, Martin From 54851503251dee7a8bd074485db262715e628728 Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 13 Nov 2015 12:23:22 +0100 Subject: [PATCH] Fix memory leaks in tree-ssa-uninit.c gcc/ChangeLog: 2015-11-13 Martin Liska * tree-ssa-uninit.c (convert_control_dep_chain_into_preds): Fix GNU coding style. (find_def_preds): Use auto_vec. (destroy_predicate_vecs): Change signature of the function. (prune_uninit_phi_opnds_in_unrealizable_paths): Use the new signature. (simplify_preds_4): Use destroy_predicate_vecs instread of just releasing preds vector. (normalize_preds): Likewise. (is_use_properly_guarded): Use new signature of destroy_predicate_vecs. (find_uninit_use): Likewise. --- gcc/tree-ssa-uninit.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index a439363..0709cce 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -628,9 +628,9 @@ convert_control_dep_chain_into_preds (vec *dep_chains, } if (!has_valid_pred) - break; + break; else - preds->safe_push (t_chain); + preds->safe_push (t_chain); } return has_valid_pred; } @@ -682,7 +682,7 @@ find_predicates (pred_chain_union *preds, static void collect_phi_def_edges (gphi *phi, basic_block cd_root, - vec *edges, + auto_vec *edges, hash_set *visited_phis) { size_t i, n; @@ -739,7 +739,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi) size_t num_chains = 0, i, n; vec dep_chains[MAX_NUM_CHAINS]; auto_vec cur_chain; - vec def_edges = vNULL; + auto_vec def_edges; bool has_valid_pred = false; basic_block phi_bb, cd_root = 0; @@ -829,14 +829,14 @@ dump_predicates (gimple *usestmt, pred_chain_union preds, /* Destroys the predicate set *PREDS. */ static void -destroy_predicate_vecs (pred_chain_union preds) +destroy_predicate_vecs (pred_chain_union *preds) { size_t i; - size_t n = preds.length (); + size_t n = preds->length (); for (i = 0; i < n; i++) - preds[i].release (); - preds.release (); + (*preds)[i].release (); + preds->release (); } @@ -1103,7 +1103,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, uninit_opnds2, &def_preds, visited_phis); - destroy_predicate_vecs (def_preds); + destroy_predicate_vecs (&def_preds); if (!ok) return false; } @@ -1769,7 +1769,8 @@ simplify_preds_4 (pred_chain_union *preds) continue; s_preds.safe_push ((*preds)[i]); } - preds->release (); + + destroy_predicate_vecs (preds); (*preds) = s_preds; s_preds = vNULL; } @@ -2148,7 +2149,7 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use) dump_predicates (use_or_def, norm_preds, is_use ? "[USE]:\n" : "[DEF]:\n"); } - preds.release (); + destroy_predicate_vecs (&preds); return norm_preds; } @@ -2199,7 +2200,7 @@ is_use_properly_guarded (gimple *use_stmt, if (!has_valid_preds) { - destroy_predicate_vecs (preds); + destroy_predicate_vecs (&preds); return false; } @@ -2210,7 +2211,7 @@ is_use_properly_guarded (gimple *use_stmt, if (is_properly_guarded) { - destroy_predicate_vecs (preds); + destroy_predicate_vecs (&preds); return true; } @@ -2220,7 +2221,7 @@ is_use_properly_guarded (gimple *use_stmt, if (!has_valid_preds) { - destroy_predicate_vecs (preds); + destroy_predicate_vecs (&preds); return false; } @@ -2233,7 +2234,7 @@ is_use_properly_guarded (gimple *use_stmt, is_properly_guarded = is_superset_of (*def_preds, preds); - destroy_predicate_vecs (preds); + destroy_predicate_vecs (&preds); return is_properly_guarded; } @@ -2306,7 +2307,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, } } - destroy_predicate_vecs (def_preds); + destroy_predicate_vecs (&def_preds); return ret; } -- 2.6.2