From patchwork Fri Mar 1 20:21:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 224449 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]) by ozlabs.org (Postfix) with SMTP id 5001D2C02FC for ; Sat, 2 Mar 2013 07:21:34 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1362774095; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=0Rm0Pi87n97d37gRnK6P iLAFkpI=; b=cgIIsutJVg/pB7D2bxw5ygUotY5pxo3Vd1+sgRE88xophHm9Gdw8 jpZAY/p5t01verxnZeDOwvp83UX84tBIP1iobOFowm7vMAhTpkgr6cUNwALggRIJ aTdFsayJtfjJKTGrjpgEu87gaI5X9dThgaKqL2owznUOLmfNpAArY/A= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FmQD6JsrB0mF7pVMMJRcPff/uaL6+TxeX0rapnkoMmo6apYQsJG1VAuh7+Bu/h qYHcSTV6fQkLn0L5NB4DOztr94/BMxBRZI9L8XnqKUqC7alDldZpQURxx65vTeiW MFeDvp622A5TnHtYSNfUljAkJicLFZkHI6A1XtQLn+oU0=; Received: (qmail 16847 invoked by alias); 1 Mar 2013 20:21:29 -0000 Received: (qmail 16833 invoked by uid 22791); 1 Mar 2013 20:21:26 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Mar 2013 20:21:23 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r21KLNti023529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Mar 2013 15:21:23 -0500 Received: from zalov.cz (vpn1-7-207.ams2.redhat.com [10.36.7.207]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r21KLLN6021014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Mar 2013 15:21:22 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r21KLKpO016485; Fri, 1 Mar 2013 21:21:20 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r21KLK0R016484; Fri, 1 Mar 2013 21:21:20 +0100 Date: Fri, 1 Mar 2013 21:21:20 +0100 From: Jakub Jelinek To: Vladimir Makarov Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix IRA memory leak (PR middle-end/56461) Message-ID: <20130301202120.GJ12913@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! When ira_destroy is called, often (always?) this is after loop_optimize_finalize call and thus current_loops is NULL, which results in only freeing ira_loop_nodes[0] and not ira_loop_nodes[1] and above (if any). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-03-01 Jakub Jelinek PR middle-end/56461 * ira-build.c (ira_loop_nodes_count): New variable. (create_loop_tree_nodes): Initialize it. (finish_loop_tree_nodes): Use it instead of looking at current_loops. Jakub --- gcc/ira-build.c.jj 2013-02-08 13:16:55.000000000 +0100 +++ gcc/ira-build.c 2013-03-01 17:30:30.279549566 +0100 @@ -57,6 +57,9 @@ ira_loop_tree_node_t ira_bb_nodes; array. */ ira_loop_tree_node_t ira_loop_nodes; +/* And size of the ira_loop_nodes array. */ +unsigned int ira_loop_nodes_count; + /* Map regno -> allocnos with given regno (see comments for allocno member `next_regno_allocno'). */ ira_allocno_t *ira_regno_allocno_map; @@ -142,14 +145,16 @@ create_loop_tree_nodes (void) } if (current_loops == NULL) { + ira_loop_nodes_count = 1; ira_loop_nodes = ((struct ira_loop_tree_node *) ira_allocate (sizeof (struct ira_loop_tree_node))); init_loop_tree_node (ira_loop_nodes, 0); return; } + ira_loop_nodes_count = number_of_loops (); ira_loop_nodes = ((struct ira_loop_tree_node *) ira_allocate (sizeof (struct ira_loop_tree_node) - * number_of_loops ())); + * ira_loop_nodes_count)); FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) { if (loop_outer (loop) != NULL) @@ -217,13 +222,9 @@ static void finish_loop_tree_nodes (void) { unsigned int i; - loop_p loop; - if (current_loops == NULL) - finish_loop_tree_node (&ira_loop_nodes[0]); - else - FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) - finish_loop_tree_node (&ira_loop_nodes[i]); + for (i = 0; i < ira_loop_nodes_count; i++) + finish_loop_tree_node (&ira_loop_nodes[i]); ira_free (ira_loop_nodes); for (i = 0; i < (unsigned int) last_basic_block_before_change; i++) {