From patchwork Sat Nov 17 12:32:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 199849 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 922762C0089 for ; Sat, 17 Nov 2012 23:32:19 +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=1353760340; 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=mW6xVmO36bXofyNKlm4z mz7SuSA=; b=D0AUrmiwYr/uY92PvuKUmAWbUD3uKITJKf86jCzIkfiXajW9969b riPE3OUhlnKNhEZYBmPnI3LlnC34m0iI8keMY0vMPew2BO1s0SWiCWuf4DkThEcY YzyYV3PU+8EWmo3elQ2qJgwldxD6AC35kv9RzGKyzVANvsHW9o1/GtY= 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=btGwTKGw2IGHmiwO3Bf33gb1bCoitJuRPtu3qE2P4vQhjC4HsbsYs/6FukE3Z2 zq3pHJvY4xlNz47W4r30m3zazmT7QKsnn+NqUzXtNJmHPNpxcByBtq8UghqqGjil 30jjAgF1kTepcmYdGGpRDquF1CFMnfBsUda2cHYqURVo4=; Received: (qmail 7124 invoked by alias); 17 Nov 2012 12:32:16 -0000 Received: (qmail 7116 invoked by uid 22791); 17 Nov 2012 12:32:16 -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; Sat, 17 Nov 2012 12:32:10 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAHCW9jS011590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 17 Nov 2012 07:32:09 -0500 Received: from zalov.redhat.com (vpn1-5-234.ams2.redhat.com [10.36.5.234]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAHCW8Dk015250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 17 Nov 2012 07:32:09 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qAHCW7lL032452; Sat, 17 Nov 2012 13:32:07 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qAHCW7eh032451; Sat, 17 Nov 2012 13:32:07 +0100 Date: Sat, 17 Nov 2012 13:32:06 +0100 From: Jakub Jelinek To: Jason Merrill , Diego Novillo Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid unnecessary __cxa_quard_{acquire, release} (PR middle-end/54630) Message-ID: <20121117123206.GM1886@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 PR points out that unnecessarily in two gcc spots we now use __cxa_guard_acquire/release. In the first case, there is no point to make the var static, it is always created and disposed in the same function, so making it an automatic variable is certainly cheaper, there is no need to initialize anything in global ctors, the local initialization is just = NULL overridden almost immediately by assignment in create anyway. The other change is perhaps more controversial, it is tiny bit nicer to have the variable local static, but it is more costly. In any case, both changes passed bootstrap/regtest on x86_64-linux and i686-linux, ok? 2012-11-16 Jakub Jelinek PR middle-end/54630 * tree-ssa-coalesce.c (coalesce_ssa_name): Remove static keyword from ssa_name_hash var. * class.c (fixed_type_or_null_ref_ht): New variable. (fixed_type_or_null): Use it instead of local static ht. Jakub --- gcc/tree-ssa-coalesce.c.jj 2012-10-26 18:05:03.000000000 +0200 +++ gcc/tree-ssa-coalesce.c 2012-11-16 16:09:47.302657256 +0100 @@ -1,5 +1,5 @@ /* Coalesce SSA_NAMES together for the out-of-ssa pass. - Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Andrew MacLeod @@ -1292,7 +1292,6 @@ coalesce_ssa_name (void) bitmap used_in_copies = BITMAP_ALLOC (NULL); var_map map; unsigned int i; - static hash_table ssa_name_hash; cl = create_coalesce_list (); map = create_outofssa_var_map (cl, used_in_copies); @@ -1301,6 +1300,8 @@ coalesce_ssa_name (void) so debug info remains undisturbed. */ if (!optimize) { + hash_table ssa_name_hash; + ssa_name_hash.create (10); for (i = 1; i < num_ssa_names; i++) { --- gcc/cp/class.c.jj 2012-11-16 12:39:15.000000000 +0100 +++ gcc/cp/class.c 2012-11-16 16:13:32.963262681 +0100 @@ -6567,6 +6567,9 @@ finish_struct (tree t, tree attributes) return t; } +/* Hash table to avoid endless recursion when handling references. */ +static hash_table > fixed_type_or_null_ref_ht; + /* Return the dynamic type of INSTANCE, if known. Used to determine whether the virtual function table is needed or not. @@ -6682,9 +6685,8 @@ fixed_type_or_null (tree instance, int * else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE) { /* We only need one hash table because it is always left empty. */ - static hash_table > ht; - if (!ht.is_created ()) - ht.create (37); + if (!fixed_type_or_null_ref_ht.is_created ()) + fixed_type_or_null_ref_ht.create (37); /* Reference variables should be references to objects. */ if (nonnull) @@ -6696,15 +6698,15 @@ fixed_type_or_null (tree instance, int * if (TREE_CODE (instance) == VAR_DECL && DECL_INITIAL (instance) && !type_dependent_expression_p_push (DECL_INITIAL (instance)) - && !ht.find (instance)) + && !fixed_type_or_null_ref_ht.find (instance)) { tree type; tree_node **slot; - slot = ht.find_slot (instance, INSERT); + slot = fixed_type_or_null_ref_ht.find_slot (instance, INSERT); *slot = instance; type = RECUR (DECL_INITIAL (instance)); - ht.remove_elt (instance); + fixed_type_or_null_ref_ht.remove_elt (instance); return type; }