summaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorctice <ctice@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-18 16:22:08 +0000
committerctice <ctice@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-18 16:22:08 +0000
commit065efcb175f104e463b1715a38244378d60bcf07 (patch)
treec63a7ba63b9528cef9f1bb15e12b69de24533c51 /gcc/varasm.c
parentd6a99b4bbc51fb9508bdf93ba61cec064d6e4c36 (diff)
downloadgcc-065efcb175f104e463b1715a38244378d60bcf07.tar.gz
Hot/cold partitioning update patch. The problems that this patch
attemptd to address/fix are: - Fix places where adding in_unlikely_executed_text to the enum data type "in_section" threw off switch case statements. - Make it work correctly (by turning it off) for functions where user specifies "__attribute__ section" - Make it work correctly (by turning it off) for linkonce sections - Make it work correctly with -ffunction-sections flag - Make it output correct cold section labels - Undo some changes to original assembly code generation - Turn off hot/cold partitioning in the presence of DWARF debugging (for the moment) - Turn off hot/cold partitioning for architectures that do not support named sections - Use variables rather than constants for cold section labels and names (to work correctly with -ffunction-sections, among other things) 2004-08-18 Caroline Tice <ctice@apple.com> * Makefile.in (STAGEFEEDBACK_FLAGS_TO_PASS) Add "-freorder-blocks-and-partition" to the flags used in second stage of profiledbootstrap. * bb-reorder.c (push_to_next_round_p): Add new variable, next_round_is_last; set and use variable to make sure, when partitioning, that the last trace construction round consists of all (and only) cold basic blocks. (rotate_loop): Don't copy blocks that end in a section crossing jump. (copy_bb): Correctly initialize "partition" of duplicated bb. (add_unlikely_executed_notes): Add a comment. (find_rarely_executed_basic_blocks_and_crossing_edges): Modify to make sure, if function contains hot blocks, that the successors of ENTRY_BLOCK_PTR are hot; also, only look for crossing edges if the architecture supports named sections. (mark_bb_for_unlikely_executed_section): Modify to always insert the NOTE_INSN_UNLIKELY_EXECUTED_CODE immediately after the basic block note insn. (fix_crossing_unconditional_branches): Remove extra space. (fix_edges_for_rarely_executed_code): Modify to only do partitioning work if the architecture supports named sections. (reorder_basic_blocks): Modify to only add NOTE_INSN_UNLIKELY_EXECUTED_CODE notes if the architecture supports named sections. * c-common.c (handle_section_attribute): Initialize new global variable, user_defined_section_attribute, to true if user has specified one. * cfgcleanup.c (try_forward_edges): Modify to not attempt to forward edges that cross section boundaries. * cfglayout.c (fixup_reorder_chain): Modify to only fix up partitioning information if the architecture supports named sections. * cfgrtl.c (target.h): Add statement to include this. (rtl_split_block): Make sure newly created bb gets correct partition. (try_redirect_by_replacing_jump): Make sure redirection isn't attempting to cross section boundaries. (force_nonfallthru_and_redirect): Only do partition fix up if architecture supports named sections. (rtl_split_edge): Make sure newly created bb ends up in correct partition. (commit_one_edge_insertion): Remove code that incorrectly updated basic block partition; Make sure partition fix up only happens if architecture supports named sections and it's not already done. (rtl_verify_flow_info_1): Fix if-condition on test/error condition that fallthru edges are not allowed to cross section boundaries. * defaults.h (NORMAL_TEXT_SECTION_NAME): Remove this. * final.c (final_scan_insn): Remove redundant test from if-statement; change calls to text_section into calls to function_section; add code to only to partitioning fix up if architecture supports named sections. * ifcvt.c (find_if_case_1): Make sure newly created bb has correct partition. (if_convert): Add targetm.have_named_sections to test. * output.h (unlikely_section_label): Extern declaration for new global variable. (unlikely_text_section_name): Likewise. * opts.c (decode_options): If both partitioning and DWARF debugging are turned on, issue a warning that this doesn't work, and change partitiong to basic block reordering (without hot/cold partitions). * passes.c (rest_of_handle_final): Re-set new global variable, user_defined_section_attribute, to false. (rest_of_compilation): Change options for calling partitioning function: Don't call if the user defined the section attribute, and don't call if DECL_ONE_ONLY is true for the current function. * predict.c (choose_function_section): Return immediately if we are doing hot/cold partitioning (i.e. let the basic block partitioning determine where the function belongs). * reg-stack.c (emit_swap_insn): Add condition to step over NOTE_INSN_UNLIKELY_EXECUTED_CODE notes. * toplev.c (user_defined_section_attribute): New global variable. * toplev.h (user_defined_section_attribute): Extern declaration for new global variable. * varasm.c (unlikely_section_label): New global variable. (unlikely_text_section_name): New global variable. (unlikely_text_section): Add code to initialize unlikely_text_section_name if necessary; modify to use unlikely_text_section_name and unlikely_section_label; also to use named_section properly. (in_unlikely_text_section): Modify to work correctly with named_section and to use unlikely_text_section_name. (named_section): Add code to work properly with cold section. (function_section): Clean up if-statement. * config/darwin.c (darwin_asm_named_section): Return to original code, removing use of SECTION_FORMAT_STRING. * config/arm/pe.h (switch_to_section): Add case for in_unlikely_executed_text to switch statement. * config/i386/cygming.h (switch_to_section): Likewise. * config/i386/darwin.h (NORMAL_TEXT_SECTION_NAME): Remove. (SECTION_FORMAT_STRING): Likewise. * config/mcore/mcore.h (switch_to_section): Likewise. * config/rs6000/darwin.h (NORMAL_TEXT_SECTION_NAME): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86189 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c75
1 files changed, 57 insertions, 18 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index a8d23f20207..5d02c570ae3 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -222,18 +222,42 @@ text_section (void)
void
unlikely_text_section (void)
{
- if ((in_section != in_unlikely_executed_text)
- && (in_section != in_named
- || strcmp (in_named_name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) != 0))
+ const char *name;
+ int len;
+
+ if (! unlikely_text_section_name)
{
- if (targetm.have_named_sections)
- named_section (NULL_TREE, UNLIKELY_EXECUTED_TEXT_SECTION_NAME, 0);
+ if (DECL_SECTION_NAME (current_function_decl)
+ && (strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME
+ (current_function_decl)),
+ HOT_TEXT_SECTION_NAME) != 0)
+ && (strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME
+ (current_function_decl)),
+ UNLIKELY_EXECUTED_TEXT_SECTION_NAME) != 0))
+ {
+ name = TREE_STRING_POINTER (DECL_SECTION_NAME
+ (current_function_decl));
+ len = strlen (name);
+ unlikely_text_section_name = xmalloc ((len + 10) * sizeof (char));
+ strcpy (unlikely_text_section_name, name);
+ strcat (unlikely_text_section_name, "_unlikely");
+ }
else
{
- in_section = in_unlikely_executed_text;
- fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
+ len = strlen (UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
+ unlikely_text_section_name = xmalloc (len+1 * sizeof (char));
+ strcpy (unlikely_text_section_name,
+ UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
}
-
+ }
+
+ if ((in_section != in_unlikely_executed_text)
+ && (in_section != in_named
+ || strcmp (in_named_name, unlikely_text_section_name) != 0))
+ {
+ named_section (NULL_TREE, unlikely_text_section_name, 0);
+ in_section = in_unlikely_executed_text;
+
if (!unlikely_section_label_printed)
{
ASM_OUTPUT_LABEL (asm_out_file, unlikely_section_label);
@@ -289,7 +313,14 @@ in_text_section (void)
int
in_unlikely_text_section (void)
{
- return in_section == in_unlikely_executed_text;
+ bool ret_val;
+
+ ret_val = ((in_section == in_unlikely_executed_text)
+ || (in_section == in_named
+ && unlikely_text_section_name
+ && strcmp (in_named_name, unlikely_text_section_name) == 0));
+
+ return ret_val;
}
/* Determine if we're in the data section. */
@@ -423,6 +454,16 @@ named_section (tree decl, const char *name, int reloc)
if (name == NULL)
name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
+ if (strcmp (name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0
+ && !unlikely_text_section_name)
+ {
+ unlikely_text_section_name = xmalloc
+ (strlen (UNLIKELY_EXECUTED_TEXT_SECTION_NAME) + 1
+ * sizeof (char));
+ strcpy (unlikely_text_section_name,
+ UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
+ }
+
flags = targetm.section_type_flags (decl, name, reloc);
/* Sanity check user variables for flag changes. Non-user
@@ -533,14 +574,11 @@ function_section (tree decl)
{
if (scan_ahead_for_unlikely_executed_note (get_insns()))
unlikely_text_section ();
+ else if (decl != NULL_TREE
+ && DECL_SECTION_NAME (decl) != NULL_TREE)
+ named_section (decl, (char *) 0, 0);
else
- {
- if (decl != NULL_TREE
- && DECL_SECTION_NAME (decl) != NULL_TREE)
- named_section (decl, (char *) 0, 0);
- else
- text_section ();
- }
+ text_section ();
}
/* Switch to read-only data section associated with function DECL. */
@@ -1153,7 +1191,7 @@ assemble_start_function (tree decl, const char *fnname)
free (unlikely_section_label);
unlikely_section_label = xmalloc ((strlen (fnname) + 18) * sizeof (char));
sprintf (unlikely_section_label, "%s_unlikely_section", fnname);
-
+
/* The following code does not need preprocessing in the assembler. */
app_disable ();
@@ -4481,7 +4519,8 @@ default_section_type_flags_1 (tree decl, const char *name, int reloc,
flags = SECTION_CODE;
else if (decl && decl_readonly_section_1 (decl, reloc, shlib))
flags = 0;
- else if (strcmp (name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0)
+ else if (unlikely_text_section_name
+ && strcmp (name, unlikely_text_section_name) == 0)
flags = SECTION_CODE;
else
flags = SECTION_WRITE;