From patchwork Wed Feb 27 20:21:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 223695 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 032102C0077 for ; Thu, 28 Feb 2013 07:21:58 +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=1362601319; 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=hOZQgjpuXO09P2Nv1X37 o9TZtmM=; b=qtC5vi7krzXhOw6wBzXTP7NKDwTW9BhG+j/mnf0kO46XKMWiUe5h mV2AHsW0bd8jC66vMc313rHUWF/b8hvOWfEkT3V9bJQZPmbMqEFKbigJSt5kVqJp Y1GqQzAhHh7NBcuKybLDzoLZCNdp5/6DApB1Tg4Ncc77LeeLh2xmvW8= 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=mBq43qX6vzlrFoELUGNlSdubIAyuStUqScV58sPAYQkWYI8yfT0xoSI7tJRaWj vPxepE8cwNWO7LJPKUC5T2Lt0kZW9ls39utidXtovGKHL+VLIyofRMLp9VuKENUC FEhQdCbBv0Q4dz08toH0edjg/yzcTJYX3kG5jWCrEgHXw=; Received: (qmail 1814 invoked by alias); 27 Feb 2013 20:21:43 -0000 Received: (qmail 1801 invoked by uid 22791); 27 Feb 2013 20:21: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_CP 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 20:21:39 +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 r1RKLcP4031568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Feb 2013 15:21:38 -0500 Received: from zalov.cz (vpn1-4-213.ams2.redhat.com [10.36.4.213]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1RKLaFc021324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Feb 2013 15:21:38 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r1RKLaLl017723; Wed, 27 Feb 2013 21:21:36 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r1RKLZuv017722; Wed, 27 Feb 2013 21:21:35 +0100 Date: Wed, 27 Feb 2013 21:21:35 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix vect_permute_load_chain leaks (PR middle-end/56461) Message-ID: <20130227202135.GQ12913@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! This function used vec copy () method, but unfortunately that allocates a fresh new vector and overwrites the target vector variable with it (making it leak memory). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-02-27 Jakub Jelinek PR middle-end/56461 * tree-vect-data-refs.c (vect_permute_load_chain): Avoid using copy method on dr_chain and result_chain. Jakub --- gcc/tree-vect-data-refs.c.jj 2013-02-05 16:45:40.000000000 +0100 +++ gcc/tree-vect-data-refs.c 2013-02-27 17:59:19.574144962 +0100 @@ -4673,7 +4673,9 @@ vect_permute_load_chain (vec dr_ch unsigned 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; i < nelt; ++i) sel[i] = i * 2; @@ -4708,7 +4710,8 @@ vect_permute_load_chain (vec dr_ch vect_finish_stmt_generation (stmt, perm_stmt, gsi); (*result_chain)[j/2+length/2] = data_ref; } - dr_chain = result_chain->copy (); + memcpy (dr_chain.address (), result_chain->address (), + length * sizeof (tree)); } }