aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2005-04-27 21:35:20 +0000
committerCaroline Tice <ctice@gcc.gnu.org>2005-04-27 14:35:20 -0700
commitc7466deed4c713f843bf5256ffddbeca135d1371 (patch)
tree25224a7ffa0ad51eb003a772afe847c2781c56d4 /gcc/dwarf2out.c
parent32cf6a3bfe9f7512312a377648f13a437bb1a0c7 (diff)
downloadgcc-c7466deed4c713f843bf5256ffddbeca135d1371.zip
gcc-c7466deed4c713f843bf5256ffddbeca135d1371.tar.gz
gcc-c7466deed4c713f843bf5256ffddbeca135d1371.tar.bz2
Correct fixes for various hot/cold partitioning concerns.
2005-04-27 Caroline Tice <ctice@apple.com> * bb-reorder.c (find_rarely_executed_basic_blocks_and_crossing_edges): Remove targetm.have_named_sections test. (fix_edges_for_rarely_executed_code): Likewise. (insert_section_boundary_note): Likewise. (reorder_basic_blocks): Check partitioning flag before calling verify_hot_cold_block_grouping. * dbxout.c (dbxout_function_end): Get hot/cold section labels from the function struct rather than global variables. * dwarf2out.c (COLD_TEXT_SECTION_LABEL): New macro. (COLD_END_LABEL): Likewise (cold_text_section_label): New static global variable. (cold_end_label): Likewise. (dwarf2out_switch_text_section): Get hot/cold section labels from the function struct rather than global variables; test to make sure cfun is defined. (output_aranges): Use cold_text_section_label and cold_end_label; check partitioning flag before putting out delta. (output_ranges): Remove incorrect code attempting to use hot/cold labels. (output_line_info): Get cold section label from function struct; test to make sure cfun is defined. (add_location_or_const_value_attribute): Likewise. (dwarf2out_var_location): Likewise. (dwarf2out_init): Generate cold_text_section_label and cold_end_label; write out cold_text_section_label if partition flag is set. (dwarf2out_finish): Write out cold_end_label if partition flag is set; * function.h (struct function): Add new fields to point to hot/cold section labels: hot_section_label, cold_section_label, hot_section_end_label and cold_section_end_label; also add new field for cold text section name, unlikely_text_section_name. * opts.c (decode_options): Turn off partitioning flag if !targetm.have_named_sections. * output.h (hot_section_label): Remove. (hot_section_end_label): Remove. (cold_section_end_label): Remove. (unlikely_section_label): Remove. (unlikely_text_section_name): Remove. * passes.c (rest_of_handle_final): Remove extra blank line. * varasm.c (unlikely_section_label): Remove. (hot_section_label): Remove. (hot_section_end_label): Remove. (cold_section_end_label): Remove. (unlikely_text_section_name): Remove. (initialize_cold_section_name): Modify to call targetm.strip_name_encoding; to store cold section name in current function struct, if it exists; and to only use the decl_section_name if flag_named_sections is true. (unlikely_text_section): Modify to get section name out of current function struct, if there is one; otherwise build it from UNLIKELY_EXECUTED_TEXT_SECTION_NAME. (in_unlikely_text_section): Likewise. (named_section): Modify to get/put cold section name in current function struct, if there is one. (function_section): Change 'bool unlikely' to 'int reloc'; check targetm.have_named_sections before calling named_section. (current_function_section): Likewise. (assemble_start_function): Modify to get/put unlikely_text_section_name in current function struct; modify to get hot/cold section labels from function struct; initialize labels using ASM_GENERATE_INTERNAL_LABEL; test partitioning flag before writing out hot section label. (assemble_end_function): Test partitioning flag before writing out hot/cold section labels. (default_section_type_flags_1): Get cold text section name from function struct if there is one; Set flags correctly for cold text section if there is not a current function struct. From-SVN: r98885
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c103
1 files changed, 59 insertions, 44 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index a1ff63f..d44822c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4122,6 +4122,9 @@ static int maybe_emit_file (int);
#ifndef TEXT_SECTION_LABEL
#define TEXT_SECTION_LABEL "Ltext"
#endif
+#ifndef COLD_TEXT_SECTION_LABEL
+#define COLD_TEXT_SECTION_LABEL "Ltext_cold"
+#endif
#ifndef DEBUG_LINE_SECTION_LABEL
#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
#endif
@@ -4149,6 +4152,8 @@ static int maybe_emit_file (int);
static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char cold_text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char cold_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -4159,6 +4164,9 @@ static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
#ifndef TEXT_END_LABEL
#define TEXT_END_LABEL "Letext"
#endif
+#ifndef COLD_END_LABEL
+#define COLD_END_LABEL "Letext_cold"
+#endif
#ifndef BLOCK_BEGIN_LABEL
#define BLOCK_BEGIN_LABEL "LBB"
#endif
@@ -6800,12 +6808,15 @@ dwarf2out_switch_text_section (void)
{
dw_fde_ref fde;
+ if (!cfun)
+ internal_error ("Attempt to switch text sections without any code.");
+
fde = &fde_table[fde_table_in_use - 1];
fde->dw_fde_switched_sections = true;
- fde->dw_fde_hot_section_label = xstrdup (hot_section_label);
- fde->dw_fde_hot_section_end_label = xstrdup (hot_section_end_label);
- fde->dw_fde_unlikely_section_label = xstrdup (unlikely_section_label);
- fde->dw_fde_unlikely_section_end_label = xstrdup (cold_section_end_label);
+ fde->dw_fde_hot_section_label = cfun->hot_section_label;
+ fde->dw_fde_hot_section_end_label = cfun->hot_section_end_label;
+ fde->dw_fde_unlikely_section_label = cfun->cold_section_label;
+ fde->dw_fde_unlikely_section_end_label = cfun->cold_section_end_label;
separate_line_info_table_in_use++;
}
@@ -7235,14 +7246,15 @@ output_aranges (void)
}
dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_section_label, "Address");
- if (last_text_section == in_unlikely_executed_text
- || (last_text_section == in_named
- && last_text_section_name == unlikely_text_section_name))
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
- unlikely_section_label, "Length");
- else
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
- text_section_label, "Length");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
+ text_section_label, "Length");
+ if (flag_reorder_blocks_and_partition)
+ {
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, cold_text_section_label,
+ "Address");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, cold_end_label,
+ cold_text_section_label, "Length");
+ }
for (i = 0; i < arange_table_in_use; i++)
{
@@ -7332,24 +7344,11 @@ output_ranges (void)
base of the text section. */
if (separate_line_info_table_in_use == 0)
{
- if (last_text_section == in_unlikely_executed_text
- || (last_text_section == in_named
- && last_text_section_name == unlikely_text_section_name))
- {
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
- unlikely_section_label,
- fmt, i * 2 * DWARF2_ADDR_SIZE);
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
- unlikely_section_label, NULL);
- }
- else
- {
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
- text_section_label,
- fmt, i * 2 * DWARF2_ADDR_SIZE);
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
- text_section_label, NULL);
- }
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
+ text_section_label,
+ fmt, i * 2 * DWARF2_ADDR_SIZE);
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
+ text_section_label, NULL);
}
/* Otherwise, we add a DW_AT_entry_pc attribute to force the
@@ -7734,11 +7733,12 @@ output_line_info (void)
a series of state machine operations. */
current_file = 1;
current_line = 1;
-
- if (last_text_section == in_unlikely_executed_text
- || (last_text_section == in_named
- && last_text_section_name == unlikely_text_section_name))
- strcpy (prev_line_label, unlikely_section_label);
+
+ if (cfun
+ && (last_text_section == in_unlikely_executed_text
+ || (last_text_section == in_named
+ && last_text_section_name == cfun->unlikely_text_section_name)))
+ strcpy (prev_line_label, cfun->cold_section_label);
else
strcpy (prev_line_label, text_section_label);
for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index)
@@ -10112,7 +10112,6 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl,
dw_loc_list_ref list;
rtx varloc;
-
/* We need to figure out what section we should use as the base
for the address ranges where a given location is valid.
1. If this particular DECL has a section associated with it,
@@ -10134,10 +10133,12 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl,
tree sectree = DECL_SECTION_NAME (current_function_decl);
secname = TREE_STRING_POINTER (sectree);
}
- else if (last_text_section == in_unlikely_executed_text
- || (last_text_section == in_named
- && last_text_section_name == unlikely_text_section_name))
- secname = unlikely_section_label;
+ else if (cfun
+ && (last_text_section == in_unlikely_executed_text
+ || (last_text_section == in_named
+ && last_text_section_name ==
+ cfun->unlikely_text_section_name)))
+ secname = cfun->cold_section_label;
else
secname = text_section_label;
@@ -13260,10 +13261,11 @@ dwarf2out_var_location (rtx loc_note)
newloc->var_loc_note = loc_note;
newloc->next = NULL;
- if (last_text_section == in_unlikely_executed_text
- || (last_text_section == in_named
- && last_text_section_name == unlikely_text_section_name))
- newloc->section_label = unlikely_section_label;
+ if (cfun
+ && (last_text_section == in_unlikely_executed_text
+ || (last_text_section == in_named
+ && last_text_section_name == cfun->unlikely_text_section_name)))
+ newloc->section_label = cfun->cold_section_label;
else
newloc->section_label = text_section_label;
@@ -13501,6 +13503,9 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
DEBUG_ABBREV_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label,
+ COLD_TEXT_SECTION_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (cold_end_label, COLD_END_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
DEBUG_INFO_SECTION_LABEL, 0);
@@ -13525,6 +13530,11 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
text_section ();
ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
+ if (flag_reorder_blocks_and_partition)
+ {
+ unlikely_text_section ();
+ ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
+ }
}
/* A helper function for dwarf2out_finish called through
@@ -13856,6 +13866,11 @@ dwarf2out_finish (const char *filename)
/* Output a terminator label for the .text section. */
text_section ();
targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
+ if (flag_reorder_blocks_and_partition)
+ {
+ unlikely_text_section ();
+ targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0);
+ }
/* Output the source line correspondence table. We must do this
even if there is no line information. Otherwise, on an empty