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
This commit is contained in:
parent
0b764288f9
commit
14d11d4097
9 changed files with 75 additions and 26 deletions
|
@ -1,3 +1,18 @@
|
|||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
10
gcc/final.c
10
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:
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue