From patchwork Wed Aug 22 13:03:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 179319 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 077D82C0096 for ; Wed, 22 Aug 2012 23:09:53 +1000 (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=1346245794; 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=lujMysvhsQSyuk4rRpQI jL/VHLQ=; b=r64QWVtPlzv40qI772ZJUI3+YGgASfGiqdrVspjWh+fAvLCdMyjm 2M2NGkGX6iLaJGGK7+OzQuFeu6IMMozHkHqQ/6NE8XaN2bMxN2pLLtiXQtYTVQlH IKmFP+6lpvjirN4+YFEYrWD7IMYwmHvhNasQPsZgrU2V5hZOyK/Gluc= 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=EO3m+g7uWI5zdylXy+evc/n9lViLRBhXrXBoNXnmlN2cKWy+o9SYe3LYFAosm/ 71w/VmQ7XG9OXc5n2pCE5hArugyTlUGd7y7OkPvrrj4zxhZckwU2Qo0ViYP1M6oM pCqoapsCLdN2Tv8WyARJeqT7qTtfc2s73eWA2pYG5BAY0=; Received: (qmail 5262 invoked by alias); 22 Aug 2012 13:09:37 -0000 Received: (qmail 5196 invoked by uid 22791); 22 Aug 2012 13:09:35 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, 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, 22 Aug 2012 13:09:17 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7MD9E6l011026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 22 Aug 2012 09:09:14 -0400 Received: from tucnak.redhat.com (vpn1-7-241.ams2.redhat.com [10.36.7.241]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7MD9CKq002182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 22 Aug 2012 09:09:13 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q7MD3EJA002756; Wed, 22 Aug 2012 15:03:15 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q7MD3E84002755; Wed, 22 Aug 2012 15:03:14 +0200 Date: Wed, 22 Aug 2012 15:03:14 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] Fix memory leak in Fortran FE with init_emit Message-ID: <20120822130314.GU1999@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! init_function_start is these days supposed to be called only at the start of RTL expansion, it shouldn't be called much earlier, because then we leak e.g. the memory allocated by init_emit. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-08-22 Jakub Jelinek * trans-decl.c (trans_function_start, generate_coarray_init, create_main_function, gfc_generate_constructors): Call allocate_struct_function instead of init_function_start. Jakub --- gcc/fortran/trans-decl.c.jj 2012-08-13 14:36:51.000000000 +0200 +++ gcc/fortran/trans-decl.c 2012-08-22 12:18:29.963953958 +0200 @@ -2265,7 +2265,8 @@ trans_function_start (gfc_symbol * sym) /* Create RTL for function definition. */ make_decl_rtl (fndecl); - init_function_start (fndecl); + gcc_checking_assert (DECL_STRUCT_FUNCTION (fndecl) == NULL); + allocate_struct_function (fndecl, false); /* function.c requires a push at the start of the function. */ pushlevel (); @@ -4408,7 +4409,8 @@ generate_coarray_init (gfc_namespace * n rest_of_decl_compilation (fndecl, 0, 0); make_decl_rtl (fndecl); - init_function_start (fndecl); + gcc_checking_assert (DECL_STRUCT_FUNCTION (fndecl) == NULL); + allocate_struct_function (fndecl, false); pushlevel (); gfc_init_block (&caf_init_block); @@ -4982,7 +4984,8 @@ create_main_function (tree fndecl) rest_of_decl_compilation (ftn_main, 1, 0); make_decl_rtl (ftn_main); - init_function_start (ftn_main); + gcc_checking_assert (DECL_STRUCT_FUNCTION (ftn_main) == NULL); + allocate_struct_function (ftn_main, false); pushlevel (); gfc_init_block (&body); @@ -5537,7 +5540,8 @@ gfc_generate_constructors (void) make_decl_rtl (fndecl); - init_function_start (fndecl); + gcc_checking_assert (DECL_STRUCT_FUNCTION (fndecl) == NULL); + allocate_struct_function (fndecl, false); pushlevel ();