Commit 3edb53aa by Richard Henderson Committed by Richard Henderson

dwarf2cfi: Unify add_fde_cfi and add_cie_cfi.

        * dwarf2cfi.c (add_cfi_vec): New.
        (add_cfi): Rename from add_fde_cfi.  Add the element to add_cfi_vec.
        (def_cfa_1, reg_save): Remove for_cie argument.  Update all callers.
        (execute_dwarf2_frame): Set add_cfi_vec.

From-SVN: r176095
parent ded49a7f
2011-07-09 Richard Henderson <rth@redhat.com> 2011-07-09 Richard Henderson <rth@redhat.com>
* dwarf2cfi.c (add_cfi_vec): New.
(add_cfi): Rename from add_fde_cfi. Add the element to add_cfi_vec.
(def_cfa_1, reg_save): Remove for_cie argument. Update all callers.
(execute_dwarf2_frame): Set add_cfi_vec.
2011-07-09 Richard Henderson <rth@redhat.com>
* defaults.h (ASM_COMMENT_START): Move here... * defaults.h (ASM_COMMENT_START): Move here...
* dwarf2asm.c: ... from here. * dwarf2asm.c: ... from here.
* dwarf2out.c, final.c, vmsdbgout.c: Remove duplicates. * dwarf2out.c, final.c, vmsdbgout.c: Remove duplicates.
......
...@@ -146,6 +146,9 @@ static GTY(()) unsigned long dwarf2out_cfi_label_num; ...@@ -146,6 +146,9 @@ static GTY(()) unsigned long dwarf2out_cfi_label_num;
/* The insn after which a new CFI note should be emitted. */ /* The insn after which a new CFI note should be emitted. */
static rtx cfi_insn; static rtx cfi_insn;
/* When non-null, add_cfi will add the CFI to this vector. */
static cfi_vec *add_cfi_vec;
/* True if remember_state should be emitted before following CFI directive. */ /* True if remember_state should be emitted before following CFI directive. */
static bool emit_cfa_remember; static bool emit_cfa_remember;
...@@ -270,10 +273,10 @@ dwarf2out_cfi_label (void) ...@@ -270,10 +273,10 @@ dwarf2out_cfi_label (void)
return xstrdup (label); return xstrdup (label);
} }
/* Add CFI to the current fde. */ /* Add CFI either to the current insn stream or to a vector, or both. */
static void static void
add_fde_cfi (dw_cfi_ref cfi) add_cfi (dw_cfi_ref cfi)
{ {
if (emit_cfa_remember) if (emit_cfa_remember)
{ {
...@@ -283,7 +286,7 @@ add_fde_cfi (dw_cfi_ref cfi) ...@@ -283,7 +286,7 @@ add_fde_cfi (dw_cfi_ref cfi)
emit_cfa_remember = false; emit_cfa_remember = false;
cfi_remember = new_cfi (); cfi_remember = new_cfi ();
cfi_remember->dw_cfi_opc = DW_CFA_remember_state; cfi_remember->dw_cfi_opc = DW_CFA_remember_state;
add_fde_cfi (cfi_remember); add_cfi (cfi_remember);
} }
any_cfis_emitted = true; any_cfis_emitted = true;
...@@ -292,18 +295,8 @@ add_fde_cfi (dw_cfi_ref cfi) ...@@ -292,18 +295,8 @@ add_fde_cfi (dw_cfi_ref cfi)
cfi_insn = emit_note_after (NOTE_INSN_CFI, cfi_insn); cfi_insn = emit_note_after (NOTE_INSN_CFI, cfi_insn);
NOTE_CFI (cfi_insn) = cfi; NOTE_CFI (cfi_insn) = cfi;
} }
else if (add_cfi_vec != NULL)
{ VEC_safe_push (dw_cfi_ref, gc, *add_cfi_vec, cfi);
dw_fde_ref fde = cfun->fde;
VEC_safe_push (dw_cfi_ref, gc, fde->dw_fde_cfi, cfi);
dwarf2out_emit_cfi (cfi);
}
}
static void
add_cie_cfi (dw_cfi_ref cfi)
{
VEC_safe_push (dw_cfi_ref, gc, cie_cfi_vec, cfi);
} }
/* This function fills in aa dw_cfa_location structure from a dwarf location /* This function fills in aa dw_cfa_location structure from a dwarf location
...@@ -512,7 +505,7 @@ cfa_equal_p (const dw_cfa_location *loc1, const dw_cfa_location *loc2) ...@@ -512,7 +505,7 @@ cfa_equal_p (const dw_cfa_location *loc1, const dw_cfa_location *loc2)
the dw_cfa_location structure. */ the dw_cfa_location structure. */
static void static void
def_cfa_1 (bool for_cie, dw_cfa_location *loc_p) def_cfa_1 (dw_cfa_location *loc_p)
{ {
dw_cfi_ref cfi; dw_cfi_ref cfi;
dw_cfa_location loc; dw_cfa_location loc;
...@@ -584,10 +577,7 @@ def_cfa_1 (bool for_cie, dw_cfa_location *loc_p) ...@@ -584,10 +577,7 @@ def_cfa_1 (bool for_cie, dw_cfa_location *loc_p)
cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list; cfi->dw_cfi_oprnd1.dw_cfi_loc = loc_list;
} }
if (for_cie) add_cfi (cfi);
add_cie_cfi (cfi);
else
add_fde_cfi (cfi);
old_cfa = loc; old_cfa = loc;
} }
...@@ -596,10 +586,9 @@ def_cfa_1 (bool for_cie, dw_cfa_location *loc_p) ...@@ -596,10 +586,9 @@ def_cfa_1 (bool for_cie, dw_cfa_location *loc_p)
otherwise it is saved in SREG. */ otherwise it is saved in SREG. */
static void static void
reg_save (bool for_cie, unsigned int reg, unsigned int sreg, reg_save (unsigned int reg, unsigned int sreg, HOST_WIDE_INT offset)
HOST_WIDE_INT offset)
{ {
dw_fde_ref fde = for_cie ? NULL : cfun->fde; dw_fde_ref fde = cfun ? cfun->fde : NULL;
dw_cfi_ref cfi = new_cfi (); dw_cfi_ref cfi = new_cfi ();
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg; cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
...@@ -632,10 +621,7 @@ reg_save (bool for_cie, unsigned int reg, unsigned int sreg, ...@@ -632,10 +621,7 @@ reg_save (bool for_cie, unsigned int reg, unsigned int sreg,
cfi->dw_cfi_oprnd2.dw_cfi_reg_num = sreg; cfi->dw_cfi_oprnd2.dw_cfi_reg_num = sreg;
} }
if (for_cie) add_cfi (cfi);
add_cie_cfi (cfi);
else
add_fde_cfi (cfi);
} }
/* Record the initial position of the return address. RTL is /* Record the initial position of the return address. RTL is
...@@ -693,7 +679,7 @@ initial_return_save (rtx rtl) ...@@ -693,7 +679,7 @@ initial_return_save (rtx rtl)
} }
if (reg != DWARF_FRAME_RETURN_COLUMN) if (reg != DWARF_FRAME_RETURN_COLUMN)
reg_save (true, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset); reg_save (DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
} }
/* Given a SET, calculate the amount of stack adjustment it /* Given a SET, calculate the amount of stack adjustment it
...@@ -975,7 +961,7 @@ dwarf2out_args_size (HOST_WIDE_INT size) ...@@ -975,7 +961,7 @@ dwarf2out_args_size (HOST_WIDE_INT size)
cfi = new_cfi (); cfi = new_cfi ();
cfi->dw_cfi_opc = DW_CFA_GNU_args_size; cfi->dw_cfi_opc = DW_CFA_GNU_args_size;
cfi->dw_cfi_oprnd1.dw_cfi_offset = size; cfi->dw_cfi_oprnd1.dw_cfi_offset = size;
add_fde_cfi (cfi); add_cfi (cfi);
} }
/* Record a stack adjustment of OFFSET bytes. */ /* Record a stack adjustment of OFFSET bytes. */
...@@ -1000,7 +986,7 @@ dwarf2out_stack_adjust (HOST_WIDE_INT offset) ...@@ -1000,7 +986,7 @@ dwarf2out_stack_adjust (HOST_WIDE_INT offset)
if (args_size < 0) if (args_size < 0)
args_size = 0; args_size = 0;
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
if (flag_asynchronous_unwind_tables) if (flag_asynchronous_unwind_tables)
dwarf2out_args_size (args_size); dwarf2out_args_size (args_size);
} }
...@@ -1205,7 +1191,7 @@ dwarf2out_flush_queued_reg_saves (void) ...@@ -1205,7 +1191,7 @@ dwarf2out_flush_queued_reg_saves (void)
sreg = DWARF_FRAME_REGNUM (REGNO (q->saved_reg)); sreg = DWARF_FRAME_REGNUM (REGNO (q->saved_reg));
else else
sreg = INVALID_REGNUM; sreg = INVALID_REGNUM;
reg_save (false, reg, sreg, q->cfa_offset); reg_save (reg, sreg, q->cfa_offset);
} }
queued_reg_saves = NULL; queued_reg_saves = NULL;
...@@ -1299,7 +1285,7 @@ dwarf2out_frame_debug_def_cfa (rtx pat) ...@@ -1299,7 +1285,7 @@ dwarf2out_frame_debug_def_cfa (rtx pat)
gcc_unreachable (); gcc_unreachable ();
} }
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
} }
/* A subroutine of dwarf2out_frame_debug, process a REG_ADJUST_CFA note. */ /* A subroutine of dwarf2out_frame_debug, process a REG_ADJUST_CFA note. */
...@@ -1330,7 +1316,7 @@ dwarf2out_frame_debug_adjust_cfa (rtx pat) ...@@ -1330,7 +1316,7 @@ dwarf2out_frame_debug_adjust_cfa (rtx pat)
cfa.reg = REGNO (dest); cfa.reg = REGNO (dest);
gcc_assert (cfa.indirect == 0); gcc_assert (cfa.indirect == 0);
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
} }
/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_OFFSET note. */ /* A subroutine of dwarf2out_frame_debug, process a REG_CFA_OFFSET note. */
...@@ -1376,7 +1362,7 @@ dwarf2out_frame_debug_cfa_offset (rtx set) ...@@ -1376,7 +1362,7 @@ dwarf2out_frame_debug_cfa_offset (rtx set)
/* ??? We'd like to use queue_reg_save, but we need to come up with /* ??? We'd like to use queue_reg_save, but we need to come up with
a different flushing heuristic for epilogues. */ a different flushing heuristic for epilogues. */
if (!span) if (!span)
reg_save (false, sregno, INVALID_REGNUM, offset); reg_save (sregno, INVALID_REGNUM, offset);
else else
{ {
/* We have a PARALLEL describing where the contents of SRC live. /* We have a PARALLEL describing where the contents of SRC live.
...@@ -1393,7 +1379,7 @@ dwarf2out_frame_debug_cfa_offset (rtx set) ...@@ -1393,7 +1379,7 @@ dwarf2out_frame_debug_cfa_offset (rtx set)
rtx elem = XVECEXP (span, 0, par_index); rtx elem = XVECEXP (span, 0, par_index);
sregno = DWARF_FRAME_REGNUM (REGNO (src)); sregno = DWARF_FRAME_REGNUM (REGNO (src));
reg_save (false, sregno, INVALID_REGNUM, span_offset); reg_save (sregno, INVALID_REGNUM, span_offset);
span_offset += GET_MODE_SIZE (GET_MODE (elem)); span_offset += GET_MODE_SIZE (GET_MODE (elem));
} }
} }
...@@ -1422,7 +1408,7 @@ dwarf2out_frame_debug_cfa_register (rtx set) ...@@ -1422,7 +1408,7 @@ dwarf2out_frame_debug_cfa_register (rtx set)
/* ??? We'd like to use queue_reg_save, but we need to come up with /* ??? We'd like to use queue_reg_save, but we need to come up with
a different flushing heuristic for epilogues. */ a different flushing heuristic for epilogues. */
reg_save (false, sregno, dregno, 0); reg_save (sregno, dregno, 0);
} }
/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_EXPRESSION note. */ /* A subroutine of dwarf2out_frame_debug, process a REG_CFA_EXPRESSION note. */
...@@ -1450,7 +1436,7 @@ dwarf2out_frame_debug_cfa_expression (rtx set) ...@@ -1450,7 +1436,7 @@ dwarf2out_frame_debug_cfa_expression (rtx set)
/* ??? We'd like to use queue_reg_save, were the interface different, /* ??? We'd like to use queue_reg_save, were the interface different,
and, as above, we could manage flushing for epilogues. */ and, as above, we could manage flushing for epilogues. */
add_fde_cfi (cfi); add_cfi (cfi);
} }
/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE note. */ /* A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE note. */
...@@ -1464,7 +1450,7 @@ dwarf2out_frame_debug_cfa_restore (rtx reg) ...@@ -1464,7 +1450,7 @@ dwarf2out_frame_debug_cfa_restore (rtx reg)
cfi->dw_cfi_opc = (regno & ~0x3f ? DW_CFA_restore_extended : DW_CFA_restore); cfi->dw_cfi_opc = (regno & ~0x3f ? DW_CFA_restore_extended : DW_CFA_restore);
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = regno; cfi->dw_cfi_oprnd1.dw_cfi_reg_num = regno;
add_fde_cfi (cfi); add_cfi (cfi);
} }
/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_WINDOW_SAVE. /* A subroutine of dwarf2out_frame_debug, process a REG_CFA_WINDOW_SAVE.
...@@ -1477,7 +1463,7 @@ dwarf2out_frame_debug_cfa_window_save (void) ...@@ -1477,7 +1463,7 @@ dwarf2out_frame_debug_cfa_window_save (void)
dw_cfi_ref cfi = new_cfi (); dw_cfi_ref cfi = new_cfi ();
cfi->dw_cfi_opc = DW_CFA_GNU_window_save; cfi->dw_cfi_opc = DW_CFA_GNU_window_save;
add_fde_cfi (cfi); add_cfi (cfi);
} }
/* Record call frame debugging information for an expression EXPR, /* Record call frame debugging information for an expression EXPR,
...@@ -1943,7 +1929,7 @@ dwarf2out_frame_debug_expr (rtx expr) ...@@ -1943,7 +1929,7 @@ dwarf2out_frame_debug_expr (rtx expr)
gcc_unreachable (); gcc_unreachable ();
} }
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
break; break;
case MEM: case MEM:
...@@ -2103,14 +2089,14 @@ dwarf2out_frame_debug_expr (rtx expr) ...@@ -2103,14 +2089,14 @@ dwarf2out_frame_debug_expr (rtx expr)
fde->drap_reg_saved = 1; fde->drap_reg_saved = 1;
def_cfa_1 (false, &cfa_exp); def_cfa_1 (&cfa_exp);
break; break;
} }
/* If the source register is exactly the CFA, assume /* If the source register is exactly the CFA, assume
we're saving SP like any other register; this happens we're saving SP like any other register; this happens
on the ARM. */ on the ARM. */
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
queue_reg_save (stack_pointer_rtx, NULL_RTX, offset); queue_reg_save (stack_pointer_rtx, NULL_RTX, offset);
break; break;
} }
...@@ -2127,12 +2113,12 @@ dwarf2out_frame_debug_expr (rtx expr) ...@@ -2127,12 +2113,12 @@ dwarf2out_frame_debug_expr (rtx expr)
cfa.reg = REGNO (x); cfa.reg = REGNO (x);
cfa.base_offset = offset; cfa.base_offset = offset;
cfa.indirect = 1; cfa.indirect = 1;
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
break; break;
} }
} }
def_cfa_1 (false, &cfa); def_cfa_1 (&cfa);
{ {
span = targetm.dwarf_register_span (src); span = targetm.dwarf_register_span (src);
...@@ -2570,7 +2556,7 @@ dwarf2out_frame_debug_restore_state (void) ...@@ -2570,7 +2556,7 @@ dwarf2out_frame_debug_restore_state (void)
dw_cfi_ref cfi = new_cfi (); dw_cfi_ref cfi = new_cfi ();
cfi->dw_cfi_opc = DW_CFA_restore_state; cfi->dw_cfi_opc = DW_CFA_restore_state;
add_fde_cfi (cfi); add_cfi (cfi);
gcc_assert (cfa_remember.in_use); gcc_assert (cfa_remember.in_use);
cfa = cfa_remember; cfa = cfa_remember;
...@@ -2591,6 +2577,8 @@ execute_dwarf2_frame (void) ...@@ -2591,6 +2577,8 @@ execute_dwarf2_frame (void)
{ {
dw_cfa_location loc; dw_cfa_location loc;
add_cfi_vec = &cie_cfi_vec;
memset(&old_cfa, 0, sizeof (old_cfa)); memset(&old_cfa, 0, sizeof (old_cfa));
old_cfa.reg = INVALID_REGNUM; old_cfa.reg = INVALID_REGNUM;
...@@ -2598,11 +2586,13 @@ execute_dwarf2_frame (void) ...@@ -2598,11 +2586,13 @@ execute_dwarf2_frame (void)
memset(&loc, 0, sizeof (loc)); memset(&loc, 0, sizeof (loc));
loc.reg = STACK_POINTER_REGNUM; loc.reg = STACK_POINTER_REGNUM;
loc.offset = INCOMING_FRAME_SP_OFFSET; loc.offset = INCOMING_FRAME_SP_OFFSET;
def_cfa_1 (true, &loc); def_cfa_1 (&loc);
if (targetm.debug_unwind_info () == UI_DWARF2 if (targetm.debug_unwind_info () == UI_DWARF2
|| targetm_common.except_unwind_info (&global_options) == UI_DWARF2) || targetm_common.except_unwind_info (&global_options) == UI_DWARF2)
initial_return_save (INCOMING_RETURN_ADDR_RTX); initial_return_save (INCOMING_RETURN_ADDR_RTX);
add_cfi_vec = NULL;
} }
/* Set up state for generating call frame debug info. */ /* Set up state for generating call frame debug info. */
......
...@@ -825,10 +825,10 @@ output_cfi_directive (FILE *f, dw_cfi_ref cfi) ...@@ -825,10 +825,10 @@ output_cfi_directive (FILE *f, dw_cfi_ref cfi)
case DW_CFA_advance_loc4: case DW_CFA_advance_loc4:
case DW_CFA_MIPS_advance_loc8: case DW_CFA_MIPS_advance_loc8:
case DW_CFA_set_loc: case DW_CFA_set_loc:
/* Should only be created by add_fde_cfi in a code path not /* Should only be created in a code path not followed when emitting
followed when emitting via directives. The assembler is via directives. The assembler is going to take care of this for
going to take care of this for us. But this routines is us. But this routines is also used for debugging dumps, so
also used for debugging dumps, so print something. */ print something. */
gcc_assert (f != asm_out_file); gcc_assert (f != asm_out_file);
fprintf (f, "\t.cfi_advance_loc\n"); fprintf (f, "\t.cfi_advance_loc\n");
break; break;
......
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