GCC Middle and Back End API Reference
cselib.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "regs.h"
#include "emit-rtl.h"
#include "dumpfile.h"
#include "cselib.h"
#include "function-abi.h"
#include "alias.h"
#include "gt-cselib.h"
Include dependency graph for cselib.cc:

Data Structures

struct  elt_list
 
struct  expand_value_data
 
struct  cselib_hasher
 
struct  cselib_hasher::key
 
struct  cselib_record_autoinc_data
 

Macros

#define PRESERVED_VALUE_P(RTX)    (RTL_FLAG_CHECK1 ("PRESERVED_VALUE_P", (RTX), VALUE)->unchanging)
 
#define SP_BASED_VALUE_P(RTX)    (RTL_FLAG_CHECK1 ("SP_BASED_VALUE_P", (RTX), VALUE)->jump)
 
#define SP_DERIVED_VALUE_P(RTX)    (RTL_FLAG_CHECK1 ("SP_DERIVED_VALUE_P", (RTX), VALUE)->call)
 
#define MAX_USELESS_VALUES   32
 
#define REG_VALUES(i)   reg_values[i]
 
#define MAX_SETS   (FIRST_PSEUDO_REGISTER * 2)
 

Functions

static void promote_debug_loc (struct elt_loc_list *l)
 
static struct elt_listnew_elt_list (struct elt_list *, cselib_val *)
 
static void new_elt_loc_list (cselib_val *, rtx)
 
static void unchain_one_value (cselib_val *)
 
static void unchain_one_elt_list (struct elt_list **)
 
static void unchain_one_elt_loc_list (struct elt_loc_list **)
 
static void remove_useless_values (void)
 
static unsigned int cselib_hash_rtx (rtx, int, machine_mode)
 
static cselib_valnew_cselib_val (unsigned int, machine_mode, rtx)
 
static void add_mem_for_addr (cselib_val *, cselib_val *, rtx)
 
static cselib_valcselib_lookup_mem (rtx, int)
 
static void cselib_invalidate_regno (unsigned int, machine_mode)
 
static void cselib_invalidate_mem (rtx)
 
static void cselib_record_set (rtx, cselib_val *, cselib_val *)
 
static void cselib_record_sets (rtx_insn *)
 
static rtx autoinc_split (rtx, rtx *, machine_mode)
 
static rtx cselib_expand_value_rtx_1 (rtx, struct expand_value_data *, int)
 
void cselib_clear_table (void)
 
static bool invariant_or_equiv_p (cselib_val *v)
 
int preserve_constants_and_equivs (cselib_val **x, void *info)
 
void cselib_reset_table (unsigned int num)
 
unsigned int cselib_get_next_uid (void)
 
static cselib_val ** cselib_find_slot (machine_mode mode, rtx x, hashval_t hash, enum insert_option insert, machine_mode memmode)
 
bool references_value_p (const_rtx x, int only_useless)
 
static bool cselib_useless_value_p (cselib_val *v)
 
int discard_useless_locs (cselib_val **x, void *info)
 
int discard_useless_values (cselib_val **x, void *info)
 
void cselib_preserve_value (cselib_val *v)
 
bool cselib_preserved_value_p (cselib_val *v)
 
void cselib_preserve_cfa_base_value (cselib_val *v, unsigned int regno)
 
void cselib_preserve_only_values (void)
 
void cselib_set_value_sp_based (cselib_val *v)
 
bool cselib_sp_based_value_p (cselib_val *v)
 
machine_mode cselib_reg_set_mode (const_rtx x)
 
bool rtx_equal_for_cselib_1 (rtx x, rtx y, machine_mode memmode, int depth)
 
bool cselib_redundant_set_p (rtx set)
 
static unsigned int cselib_hash_plus_const_int (rtx x, HOST_WIDE_INT c, int create, machine_mode memmode)
 
static rtx expand_loc (struct elt_loc_list *p, struct expand_value_data *evd, int max_depth)
 
rtx cselib_expand_value_rtx (rtx orig, bitmap regs_active, int max_depth)
 
rtx cselib_expand_value_rtx_cb (rtx orig, bitmap regs_active, int max_depth, cselib_expand_callback cb, void *data)
 
bool cselib_dummy_expand_value_rtx_cb (rtx orig, bitmap regs_active, int max_depth, cselib_expand_callback cb, void *data)
 
rtx cselib_subst_to_values (rtx x, machine_mode memmode)
 
rtx cselib_subst_to_values_from_insn (rtx x, machine_mode memmode, rtx_insn *insn)
 
static cselib_valcselib_lookup_1 (rtx x, machine_mode mode, int create, machine_mode memmode)
 
cselib_valcselib_lookup_from_insn (rtx x, machine_mode mode, int create, machine_mode memmode, rtx_insn *insn)
 
cselib_valcselib_lookup (rtx x, machine_mode mode, int create, machine_mode memmode)
 
static void cselib_invalidate_regno_val (unsigned int regno, struct elt_list **l)
 
void cselib_invalidate_rtx (rtx dest)
 
static void cselib_invalidate_rtx_note_stores (rtx dest, const_rtx, void *data)
 
void cselib_add_permanent_equiv (cselib_val *elt, rtx x, rtx_insn *insn)
 
bool cselib_have_permanent_equivalences (void)
 
void cselib_record_sp_cfa_base_equiv (HOST_WIDE_INT offset, rtx_insn *insn)
 
bool cselib_sp_derived_value_p (cselib_val *v)
 
static int cselib_record_autoinc_cb (rtx mem, rtx op, rtx dest, rtx src, rtx srcoff, void *arg)
 
bool fp_setter_insn (rtx_insn *insn)
 
static bool cselib_invalidated_by_call_p (const function_abi &callee_abi, unsigned int regno, cselib_val *v)
 
void cselib_process_insn (rtx_insn *insn)
 
void cselib_init (int record_what)
 
void cselib_finish (void)
 
int dump_cselib_val (cselib_val **x, FILE *out)
 
void dump_cselib_table (FILE *out)
 

Variables

static bool cselib_record_memory
 
static bool cselib_preserve_constants
 
static bool cselib_any_perm_equivs
 
static rtx_insncselib_current_insn
 
static hash_table< cselib_hasher > * cselib_hash_table
 
static hash_table< cselib_hasher > * cselib_preserved_hash_table
 
static unsigned int next_uid
 
static unsigned int cselib_nregs
 
static int n_useless_values
 
static int n_useless_debug_values
 
static int n_debug_values
 
static struct elt_list ** reg_values
 
static unsigned int reg_values_size
 
static unsigned int max_value_regs
 
static unsigned int * used_regs
 
static unsigned int n_used_regs
 
static rtx callmem
 
static int values_became_useless
 
static cselib_val dummy_val
 
static cselib_valcfa_base_preserved_val
 
static unsigned int cfa_base_preserved_regno = INVALID_REGNUM
 
static cselib_valfirst_containing_mem = &dummy_val
 
static object_allocator< elt_listelt_list_pool ("elt_list")
 
static object_allocator< elt_loc_listelt_loc_list_pool ("elt_loc_list")
 
static object_allocator< cselib_valcselib_val_pool ("cselib_val_list")
 
static pool_allocator value_pool ("value", RTX_CODE_SIZE(VALUE))
 
void(* cselib_discard_hook )(cselib_val *)
 
void(* cselib_record_sets_hook )(rtx_insn *insn, struct cselib_set *sets, int n_sets)
 

Macro Definition Documentation

◆ MAX_SETS

#define MAX_SETS   (FIRST_PSEUDO_REGISTER * 2)
There is no good way to determine how many elements there can be
in a PARALLEL.  Since it's fairly cheap, use a really large number.   

Referenced by cselib_record_sets().

◆ MAX_USELESS_VALUES

#define MAX_USELESS_VALUES   32
Number of useless values before we remove them from the hash table.   

Referenced by cselib_process_insn().

◆ PRESERVED_VALUE_P

◆ REG_VALUES

◆ SP_BASED_VALUE_P

#define SP_BASED_VALUE_P ( RTX)     (RTL_FLAG_CHECK1 ("SP_BASED_VALUE_P", (RTX), VALUE)->jump)

◆ SP_DERIVED_VALUE_P

Function Documentation

◆ add_mem_for_addr()

static void add_mem_for_addr ( cselib_val * addr_elt,
cselib_val * mem_elt,
rtx x )
static
ADDR_ELT is a value that is used as address.  MEM_ELT is the value that
contains the data at this address.  X is a MEM that represents the
value.  Update the two value structures to represent this situation.   

References canonical_cselib_val(), CSELIB_VAL_PTR, first_containing_mem, ggc_alloc(), MEM_ADDR_SPACE, MEM_P, new_elt_list(), new_elt_loc_list(), NULL, promote_debug_loc(), replace_equiv_address_nv(), and XEXP.

Referenced by cselib_lookup_mem(), and cselib_record_set().

◆ autoinc_split()

static rtx autoinc_split ( rtx x,
rtx * off,
machine_mode memmode )
static
If x is a PLUS or an autoinc operation, expand the operation,
storing the offset, if any, in *OFF.   

References const0_rtx, CONST_INT_P, cselib_lookup(), CSELIB_VAL_PTR, gen_int_mode(), GET_CODE, GET_MODE, GET_MODE_SIZE(), ggc_alloc(), INTVAL, cselib_val::locs, MEM_P, NULL_RTX, plus_constant(), REG_P, SP_DERIVED_VALUE_P, cselib_val::val_rtx, and XEXP.

Referenced by cselib_hasher::equal(), and rtx_equal_for_cselib_1().

◆ cselib_add_permanent_equiv()

◆ cselib_clear_table()

void cselib_clear_table ( void )
Remove all entries from the hash table.  Also used during
initialization.   

References cselib_reset_table().

Referenced by cselib_finish(), dse_step1(), and local_cprop_pass().

◆ cselib_dummy_expand_value_rtx_cb()

bool cselib_dummy_expand_value_rtx_cb ( rtx orig,
bitmap regs_active,
int max_depth,
cselib_expand_callback cb,
void * data )
Similar to cselib_expand_value_rtx_cb, but no rtxs are actually copied
or simplified.  Useful to find out whether cselib_expand_value_rtx_cb
would return NULL or non-NULL, without allocating new rtx.   

References cselib_expand_value_rtx_1(), ggc_alloc(), NULL, and expand_value_data::regs_active.

◆ cselib_expand_value_rtx()

rtx cselib_expand_value_rtx ( rtx orig,
bitmap regs_active,
int max_depth )
Forward substitute and expand an expression out to its roots.
This is the opposite of common subexpression.  Because local value
numbering is such a weak optimization, the expanded expression is
pretty much unique (not from a pointer equals point of view but
from a tree shape point of view.

This function returns NULL if the expansion fails.  The expansion
will fail if there is no value number for one of the operands or if
one of the operands has been overwritten between the current insn
and the beginning of the basic block.  For instance x has no
expansion in:

r1 <- r1 + 3
x <- r1 + 8

REGS_ACTIVE is a scratch bitmap that should be clear when passing in.
It is clear on return.   

References cselib_expand_value_rtx_1(), ggc_alloc(), NULL, and expand_value_data::regs_active.

Referenced by canon_address(), get_call_args(), record_store(), and reverse_op().

◆ cselib_expand_value_rtx_1()

◆ cselib_expand_value_rtx_cb()

rtx cselib_expand_value_rtx_cb ( rtx orig,
bitmap regs_active,
int max_depth,
cselib_expand_callback cb,
void * data )
Same as cselib_expand_value_rtx, but using a callback to try to
resolve some expressions.  The CB function should return ORIG if it
can't or does not want to deal with a certain RTX.  Any other
return value, including NULL, will be used as the expansion for
VALUE, without any further changes.   

References cselib_expand_value_rtx_1(), ggc_alloc(), and expand_value_data::regs_active.

Referenced by vt_expand_loc(), vt_expand_loc_callback(), and vt_expand_var_loc_chain().

◆ cselib_find_slot()

static cselib_val ** cselib_find_slot ( machine_mode mode,
rtx x,
hashval_t hash,
enum insert_option insert,
machine_mode memmode )
static
Search for X, whose hashcode is HASH, in CSELIB_HASH_TABLE,
INSERTing if requested.  When X is part of the address of a MEM,
MEMMODE should specify the mode of the MEM.   

References cselib_hash_table, cselib_preserve_constants, cselib_preserved_hash_table, ggc_alloc(), insert(), lookup(), and NULL.

Referenced by cselib_lookup_1(), and cselib_lookup_mem().

◆ cselib_finish()

◆ cselib_get_next_uid()

unsigned int cselib_get_next_uid ( void )
Return the number of the next value that will be generated.   

References next_uid.

Referenced by vt_emit_notes(), and vt_initialize().

◆ cselib_hash_plus_const_int()

static unsigned int cselib_hash_plus_const_int ( rtx x,
HOST_WIDE_INT c,
int create,
machine_mode memmode )
static
Helper function for cselib_hash_rtx.  Arguments like for cselib_hash_rtx,
except that it hashes (plus:P x c).   

References CONST_INT_P, cselib_lookup(), CSELIB_VAL_PTR, GET_CODE, GET_MODE, ggc_alloc(), cselib_val::hash, cselib_val::locs, SP_DERIVED_VALUE_P, trunc_int_for_mode(), UINTVAL, cselib_val::val_rtx, and XEXP.

Referenced by cselib_hash_rtx().

◆ cselib_hash_rtx()

static unsigned int cselib_hash_rtx ( rtx x,
int create,
machine_mode memmode )
static
Hash an rtx.  Return 0 if we couldn't hash the rtx.
For registers and memory locations, we look up their cselib_val structure
and return its VALUE element.
Possible reasons for return 0 are: the object is volatile, or we couldn't
find a register or memory location in the table and CREATE is zero.  If
CREATE is nonzero, table elts are created for regs and mem.
N.B. this hash function returns the same hash value for RTXes that
differ only in the order of operands, thus it is suitable for comparisons
that take commutativity into account.
If we wanted to also support associative rules, we'd have to use a different
strategy to avoid returning spurious 0, e.g. return ~(~0U >> 1) .
MEMMODE indicates the mode of an enclosing MEM, and it's only
used to compute autoinc values.
We used to have a MODE argument for hashing for CONST_INTs, but that
didn't make sense, since it caused spurious hash differences between
 (set (reg:SI 1) (const_int))
 (plus:SI (reg:SI 2) (reg:SI 1))
and
 (plus:SI (reg:SI 2) (const_int))
If the mode is important in any context, it must be checked specifically
in a comparison anyway, since relying on hash differences is unsafe.   

References CODE_LABEL_NUMBER, CONST_DOUBLE_HIGH, CONST_DOUBLE_LOW, CONST_DOUBLE_REAL_VALUE, CONST_FIXED_VALUE, CONST_INT_P, CONST_POLY_INT_COEFFS, CONST_VECTOR_ENCODED_ELT, const_vector_encoded_nelts(), CONST_WIDE_INT_ELT, CONST_WIDE_INT_NUNITS, cselib_hash_plus_const_int(), cselib_hash_rtx(), cselib_lookup(), CSELIB_VAL_PTR, DEBUG_EXPR_TREE_DECL, DEBUG_IMPLICIT_PTR_DECL, DEBUG_PARAMETER_REF_DECL, DEBUG_TEMP_UID, DECL_UID, ENTRY_VALUE_EXP, fixed_hash(), gcc_assert, gcc_unreachable, gen_int_mode(), GET_CODE, GET_MODE, GET_MODE_SIZE(), GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), cselib_val::hash, i, INTVAL, label_ref_label(), MEM_P, MEM_VOLATILE_P, NUM_POLY_INT_COEFFS, offset, real_hash(), REG_P, REGNO, SUBREG_BYTE, TARGET_SUPPORTS_WIDE_INT, trunc_int_for_mode(), UINTVAL, XEXP, XINT, XSTR, XVECEXP, and XVECLEN.

Referenced by cselib_hash_rtx(), and cselib_lookup_1().

◆ cselib_have_permanent_equivalences()

bool cselib_have_permanent_equivalences ( void )
Return TRUE if any permanent equivalences have been recorded since
the table was last initialized.   

References cselib_any_perm_equivs.

Referenced by get_addr().

◆ cselib_init()

◆ cselib_invalidate_mem()

◆ cselib_invalidate_regno()

static void cselib_invalidate_regno ( unsigned int regno,
machine_mode mode )
static
Invalidate any entries in reg_values that overlap REGNO.  This is called
if REGNO is changing.  MODE is the mode of the assignment to REGNO, which
is used to determine how many hard registers are being changed.  If MODE
is VOIDmode, then only REGNO is being changed; this is used when
invalidating call clobbered registers across a call.   

References cfa_base_preserved_regno, cfa_base_preserved_val, cselib_invalidate_regno_val(), end_hard_regno(), gcc_assert, GET_MODE, ggc_alloc(), i, max_value_regs, elt_list::next, NULL, reg_renumber, REG_VALUES, reload_completed, and cselib_val::val_rtx.

Referenced by cselib_invalidate_rtx(), and cselib_preserve_only_values().

◆ cselib_invalidate_regno_val()

◆ cselib_invalidate_rtx()

◆ cselib_invalidate_rtx_note_stores()

static void cselib_invalidate_rtx_note_stores ( rtx dest,
const_rtx ,
void * data )
static
A wrapper for cselib_invalidate_rtx to be called via note_stores.   

References cselib_invalidate_rtx().

Referenced by cselib_record_sets().

◆ cselib_invalidated_by_call_p()

static bool cselib_invalidated_by_call_p ( const function_abi & callee_abi,
unsigned int regno,
cselib_val * v )
static
V is one of the values in REG_VALUES (REGNO).  Return true if it
would be invalidated by CALLEE_ABI.   

References GET_MODE, ggc_alloc(), REG_VALUES, and cselib_val::val_rtx.

Referenced by cselib_process_insn().

◆ cselib_lookup()

◆ cselib_lookup_1()

static cselib_val * cselib_lookup_1 ( rtx x,
machine_mode mode,
int create,
machine_mode memmode )
static
Look up the rtl expression X in our tables and return the value it
has.  If CREATE is zero, we return NULL if we don't know the value.
Otherwise, we create a new one if possible, using mode MODE if X
doesn't have a mode (i.e. because it's a constant).  When X is part
of an address, MEMMODE should be the mode of the enclosing MEM if
we're tracking autoinc expressions.   

References cselib_find_slot(), cselib_hash_rtx(), cselib_lookup_mem(), cselib_preserve_constants, cselib_subst_to_values(), CSELIB_VAL_PTR, elt_list::elt, GET_CODE, GET_MODE, GET_MODE_SIZE(), ggc_alloc(), hard_regno_nregs(), cselib_val::hash, i, is_int_mode(), cselib_val::locs, lowpart_subreg(), max_value_regs, MEM_P, n_used_regs, new_cselib_val(), new_elt_list(), new_elt_loc_list(), elt_list::next, elt_loc_list::next, el::next, next_uid, NULL, partial_subreg_p(), PRESERVED_VALUE_P, promote_debug_loc(), REG_P, REG_VALUES, REGNO, SP_DERIVED_VALUE_P, stack_pointer_rtx, used_regs, and cselib_val::val_rtx.

Referenced by cselib_lookup().

◆ cselib_lookup_from_insn()

cselib_val * cselib_lookup_from_insn ( rtx x,
machine_mode mode,
int create,
machine_mode memmode,
rtx_insn * insn )
Wrapper for cselib_lookup, that indicates X is in INSN.   

References cselib_current_insn, cselib_lookup(), gcc_assert, ggc_alloc(), and NULL.

Referenced by cselib_record_sp_cfa_base_equiv(), vt_add_function_parameter(), vt_init_cfa_base(), and vt_initialize().

◆ cselib_lookup_mem()

static cselib_val * cselib_lookup_mem ( rtx x,
int create )
static
Subroutine of cselib_lookup.  Return a value for X, which is a MEM rtx.
If CREATE, make a new one if we haven't seen it before.   

References add_mem_for_addr(), cselib_val::addr_list, canonical_cselib_val(), cselib_find_slot(), cselib_lookup(), cselib_record_memory, FLOAT_MODE_P, GET_MODE, ggc_alloc(), MEM_ADDR_SPACE, MEM_P, MEM_VOLATILE_P, new_cselib_val(), next_uid, promote_debug_loc(), and XEXP.

Referenced by cselib_lookup_1(), and cselib_subst_to_values().

◆ cselib_preserve_cfa_base_value()

void cselib_preserve_cfa_base_value ( cselib_val * v,
unsigned int regno )
Arrange for a REG value to be assumed constant through the whole function,
never invalidated and preserved across cselib_reset_table calls.   

References cfa_base_preserved_regno, cfa_base_preserved_val, cselib_preserve_constants, elt_loc_list::loc, cselib_val::locs, and REG_P.

Referenced by vt_init_cfa_base(), and vt_initialize().

◆ cselib_preserve_only_values()

void cselib_preserve_only_values ( void )
Clean all non-constant expressions in the hash table, but retain
their values.   

References callmem, cselib_invalidate_mem(), cselib_invalidate_regno(), dummy_val, first_containing_mem, gcc_assert, ggc_alloc(), i, reg_raw_mode, and remove_useless_values().

Referenced by cselib_process_insn(), and vt_initialize().

◆ cselib_preserve_value()

void cselib_preserve_value ( cselib_val * v)
Arrange for a value to not be removed from the hash table even if
it becomes useless.   

References PRESERVED_VALUE_P, and cselib_val::val_rtx.

Referenced by cselib_add_permanent_equiv(), cselib_record_sets(), preserve_value(), and variable_post_merge_new_vals().

◆ cselib_preserved_value_p()

bool cselib_preserved_value_p ( cselib_val * v)

◆ cselib_process_insn()

◆ cselib_record_autoinc_cb()

static int cselib_record_autoinc_cb ( rtx mem,
rtx op,
rtx dest,
rtx src,
rtx srcoff,
void * arg )
static
Callback for for_each_inc_dec.  Records in ARG the SETs implied by
autoinc RTXs: SRC plus SRCOFF if non-NULL is stored in DEST.   

References GET_MODE, and ggc_alloc().

Referenced by cselib_record_sets().

◆ cselib_record_set()

static void cselib_record_set ( rtx dest,
cselib_val * src_elt,
cselib_val * dest_addr_elt )
static
Record the result of a SET instruction.  DEST is being set; the source
contains the value described by SRC_ELT.  If DEST is a MEM, DEST_ADDR_ELT
describes its address.   

References add_mem_for_addr(), cselib_record_memory, cselib_useless_value_p(), elt_list::elt, gcc_assert, ggc_alloc(), max_value_regs, MEM_P, n_used_regs, n_useless_values, new_elt_list(), new_elt_loc_list(), REG_NREGS, REG_P, REG_VALUES, REGNO, side_effects_p(), and used_regs.

Referenced by cselib_record_sets(), and cselib_record_sp_cfa_base_equiv().

◆ cselib_record_sets()

◆ cselib_record_sp_cfa_base_equiv()

void cselib_record_sp_cfa_base_equiv ( HOST_WIDE_INT offset,
rtx_insn * insn )
Record stack_pointer_rtx to be equal to
(plus:P cfa_base_preserved_val offset).  Used by var-tracking
at the start of basic blocks for !frame_pointer_needed functions.   

References cfa_base_preserved_val, CONST_INT_P, cselib_lookup_from_insn(), cselib_record_set(), GET_CODE, ggc_alloc(), cselib_val::locs, NULL, NULL_RTX, offset, plus_constant(), PRESERVED_VALUE_P, SP_DERIVED_VALUE_P, stack_pointer_rtx, UINTVAL, cselib_val::val_rtx, and XEXP.

Referenced by vt_initialize().

◆ cselib_redundant_set_p()

bool cselib_redundant_set_p ( rtx set)
Wrapper for rtx_equal_for_cselib_p to determine whether a SET is
truly redundant, taking into account aliasing information.   

References cselib_lookup(), cselib_reg_set_mode(), gcc_assert, GET_CODE, GET_MODE, ggc_alloc(), MEM_P, mems_same_for_tbaa_p(), rtx_equal_for_cselib_1(), rtx_equal_for_cselib_p(), SET, SET_DEST, SET_SRC, and XEXP.

Referenced by mark_effect(), and reload_cse_simplify().

◆ cselib_reg_set_mode()

machine_mode cselib_reg_set_mode ( const_rtx x)
Return the mode in which a register was last set.  If X is not a
register, return its mode.  If the mode in which the register was
set is not known, or the value was already clobbered, return
VOIDmode.   

References GET_MODE, ggc_alloc(), NULL, REG_P, REG_VALUES, and REGNO.

Referenced by cselib_redundant_set_p().

◆ cselib_reset_table()

◆ cselib_set_value_sp_based()

void cselib_set_value_sp_based ( cselib_val * v)
Arrange for a value to be marked as based on stack pointer
for find_base_term purposes.   

References SP_BASED_VALUE_P, and cselib_val::val_rtx.

Referenced by add_stores(), and vt_initialize().

◆ cselib_sp_based_value_p()

bool cselib_sp_based_value_p ( cselib_val * v)
Test whether a value is based on stack pointer for
find_base_term purposes.   

References SP_BASED_VALUE_P, and cselib_val::val_rtx.

Referenced by find_base_term().

◆ cselib_sp_derived_value_p()

bool cselib_sp_derived_value_p ( cselib_val * v)
Return true if V is SP_DERIVED_VALUE_P (or SP_DERIVED_VALUE_P + CONST_INT)
that can be expressed using cfa_base_preserved_val + CONST_INT.   

References cfa_base_preserved_val, CONST_INT_P, CSELIB_VAL_PTR, GET_CODE, ggc_alloc(), cselib_val::locs, SP_DERIVED_VALUE_P, cselib_val::val_rtx, and XEXP.

Referenced by add_stores().

◆ cselib_subst_to_values()

rtx cselib_subst_to_values ( rtx x,
machine_mode memmode )
Walk rtx X and replace all occurrences of REG and MEM subexpressions
with VALUE expressions.  This way, it becomes independent of changes
to registers and memory.
X isn't actually modified; if modifications are needed, new rtl is
allocated.  However, the return value can share rtl with X.
If X is within a MEM, MEMMODE must be the mode of the MEM.   

References CASE_CONST_ANY, const0_rtx, CONST_INT_P, cselib_lookup(), cselib_lookup_mem(), cselib_subst_to_values(), CSELIB_VAL_PTR, elt_list::elt, gcc_assert, gcc_unreachable, GET_CODE, GET_MODE, GET_MODE_SIZE(), GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, INTVAL, new_cselib_val(), elt_list::next, next_uid, NULL, offset, plus_constant(), REG_VALUES, REGNO, shallow_copy_rtvec(), shallow_copy_rtx(), SP_DERIVED_VALUE_P, cselib_val::val_rtx, XEXP, XVEC, XVECEXP, and XVECLEN.

Referenced by cselib_lookup_1(), cselib_subst_to_values(), cselib_subst_to_values_from_insn(), and replace_expr_with_values().

◆ cselib_subst_to_values_from_insn()

rtx cselib_subst_to_values_from_insn ( rtx x,
machine_mode memmode,
rtx_insn * insn )
Wrapper for cselib_subst_to_values, that indicates X is in INSN.   

References cselib_current_insn, cselib_subst_to_values(), gcc_assert, ggc_alloc(), and NULL.

◆ cselib_useless_value_p()

static bool cselib_useless_value_p ( cselib_val * v)
static

◆ discard_useless_locs()

int discard_useless_locs ( cselib_val ** x,
void * info )
For all locations found in X, delete locations that reference useless
values (i.e. values without any location).  Called through
htab_traverse.   

References cselib_useless_value_p(), DEBUG_INSN_P, ggc_alloc(), cselib_val::locs, n_useless_debug_values, n_useless_values, elt_loc_list::next, NULL, references_value_p(), elt_loc_list::setting_insn, unchain_one_elt_loc_list(), and values_became_useless.

Referenced by remove_useless_values().

◆ discard_useless_values()

int discard_useless_values ( cselib_val ** x,
void * info )
If X is a value with no locations, remove it from the hashtable.   

References cselib_discard_hook, cselib_hash_table, cselib_useless_value_p(), CSELIB_VAL_PTR, cselib_val::locs, n_useless_values, NULL, unchain_one_value(), and cselib_val::val_rtx.

Referenced by remove_useless_values().

◆ dump_cselib_table()

void dump_cselib_table ( FILE * out)

◆ dump_cselib_val()

◆ expand_loc()

static rtx expand_loc ( struct elt_loc_list * p,
struct expand_value_data * evd,
int max_depth )
static
Search through the possible substitutions in P.  We prefer a non reg
substitution because this allows us to expand the tree further.  If
we find, just a reg, take the lowest regno.  There may be several
non-reg results, we just take the first one because they will all
expand to the same place.   

References bitmap_bit_p, cfa_base_preserved_regno, cselib_expand_value_rtx_1(), CSELIB_VAL_PTR, dump_file, dump_flags, find_reg_note(), GET_CODE, ggc_alloc(), HARD_FRAME_POINTER_REGNUM, elt_loc_list::loc, elt_loc_list::next, NULL, NULL_RTX, print_inline_rtx(), REG_P, REGNO, elt_loc_list::setting_insn, TDF_CSELIB, UINT_MAX, and XEXP.

Referenced by cselib_expand_value_rtx_1().

◆ fp_setter_insn()

bool fp_setter_insn ( rtx_insn * insn)
Return true if INSN in the prologue initializes hard_frame_pointer_rtx.   

References expr, find_reg_note(), ggc_alloc(), hard_frame_pointer_rtx, modified_in_p(), NULL_RTX, RTX_FRAME_RELATED_P, and XEXP.

Referenced by cselib_process_insn(), and vt_initialize().

◆ invariant_or_equiv_p()

static bool invariant_or_equiv_p ( cselib_val * v)
static

◆ new_cselib_val()

◆ new_elt_list()

static struct elt_list * new_elt_list ( struct elt_list * next,
cselib_val * elt )
inlinestatic
Allocate a struct elt_list and fill in its two elements with the
arguments.   

References elt_list::elt, elt_list_pool, elt_list::next, and el::next.

Referenced by add_mem_for_addr(), cselib_lookup_1(), and cselib_record_set().

◆ new_elt_loc_list()

◆ preserve_constants_and_equivs()

int preserve_constants_and_equivs ( cselib_val ** x,
void * info )
Remove from hash table all VALUEs except constants, function
invariants and VALUE equivalences.   

References cselib_hash_table, cselib_preserved_hash_table, gcc_assert, GET_MODE, ggc_alloc(), cselib_val::hash, invariant_or_equiv_p(), lookup(), and cselib_val::val_rtx.

Referenced by cselib_reset_table().

◆ promote_debug_loc()

static void promote_debug_loc ( struct elt_loc_list * l)
inlinestatic
Promote loc L to a nondebug cselib_current_insn if L is marked as
originating from a debug insn, maintaining the debug values
count.   

References cselib_current_insn, cselib_preserve_constants, DEBUG_INSN_P, gcc_assert, n_debug_values, elt_loc_list::next, and elt_loc_list::setting_insn.

Referenced by add_mem_for_addr(), cselib_lookup_1(), cselib_lookup_mem(), and cselib_hasher::equal().

◆ references_value_p()

bool references_value_p ( const_rtx x,
int only_useless )
Return true if X contains a VALUE rtx.  If ONLY_USELESS is set, we
only return true for values which point to a cselib_val whose value
element has been set to zero, which implies the cselib_val will be
removed.   

References CSELIB_VAL_PTR, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, PRESERVED_VALUE_P, references_value_p(), XEXP, XVECEXP, and XVECLEN.

Referenced by discard_useless_locs(), invariant_or_equiv_p(), references_value_p(), reload_cse_simplify_set(), and reverse_op().

◆ remove_useless_values()

◆ rtx_equal_for_cselib_1()

bool rtx_equal_for_cselib_1 ( rtx x,
rtx y,
machine_mode memmode,
int depth )
Return true if we can prove that X and Y contain the same value,
taking our gathered information into account.  MEMMODE holds the
mode of the enclosing MEM, if any, as required to deal with autoinc
addressing modes.  If X and Y are not (known to be) part of
addresses, MEMMODE should be VOIDmode.   

References autoinc_split(), canonical_cselib_val(), CASE_CONST_UNIQUE, CONST_INT_P, cselib_lookup(), CSELIB_VAL_PTR, DEBUG_IMPLICIT_PTR_DECL, DEBUG_PARAMETER_REF_DECL, ENTRY_VALUE_EXP, gcc_unreachable, GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, label_ref_label(), elt_loc_list::loc, cselib_val::locs, MEM_P, elt_loc_list::next, NULL, NULL_RTX, REG_P, REGNO, rtx_equal_for_cselib_1(), rtx_equal_p(), same_vector_encodings_p(), SP_DERIVED_VALUE_P, SUBREG_BYTE, targetm, cselib_val::val_rtx, XEXP, XINT, XSTR, XVECEXP, XVECLEN, XWINT, and y.

Referenced by cselib_redundant_set_p(), cselib_hasher::equal(), rtx_equal_for_cselib_1(), and rtx_equal_for_cselib_p().

◆ unchain_one_elt_list()

static void unchain_one_elt_list ( struct elt_list ** pl)
inlinestatic
The elt_list at *PL is no longer needed.  Unchain it and free its
storage.   

References elt_list_pool, ggc_alloc(), and elt_list::next.

Referenced by cselib_invalidate_mem(), cselib_invalidate_regno_val(), and unchain_one_value().

◆ unchain_one_elt_loc_list()

static void unchain_one_elt_loc_list ( struct elt_loc_list ** pl)
static

◆ unchain_one_value()

static void unchain_one_value ( cselib_val * v)
static
Likewise for cselib_vals.  This also frees the addr_list associated with
V.   

References cselib_val::addr_list, cselib_val_pool, and unchain_one_elt_list().

Referenced by discard_useless_values().

Variable Documentation

◆ callmem

rtx callmem
static
We pass this to cselib_invalidate_mem to invalidate all of
memory for a non-const call instruction.   

Referenced by cselib_init(), cselib_preserve_only_values(), and cselib_process_insn().

◆ cfa_base_preserved_regno

◆ cfa_base_preserved_val

cselib_val* cfa_base_preserved_val
static
If non-NULL, value of the eliminated arg_pointer_rtx or frame_pointer_rtx
that is constant through the whole function and should never be
eliminated.   

Referenced by cselib_finish(), cselib_invalidate_regno(), cselib_preserve_cfa_base_value(), cselib_record_sp_cfa_base_equiv(), cselib_reset_table(), cselib_sp_derived_value_p(), and invariant_or_equiv_p().

◆ cselib_any_perm_equivs

◆ cselib_current_insn

rtx_insn* cselib_current_insn
static
This is a global so we don't have to pass this through every function.
It is used in new_elt_loc_list to set SETTING_INSN.   

Referenced by cselib_add_permanent_equiv(), cselib_lookup_from_insn(), cselib_process_insn(), cselib_reset_table(), cselib_subst_to_values_from_insn(), cselib_hasher::equal(), new_cselib_val(), new_elt_loc_list(), and promote_debug_loc().

◆ cselib_discard_hook

void(* cselib_discard_hook) (cselib_val *) ( cselib_val * )
If nonnull, cselib will call this function before freeing useless
VALUEs.  A VALUE is deemed useless if its "locs" field is null.   

Referenced by cselib_finish(), discard_useless_values(), and dse_step1().

◆ cselib_hash_table

◆ cselib_nregs

unsigned int cselib_nregs
static
The number of registers we had when the varrays were last resized.   

Referenced by cselib_init().

◆ cselib_preserve_constants

◆ cselib_preserved_hash_table

hash_table<cselib_hasher>* cselib_preserved_hash_table
static

◆ cselib_record_memory

bool cselib_record_memory
static

◆ cselib_record_sets_hook

void(* cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets, int n_sets) ( rtx_insn * insn,
struct cselib_set * sets,
int n_sets )
If nonnull, cselib will call this function before recording sets or
even clobbering outputs of INSN.  All the recorded sets will be
represented in the array sets[n_sets].  new_val_min can be used to
tell whether values present in sets are introduced by this
instruction.   

Referenced by cselib_record_sets(), and vt_initialize().

◆ cselib_val_pool

object_allocator< cselib_val > cselib_val_pool("cselib_val_list") ( "cselib_val_list" )
static

◆ dummy_val

cselib_val dummy_val
static
Used as stop element of the containing_mem list so we can check
presence in the list by checking the next pointer.   

Referenced by cselib_invalidate_mem(), cselib_preserve_only_values(), cselib_reset_table(), dump_cselib_table(), dump_cselib_val(), and remove_useless_values().

◆ elt_list_pool

object_allocator< elt_list > elt_list_pool("elt_list") ( "elt_list" )
static

◆ elt_loc_list_pool

object_allocator< elt_loc_list > elt_loc_list_pool("elt_loc_list") ( "elt_loc_list" )
static

◆ first_containing_mem

cselib_val* first_containing_mem = &dummy_val
static
Used to list all values that contain memory reference.
May or may not contain the useless values - the list is compacted
each time memory is invalidated.   

Referenced by add_mem_for_addr(), cselib_invalidate_mem(), cselib_preserve_only_values(), cselib_reset_table(), dump_cselib_table(), and remove_useless_values().

◆ max_value_regs

unsigned int max_value_regs
static
The largest number of hard regs used by any entry added to the
REG_VALUES table.  Cleared on each cselib_clear_table() invocation.   

Referenced by cselib_invalidate_regno(), cselib_lookup_1(), cselib_record_set(), cselib_reset_table(), and kill_value_regno().

◆ n_debug_values

int n_debug_values
static
Count values whose locs have been taken exclusively from debug
insns for the entire life of the value.   

Referenced by cselib_finish(), cselib_process_insn(), cselib_reset_table(), new_elt_loc_list(), promote_debug_loc(), and remove_useless_values().

◆ n_used_regs

◆ n_useless_debug_values

◆ n_useless_values

int n_useless_values
static
Count values without known locations, or with only locations that
wouldn't have been known except for debug insns.  Whenever this
grows too big, we remove these useless values from the table.

Counting values with only debug values is a bit tricky.  We don't
want to increment n_useless_values when we create a value for a
debug insn, for this would get n_useless_values out of sync, but we
want increment it if all locs in the list that were ever referenced
in nondebug insns are removed from the list.

In the general case, once we do that, we'd have to stop accepting
nondebug expressions in the loc list, to avoid having two values
equivalent that, without debug insns, would have been made into
separate values.  However, because debug insns never introduce
equivalences themselves (no assignments), the only means for
growing loc lists is through nondebug assignments.  If the locs
also happen to be referenced in debug insns, it will work just fine.

A consequence of this is that there's at most one debug-only loc in
each loc list.  If we keep it in the first entry, testing whether
we have a debug-only loc list takes O(1).

Furthermore, since any additional entry in a loc list containing a
debug loc would have to come from an assignment (nondebug) that
references both the initial debug loc and the newly-equivalent loc,
the initial debug loc would be promoted to a nondebug loc, and the
loc list would not contain debug locs any more.

So the only case we have to be careful with in order to keep
n_useless_values in sync between debug and nondebug compilations is
to avoid incrementing n_useless_values when removing the single loc
from a value that turns out to not appear outside debug values.  We
increment n_useless_debug_values instead, and leave such values
alone until, for other reasons, we garbage-collect useless
values.   

Referenced by cselib_finish(), cselib_invalidate_mem(), cselib_invalidate_regno_val(), cselib_process_insn(), cselib_record_set(), cselib_reset_table(), discard_useless_locs(), discard_useless_values(), and remove_useless_values().

◆ next_uid

◆ reg_values

struct elt_list** reg_values
static
This table maps from register number to values.  It does not
contain pointers to cselib_val structures, but rather elt_lists.
The purpose is to be able to refer to the same register in
different modes.  The first element of the list defines the mode in
which the register was set; if the mode is unknown or the value is
no longer valid in that mode, ELT will be NULL for the first
element.   

Referenced by cselib_init().

◆ reg_values_size

unsigned int reg_values_size
static

Referenced by cselib_init().

◆ used_regs

unsigned int* used_regs
static
Here the set of indices I with REG_VALUES(I) != 0 is saved.  This is used
in cselib_clear_table() for fast emptying.   

Referenced by cselib_finish(), cselib_init(), cselib_lookup_1(), cselib_record_set(), cselib_reset_table(), reload_combine(), and setup_save_areas().

◆ value_pool

pool_allocator value_pool("value", RTX_CODE_SIZE(VALUE)) ( "value" ,
RTX_CODE_SIZE(VALUE)  )
static

Referenced by cselib_finish(), and new_cselib_val().

◆ values_became_useless

int values_became_useless
static
Set by discard_useless_locs if it deleted the last location of any
value.   

Referenced by discard_useless_locs(), and remove_useless_values().