From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18419 invoked by alias); 4 Mar 2013 21:03:43 -0000 Received: (qmail 18408 invoked by uid 22791); 4 Mar 2013 21:03:42 -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,TW_TM 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; Mon, 04 Mar 2013 21:03:38 +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 r24L3cAb020402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 Mar 2013 16:03:38 -0500 Received: from zalov.cz (vpn1-7-229.ams2.redhat.com [10.36.7.229]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r24L3a0k019047 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 4 Mar 2013 16:03:38 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r24L3aNS003460; Mon, 4 Mar 2013 22:03:36 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r24L3YXF003459; Mon, 4 Mar 2013 22:03:34 +0100 Date: Mon, 04 Mar 2013 21:03:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix vect_create_epilog_for_reduction memory leaks (PR middle-end/56461) Message-ID: <20130304210333.GS12913@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00128.txt.bz2 Hi! vect_create_epilog_for_reduction leaks memory both from the inner_phis vector not being released for double_reduc, and also for stmt_vec_info it creates (because those are added for stmts added into exit_bb, i.e. after loop, which destroy_loop_vec_info doesn't free). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-03-04 Jakub Jelinek PR middle-end/56461 * tree-vect-stmts.c (free_stmt_vec_info_vec): Call free_stmt_vec_info on any left-over stmt_vec_info in the vector. * tree-vect-loop.c (vect_create_epilog_for_reduction): Release inner_phis vector. --- gcc/tree-vect-stmts.c.jj 2013-03-04 11:07:33.000000000 +0100 +++ gcc/tree-vect-stmts.c 2013-03-04 12:14:16.111393716 +0100 @@ -5969,6 +5969,11 @@ init_stmt_vec_info_vec (void) void free_stmt_vec_info_vec (void) { + unsigned int i; + vec_void_p info; + FOR_EACH_VEC_ELT (stmt_vec_info_vec, i, info) + if (info != NULL) + free_stmt_vec_info (STMT_VINFO_STMT ((stmt_vec_info) info)); gcc_assert (stmt_vec_info_vec.exists ()); stmt_vec_info_vec.release (); } --- gcc/tree-vect-loop.c.jj 2013-03-04 11:01:48.000000000 +0100 +++ gcc/tree-vect-loop.c 2013-03-04 12:17:09.934351015 +0100 @@ -4487,8 +4487,9 @@ vect_finalize_reduction: } scalar_results.release (); + inner_phis.release (); new_phis.release (); -} +} /* Function vectorizable_reduction. Jakub