From patchwork Wed Jul 14 16:28:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 58915 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 ABB5CB6F0E for ; Thu, 15 Jul 2010 02:28:41 +1000 (EST) Received: (qmail 10301 invoked by alias); 14 Jul 2010 16:28:37 -0000 Received: (qmail 10274 invoked by uid 22791); 14 Jul 2010 16:28:35 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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, 14 Jul 2010 16:28:30 +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.13.8/8.13.8) with ESMTP id o6EGSQ1P026059 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 Jul 2010 12:28:27 -0400 Received: from anchor.twiddle.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6EGSQkc021756 for ; Wed, 14 Jul 2010 12:28:26 -0400 Message-ID: <4C3DE5AA.1080105@redhat.com> Date: Wed, 14 Jul 2010 09:28:26 -0700 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Thunderbird/3.0.5 MIME-Version: 1.0 To: GCC Patches Subject: Avoid a bit o useless work in rest_of_decl_compilation 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 I noticed this bit of weirdness when I added an assertion that emulated tls variables should not be assembled. That check crashed because I surely did not expect to have to check for VAR_DECL in a function named assemble_variable. It turns out there was only one place in the compiler silly enough to try to assemble_variable on a function. Committed. r~ * passes.c (rest_of_decl_compilation): Do not call assemble_variable for functions. * varasm.c (assemble_variable): Remove early exit for functions; assert that we're given a variable. diff --git a/gcc/passes.c b/gcc/passes.c index 8828967..72e9b5a 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -194,8 +194,6 @@ rest_of_decl_compilation (tree decl, ; else if (TREE_CODE (decl) != FUNCTION_DECL) varpool_finalize_decl (decl); - else - assemble_variable (decl, top_level, at_end, 0); } #ifdef ASM_FINISH_DECLARE_OBJECT diff --git a/gcc/varasm.c b/gcc/varasm.c index 5fad5f0..55218c4 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2150,6 +2150,9 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, rtx decl_rtl, symbol; section *sect; + /* This function is supposed to handle VARIABLES. Ensure we have one. */ + gcc_assert (TREE_CODE (decl) == VAR_DECL); + if (! targetm.have_tls && TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) @@ -2188,12 +2191,6 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, if (DECL_EXTERNAL (decl)) return; - /* Output no assembler code for a function declaration. - Only definitions of functions output anything. */ - - if (TREE_CODE (decl) == FUNCTION_DECL) - return; - /* Do nothing for global register variables. */ if (DECL_RTL_SET_P (decl) && REG_P (DECL_RTL (decl))) {