diff options
author | Jan Hubicka <jh@suse.cz> | 2010-11-23 17:06:37 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2010-11-23 16:06:37 +0000 |
commit | f16d3f392e1b5a317ac75dbed2b9cb81d79bc50f (patch) | |
tree | 152a6dc3dab8ba9ba276a0b044af0fa1b93bb32b /gcc/config | |
parent | 7f814c0bb0216cf3c6929ae28bffcc4620ea2fef (diff) | |
download | gcc-f16d3f392e1b5a317ac75dbed2b9cb81d79bc50f.zip gcc-f16d3f392e1b5a317ac75dbed2b9cb81d79bc50f.tar.gz gcc-f16d3f392e1b5a317ac75dbed2b9cb81d79bc50f.tar.bz2 |
tree.h (DECL_HAS_IMPLICIT_SECTION_NAME_P): New macro.
* tree.h (DECL_HAS_IMPLICIT_SECTION_NAME_P): New macro.
(tree_decl_with_vis): Add implicit_section_name_p.
* targhooks.h (default_function_section): Declare.
* target.def (function_section): New hook.
* defaults.h (HOT_TEXT_SECTION_NAME,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME): Remove.
* predict.c (choose_function_section): Remove.
(estimate_bb_frequencies): Do not use choose_function_section.
* coretypes.h (enum node_frequency): Move here from cgraph.h
* cgraph.h (enum node_frequency): Remove.
* varasm.c (initialize_cold_section_name, unlikely_text_section,
unlikely_text_section_p): Remove.
(named_subsection_entry): New structure.
(get_text_section): New function.
(default_function_section): New function.
(function_section_1): Break out from ...; handle profile info.
(function_section): ... here.
(unlikely_text_section): Remove.
(unlikely_text_section_p): Use function_section_1.
(assemble_start_function): Do not initialize cold section.
(default_section_type_flags): Do not special case cold subsection.
(switch_to_section): Likewise.
* output.h (get_text_section): Define.
* config/i386/winnt.c: Do not special case cold section.
* config/darwin-protos.h (darwin_function_section): Declare.
* config/microblaze/microblaze.h (HOT_TEXT_SECTION_NAME,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME): Remove.
* config/ia64/hpux.h (HOT_TEXT_SECTION_NAME,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME): Remove.
(TARGET_ASM_FUNCTION_SECTION): Define to ia64_hpux_function_section.
* config/ia64/ia64.c (ia64_hpux_function_section): New function.
* config/darwin.c (machopic_select_section): Use
darwin_function_section.
(darwin_function_section): New function.
* config/darwin.h (HOT_TEXT_SECTION_NAME,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME): Remove.
(TARGET_ASM_FUNCTION_SECTION): Define.
* system.h (HOT_TEXT_SECTION_NAME,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME): Poison.
From-SVN: r167085
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/darwin-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/darwin.c | 48 | ||||
-rw-r--r-- | gcc/config/darwin.h | 7 | ||||
-rw-r--r-- | gcc/config/i386/winnt.c | 9 | ||||
-rw-r--r-- | gcc/config/ia64/hpux.h | 6 | ||||
-rw-r--r-- | gcc/config/ia64/ia64.c | 13 | ||||
-rw-r--r-- | gcc/config/microblaze/microblaze.h | 4 |
7 files changed, 63 insertions, 25 deletions
diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index e70de1b..08cacc1 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -57,6 +57,7 @@ extern section *machopic_select_section (tree, int, unsigned HOST_WIDE_INT); 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_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 79b4272..e8da4f1 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1233,12 +1233,22 @@ machopic_select_section (tree decl, && DECL_WEAK (decl) && !lookup_attribute ("weak_import", DECL_ATTRIBUTES (decl))); - section *base_section; + section *base_section = NULL; switch (categorize_decl_for_section (decl, reloc)) { case SECCAT_TEXT: - base_section = darwin_text_section (reloc, weak); + { + 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); + } break; case SECCAT_RODATA: @@ -2362,4 +2372,38 @@ darwin_enter_string_into_cfstring_table (tree str) } } +/* Choose named function section based on its frequency. */ + +section * +darwin_function_section (tree decl, enum node_frequency freq, + bool startup, bool exit) +{ + /* 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. */ + if (startup && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED) + return get_named_text_section + (decl, "__TEXT,__startup,regular,pure_instructions", "_startup"); + + /* Similarly for exit. */ + if (exit && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED) + return get_named_text_section (decl, + "__TEXT,__exit,regular,pure_instructions", + "_exit"); + + /* Group cold functions together, similarly for hot code. */ + switch (freq) + { + case NODE_FREQUENCY_UNLIKELY_EXECUTED: + return get_named_text_section + (decl, + "__TEXT,__unlikely,regular,pure_instructions", "_unlikely"); + case NODE_FREQUENCY_HOT: + return get_named_text_section + (decl, "__TEXT,__hot,regular,pure_instructions", "_hot"); + default: + return NULL; + } +} + #include "gt-darwin.h" diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index b93f588..854cb95 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -664,11 +664,6 @@ int darwin_label_is_anonymous_local_objc_name (const char *name); /* The generic version, archs should over-ride where required. */ #define MACHOPIC_NL_SYMBOL_PTR_SECTION ".non_lazy_symbol_pointer" -/* These are used by -fbranch-probabilities */ -#define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions" -#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \ - "__TEXT,__unlikely,regular,pure_instructions" - /* Declare the section variables. */ #ifndef USED_FOR_TARGET enum darwin_section_enum { @@ -683,6 +678,8 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS]; #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 #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index b8d2979..b8d6d69 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -414,15 +414,6 @@ i386_pe_section_type_flags (tree decl, const char *name, int reloc) flags = SECTION_CODE; else if (decl && decl_readonly_section (decl, reloc)) flags = 0; - else if (current_function_decl - && cfun - && crtl->subsections.unlikely_text_section_name - && strcmp (name, crtl->subsections.unlikely_text_section_name) == 0) - flags = SECTION_CODE; - else if (!decl - && (!current_function_decl || !cfun) - && strcmp (name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0) - flags = SECTION_CODE; else { flags = SECTION_WRITE; diff --git a/gcc/config/ia64/hpux.h b/gcc/config/ia64/hpux.h index b422441..38a005b 100644 --- a/gcc/config/ia64/hpux.h +++ b/gcc/config/ia64/hpux.h @@ -218,8 +218,4 @@ do { \ it is fixed, prevent code from being put into .text.unlikely or .text.hot. */ -#undef UNLIKELY_EXECUTED_TEXT_SECTION_NAME -#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME ".text" - -#undef HOT_TEXT_SECTION_NAME -#define HOT_TEXT_SECTION_NAME ".text" +#define TARGET_ASM_FUNCTION_SECTION ia64_hpux_function_section diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 06258cb..a007743 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -336,6 +336,8 @@ static tree ia64_builtin_decl (unsigned, bool); static reg_class_t ia64_preferred_reload_class (rtx, reg_class_t); static enum machine_mode ia64_get_reg_raw_mode (int regno); +static section * ia64_hpux_function_section (tree, enum node_frequency, + bool, bool); /* Table of valid machine attributes. */ static const struct attribute_spec ia64_attribute_table[] = @@ -11022,4 +11024,15 @@ ia64_get_reg_raw_mode (int regno) return default_get_reg_raw_mode(regno); } +/* Always default to .text section until HP-UX linker is fixed. */ + +ATTRIBUTE_UNUSED static section * +ia64_hpux_function_section (tree decl ATTRIBUTE_UNUSED, + enum node_frequency freq ATTRIBUTE_UNUSED, + bool startup ATTRIBUTE_UNUSED, + bool exit ATTRIBUTE_UNUSED) +{ + return NULL; +} + #include "gt-ia64.h" diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h index 63fd4f6..2fb438d 100644 --- a/gcc/config/microblaze/microblaze.h +++ b/gcc/config/microblaze/microblaze.h @@ -880,10 +880,6 @@ do { \ #define SBSS_SECTION_ASM_OP "\t.sbss" /* Small RW uninitialized data */ #define SBSS2_SECTION_ASM_OP "\t.sbss2" /* Small RO uninitialized data */ -#define HOT_TEXT_SECTION_NAME ".text.hot" -#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \ - ".text.unlikely" - /* We do this to save a few 10s of code space that would be taken up by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION definition in crtstuff.c. */ |