Commit c543ca49 by Richard Sandiford Committed by Richard Sandiford

final.c (final_scan_insn): Flip in_cold_section_p when changing between the hot and cold sections.

	* final.c (final_scan_insn): Flip in_cold_section_p when changing
	between the hot and cold sections.  Use current_function_section
	to get the new section.
	* dwarf2out.c (output_line_info): Use in_cold_section_p to
	determine whether we are assembling hot or cold code.
	(secname_for_decl, dwarf2out_var_location): Likewise.
	(dwarf2out_init, dwarf2out_finish): Use switch_to_section.
	* varasm.c (last_text_section): Delete.
	(in_cold_section_p): New variable.
	(hot_function_section): New function.
	(current_function_section): Pass in_cold_section_p as the
	reloc argument to select_section.  Use it to decide between
	unlikely_function_section and hot_function_section.
	(assemble_start_function): Use switch_to_section.  Set
	in_cold_section_p instead of last_text_section.
	(assemble_end_function): Use switch_to_section.
	(switch_to_section): Don't set last_text_section.
	* config/darwin/darwin.c (machopic_select_section): Trust the reloc
	argument to make the right choice between hot and cold sections.

From-SVN: r108572
parent 8d46ce60
2005-12-15 Richard Sandiford <richard@codesourcery.com>
* final.c (final_scan_insn): Flip in_cold_section_p when changing
between the hot and cold sections. Use current_function_section
to get the new section.
* dwarf2out.c (output_line_info): Use in_cold_section_p to
determine whether we are assembling hot or cold code.
(secname_for_decl, dwarf2out_var_location): Likewise.
(dwarf2out_init, dwarf2out_finish): Use switch_to_section.
* varasm.c (last_text_section): Delete.
(in_cold_section_p): New variable.
(hot_function_section): New function.
(current_function_section): Pass in_cold_section_p as the
reloc argument to select_section. Use it to decide between
unlikely_function_section and hot_function_section.
(assemble_start_function): Use switch_to_section. Set
in_cold_section_p instead of last_text_section.
(assemble_end_function): Use switch_to_section.
(switch_to_section): Don't set last_text_section.
* config/darwin/darwin.c (machopic_select_section): Trust the reloc
argument to make the right choice between hot and cold sections.
2005-12-15 Nathan Sidwell <nathan@codesourcery.com> 2005-12-15 Nathan Sidwell <nathan@codesourcery.com>
Second part of MS1->MT renaming Second part of MS1->MT renaming
......
...@@ -1093,9 +1093,7 @@ machopic_select_section (tree exp, int reloc, ...@@ -1093,9 +1093,7 @@ machopic_select_section (tree exp, int reloc,
if (TREE_CODE (exp) == FUNCTION_DECL) if (TREE_CODE (exp) == FUNCTION_DECL)
{ {
if (reloc == 1 if (reloc == 1)
|| unlikely_text_section_p (last_text_section)
|| last_text_section == text_unlikely_coal_section)
base_section = (weak_p base_section = (weak_p
? text_unlikely_coal_section ? text_unlikely_coal_section
: unlikely_text_section ()); : unlikely_text_section ());
......
...@@ -7837,7 +7837,7 @@ output_line_info (void) ...@@ -7837,7 +7837,7 @@ output_line_info (void)
current_file = 1; current_file = 1;
current_line = 1; current_line = 1;
if (cfun && unlikely_text_section_p (last_text_section)) if (cfun && in_cold_section_p)
strcpy (prev_line_label, cfun->cold_section_label); strcpy (prev_line_label, cfun->cold_section_label);
else else
strcpy (prev_line_label, text_section_label); strcpy (prev_line_label, text_section_label);
...@@ -10182,7 +10182,7 @@ secname_for_decl (tree decl) ...@@ -10182,7 +10182,7 @@ secname_for_decl (tree decl)
tree sectree = DECL_SECTION_NAME (current_function_decl); tree sectree = DECL_SECTION_NAME (current_function_decl);
secname = TREE_STRING_POINTER (sectree); secname = TREE_STRING_POINTER (sectree);
} }
else if (cfun && unlikely_text_section_p (last_text_section)) else if (cfun && in_cold_section_p)
secname = cfun->cold_section_label; secname = cfun->cold_section_label;
else else
secname = text_section_label; secname = text_section_label;
...@@ -13552,7 +13552,7 @@ dwarf2out_var_location (rtx loc_note) ...@@ -13552,7 +13552,7 @@ dwarf2out_var_location (rtx loc_note)
newloc->var_loc_note = loc_note; newloc->var_loc_note = loc_note;
newloc->next = NULL; newloc->next = NULL;
if (cfun && unlikely_text_section_p (last_text_section)) if (cfun && in_cold_section_p)
newloc->section_label = cfun->cold_section_label; newloc->section_label = cfun->cold_section_label;
else else
newloc->section_label = text_section_label; newloc->section_label = text_section_label;
...@@ -13841,7 +13841,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) ...@@ -13841,7 +13841,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
ASM_OUTPUT_LABEL (asm_out_file, text_section_label); ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
if (flag_reorder_blocks_and_partition) if (flag_reorder_blocks_and_partition)
{ {
unlikely_text_section (); switch_to_section (unlikely_text_section ());
ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label); ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
} }
} }
...@@ -14177,7 +14177,7 @@ dwarf2out_finish (const char *filename) ...@@ -14177,7 +14177,7 @@ dwarf2out_finish (const char *filename)
targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0); targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
if (flag_reorder_blocks_and_partition) if (flag_reorder_blocks_and_partition)
{ {
unlikely_text_section (); switch_to_section (unlikely_text_section ());
targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0); targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0);
} }
......
...@@ -1708,22 +1708,9 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ...@@ -1708,22 +1708,9 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
break; break;
case NOTE_INSN_SWITCH_TEXT_SECTIONS: case NOTE_INSN_SWITCH_TEXT_SECTIONS:
in_cold_section_p = !in_cold_section_p;
/* The presence of this note indicates that this basic block (*debug_hooks->switch_text_section) ();
belongs in the "cold" section of the .o file. If we are switch_to_section (current_function_section ());
not already writing to the cold section we need to change
to it. */
if (last_text_section == text_section)
{
(*debug_hooks->switch_text_section) ();
switch_to_section (unlikely_text_section ());
}
else
{
(*debug_hooks->switch_text_section) ();
switch_to_section (text_section);
}
break; break;
case NOTE_INSN_BASIC_BLOCK: case NOTE_INSN_BASIC_BLOCK:
......
...@@ -499,7 +499,7 @@ extern GTY(()) section *exception_section; ...@@ -499,7 +499,7 @@ extern GTY(()) section *exception_section;
extern GTY(()) section *eh_frame_section; extern GTY(()) section *eh_frame_section;
extern GTY(()) section *in_section; extern GTY(()) section *in_section;
extern GTY(()) section *last_text_section; extern GTY(()) bool in_cold_section_p;
extern section *get_unnamed_section (unsigned int, void (*) (const void *), extern section *get_unnamed_section (unsigned int, void (*) (const void *),
const void *); const void *);
......
...@@ -167,8 +167,9 @@ section *eh_frame_section; ...@@ -167,8 +167,9 @@ section *eh_frame_section;
been selected or if we lose track of what the current section is. */ been selected or if we lose track of what the current section is. */
section *in_section; section *in_section;
/* The last text section used by asm_out_file. */ /* True if code for the current function is currently being directed
section *last_text_section; at the cold section. */
bool in_cold_section_p;
/* A linked list of all the unnamed sections. */ /* A linked list of all the unnamed sections. */
static GTY(()) section *unnamed_sections; static GTY(()) section *unnamed_sections;
...@@ -411,6 +412,22 @@ asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, ...@@ -411,6 +412,22 @@ asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
#endif /* BSS_SECTION_ASM_OP */ #endif /* BSS_SECTION_ASM_OP */
#ifndef USE_SELECT_SECTION_FOR_FUNCTIONS
/* Return the hot section for function DECL. Return text_section for
null DECLs. */
static section *
hot_function_section (tree decl)
{
if (decl != NULL_TREE
&& DECL_SECTION_NAME (decl) != NULL_TREE
&& targetm.have_named_sections)
return get_named_section (decl, NULL, 0);
else
return text_section;
}
#endif
/* Return the section for function DECL. /* Return the section for function DECL.
If DECL is NULL_TREE, return the text section. We can be passed If DECL is NULL_TREE, return the text section. We can be passed
...@@ -427,12 +444,7 @@ function_section (tree decl) ...@@ -427,12 +444,7 @@ function_section (tree decl)
#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl)); return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
#else #else
if (decl != NULL_TREE return hot_function_section (decl);
&& DECL_SECTION_NAME (decl) != NULL_TREE
&& targetm.have_named_sections)
return get_named_section (decl, NULL, 0);
else
return text_section;
#endif #endif
} }
...@@ -440,17 +452,13 @@ section * ...@@ -440,17 +452,13 @@ section *
current_function_section (void) current_function_section (void)
{ {
#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
int reloc = 0; return targetm.asm_out.select_section (current_function_decl,
in_cold_section_p,
if (unlikely_text_section_p (last_text_section))
reloc = 1;
return targetm.asm_out.select_section (current_function_decl, reloc,
DECL_ALIGN (current_function_decl)); DECL_ALIGN (current_function_decl));
#else #else
if (last_text_section) return (in_cold_section_p
return last_text_section; ? unlikely_text_section ()
return function_section (current_function_decl); : hot_function_section (current_function_decl));
#endif #endif
} }
...@@ -1083,7 +1091,7 @@ assemble_start_function (tree decl, const char *fnname) ...@@ -1083,7 +1091,7 @@ assemble_start_function (tree decl, const char *fnname)
if (flag_reorder_blocks_and_partition) if (flag_reorder_blocks_and_partition)
{ {
unlikely_text_section (); switch_to_section (unlikely_text_section ());
assemble_align (FUNCTION_BOUNDARY); assemble_align (FUNCTION_BOUNDARY);
ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_label); ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_label);
...@@ -1115,7 +1123,7 @@ assemble_start_function (tree decl, const char *fnname) ...@@ -1115,7 +1123,7 @@ assemble_start_function (tree decl, const char *fnname)
first_function_block_is_cold = true; first_function_block_is_cold = true;
} }
last_text_section = NULL; in_cold_section_p = first_function_block_is_cold;
/* Switch to the correct text section for the start of the function. */ /* Switch to the correct text section for the start of the function. */
...@@ -1200,7 +1208,7 @@ assemble_end_function (tree decl, const char *fnname) ...@@ -1200,7 +1208,7 @@ assemble_end_function (tree decl, const char *fnname)
section *save_text_section; section *save_text_section;
save_text_section = in_section; save_text_section = in_section;
unlikely_text_section (); switch_to_section (unlikely_text_section ());
ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_end_label); ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_end_label);
if (first_function_block_is_cold) if (first_function_block_is_cold)
switch_to_section (text_section); switch_to_section (text_section);
...@@ -5586,11 +5594,7 @@ switch_to_section (section *new_section) ...@@ -5586,11 +5594,7 @@ switch_to_section (section *new_section)
if (new_section->common.flags & SECTION_FORGET) if (new_section->common.flags & SECTION_FORGET)
in_section = NULL; in_section = NULL;
else else
{ in_section = new_section;
in_section = new_section;
if (new_section->common.flags & SECTION_CODE)
last_text_section = in_section;
}
if (new_section->common.flags & SECTION_NAMED) if (new_section->common.flags & SECTION_NAMED)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment