GCC Middle and Back End API Reference
dwarf2cfi.c File Reference
#include "expr.h"
Include dependency graph for dwarf2cfi.c:

Data Structures

struct  dw_cfi_row_struct
struct  reg_saved_in_data_struct
struct  dw_trace_info
struct  trace_info_hasher
struct  queued_reg_save

Typedefs

typedef struct dw_cfi_row_struct dw_cfi_row
typedef struct
reg_saved_in_data_struct 
reg_saved_in_data
typedef dw_trace_infodw_trace_info_ref

Functions

rtx expand_builtin_dwarf_sp_column ()
static void init_return_column_size ()
void expand_builtin_init_dwarf_reg_sizes ()
static dw_trace_infoget_trace_info ()
static bool save_point_p ()
static HOST_WIDE_INT div_data_align ()
static bool need_data_align_sf_opcode ()
static dw_cfi_ref new_cfi ()
static dw_cfi_rownew_cfi_row ()
static dw_cfi_rowcopy_cfi_row ()
static char * dwarf2out_cfi_label ()
static void add_cfi ()
static void add_cfi_args_size ()
static void add_cfi_restore ()
static void update_row_reg_save ()
static void get_cfa_from_loc_descr ()
void lookup_cfa_1 ()
bool cfa_equal_p ()
static bool cfi_oprnd_equal_p ()
static bool cfi_equal_p ()
static bool cfi_row_equal_p ()
static dw_cfi_ref def_cfa_0 ()
static void def_cfa_1 ()
static void reg_save ()
static void notice_args_size ()
static void notice_eh_throw ()
static unsigned dwf_regno ()
static bool compare_reg_or_pc ()
static void record_reg_saved_in_reg ()
static void queue_reg_save ()
static void dwarf2out_flush_queued_reg_saves ()
static bool clobbers_queued_reg_save ()
static rtx reg_saved_in ()
static void dwarf2out_frame_debug_def_cfa ()
static void dwarf2out_frame_debug_adjust_cfa ()
static void dwarf2out_frame_debug_cfa_offset ()
static void dwarf2out_frame_debug_cfa_register ()
static void dwarf2out_frame_debug_cfa_expression ()
static void dwarf2out_frame_debug_cfa_restore ()
static void dwarf2out_frame_debug_cfa_window_save ()
static void dwarf2out_frame_debug_expr ()
static void dwarf2out_frame_debug ()
static void change_cfi_row ()
static bool cfi_label_required_p ()
static void add_cfis_to_fde ()
static void maybe_record_trace_start ()
static void maybe_record_trace_start_abnormal ()
static void create_trace_edges ()
static void scan_insn_after ()
static void scan_trace ()
static void create_cfi_notes ()
static rtx before_next_cfi_note ()
static void connect_traces ()
static void create_pseudo_cfg ()
static void initial_return_save ()
static void create_cie_data ()
static unsigned int execute_dwarf2_frame ()
static const char * dwarf_cfi_name ()
static void output_cfa_loc ()
static void output_cfa_loc_raw ()
void output_cfi ()
void output_cfi_directive ()
void dwarf2out_emit_cfi ()
static void dump_cfi_row ()
void debug_cfi_row (dw_cfi_row *row)
void debug_cfi_row ()
bool dwarf2out_do_frame ()
bool dwarf2out_do_cfi_asm ()
static bool gate_dwarf2_frame ()
rtl_opt_passmake_pass_dwarf2_frame ()

Variables

static vec< dw_trace_infotrace_info
static vec< dw_trace_info_reftrace_work_list
static hash_table
< trace_info_hasher
trace_index
cfi_vec cie_cfi_vec
static dw_cfi_rowcie_cfi_row
static reg_saved_in_datacie_return_save
static unsigned long dwarf2out_cfi_label_num
static rtx add_cfi_insn
static cfi_vecadd_cfi_vec
static dw_trace_infocur_trace
static dw_cfi_rowcur_row
static dw_cfa_locationcur_cfa
static vec< queued_reg_savequeued_reg_saves
static bool any_cfis_emitted
static unsigned dw_stack_pointer_regnum
static unsigned dw_frame_pointer_regnum
static signed char saved_do_cfi_asm = 0

Typedef Documentation

typedef struct dw_cfi_row_struct dw_cfi_row
   A collected description of an entire row of the abstract CFI table.  
   The caller's ORIG_REG is saved in SAVED_IN_REG.  

Function Documentation

static void add_cfi ( )
static
   Add CFI either to the current insn stream or to a vector, or both.  

References dw_cfi_row_struct::reg_save, vec_safe_grow_cleared(), and vec_safe_length().

Referenced by copy_cfi_row(), and dwarf2out_cfi_label().

static void add_cfi_args_size ( )
static
     While we can occasionally have args_size < 0 internally, this state
     should not persist at a point we actually need an opcode.  
static void add_cfi_restore ( )
static
static void add_cfis_to_fde ( )
static
   Walk the function, looking for NOTE_INSN_CFI notes.  Add the CFIs to the
   function's FDE, adding CFI labels and set_loc/advance_loc opcodes as
   necessary.  
     We always start with a function_begin label.  
             Don't attempt to advance_loc4 between labels
             in different sections.  
                 Set the location counter to the new label.  
static rtx before_next_cfi_note ( )
static
   Return the insn before the first NOTE_INSN_CFI after START.  

References dw_trace_info::head, dw_trace_info::id, memset(), and dw_trace_info::switch_sections.

bool cfa_equal_p ( )
   Determine if two dw_cfa_location structures define the same data.  
static bool cfi_equal_p ( )
static
   Determine if two CFI entries are identical.  
     Make things easier for our callers, including missing operands.  
     Obviously, the opcodes must match.  
     Compare the two operands, re-using the type of the operands as
     already exposed elsewhere.  

Referenced by cfi_oprnd_equal_p().

static bool cfi_label_required_p ( )
static
   Examine CFI and return true if a cfi label and set_loc is needed
   beforehand.  Even when generating CFI assembler instructions, we
   still have to add the cfi to the list so that lookup_cfa_1 works
   later on.  When -g2 and above we even need to force emitting of
   CFI labels and add to list a DW_CFA_set_loc for convert_cfa_to_fb_loc_list
   purposes.  If we're generating DWARF3 output we use DW_OP_call_frame_cfa
   and so don't use convert_cfa_to_fb_loc_list.  

References dw_cfi_row_struct::cfa, cur_row, cur_trace, dw_trace_info::end_true_args_size, HOST_WIDE_INT, maybe_record_trace_start(), cfa_loc::offset, and cfa_loc::reg.

static bool cfi_oprnd_equal_p ( )
static
   Determine if two CFI operands are identical.  

References dw_cfi_row_struct::cfa_cfi, and cfi_equal_p().

static bool cfi_row_equal_p ( )
static
   Determine if two CFI_ROW structures are identical.  

Referenced by change_cfi_row().

static bool clobbers_queued_reg_save ( )
static
   Does INSN clobber any register which QUEUED_REG_SAVES lists a saved
   location for?  Or, does it clobber a register which we've previously
   said that some other register is saved in, and for which we now
   have a new location for?  
static bool compare_reg_or_pc ( )
static
   Compare X and Y for equivalence.  The inputs may be REGs or PC_RTX.  

Referenced by notice_eh_throw(), and record_reg_saved_in_reg().

static void connect_traces ( )
static
   Insert CFI notes between traces to properly change state between them.  
     ??? Ideally, we should have both queued and processed every trace.
     However the current representation of constant pools on various targets
     is indistinguishable from unreachable code.  Assume for the moment that
     we can simply skip over such traces.  
     ??? Consider creating a DATA_INSN rtx code to indicate that
     these are not "real" instructions, and should not be considered.
     This could be generically useful for tablejump data as well.  
     Remove all unprocessed traces from the list.  
     Work from the end back to the beginning.  This lets us easily insert
     remember/restore_state notes in the correct order wrt other notes.  
         In dwarf2out_switch_text_section, we'll begin a new FDE
         for the portion of the function in the alternate text
         section.  The row state at the very beginning of that
         new FDE will be exactly the row state from the CIE.  
             If there's no change from the previous end state, fine.  
             Otherwise check for the common case of sharing state with
             the beginning of an epilogue, but not the end.  Insert
             remember/restore opcodes in that case.  
                 Note that if we blindly insert the remember at the
                 start of the trace, we can wind up increasing the
                 size of the unwind info due to extra advance opcodes.
                 Instead, put the remember immediately before the next
                 state change.  We know there must be one, because the 
                 state at the beginning and head of the trace differ.  
             Otherwise, we'll simply change state from the previous end.  
     Connect args_size between traces that have can_throw_internal insns.  
                 ??? Search back to previous CFI note.  

References dump_file, hash_table< Descriptor, Allocator >::find_slot_with_hash(), dw_trace_info::head, rtx_name, and dw_trace_info::switch_sections.

static dw_cfi_row* copy_cfi_row ( )
static
static void create_cfi_notes ( )
static
   Scan the function and create the initial set of CFI notes.  
     Always begin at the entry trace.  

References save_point_p().

static void create_cie_data ( )
static
     On entry, the Canonical Frame Address is at SP.  
         For a few targets, we have the return address incoming into a
         register, but choose a different return column.  This will result
         in a DW_CFA_register for the return, and an entry in
         regs_saved_in_regs to match.  If the target later stores that
         return address register to the stack, we want to be able to emit
         the DW_CFA_offset against the return column, not the intermediate
         save register.  Save the contents of regs_saved_in_regs so that
         we can re-initialize it at the start of each function.  
static void create_pseudo_cfg ( )
static
   Set up the pseudo-cfg of instruction traces, as described at the
   block comment at the top of the file.  
     The first trace begins at the start of the function,
     and begins with the CIE row state.  
     Walk all the insns, collecting start of trace locations.  
             We should have just seen a barrier.  
         Watch out for save_point notes between basic blocks.
         In particular, a note after a barrier.  Do not record these,
         delaying trace creation until the label.  
     Create the trace index after we've finished building trace_info,
     avoiding stale pointer problems due to reallocation.  
static void create_trace_edges ( )
static
   Propagate CUR_TRACE state to the destinations implied by INSN.  
   ??? Sadly, this is in large part a duplicate of make_edges.  
         Sibling calls don't have edges inside this function.  
         Process non-local goto edges.  
     Process EH edges.  

References add_cfi_insn, dw_cfi_row_struct::cfa, cur_cfa, cur_row, cur_trace, dw_trace_info::end_true_args_size, HOST_WIDE_INT, dw_cfi_row_struct::reg_save, scan_insn_after(), and vec_safe_copy().

void debug_cfi_row ( dw_cfi_row row)
void debug_cfi_row ( )
static dw_cfi_ref def_cfa_0 ( )
static
   The CFA is now calculated from NEW_CFA.  Consider OLD_CFA in determining
   what opcode to emit.  Returns the CFI opcode to effect the change, or
   NULL if NEW_CFA == OLD_CFA.  
     If nothing changed, no need to issue any call frame instructions.  
         Construct a "DW_CFA_def_cfa_offset <offset>" instruction, indicating
         the CFA register did not change but the offset did.  The data
         factoring for DW_CFA_def_cfa_offset_sf happens in output_cfi, or
         in the assembler via the .cfi_def_cfa_offset directive.  
         Construct a "DW_CFA_def_cfa_register <register>" instruction,
         indicating the CFA register has changed to <register> but the
         offset has not changed.  
         Construct a "DW_CFA_def_cfa <register> <offset>" instruction,
         indicating the CFA register has changed to <register> with
         the specified offset.  The data factoring for DW_CFA_def_cfa_sf
         happens in output_cfi, or in the assembler via the .cfi_def_cfa
         directive.  
         Construct a DW_CFA_def_cfa_expression instruction to
         calculate the CFA using a full location expression since no
         register-offset pair is available.  
static void def_cfa_1 ( )
static
   Similarly, but take OLD_CFA from CUR_ROW, and update it after the fact.  
static HOST_WIDE_INT div_data_align ( )
inlinestatic
   Divide OFF by DWARF_CIE_DATA_ALIGNMENT, asserting no remainder.  
static void dump_cfi_row ( )
static
static char* dwarf2out_cfi_label ( )
static
   Generate a new label for the CFI info to refer to.  

References add_cfi(), dw_cfi_struct::dw_cfi_opc, dw_cfi_struct::dw_cfi_oprnd1, dw_cfi_oprnd_struct::dw_cfi_reg_num, and new_cfi().

bool dwarf2out_do_cfi_asm ( void  )
   Decide whether to emit frame unwind via assembler directives.  
     Assume failure for a moment.  
     Make sure the personality encoding is one the assembler can support.
     In particular, aligned addresses can't be handled.  
     If we can't get the assembler to emit only .debug_frame, and we don't need
     dwarf2 unwind info for exceptions, then emit .debug_frame by hand.  
     Success!  

Referenced by append_entry_to_tmpl_value_parm_die_table().

bool dwarf2out_do_frame ( void  )
   Decide whether we want to emit frame unwind information for the current
   translation unit.  
     We want to emit correct CFA location expressions or lists, so we
     have to return true if we're going to output debug info, even if
     we're not going to output frame or unwind info.  
void dwarf2out_emit_cfi ( )
static void dwarf2out_flush_queued_reg_saves ( )
static
   Output all the entries in QUEUED_REG_SAVES.  

References cfa_loc::base_offset, cur_cfa, dwf_regno(), cfa_loc::indirect, memset(), cfa_loc::offset, and cfa_loc::reg.

static void dwarf2out_frame_debug ( )
static
   Record call frame debugging information for INSN, which either sets
   SP or FP (adjusting how we calculate the frame address) or saves a
   register to the stack.  
           The actual flush happens elsewhere.  
         Check again.  A parallel can save and update the same register.
         We could probably check just once, here, but this is safer than
         removing the check at the start of the function.  
static void dwarf2out_frame_debug_adjust_cfa ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_ADJUST_CFA note.  

References dwf_regno(), and reg_save().

static void dwarf2out_frame_debug_cfa_expression ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_CFA_EXPRESSION note. 
     ??? We'd like to use queue_reg_save, were the interface different,
     and, as above, we could manage flushing for epilogues.  
static void dwarf2out_frame_debug_cfa_offset ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_CFA_OFFSET note.  
     As documented, only consider extremely simple addresses.  
     ??? We'd like to use queue_reg_save, but we need to come up with
     a different flushing heuristic for epilogues.  
         We have a PARALLEL describing where the contents of SRC live.
         Queue register saves for each piece of the PARALLEL.  
static void dwarf2out_frame_debug_cfa_register ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_CFA_REGISTER note.  
     ??? We'd like to use queue_reg_save, but we need to come up with
     a different flushing heuristic for epilogues.  
static void dwarf2out_frame_debug_cfa_restore ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE note.  
static void dwarf2out_frame_debug_cfa_window_save ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_CFA_WINDOW_SAVE.
   ??? Perhaps we should note in the CIE where windows are saved (instead of
   assuming 0(cfa)) and what registers are in the window.  

References dw_trace_info::cfa_temp, cfun, cur_cfa, cur_trace, dwarf2out_frame_debug_expr(), dwf_regno(), function::fde, HOST_WIDE_INT, limit, cfa_loc::offset, offset, cfa_loc::reg, reg_saved_in(), SET, and dw_fde_struct::stack_realign.

static void dwarf2out_frame_debug_def_cfa ( )
static
   A subroutine of dwarf2out_frame_debug, process a REG_DEF_CFA note.  
     ??? If this fails, we could be calling into the _loc functions to
     define a full expression.  So far no port does that.  
static void dwarf2out_frame_debug_expr ( )
static
   Record call frame debugging information for an expression EXPR,
   which either sets SP or FP (adjusting how we calculate the frame
   address) or saves a register to the stack or another register.
   LABEL indicates the address of EXPR.

   This function encodes a state machine mapping rtxes to actions on
   cfa, cfa_store, and cfa_temp.reg.  We describe these rules so
   users need not read the source code.

  The High-Level Picture

  Changes in the register we use to calculate the CFA: Currently we
  assume that if you copy the CFA register into another register, we
  should take the other one as the new CFA register; this seems to
  work pretty well.  If it's wrong for some target, it's simple
  enough not to set RTX_FRAME_RELATED_P on the insn in question.

  Changes in the register we use for saving registers to the stack:
  This is usually SP, but not always.  Again, we deduce that if you
  copy SP into another register (and SP is not the CFA register),
  then the new register is the one we will be using for register
  saves.  This also seems to work.

  Register saves: There's not much guesswork about this one; if
  RTX_FRAME_RELATED_P is set on an insn which modifies memory, it's a
  register save, and the register used to calculate the destination
  had better be the one we think we're using for this purpose.
  It's also assumed that a copy from a call-saved register to another
  register is saving that register if RTX_FRAME_RELATED_P is set on
  that instruction.  If the copy is from a call-saved register to
  the *same* register, that means that the register is now the same
  value as in the caller.

  Except: If the register being saved is the CFA register, and the
  offset is nonzero, we are saving the CFA, so we assume we have to
  use DW_CFA_def_cfa_expression.  If the offset is 0, we assume that
  the intent is to save the value of SP from the previous frame.

  In addition, if a register has previously been saved to a different
  register,

  Invariants / Summaries of Rules

  cfa          current rule for calculating the CFA.  It usually
               consists of a register and an offset.  This is
               actually stored in *cur_cfa, but abbreviated
               for the purposes of this documentation.
  cfa_store    register used by prologue code to save things to the stack
               cfa_store.offset is the offset from the value of
               cfa_store.reg to the actual CFA
  cfa_temp     register holding an integral value.  cfa_temp.offset
               stores the value, which will be used to adjust the
               stack pointer.  cfa_temp is also used like cfa_store,
               to track stores to the stack via fp or a temp reg.

  Rules  1- 4: Setting a register's value to cfa.reg or an expression
               with cfa.reg as the first operand changes the cfa.reg and its
               cfa.offset.  Rule 1 and 4 also set cfa_temp.reg and
               cfa_temp.offset.

  Rules  6- 9: Set a non-cfa.reg register value to a constant or an
               expression yielding a constant.  This sets cfa_temp.reg
               and cfa_temp.offset.

  Rule 5:      Create a new register cfa_store used to save items to the
               stack.

  Rules 10-14: Save a register to the stack.  Define offset as the
               difference of the original location and cfa_store's
               location (or cfa_temp's location if cfa_temp is used).

  Rules 16-20: If AND operation happens on sp in prologue, we assume
               stack is realigned.  We will use a group of DW_OP_XXX
               expressions to represent the location of the stored
               register instead of CFA+offset.

  The Rules

  "{a,b}" indicates a choice of a xor b.
  "<reg>:cfa.reg" indicates that <reg> must equal cfa.reg.

  Rule 1:
  (set <reg1> <reg2>:cfa.reg)
  effects: cfa.reg = <reg1>
           cfa.offset unchanged
           cfa_temp.reg = <reg1>
           cfa_temp.offset = cfa.offset

  Rule 2:
  (set sp ({minus,plus,losum} {sp,fp}:cfa.reg
                              {<const_int>,<reg>:cfa_temp.reg}))
  effects: cfa.reg = sp if fp used
           cfa.offset += {+/- <const_int>, cfa_temp.offset} if cfa.reg==sp
           cfa_store.offset += {+/- <const_int>, cfa_temp.offset}
             if cfa_store.reg==sp

  Rule 3:
  (set fp ({minus,plus,losum} <reg>:cfa.reg <const_int>))
  effects: cfa.reg = fp
           cfa_offset += +/- <const_int>

  Rule 4:
  (set <reg1> ({plus,losum} <reg2>:cfa.reg <const_int>))
  constraints: <reg1> != fp
               <reg1> != sp
  effects: cfa.reg = <reg1>
           cfa_temp.reg = <reg1>
           cfa_temp.offset = cfa.offset

  Rule 5:
  (set <reg1> (plus <reg2>:cfa_temp.reg sp:cfa.reg))
  constraints: <reg1> != fp
               <reg1> != sp
  effects: cfa_store.reg = <reg1>
           cfa_store.offset = cfa.offset - cfa_temp.offset

  Rule 6:
  (set <reg> <const_int>)
  effects: cfa_temp.reg = <reg>
           cfa_temp.offset = <const_int>

  Rule 7:
  (set <reg1>:cfa_temp.reg (ior <reg2>:cfa_temp.reg <const_int>))
  effects: cfa_temp.reg = <reg1>
           cfa_temp.offset |= <const_int>

  Rule 8:
  (set <reg> (high <exp>))
  effects: none

  Rule 9:
  (set <reg> (lo_sum <exp> <const_int>))
  effects: cfa_temp.reg = <reg>
           cfa_temp.offset = <const_int>

  Rule 10:
  (set (mem ({pre,post}_modify sp:cfa_store (???? <reg1> <const_int>))) <reg2>)
  effects: cfa_store.offset -= <const_int>
           cfa.offset = cfa_store.offset if cfa.reg == sp
           cfa.reg = sp
           cfa.base_offset = -cfa_store.offset

  Rule 11:
  (set (mem ({pre_inc,pre_dec,post_dec} sp:cfa_store.reg)) <reg>)
  effects: cfa_store.offset += -/+ mode_size(mem)
           cfa.offset = cfa_store.offset if cfa.reg == sp
           cfa.reg = sp
           cfa.base_offset = -cfa_store.offset

  Rule 12:
  (set (mem ({minus,plus,losum} <reg1>:{cfa_store,cfa_temp} <const_int>))

       <reg2>)
  effects: cfa.reg = <reg1>
           cfa.base_offset = -/+ <const_int> - {cfa_store,cfa_temp}.offset

  Rule 13:
  (set (mem <reg1>:{cfa_store,cfa_temp}) <reg2>)
  effects: cfa.reg = <reg1>
           cfa.base_offset = -{cfa_store,cfa_temp}.offset

  Rule 14:
  (set (mem (post_inc <reg1>:cfa_temp <const_int>)) <reg2>)
  effects: cfa.reg = <reg1>
           cfa.base_offset = -cfa_temp.offset
           cfa_temp.offset -= mode_size(mem)

  Rule 15:
  (set <reg> {unspec, unspec_volatile})
  effects: target-dependent

  Rule 16:
  (set sp (and: sp <const_int>))
  constraints: cfa_store.reg == sp
  effects: cfun->fde.stack_realign = 1
           cfa_store.offset = 0
           fde->drap_reg = cfa.reg if cfa.reg != sp and cfa.reg != fp

  Rule 17:
  (set (mem ({pre_inc, pre_dec} sp)) (mem (plus (cfa.reg) (const_int))))
  effects: cfa_store.offset += -/+ mode_size(mem)

  Rule 18:
  (set (mem ({pre_inc, pre_dec} sp)) fp)
  constraints: fde->stack_realign == 1
  effects: cfa_store.offset = 0
           cfa.reg != HARD_FRAME_POINTER_REGNUM

  Rule 19:
  (set (mem ({pre_inc, pre_dec} sp)) cfa.reg)
  constraints: fde->stack_realign == 1
               && cfa.offset == 0
               && cfa.indirect == 0
               && cfa.reg != HARD_FRAME_POINTER_REGNUM
  effects: Use DW_CFA_def_cfa_expression to define cfa
           cfa.reg == fde->drap_reg  
     If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
     the PARALLEL independently. The first element is always processed if
     it is a SET. This is for backward compatibility.   Other elements
     are processed only if they are SETs and the RTX_FRAME_RELATED_P
     flag is set in them.  
         PARALLELs have strict read-modify-write semantics, so we
         ought to evaluate every rvalue before changing any lvalue.
         It's cumbersome to do that in general, but there's an
         easy approximation that is enough for all current users:
         handle register saves before register assignments.  
             Setting FP from SP.  
                 Rule 1 
                 Update the CFA rule wrt SP or FP.  Make sure src is
                 relative to the current CFA register.

                 We used to require that dest be either SP or FP, but the
                 ARM copies SP to a temporary register, and from there to
                 FP.  So we just rely on the backends to only set
                 RTX_FRAME_RELATED_P on appropriate insns.  
                 Saving a register in a register.  
                             For the SPARC and its register window.  
                 After stack is aligned, we can only save SP in FP
                 if drap register is used.  In this case, we have
                 to restore stack pointer with the CFA value and we
                 don't generate this DWARF information.  
                 Rule 2 
                 Adjusting SP.  
                     Restoring SP from FP in the epilogue.  
                   Assume we've set the source reg of the LO_SUM from sp.  
                 Rule 3 
                 Either setting the FP from an offset of the SP,
                 or adjusting the FP 
                 Rule 4 
                     Setting a temporary CFA register that will be copied
                     into the FP later on.  
                     Or used to save regs to the stack.  
                 Rule 5 
                     Setting a scratch register that we will use instead
                     of SP for saving registers to the stack.  
                 Rule 9 
             Rule 6 
             Rule 7 
             Skip over HIGH, assuming it will be followed by a LO_SUM,
             which will fill in all of the bits.  
             Rule 8 
             Rule 15 
             All unspecs should be represented by REG_CFA_* notes.  
             Rule 16 
             If this AND operation happens on stack pointer in prologue,
             we assume the stack is realigned and we extract the
             alignment.  
                 We interpret reg_save differently with stack_realign set.
                 Thus we must flush whatever we have queued first.  
         Saving a register to the stack.  Make sure dest is relative to the
         CFA register.  
             Rule 10 
             With a push.  
             We can't handle variable size modifications.  
             Rule 11 
             Rule 18: If stack is aligned, we will use FP as a
             reference to represent the address of the stored
             regiser.  
             Rule 12 
             With an offset.  
             Rule 13 
             Without an offset.  
             Rule 14 
         Rule 17 
         If the source operand of this MEM operation is a memory,
         we only care how much stack grew.  
             We're storing the current CFA reg into the stack.  
                 Rule 19 
                 If stack is aligned, putting CFA reg into stack means
                 we can no longer use reg + offset to represent CFA.
                 Here we use DW_CFA_def_cfa_expression instead.  The
                 result of this expression equals to the original CFA
                 value.  
                 If the source register is exactly the CFA, assume
                 we're saving SP like any other register; this happens
                 on the ARM.  
                 Otherwise, we'll need to look in the stack to
                 calculate the CFA.  
             We have a PARALLEL describing where the contents of SRC live.
             Queue register saves for each piece of the PARALLEL.  

Referenced by dwarf2out_frame_debug_cfa_window_save().

static const char* dwarf_cfi_name ( )
static
   Convert a DWARF call frame info. operation to its string name 

References asm_out_file.

static unsigned dwf_regno ( )
inlinestatic
   Short-hand inline for the very common D_F_R (REGNO (x)) operation.  
   ??? This ought to go into dwarf2out.h, except that dwarf2out.h is
   used in places where rtl is prohibited.  

References pc_rtx, record_reg_saved_in_reg(), queued_reg_save::reg, and queued_reg_save::saved_reg.

Referenced by dwarf2out_flush_queued_reg_saves(), dwarf2out_frame_debug_adjust_cfa(), dwarf2out_frame_debug_cfa_window_save(), and reg_saved_in().

static unsigned int execute_dwarf2_frame ( )
static
   Annotate the function with NOTE_INSN_CFI notes to record the CFI
   state at each location within the function.  These notes will be
   emitted during pass_final.  
     The first time we're called, compute the incoming frame state.  
     Do the work.  
     Free all the data we allocated.  
rtx expand_builtin_dwarf_sp_column ( void  )
   Hook used by __throw.  

References choose_hard_reg_mode(), and HOST_WIDE_INT.

void expand_builtin_init_dwarf_reg_sizes ( )
   Generate code to initialize the register size table.  

References targetm.

static bool gate_dwarf2_frame ( )
static
     Targets which still implement the prologue in assembler text
     cannot use the generic dwarf2 unwinding.  
     ??? What to do for UI_TARGET unwinding?  They might be able to benefit
     from the optimized shrink-wrapping annotations that we will compute.
     For now, only produce the CFI notes for dwarf2.  
static void get_cfa_from_loc_descr ( )
static
   This function fills in aa dw_cfa_location structure from a dwarf location
   descriptor sequence.  
static dw_trace_info* get_trace_info ( )
static

Referenced by change_cfi_row().

static void init_return_column_size ( )
static
   MEM is a memory reference for the register size table, each element of
   which has mode MODE.  Initialize column C as a return address column.  
static void initial_return_save ( )
static
   Record the initial position of the return address.  RTL is
   INCOMING_RETURN_ADDR_RTX.  
         RA is in a register.  
         RA is on the stack.  
         The return address is at some offset from any value we can
         actually load.  For instance, on the SPARC it is in %i7+8. Just
         ignore the offset for now; it doesn't matter for unwinding frames.  
void lookup_cfa_1 ( )
   Find the previous value for the CFA, iteratively.  CFI is the opcode
   to interpret, *LOC will be updated as necessary, *REMEMBER is used for
   one level of remember/restore state processing.  

References dw_cfi_oprnd_struct::dw_cfi_addr, dw_cfi_oprnd_struct::dw_cfi_loc, dw_cfi_oprnd_struct::dw_cfi_offset, dw_cfi_oprnd_addr, dw_cfi_oprnd_loc, dw_cfi_oprnd_offset, dw_cfi_oprnd_reg_num, dw_cfi_oprnd_unused, dw_cfi_oprnd_struct::dw_cfi_reg_num, and loc_descr_equal_p().

rtl_opt_pass* make_pass_dwarf2_frame ( )
static void maybe_record_trace_start ( )
static
   If LABEL is the start of a trace, then initialize the state of that
   trace from CUR_TRACE and CUR_ROW.  
         This is the first time we've encountered this trace.  Propagate
         state across the edge and push the trace onto the work list.  
         We ought to have the same state incoming to a given trace no
         matter how we arrive at the trace.  Anything else means we've
         got some kind of optimization error.  
         The args_size is allowed to conflict if it isn't actually used.  

Referenced by cfi_label_required_p().

static void maybe_record_trace_start_abnormal ( )
static
   Similarly, but handle the args_size and CFA reset across EH
   and non-local goto edges.  
         Convert a change in args_size (always a positive in the
         direction of stack growth) to a change in stack pointer.  
static bool need_data_align_sf_opcode ( )
inlinestatic
   Return true if we need a signed version of a given opcode
   (e.g. DW_CFA_offset_extended_sf vs DW_CFA_offset_extended).  
static dw_cfi_ref new_cfi ( )
inlinestatic
   Return a pointer to a newly allocated Call Frame Instruction.  

Referenced by copy_cfi_row(), and dwarf2out_cfi_label().

static dw_cfi_row* new_cfi_row ( )
static
   Return a newly allocated CFI row, with no defined data.  

References add_cfi_insn, and emit_note_after().

static void notice_args_size ( )
static
   A subroutine of scan_trace.  Check INSN for a REG_ARGS_SIZE note
   and adjust data structures to match.  
     If the CFA is computed off the stack pointer, then we must adjust
     the computation of the CFA as well.  
         Convert a change in args_size (always a positive in the
         direction of stack growth) to a change in stack pointer.  
static void notice_eh_throw ( )
static
   A subroutine of scan_trace.  INSN is can_throw_internal.  Update the
   data within the trace related to EH insns and args_size.  
         ??? If the CFA is the stack pointer, search backward for the last
         CFI note and insert there.  Given that the stack changed for the
         args_size change, there *must* be such a note in between here and
         the last eh insn.  

References compare_reg_or_pc(), and queued_reg_save::reg.

static void output_cfa_loc ( )
static
   This routine will generate the correct assembly data for a location
   description based on a cfi entry with a complex address.  
     Output the size of the block.  
     Now output the operations themselves.  
static void output_cfa_loc_raw ( )
static
   Similar, but used for .cfi_escape.  
     Output the size of the block.  
     Now output the operations themselves.  
void output_cfi ( )
   Output a Call Frame Information opcode and its operand(s).  
             Obsoleted by DW_CFA_offset_extended_sf.  

References dw2_asm_output_data_uleb128_raw(), dw_cfi_oprnd_struct::dw_cfi_offset, dw_cfi_struct::dw_cfi_oprnd1, and HOST_WIDE_INT_PRINT_DEC.

void output_cfi_directive ( )
   Similar, but do it via assembler directives instead.  
         Should only be created in a code path not followed when emitting
         via directives.  The assembler is going to take care of this for
         us.  But this routines is also used for debugging dumps, so
         print something.  
         FALLTHRU 
static void queue_reg_save ( )
static
   Add an entry to QUEUED_REG_SAVES saying that REG is now saved at
   SREG, or if SREG is NULL then it is saved at OFFSET to the CFA.  
     Duplicates waste space, but it's also necessary to remove them
     for correctness, since the queue gets output in reverse order.  

References cur_trace, reg_saved_in_data_struct::orig_reg, queued_reg_save::reg, dw_trace_info::regs_saved_in_regs, reg_saved_in_data_struct::saved_in_reg, and queued_reg_save::saved_reg.

static void record_reg_saved_in_reg ( )
static
   Record SRC as being saved in DEST.  DEST may be null to delete an
   existing entry.  SRC may be a register or PC_RTX.  

References compare_reg_or_pc(), cur_trace, modified_in_p(), reg_saved_in_data_struct::orig_reg, queued_reg_save::reg, dw_trace_info::regs_saved_in_regs, and reg_saved_in_data_struct::saved_in_reg.

Referenced by dwf_regno().

static void reg_save ( )
static
   Add the CFI for saving a register.  REG is the CFA column number.
   If SREG is -1, the register is saved at OFFSET from the CFA;
   otherwise it is saved in SREG.  
     When stack is aligned, store REG using DW_CFA_expression with FP.  
         While we could emit something like DW_CFA_same_value or
         DW_CFA_restore, we never expect to see something like that
         in a prologue.  This is more likely to be a bug.  A backend
         can always bypass this by using REG_CFA_RESTORE directly.  

References cur_cfa, cfa_loc::indirect, and cfa_loc::offset.

Referenced by dwarf2out_frame_debug_adjust_cfa().

static rtx reg_saved_in ( )
static
   What register, if any, is currently saved in REG?  

References cur_cfa, dwf_regno(), HOST_WIDE_INT, cfa_loc::offset, offset, and cfa_loc::reg.

Referenced by dwarf2out_frame_debug_cfa_window_save().

static bool save_point_p ( )
static
     Labels, except those that are really jump tables.  
     We split traces at the prologue/epilogue notes because those
     are points at which the unwind info is usually stable.  This
     makes it easier to find spots with identical unwind info so
     that we can use remember/restore_state opcodes.  

Referenced by create_cfi_notes().

static void scan_insn_after ( )
static
   A subroutine of scan_trace.  Do what needs to be done "after" INSN.  

Referenced by create_trace_edges().

static void scan_trace ( )
static
   Scan the trace beginning at INSN and create the CFI notes for the
   instructions therein.  
         Do everything that happens "before" the insn.  
         Notice the end of a trace.  
             Don't bother saving the unneeded queued registers at all.  
             Propagate across fallthru edges.  
         Handle all changes to the row state.  Sequences require special
         handling for the positioning of the notes.  
                 ??? Hopefully multiple delay slots are not annulled.  
                     If ELT is an instruction from target of an annulled
                     branch, the effects are for the target only and so
                     the args_size and CFA along the current path
                     shouldn't change.  
                     ??? Should we instead save the entire row state?  
                     If ELT is a annulled branch-taken instruction (i.e.
                     executed only when branch is not taken), the args_size
                     and CFA should not change through the jump.  
                     Update and continue with the trace.  
             The insns in the delay slot should all be considered to happen
             "before" a call insn.  Consider a call with a stack pointer
             adjustment in the delay slot.  The backtrace from the callee
             should include the sp adjustment.  Unfortunately, that leaves
             us with an unavoidable unwinding error exactly at the call insn
             itself.  For jump insns we'd prefer to avoid this error by
             placing the notes after the sequence.  
             Make sure any register saves are visible at the jump target.  
             However, if there is some adjustment on the call itself, e.g.
             a call_pop, that action should be considered to happen after
             the call returns.  
             Flush data before calls and jumps, and of course if necessary.  
         Between frame-related-p and args_size we might have otherwise
         emitted two cfa adjustments.  Do it now.  
         Minimize the number of advances by emitting the entire queue
         once anything is emitted.  
         Note that a test for control_flow_insn_p does exactly the
         same tests as are done to actually create the edges.  So
         always call the routine and let it not create edges for
         non-control-flow insns.  
static void update_row_reg_save ( )
static
   Perform ROW->REG_SAVE[COLUMN] = CFI.  CFI may be null, indicating
   that the register column is no longer saved.  

Variable Documentation

rtx add_cfi_insn
static
   The insn after which a new CFI note should be emitted.  

Referenced by create_trace_edges(), and new_cfi_row().

cfi_vec* add_cfi_vec
static
   When non-null, add_cfi will add the CFI to this vector.  
bool any_cfis_emitted
static
   True if any CFI directives were emitted at the current insn.  
dw_cfi_row* cie_cfi_row
static
   The state of the first row of the FDE table, which includes the
   state provided by the CIE.  
cfi_vec cie_cfi_vec
   A vector of call frame insns for the CIE.  
reg_saved_in_data* cie_return_save
static
dw_cfa_location* cur_cfa
static
   A copy of the current CFA, for use during the processing of a
   single insn.  

Referenced by create_trace_edges(), dwarf2out_flush_queued_reg_saves(), dwarf2out_frame_debug_cfa_window_save(), reg_save(), and reg_saved_in().

dw_cfi_row* cur_row
static
   The current, i.e. most recently generated, row of the CFI table.  

Referenced by cfi_label_required_p(), change_cfi_row(), and create_trace_edges().

unsigned dw_frame_pointer_regnum
static
unsigned dw_stack_pointer_regnum
static
   Short-hand for commonly used register numbers.  
unsigned long dwarf2out_cfi_label_num
static
vec<queued_reg_save> queued_reg_saves
static
signed char saved_do_cfi_asm = 0
static
   Save the result of dwarf2out_do_frame across PCH.
   This variable is tri-state, with 0 unset, >0 true, <0 false.  
hash_table<trace_info_hasher> trace_index
static
vec<dw_trace_info> trace_info
static
   The variables making up the pseudo-cfg, as described above.  
vec<dw_trace_info_ref> trace_work_list
static