GCC Middle and Back End API Reference
dwarf2cfi.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "function.h"
#include "rtl.h"
#include "tree.h"
#include "tree-pass.h"
#include "memmodel.h"
#include "tm_p.h"
#include "emit-rtl.h"
#include "stor-layout.h"
#include "cfgbuild.h"
#include "dwarf2out.h"
#include "dwarf2asm.h"
#include "common/common-target.h"
#include "except.h"
#include "profile-count.h"
#include "expr.h"
#include "output.h"
#include "debug.h"
#include "flags.h"
#include "gt-dwarf2cfi.h"
Include dependency graph for dwarf2cfi.cc:

Data Structures

struct  dw_cfi_row
 
struct  reg_saved_in_data
 
struct  dw_trace_info
 
struct  trace_info_hasher
 
struct  queued_reg_save
 
struct  init_one_dwarf_reg_state
 

Macros

#define INCOMING_RETURN_ADDR_RTX   (gcc_unreachable (), NULL_RTX)
 
#define DEFAULT_INCOMING_FRAME_SP_OFFSET   INCOMING_FRAME_SP_OFFSET
 

Enumerations

enum  ra_signing_method_t { ra_no_signing = 0x0 , ra_signing_sp = 0x1 }
 

Functions

rtx expand_builtin_dwarf_sp_column (void)
 
static void init_return_column_size (scalar_int_mode mode, rtx mem, unsigned int c)
 
static void init_one_dwarf_reg_size (int regno, machine_mode regmode, rtx table, machine_mode slotmode, init_one_dwarf_reg_state *init_state)
 
void expand_builtin_init_dwarf_reg_sizes (tree address)
 
static dw_trace_infoget_trace_info (rtx_insn *insn)
 
static bool save_point_p (rtx_insn *insn)
 
static HOST_WIDE_INT div_data_align (HOST_WIDE_INT off)
 
static bool need_data_align_sf_opcode (HOST_WIDE_INT off)
 
static dw_cfi_ref new_cfi (void)
 
static dw_cfi_rownew_cfi_row (void)
 
static dw_cfi_rowcopy_cfi_row (dw_cfi_row *src)
 
static dw_cfa_locationcopy_cfa (dw_cfa_location *src)
 
static char * dwarf2out_cfi_label (void)
 
static void add_cfi (dw_cfi_ref cfi)
 
static void add_cfi_args_size (poly_int64 size)
 
static void add_cfi_restore (unsigned reg)
 
static void update_row_reg_save (dw_cfi_row *row, unsigned column, dw_cfi_ref cfi)
 
static void get_cfa_from_loc_descr (dw_cfa_location *cfa, struct dw_loc_descr_node *loc)
 
void lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_location *loc, dw_cfa_location *remember)
 
bool cfa_equal_p (const dw_cfa_location *loc1, const dw_cfa_location *loc2)
 
static bool cfi_oprnd_equal_p (enum dw_cfi_oprnd_type t, dw_cfi_oprnd *a, dw_cfi_oprnd *b)
 
static bool cfi_equal_p (dw_cfi_ref a, dw_cfi_ref b)
 
static bool cfi_row_equal_p (dw_cfi_row *a, dw_cfi_row *b)
 
static dw_cfi_ref def_cfa_0 (dw_cfa_location *old_cfa, dw_cfa_location *new_cfa)
 
static void def_cfa_1 (dw_cfa_location *new_cfa)
 
static void reg_save (unsigned int reg, struct cfa_reg sreg, poly_int64 offset)
 
static void notice_args_size (rtx_insn *insn)
 
static void notice_eh_throw (rtx_insn *insn)
 
static unsigned dwf_regno (const_rtx reg)
 
static struct cfa_reg dwf_cfa_reg (rtx reg)
 
static bool operator== (cfa_reg &cfa, rtx reg)
 
static bool operator!= (cfa_reg &cfa, rtx reg)
 
static bool compare_reg_or_pc (rtx x, rtx y)
 
static void record_reg_saved_in_reg (rtx dest, rtx src)
 
static void queue_reg_save (rtx reg, rtx sreg, poly_int64 offset)
 
static void dwarf2out_flush_queued_reg_saves (void)
 
static bool clobbers_queued_reg_save (const_rtx insn)
 
static rtx reg_saved_in (rtx reg)
 
static void dwarf2out_frame_debug_def_cfa (rtx pat)
 
static void dwarf2out_frame_debug_adjust_cfa (rtx pat)
 
static void dwarf2out_frame_debug_cfa_offset (rtx set)
 
static void dwarf2out_frame_debug_cfa_register (rtx set)
 
static void dwarf2out_frame_debug_cfa_expression (rtx set)
 
static void dwarf2out_frame_debug_cfa_val_expression (rtx set)
 
static void dwarf2out_frame_debug_cfa_restore (rtx reg, bool emit_cfi)
 
static void dwarf2out_frame_debug_cfa_window_save (void)
 
static void dwarf2out_frame_debug_cfa_negate_ra_state (void)
 
static void dwarf2out_frame_debug_expr (rtx expr)
 
static void dwarf2out_frame_debug (rtx_insn *insn)
 
static void change_cfi_row (dw_cfi_row *old_row, dw_cfi_row *new_row)
 
static bool cfi_label_required_p (dw_cfi_ref cfi)
 
static void add_cfis_to_fde (void)
 
static void dump_cfi_row (FILE *f, dw_cfi_row *row)
 
static void maybe_record_trace_start (rtx_insn *start, rtx_insn *origin)
 
static void maybe_record_trace_start_abnormal (rtx_insn *start, rtx_insn *origin)
 
static void create_trace_edges (rtx_insn *insn)
 
static void scan_insn_after (rtx_insn *insn)
 
static void scan_trace (dw_trace_info *trace, bool entry)
 
static void create_cfi_notes (void)
 
static rtx_insnbefore_next_cfi_note (rtx_insn *start)
 
static void connect_traces (void)
 
static void create_pseudo_cfg (void)
 
static void initial_return_save (rtx rtl)
 
static void create_cie_data (void)
 
static void execute_dwarf2_frame (void)
 
static const char * dwarf_cfi_name (unsigned int cfi_opc)
 
static void output_cfa_loc (dw_cfi_ref cfi, int for_eh)
 
static void output_cfa_loc_raw (dw_cfi_ref cfi)
 
void output_cfi (dw_cfi_ref cfi, dw_fde_ref fde, int for_eh)
 
void output_cfi_directive (FILE *f, dw_cfi_ref cfi)
 
void dwarf2out_emit_cfi (dw_cfi_ref cfi)
 
void debug_cfi_row (dw_cfi_row *row)
 
bool dwarf2out_do_eh_frame (void)
 
bool dwarf2out_do_frame (void)
 
bool dwarf2out_do_cfi_asm (void)
 
rtl_opt_passmake_pass_dwarf2_frame (gcc::context *ctxt)
 
void dwarf2cfi_cc_finalize ()
 

Variables

static vec< dw_trace_infotrace_info
 
static vec< dw_trace_info * > trace_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_insnadd_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 struct cfa_reg dw_stack_pointer_regnum
 
static struct cfa_reg dw_frame_pointer_regnum
 
static signed char saved_do_cfi_asm = 0
 

Macro Definition Documentation

◆ DEFAULT_INCOMING_FRAME_SP_OFFSET

#define DEFAULT_INCOMING_FRAME_SP_OFFSET   INCOMING_FRAME_SP_OFFSET

Referenced by create_cie_data(), and scan_trace().

◆ INCOMING_RETURN_ADDR_RTX

#define INCOMING_RETURN_ADDR_RTX   (gcc_unreachable (), NULL_RTX)
Dwarf2 Call Frame Information helper routines.
   Copyright (C) 1992-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
??? Poison these here until it can be done generically.  They've been
totally replaced in this file; make sure it stays that way.   

Referenced by create_cie_data(), and df_get_entry_block_def_set().

Enumeration Type Documentation

◆ ra_signing_method_t

Signing method used for return address authentication.
(AArch64 extension)   
Enumerator
ra_no_signing 
ra_signing_sp 

Function Documentation

◆ add_cfi()

◆ add_cfi_args_size()

◆ add_cfi_restore()

static void add_cfi_restore ( unsigned reg)
static

◆ add_cfis_to_fde()

static void add_cfis_to_fde ( void )
static

◆ before_next_cfi_note()

static rtx_insn * before_next_cfi_note ( rtx_insn * start)
static
Return the insn before the first NOTE_INSN_CFI after START.   

References gcc_unreachable, NEXT_INSN(), NOTE_KIND, and NOTE_P.

Referenced by connect_traces().

◆ cfa_equal_p()

bool cfa_equal_p ( const dw_cfa_location * loc1,
const dw_cfa_location * loc2 )

◆ cfi_equal_p()

static bool cfi_equal_p ( dw_cfi_ref a,
dw_cfi_ref b )
static
Determine if two CFI entries are identical.   

References a, b, cfi_oprnd_equal_p(), dw_cfi_oprnd1_desc(), dw_cfi_oprnd2_desc(), and NULL.

Referenced by cfi_row_equal_p(), and change_cfi_row().

◆ cfi_label_required_p()

static bool cfi_label_required_p ( dw_cfi_ref cfi)
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 DINFO_LEVEL_TERSE, dw_cfi_node::dw_cfi_opc, dwarf2out_do_cfi_asm(), and dwarf_debuginfo_p().

Referenced by add_cfis_to_fde().

◆ cfi_oprnd_equal_p()

static bool cfi_oprnd_equal_p ( enum dw_cfi_oprnd_type t,
dw_cfi_oprnd * a,
dw_cfi_oprnd * b )
static

◆ cfi_row_equal_p()

static bool cfi_row_equal_p ( dw_cfi_row * a,
dw_cfi_row * b )
static
Determine if two CFI_ROW structures are identical.   

References a, b, cfa_equal_p(), cfi_equal_p(), i, MAX, NULL, and vec_safe_length().

Referenced by connect_traces(), and maybe_record_trace_start().

◆ change_cfi_row()

static void change_cfi_row ( dw_cfi_row * old_row,
dw_cfi_row * new_row )
static

◆ clobbers_queued_reg_save()

static bool clobbers_queued_reg_save ( const_rtx insn)
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?   

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

Referenced by dwarf2out_frame_debug(), and scan_trace().

◆ compare_reg_or_pc()

static bool compare_reg_or_pc ( rtx x,
rtx y )
static
Compare X and Y for equivalence.  The inputs may be REGs or PC_RTX.   

References REG_P, REGNO, and y.

Referenced by clobbers_queued_reg_save(), queue_reg_save(), and record_reg_saved_in_reg().

◆ connect_traces()

◆ copy_cfa()

static dw_cfa_location * copy_cfa ( dw_cfa_location * src)
static
Return a copy of an existing CFA location.   

References ggc_alloc().

Referenced by def_cfa_0().

◆ copy_cfi_row()

static dw_cfi_row * copy_cfi_row ( dw_cfi_row * src)
static
Return a copy of an existing CFI row.   

References ggc_alloc(), dw_cfi_row::reg_save, and vec_safe_copy().

Referenced by maybe_record_trace_start(), and scan_trace().

◆ create_cfi_notes()

static void create_cfi_notes ( void )
static
Scan the function and create the initial set of CFI notes.   

References gcc_checking_assert, queued_reg_saves, scan_trace(), trace_info, and trace_work_list.

Referenced by execute_dwarf2_frame().

◆ create_cie_data()

◆ create_pseudo_cfg()

◆ create_trace_edges()

◆ debug_cfi_row()

void debug_cfi_row ( dw_cfi_row * row)

References dump_cfi_row().

◆ def_cfa_0()

◆ def_cfa_1()

static void def_cfa_1 ( dw_cfa_location * new_cfa)
static

◆ div_data_align()

static HOST_WIDE_INT div_data_align ( HOST_WIDE_INT off)
inlinestatic
Divide OFF by DWARF_CIE_DATA_ALIGNMENT, asserting no remainder.   

References DWARF_CIE_DATA_ALIGNMENT, gcc_assert, and r.

Referenced by output_cfi().

◆ dump_cfi_row()

◆ dwarf2cfi_cc_finalize()

void dwarf2cfi_cc_finalize ( void )

◆ dwarf2out_cfi_label()

static char * dwarf2out_cfi_label ( void )
static
Generate a new label for the CFI info to refer to.   

References dwarf2out_cfi_label_num.

Referenced by add_cfis_to_fde().

◆ dwarf2out_do_cfi_asm()

◆ dwarf2out_do_eh_frame()

bool dwarf2out_do_eh_frame ( void )
Decide whether to emit EH frame unwind information for the current
translation unit.   

References global_options, and UI_DWARF2.

Referenced by dwarf2out_begin_prologue(), dwarf2out_do_cfi_asm(), and dwarf2out_do_frame().

◆ dwarf2out_do_frame()

bool dwarf2out_do_frame ( void )
Decide whether we want to emit frame unwind information for the current
translation unit.   

References dwarf2out_do_eh_frame(), dwarf_based_debuginfo_p(), dwarf_debuginfo_p(), saved_do_cfi_asm, targetm, and UI_DWARF2.

Referenced by dwarf2out_begin_prologue(), dwarf2out_do_cfi_asm(), final_end_function(), and final_scan_insn_1().

◆ dwarf2out_emit_cfi()

void dwarf2out_emit_cfi ( dw_cfi_ref cfi)

◆ dwarf2out_flush_queued_reg_saves()

◆ dwarf2out_frame_debug()

◆ dwarf2out_frame_debug_adjust_cfa()

static void dwarf2out_frame_debug_adjust_cfa ( rtx pat)
static
A subroutine of dwarf2out_frame_debug, process a REG_ADJUST_CFA note.   

References cur_cfa, dwf_cfa_reg(), gcc_assert, gcc_unreachable, GET_CODE, dw_cfa_location::indirect, dw_cfa_location::offset, dw_cfa_location::reg, rtx_to_poly_int64(), SET, and XEXP.

Referenced by dwarf2out_frame_debug().

◆ dwarf2out_frame_debug_cfa_expression()

◆ dwarf2out_frame_debug_cfa_negate_ra_state()

static void dwarf2out_frame_debug_cfa_negate_ra_state ( void )
static
A subroutine of dwarf2out_frame_debug, process REG_CFA_NEGATE_RA_STATE.   

References add_cfi(), cur_row, dw_cfi_node::dw_cfi_opc, new_cfi(), ra_no_signing, ra_signing_sp, and dw_cfi_row::ra_state.

Referenced by dwarf2out_frame_debug().

◆ dwarf2out_frame_debug_cfa_offset()

static void dwarf2out_frame_debug_cfa_offset ( rtx set)
static

◆ dwarf2out_frame_debug_cfa_register()

static void dwarf2out_frame_debug_cfa_register ( rtx set)
static
A subroutine of dwarf2out_frame_debug, process a REG_CFA_REGISTER note.   

References DWARF_FRAME_RETURN_COLUMN, dwf_cfa_reg(), dwf_regno(), pc_rtx, record_reg_saved_in_reg(), reg_save(), and XEXP.

Referenced by dwarf2out_frame_debug().

◆ dwarf2out_frame_debug_cfa_restore()

static void dwarf2out_frame_debug_cfa_restore ( rtx reg,
bool emit_cfi )
static
A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE
note. When called with EMIT_CFI set to false emitting a CFI
statement is suppressed.   

References add_cfi_restore(), cur_row, dwf_regno(), gcc_assert, GET_CODE, NULL, cfa_reg::reg, REG_P, cfa_reg::span, targetm, update_row_reg_save(), XVECEXP, and XVECLEN.

Referenced by dwarf2out_frame_debug().

◆ dwarf2out_frame_debug_cfa_val_expression()

static void dwarf2out_frame_debug_cfa_val_expression ( rtx set)
static

◆ dwarf2out_frame_debug_cfa_window_save()

static void dwarf2out_frame_debug_cfa_window_save ( void )
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 add_cfi(), cur_row, dw_cfi_node::dw_cfi_opc, new_cfi(), and dw_cfi_row::window_save.

Referenced by dwarf2out_frame_debug().

◆ dwarf2out_frame_debug_def_cfa()

static void dwarf2out_frame_debug_def_cfa ( rtx pat)
static
A subroutine of dwarf2out_frame_debug, process a REG_DEF_CFA note.   

References dw_cfa_location::base_offset, cur_cfa, dwf_cfa_reg(), gcc_assert, dw_cfa_location::indirect, MEM_P, dw_cfa_location::offset, dw_cfa_location::reg, REG_P, strip_offset(), and XEXP.

Referenced by dwarf2out_frame_debug().

◆ dwarf2out_frame_debug_expr()

static void dwarf2out_frame_debug_expr ( rtx 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   

References dw_cfa_location::base_offset, dw_trace_info::cfa_store, dw_trace_info::cfa_temp, cfun, CONST_INT_P, cur_cfa, cur_trace, dw_fde_node::drap_reg, dw_fde_node::drap_reg_saved, dw_frame_pointer_regnum, dw_stack_pointer_regnum, dwarf2out_flush_queued_reg_saves(), dwarf2out_frame_debug_expr(), DWARF_FRAME_RETURN_COLUMN, dwf_cfa_reg(), dwf_regno(), fixed_regs, frame_pointer_needed, gcc_assert, gcc_unreachable, GET_CODE, GET_MODE, GET_MODE_SIZE(), HARD_FRAME_POINTER_REGNUM, hard_frame_pointer_rtx, dw_cfa_location::indirect, INTVAL, INVALID_REGNUM, known_eq, MEM_P, NULL, NULL_RTX, dw_cfa_location::offset, offset, poly_int_rtx_p(), queue_reg_save(), cfa_reg::reg, dw_cfa_location::reg, REG_P, reg_saved_in(), REGNO, RTX_FRAME_RELATED_P, rtx_to_poly_int64(), dw_fde_node::rule18, SET, SET_DEST, SET_SRC, cfa_reg::span, stack_pointer_rtx, dw_fde_node::stack_realign, dw_fde_node::stack_realignment, targetm, XEXP, XVECEXP, and XVECLEN.

Referenced by dwarf2out_frame_debug(), and dwarf2out_frame_debug_expr().

◆ dwarf_cfi_name()

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

References NULL.

Referenced by output_cfi().

◆ dwf_cfa_reg()

◆ dwf_regno()

static unsigned dwf_regno ( const_rtx reg)
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 DWARF_FRAME_REGNUM, gcc_assert, and REGNO.

Referenced by dwarf2out_flush_queued_reg_saves(), dwarf2out_frame_debug(), dwarf2out_frame_debug_cfa_expression(), dwarf2out_frame_debug_cfa_offset(), dwarf2out_frame_debug_cfa_register(), dwarf2out_frame_debug_cfa_restore(), dwarf2out_frame_debug_cfa_val_expression(), dwarf2out_frame_debug_expr(), dwf_cfa_reg(), and operator==().

◆ execute_dwarf2_frame()

static void execute_dwarf2_frame ( void )
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.   

References add_cfis_to_fde(), cie_cfi_vec, connect_traces(), create_cfi_notes(), create_cie_data(), create_pseudo_cfg(), dw_frame_pointer_regnum, dwarf2out_alloc_current_fde(), dwf_cfa_reg(), FOR_EACH_VEC_ELT, hard_frame_pointer_rtx, i, NULL, dw_trace_info::regs_saved_in_regs, trace_index, and trace_info.

◆ expand_builtin_dwarf_sp_column()

rtx expand_builtin_dwarf_sp_column ( void )
Hook used by __throw.   

References DWARF2_FRAME_REG_OUT, DWARF_FRAME_REGNUM, and GEN_INT.

Referenced by expand_builtin().

◆ expand_builtin_init_dwarf_reg_sizes()

void expand_builtin_init_dwarf_reg_sizes ( tree address)

◆ get_cfa_from_loc_descr()

◆ get_trace_info()

static dw_trace_info * get_trace_info ( rtx_insn * insn)
static

◆ init_one_dwarf_reg_size()

static void init_one_dwarf_reg_size ( int regno,
machine_mode regmode,
rtx table,
machine_mode slotmode,
init_one_dwarf_reg_state * init_state )
static
Helper for expand_builtin_init_dwarf_reg_sizes.  Generate code to
initialize the dwarf register size table entry corresponding to register
REGNO in REGMODE.  TABLE is the table base address, SLOTMODE is the mode to
use for the size entry to initialize, and INIT_STATE is the communication
datastructure conveying what we're doing to our caller.   

References adjust_address, DWARF2_FRAME_REG_OUT, DWARF_FRAME_REGISTERS, DWARF_FRAME_REGNUM, DWARF_FRAME_RETURN_COLUMN, DWARF_REG_TO_UNWIND_COLUMN, emit_move_insn(), gen_int_mode(), GET_MODE_SIZE(), init_one_dwarf_reg_state::processed_regno, table, and init_one_dwarf_reg_state::wrote_return_column.

Referenced by expand_builtin_init_dwarf_reg_sizes().

◆ init_return_column_size()

static void init_return_column_size ( scalar_int_mode mode,
rtx mem,
unsigned int c )
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.   

References adjust_address, emit_move_insn(), gen_int_mode(), GET_MODE_SIZE(), and offset.

Referenced by expand_builtin_init_dwarf_reg_sizes().

◆ initial_return_save()

static void initial_return_save ( rtx rtl)
static

◆ lookup_cfa_1()

void lookup_cfa_1 ( dw_cfi_ref cfi,
dw_cfa_location * loc,
dw_cfa_location * remember )
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::dw_cfi_cfa_loc, dw_cfi_oprnd::dw_cfi_loc, dw_cfi_oprnd::dw_cfi_offset, dw_cfi_node::dw_cfi_opc, dw_cfi_node::dw_cfi_oprnd1, dw_cfi_node::dw_cfi_oprnd2, dw_cfi_oprnd::dw_cfi_reg_num, gcc_assert, get_cfa_from_loc_descr(), dw_cfa_location::in_use, dw_cfa_location::offset, dw_cfa_location::reg, and cfa_reg::set_by_dwreg().

Referenced by convert_cfa_to_fb_loc_list().

◆ make_pass_dwarf2_frame()

rtl_opt_pass * make_pass_dwarf2_frame ( gcc::context * ctxt)

◆ maybe_record_trace_start()

◆ maybe_record_trace_start_abnormal()

static void maybe_record_trace_start_abnormal ( rtx_insn * start,
rtx_insn * origin )
static
Similarly, but handle the args_size and CFA reset across EH
and non-local goto edges.   

References dw_cfi_row::cfa, cur_row, cur_trace, dw_stack_pointer_regnum, dw_trace_info::end_true_args_size, known_eq, maybe_record_trace_start(), dw_cfa_location::offset, dw_cfa_location::reg, and STACK_GROWS_DOWNWARD.

Referenced by create_trace_edges().

◆ need_data_align_sf_opcode()

static bool need_data_align_sf_opcode ( HOST_WIDE_INT off)
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).   

References DWARF_CIE_DATA_ALIGNMENT.

Referenced by reg_save().

◆ new_cfi()

◆ new_cfi_row()

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

References dw_cfi_row::cfa, ggc_cleared_alloc(), INVALID_REGNUM, dw_cfa_location::reg, and cfa_reg::set_by_dwreg().

Referenced by create_cie_data().

◆ notice_args_size()

static void notice_args_size ( rtx_insn * insn)
static

◆ notice_eh_throw()

static void notice_eh_throw ( rtx_insn * insn)
static
A subroutine of scan_trace.  INSN is can_throw_internal.  Update the
data within the trace related to EH insns and args_size.   

References add_cfi_args_size(), dw_trace_info::beg_delay_args_size, cur_trace, dw_trace_info::eh_head, dw_trace_info::end_delay_args_size, dw_trace_info::end_true_args_size, and NULL.

Referenced by scan_trace().

◆ operator!=()

static bool operator!= ( cfa_reg & cfa,
rtx reg )
inlinestatic

References cfa_reg::reg.

◆ operator==()

static bool operator== ( cfa_reg & cfa,
rtx reg )
static
More efficient comparisons that don't call targetm.dwarf_register_span
unnecessarily.  These cfa_reg vs. rtx comparisons should be done at
least for call-saved REGs that might not be CFA related (like stack
pointer, hard frame pointer or DRAP registers are), in other cases it is
just a compile time and memory optimization.   

References dwf_cfa_reg(), dwf_regno(), and cfa_reg::reg.

◆ output_cfa_loc()

static void output_cfa_loc ( dw_cfi_ref cfi,
int for_eh )
static
This routine will generate the correct assembly data for a location
description based on a cfi entry with a complex address.   

References dw2_asm_output_data(), dw2_asm_output_data_uleb128(), dw_cfi_oprnd::dw_cfi_loc, dw_cfi_node::dw_cfi_opc, dw_cfi_node::dw_cfi_oprnd1, dw_cfi_node::dw_cfi_oprnd2, dw_cfi_oprnd::dw_cfi_reg_num, DWARF2_FRAME_REG_OUT, NULL, output_loc_sequence(), r, and size_of_locs().

Referenced by output_cfi().

◆ output_cfa_loc_raw()

◆ output_cfi()

◆ output_cfi_directive()

◆ queue_reg_save()

static void queue_reg_save ( rtx reg,
rtx sreg,
poly_int64 offset )
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.   

References compare_reg_or_pc(), FOR_EACH_VEC_ELT, i, offset, queued_reg_saves, cfa_reg::reg, and queued_reg_save::reg.

Referenced by dwarf2out_frame_debug_expr().

◆ record_reg_saved_in_reg()

static void record_reg_saved_in_reg ( rtx dest,
rtx src )
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, FOR_EACH_VEC_ELT, i, NULL, reg_saved_in_data::orig_reg, dw_trace_info::regs_saved_in_regs, and reg_saved_in_data::saved_in_reg.

Referenced by dwarf2out_flush_queued_reg_saves(), dwarf2out_frame_debug_cfa_register(), and initial_return_save().

◆ reg_save()

◆ reg_saved_in()

◆ save_point_p()

static bool save_point_p ( rtx_insn * insn)
static

◆ scan_insn_after()

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

References dwarf2out_frame_debug(), notice_args_size(), and RTX_FRAME_RELATED_P.

Referenced by scan_trace().

◆ scan_trace()

◆ update_row_reg_save()

static void update_row_reg_save ( dw_cfi_row * row,
unsigned column,
dw_cfi_ref cfi )
static
Perform ROW->REG_SAVE[COLUMN] = CFI.  CFI may be null, indicating
that the register column is no longer saved.   

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

Referenced by dwarf2out_frame_debug_cfa_expression(), dwarf2out_frame_debug_cfa_restore(), dwarf2out_frame_debug_cfa_val_expression(), and reg_save().

Variable Documentation

◆ add_cfi_insn

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

Referenced by add_cfi(), connect_traces(), dwarf2cfi_cc_finalize(), and scan_trace().

◆ add_cfi_vec

cfi_vec* add_cfi_vec
static
When non-null, add_cfi will add the CFI to this vector.   

Referenced by add_cfi(), create_cie_data(), and dwarf2cfi_cc_finalize().

◆ any_cfis_emitted

bool any_cfis_emitted
static
True if any CFI directives were emitted at the current insn.   

Referenced by add_cfi(), and scan_trace().

◆ cie_cfi_row

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.   

Referenced by connect_traces(), create_cie_data(), and create_pseudo_cfg().

◆ cie_cfi_vec

cfi_vec cie_cfi_vec
A vector of call frame insns for the CIE.   

Referenced by convert_cfa_to_fb_loc_list(), create_cie_data(), execute_dwarf2_frame(), and output_call_frame_info().

◆ cie_return_save

reg_saved_in_data* cie_return_save
static

◆ cur_cfa

◆ cur_row

◆ cur_trace

◆ dw_frame_pointer_regnum

struct cfa_reg dw_frame_pointer_regnum
static

◆ dw_stack_pointer_regnum

struct cfa_reg dw_stack_pointer_regnum
static
Short-hand for commonly used register numbers.   

Referenced by create_cie_data(), dwarf2out_frame_debug_expr(), maybe_record_trace_start_abnormal(), and notice_args_size().

◆ dwarf2out_cfi_label_num

unsigned long dwarf2out_cfi_label_num
static

◆ queued_reg_saves

◆ saved_do_cfi_asm

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.   

Referenced by dwarf2out_do_cfi_asm(), and dwarf2out_do_frame().

◆ trace_index

◆ trace_info

vec<dw_trace_info> trace_info
static
The variables making up the pseudo-cfg, as described above.   

Referenced by connect_traces(), create_cfi_notes(), create_pseudo_cfg(), and execute_dwarf2_frame().

◆ trace_work_list

vec<dw_trace_info *> trace_work_list
static