From patchwork Fri Mar 1 20:23:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 224450 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 BDE632C02F1 for ; Sat, 2 Mar 2013 07:23:53 +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=1362774235; 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=NqIPFgrpABK6xiuy1KNA VZtHBKg=; b=g78hR+t5YVvVUHnFbAPsOaLXGzIujBD3U8g56pMIovCohbU8QCnj tU86t+I6eIgRdvGScu/SBiyABUW8hZFEUJC8kWEVGLxm90b9j1WrdODV7AiKQaVW WrO2xFxxkyZUAWEb2UQhv/iqsw6yn896jrj92gW3mz4lTAsI/VNOOio= 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=MX/O3HYB/YRMbax2KraGnbwKycVwGvvzp21WZatYqA276Elxz3flE9sj73nz3G YxRiV3bdtJqaM0fxyE97zr10tVqAWymrfroDBU3rnnMwM5R2Y7+4yQXP+c+7FVE6 Z0yMwrS1sQK0owIVUSSReYu5n1YBHnn1n+M5z5iI3ynyY=; Received: (qmail 17778 invoked by alias); 1 Mar 2013 20:23:44 -0000 Received: (qmail 17764 invoked by uid 22791); 1 Mar 2013 20:23:41 -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_CP, 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; Fri, 01 Mar 2013 20:23:06 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r21KN6aG024116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Mar 2013 15:23:06 -0500 Received: from zalov.cz (vpn1-7-207.ams2.redhat.com [10.36.7.207]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r21KN483013666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Mar 2013 15:23:05 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r21KN3SS016498; Fri, 1 Mar 2013 21:23:03 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r21KN3UO016497; Fri, 1 Mar 2013 21:23:03 +0100 Date: Fri, 1 Mar 2013 21:23:03 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix vectorizable_store memory leaks (PR middle-end/56461) Message-ID: <20130301202303.GK12913@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! The first two hunks are similar issue to what I've posted for vect_permute_load_chain two days ago, the remaining issue is that if ncopies > 1, we'd leak the result_chain vector too. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-03-01 Jakub Jelinek PR middle-end/56461 * tree-vect-data-refs.c (vect_permute_store_chain): Avoid using copy method on dr_chain and result_chain. * tree-vect-stmts.c (vectorizable_store): Only call result_chain.create if j == 0. Jakub --- gcc/tree-vect-data-refs.c.jj 2013-02-27 23:05:57.000000000 +0100 +++ gcc/tree-vect-data-refs.c 2013-03-01 17:41:12.296992793 +0100 @@ -4218,7 +4218,9 @@ vect_permute_store_chain (vec dr_c unsigned int j, nelt = TYPE_VECTOR_SUBPARTS (vectype); unsigned char *sel = XALLOCAVEC (unsigned char, nelt); - *result_chain = dr_chain.copy (); + result_chain->quick_grow (length); + memcpy (result_chain->address (), dr_chain.address (), + length * sizeof (tree)); for (i = 0, n = nelt / 2; i < n; i++) { @@ -4259,7 +4261,8 @@ vect_permute_store_chain (vec dr_c vect_finish_stmt_generation (stmt, perm_stmt, gsi); (*result_chain)[2*j+1] = low; } - dr_chain = result_chain->copy (); + memcpy (dr_chain.address (), result_chain->address (), + length * sizeof (tree)); } } --- gcc/tree-vect-stmts.c.jj 2013-03-01 13:33:37.000000000 +0100 +++ gcc/tree-vect-stmts.c 2013-03-01 17:35:17.146958118 +0100 @@ -4135,7 +4135,8 @@ vectorizable_store (gimple stmt, gimple_ new_stmt = NULL; if (grouped_store) { - result_chain.create (group_size); + if (j == 0) + result_chain.create (group_size); /* Permute. */ vect_permute_store_chain (dr_chain, group_size, stmt, gsi, &result_chain);