aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iains@gcc.gnu.org>2011-01-07 13:57:45 +0000
committerIain Sandoe <iains@gcc.gnu.org>2011-01-07 13:57:45 +0000
commit14d11d4097091e8abaa63866f8cc0903f581c82a (patch)
treecf51df2cf5cae2810e51692d844e2d9afa6b187f
parent0b764288f97fbb0f33b42c66ebffc061ba59cb7d (diff)
downloadgcc-14d11d4097091e8abaa63866f8cc0903f581c82a.zip
gcc-14d11d4097091e8abaa63866f8cc0903f581c82a.tar.gz
gcc-14d11d4097091e8abaa63866f8cc0903f581c82a.tar.bz2
allow the target to label code fragments generated by partitioning.
* target.def (function_switched_text_sections): New Hook. * doc/tm.texi Regenerated. * doc/tm.texi.in (TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS) New. * final.c (default_function_switched_text_sections): New. (final_scan_insn): Call function_switched_text_sections when a mid-function section change occurs. * output.h (default_function_switched_text_sections): Declare. * config/darwin-protos.h (darwin_function_switched_text_sections) : Likewise. * config/darwin.c (darwin_function_switched_text_sections): New. * config/darwin.h (TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS) New. From-SVN: r168571
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/config/darwin-protos.h2
-rw-r--r--gcc/config/darwin.c50
-rw-r--r--gcc/config/darwin.h4
-rw-r--r--gcc/doc/tm.texi4
-rw-r--r--gcc/doc/tm.texi.in2
-rw-r--r--gcc/final.c10
-rw-r--r--gcc/output.h3
-rw-r--r--gcc/target.def11
9 files changed, 75 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 01438e7..54c14cc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,20 @@
2011-01-07 Iain Sandoe <iains@gcc.gnu.org>
+ * target.def (function_switched_text_sections): New Hook.
+ * doc/tm.texi Regenerated.
+ * doc/tm.texi.in (TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS)
+ New.
+ * final.c (default_function_switched_text_sections): New.
+ (final_scan_insn): Call function_switched_text_sections when a mid-function section
+ change occurs.
+ * output.h (default_function_switched_text_sections): Declare.
+ * config/darwin-protos.h (darwin_function_switched_text_sections) : Likewise.
+ * config/darwin.c (darwin_function_switched_text_sections): New.
+ * config/darwin.h (TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS)
+ New.
+
+2011-01-07 Iain Sandoe <iains@gcc.gnu.org>
+
* dwarf2out.c (gen_subprogram_die): Add pubnames with code ranges for
DWARF >= 3. Add pubnames for the primary section and a reduced DIE for
the secondary code fragment when outputting for DWARF == 2.
diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h
index fca8065..bf81ed9 100644
--- a/gcc/config/darwin-protos.h
+++ b/gcc/config/darwin-protos.h
@@ -58,6 +58,8 @@ extern section *machopic_select_rtx_section (enum machine_mode, rtx,
unsigned HOST_WIDE_INT);
extern section *darwin_function_section (tree, enum node_frequency, bool, bool);
+extern void darwin_function_switched_text_sections (FILE *, tree, bool);
+
extern void darwin_unique_section (tree decl, int reloc);
extern void darwin_asm_named_section (const char *, unsigned int, tree);
extern void darwin_non_lazy_pcrel (FILE *, rtx);
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index d9185db..5560bf9 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -2572,18 +2572,6 @@ darwin_override_options (void)
if (!global_options_set.x_dwarf_strict)
dwarf_strict = 1;
- /* FIXME: Darwin cannot support multiple function sections until (a) the new code
- atoms created have a proper start label and (b) there are suitable pubnames
- emitted. This applies to all current Darwin versions (OSX <= 10.6.5). */
- if (global_options.x_flag_reorder_blocks_and_partition)
- {
- inform (input_location,
- "-freorder-blocks-and-partition is currently disabled for this "
- "platform");
- flag_reorder_blocks_and_partition = 0;
- flag_reorder_blocks = 1;
- }
-
/* Do not allow unwind tables to be generated by default for m32.
fnon-call-exceptions will override this, regardless of what we do. */
if (generating_for_darwin_version < 10
@@ -2591,13 +2579,13 @@ darwin_override_options (void)
&& !TARGET_64BIT)
global_options.x_flag_asynchronous_unwind_tables = 0;
- /* Disable -freorder-blocks-and-partition when unwind tables are being emitted
- for Darwin < 10 (OSX 10.6).
- The strategy is, "Unless the User has specifically set/unset an unwind flag
- we will switch off -freorder-blocks-and-partition when unwind tables will be
- generated". If the User specifically sets flags... we assume (s)he knows
- why... */
- if (generating_for_darwin_version < 10
+ /* Disable -freorder-blocks-and-partition when unwind tables are being emitted
+ for Darwin < 10 (OSX 10.6).
+ The strategy is, "Unless the User has specifically set/unset an unwind flag
+ we will switch off -freorder-blocks-and-partition when unwind tables will be
+ generated". If the User specifically sets flags... we assume (s)he knows
+ why... */
+ if (generating_for_darwin_version < 9
&& global_options_set.x_flag_reorder_blocks_and_partition
&& ((global_options.x_flag_exceptions /* User, c++, java */
&& !global_options_set.x_flag_exceptions) /* User specified... */
@@ -2607,13 +2595,6 @@ darwin_override_options (void)
&& !global_options_set.x_flag_non_call_exceptions)
|| (global_options.x_flag_asynchronous_unwind_tables
&& !global_options_set.x_flag_asynchronous_unwind_tables)))
- {
- inform (input_location,
- "-freorder-blocks-and-partition does not work with exceptions "
- "on this architecture");
- flag_reorder_blocks_and_partition = 0;
- flag_reorder_blocks = 1;
- }
if (flag_mkernel || flag_apple_kext)
{
@@ -3066,4 +3047,21 @@ darwin_function_section (tree decl, enum node_frequency freq,
}
}
+/* When a function is partitioned between sections, we need to insert a label
+ at the start of each new chunk - so that it may become a valid 'atom' for
+ eh and debug purposes. Without this the linker will emit warnings if one
+ tries to add line location information (since the switched fragment will
+ be anonymous). */
+
+void
+darwin_function_switched_text_sections (FILE *fp, tree decl, bool new_is_cold)
+{
+ char buf[128];
+ snprintf (buf, 128, "%s%s",new_is_cold?"__cold_sect_of_":"__hot_sect_of_",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ /* Make sure we pick up all the relevant quotes etc. */
+ assemble_name_raw (fp, (const char *) buf);
+ fputs (":\n", fp);
+}
+
#include "gt-darwin.h"
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 9092d6b..74ced9c 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -673,6 +673,10 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
#undef TARGET_ASM_FUNCTION_SECTION
#define TARGET_ASM_FUNCTION_SECTION darwin_function_section
+#undef TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS
+#define TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS \
+ darwin_function_switched_text_sections
+
#undef TARGET_ASM_SELECT_RTX_SECTION
#define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
#undef TARGET_ASM_UNIQUE_SECTION
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index b13ddfb..139c5a7 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -7325,6 +7325,10 @@ at startup (from static constructors or it is @code{main()}).
Return NULL if function should go to default text section.
@end deftypefn
+@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS (FILE *@var{file}, tree @var{decl}, bool @var{new_is_cold})
+Used by the target to emit any assembler directives or additional labels needed when a function is partitioned between different sections. Output should be written to @var{file}. The function decl is available as @var{decl} and the new section is `cold' if @var{new_is_cold} is @code{true}.
+@end deftypefn
+
@deftypevr {Target Hook} bool TARGET_HAVE_NAMED_SECTIONS
This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
It must not be modified by command-line option processing.
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f78eba9..2085816 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -7298,6 +7298,8 @@ at startup (from static constructors or it is @code{main()}).
Return NULL if function should go to default text section.
@end deftypefn
+@hook TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS
+
@hook TARGET_HAVE_NAMED_SECTIONS
This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
It must not be modified by command-line option processing.
diff --git a/gcc/final.c b/gcc/final.c
index ebe21b6..09dec08 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -256,6 +256,13 @@ default_function_pro_epilogue (FILE *file ATTRIBUTE_UNUSED,
{
}
+void
+default_function_switched_text_sections (FILE *file ATTRIBUTE_UNUSED,
+ tree decl ATTRIBUTE_UNUSED,
+ bool new_is_cold ATTRIBUTE_UNUSED)
+{
+}
+
/* Default target hook that outputs nothing to a stream. */
void
no_asm_to_stream (FILE *file ATTRIBUTE_UNUSED)
@@ -1841,6 +1848,9 @@ final_scan_insn (rtx insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
debug_hooks->switch_text_section ();
switch_to_section (current_function_section ());
+ targetm.asm_out.function_switched_text_sections (asm_out_file,
+ current_function_decl,
+ in_cold_section_p);
break;
case NOTE_INSN_BASIC_BLOCK:
diff --git a/gcc/output.h b/gcc/output.h
index 6a835c0..39225a3a 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -417,6 +417,9 @@ extern const char *user_label_prefix;
/* Default target function prologue and epilogue assembler output. */
extern void default_function_pro_epilogue (FILE *, HOST_WIDE_INT);
+/* Default target function switched text sections. */
+extern void default_function_switched_text_sections (FILE *, tree, bool);
+
/* Default target hook that outputs nothing to a stream. */
extern void no_asm_to_stream (FILE *);
diff --git a/gcc/target.def b/gcc/target.def
index 653981f..9d96e65 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -294,6 +294,17 @@ DEFHOOK
section *, (tree decl, enum node_frequency freq, bool startup, bool exit),
default_function_section)
+/* Output the assembler code for function exit. */
+DEFHOOK
+(function_switched_text_sections,
+ "Used by the target to emit any assembler directives or additional\
+ labels needed when a function is partitioned between different\
+ sections. Output should be written to @var{file}. The function\
+ decl is available as @var{decl} and the new section is `cold' if\
+ @var{new_is_cold} is @code{true}.",
+ void, (FILE *file, tree decl, bool new_is_cold),
+ default_function_switched_text_sections)
+
/* Return a mask describing how relocations should be treated when
selecting sections. Bit 1 should be set if global relocations
should be placed in a read-write section; bit 0 should be set if