GCC Middle and Back End API Reference
alias.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 "gimple.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "gimple-ssa.h"
#include "emit-rtl.h"
#include "alias.h"
#include "fold-const.h"
#include "varasm.h"
#include "cselib.h"
#include "langhooks.h"
#include "cfganal.h"
#include "rtl-iter.h"
#include "cgraph.h"
#include "ipa-utils.h"
#include "gt-alias.h"
Include dependency graph for alias.cc:

Data Structures

struct  alias_set_hash
 
struct  alias_set_entry
 

Macros

#define SIZE_FOR_MODE(X)
 
#define MAX_ALIAS_LOOP_PASSES   10
 
#define UNIQUE_BASE_VALUE_SP   -1
 
#define UNIQUE_BASE_VALUE_ARGP   -2
 
#define UNIQUE_BASE_VALUE_FP   -3
 
#define UNIQUE_BASE_VALUE_HFP   -4
 
#define static_reg_base_value    (this_target_rtl->x_static_reg_base_value)
 
#define REG_BASE_VALUE(X)
 

Functions

static int compare_base_symbol_refs (const_rtx, const_rtx, HOST_WIDE_INT *=NULL)
 
static bool ao_ref_from_mem (ao_ref *ref, const_rtx mem)
 
static bool rtx_refs_may_alias_p (const_rtx x, const_rtx mem, bool tbaa_p)
 
bool refs_same_for_tbaa_p (tree earlier, tree later)
 
bool mems_same_for_tbaa_p (rtx earlier, rtx later)
 
static alias_set_entryget_alias_set_entry (alias_set_type alias_set)
 
static bool mems_in_disjoint_alias_sets_p (const_rtx mem1, const_rtx mem2)
 
bool alias_set_subset_of (alias_set_type set1, alias_set_type set2)
 
bool alias_sets_conflict_p (alias_set_type set1, alias_set_type set2)
 
bool alias_sets_must_conflict_p (alias_set_type set1, alias_set_type set2)
 
bool objects_must_conflict_p (tree t1, tree t2)
 
bool ends_tbaa_access_path_p (const_tree t)
 
tree component_uses_parent_alias_set_from (const_tree t)
 
static bool ref_all_alias_ptr_type_p (const_tree t)
 
static alias_set_type get_deref_alias_set_1 (tree t)
 
alias_set_type get_deref_alias_set (tree t)
 
tree reference_alias_ptr_type_1 (tree *t)
 
tree reference_alias_ptr_type (tree t)
 
bool alias_ptr_types_compatible_p (tree t1, tree t2)
 
alias_set_entryinit_alias_set_entry (alias_set_type set)
 
alias_set_type get_alias_set (tree t)
 
alias_set_type new_alias_set (void)
 
void record_alias_subset (alias_set_type superset, alias_set_type subset)
 
void record_component_aliases (tree type, alias_set_type superset)
 
void record_component_aliases (tree type)
 
alias_set_type get_varargs_alias_set (void)
 
alias_set_type get_frame_alias_set (void)
 
static rtx unique_base_value (HOST_WIDE_INT id)
 
static bool unique_base_value_p (rtx x)
 
static rtx find_base_value (rtx src)
 
static void record_set (rtx dest, const_rtx set, void *data)
 
rtx get_reg_base_value (unsigned int regno)
 
rtx get_reg_known_value (unsigned int regno)
 
static void set_reg_known_value (unsigned int regno, rtx val)
 
bool get_reg_known_equiv_p (unsigned int regno)
 
static void set_reg_known_equiv_p (unsigned int regno, bool val)
 
rtx canon_rtx (rtx x)
 
static bool rtx_equal_for_memref_p (const_rtx x, const_rtx y)
 
static rtx find_base_term (rtx x, vec< std::pair< cselib_val *, struct elt_loc_list * > > &visited_vals)
 
static rtx find_base_term (rtx x)
 
bool may_be_sp_based_p (rtx x)
 
int compare_base_decls (tree base1, tree base2)
 
static bool base_alias_check (rtx x, rtx x_base, rtx y, rtx y_base, machine_mode x_mode, machine_mode y_mode)
 
static bool refs_newer_value_p (const_rtx expr, rtx v)
 
rtx get_addr (rtx x)
 
static rtx addr_side_effect_eval (rtx addr, poly_int64 size, int n_refs)
 
static bool offset_overlap_p (poly_int64 c, poly_int64 xsize, poly_int64 ysize)
 
static int memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y, poly_int64 c)
 
bool read_dependence (const_rtx mem, const_rtx x)
 
static tree decl_for_component_ref (tree x)
 
static void adjust_offset_for_component_ref (tree x, bool *known_p, poly_int64 *offset)
 
bool nonoverlapping_memrefs_p (const_rtx x, const_rtx y, bool loop_invariant)
 
static bool true_dependence_1 (const_rtx mem, machine_mode mem_mode, rtx mem_addr, const_rtx x, rtx x_addr, bool mem_canonicalized)
 
bool true_dependence (const_rtx mem, machine_mode mem_mode, const_rtx x)
 
bool canon_true_dependence (const_rtx mem, machine_mode mem_mode, rtx mem_addr, const_rtx x, rtx x_addr)
 
static bool write_dependence_p (const_rtx mem, const_rtx x, machine_mode x_mode, rtx x_addr, bool mem_canonicalized, bool x_canonicalized, bool writep)
 
bool anti_dependence (const_rtx mem, const_rtx x)
 
bool canon_anti_dependence (const_rtx mem, bool mem_canonicalized, const_rtx x, machine_mode x_mode, rtx x_addr)
 
bool output_dependence (const_rtx mem, const_rtx x)
 
bool canon_output_dependence (const_rtx mem, bool mem_canonicalized, const_rtx x, machine_mode x_mode, rtx x_addr)
 
bool may_alias_p (const_rtx mem, const_rtx x)
 
void init_alias_target (void)
 
static void memory_modified_1 (rtx x, const_rtx pat, void *data)
 
bool memory_modified_in_insn_p (const_rtx mem, const_rtx insn)
 
void init_alias_analysis (void)
 
void vt_equate_reg_base_value (const_rtx reg1, const_rtx reg2)
 
void end_alias_analysis (void)
 
void dump_alias_stats_in_alias_c (FILE *s)
 

Variables

struct { 
 
   unsigned long long   num_alias_zero 
 
   unsigned long long   num_same_alias_set 
 
   unsigned long long   num_same_objects 
 
   unsigned long long   num_volatile 
 
   unsigned long long   num_dag 
 
   unsigned long long   num_universal 
 
   unsigned long long   num_disambiguated 
 
alias_stats 
 
static vec< rtx, va_gc > * reg_base_value
 
static rtxnew_reg_base_value
 
static rtx arg_base_value
 
static int unique_id
 
static vec< rtx, va_gc > * old_reg_base_value
 
static vec< rtx, va_gc > * reg_known_value
 
static sbitmap reg_known_equiv_p
 
static bool copying_arguments
 
static vec< alias_set_entry *, va_gc > * alias_sets
 
static alias_set_type varargs_set = -1
 
static alias_set_type frame_set = -1
 
static sbitmap reg_seen
 
static bool memory_modified
 

Macro Definition Documentation

◆ MAX_ALIAS_LOOP_PASSES

#define MAX_ALIAS_LOOP_PASSES   10
Cap the number of passes we make over the insns propagating alias
information through set chains.
??? 10 is a completely arbitrary choice.  This should be based on the
maximum loop depth in the CFG, but we do not have this information
available (even if current_loops _is_ available).   

Referenced by init_alias_analysis().

◆ REG_BASE_VALUE

#define REG_BASE_VALUE ( X)
Value:
? (*reg_base_value)[REGNO (X)] : 0)
static vec< rtx, va_gc > * reg_base_value
Definition alias.cc:213
#define REGNO(RTX)
Definition rtl.h:1914
unsigned vec_safe_length(const vec< T, A, vl_embed > *v)
Definition vec.h:685

Referenced by find_base_term(), and vt_equate_reg_base_value().

◆ SIZE_FOR_MODE

#define SIZE_FOR_MODE ( X)
Value:
ALWAYS_INLINE poly_uint16 GET_MODE_SIZE(machine_mode mode)
Definition machmode.h:647
#define GET_MODE(RTX)
Definition rtl.h:728
Set up all info needed to perform alias analysis on memory references.   
Returns the size in bytes of the mode of X.   

Referenced by true_dependence_1(), and write_dependence_p().

◆ static_reg_base_value

#define static_reg_base_value    (this_target_rtl->x_static_reg_base_value)

◆ UNIQUE_BASE_VALUE_ARGP

#define UNIQUE_BASE_VALUE_ARGP   -2

Referenced by init_alias_target().

◆ UNIQUE_BASE_VALUE_FP

#define UNIQUE_BASE_VALUE_FP   -3

Referenced by init_alias_target().

◆ UNIQUE_BASE_VALUE_HFP

#define UNIQUE_BASE_VALUE_HFP   -4

Referenced by init_alias_target().

◆ UNIQUE_BASE_VALUE_SP

#define UNIQUE_BASE_VALUE_SP   -1
Values of XINT (address, 0) of Pmode ADDRESS rtxes for special
registers.   

Referenced by init_alias_target().

Function Documentation

◆ addr_side_effect_eval()

static rtx addr_side_effect_eval ( rtx addr,
poly_int64 size,
int n_refs )
static
Return the address of the (N_REFS + 1)th memory reference to ADDR
where SIZE is the size in bytes of the memory reference.  If ADDR
is not modified by the memory reference then ADDR is returned.   

References canon_rtx(), GET_CODE, GET_MODE, offset, plus_constant(), and XEXP.

Referenced by memrefs_conflict_p().

◆ adjust_offset_for_component_ref()

static void adjust_offset_for_component_ref ( tree x,
bool * known_p,
poly_int64 * offset )
static
Walk up the COMPONENT_REF list in X and adjust *OFFSET to compensate
for the offset of the field reference.  *KNOWN_P says whether the
offset is known.   

References component_ref_field_offset(), DECL_FIELD_BIT_OFFSET, offset, poly_int_tree_p(), wi::to_offset(), wi::to_poly_offset(), poly_int< N, C >::to_shwi(), TREE_CODE, and TREE_OPERAND.

Referenced by nonoverlapping_memrefs_p().

◆ alias_ptr_types_compatible_p()

bool alias_ptr_types_compatible_p ( tree t1,
tree t2 )
Return whether the pointer-types T1 and T2 used to determine
two alias sets of two references will yield the same answer
from get_deref_alias_set.   

References get_deref_alias_set(), ref_all_alias_ptr_type_p(), TREE_TYPE, and TYPE_MAIN_VARIANT.

Referenced by ao_compare::compare_ao_refs(), and operand_compare::operand_equal_p().

◆ alias_set_subset_of()

◆ alias_sets_conflict_p()

◆ alias_sets_must_conflict_p()

bool alias_sets_must_conflict_p ( alias_set_type set1,
alias_set_type set2 )
Return true if the two specified alias sets will always conflict.   

References alias_stats.

Referenced by alias_sets_conflict_p(), and objects_must_conflict_p().

◆ anti_dependence()

bool anti_dependence ( const_rtx mem,
const_rtx x )
Anti dependence: X is written after read in MEM takes place.   

References NULL_RTX, and write_dependence_p().

Referenced by load_kills_store(), memory_modified_1(), and validate_equiv_mem_from_store().

◆ ao_ref_from_mem()

static bool ao_ref_from_mem ( ao_ref * ref,
const_rtx mem )
static
Build a decomposed reference object for querying the alias-oracle
from the MEM rtx and store it in *REF.
Returns false if MEM is not suitable for the alias-oracle.   

References ao_ref_base(), ao_ref_init(), DECL_P, DECL_SIZE, get_spill_slot_decl(), maybe_gt, MEM_ALIAS_SET, MEM_EXPR, MEM_OFFSET, MEM_OFFSET_KNOWN_P, MEM_SIZE, MEM_SIZE_KNOWN_P, NULL_TREE, poly_int_tree_p(), TMR_BASE, wi::to_poly_offset(), TREE_CODE, and TREE_OPERAND.

Referenced by rtx_refs_may_alias_p().

◆ base_alias_check()

static bool base_alias_check ( rtx x,
rtx x_base,
rtx y,
rtx y_base,
machine_mode x_mode,
machine_mode y_mode )
static
Return false if the addresses X and Y are known to point to different
objects, true if they might be pointers to the same object.   

References canon_rtx(), compare_base_symbol_refs(), CONST_INT_P, find_base_term(), GET_CODE, GET_MODE_UNIT_SIZE, INTVAL, rtx_equal_p(), unique_base_value_p(), XEXP, and y.

Referenced by may_alias_p(), true_dependence_1(), and write_dependence_p().

◆ canon_anti_dependence()

bool canon_anti_dependence ( const_rtx mem,
bool mem_canonicalized,
const_rtx x,
machine_mode x_mode,
rtx x_addr )
Likewise, but we already have a canonicalized MEM, and X_ADDR for X.
Also, consider X in X_MODE (which might be from an enclosing
STRICT_LOW_PART / ZERO_EXTRACT).
If MEM_CANONICALIZED is true, MEM is canonicalized.   

References write_dependence_p().

Referenced by check_dependence(), and cselib_invalidate_mem().

◆ canon_output_dependence()

bool canon_output_dependence ( const_rtx mem,
bool mem_canonicalized,
const_rtx x,
machine_mode x_mode,
rtx x_addr )
Likewise, but we already have a canonicalized MEM, and X_ADDR for X.
Also, consider X in X_MODE (which might be from an enclosing
STRICT_LOW_PART / ZERO_EXTRACT).
If MEM_CANONICALIZED is true, MEM is canonicalized.   

References write_dependence_p().

Referenced by record_store().

◆ canon_rtx()

rtx canon_rtx ( rtx x)
Returns a canonical version of X, from the point of view alias
analysis.  (For example, if X is a MEM whose address is a register,
and the register has a known value (say a SYMBOL_REF), then a MEM
whose address is the SYMBOL_REF is returned.)   

References canon_rtx(), GET_CODE, GET_MODE, get_reg_known_value(), MEM_P, REG_P, REGNO, replace_equiv_address_nv(), simplify_gen_binary(), and XEXP.

Referenced by addr_side_effect_eval(), base_alias_check(), canon_address(), canon_list_insert(), canon_rtx(), clobber_overlapping_mems(), compute_transp(), cselib_invalidate_mem(), get_addr_from_global_cache(), get_group_info(), invalidate(), memrefs_conflict_p(), record_store(), rtx_equal_for_memref_p(), true_dependence_1(), vt_canonicalize_addr(), and write_dependence_p().

◆ canon_true_dependence()

bool canon_true_dependence ( const_rtx mem,
machine_mode mem_mode,
rtx mem_addr,
const_rtx x,
rtx x_addr )
Canonical true dependence: X is read after store in MEM takes place.
Variant of true_dependence which assumes MEM has already been
canonicalized (hence we no longer do that here).
The mem_addr argument has been added, since true_dependence_1 computed
this value prior to canonicalizing.   

References true_dependence_1().

Referenced by check_mem_read_rtx(), compute_transp(), scan_reads(), and vt_canon_true_dep().

◆ compare_base_decls()

int compare_base_decls ( tree base1,
tree base2 )
BASE1 and BASE2 are decls.  Return 1 if they refer to same object, 0
if they refer to different objects and -1 if we cannot decide.   

References DECL_ASSEMBLER_NAME_RAW, DECL_ASSEMBLER_NAME_SET_P, DECL_HARD_REGISTER, decl_in_symtab_p(), DECL_P, symtab_node::equal_address_to(), gcc_checking_assert, symtab_node::get(), and VAR_P.

Referenced by compare_base_symbol_refs(), decl_refs_may_alias_p(), nonoverlapping_memrefs_p(), and ptr_deref_may_alias_decl_p().

◆ compare_base_symbol_refs()

static int compare_base_symbol_refs ( const_rtx x_base,
const_rtx y_base,
HOST_WIDE_INT * distance )
static
Compare SYMBOL_REFs X_BASE and Y_BASE.

- Return 1 if Y_BASE - X_BASE is constant, adding that constant
  to *DISTANCE if DISTANCE is nonnull.

- Return 0 if no accesses based on X_BASE can alias Y_BASE.

- Return -1 if one of the two results applies, but we can't tell
  which at compile time.  Update DISTANCE in the same way as
  for a return value of 1, for the case in which that holds.   

References compare_base_decls(), symtab_node::decl, decl_binds_to_current_def_p(), DECL_RTL, symtab_node::definition, symtab_node::get_create(), SYMBOL_REF_BLOCK, SYMBOL_REF_BLOCK_OFFSET, SYMBOL_REF_DECL, SYMBOL_REF_HAS_BLOCK_INFO_P, TREE_PUBLIC, TREE_STATIC, symtab_node::ultimate_alias_target(), VAR_P, XEXP, and XSTR.

Referenced by base_alias_check(), memrefs_conflict_p(), and rtx_equal_for_memref_p().

◆ component_uses_parent_alias_set_from()

tree component_uses_parent_alias_set_from ( const_tree t)
Return the outermost parent of component present in the chain of
component references handled by get_inner_reference in T with the
following property:
  - the component is non-addressable
or NULL_TREE if no such parent exists.  In the former cases, the alias
set of this parent is the alias set that must be used for T itself.   

References ends_tbaa_access_path_p(), handled_component_p(), NULL_TREE, and TREE_OPERAND.

Referenced by reference_alias_ptr_type_1(), and set_mem_attributes_minus_bitpos().

◆ decl_for_component_ref()

static tree decl_for_component_ref ( tree x)
static
Look at the bottom of the COMPONENT_REF list for a DECL, and return it.   

References DECL_P, NULL_TREE, TREE_CODE, and TREE_OPERAND.

Referenced by nonoverlapping_memrefs_p().

◆ dump_alias_stats_in_alias_c()

void dump_alias_stats_in_alias_c ( FILE * s)

References alias_stats.

Referenced by dump_alias_stats().

◆ end_alias_analysis()

◆ ends_tbaa_access_path_p()

bool ends_tbaa_access_path_p ( const_tree t)

◆ find_base_term() [1/2]

static rtx find_base_term ( rtx x)
static
Wrapper around the worker above which removes locs from visited VALUEs
to avoid visiting them multiple times.  We unwind that changes here.   

References find_base_term(), and i.

◆ find_base_term() [2/2]

◆ find_base_value()

◆ get_addr()

◆ get_alias_set()

alias_set_type get_alias_set ( tree t)
Return the alias set for T, which may be either a type or an
expression.  Call language-specific routine for help, if needed.   

References AGGREGATE_TYPE_P, build_pointer_type(), build_reference_type(), canonical_type_used_p(), COMPLETE_TYPE_P, DECL_RTL, DECL_RTL_SET_P, error_mark_node, gcc_checking_assert, get_alias_set(), lang_hooks::get_alias_set, get_alias_set_entry(), get_deref_alias_set(), alias_set_entry::has_pointer, init_alias_set_entry(), alias_set_entry::is_pointer, MEM_ALIAS_SET, MEM_P, new_alias_set(), NULL, odr_type_p(), POINTER_TYPE_P, prevailing_odr_type(), ptr_type_node, record_component_aliases(), reference_alias_ptr_type_1(), STRIP_NOPS, TREE_CODE, TREE_TYPE, TYPE_ALIAS_SET, TYPE_ALIAS_SET_KNOWN_P, TYPE_CANONICAL, TYPE_MAIN_VARIANT, TYPE_NONALIASED_COMPONENT, TYPE_P, TYPE_STRUCTURAL_EQUALITY_P, TYPE_TYPELESS_STORAGE, type_with_alias_set_p(), and VAR_P.

Referenced by ao_ref_alias_set(), ao_ref_base_alias_set(), assign_stack_temp_for_type(), check_scan_store(), dr_may_alias_p(), dump_lto_records(), expand_assignment(), expand_builtin_va_copy(), get_alias_set(), get_deref_alias_set(), ipa_polymorphic_call_context::get_dynamic_type(), get_group_alias_ptr_type(), gimple_get_alias_set(), gimplify_init_constructor(), gimplify_init_ctor_preeval_1(), make_bit_field_ref(), objects_must_conflict_p(), record_component_aliases(), record_component_aliases(), safe_from_p(), same_type_for_tbaa(), set_mem_attributes_minus_bitpos(), store_constructor(), vect_analyze_data_ref_dependence(), vect_create_data_ref_ptr(), vectorizable_load(), and vectorizable_store().

◆ get_alias_set_entry()

static alias_set_entry * get_alias_set_entry ( alias_set_type alias_set)
inlinestatic
Returns a pointer to the alias set entry for ALIAS_SET, if there is
such an entry, or NULL otherwise.   

References alias_sets.

Referenced by alias_set_subset_of(), alias_sets_conflict_p(), get_alias_set(), init_alias_set_entry(), and record_alias_subset().

◆ get_deref_alias_set()

alias_set_type get_deref_alias_set ( tree t)
Return the alias set for the memory pointed to by T, which may be
either a type or an expression.   

References get_alias_set(), get_deref_alias_set_1(), TREE_TYPE, and TYPE_P.

Referenced by alias_ptr_types_compatible_p(), call_may_clobber_ref_p_1(), get_alias_set(), ipa_icf::sem_item_optimizer::read_section(), ref_maybe_used_by_call_p_1(), and vn_reference_lookup_3().

◆ get_deref_alias_set_1()

static alias_set_type get_deref_alias_set_1 ( tree t)
static
Return the alias set for the memory pointed to by T, which may be
either a type or an expression.  Return -1 if there is nothing
special about dereferencing T.   

References ref_all_alias_ptr_type_p(), TREE_TYPE, and TYPE_P.

Referenced by get_deref_alias_set().

◆ get_frame_alias_set()

alias_set_type get_frame_alias_set ( void )

◆ get_reg_base_value()

rtx get_reg_base_value ( unsigned int regno)
Return REG_BASE_VALUE for REGNO.  Selective scheduler uses this to avoid
using hard registers with non-null REG_BASE_VALUE for renaming.   

References reg_base_value.

◆ get_reg_known_equiv_p()

bool get_reg_known_equiv_p ( unsigned int regno)
Similarly for reg_known_equiv_p.   

References bitmap_bit_p, reg_known_equiv_p, reg_known_value, and vec_safe_length().

◆ get_reg_known_value()

rtx get_reg_known_value ( unsigned int regno)
If a value is known for REGNO, return it.   

References NULL, reg_known_value, and vec_safe_length().

Referenced by canon_rtx(), and init_alias_analysis().

◆ get_varargs_alias_set()

alias_set_type get_varargs_alias_set ( void )

References new_alias_set(), and varargs_set.

◆ init_alias_analysis()

◆ init_alias_set_entry()

◆ init_alias_target()

◆ may_alias_p()

bool may_alias_p ( const_rtx mem,
const_rtx x )
Check whether X may be aliased with MEM.  Don't do offset-based
memory disambiguation & TBAA.   

References ALIAS_SET_MEMORY_BARRIER, base_alias_check(), find_base_term(), get_addr(), GET_CODE, GET_MODE, MEM_ADDR_SPACE, MEM_ALIAS_SET, MEM_READONLY_P, MEM_VOLATILE_P, nonoverlapping_memrefs_p(), rtx_refs_may_alias_p(), and XEXP.

◆ may_be_sp_based_p()

bool may_be_sp_based_p ( rtx x)
Return true if accesses to address X may alias accesses based
on the stack pointer.   

References find_base_term(), and static_reg_base_value.

Referenced by record_store(), and store_killed_in_insn().

◆ memory_modified_1()

static void memory_modified_1 ( rtx x,
const_rtx pat,
void * data )
static

◆ memory_modified_in_insn_p()

bool memory_modified_in_insn_p ( const_rtx mem,
const_rtx insn )
Return true when INSN possibly modify memory contents of MEM
(i.e. address can be modified).   

References as_a(), CALL_P, CONST_CAST_RTX, INSN_P, memory_modified, memory_modified_1(), and note_stores().

Referenced by load_modified_by_store_p(), modified_between_p(), modified_in_p(), and store_modifies_mem_p().

◆ memrefs_conflict_p()

static int memrefs_conflict_p ( poly_int64 xsize,
rtx x,
poly_int64 ysize,
rtx y,
poly_int64 c )
static
Return one if X and Y (memory addresses) reference the
same location in memory or if the references overlap.
Return zero if they do not overlap, else return
minus one in which case they still might reference the same location.

C is an offset accumulator.  When
C is nonzero, we are testing aliases between X and Y + C.
XSIZE is the size in bytes of the X reference,
similarly YSIZE is the size in bytes for Y.
Expect that canon_rtx has been already called for X and Y.

If XSIZE or YSIZE is zero, we do not know the amount of memory being
referenced (the reference was BLKmode), so make the most pessimistic
assumptions.

If XSIZE or YSIZE is negative, we may access memory outside the object
being referenced as a side effect.  This can happen when using AND to
align memory references, as is done on the Alpha.

Nice to notice that varying addresses cannot conflict with fp if no
local variables had their addresses taken, but that's too hard now.

???  Contrary to the tree alias oracle this does not return
one for X + non-constant and Y + non-constant when X and Y are equal.
If that is fixed the TBAA hack for union type-punning can be removed.   

References addr_side_effect_eval(), canon_rtx(), canonical_cselib_val(), compare_base_symbol_refs(), const0_rtx, CONST_INT_P, CONSTANT_P, CSELIB_VAL_PTR, get_addr(), GET_CODE, INTVAL, elt_loc_list::loc, maybe_gt, memrefs_conflict_p(), elt_loc_list::next, NULL, offset_overlap_p(), poly_int_rtx_p(), pow2_or_zerop(), REG_P, rtx_equal_for_memref_p(), sc, uc, XEXP, and y.

Referenced by memrefs_conflict_p(), true_dependence_1(), and write_dependence_p().

◆ mems_in_disjoint_alias_sets_p()

static bool mems_in_disjoint_alias_sets_p ( const_rtx mem1,
const_rtx mem2 )
inlinestatic
Returns true if the alias sets for MEM1 and MEM2 are such that
the two MEMs cannot alias each other.   

References alias_sets_conflict_p(), and MEM_ALIAS_SET.

Referenced by true_dependence_1().

◆ mems_same_for_tbaa_p()

bool mems_same_for_tbaa_p ( rtx earlier,
rtx later )
Similar to refs_same_for_tbaa_p() but for use on MEM rtxs.   

References alias_set_subset_of(), gcc_assert, MEM_ALIAS_SET, MEM_EXPR, MEM_P, and refs_same_for_tbaa_p().

Referenced by cselib_redundant_set_p(), record_store(), and store_expr().

◆ new_alias_set()

◆ nonoverlapping_memrefs_p()

bool nonoverlapping_memrefs_p ( const_rtx x,
const_rtx y,
bool loop_invariant )

◆ objects_must_conflict_p()

bool objects_must_conflict_p ( tree t1,
tree t2 )
Return true if any MEM object of type T1 will always conflict (using the
dependency routines in this file) with any MEM object of type T2.
This is used when allocating temporary storage.  If T1 and/or T2 are
NULL_TREE, it means we know nothing about the storage.   

References alias_sets_must_conflict_p(), alias_stats, get_alias_set(), and TYPE_VOLATILE.

Referenced by assign_stack_temp_for_type().

◆ offset_overlap_p()

static bool offset_overlap_p ( poly_int64 c,
poly_int64 xsize,
poly_int64 ysize )
inlinestatic
Return TRUE if an object X sized at XSIZE bytes and another object
Y sized at YSIZE bytes, starting C bytes after X, may overlap.  If
any of the sizes is zero, assume an overlap, otherwise use the
absolute value of the sizes as the actual sizes.   

References known_eq, maybe_ge, and maybe_gt.

Referenced by memrefs_conflict_p(), and nonoverlapping_memrefs_p().

◆ output_dependence()

bool output_dependence ( const_rtx mem,
const_rtx x )
Output dependence: X is written after store in MEM takes place.   

References NULL_RTX, and write_dependence_p().

Referenced by memory_modified_1(), and store_killed_in_pat().

◆ read_dependence()

bool read_dependence ( const_rtx mem,
const_rtx x )
Functions to compute memory dependencies.

Since we process the insns in execution order, we can build tables
to keep track of what registers are fixed (and not aliased), what registers
are varying in known ways, and what registers are varying in unknown
ways.

If both memory references are volatile, then there must always be a
dependence between the two references, since their order cannot be
changed.  A volatile and non-volatile reference can be interchanged
though.

We also must allow AND addresses, because they may generate accesses
outside the object being referenced.  This is used to generate aligned
addresses from unaligned addresses, for instance, the alpha
storeqi_unaligned pattern.   
Read dependence: X is read after read in MEM takes place.  There can
only be a dependence here if both reads are volatile, or if either is
an explicit barrier.   

References ALIAS_SET_MEMORY_BARRIER, MEM_ALIAS_SET, and MEM_VOLATILE_P.

◆ record_alias_subset()

void record_alias_subset ( alias_set_type superset,
alias_set_type subset )
Indicate that things in SUBSET can alias things in SUPERSET, but that
not everything that aliases SUPERSET also aliases SUBSET.  For example,
in C, a store to an `int' can alias a load of a structure containing an
`int', and vice versa.  But it can't alias a load of a 'double' member
of the same structure.  Here, the structure would be the SUPERSET and
`int' the SUBSET.  This relationship is also described in the comment at
the beginning of this file.

This function should be called only once per SUPERSET/SUBSET pair.

It is illegal for SUPERSET to be zero; everything is implicitly a
subset of alias set zero.   

References hash_map< KeyId, Value, Traits >::begin(), alias_set_entry::children, hash_map< KeyId, Value, Traits >::create_ggc(), hash_map< KeyId, Value, Traits >::end(), gcc_assert, get_alias_set_entry(), alias_set_entry::has_pointer, alias_set_entry::has_zero_child, init_alias_set_entry(), and hash_map< KeyId, Value, Traits >::put().

Referenced by record_component_aliases().

◆ record_component_aliases() [1/2]

void record_component_aliases ( tree type)
Record that component types of TYPE, if any, are part of that type for
aliasing purposes.  For record types, we only record component types
for fields that are not marked non-addressable.  For array types, we
only record the component type if it is not marked non-aliased.   

References get_alias_set(), and record_component_aliases().

◆ record_component_aliases() [2/2]

void record_component_aliases ( tree type,
alias_set_type superset )
Record that component types of TYPE, if any, are part of SUPERSET for
aliasing purposes.  For record types, we only record component types
for fields that are not marked non-addressable.  For array types, we
only record the component type if it is not marked non-aliased.   

References canonical_type_used_p(), DECL_CHAIN, DECL_NONADDRESSABLE_P, gcc_checking_assert, get_alias_set(), odr_based_tbaa_p(), odr_type_p(), POINTER_TYPE_P, ptr_type_node, record_alias_subset(), record_component_aliases(), TREE_CODE, TREE_TYPE, TYPE_FIELDS, and TYPE_STRUCTURAL_EQUALITY_P.

Referenced by get_alias_set(), record_component_aliases(), and record_component_aliases().

◆ record_set()

◆ ref_all_alias_ptr_type_p()

static bool ref_all_alias_ptr_type_p ( const_tree t)
static
Return whether the pointer-type T effective for aliasing may
access everything and thus the reference has to be assigned
alias-set zero.   

References TREE_TYPE, TYPE_REF_CAN_ALIAS_ALL, and VOID_TYPE_P.

Referenced by alias_ptr_types_compatible_p(), get_deref_alias_set_1(), and reference_alias_ptr_type_1().

◆ reference_alias_ptr_type()

◆ reference_alias_ptr_type_1()

tree reference_alias_ptr_type_1 ( tree * t)
Return the pointer-type relevant for TBAA purposes from the
memory reference tree *T or NULL_TREE in which case *T is
adjusted to point to the outermost component reference that
can be used for assigning an alias set.   

References component_uses_parent_alias_set_from(), handled_component_p(), INDIRECT_REF_P, NULL_TREE, ref_all_alias_ptr_type_p(), TMR_OFFSET, TREE_CODE, TREE_OPERAND, TREE_TYPE, TYPE_MAIN_VARIANT, and view_converted_memref_p().

Referenced by get_alias_set(), and reference_alias_ptr_type().

◆ refs_newer_value_p()

static bool refs_newer_value_p ( const_rtx expr,
rtx v )
static
Return TRUE if EXPR refers to a VALUE whose uid is greater than
(or equal to) that of V.   

References CSELIB_VAL_PTR, FOR_EACH_SUBRTX, and GET_CODE.

Referenced by get_addr().

◆ refs_same_for_tbaa_p()

bool refs_same_for_tbaa_p ( tree earlier,
tree later )
Return true if the ref EARLIER behaves the same as LATER with respect
to TBAA for every memory reference that might follow LATER.   

References alias_set_subset_of(), ao_ref_alias_set(), ao_ref_base_alias_set(), and ao_ref_init().

Referenced by cse_insn(), mems_same_for_tbaa_p(), and dom_opt_dom_walker::optimize_stmt().

◆ rtx_equal_for_memref_p()

static bool rtx_equal_for_memref_p ( const_rtx x,
const_rtx y )
static
Return true if X and Y are identical-looking rtx's.
Expect that X and Y has been already canonicalized.

We use the data in reg_known_value above to see if two registers with
different numbers are, in fact, equivalent.   

References canon_rtx(), CASE_CONST_UNIQUE, COMMUTATIVE_P, compare_base_symbol_refs(), ENTRY_VALUE_EXP, gcc_unreachable, GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, label_ref_label(), NON_COMMUTATIVE_P, REGNO, rtx_equal_for_memref_p(), rtx_equal_p(), SUBREG_BYTE, UNARY_P, XEXP, XINT, XSTR, XVECEXP, XVECLEN, and y.

Referenced by memrefs_conflict_p(), and rtx_equal_for_memref_p().

◆ rtx_refs_may_alias_p()

static bool rtx_refs_may_alias_p ( const_rtx x,
const_rtx mem,
bool tbaa_p )
static
Query the alias-oracle on whether the two memory rtx X and MEM may
alias.  If TBAA_P is set also apply TBAA.  Returns true if the
two rtxen may alias, false otherwise.   

References ao_ref_from_mem(), MEM_ALIAS_SET, and refs_may_alias_p_1().

Referenced by may_alias_p(), true_dependence_1(), and write_dependence_p().

◆ set_reg_known_equiv_p()

static void set_reg_known_equiv_p ( unsigned int regno,
bool val )
static

◆ set_reg_known_value()

static void set_reg_known_value ( unsigned int regno,
rtx val )
static
Set it.   

References reg_known_value, and vec_safe_length().

Referenced by init_alias_analysis().

◆ true_dependence()

bool true_dependence ( const_rtx mem,
machine_mode mem_mode,
const_rtx x )
True dependence: X is read after store in MEM takes place.   

References NULL_RTX, and true_dependence_1().

Referenced by find_mem_conflicts(), load_kills_store(), memref_referenced_p(), mems_conflict_for_gcse_p(), and safe_from_p().

◆ true_dependence_1()

static bool true_dependence_1 ( const_rtx mem,
machine_mode mem_mode,
rtx mem_addr,
const_rtx x,
rtx x_addr,
bool mem_canonicalized )
static
Helper for true_dependence and canon_true_dependence.
Checks for true dependence: X is read after store in MEM takes place.

If MEM_CANONICALIZED is FALSE, then X_ADDR and MEM_ADDR should be
NULL_RTX, and the canonical addresses of MEM and X are both computed
here.  If MEM_CANONICALIZED, then MEM must be already canonicalized.

If X_ADDR is non-NULL, it is used in preference of XEXP (x, 0).

Returns true if there is a true dependence, false otherwise.   

References ALIAS_SET_MEMORY_BARRIER, base_alias_check(), canon_rtx(), CONSTANT_POOL_ADDRESS_P, find_base_term(), gcc_checking_assert, get_addr(), GET_CODE, GET_MODE, GET_MODE_SIZE(), MEM_ADDR_SPACE, MEM_ALIAS_SET, MEM_READONLY_P, MEM_VOLATILE_P, memrefs_conflict_p(), mems_in_disjoint_alias_sets_p(), nonoverlapping_memrefs_p(), NULL_RTX, rtx_refs_may_alias_p(), SIZE_FOR_MODE, and XEXP.

Referenced by canon_true_dependence(), and true_dependence().

◆ unique_base_value()

static rtx unique_base_value ( HOST_WIDE_INT id)
static
Create a new, unique base with id ID.   

Referenced by init_alias_target(), and record_set().

◆ unique_base_value_p()

static bool unique_base_value_p ( rtx x)
static
Return true if accesses based on any other base value cannot alias
those based on X.   

References GET_CODE, and GET_MODE.

Referenced by base_alias_check().

◆ vt_equate_reg_base_value()

void vt_equate_reg_base_value ( const_rtx reg1,
const_rtx reg2 )
Equate REG_BASE_VALUE (reg1) to REG_BASE_VALUE (reg2).
Special API for var-tracking pass purposes.   

References REG_BASE_VALUE, and REGNO.

Referenced by vt_init_cfa_base().

◆ write_dependence_p()

static bool write_dependence_p ( const_rtx mem,
const_rtx x,
machine_mode x_mode,
rtx x_addr,
bool mem_canonicalized,
bool x_canonicalized,
bool writep )
static
Returns true if a write to X might alias a previous read from
(or, if WRITEP is true, a write to) MEM.
If X_CANONCALIZED is true, then X_ADDR is the canonicalized address of X,
and X_MODE the mode for that access.
If MEM_CANONICALIZED is true, MEM is canonicalized.   

References ALIAS_SET_MEMORY_BARRIER, base_alias_check(), canon_rtx(), CONSTANT_POOL_ADDRESS_P, find_base_term(), gcc_checking_assert, get_addr(), GET_CODE, GET_MODE, GET_MODE_SIZE(), MEM_ADDR_SPACE, MEM_ALIAS_SET, MEM_READONLY_P, MEM_VOLATILE_P, memrefs_conflict_p(), nonoverlapping_memrefs_p(), NULL_RTX, rtx_refs_may_alias_p(), SIZE_FOR_MODE, and XEXP.

Referenced by anti_dependence(), canon_anti_dependence(), canon_output_dependence(), and output_dependence().

Variable Documentation

◆ alias_sets

vec<alias_set_entry *, va_gc>* alias_sets
static
The splay-tree used to store the various alias set entries.   

Referenced by get_alias_set_entry(), and new_alias_set().

◆ [struct]

struct { ... } alias_stats
Query statistics for the different low-level disambiguators.
A high-level query may trigger multiple of them.   

Referenced by alias_sets_conflict_p(), alias_sets_must_conflict_p(), dump_alias_stats_in_alias_c(), and objects_must_conflict_p().

◆ arg_base_value

rtx arg_base_value
static
The single VOIDmode ADDRESS that represents all argument bases.
It has id 0.   

Referenced by find_base_value(), and init_alias_target().

◆ copying_arguments

bool copying_arguments
static
True when scanning insns from the start of the rtl to the
NOTE_INSN_FUNCTION_BEG note.   

Referenced by find_base_value(), and init_alias_analysis().

◆ frame_set

alias_set_type frame_set = -1
static
Likewise, but used for the fixed portions of the frame, e.g., register
save areas.   

Referenced by get_frame_alias_set().

◆ memory_modified

bool memory_modified
static
Set MEMORY_MODIFIED when X modifies DATA (that is assumed
to be memory reference.   

Referenced by memory_modified_1(), and memory_modified_in_insn_p().

◆ new_reg_base_value

rtx* new_reg_base_value
static

◆ num_alias_zero

unsigned long long num_alias_zero

◆ num_dag

unsigned long long num_dag

◆ num_disambiguated

unsigned long long num_disambiguated

◆ num_same_alias_set

unsigned long long num_same_alias_set

◆ num_same_objects

unsigned long long num_same_objects

◆ num_universal

unsigned long long num_universal

◆ num_volatile

unsigned long long num_volatile

◆ old_reg_base_value

vec<rtx, va_gc>* old_reg_base_value
static
We preserve the copy of old array around to avoid amount of garbage
produced.  About 8% of garbage produced were attributed to this
array.   

Referenced by end_alias_analysis(), and init_alias_analysis().

◆ reg_base_value

vec<rtx, va_gc>* reg_base_value
static
reg_base_value[N] gives an address to which register N is related.
If all sets after the first add or subtract to the current value
or otherwise modify it so it does not point to a different top level
object, reg_base_value[N] is equal to the address part of the source
of the first set.

A base address can be an ADDRESS, SYMBOL_REF, or LABEL_REF.  ADDRESS
expressions represent three types of base:

  1. incoming arguments.  There is just one ADDRESS to represent all
     arguments, since we do not know at this level whether accesses
     based on different arguments can alias.  The ADDRESS has id 0.

  2. stack_pointer_rtx, frame_pointer_rtx, hard_frame_pointer_rtx
     (if distinct from frame_pointer_rtx) and arg_pointer_rtx.
     Each of these rtxes has a separate ADDRESS associated with it,
     each with a negative id.

     GCC is (and is required to be) precise in which register it
     chooses to access a particular region of stack.  We can therefore
     assume that accesses based on one of these rtxes do not alias
     accesses based on another of these rtxes.

  3. bases that are derived from malloc()ed memory (REG_NOALIAS).
     Each such piece of memory has a separate ADDRESS associated
     with it, each with an id greater than 0.

Accesses based on one ADDRESS do not alias accesses based on other
ADDRESSes.  Accesses based on ADDRESSes in groups (2) and (3) do not
alias globals either; the ADDRESSes have Pmode to indicate this.
The ADDRESS in group (1) _may_ alias globals; it has VOIDmode to
indicate this.   

Referenced by end_alias_analysis(), find_base_value(), get_reg_base_value(), and init_alias_analysis().

◆ reg_known_equiv_p

sbitmap reg_known_equiv_p
static
Vector recording for each reg_known_value whether it is due to a
REG_EQUIV note.  Future passes (viz., reload) may replace the
pseudo with the equivalent expression and so we account for the
dependences that would be introduced if that happens.

The REG_EQUIV notes created in assign_parms may mention the arg
pointer, and there are explicit insns in the RTL that modify the
arg pointer.  Thus we must ensure that such insns don't get
scheduled across each other because that would invalidate the
REG_EQUIV notes.  One could argue that the REG_EQUIV notes are
wrong, but solving the problem in the scheduler will likely give
better code, so we do it here.   

Referenced by end_alias_analysis(), get_reg_known_equiv_p(), init_alias_analysis(), and set_reg_known_equiv_p().

◆ reg_known_value

vec<rtx, va_gc>* reg_known_value
static
Vector indexed by N giving the initial (unchanging) value known for
pseudo-register N.  This vector is initialized in init_alias_analysis,
and does not change until end_alias_analysis is called.   

Referenced by end_alias_analysis(), get_reg_known_equiv_p(), get_reg_known_value(), init_alias_analysis(), set_reg_known_equiv_p(), and set_reg_known_value().

◆ reg_seen

sbitmap reg_seen
static
Called from init_alias_analysis indirectly through note_stores,
or directly if DEST is a register with a REG_NOALIAS note attached.
SET is null in the latter case.   
While scanning insns to find base values, reg_seen[N] is nonzero if
register N has been set in this function.   

Referenced by init_alias_analysis(), and record_set().

◆ unique_id

int unique_id
static
Used to allocate unique ids to each REG_NOALIAS ADDRESS.   

Referenced by init_alias_analysis(), and record_set().

◆ varargs_set

alias_set_type varargs_set = -1
static
Allocate an alias set for use in storing and reading from the varargs
spill area.   

Referenced by get_varargs_alias_set().