From patchwork Wed Feb 27 15:56:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 223642 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 D6D272C0079 for ; Thu, 28 Feb 2013 02:57:24 +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=1362585445; 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=ATEXsZ/Vls/fxnjyl/2r ftTyT+Y=; b=E73aaM49R1vpCuLT1IJpo4ayRyJ6c2UUAe6xh/iKu3HxT1mpHVrp /UkNLtDnYBwM+lrvdkkEoPxd6dul2Vdok9/FoMSr21qJ/TVSBkSfO0gyuYiTVADY zamRAz2iW56q+hbrR5j2rOP1P/LaG8Fl0wtXvDzb4fvt0ov/RB3G28w= 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=O34UJe9ED0Rx5jaK9sqpp681RQqHsLdrK/S2aE00RTsIMOhfoW140/kO7EuOGl L8Z29livy2BmgL+ZpIy4Tjo4ng+/PXFc7+Oel3upmJhXZmILj30IVNaAM2DlsRlc anJ67MDApLAD4xEFqmsEO3qtfLG21G8yIbUrkcnLDcLBs=; Received: (qmail 10895 invoked by alias); 27 Feb 2013 15:57:12 -0000 Received: (qmail 10884 invoked by uid 22791); 27 Feb 2013 15:57:11 -0000 X-SWARE-Spam-Status: No, hits=-6.6 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; Wed, 27 Feb 2013 15:57:01 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1RFv19D007619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Feb 2013 10:57:01 -0500 Received: from zalov.cz (vpn1-7-146.ams2.redhat.com [10.36.7.146]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1RFuxNc012072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Feb 2013 10:57:00 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r1RFuwTX004000; Wed, 27 Feb 2013 16:56:58 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r1RFuwMd003999; Wed, 27 Feb 2013 16:56:58 +0100 Date: Wed, 27 Feb 2013 16:56:58 +0100 From: Jakub Jelinek To: Vladimir Makarov Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix another LRA memory leak (PR middle-end/56461) Message-ID: <20130227155658.GI12913@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! As discussed in the PR, sometimes we call lra_create_live_ranges multiple times without intervening lra_clear_live_ranges, which results in memory leaks. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-02-27 Jakub Jelinek PR middle-end/56461 * lra.c (lra): Call lra_clear_live_ranges if live_p, right before calling lra_create_live_ranges, also call it when clearing live_p. Only call lra_clear_live_ranges at the end if live_p. Jakub --- gcc/lra.c.jj 2013-02-09 10:29:36.000000000 +0100 +++ gcc/lra.c 2013-02-27 08:51:34.971860214 +0100 @@ -2291,6 +2291,8 @@ lra (FILE *f) /* Do inheritance only for regular algorithms. */ if (! lra_simple_p) lra_inheritance (); + if (live_p) + lra_clear_live_ranges (); /* We need live ranges for lra_assign -- so build them. */ lra_create_live_ranges (true); live_p = true; @@ -2308,6 +2310,8 @@ lra (FILE *f) live_p = false; if (lra_undo_inheritance ()) live_p = false; + if (! live_p) + lra_clear_live_ranges (); } } bitmap_clear (&lra_optional_reload_pseudos); @@ -2334,7 +2338,8 @@ lra (FILE *f) lra_eliminate (true); lra_final_code_change (); lra_in_progress = 0; - lra_clear_live_ranges (); + if (live_p) + lra_clear_live_ranges (); lra_live_ranges_finish (); lra_constraints_finish (); finish_reg_info ();