OSDN Git Service

PR middle-end/46671
authordanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Dec 2010 01:26:44 +0000 (01:26 +0000)
committerdanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Dec 2010 01:26:44 +0000 (01:26 +0000)
PR target/46685
* config/pa/pa.c (pa_function_section): New function.
(TARGET_ASM_FUNCTION_SECTION): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167581 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/pa/pa.c

index c5865dd..b1b5c12 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-07  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+
+       PR middle-end/46671
+       PR target/46685
+       * config/pa/pa.c (pa_function_section): New function.
+       (TARGET_ASM_FUNCTION_SECTION): Define.
+
 2010-12-07  Ian Lance Taylor  <iant@google.com>
            Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
index aa8ad01..ab54e4b 100644 (file)
@@ -181,6 +181,7 @@ static bool pa_print_operand_punct_valid_p (unsigned char);
 static rtx pa_internal_arg_pointer (void);
 static bool pa_can_eliminate (const int, const int);
 static void pa_conditional_register_usage (void);
+static section *pa_function_section (tree, enum node_frequency, bool, bool);
 
 /* The following extra sections are only used for SOM.  */
 static GTY(()) section *som_readonly_data_section;
@@ -388,6 +389,8 @@ static const struct default_options pa_option_optimization_table[] =
 #define TARGET_CAN_ELIMINATE pa_can_eliminate
 #undef TARGET_CONDITIONAL_REGISTER_USAGE
 #define TARGET_CONDITIONAL_REGISTER_USAGE pa_conditional_register_usage
+#undef TARGET_ASM_FUNCTION_SECTION
+#define TARGET_ASM_FUNCTION_SECTION pa_function_section
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
@@ -10200,4 +10203,27 @@ pa_conditional_register_usage (void)
     fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;
 }
 
+/* Target hook for function_section.  */
+
+static section *
+pa_function_section (tree decl, enum node_frequency freq,
+                    bool startup, bool exit)
+{
+  /* Put functions in text section if target doesn't have named sections.  */
+  if (!targetm.have_named_sections)
+    return text_section;
+
+  /* Force nested functions into the same section as the containing
+     function.  */
+  if (decl
+      && DECL_SECTION_NAME (decl) == NULL_TREE
+      && DECL_CONTEXT (decl) != NULL_TREE
+      && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL
+      && DECL_SECTION_NAME (DECL_CONTEXT (decl)) == NULL_TREE)
+    return function_section (DECL_CONTEXT (decl));
+
+  /* Otherwise, use the default function section.  */
+  return default_function_section (decl, freq, startup, exit);
+}
+
 #include "gt-pa.h"