This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR46667, fix section type conflicts


Hi, I've tested your patch, and it also fixes the libstdc++ build on ARM-Linux. Can you see that it gets applied soon? Thanks!

Chung-Lin

On 2010/12/5 08:20 PM, Jan Hubicka wrote:

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?

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 ();

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<cltang@codesourcery.com>

         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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]