From patchwork Sun Dec 5 12:20:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 74296 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 15246B70B8 for ; Sun, 5 Dec 2010 23:20:16 +1100 (EST) Received: (qmail 24012 invoked by alias); 5 Dec 2010 12:20:11 -0000 Received: (qmail 24000 invoked by uid 22791); 5 Dec 2010 12:20:09 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ksp.mff.cuni.cz (HELO atrey.karlin.mff.cuni.cz) (195.113.26.206) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 05 Dec 2010 12:20:03 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 4018) id 14BE2F0DA5; Sun, 5 Dec 2010 13:20:01 +0100 (CET) Date: Sun, 5 Dec 2010 13:20:01 +0100 From: Jan Hubicka To: Chung-Lin Tang Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR46667, fix section type conflicts Message-ID: <20101205122000.GA24047@atrey.karlin.mff.cuni.cz> References: <4CF76168.6060806@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4CF76168.6060806@codesourcery.com> User-Agent: Mutt/1.5.18 (2008-05-17) 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 > > The x86-64 failure seems to be calling get_named_section() during > dwarf2out_init(), when current_function_decl is still NULL, with the > resulting section flags containing SECTION_WRITE. I've added an > additional condition testing the ".text." section name prefix when decl > is NULL. I've fixed the problem in meanitme by preventing dwarf2out from consturcting unlikely section until some functions are output. As I understand the problem is due the fact that current_function_section is called at expansion time #6 0x0000000000b009b8 in current_function_section () at ../../combined/gcc/varasm.c:635 #7 0x0000000000b39835 in arm_is_long_call_p (decl=0x2ba5b225cd00) at ../../combined/gcc/config/arm/arm.c:5001 #8 0x0000000000b39937 in arm_function_ok_for_sibcall (decl=0x2ba5b225cd00, exp=0x2ba5b2a84370) at ../../combined/gcc/config/arm/arm.c:5033 #9 0x00000000006b1a4b in expand_call (exp=0x2ba5b2a84370, target=0x0, ignore=1) at ../../combined/gcc/calls.c:2306 #10 0x00000000007614e0 in expand_expr_real_1 (exp=0x2ba5b2a84370, target=0x0, tmode=VOIDmode, modifier=EXPAND_NORMAL, alt_rtl=0x0) at ../../combined/gcc/expr.c:9299 #11 0x00000000006c2796 in expand_gimple_stmt (stmt=0x2ba5b22caee0) at ../../combined/gcc/cfgexpand.c:1916 #12 0x00000000006c342b in expand_gimple_basic_block (bb=0x2ba5b253e548) at ../../combined/gcc/cfgexpand.c:2154 #13 0x00000000006c47b8 in gimple_expand_cfg () at while at this point, the current section does not have very good meaning. Unique sections are resolved at assemble_function_start time and we don't know about hot/cold partitioning yet. This seems to be sort of hack in ARM BE trying to second guess if the function will end up in same section with arm_function_in_section_p getting rid of some cases. It is arguably hack, but I guess nothing prevents us from compuing unique section early. Does the following (untested) patch help? > > This patch has been tested on the respective platforms with no > regressions, and does now revive the ARM-Linux C++ build; however, I'm > not sure whether this is a robust enough fix; it may just well be > band-aid :P > > Thanks, > Chung-Lin > > 2010-12-02 Chung-Lin Tang > > PR middle-end/46667 > * varasm.c (get_named_section): Add call to > resolve_unique_section(). > (default_function_section): Call get_named_section() for > DECL_ONE_ONLY decls. > (default_section_type_flags): Start off with SECTION_CODE as > flags value when decl is NULL and section name starts with > ".text.". > Index: varasm.c > =================================================================== > --- varasm.c (revision 167365) > +++ varasm.c (working copy) > @@ -380,6 +380,10 @@ > unsigned int flags; > > gcc_assert (!decl || DECL_P (decl)); > + > + if (decl) > + resolve_unique_section (decl, reloc, 0); > + > if (name == NULL) > name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); > > @@ -533,6 +537,9 @@ > default_function_section (tree decl, enum node_frequency freq, > bool startup, bool exit) > { > + if (decl && DECL_ONE_ONLY (decl)) > + return get_named_section (decl, NULL, 0); > + > /* Startup code should go to startup subsection unless it is > unlikely executed (this happens especially with function splitting > where we can split away unnecesary parts of static constructors. */ > @@ -5934,7 +5941,8 @@ > { > unsigned int flags; > > - if (decl && TREE_CODE (decl) == FUNCTION_DECL) > + if ((decl && TREE_CODE (decl) == FUNCTION_DECL) > + || (!decl && strncmp (name, ".text.", 6) == 0)) > flags = SECTION_CODE; > else if (decl && decl_readonly_section (decl, reloc)) > flags = 0; Index: varasm.c =================================================================== --- varasm.c (revision 167472) +++ varasm.c (working copy) @@ -1548,8 +1548,6 @@ if (CONSTANT_POOL_BEFORE_FUNCTION) output_constant_pool (fnname, decl); - resolve_unique_section (decl, 0, flag_function_sections); - /* Make sure the not and cold text (code) sections are properly aligned. This is necessary here in the case where the function has both hot and cold sections, because we don't want to re-set Index: cfgexpand.c =================================================================== --- cfgexpand.c (revision 167472) +++ cfgexpand.c (working copy) @@ -3949,6 +3949,10 @@ crtl->preferred_stack_boundary = STACK_BOUNDARY; cfun->cfg->max_jumptable_ents = 0; + /* Resovle the function section. Some targets, like ARM EABI rely on knowledge + of the function section at exapnsion time to predict distance of calls. */ + resolve_unique_section (current_function_decl, 0, flag_function_sections); + /* Expand the variables recorded during gimple lowering. */ timevar_push (TV_VAR_EXPAND); start_sequence ();