const char *dw_fde_begin;
const char *dw_fde_current_label;
const char *dw_fde_end;
+ const char *dw_fde_hot_section_label;
+ const char *dw_fde_hot_section_end_label;
+ const char *dw_fde_unlikely_section_label;
+ const char *dw_fde_unlikely_section_end_label;
+ bool dw_fde_switched_sections;
dw_cfi_ref dw_fde_cfi;
unsigned funcdef_number;
unsigned all_throwers_are_sibcalls : 1;
dw2_asm_output_encoded_addr_rtx (fde_encoding,
sym_ref,
"FDE initial location");
- dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
- fde->dw_fde_end, fde->dw_fde_begin,
- "FDE address range");
+ if (fde->dw_fde_switched_sections)
+ {
+ rtx sym_ref2 = gen_rtx_SYMBOL_REF (Pmode,
+ fde->dw_fde_unlikely_section_label);
+ rtx sym_ref3= gen_rtx_SYMBOL_REF (Pmode,
+ fde->dw_fde_hot_section_label);
+ SYMBOL_REF_FLAGS (sym_ref2) |= SYMBOL_FLAG_LOCAL;
+ SYMBOL_REF_FLAGS (sym_ref3) |= SYMBOL_FLAG_LOCAL;
+ dw2_asm_output_encoded_addr_rtx (fde_encoding, sym_ref3,
+ "FDE initial location");
+ dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
+ fde->dw_fde_hot_section_end_label,
+ fde->dw_fde_hot_section_label,
+ "FDE address range");
+ dw2_asm_output_encoded_addr_rtx (fde_encoding, sym_ref2,
+ "FDE initial location");
+ dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
+ fde->dw_fde_unlikely_section_end_label,
+ fde->dw_fde_unlikely_section_label,
+ "FDE address range");
+ }
+ else
+ dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
+ fde->dw_fde_end, fde->dw_fde_begin,
+ "FDE address range");
}
else
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_begin,
"FDE initial location");
- dw2_asm_output_delta (DWARF2_ADDR_SIZE,
- fde->dw_fde_end, fde->dw_fde_begin,
- "FDE address range");
+ if (fde->dw_fde_switched_sections)
+ {
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE,
+ fde->dw_fde_hot_section_label,
+ "FDE initial location");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE,
+ fde->dw_fde_hot_section_end_label,
+ fde->dw_fde_hot_section_label,
+ "FDE address range");
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE,
+ fde->dw_fde_unlikely_section_label,
+ "FDE initial location");
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE,
+ fde->dw_fde_unlikely_section_end_label,
+ fde->dw_fde_unlikely_section_label,
+ "FDE address range");
+ }
+ else
+ dw2_asm_output_delta (DWARF2_ADDR_SIZE,
+ fde->dw_fde_end, fde->dw_fde_begin,
+ "FDE address range");
}
if (augmentation[0])
fde->decl = current_function_decl;
fde->dw_fde_begin = dup_label;
fde->dw_fde_current_label = NULL;
+ fde->dw_fde_hot_section_label = NULL;
+ fde->dw_fde_hot_section_end_label = NULL;
+ fde->dw_fde_unlikely_section_label = NULL;
+ fde->dw_fde_unlikely_section_end_label = NULL;
+ fde->dw_fde_switched_sections = false;
fde->dw_fde_end = NULL;
fde->dw_fde_cfi = NULL;
fde->funcdef_number = current_function_funcdef_no;
dwarf2out_frame_finish (void)
{
/* Output call frame information. */
- if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
+ if (write_symbols == DWARF2_DEBUG
+ || write_symbols == VMS_AND_DWARF2_DEBUG
+#ifdef DWARF2_FRAME_INFO
+ || DWARF2_FRAME_INFO
+#endif
+ )
output_call_frame_info (0);
#ifndef TARGET_UNWIND_INFO
static void dwarf2out_abstract_function (tree);
static void dwarf2out_var_location (rtx);
static void dwarf2out_begin_function (tree);
+static void dwarf2out_switch_text_section (void);
/* The debug hooks structure. */
debug_nothing_rtx, /* label */
debug_nothing_int, /* handle_pch */
dwarf2out_var_location,
+ dwarf2out_switch_text_section,
1 /* start_end_main_source_file */
};
#endif
{
rtx GTY (()) var_loc_note;
const char * GTY (()) label;
+ const char * GTY (()) section_label;
struct var_loc_node * GTY (()) next;
};
*d = new_loc_list (descr, begin, end, section, 0);
}
+static void
+dwarf2out_switch_text_section (void)
+{
+ dw_fde_ref fde;
+
+ 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);
+ separate_line_info_table_in_use++;
+}
+
/* Output the location list given to us. */
static void
}
dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_section_label, "Address");
- dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
- text_section_label, "Length");
+ 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");
for (i = 0; i < arange_table_in_use; i++)
{
base of the text section. */
if (separate_line_info_table_in_use == 0)
{
- 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);
+ 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);
+ }
}
/* Otherwise, we add a DW_AT_entry_pc attribute to force the
a series of state machine operations. */
current_file = 1;
current_line = 1;
- strcpy (prev_line_label, text_section_label);
+ 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);
+ else
+ strcpy (prev_line_label, text_section_label);
for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index)
{
dw_line_info_ref line_info = &line_info_table[lt_index];
case METHOD_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
- case FILE_TYPE:
case OFFSET_TYPE:
case LANG_TYPE:
case VECTOR_TYPE:
}
+/* Generate an RTL constant from a decl initializer INIT with decl type TYPE,
+ for use in a later add_const_value_attribute call. */
+
+static rtx
+rtl_for_decl_init (tree init, tree type)
+{
+ rtx rtl = NULL_RTX;
+
+ /* If a variable is initialized with a string constant without embedded
+ zeros, build CONST_STRING. */
+ if (TREE_CODE (init) == STRING_CST && TREE_CODE (type) == ARRAY_TYPE)
+ {
+ tree enttype = TREE_TYPE (type);
+ tree domain = TYPE_DOMAIN (type);
+ enum machine_mode mode = TYPE_MODE (enttype);
+
+ if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1
+ && domain
+ && integer_zerop (TYPE_MIN_VALUE (domain))
+ && compare_tree_int (TYPE_MAX_VALUE (domain),
+ TREE_STRING_LENGTH (init) - 1) == 0
+ && ((size_t) TREE_STRING_LENGTH (init)
+ == strlen (TREE_STRING_POINTER (init)) + 1))
+ rtl = gen_rtx_CONST_STRING (VOIDmode,
+ ggc_strdup (TREE_STRING_POINTER (init)));
+ }
+ /* If the initializer is something that we know will expand into an
+ immediate RTL constant, expand it now. Expanding anything else
+ tends to produce unresolved symbols; see debug/5770 and c++/6381. */
+ /* Aggregate, vector, and complex types may contain constructors that may
+ result in code being generated when expand_expr is called, so we can't
+ handle them here. Integer and float are useful and safe types to handle
+ here. */
+ else if ((INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type))
+ && initializer_constant_valid_p (init, type) == null_pointer_node)
+ {
+ rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
+
+ /* If expand_expr returns a MEM, it wasn't immediate. */
+ gcc_assert (!rtl || !MEM_P (rtl));
+ }
+
+ return rtl;
+}
+
+/* Generate RTL for the variable DECL to represent its location. */
+
static rtx
rtl_for_decl_location (tree decl)
{
and will have been substituted directly into all expressions that use it.
C does not have such a concept, but C++ and other languages do. */
else if (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
- {
- /* If a variable is initialized with a string constant without embedded
- zeros, build CONST_STRING. */
- if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
- && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
- {
- tree arrtype = TREE_TYPE (decl);
- tree enttype = TREE_TYPE (arrtype);
- tree domain = TYPE_DOMAIN (arrtype);
- tree init = DECL_INITIAL (decl);
- enum machine_mode mode = TYPE_MODE (enttype);
-
- if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1
- && domain
- && integer_zerop (TYPE_MIN_VALUE (domain))
- && compare_tree_int (TYPE_MAX_VALUE (domain),
- TREE_STRING_LENGTH (init) - 1) == 0
- && ((size_t) TREE_STRING_LENGTH (init)
- == strlen (TREE_STRING_POINTER (init)) + 1))
- rtl = gen_rtx_CONST_STRING (VOIDmode,
- ggc_strdup (TREE_STRING_POINTER (init)));
- }
- /* If the initializer is something that we know will expand into an
- immediate RTL constant, expand it now. Expanding anything else
- tends to produce unresolved symbols; see debug/5770 and c++/6381. */
- else if (TREE_CODE (DECL_INITIAL (decl)) == INTEGER_CST
- || TREE_CODE (DECL_INITIAL (decl)) == REAL_CST)
- {
- rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
- EXPAND_INITIALIZER);
- /* If expand_expr returns a MEM, it wasn't immediate. */
- gcc_assert (!rtl || !MEM_P (rtl));
- }
- }
+ rtl = rtl_for_decl_init (DECL_INITIAL (decl), TREE_TYPE (decl));
if (rtl)
rtl = targetm.delegitimize_address (rtl);
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
secname = text_section_label;
{
tree init = DECL_INITIAL (decl);
tree type = TREE_TYPE (decl);
+ rtx rtl;
- if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) && init
- && initializer_constant_valid_p (init, type) == null_pointer_node)
+ if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) && init)
/* OK */;
else
return;
- switch (TREE_CODE (type))
- {
- case INTEGER_TYPE:
- if (host_integerp (init, 0))
- add_AT_unsigned (var_die, DW_AT_const_value,
- tree_low_cst (init, 0));
- else
- add_AT_long_long (var_die, DW_AT_const_value,
- TREE_INT_CST_HIGH (init),
- TREE_INT_CST_LOW (init));
- break;
-
- default:;
- }
+ rtl = rtl_for_decl_init (init, type);
+ if (rtl)
+ add_const_value_attribute (var_die, rtl);
}
/* Generate a DW_AT_name attribute given some string value to be included as
if (TYPE_P (fn))
fn = TYPE_STUB_DECL (fn);
- /* TYPE_STUB_DECL may have given us a NULL, which decl_function_context
- won't like. */
- if (fn)
- fn = decl_function_context (fn);
-
+ fn = decl_function_context (fn);
if (fn)
dwarf2out_abstract_function (fn);
}
if (TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))
&& ! lookup_decl_die (member))
{
+ dw_die_ref type_die;
gcc_assert (!decl_ultimate_origin (member));
push_decl_scope (type);
+ type_die = lookup_type_die (type);
if (TREE_CODE (member) == FUNCTION_DECL)
- gen_subprogram_die (member, lookup_type_die (type));
+ gen_subprogram_die (member, type_die);
+ else if (TREE_CODE (member) == FIELD_DECL)
+ {
+ /* Ignore the nameless fields that are used to skip bits but handle
+ C++ anonymous unions and structs. */
+ if (DECL_NAME (member) != NULL_TREE
+ || TREE_CODE (TREE_TYPE (member)) == UNION_TYPE
+ || TREE_CODE (TREE_TYPE (member)) == RECORD_TYPE)
+ {
+ gen_type_die (member_declared_type (member), type_die);
+ gen_field_die (member, type_die);
+ }
+ }
else
- gen_variable_die (member, lookup_type_die (type));
+ gen_variable_die (member, type_die);
pop_decl_scope ();
}
if (!old_die || !get_AT (old_die, DW_AT_inline))
equate_decl_number_to_die (decl, subr_die);
- ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_BEGIN_LABEL,
- current_function_funcdef_no);
- add_AT_lbl_id (subr_die, DW_AT_low_pc, label_id);
- ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
- current_function_funcdef_no);
- add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id);
-
- add_pubname (decl, subr_die);
- add_arange (decl, subr_die);
+ if (!flag_reorder_blocks_and_partition)
+ {
+ ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_BEGIN_LABEL,
+ current_function_funcdef_no);
+ add_AT_lbl_id (subr_die, DW_AT_low_pc, label_id);
+ ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
+ current_function_funcdef_no);
+ add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id);
+
+ add_pubname (decl, subr_die);
+ add_arange (decl, subr_die);
+ }
+ else
+ { /* Do nothing for now; maybe need to duplicate die, one for
+ hot section and ond for cold section, then use the hot/cold
+ section begin/end labels to generate the aranges... */
+ /*
+ add_AT_lbl_id (subr_die, DW_AT_low_pc, hot_section_label);
+ add_AT_lbl_id (subr_die, DW_AT_high_pc, hot_section_end_label);
+ add_AT_lbl_id (subr_die, DW_AT_lo_user, unlikely_section_label);
+ add_AT_lbl_id (subr_die, DW_AT_hi_user, cold_section_end_label);
+
+ add_pubname (decl, subr_die);
+ add_arange (decl, subr_die);
+ add_arange (decl, subr_die);
+ */
+ }
#ifdef MIPS_DEBUGGING_INFO
/* Add a reference to the FDE for this routine. */
}
}
-/* Generate a DIE for a lexical block. */
+/* A helper function for gen_lexical_block_die and gen_inlined_subroutine_die.
+ Add low_pc and high_pc attributes to the DIE for a block STMT. */
-static void
-gen_lexical_block_die (tree stmt, dw_die_ref context_die, int depth)
+static inline void
+add_high_low_attributes (tree stmt, dw_die_ref die)
{
- dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
- if (! BLOCK_ABSTRACT (stmt))
+ if (BLOCK_FRAGMENT_CHAIN (stmt))
{
- if (BLOCK_FRAGMENT_CHAIN (stmt))
- {
- tree chain;
+ tree chain;
- add_AT_range_list (stmt_die, DW_AT_ranges, add_ranges (stmt));
+ add_AT_range_list (die, DW_AT_ranges, add_ranges (stmt));
- chain = BLOCK_FRAGMENT_CHAIN (stmt);
- do
- {
- add_ranges (chain);
- chain = BLOCK_FRAGMENT_CHAIN (chain);
- }
- while (chain);
- add_ranges (NULL);
- }
- else
+ chain = BLOCK_FRAGMENT_CHAIN (stmt);
+ do
{
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
- BLOCK_NUMBER (stmt));
- add_AT_lbl_id (stmt_die, DW_AT_low_pc, label);
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL,
- BLOCK_NUMBER (stmt));
- add_AT_lbl_id (stmt_die, DW_AT_high_pc, label);
+ add_ranges (chain);
+ chain = BLOCK_FRAGMENT_CHAIN (chain);
}
+ while (chain);
+ add_ranges (NULL);
+ }
+ else
+ {
+ ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
+ BLOCK_NUMBER (stmt));
+ add_AT_lbl_id (die, DW_AT_low_pc, label);
+ ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL,
+ BLOCK_NUMBER (stmt));
+ add_AT_lbl_id (die, DW_AT_high_pc, label);
}
+}
+
+/* Generate a DIE for a lexical block. */
+
+static void
+gen_lexical_block_die (tree stmt, dw_die_ref context_die, int depth)
+{
+ dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
+
+ if (! BLOCK_ABSTRACT (stmt))
+ add_high_low_attributes (stmt, stmt_die);
decls_for_scope (stmt, stmt_die, depth);
}
{
dw_die_ref subr_die
= new_die (DW_TAG_inlined_subroutine, context_die, stmt);
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
add_abstract_origin_attribute (subr_die, decl);
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
- BLOCK_NUMBER (stmt));
- add_AT_lbl_id (subr_die, DW_AT_low_pc, label);
- ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_END_LABEL,
- BLOCK_NUMBER (stmt));
- add_AT_lbl_id (subr_die, DW_AT_high_pc, label);
+ add_high_low_attributes (stmt, subr_die);
+
decls_for_scope (stmt, subr_die, depth);
current_function_has_inlines = 1;
}
gen_ptr_to_mbr_type_die (type, context_die);
break;
- case FILE_TYPE:
- gen_type_die (TREE_TYPE (type), context_die);
- /* No way to represent these in Dwarf yet! */
- gcc_unreachable ();
- break;
-
case FUNCTION_TYPE:
/* Force out return type (in case it wasn't forced out already). */
gen_type_die (TREE_TYPE (type), context_die);
if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL)
at_import_die = force_type_die (TREE_TYPE (decl));
else
- at_import_die = force_decl_die (decl);
+ {
+ at_import_die = lookup_decl_die (decl);
+ if (!at_import_die)
+ {
+ /* If we're trying to avoid duplicate debug info, we may not have
+ emitted the member decl for this field. Emit it now. */
+ if (TREE_CODE (decl) == FIELD_DECL)
+ {
+ tree type = DECL_CONTEXT (decl);
+ dw_die_ref type_context_die;
+
+ if (TYPE_CONTEXT (type))
+ if (TYPE_P (TYPE_CONTEXT (type)))
+ type_context_die = force_type_die (TYPE_CONTEXT (type));
+ else
+ type_context_die = force_decl_die (TYPE_CONTEXT (type));
+ else
+ type_context_die = comp_unit_die;
+ gen_type_die_for_member (type, decl, type_context_die);
+ }
+ at_import_die = force_decl_die (decl);
+ }
+ }
/* OK, now we have DIEs for decl as well as scope. Emit imported die. */
if (TREE_CODE (decl) == NAMESPACE_DECL)
dwarf2out_begin_block (unsigned int line ATTRIBUTE_UNUSED,
unsigned int blocknum)
{
- function_section (current_function_decl);
+ current_function_section (current_function_decl);
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
}
static void
dwarf2out_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int blocknum)
{
- function_section (current_function_decl);
+ current_function_section (current_function_decl);
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
}
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;
+ else
+ newloc->section_label = text_section_label;
+
last_insn = loc_note;
last_label = newloc->label;
decl = NOTE_VAR_LOCATION_DECL (loc_note);
if (debug_info_level >= DINFO_LEVEL_NORMAL
&& line != 0)
{
- function_section (current_function_decl);
+ current_function_section (current_function_decl);
/* If requested, emit something human-readable. */
if (flag_debug_asm)