Commit 35d177a2 by Alexandre Oliva Committed by Alexandre Oliva

defaults.h (CFA_FRAME_BASE_OFFSET): Define.

* defaults.h (CFA_FRAME_BASE_OFFSET): Define.
* config/ia64/ia64.h (CFA_FRAME_BASE_OFFSET): Override.
* doc/tm.texi (CFA_FRAME_BASE_OFFSET): Document.
* dwarf2out.c (build_cfa_loc): New offset parameter.  Add it
to the result of the expression.
(def_cfa_1): Adjust.
(frame_pointer_cfa_offset): Rename to...
(frame_pointer_fb_offset): ... this.  Adjust all uses.
(convert_cfa_to_loc_list): Rename to...
(convert_cfa_to_fb_loc_list): ... this.  New offset parameter.
Pass it on to build_cfa_loc.
(compute_frame_pointer_to_cfa_displacement): Rename to...
(compute_frame_pointer_to_fb_displacement): ... this.  New
offset parameter.  Use it in computation.
(gen_subprogram_die): Compute cfa_fb_offset with the new
macro, and use it to compute the fb loc list and the
displacement.

From-SVN: r111341
parent 529490b4
2006-02-21 Alexandre Oliva <aoliva@redhat.com>
* defaults.h (CFA_FRAME_BASE_OFFSET): Define.
* config/ia64/ia64.h (CFA_FRAME_BASE_OFFSET): Override.
* doc/tm.texi (CFA_FRAME_BASE_OFFSET): Document.
* dwarf2out.c (build_cfa_loc): New offset parameter. Add it
to the result of the expression.
(def_cfa_1): Adjust.
(frame_pointer_cfa_offset): Rename to...
(frame_pointer_fb_offset): ... this. Adjust all uses.
(convert_cfa_to_loc_list): Rename to...
(convert_cfa_to_fb_loc_list): ... this. New offset parameter.
Pass it on to build_cfa_loc.
(compute_frame_pointer_to_cfa_displacement): Rename to...
(compute_frame_pointer_to_fb_displacement): ... this. New
offset parameter. Use it in computation.
(gen_subprogram_die): Compute cfa_fb_offset with the new
macro, and use it to compute the fb loc list and the
displacement.
2006-02-21 Bernd Schmidt <bernd.schmidt@analog.com> 2006-02-21 Bernd Schmidt <bernd.schmidt@analog.com>
* config/bfin/predicates.md (cc_operand): Delete predicate. All uses * config/bfin/predicates.md (cc_operand): Delete predicate. All uses
......
...@@ -1020,6 +1020,9 @@ enum reg_class ...@@ -1020,6 +1020,9 @@ enum reg_class
pointer. */ pointer. */
#define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET #define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET
/* We shorten debug info by using CFA-16 as DW_AT_frame_base. */
#define CFA_FRAME_BASE_OFFSET(FUNDECL) (-INCOMING_FRAME_SP_OFFSET)
/* Register That Address the Stack Frame. */ /* Register That Address the Stack Frame. */
......
...@@ -889,6 +889,11 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -889,6 +889,11 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#define ARG_POINTER_CFA_OFFSET(FNDECL) FIRST_PARM_OFFSET (FNDECL) #define ARG_POINTER_CFA_OFFSET(FNDECL) FIRST_PARM_OFFSET (FNDECL)
#endif #endif
/* On most machines, we use the CFA as DW_AT_frame_base. */
#ifndef CFA_FRAME_BASE_OFFSET
#define CFA_FRAME_BASE_OFFSET(FNDECL) 0
#endif
/* The offset from the incoming value of %sp to the top of the stack frame /* The offset from the incoming value of %sp to the top of the stack frame
for the current function. */ for the current function. */
#ifndef INCOMING_FRAME_SP_OFFSET #ifndef INCOMING_FRAME_SP_OFFSET
......
...@@ -3043,6 +3043,13 @@ of @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET} ...@@ -3043,6 +3043,13 @@ of @code{FRAME_POINTER_CFA_OFFSET} and @code{ARG_POINTER_CFA_OFFSET}
should be defined. should be defined.
@end defmac @end defmac
@defmac CFA_FRAME_BASE_OFFSET (@var{fundecl})
If defined, a C expression whose value is an integer giving the offset
in bytes from the canonical frame address (cfa) to the frame base used
in DWARF 2 debug information. The default is zero. A different value
may reduce the size of debug information on some ports.
@end defmac
@node Exception Handling @node Exception Handling
@subsection Exception Handling Support @subsection Exception Handling Support
@cindex exception handling @cindex exception handling
......
...@@ -344,7 +344,7 @@ static void output_cfa_loc (dw_cfi_ref); ...@@ -344,7 +344,7 @@ static void output_cfa_loc (dw_cfi_ref);
static void get_cfa_from_loc_descr (dw_cfa_location *, static void get_cfa_from_loc_descr (dw_cfa_location *,
struct dw_loc_descr_struct *); struct dw_loc_descr_struct *);
static struct dw_loc_descr_struct *build_cfa_loc static struct dw_loc_descr_struct *build_cfa_loc
(dw_cfa_location *); (dw_cfa_location *, HOST_WIDE_INT);
static void def_cfa_1 (const char *, dw_cfa_location *); static void def_cfa_1 (const char *, dw_cfa_location *);
/* How to start an assembler comment. */ /* How to start an assembler comment. */
...@@ -805,7 +805,7 @@ def_cfa_1 (const char *label, dw_cfa_location *loc_p) ...@@ -805,7 +805,7 @@ def_cfa_1 (const char *label, dw_cfa_location *loc_p)
struct dw_loc_descr_struct *loc_list; struct dw_loc_descr_struct *loc_list;
cfi->dw_cfi_opc = DW_CFA_def_cfa_expression; cfi->dw_cfi_opc = DW_CFA_def_cfa_expression;
loc_list = build_cfa_loc (&loc); loc_list = build_cfa_loc (&loc, 0);
cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list; cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list;
} }
...@@ -3390,14 +3390,17 @@ output_cfa_loc (dw_cfi_ref cfi) ...@@ -3390,14 +3390,17 @@ output_cfa_loc (dw_cfi_ref cfi)
output_loc_sequence (loc); output_loc_sequence (loc);
} }
/* This function builds a dwarf location descriptor sequence from /* This function builds a dwarf location descriptor sequence from a
a dw_cfa_location. */ dw_cfa_location, adding the given OFFSET to the result of the
expression. */
static struct dw_loc_descr_struct * static struct dw_loc_descr_struct *
build_cfa_loc (dw_cfa_location *cfa) build_cfa_loc (dw_cfa_location *cfa, HOST_WIDE_INT offset)
{ {
struct dw_loc_descr_struct *head, *tmp; struct dw_loc_descr_struct *head, *tmp;
offset += cfa->offset;
if (cfa->indirect) if (cfa->indirect)
{ {
if (cfa->base_offset) if (cfa->base_offset)
...@@ -3415,23 +3418,23 @@ build_cfa_loc (dw_cfa_location *cfa) ...@@ -3415,23 +3418,23 @@ build_cfa_loc (dw_cfa_location *cfa)
head->dw_loc_oprnd1.val_class = dw_val_class_const; head->dw_loc_oprnd1.val_class = dw_val_class_const;
tmp = new_loc_descr (DW_OP_deref, 0, 0); tmp = new_loc_descr (DW_OP_deref, 0, 0);
add_loc_descr (&head, tmp); add_loc_descr (&head, tmp);
if (cfa->offset != 0) if (offset != 0)
{ {
tmp = new_loc_descr (DW_OP_plus_uconst, cfa->offset, 0); tmp = new_loc_descr (DW_OP_plus_uconst, offset, 0);
add_loc_descr (&head, tmp); add_loc_descr (&head, tmp);
} }
} }
else else
{ {
if (cfa->offset == 0) if (offset == 0)
if (cfa->reg <= 31) if (cfa->reg <= 31)
head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0); head = new_loc_descr (DW_OP_reg0 + cfa->reg, 0, 0);
else else
head = new_loc_descr (DW_OP_regx, cfa->reg, 0); head = new_loc_descr (DW_OP_regx, cfa->reg, 0);
else if (cfa->reg <= 31) else if (cfa->reg <= 31)
head = new_loc_descr (DW_OP_breg0 + cfa->reg, cfa->offset, 0); head = new_loc_descr (DW_OP_breg0 + cfa->reg, offset, 0);
else else
head = new_loc_descr (DW_OP_bregx, cfa->reg, cfa->offset); head = new_loc_descr (DW_OP_bregx, cfa->reg, offset);
} }
return head; return head;
...@@ -3930,9 +3933,9 @@ static GTY(()) int label_num; ...@@ -3930,9 +3933,9 @@ static GTY(()) int label_num;
#ifdef DWARF2_DEBUGGING_INFO #ifdef DWARF2_DEBUGGING_INFO
/* Offset from the "steady-state frame pointer" to the CFA, /* Offset from the "steady-state frame pointer" to the frame base,
within the current function. */ within the current function. */
static HOST_WIDE_INT frame_pointer_cfa_offset; static HOST_WIDE_INT frame_pointer_fb_offset;
/* Forward declarations for functions defined in this file. */ /* Forward declarations for functions defined in this file. */
...@@ -8644,7 +8647,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT offset) ...@@ -8644,7 +8647,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT offset)
} }
gcc_assert (elim == (frame_pointer_needed ? hard_frame_pointer_rtx gcc_assert (elim == (frame_pointer_needed ? hard_frame_pointer_rtx
: stack_pointer_rtx)); : stack_pointer_rtx));
offset += frame_pointer_cfa_offset; offset += frame_pointer_fb_offset;
return new_loc_descr (DW_OP_fbreg, offset, 0); return new_loc_descr (DW_OP_fbreg, offset, 0);
} }
...@@ -10303,12 +10306,14 @@ tree_add_const_value_attribute (dw_die_ref var_die, tree decl) ...@@ -10303,12 +10306,14 @@ tree_add_const_value_attribute (dw_die_ref var_die, tree decl)
add_const_value_attribute (var_die, rtl); add_const_value_attribute (var_die, rtl);
} }
/* Convert the CFI instructions for the current function into a location /* Convert the CFI instructions for the current function into a
list. This is used for DW_AT_frame_base when we targeting a dwarf2 location list. This is used for DW_AT_frame_base when we targeting
consumer that does not support the dwarf3 DW_OP_call_frame_cfa. */ a dwarf2 consumer that does not support the dwarf3
DW_OP_call_frame_cfa. OFFSET is a constant to be added to all CFA
expressions. */
static dw_loc_list_ref static dw_loc_list_ref
convert_cfa_to_loc_list (void) convert_cfa_to_fb_loc_list (HOST_WIDE_INT offset)
{ {
dw_fde_ref fde; dw_fde_ref fde;
dw_loc_list_ref list, *list_tail; dw_loc_list_ref list, *list_tail;
...@@ -10345,8 +10350,9 @@ convert_cfa_to_loc_list (void) ...@@ -10345,8 +10350,9 @@ convert_cfa_to_loc_list (void)
case DW_CFA_advance_loc4: case DW_CFA_advance_loc4:
if (!cfa_equal_p (&last_cfa, &next_cfa)) if (!cfa_equal_p (&last_cfa, &next_cfa))
{ {
*list_tail = new_loc_list (build_cfa_loc (&last_cfa), start_label, *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
last_label, section, list == NULL); start_label, last_label, section,
list == NULL);
list_tail = &(*list_tail)->dw_loc_next; list_tail = &(*list_tail)->dw_loc_next;
last_cfa = next_cfa; last_cfa = next_cfa;
...@@ -10370,32 +10376,35 @@ convert_cfa_to_loc_list (void) ...@@ -10370,32 +10376,35 @@ convert_cfa_to_loc_list (void)
if (!cfa_equal_p (&last_cfa, &next_cfa)) if (!cfa_equal_p (&last_cfa, &next_cfa))
{ {
*list_tail = new_loc_list (build_cfa_loc (&last_cfa), start_label, *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
last_label, section, list == NULL); start_label, last_label, section,
list == NULL);
list_tail = &(*list_tail)->dw_loc_next; list_tail = &(*list_tail)->dw_loc_next;
start_label = last_label; start_label = last_label;
} }
*list_tail = new_loc_list (build_cfa_loc (&next_cfa), start_label, *list_tail = new_loc_list (build_cfa_loc (&next_cfa, offset),
fde->dw_fde_end, section, list == NULL); start_label, fde->dw_fde_end, section,
list == NULL);
return list; return list;
} }
/* Compute a displacement from the "steady-state frame pointer" to /* Compute a displacement from the "steady-state frame pointer" to the
the CFA, and store it in frame_pointer_cfa_offset. */ frame base (often the same as the CFA), and store it in
frame_pointer_fb_offset. OFFSET is added to the displacement
before the latter is negated. */
static void static void
compute_frame_pointer_to_cfa_displacement (void) compute_frame_pointer_to_fb_displacement (HOST_WIDE_INT offset)
{ {
HOST_WIDE_INT offset;
rtx reg, elim; rtx reg, elim;
#ifdef FRAME_POINTER_CFA_OFFSET #ifdef FRAME_POINTER_CFA_OFFSET
reg = frame_pointer_rtx; reg = frame_pointer_rtx;
offset = FRAME_POINTER_CFA_OFFSET (current_function_decl); offset += FRAME_POINTER_CFA_OFFSET (current_function_decl);
#else #else
reg = arg_pointer_rtx; reg = arg_pointer_rtx;
offset = ARG_POINTER_CFA_OFFSET (current_function_decl); offset += ARG_POINTER_CFA_OFFSET (current_function_decl);
#endif #endif
elim = eliminate_regs (reg, VOIDmode, NULL_RTX); elim = eliminate_regs (reg, VOIDmode, NULL_RTX);
...@@ -10407,7 +10416,7 @@ compute_frame_pointer_to_cfa_displacement (void) ...@@ -10407,7 +10416,7 @@ compute_frame_pointer_to_cfa_displacement (void)
gcc_assert (elim == (frame_pointer_needed ? hard_frame_pointer_rtx gcc_assert (elim == (frame_pointer_needed ? hard_frame_pointer_rtx
: stack_pointer_rtx)); : stack_pointer_rtx));
frame_pointer_cfa_offset = -offset; frame_pointer_fb_offset = -offset;
} }
/* Generate a DW_AT_name attribute given some string value to be included as /* Generate a DW_AT_name attribute given some string value to be included as
...@@ -11607,6 +11616,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) ...@@ -11607,6 +11616,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
} }
else if (!DECL_EXTERNAL (decl)) else if (!DECL_EXTERNAL (decl))
{ {
HOST_WIDE_INT cfa_fb_offset;
if (!old_die || !get_AT (old_die, DW_AT_inline)) if (!old_die || !get_AT (old_die, DW_AT_inline))
equate_decl_number_to_die (decl, subr_die); equate_decl_number_to_die (decl, subr_die);
...@@ -11643,6 +11654,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) ...@@ -11643,6 +11654,8 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
add_AT_fde_ref (subr_die, DW_AT_MIPS_fde, current_funcdef_fde); add_AT_fde_ref (subr_die, DW_AT_MIPS_fde, current_funcdef_fde);
#endif #endif
cfa_fb_offset = CFA_FRAME_BASE_OFFSET (decl);
/* We define the "frame base" as the function's CFA. This is more /* We define the "frame base" as the function's CFA. This is more
convenient for several reasons: (1) It's stable across the prologue convenient for several reasons: (1) It's stable across the prologue
and epilogue, which makes it better than just a frame pointer, and epilogue, which makes it better than just a frame pointer,
...@@ -11656,7 +11669,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) ...@@ -11656,7 +11669,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
consumers that understand it; fall back to "pure" dwarf2 and consumers that understand it; fall back to "pure" dwarf2 and
convert the CFA data into a location list. */ convert the CFA data into a location list. */
{ {
dw_loc_list_ref list = convert_cfa_to_loc_list (); dw_loc_list_ref list = convert_cfa_to_fb_loc_list (cfa_fb_offset);
if (list->dw_loc_next) if (list->dw_loc_next)
add_AT_loc_list (subr_die, DW_AT_frame_base, list); add_AT_loc_list (subr_die, DW_AT_frame_base, list);
else else
...@@ -11668,7 +11681,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) ...@@ -11668,7 +11681,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
will reference in the rtl; the later is what we've told the will reference in the rtl; the later is what we've told the
debugger about. We'll need to adjust all frame_base references debugger about. We'll need to adjust all frame_base references
by this displacement. */ by this displacement. */
compute_frame_pointer_to_cfa_displacement (); compute_frame_pointer_to_fb_displacement (cfa_fb_offset);
if (cfun->static_chain_decl) if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link, add_AT_location_description (subr_die, DW_AT_static_link,
......
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