http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46916

--- Comment #21 from Iain Sandoe <iains at gcc dot gnu.org> 2010-12-14 14:04:58 
UTC ---
(In reply to comment #19)
> Hi,
> does the following patch fix the problem?
> darwin_text_section no longer needs to care about hot/cold code since this is
> already done in darwin_function_section.
> 
> In fact you might additionally consider putting 
>   return (DECL_WEAK (decl)
>       ? darwin_sections[text_coal_section]
>       : text_section);
> into places returning NULL in darwin_function_section, removing case
> SECCAT_TEXT
> from machopic_select_section undefining USE_SELECT_SECTION_FOR_FUNCTIONS
> as suggested by rth as cleanup.

like this?
 (fixes the specific problem - but not reg-tested):


Index: gcc/opts.c
===================================================================
--- gcc/opts.c    (revision 167793)
+++ gcc/opts.c    (working copy)
@@ -723,6 +723,9 @@ finish_options (struct gcc_options *opts, struct g
       opts->x_flag_reorder_blocks = 1;
     }

+  if (opts->x_flag_reorder_blocks_and_partition)
+    opts->x_flag_reorder_blocks = 1;
+
   /* If user requested unwind info, then turn off the partitioning
      optimization.  */

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c    (revision 167793)
+++ gcc/config/darwin.c    (working copy)
@@ -1145,19 +1145,6 @@ darwin_mark_decl_preserved (const char *name)
 }

 static section *
-darwin_text_section (int reloc, int weak)
-{
-  if (reloc)
-    return (weak
-        ? darwin_sections[text_unlikely_coal_section]
-        : unlikely_text_section ());
-  else
-    return (weak
-        ? darwin_sections[text_coal_section]
-        : text_section);
-}
-
-static section *
 darwin_rodata_section (int weak, bool zsize)
 {
   return (weak
@@ -1267,17 +1254,7 @@ machopic_select_section (tree decl,
   switch (categorize_decl_for_section (decl, reloc))
     {
     case SECCAT_TEXT:
-      {
-    struct cgraph_node *node;
-    if (decl && TREE_CODE (decl) == FUNCTION_DECL
-        && (node = cgraph_get_node (decl)) != NULL)
-      base_section = darwin_function_section (decl,
-                          node->frequency,
-                          node->only_called_at_startup,
-                          node->only_called_at_exit);
-    if (!base_section)
-          base_section = darwin_text_section (reloc, weak);
-      }
+      gcc_unreachable ();
       break;

     case SECCAT_RODATA:
@@ -2969,7 +2946,10 @@ darwin_function_section (tree decl, enum node_freq
               bool startup, bool exit)
 {
   if (!flag_reorder_functions)
-    return NULL;
+    return (DECL_WEAK (decl)
+        ? darwin_sections[text_coal_section]
+        : text_section);
+
   /* 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.  */
@@ -2994,7 +2974,9 @@ darwin_function_section (tree decl, enum node_freq
     return get_named_text_section
          (decl, "__TEXT,__hot,regular,pure_instructions", "_hot");
       default:
-    return NULL;
+    return (DECL_WEAK (decl)
+        ? darwin_sections[text_coal_section]
+        : text_section);
     }
 }

Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h    (revision 167793)
+++ gcc/config/darwin.h    (working copy)
@@ -664,7 +664,7 @@ extern GTY(()) section * darwin_sections[NUM_DARWI

 #undef    TARGET_ASM_SELECT_SECTION
 #define TARGET_ASM_SELECT_SECTION machopic_select_section
-#define USE_SELECT_SECTION_FOR_FUNCTIONS
+
 #undef    TARGET_ASM_FUNCTION_SECTION
 #define TARGET_ASM_FUNCTION_SECTION darwin_function_section

Reply via email to