From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6748 invoked by alias); 7 Mar 2013 23:01:50 -0000 Received: (qmail 6732 invoked by uid 22791); 7 Mar 2013 23:01:48 -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; Thu, 07 Mar 2013 23:01:41 +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 r27N1f7K003601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Mar 2013 18:01:41 -0500 Received: from zalov.cz (vpn1-6-72.ams2.redhat.com [10.36.6.72]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r27N1djC025769 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Mar 2013 18:01:40 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r27N1cK3024921; Fri, 8 Mar 2013 00:01:38 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r27N1bF4024920; Fri, 8 Mar 2013 00:01:37 +0100 Date: Thu, 07 Mar 2013 23:01:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, aldyh@redhat.com, sellcey@mips.com, rdsandiford@googlemail.com Subject: Re: PR 56524: TREE_OPTIMIZATION_OPTABS vs. mips16 Message-ID: <20130307230137.GM12913@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <87zjyezuvx.fsf@talisman.default> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zjyezuvx.fsf@talisman.default> 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/msg00322.txt.bz2 On Thu, Mar 07, 2013 at 10:51:14PM +0000, Richard Sandiford wrote: > void > -save_optabs_if_changed (tree fndecl) > +init_tree_optimization_optabs (tree optnode) > { > - /* ?? If this fails, we should temporarily restore the default > - target first (set_cfun (NULL) ??), do the rest of this function, > - and then restore it. */ > - gcc_assert (this_target_optabs == &default_target_optabs); > + /* Quick exit if we have already computed optabs for this target. */ > + if (TREE_OPTIMIZATION_BASE_OPTABS (optnode) == this_target_optabs) > + return; > > + /* Forget any previous information and set up for the current target. */ > + TREE_OPTIMIZATION_BASE_OPTABS (optnode) = this_target_optabs; > struct target_optabs *tmp_optabs = (struct target_optabs *) > - ggc_alloc_atomic (sizeof (struct target_optabs)); > - tree optnode = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl); > + TREE_OPTIMIZATION_OPTABS (optnode); > + if (tmp_optabs) > + memset (tmp_optabs, 0, sizeof (struct target_optabs)); > + else > + tmp_optabs = (struct target_optabs *) > + ggc_alloc_atomic (sizeof (struct target_optabs)); > > /* Generate a new set of optabs into tmp_optabs. */ > init_all_optabs (tmp_optabs); If TARGET_OPTIMIZATION_OPTABS is non-NULL upon entering the function, then we call memset above, and then ... /* If the optabs changed, record it. */ if (memcmp (tmp_optabs, this_target_optabs, sizeof (struct target_optabs))) { if (TREE_OPTIMIZATION_OPTABS (optnode)) ggc_free (TREE_OPTIMIZATION_OPTABS (optnode)); TREE_OPTIMIZATION_OPTABS (optnode) = (unsigned char *) tmp_optabs; As tmp_optabs == TREE_OPTIMIZATION_OPTABS (optnode); in that case, the ggc_free is wrong, TREE_OPTIMIZATION_OPTABS (optnode) will then point to freed memory. So I think the if (TREE_OPTIMIZATION_OPTABS (optnode)) ggc_free (TREE_OPTIMIZATION_OPTABS (optnode)); has to be removed (of course the second ggc_free, if memcmp returned 0, is desirable). Otherwise looks good. Jakub