GCC Middle and Back End API Reference
tree-ssa-structalias.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "alloc-pool.h"
#include "tree-pass.h"
#include "ssa.h"
#include "cgraph.h"
#include "tree-pretty-print.h"
#include "diagnostic-core.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "stmt.h"
#include "gimple-iterator.h"
#include "tree-into-ssa.h"
#include "tree-dfa.h"
#include "gimple-walk.h"
#include "varasm.h"
#include "stringpool.h"
#include "attribs.h"
#include "tree-ssa.h"
#include "tree-cfg.h"
#include "gimple-range.h"
#include "ipa-modref-tree.h"
#include "ipa-modref.h"
#include "attr-fnspec.h"
Include dependency graph for tree-ssa-structalias.cc:

Data Structures

struct  constraint_stats
 
struct  variable_info
 
struct  constraint_expr
 
struct  constraint
 
struct  constraint_graph
 
class  scc_info
 
struct  equiv_class_label
 
struct  equiv_class_hasher
 
struct  fieldoff
 
struct  shared_bitmap_info
 
struct  shared_bitmap_hasher
 
struct  vls_data
 
struct  msdi_data
 

Macros

#define EXECUTE_IF_IN_NONNULL_BITMAP(a, b, c, d)
 
#define UNKNOWN_OFFSET   HOST_WIDE_INT_MIN
 
#define FIRST_REF_NODE   (varmap).length ()
 
#define LAST_REF_NODE   (FIRST_REF_NODE + (FIRST_REF_NODE - 1))
 

Typedefs

typedef struct constraint_graphconstraint_graph_t
 
typedef struct constraintconstraint_t
 
typedef struct variable_infovarinfo_t
 
typedef struct constraint_expr ce_s
 
typedef struct equiv_class_labelequiv_class_label_t
 
typedef const struct equiv_class_labelconst_equiv_class_label_t
 
typedef struct fieldoff fieldoff_s
 
typedef struct shared_bitmap_infoshared_bitmap_info_t
 
typedef const struct shared_bitmap_infoconst_shared_bitmap_info_t
 

Enumerations

enum  {
  nothing_id = 1 , anything_id = 2 , string_id = 3 , escaped_id = 4 ,
  nonlocal_id = 5 , escaped_return_id = 6 , storedanything_id = 7 , integer_id = 8
}
 
enum  constraint_expr_type { SCALAR , DEREF , ADDRESSOF }
 
enum  {
  fi_clobbers = 1 , fi_uses = 2 , fi_static_chain = 3 , fi_result = 4 ,
  fi_parm_base = 5
}
 

Functions

static unsigned int create_variable_info_for (tree, const char *, bool)
 
static void unify_nodes (constraint_graph_t, unsigned int, unsigned int, bool)
 
static varinfo_t first_vi_for_offset (varinfo_t, unsigned HOST_WIDE_INT)
 
static varinfo_t first_or_preceding_vi_for_offset (varinfo_t, unsigned HOST_WIDE_INT)
 
static varinfo_t lookup_vi_for_tree (tree)
 
static bool type_can_have_subvars (const_tree)
 
static void make_param_constraints (varinfo_t)
 
static varinfo_t get_varinfo (unsigned int n)
 
static varinfo_t vi_next (varinfo_t vi)
 
static varinfo_t new_var_info (tree t, const char *name, bool add_id)
 
static varinfo_t get_call_vi (gcall *call)
 
static varinfo_t lookup_call_use_vi (gcall *call)
 
static varinfo_t lookup_call_clobber_vi (gcall *call)
 
static varinfo_t get_call_use_vi (gcall *call)
 
static varinfo_t get_call_clobber_vi (gcall *call)
 
static void get_constraint_for_1 (tree, vec< ce_s > *, bool, bool)
 
static void get_constraint_for (tree, vec< ce_s > *)
 
static void get_constraint_for_rhs (tree, vec< ce_s > *)
 
static void do_deref (vec< ce_s > *)
 
static unsigned int find (unsigned int node)
 
static bool unite (unsigned int to, unsigned int from)
 
static constraint_t new_constraint (const struct constraint_expr lhs, const struct constraint_expr rhs)
 
static void dump_constraint (FILE *file, constraint_t c)
 
void debug_constraint (constraint_t)
 
void debug_constraints (void)
 
void debug_constraint_graph (void)
 
void debug_solution_for_var (unsigned int)
 
void debug_sa_points_to_info (void)
 
void debug_varinfo (varinfo_t)
 
void debug_varmap (void)
 
static void dump_constraints (FILE *file, int from)
 
static void dump_constraint_graph (FILE *file)
 
static bool constraint_expr_equal (struct constraint_expr a, struct constraint_expr b)
 
static bool constraint_expr_less (struct constraint_expr a, struct constraint_expr b)
 
static bool constraint_less (const constraint_t &a, const constraint_t &b)
 
static bool constraint_equal (struct constraint a, struct constraint b)
 
static constraint_t constraint_vec_find (vec< constraint_t > vec, struct constraint lookfor)
 
static bool constraint_set_union (vec< constraint_t > *to, vec< constraint_t > *from)
 
static bitmap solution_set_expand (bitmap set, bitmap *expanded)
 
static bool set_union_with_increment (bitmap to, bitmap delta, HOST_WIDE_INT inc, bitmap *expanded_delta)
 
static void insert_into_complex (constraint_graph_t graph, unsigned int var, constraint_t c)
 
static bool merge_node_constraints (constraint_graph_t graph, unsigned int to, unsigned int from)
 
static void clear_edges_for_node (constraint_graph_t graph, unsigned int node)
 
static void merge_graph_nodes (constraint_graph_t graph, unsigned int to, unsigned int from)
 
static void add_implicit_graph_edge (constraint_graph_t graph, unsigned int to, unsigned int from)
 
static void add_pred_graph_edge (constraint_graph_t graph, unsigned int to, unsigned int from)
 
static bool add_graph_edge (constraint_graph_t graph, unsigned int to, unsigned int from)
 
static void init_graph (unsigned int size)
 
static void build_pred_graph (void)
 
static void build_succ_graph (void)
 
static void scc_visit (constraint_graph_t graph, class scc_info *si, unsigned int n)
 
static bool solve_add_graph_edge (constraint_graph_t graph, unsigned int to, unsigned int from)
 
static void do_sd_constraint (constraint_graph_t graph, constraint_t c, bitmap delta, bitmap *expanded_delta)
 
static void do_ds_constraint (constraint_t c, bitmap delta, bitmap *expanded_delta)
 
static void do_complex_constraint (constraint_graph_t graph, constraint_t c, bitmap delta, bitmap *expanded_delta)
 
static void find_indirect_cycles (constraint_graph_t graph)
 
static void topo_visit (constraint_graph_t graph, vec< unsigned > &topo_order, sbitmap visited, unsigned int n)
 
static auto_vec< unsignedcompute_topo_order (constraint_graph_t graph)
 
static equiv_class_labelequiv_class_lookup_or_add (hash_table< equiv_class_hasher > *table, bitmap labels)
 
static void condense_visit (constraint_graph_t graph, class scc_info *si, unsigned int n)
 
static void label_visit (constraint_graph_t graph, class scc_info *si, unsigned int n)
 
static void dump_pred_graph (class scc_info *si, FILE *file)
 
static class scc_infoperform_var_substitution (constraint_graph_t graph)
 
static void free_var_substitution_info (class scc_info *si)
 
static unsigned int find_equivalent_node (constraint_graph_t graph, unsigned int node, unsigned int label)
 
static void unite_pointer_equivalences (constraint_graph_t graph)
 
static void move_complex_constraints (constraint_graph_t graph)
 
static void rewrite_constraints (constraint_graph_t graph, class scc_info *si)
 
static bool eliminate_indirect_cycles (unsigned int node)
 
static void solve_graph (constraint_graph_t graph)
 
static void insert_vi_for_tree (tree t, varinfo_t vi)
 
static const charalias_get_name (tree decl)
 
static varinfo_t get_vi_for_tree (tree t)
 
static struct constraint_expr new_scalar_tmp_constraint_exp (const char *name, bool add_id)
 
static void get_constraint_for_ssa_var (tree t, vec< ce_s > *results, bool address_p)
 
static void process_constraint (constraint_t t)
 
static HOST_WIDE_INT bitpos_of_field (const tree fdecl)
 
static void get_constraint_for_ptr_offset (tree ptr, tree offset, vec< ce_s > *results)
 
static void get_constraint_for_component_ref (tree t, vec< ce_s > *results, bool address_p, bool lhs_p)
 
static void get_constraint_for_address_of (tree t, vec< ce_s > *results)
 
static void process_all_all_constraints (const vec< ce_s > &lhsc, const vec< ce_s > &rhsc)
 
static void do_structure_copy (tree lhsop, tree rhsop)
 
static void make_constraints_to (unsigned id, const vec< ce_s > &rhsc)
 
static void make_constraint_to (unsigned id, tree op)
 
static void make_constraint_from (varinfo_t vi, int from)
 
static void make_copy_constraint (varinfo_t vi, int from)
 
static void make_escape_constraint (tree op)
 
static void make_indirect_escape_constraint (varinfo_t vi)
 
static void make_transitive_closure_constraints (varinfo_t vi)
 
static void make_any_offset_constraints (varinfo_t vi)
 
static tree build_fake_var_decl (tree type)
 
static varinfo_t make_heapvar (const char *name, bool add_id)
 
static varinfo_t make_constraint_from_restrict (varinfo_t lhs, const char *name, bool add_id)
 
static varinfo_t make_constraint_from_global_restrict (varinfo_t lhs, const char *name, bool add_id)
 
static struct constraint_expr get_function_part_constraint (varinfo_t fi, unsigned part)
 
static void handle_call_arg (gcall *stmt, tree arg, vec< ce_s > *results, int flags, int callescape_id, bool writes_global_memory)
 
static void determine_global_memory_access (gcall *stmt, bool *writes_global_memory, bool *reads_global_memory, bool *uses_global_memory)
 
static void handle_rhs_call (gcall *stmt, vec< ce_s > *results, int implicit_eaf_flags, bool writes_global_memory, bool reads_global_memory)
 
static void handle_lhs_call (gcall *stmt, tree lhs, int flags, vec< ce_s > &rhsc, tree fndecl)
 
static varinfo_t get_fi_for_callee (gcall *call)
 
static void find_func_aliases_for_call_arg (varinfo_t fi, unsigned index, tree arg)
 
static bool fndecl_maybe_in_other_partition (tree fndecl)
 
static bool find_func_aliases_for_builtin_call (struct function *fn, gcall *t)
 
static void find_func_aliases_for_call (struct function *fn, gcall *t)
 
static void find_func_aliases (struct function *fn, gimple *origt)
 
static void process_ipa_clobber (varinfo_t fi, tree ptr)
 
static void find_func_clobbers (struct function *fn, gimple *origt)
 
static int fieldoff_compare (const void *pa, const void *pb)
 
static void sort_fieldstack (vec< fieldoff_s > &fieldstack)
 
static bool var_can_have_subvars (const_tree v)
 
static bool type_must_have_pointers (tree type)
 
static bool field_must_have_pointers (tree t)
 
static bool push_fields_onto_fieldstack (tree type, vec< fieldoff_s > *fieldstack, HOST_WIDE_INT offset)
 
static unsigned int count_num_arguments (tree decl, bool *is_varargs)
 
static varinfo_t create_function_info_for (tree decl, const char *name, bool add_id, bool nonlocal_p)
 
static bool check_for_overlaps (const vec< fieldoff_s > &fieldstack)
 
static varinfo_t create_variable_info_for_1 (tree decl, const char *name, bool add_id, bool handle_param, bitmap handled_struct_type, bool add_restrict=false)
 
static void dump_solution_for_var (FILE *file, unsigned int var)
 
static void intra_create_variable_infos (struct function *fn)
 
static bitmap shared_bitmap_lookup (bitmap pt_vars)
 
static void shared_bitmap_add (bitmap pt_vars)
 
static void set_uids_in_ptset (bitmap into, bitmap from, struct pt_solution *pt, tree fndecl)
 
static struct pt_solution find_what_var_points_to (tree fndecl, varinfo_t orig_vi)
 
static void find_what_p_points_to (tree fndecl, tree p)
 
void dump_pta_stats (FILE *s)
 
void pt_solution_reset (struct pt_solution *pt)
 
void pt_solution_set (struct pt_solution *pt, bitmap vars, bool vars_contains_nonlocal)
 
void pt_solution_set_var (struct pt_solution *pt, tree var)
 
static void pt_solution_ior_into (struct pt_solution *dest, struct pt_solution *src)
 
bool pt_solution_empty_p (const pt_solution *pt)
 
bool pt_solution_singleton_or_null_p (struct pt_solution *pt, unsigned *uid)
 
bool pt_solution_includes_global (struct pt_solution *pt, bool escaped_local_p)
 
static bool pt_solution_includes_1 (struct pt_solution *pt, const_tree decl)
 
bool pt_solution_includes (struct pt_solution *pt, const_tree decl)
 
bool pt_solution_includes_const_pool (struct pt_solution *pt)
 
static bool pt_solutions_intersect_1 (struct pt_solution *pt1, struct pt_solution *pt2)
 
bool pt_solutions_intersect (struct pt_solution *pt1, struct pt_solution *pt2)
 
static void dump_sa_stats (FILE *outfile)
 
static void dump_sa_points_to_info (FILE *outfile)
 
static void init_base_vars (void)
 
static void init_alias_vars (void)
 
static void remove_preds_and_fake_succs (constraint_graph_t graph)
 
static void solve_constraints (void)
 
static void compute_points_to_sets (void)
 
static void delete_points_to_sets (void)
 
static bool visit_loadstore (gimple *, tree base, tree ref, void *data)
 
static bool maybe_set_dependence_info (gimple *, tree base, tree, void *data)
 
static bool clear_dependence_clique (gimple *, tree base, tree, void *data)
 
static void compute_dependence_clique (void)
 
unsigned int compute_may_aliases (void)
 
gimple_opt_passmake_pass_build_alias (gcc::context *ctxt)
 
gimple_opt_passmake_pass_build_ealias (gcc::context *ctxt)
 
static bool associate_varinfo_to_alias (struct cgraph_node *node, void *data)
 
static void dump_varinfo (FILE *file, varinfo_t vi)
 
static void dump_varmap (FILE *file)
 
static bool refered_from_nonlocal_fn (struct cgraph_node *node, void *data)
 
static bool refered_from_nonlocal_var (struct varpool_node *node, void *data)
 
static unsigned int ipa_pta_execute (void)
 
simple_ipa_opt_passmake_pass_ipa_pta (gcc::context *ctxt)
 

Variables

static bool use_field_sensitive = true
 
static int in_ipa_mode = 0
 
static bitmap_obstack predbitmap_obstack
 
static bitmap_obstack pta_obstack
 
static bitmap_obstack oldpta_obstack
 
static bitmap_obstack iteration_obstack
 
static struct constraint_stats stats
 
static object_allocator< variable_infovariable_info_pool ("Variable info pool")
 
static hash_map< varinfo_t, pt_solution * > * final_solutions
 
struct obstack final_solutions_obstack
 
static vec< varinfo_tvarmap
 
static hash_map< gimple *, varinfo_t > * call_stmt_vars
 
static vec< constraint_tconstraints
 
static object_allocator< constraintconstraint_pool ("Constraint pool")
 
static constraint_graph_t graph
 
static bitmap changed
 
static hash_table< equiv_class_hasher > * pointer_equiv_class_table
 
static hash_table< equiv_class_hasher > * location_equiv_class_table
 
struct obstack equiv_class_obstack
 
static int pointer_equiv_class
 
static int location_equiv_class
 
static hash_map< tree, varinfo_t > * vi_for_tree
 
struct obstack fake_var_decl_obstack
 
static hash_table< shared_bitmap_hasher > * shared_bitmap_table
 
struct { 
 
   unsigned HOST_WIDE_INT   pt_solution_includes_may_alias 
 
   unsigned HOST_WIDE_INT   pt_solution_includes_no_alias 
 
   unsigned HOST_WIDE_INT   pt_solutions_intersect_may_alias 
 
   unsigned HOST_WIDE_INT   pt_solutions_intersect_no_alias 
 
pta_stats 
 
struct pt_solution ipa_escaped_pt
 

Macro Definition Documentation

◆ EXECUTE_IF_IN_NONNULL_BITMAP

#define EXECUTE_IF_IN_NONNULL_BITMAP ( a,
b,
c,
d )
Value:
if (a) \
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Ca const poly_int< N, Cb > & b
Definition poly-int.h:767
Ca & a
Definition poly-int.h:766

Referenced by condense_visit(), dump_constraint_graph(), dump_pred_graph(), label_visit(), scc_visit(), and solve_graph().

◆ FIRST_REF_NODE

#define FIRST_REF_NODE   (varmap).length ()
During variable substitution and the offline version of indirect
cycle finding, we create nodes to represent dereferences and
address taken constraints.  These represent where these start and
end.   

Referenced by add_graph_edge(), build_pred_graph(), build_succ_graph(), dump_constraint_graph(), dump_pred_graph(), label_visit(), perform_var_substitution(), remove_preds_and_fake_succs(), scc_visit(), and unite_pointer_equivalences().

◆ LAST_REF_NODE

#define LAST_REF_NODE   (FIRST_REF_NODE + (FIRST_REF_NODE - 1))

Referenced by find_indirect_cycles(), and scc_visit().

◆ UNKNOWN_OFFSET

Typedef Documentation

◆ ce_s

◆ const_equiv_class_label_t

◆ const_shared_bitmap_info_t

◆ constraint_graph_t

◆ constraint_t

◆ equiv_class_label_t

Structure used to for hash value numbering of pointer equivalence
classes.   

◆ fieldoff_s

◆ shared_bitmap_info_t

Structure used to put solution bitmaps in a hashtable so they can
be shared among variables with the same points-to set.   

◆ varinfo_t

Enumeration Type Documentation

◆ anonymous enum

Static IDs for the special variables.  Variable ID zero is unused
and used as terminator for the sub-variable chain.   
Enumerator
nothing_id 
anything_id 
string_id 
escaped_id 
nonlocal_id 
escaped_return_id 
storedanything_id 
integer_id 

◆ anonymous enum

In IPA mode there are varinfos for different aspects of reach
function designator.  One for the points-to set of the return
value, one for the variables that are clobbered by the function,
one for its uses and one for each parameter (including a single
glob for remaining variadic arguments).   
Enumerator
fi_clobbers 
fi_uses 
fi_static_chain 
fi_result 
fi_parm_base 

◆ constraint_expr_type

Enumerator
SCALAR 
DEREF 
ADDRESSOF 

Function Documentation

◆ add_graph_edge()

static bool add_graph_edge ( constraint_graph_t graph,
unsigned int to,
unsigned int from )
static
Add a graph edge to GRAPH, going from FROM to TO if
it doesn't exist in the graph already.
Return false if the edge already existed, true otherwise.   

References BITMAP_ALLOC, bitmap_bit_p, bitmap_set_bit, escaped_id, find(), FIRST_REF_NODE, get_varinfo(), pta_obstack, and r.

Referenced by build_succ_graph(), do_ds_constraint(), and solve_add_graph_edge().

◆ add_implicit_graph_edge()

static void add_implicit_graph_edge ( constraint_graph_t graph,
unsigned int to,
unsigned int from )
static
Add an indirect graph edge to GRAPH, going from TO to FROM if
it doesn't exist in the graph already.   

References BITMAP_ALLOC, bitmap_set_bit, and predbitmap_obstack.

Referenced by build_pred_graph().

◆ add_pred_graph_edge()

static void add_pred_graph_edge ( constraint_graph_t graph,
unsigned int to,
unsigned int from )
static
Add a predecessor graph edge to GRAPH, going from TO to FROM if
it doesn't exist in the graph already.
Return false if the edge already existed, true otherwise.   

References BITMAP_ALLOC, bitmap_set_bit, and predbitmap_obstack.

Referenced by build_pred_graph().

◆ alias_get_name()

◆ associate_varinfo_to_alias()

static bool associate_varinfo_to_alias ( struct cgraph_node * node,
void * data )
static
Associate node with varinfo DATA. Worker for
cgraph_for_symbol_thunks_and_aliases.   

References symtab_node::alias, symtab_node::analyzed, symtab_node::decl, symtab_node::ifunc_resolver, cgraph_node::inlined_to, insert_vi_for_tree(), and cgraph_node::thunk.

Referenced by ipa_pta_execute().

◆ bitpos_of_field()

static HOST_WIDE_INT bitpos_of_field ( const tree fdecl)
static
Return the position, in bits, of FIELD_DECL from the beginning of its
structure.   

References DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, ggc_alloc(), tree_fits_shwi_p(), and tree_to_shwi().

Referenced by push_fields_onto_fieldstack().

◆ build_fake_var_decl()

static tree build_fake_var_decl ( tree type)
static

◆ build_pred_graph()

◆ build_succ_graph()

◆ check_for_overlaps()

static bool check_for_overlaps ( const vec< fieldoff_s > & fieldstack)
static
Return true if FIELDSTACK contains fields that overlap.
FIELDSTACK is assumed to be sorted by offset.   

References FOR_EACH_VEC_ELT, ggc_alloc(), i, and NULL.

Referenced by create_variable_info_for_1().

◆ clear_dependence_clique()

static bool clear_dependence_clique ( gimple * ,
tree base,
tree ,
void * data )
static
Clear dependence info for the clique DATA.   

References ggc_alloc(), MR_DEPENDENCE_BASE, MR_DEPENDENCE_CLIQUE, and TREE_CODE.

Referenced by compute_dependence_clique().

◆ clear_edges_for_node()

static void clear_edges_for_node ( constraint_graph_t graph,
unsigned int node )
static
Remove edges involving NODE from GRAPH.   

References BITMAP_FREE.

Referenced by merge_graph_nodes(), and perform_var_substitution().

◆ compute_dependence_clique()

◆ compute_may_aliases()

unsigned int compute_may_aliases ( void )
Compute points-to information for every SSA_NAME pointer in the
current function and compute the transitive closure of escaped
variables to re-initialize the call-clobber states of local variables.   

References cfun, compute_dependence_clique(), compute_points_to_sets(), delete_points_to_sets(), dump_alias_info(), dump_file, dump_flags, gcc_assert, ggc_alloc(), need_ssa_update_p(), TDF_ALIAS, and TDF_DETAILS.

Referenced by execute_function_todo().

◆ compute_points_to_sets()

◆ compute_topo_order()

static auto_vec< unsigned > compute_topo_order ( constraint_graph_t graph)
static
Compute a topological ordering for GRAPH, and return the result.   

References bitmap_bit_p, bitmap_clear(), escaped_id, find(), ggc_alloc(), i, topo_visit(), and visited.

Referenced by solve_graph().

◆ condense_visit()

static void condense_visit ( constraint_graph_t graph,
class scc_info * si,
unsigned int n )
static
Recursive routine to find strongly connected components in GRAPH,
and label it's nodes with DFS numbers.   

References a, b, bitmap_bit_p, bitmap_clear_bit(), bitmap_ior_into_and_free(), bitmap_set_bit, condense_visit(), EXECUTE_IF_IN_NONNULL_BITMAP, gcc_assert, gcc_checking_assert, ggc_alloc(), i, and si.

Referenced by condense_visit(), and perform_var_substitution().

◆ constraint_equal()

static bool constraint_equal ( struct constraint a,
struct constraint b )
static
Return true if two constraints A and B are equal.   

References a, b, and constraint_expr_equal().

Referenced by constraint_vec_find(), and insert_into_complex().

◆ constraint_expr_equal()

static bool constraint_expr_equal ( struct constraint_expr a,
struct constraint_expr b )
static
SOLVER FUNCTIONS

The solver is a simple worklist solver, that works on the following
algorithm:

sbitmap changed_nodes = all zeroes;
changed_count = 0;
For each node that is not already collapsed:
    changed_count++;
    set bit in changed nodes

while (changed_count > 0)
{
  compute topological ordering for constraint graph

  find and collapse cycles in the constraint graph (updating
  changed if necessary)

  for each node (n) in the graph in topological order:
    changed_count--;

    Process each complex constraint associated with the node,
    updating changed if necessary.

    For each outgoing edge from n, propagate the solution from n to
    the destination of the edge, updating changed as necessary.

}   
Return true if two constraint expressions A and B are equal.   

References a, and b.

Referenced by constraint_equal().

◆ constraint_expr_less()

static bool constraint_expr_less ( struct constraint_expr a,
struct constraint_expr b )
static
Return true if constraint expression A is less than constraint expression
B.  This is just arbitrary, but consistent, in order to give them an
ordering.   

References a, and b.

Referenced by constraint_less().

◆ constraint_less()

static bool constraint_less ( const constraint_t & a,
const constraint_t & b )
static
Return true if constraint A is less than constraint B.  This is just
arbitrary, but consistent, in order to give them an ordering.   

References a, b, and constraint_expr_less().

Referenced by constraint_set_union(), constraint_vec_find(), and insert_into_complex().

◆ constraint_set_union()

static bool constraint_set_union ( vec< constraint_t > * to,
vec< constraint_t > * from )
static
Union two constraint vectors, TO and FROM.  Put the result in TO. 
Returns true of TO set is changed.   

References constraint_less(), constraint_vec_find(), FOR_EACH_VEC_ELT, ggc_alloc(), i, and NULL.

Referenced by merge_node_constraints().

◆ constraint_vec_find()

static constraint_t constraint_vec_find ( vec< constraint_t > vec,
struct constraint lookfor )
static
Find a constraint LOOKFOR in the sorted constraint vector VEC  

References constraint_equal(), constraint_less(), ggc_alloc(), and NULL.

Referenced by constraint_set_union().

◆ count_num_arguments()

static unsigned int count_num_arguments ( tree decl,
bool * is_varargs )
static
Count the number of arguments DECL has, and set IS_VARARGS to true
if it is a varargs function.   

References DECL_ARGUMENTS, DECL_CHAIN, ggc_alloc(), TREE_CHAIN, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, and void_type_node.

Referenced by create_function_info_for().

◆ create_function_info_for()

◆ create_variable_info_for()

◆ create_variable_info_for_1()

static varinfo_t create_variable_info_for_1 ( tree decl,
const char * name,
bool add_id,
bool handle_param,
bitmap handled_struct_type,
bool add_restrict = false )
static
Create a varinfo structure for NAME and DECL, and add it to VARMAP.
This will also create any varinfo structures necessary for fields
of DECL.  DECL is a function parameter if HANDLE_PARAM is set.
HANDLED_STRUCT_TYPE is used to register struct types reached by following
restrict pointers.  This is needed to prevent infinite recursion.
If ADD_RESTRICT, pretend that the pointer NAME is restrict even if DECL
does not advertise it.   

References bitmap_bit_p, bitmap_clear_bit(), bitmap_set_bit, build_fake_var_decl(), check_for_overlaps(), create_variable_info_for_1(), DECL_EXTERNAL, DECL_P, DECL_SIZE, dump_file, free(), ggc_alloc(), ggc_strdup, HOST_WIDE_INT_PRINT_DEC, i, in_ipa_mode, insert_vi_for_tree(), is_global_var(), make_constraint_from(), make_param_constraints(), new_var_info(), NULL, POINTER_TYPE_P, push_fields_onto_fieldstack(), sort_fieldstack(), tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, type_contains_placeholder_p(), TYPE_RESTRICT, TYPE_SIZE, TYPE_UID, use_field_sensitive, var_can_have_subvars(), and vi_next().

Referenced by create_variable_info_for(), create_variable_info_for_1(), and intra_create_variable_infos().

◆ debug_constraint()

DEBUG_FUNCTION void debug_constraint ( constraint_t c)
Print out constraint C to stderr.   

References dump_constraint(), and ggc_alloc().

◆ debug_constraint_graph()

DEBUG_FUNCTION void debug_constraint_graph ( void )
Print out the constraint graph to stderr.   

References dump_constraint_graph(), and ggc_alloc().

◆ debug_constraints()

DEBUG_FUNCTION void debug_constraints ( void )
Print out all constraints to stderr.   

References dump_constraints(), and ggc_alloc().

◆ debug_sa_points_to_info()

DEBUG_FUNCTION void debug_sa_points_to_info ( void )
Debug points-to information to stderr.   

References dump_sa_points_to_info(), and ggc_alloc().

◆ debug_solution_for_var()

DEBUG_FUNCTION void debug_solution_for_var ( unsigned int var)
Print the points-to solution for VAR to stderr.   

References dump_solution_for_var(), ggc_alloc(), and constraint_expr::var.

◆ debug_varinfo()

DEBUG_FUNCTION void debug_varinfo ( varinfo_t vi)
Dump varinfo VI to stderr.   

References dump_varinfo(), and ggc_alloc().

◆ debug_varmap()

DEBUG_FUNCTION void debug_varmap ( void )
Dump varmap to stderr.   

References dump_varmap(), and ggc_alloc().

◆ delete_points_to_sets()

◆ determine_global_memory_access()

static void determine_global_memory_access ( gcall * stmt,
bool * writes_global_memory,
bool * reads_global_memory,
bool * uses_global_memory )
static

◆ do_complex_constraint()

static void do_complex_constraint ( constraint_graph_t graph,
constraint_t c,
bitmap delta,
bitmap * expanded_delta )
static

◆ do_deref()

static void do_deref ( vec< ce_s > * constraints)
static
Dereference the constraint expression CONS, and return the result.
DEREF (ADDRESSOF) = SCALAR
DEREF (SCALAR) = DEREF
DEREF (DEREF) = (temp = DEREF1; result = DEREF(temp))
This is needed so that we can handle dereferencing DEREF constraints.   

References ADDRESSOF, constraints, DEREF, FOR_EACH_VEC_ELT, gcc_unreachable, ggc_alloc(), i, new_constraint(), new_scalar_tmp_constraint_exp(), process_constraint(), SCALAR, constraint_expr::type, and constraint_expr::var.

Referenced by find_func_aliases_for_builtin_call(), find_func_aliases_for_call(), get_constraint_for_1(), and get_constraint_for_component_ref().

◆ do_ds_constraint()

◆ do_sd_constraint()

◆ do_structure_copy()

static void do_structure_copy ( tree lhsop,
tree rhsop )
static

◆ dump_constraint()

◆ dump_constraint_graph()

static void dump_constraint_graph ( FILE * file)
static
Print the constraint graph in dot format.   

References dump_constraint(), EXECUTE_IF_IN_NONNULL_BITMAP, find(), FIRST_REF_NODE, get_varinfo(), ggc_alloc(), and i.

Referenced by debug_constraint_graph(), and solve_constraints().

◆ dump_constraints()

static void dump_constraints ( FILE * file,
int from )
static
Print out all constraints to FILE  

References constraints, dump_constraint(), ggc_alloc(), and i.

Referenced by compute_points_to_sets(), debug_constraints(), and ipa_pta_execute().

◆ dump_pred_graph()

static void dump_pred_graph ( class scc_info * si,
FILE * file )
static

◆ dump_pta_stats()

void dump_pta_stats ( FILE * s)

◆ dump_sa_points_to_info()

static void dump_sa_points_to_info ( FILE * outfile)
static
Dump points-to information to OUTFILE.   

References dump_solution_for_var(), get_varinfo(), ggc_alloc(), i, and varmap.

Referenced by compute_points_to_sets(), debug_sa_points_to_info(), and ipa_pta_execute().

◆ dump_sa_stats()

static void dump_sa_stats ( FILE * outfile)
static
Dump stats information to OUTFILE.   

References ggc_alloc().

Referenced by compute_points_to_sets(), and ipa_pta_execute().

◆ dump_solution_for_var()

static void dump_solution_for_var ( FILE * file,
unsigned int var )
static
Print out the points-to solution for VAR to FILE.   

References EXECUTE_IF_SET_IN_BITMAP, find(), get_varinfo(), ggc_alloc(), i, and constraint_expr::var.

Referenced by debug_solution_for_var(), and dump_sa_points_to_info().

◆ dump_varinfo()

static void dump_varinfo ( FILE * file,
varinfo_t vi )
static

◆ dump_varmap()

static void dump_varmap ( FILE * file)
static
Dump varmap to FILE.   

References dump_varinfo(), get_varinfo(), ggc_alloc(), i, and varmap.

Referenced by debug_varmap().

◆ eliminate_indirect_cycles()

static bool eliminate_indirect_cycles ( unsigned int node)
static
Eliminate indirect cycles involving NODE.  Return true if NODE was
part of an SCC, false otherwise.   

References bitmap_empty_p(), EXECUTE_IF_SET_IN_BITMAP, find(), get_varinfo(), ggc_alloc(), i, queue, unify_nodes(), and unite().

Referenced by solve_graph().

◆ equiv_class_lookup_or_add()

static equiv_class_label * equiv_class_lookup_or_add ( hash_table< equiv_class_hasher > * table,
bitmap labels )
static
Lookup a equivalence class in TABLE by the bitmap of LABELS with
hash HAS it contains.  Sets *REF_LABELS to the bitmap LABELS
is equivalent to.   

References bitmap_hash(), equiv_class_obstack, ggc_alloc(), and table.

Referenced by label_visit(), and perform_var_substitution().

◆ field_must_have_pointers()

static bool field_must_have_pointers ( tree t)
static

◆ fieldoff_compare()

static int fieldoff_compare ( const void * pa,
const void * pb )
static
qsort comparison function for two fieldoff's PA and PB  

References ggc_alloc().

Referenced by sort_fieldstack().

◆ find()

◆ find_equivalent_node()

static unsigned int find_equivalent_node ( constraint_graph_t graph,
unsigned int node,
unsigned int label )
static
Return an existing node that is equivalent to NODE, which has
equivalence class LABEL, if one exists.  Return NODE otherwise.   

References bitmap_bit_p, gcc_checking_assert, ggc_alloc(), unify_nodes(), and unite().

Referenced by rewrite_constraints().

◆ find_func_aliases()

static void find_func_aliases ( struct function * fn,
gimple * origt )
static

◆ find_func_aliases_for_builtin_call()

◆ find_func_aliases_for_call()

◆ find_func_aliases_for_call_arg()

static void find_func_aliases_for_call_arg ( varinfo_t fi,
unsigned index,
tree arg )
static
Create constraints for assigning call argument ARG to the incoming parameter
INDEX of function FI.   

References fi_parm_base, FOR_EACH_VEC_ELT, get_constraint_for_rhs(), get_function_part_constraint(), ggc_alloc(), new_constraint(), and process_constraint().

Referenced by find_func_aliases_for_builtin_call(), and find_func_aliases_for_call().

◆ find_func_clobbers()

◆ find_indirect_cycles()

static void find_indirect_cycles ( constraint_graph_t graph)
static
Find indirect cycles in GRAPH that occur, using strongly connected
components, and note them in the indirect cycles map.

This technique comes from Ben Hardekopf and Calvin Lin,
"It Pays to be Lazy: Fast and Accurate Pointer Analysis for Millions of
Lines of Code", submitted to PLDI 2007.   

References bitmap_bit_p, find(), i, LAST_REF_NODE, MIN, scc_visit(), and si.

Referenced by solve_constraints().

◆ find_what_p_points_to()

◆ find_what_var_points_to()

◆ first_or_preceding_vi_for_offset()

static varinfo_t first_or_preceding_vi_for_offset ( varinfo_t start,
unsigned HOST_WIDE_INT offset )
static
Find the first varinfo in the same variable as START that overlaps with
OFFSET.  If there is no such varinfo the varinfo directly preceding
OFFSET is returned.   

References get_varinfo(), offset, and vi_next().

Referenced by do_ds_constraint(), do_sd_constraint(), get_constraint_for_ptr_offset(), and set_union_with_increment().

◆ first_vi_for_offset()

static varinfo_t first_vi_for_offset ( varinfo_t start,
unsigned HOST_WIDE_INT offset )
static
Find the first varinfo in the same variable as START that overlaps with
OFFSET.  Return NULL if we can't find one.   

References get_varinfo(), NULL, offset, and vi_next().

Referenced by create_function_info_for(), find_func_clobbers(), get_function_part_constraint(), and ipa_pta_execute().

◆ fndecl_maybe_in_other_partition()

static bool fndecl_maybe_in_other_partition ( tree fndecl)
static
Return true if FNDECL may be part of another lto partition.   

References cgraph_node::get(), ggc_alloc(), and NULL.

Referenced by find_func_aliases_for_builtin_call(), find_func_clobbers(), and ipa_pta_execute().

◆ free_var_substitution_info()

static void free_var_substitution_info ( class scc_info * si)
static
Free information that was only necessary for variable
substitution.   

References bitmap_obstack_release(), equiv_class_obstack, free(), ggc_alloc(), iteration_obstack, location_equiv_class_table, NULL, pointer_equiv_class_table, sbitmap_free(), and si.

Referenced by solve_constraints().

◆ get_call_clobber_vi()

static varinfo_t get_call_clobber_vi ( gcall * call)
static
Lookup or create the variable for the call statement CALL representing
the clobbers.   

References get_call_vi(), and vi_next().

Referenced by find_func_aliases_for_builtin_call(), and handle_call_arg().

◆ get_call_use_vi()

static varinfo_t get_call_use_vi ( gcall * call)
static
Lookup or create the variable for the call statement CALL representing
the uses.   

References get_call_vi().

Referenced by find_func_aliases_for_builtin_call(), handle_call_arg(), and handle_rhs_call().

◆ get_call_vi()

static varinfo_t get_call_vi ( gcall * call)
static
Lookup or create the variable for the call statement CALL.   

References call_stmt_vars, ggc_alloc(), new_var_info(), and NULL_TREE.

Referenced by get_call_clobber_vi(), and get_call_use_vi().

◆ get_constraint_for()

static void get_constraint_for ( tree t,
vec< ce_s > * results )
static
Given a gimple tree T, return the constraint expression vector for it.   

References gcc_assert, get_constraint_for_1(), and ggc_alloc().

Referenced by do_structure_copy(), find_func_aliases(), find_func_aliases_for_builtin_call(), find_func_aliases_for_call(), find_func_clobbers(), and handle_lhs_call().

◆ get_constraint_for_1()

◆ get_constraint_for_address_of()

static void get_constraint_for_address_of ( tree t,
vec< ce_s > * results )
static
Given a tree T, return the constraint expression for taking the
address of it.   

References ADDRESSOF, DEREF, FOR_EACH_VEC_ELT, get_constraint_for_1(), ggc_alloc(), i, SCALAR, and constraint_expr::type.

Referenced by create_variable_info_for(), find_func_aliases_for_call(), find_func_clobbers(), get_constraint_for_1(), and handle_rhs_call().

◆ get_constraint_for_component_ref()

static void get_constraint_for_component_ref ( tree t,
vec< ce_s > * results,
bool address_p,
bool lhs_p )
static

◆ get_constraint_for_ptr_offset()

◆ get_constraint_for_rhs()

static void get_constraint_for_rhs ( tree t,
vec< ce_s > * results )
static
Given a gimple tree T, return the constraint expression vector for it
to be used as the rhs of a constraint.   

References gcc_assert, get_constraint_for_1(), and ggc_alloc().

Referenced by do_structure_copy(), find_func_aliases(), find_func_aliases_for_call_arg(), get_constraint_for_ptr_offset(), make_constraint_to(), and process_ipa_clobber().

◆ get_constraint_for_ssa_var()

◆ get_fi_for_callee()

◆ get_function_part_constraint()

◆ get_varinfo()

◆ get_vi_for_tree()

static varinfo_t get_vi_for_tree ( tree t)
static

◆ handle_call_arg()

static void handle_call_arg ( gcall * stmt,
tree arg,
vec< ce_s > * results,
int flags,
int callescape_id,
bool writes_global_memory )
static

◆ handle_lhs_call()

static void handle_lhs_call ( gcall * stmt,
tree lhs,
int flags,
vec< ce_s > & rhsc,
tree fndecl )
static
For non-IPA mode, generate constraints necessary for a call
that returns a pointer and assigns it to LHS.  This simply makes
the LHS point to global and escaped variables.   

References ADDRESSOF, BUILT_IN_NORMAL, DECL_EXTERNAL, DECL_P, ERF_NOALIAS, ERF_RETURN_ARG_MASK, ERF_RETURNS_ARG, escaped_id, fndecl_built_in_p(), get_base_address(), get_constraint_for(), ggc_alloc(), gimple_call_arg(), gimple_call_num_args(), is_global_var(), make_constraint_from(), make_heapvar(), nonlocal_id, process_all_all_constraints(), and SCALAR.

Referenced by find_func_aliases_for_builtin_call(), and find_func_aliases_for_call().

◆ handle_rhs_call()

static void handle_rhs_call ( gcall * stmt,
vec< ce_s > * results,
int implicit_eaf_flags,
bool writes_global_memory,
bool reads_global_memory )
static
For non-IPA mode, generate constraints necessary for a call on the
RHS and collect return value constraint to RESULTS to be used later in
handle_lhs_call.

IMPLICIT_EAF_FLAGS are added to each function argument.  If
WRITES_GLOBAL_MEMORY is true function is assumed to possibly write to global
memory.  Similar for READS_GLOBAL_MEMORY.   

References ADDRESSOF, determine_global_memory_access(), EAF_NO_DIRECT_ESCAPE, EAF_NOT_RETURNED_DIRECTLY, EAF_UNUSED, escaped_id, FOR_EACH_VEC_ELT, get_call_use_vi(), get_constraint_for_address_of(), ggc_alloc(), gimple_call_arg(), gimple_call_arg_flags(), gimple_call_chain(), gimple_call_lhs(), gimple_call_num_args(), gimple_call_retslot_flags(), gimple_call_return_slot_opt_p(), gimple_call_static_chain_flags(), handle_call_arg(), i, make_constraints_to(), make_copy_constraint(), new_constraint(), new_var_info(), nonlocal_id, NULL, NULL_TREE, constraint_expr::offset, process_constraint(), SCALAR, TREE_ADDRESSABLE, TREE_TYPE, constraint_expr::type, and constraint_expr::var.

Referenced by find_func_aliases_for_call().

◆ init_alias_vars()

◆ init_base_vars()

◆ init_graph()

static void init_graph ( unsigned int size)
static
Initialize the constraint graph structure to contain SIZE nodes.   

References ggc_alloc().

Referenced by solve_constraints().

◆ insert_into_complex()

static void insert_into_complex ( constraint_graph_t graph,
unsigned int var,
constraint_t c )
static
Insert constraint C into the list of complex constraints for graph
node VAR.   

References constraint_equal(), constraint_less(), and ggc_alloc().

Referenced by move_complex_constraints().

◆ insert_vi_for_tree()

static void insert_vi_for_tree ( tree t,
varinfo_t vi )
static

◆ intra_create_variable_infos()

◆ ipa_pta_execute()

static unsigned int ipa_pta_execute ( void )
static
Execute the driver for IPA PTA.   

References symtab_node::alias, alias_get_name(), allocate_decl_uid(), symtab_node::analyzed, pt_solution::anything, anything_id, associate_varinfo_to_alias(), auto_var_in_fn_p(), auto_var_p(), bitmap_bit_p, varpool_node::call_for_symbol_and_aliases(), cgraph_node::call_for_symbol_thunks_and_aliases(), cfun, cgraph_node::clone_of, constraints, create_function_info_for(), symtab_node::decl, variable_info::decl, DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, DECL_ATTRIBUTES, DECL_EXTERNAL, DECL_STRUCT_FUNCTION, delete_points_to_sets(), symbol_table::dump(), dump_constraints(), dump_file, dump_flags, symtab_node::dump_name(), dump_sa_points_to_info(), dump_sa_stats(), ECF_CONST, ECF_NOVOPS, ECF_PURE, escaped_id, EXECUTE_IF_SET_IN_BITMAP, fi_clobbers, fi_parm_base, fi_uses, final_solutions, final_solutions_obstack, find(), find_func_aliases(), find_func_clobbers(), find_what_p_points_to(), find_what_var_points_to(), first_vi_for_offset(), fndecl_maybe_in_other_partition(), FOR_EACH_BB_FN, FOR_EACH_DEFINED_FUNCTION, FOR_EACH_VARIABLE, FOR_EACH_VEC_ELT, symtab_node::force_output, gcc_assert, gcc_obstack_init, gcc_unreachable, cgraph_node::get_body(), get_fi_for_callee(), get_varinfo(), get_vi_for_tree(), ggc_alloc(), gimple_call_arg(), gimple_call_builtin_p(), gimple_call_clobber_set(), gimple_call_flags(), gimple_call_fndecl(), gimple_call_use_set(), function::gimple_df, gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), cgraph_node::has_gimple_body_p(), i, IDENTIFIER_POINTER, in_ipa_mode, symtab_node::in_other_partition, init_alias_vars(), cgraph_node::inlined_to, pt_solution::ipa_escaped, ipa_escaped_pt, gimple_df::ipa_pta, lookup_attribute(), lookup_call_clobber_vi(), lookup_call_use_vi(), lookup_vi_for_tree(), pt_solution::nonlocal, nonlocal_id, NULL, NULL_TREE, POINTER_TYPE_P, pt_solution_ior_into(), pt_solution_reset(), refered_from_nonlocal_fn(), refered_from_nonlocal_var(), variable_info::shadow_var_uid, solve_constraints(), gimple_df::ssa_names, symtab, TDF_DETAILS, TDF_STATS, TREE_OPERAND, TREE_PUBLIC, TREE_TYPE, symtab_node::used_from_other_partition, varmap, vi_next(), and virtual_operand_p().

◆ label_visit()

static void label_visit ( constraint_graph_t graph,
class scc_info * si,
unsigned int n )
static
Label pointer equivalences.

This performs a value numbering of the constraint graph to
discover which variables will always have the same points-to sets
under the current set of constraints.

The way it value numbers is to store the set of points-to bits
generated by the constraints and graph edges.  This is just used as a
hash and equality comparison.  The *actual set of points-to bits* is
completely irrelevant, in that we don't care about being able to
extract them later.

The equality values (currently bitmaps) just have to satisfy a few
constraints, the main ones being:
1. The combining operation must be order independent.
2. The end result of a given set of operations must be unique iff the
   combination of input values is unique
3. Hashable.   

References BITMAP_ALLOC, bitmap_bit_p, bitmap_copy(), bitmap_empty_p(), BITMAP_FREE, bitmap_ior(), bitmap_ior_into(), bitmap_set_bit, equiv_class_lookup_or_add(), EXECUTE_IF_IN_NONNULL_BITMAP, FIRST_REF_NODE, ggc_alloc(), i, label_visit(), pointer_equiv_class, pointer_equiv_class_table, predbitmap_obstack, and si.

Referenced by label_visit(), and perform_var_substitution().

◆ lookup_call_clobber_vi()

static varinfo_t lookup_call_clobber_vi ( gcall * call)
static
Lookup the variable for the call statement CALL representing
the clobbers.  Returns NULL if there is nothing special about this call.   

References lookup_call_use_vi(), NULL, and vi_next().

Referenced by compute_points_to_sets(), find_func_clobbers(), and ipa_pta_execute().

◆ lookup_call_use_vi()

static varinfo_t lookup_call_use_vi ( gcall * call)
static
Lookup the variable for the call statement CALL representing
the uses.  Returns NULL if there is nothing special about this call.   

References call_stmt_vars, ggc_alloc(), and NULL.

Referenced by compute_points_to_sets(), find_func_clobbers(), ipa_pta_execute(), and lookup_call_clobber_vi().

◆ lookup_vi_for_tree()

static varinfo_t lookup_vi_for_tree ( tree t)
static
Find the variable info for tree T in VI_FOR_TREE.  If T does not
exist in the map, return NULL, otherwise, return the varinfo we found.   

References NULL, and vi_for_tree.

Referenced by compute_dependence_clique(), create_function_info_for(), find_func_aliases(), find_func_aliases_for_builtin_call(), find_func_clobbers(), find_what_p_points_to(), ipa_pta_execute(), and visit_loadstore().

◆ make_any_offset_constraints()

static void make_any_offset_constraints ( varinfo_t vi)
static
Add constraints to that the solution of VI has all subvariables added.   

References ggc_alloc(), new_constraint(), constraint_expr::offset, process_constraint(), SCALAR, constraint_expr::type, UNKNOWN_OFFSET, and constraint_expr::var.

Referenced by find_func_aliases_for_builtin_call(), and handle_call_arg().

◆ make_constraint_from()

◆ make_constraint_from_global_restrict()

static varinfo_t make_constraint_from_global_restrict ( varinfo_t lhs,
const char * name,
bool add_id )
static
Create a new artificial heap variable with NAME and make a
constraint from it to LHS.  Set flags according to a tag used
for tracking restrict pointers and make the artificial heap
point to global memory.   

References ggc_alloc(), make_constraint_from_restrict(), make_copy_constraint(), and nonlocal_id.

Referenced by create_variable_info_for().

◆ make_constraint_from_restrict()

static varinfo_t make_constraint_from_restrict ( varinfo_t lhs,
const char * name,
bool add_id )
static
Create a new artificial heap variable with NAME and make a
constraint from it to LHS.  Set flags according to a tag used
for tracking restrict pointers.   

References ggc_alloc(), make_constraint_from(), and make_heapvar().

Referenced by make_constraint_from_global_restrict().

◆ make_constraint_to()

static void make_constraint_to ( unsigned id,
tree op )
static

◆ make_constraints_to()

static void make_constraints_to ( unsigned id,
const vec< ce_s > & rhsc )
static

◆ make_copy_constraint()

◆ make_escape_constraint()

static void make_escape_constraint ( tree op)
static
Make constraints necessary to make OP escape.   

References escaped_id, and make_constraint_to().

Referenced by find_func_aliases(), and handle_call_arg().

◆ make_heapvar()

static varinfo_t make_heapvar ( const char * name,
bool add_id )
static
Create a new artificial heap variable with NAME.
Return the created variable.   

References build_fake_var_decl(), DECL_EXTERNAL, ggc_alloc(), insert_vi_for_tree(), new_var_info(), and ptr_type_node.

Referenced by find_func_aliases_for_builtin_call(), handle_lhs_call(), and make_constraint_from_restrict().

◆ make_indirect_escape_constraint()

static void make_indirect_escape_constraint ( varinfo_t vi)
static
Make constraint necessary to make all indirect references
from VI escape.   

References DEREF, escaped_id, ggc_alloc(), new_constraint(), constraint_expr::offset, process_constraint(), SCALAR, constraint_expr::type, UNKNOWN_OFFSET, and constraint_expr::var.

Referenced by handle_call_arg().

◆ make_param_constraints()

static void make_param_constraints ( varinfo_t vi)
static
Register the constraints for function parameter related VI.   

References ggc_alloc(), make_constraint_from(), nonlocal_id, and vi_next().

Referenced by create_variable_info_for_1(), and intra_create_variable_infos().

◆ make_pass_build_alias()

gimple_opt_pass * make_pass_build_alias ( gcc::context * ctxt)

References ggc_alloc().

◆ make_pass_build_ealias()

gimple_opt_pass * make_pass_build_ealias ( gcc::context * ctxt)

References ggc_alloc().

◆ make_pass_ipa_pta()

simple_ipa_opt_pass * make_pass_ipa_pta ( gcc::context * ctxt)

References ggc_alloc().

◆ make_transitive_closure_constraints()

static void make_transitive_closure_constraints ( varinfo_t vi)
static
Add constraints to that the solution of VI is transitively closed.   

References DEREF, ggc_alloc(), new_constraint(), constraint_expr::offset, process_constraint(), SCALAR, constraint_expr::type, UNKNOWN_OFFSET, and constraint_expr::var.

Referenced by handle_call_arg().

◆ maybe_set_dependence_info()

static bool maybe_set_dependence_info ( gimple * ,
tree base,
tree ,
void * data )
static
If BASE is a MEM_REF then assign a clique, base pair to it, updating
CLIQUE, *RESTRICT_VAR and LAST_RUID as passed via DATA.
Return whether dependence info was assigned to BASE.   

References cfun, ggc_alloc(), MR_DEPENDENCE_BASE, MR_DEPENDENCE_CLIQUE, variable_info::ruid, TREE_CODE, and TREE_OPERAND.

Referenced by compute_dependence_clique().

◆ merge_graph_nodes()

static void merge_graph_nodes ( constraint_graph_t graph,
unsigned int to,
unsigned int from )
static
Merge GRAPH nodes FROM and TO into node TO.   

References BITMAP_ALLOC, bitmap_ior_into(), clear_edges_for_node(), and pta_obstack.

Referenced by unify_nodes().

◆ merge_node_constraints()

static bool merge_node_constraints ( constraint_graph_t graph,
unsigned int to,
unsigned int from )
static
Condense two variable nodes into a single variable node, by moving
all associated info from FROM to TO. Returns true if TO node's 
constraint set changes after the merge.   

References constraint_set_union(), DEREF, find(), FOR_EACH_VEC_ELT, gcc_checking_assert, ggc_alloc(), i, constraint::lhs, constraint::rhs, constraint_expr::type, and constraint_expr::var.

Referenced by unify_nodes().

◆ move_complex_constraints()

◆ new_constraint()

◆ new_scalar_tmp_constraint_exp()

static struct constraint_expr new_scalar_tmp_constraint_exp ( const char * name,
bool add_id )
static
Get a scalar constraint expression for a new temporary variable.   

References ggc_alloc(), new_var_info(), NULL_TREE, and SCALAR.

Referenced by do_deref(), process_all_all_constraints(), and process_constraint().

◆ new_var_info()

static varinfo_t new_var_info ( tree t,
const char * name,
bool add_id )
static
Return a new variable info structure consisting for a variable
named NAME, and using constraint graph node NODE.  Append it
to the vector of variable info structures.   

References BITMAP_ALLOC, DECL_HARD_REGISTER, DECL_P, dump_file, free(), ggc_alloc(), ggc_strdup, is_global_var(), NULL, NULL_TREE, pta_obstack, TREE_CODE, VAR_P, variable_info_pool, and varmap.

Referenced by create_function_info_for(), create_variable_info_for(), create_variable_info_for_1(), get_call_vi(), handle_call_arg(), handle_rhs_call(), init_base_vars(), make_heapvar(), and new_scalar_tmp_constraint_exp().

◆ perform_var_substitution()

◆ process_all_all_constraints()

static void process_all_all_constraints ( const vec< ce_s > & lhsc,
const vec< ce_s > & rhsc )
static
Efficiently generates constraints from all entries in *RHSC to all
entries in *LHSC.   

References FOR_EACH_VEC_ELT, ggc_alloc(), i, new_constraint(), new_scalar_tmp_constraint_exp(), and process_constraint().

Referenced by do_structure_copy(), find_func_aliases(), find_func_aliases_for_builtin_call(), and handle_lhs_call().

◆ process_constraint()

◆ process_ipa_clobber()

static void process_ipa_clobber ( varinfo_t fi,
tree ptr )
static
Create a constraint adding to the clobber set of FI the memory
pointed to by PTR.   

References fi_clobbers, FOR_EACH_VEC_ELT, get_constraint_for_rhs(), get_function_part_constraint(), ggc_alloc(), i, new_constraint(), process_constraint(), and vNULL.

Referenced by find_func_clobbers().

◆ pt_solution_empty_p()

◆ pt_solution_includes()

◆ pt_solution_includes_1()

static bool pt_solution_includes_1 ( struct pt_solution * pt,
const_tree decl )
static

◆ pt_solution_includes_const_pool()

bool pt_solution_includes_const_pool ( struct pt_solution * pt)
Return true if the points-to solution *PT contains a reference to a
constant pool entry.   

References cfun, pt_solution::const_pool, pt_solution::escaped, pt_solution::ipa_escaped, and ipa_escaped_pt.

Referenced by ptrs_compare_unequal().

◆ pt_solution_includes_global()

bool pt_solution_includes_global ( struct pt_solution * pt,
bool escaped_local_p )
Return true if the points-to solution *PT includes global memory.
If ESCAPED_LOCAL_P is true then escaped local variables are also
considered global.   

References pt_solution::anything, cfun, pt_solution::escaped, ggc_alloc(), pt_solution::ipa_escaped, ipa_escaped_pt, pt_solution::nonlocal, pt_solution_includes_global(), pt_solution::vars_contains_escaped, pt_solution::vars_contains_escaped_heap, and pt_solution::vars_contains_nonlocal.

Referenced by pt_solution_includes_global(), and ptr_deref_may_alias_global_p().

◆ pt_solution_ior_into()

static void pt_solution_ior_into ( struct pt_solution * dest,
struct pt_solution * src )
static
Computes the union of the points-to solutions *DEST and *SRC and
stores the result in *DEST.  This changes the points-to bitmap
of *DEST and thus may not be used if that might be shared.
The points-to bitmap of *SRC and *DEST will not be shared after
this function if they were not before.   

References pt_solution::anything, BITMAP_GGC_ALLOC, bitmap_ior_into(), pt_solution::const_pool, pt_solution::escaped, pt_solution::ipa_escaped, pt_solution::nonlocal, pt_solution::null, pt_solution_reset(), pt_solution::vars, pt_solution::vars_contains_escaped, pt_solution::vars_contains_escaped_heap, and pt_solution::vars_contains_nonlocal.

Referenced by ipa_pta_execute().

◆ pt_solution_reset()

void pt_solution_reset ( struct pt_solution * pt)
Reset the points-to solution *PT to a conservative default
(point to anything).   

References pt_solution::anything, ggc_alloc(), and pt_solution::null.

Referenced by delete_tree_ssa(), expand_call_inline(), get_ptr_info(), gimple_call_reset_alias_info(), init_tree_ssa(), ipa_pta_execute(), parallelize_loops(), and pt_solution_ior_into().

◆ pt_solution_set()

void pt_solution_set ( struct pt_solution * pt,
bitmap vars,
bool vars_contains_nonlocal )
Set the points-to solution *PT to point only to the variables
in VARS.  VARS_CONTAINS_GLOBAL specifies whether that contains
global variables and VARS_CONTAINS_RESTRICT specifies whether
it contains restrict tag variables.   

References bitmap_intersect_p(), cfun, ggc_alloc(), pt_solution::vars, pt_solution::vars_contains_escaped, and pt_solution::vars_contains_nonlocal.

Referenced by update_alias_info_with_stack_vars().

◆ pt_solution_set_var()

void pt_solution_set_var ( struct pt_solution * pt,
tree var )

◆ pt_solution_singleton_or_null_p()

bool pt_solution_singleton_or_null_p ( struct pt_solution * pt,
unsigned * uid )
Return true if the points-to solution *PT only point to a single var, and
return the var uid in *UID.   

References pt_solution::anything, bitmap_first_set_bit(), bitmap_single_bit_set_p(), pt_solution::escaped, pt_solution::ipa_escaped, pt_solution::nonlocal, NULL, and pt_solution::vars.

Referenced by fold_builtin_alloca_with_align(), and same_addr_size_stores_p().

◆ pt_solutions_intersect()

◆ pt_solutions_intersect_1()

static bool pt_solutions_intersect_1 ( struct pt_solution * pt1,
struct pt_solution * pt2 )
static
Return true if both points-to solutions PT1 and PT2 have a non-empty
intersection.   

References bitmap_intersect_p(), ggc_alloc(), ipa_escaped_pt, pt_solution_empty_p(), and pt_solutions_intersect_1().

Referenced by pt_solutions_intersect(), and pt_solutions_intersect_1().

◆ push_fields_onto_fieldstack()

static bool push_fields_onto_fieldstack ( tree type,
vec< fieldoff_s > * fieldstack,
HOST_WIDE_INT offset )
static
Given a TYPE, and a vector of field offsets FIELDSTACK, push all
the fields of TYPE onto fieldstack, recording their offsets along
the way.

OFFSET is used to keep track of the offset in this entire
structure, rather than just the immediately containing structure.
Returns false if the caller is supposed to handle the field we
recursed for.   

References bitpos_of_field(), DECL_CHAIN, DECL_SIZE, empty_p(), field_must_have_pointers(), field_type(), ggc_alloc(), fieldoff::has_unknown_size, integer_zerop(), fieldoff::may_have_pointers, fieldoff::must_have_pointers, NULL, NULL_TREE, offset, fieldoff::offset, fieldoff::only_restrict_pointers, POINTER_TYPE_P, push_fields_onto_fieldstack(), fieldoff::restrict_pointed_type, fieldoff::size, TREE_CODE, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, TYPE_FIELDS, TYPE_RESTRICT, and var_can_have_subvars().

Referenced by create_variable_info_for_1(), and push_fields_onto_fieldstack().

◆ refered_from_nonlocal_fn()

static bool refered_from_nonlocal_fn ( struct cgraph_node * node,
void * data )
static
Compute whether node is refered to non-locally.  Worker for
cgraph_for_symbol_thunks_and_aliases.   

References symtab_node::decl, DECL_ATTRIBUTES, DECL_EXTERNAL, symtab_node::force_output, ggc_alloc(), lookup_attribute(), TREE_PUBLIC, and symtab_node::used_from_other_partition.

Referenced by ipa_pta_execute().

◆ refered_from_nonlocal_var()

static bool refered_from_nonlocal_var ( struct varpool_node * node,
void * data )
static

◆ remove_preds_and_fake_succs()

static void remove_preds_and_fake_succs ( constraint_graph_t graph)
static
Remove the REF and ADDRESS edges from GRAPH, as well as all the
predecessor edges.   

References bitmap_clear_range(), BITMAP_FREE, bitmap_obstack_release(), FIRST_REF_NODE, free(), ggc_alloc(), i, NULL, predbitmap_obstack, and varmap.

Referenced by solve_constraints().

◆ rewrite_constraints()

static void rewrite_constraints ( constraint_graph_t graph,
class scc_info * si )
static
Optimize and rewrite complex constraints while performing
collapsing of equivalent nodes.  SI is the SCC_INFO that is the
result of perform_variable_substitution.   

References constraints, dump_constraint(), dump_file, dump_flags, find(), find_equivalent_node(), FOR_EACH_VEC_ELT, gcc_assert, get_varinfo(), ggc_alloc(), i, constraint::lhs, variable_info::name, NULL, constraint::rhs, si, TDF_DETAILS, and constraint_expr::var.

Referenced by solve_constraints().

◆ scc_visit()

static void scc_visit ( constraint_graph_t graph,
class scc_info * si,
unsigned int n )
static
Recursive routine to find strongly connected components in GRAPH.
SI is the SCC info to store the information in, and N is the id of current
graph node we are processing.

This is Tarjan's strongly connected component finding algorithm, as
modified by Nuutila to keep only non-root nodes on the stack.
The algorithm can be found in "On finding the strongly connected
connected components in a directed graph" by Esko Nuutila and Eljas
Soisalon-Soininen, in Information Processing Letters volume 49,
number 1, pages 9-14.   

References BITMAP_ALLOC, bitmap_bit_p, bitmap_first_set_bit(), bitmap_set_bit, EXECUTE_IF_IN_NONNULL_BITMAP, EXECUTE_IF_SET_IN_BITMAP, find(), FIRST_REF_NODE, gcc_assert, gcc_checking_assert, ggc_alloc(), i, LAST_REF_NODE, NULL, scc_visit(), si, unify_nodes(), and unite().

Referenced by find_indirect_cycles(), and scc_visit().

◆ set_uids_in_ptset()

◆ set_union_with_increment()

static bool set_union_with_increment ( bitmap to,
bitmap delta,
HOST_WIDE_INT inc,
bitmap * expanded_delta )
static
Union solution sets TO and DELTA, and add INC to each member of DELTA in the
process.   

References anything_id, bitmap_bit_p, bitmap_ior_into(), bitmap_set_bit, changed, EXECUTE_IF_SET_IN_BITMAP, first_or_preceding_vi_for_offset(), get_varinfo(), ggc_alloc(), i, solution_set_expand(), UNKNOWN_OFFSET, and vi_next().

Referenced by do_complex_constraint().

◆ shared_bitmap_add()

static void shared_bitmap_add ( bitmap pt_vars)
static
Add a bitmap to the shared bitmap hashtable.   

References bitmap_hash(), gcc_assert, ggc_alloc(), shared_bitmap_info::pt_vars, and shared_bitmap_table.

Referenced by find_what_var_points_to().

◆ shared_bitmap_lookup()

static bitmap shared_bitmap_lookup ( bitmap pt_vars)
static
Lookup a bitmap in the shared bitmap hashtable, and return an already
existing instance if there is one, NULL otherwise.   

References bitmap_hash(), ggc_alloc(), NULL, shared_bitmap_info::pt_vars, and shared_bitmap_table.

Referenced by find_what_var_points_to().

◆ solution_set_expand()

◆ solve_add_graph_edge()

static bool solve_add_graph_edge ( constraint_graph_t graph,
unsigned int to,
unsigned int from )
static
Add a copy edge FROM -> TO, optimizing special cases.  Returns TRUE
if the solution of TO changed.   

References add_graph_edge(), bitmap_ior_into(), bitmap_set_bit, escaped_id, find(), and get_varinfo().

Referenced by do_ds_constraint(), and do_sd_constraint().

◆ solve_constraints()

◆ solve_graph()

static void solve_graph ( constraint_graph_t graph)
static
Solve the constraint graph GRAPH using our worklist solver.
This is based on the PW* family of solvers from the "Efficient Field
Sensitive Pointer Analysis for C" paper.
It works by iterating over all the graph nodes, processing the complex
constraints and propagating the copy constraints, until everything stops
changed.  This corresponds to steps 6-8 in the solving list given above.   

References anything_id, BITMAP_ALLOC, bitmap_and_compl(), bitmap_bit_p, bitmap_clear_bit(), bitmap_copy(), bitmap_empty_p(), BITMAP_FREE, bitmap_ior_into(), bitmap_obstack_initialize(), bitmap_obstack_release(), bitmap_set_bit, changed, compute_topo_order(), DEREF, do_complex_constraint(), eliminate_indirect_cycles(), escaped_id, EXECUTE_IF_IN_NONNULL_BITMAP, find(), FOR_EACH_VEC_ELT, get_varinfo(), ggc_alloc(), i, iteration_obstack, constraint::lhs, NULL, oldpta_obstack, pta_obstack, constraint::rhs, constraint_expr::type, and constraint_expr::var.

Referenced by solve_constraints().

◆ sort_fieldstack()

static void sort_fieldstack ( vec< fieldoff_s > & fieldstack)
static
Sort a fieldstack according to the field offset and sizes.   

References fieldoff_compare(), and ggc_alloc().

Referenced by create_variable_info_for_1().

◆ topo_visit()

static void topo_visit ( constraint_graph_t graph,
vec< unsigned > & topo_order,
sbitmap visited,
unsigned int n )
static
Visit the graph in topological order starting at node N, and store the
order in TOPO_ORDER using VISITED to indicate visited nodes.   

References bitmap_bit_p, bitmap_set_bit, EXECUTE_IF_SET_IN_BITMAP, find(), ggc_alloc(), topo_visit(), and visited.

Referenced by compute_topo_order(), and topo_visit().

◆ type_can_have_subvars()

static bool type_can_have_subvars ( const_tree t)
inlinestatic
Return true if T is a type that can have subvars.   

References ggc_alloc(), and TREE_CODE.

Referenced by get_constraint_for_1(), and var_can_have_subvars().

◆ type_must_have_pointers()

static bool type_must_have_pointers ( tree type)
static
Return true if T is a type that does contain pointers.   

References FUNC_OR_METHOD_TYPE_P, ggc_alloc(), POINTER_TYPE_P, TREE_CODE, TREE_TYPE, and type_must_have_pointers().

Referenced by field_must_have_pointers(), and type_must_have_pointers().

◆ unify_nodes()

static void unify_nodes ( constraint_graph_t graph,
unsigned int to,
unsigned int from,
bool update_changed )
static

◆ unite()

static bool unite ( unsigned int to,
unsigned int from )
static
Union the TO and FROM nodes to the TO nodes.
Note that at some point in the future, we may want to do
union-by-rank, in which case we are going to have to return the
node we unified to.   

References gcc_checking_assert, and ggc_alloc().

Referenced by eliminate_indirect_cycles(), find_equivalent_node(), scc_visit(), and unite_pointer_equivalences().

◆ unite_pointer_equivalences()

static void unite_pointer_equivalences ( constraint_graph_t graph)
static
Unite pointer equivalent but not location equivalent nodes in
GRAPH.  This may only be performed once variable substitution is
finished.   

References find(), FIRST_REF_NODE, ggc_alloc(), i, unify_nodes(), and unite().

Referenced by solve_constraints().

◆ var_can_have_subvars()

static bool var_can_have_subvars ( const_tree v)
inlinestatic
Return true if V is a tree that we can have subvars for.
Normally, this is any aggregate type.  Also complex
types which are not gimple registers can have subvars.   

References DECL_P, TREE_THIS_VOLATILE, TREE_TYPE, and type_can_have_subvars().

Referenced by create_variable_info_for_1(), and push_fields_onto_fieldstack().

◆ vi_next()

◆ visit_loadstore()

Variable Documentation

◆ call_stmt_vars

hash_map<gimple *, varinfo_t>* call_stmt_vars
static
A map mapping call statements to per-stmt variables for uses
and clobbers specific to the call.   

Referenced by delete_points_to_sets(), get_call_vi(), init_alias_vars(), and lookup_call_use_vi().

◆ changed

bitmap changed
static
Changed variables on the last iteration.   

Referenced by cgraph_node::add_detected_attribute(), add_detected_attribute_1(), add_scope_conflicts(), autofdo::afdo_propagate(), autofdo::afdo_propagate_edge(), analyze_functions(), bitmap_and(), bitmap_and_compl(), bitmap_and_compl_into(), bitmap_and_into(), bitmap_and_or(), bitmap_elt_copy(), bitmap_elt_ior(), bitmap_ior(), bitmap_ior(), bitmap_ior_and_compl(), bitmap_ior_and_compl(), bitmap_ior_and_compl_into(), bitmap_ior_and_into(), bitmap_ior_into(), bitmap_ior_into_and_free(), bitmap_or_and(), bitmap_xor(), bypass_conditional_jumps(), canonicalize_induction_variables(), change_zero_ext(), cleanup_all_empty_eh(), cleanup_cfg(), cleanup_subreg_operands(), cleanup_tree_cfg(), cleanup_tree_cfg_noloop(), frange::combine_zeros(), compute_antic(), compute_antic_aux(), compute_bb_dataflow(), compute_code_hoist_vbeinout(), compute_live_vars(), copyprop_hardreg_forward_1(), cprop_insn(), cse_extended_basic_block(), dataflow_set_preserve_mem_locs(), dataflow_set_remove_mem_locs(), default_goacc_validate_dims(), defs_to_varying(), delete_slot_part(), delete_unreachable_blocks(), delete_unreachable_blocks_update_callgraph(), df_compute_regs_ever_live(), df_lr_confluence_n(), df_rd_confluence_n(), df_rd_transfer_function(), df_update_entry_block_defs(), df_update_exit_block_uses(), df_word_lr_mark_ref(), df_word_lr_simulate_defs(), df_worklist_dataflow_doublequeue(), df_worklist_propagate_backward(), df_worklist_propagate_forward(), loop_distribution::distribute_loop(), do_complex_constraint(), do_ds_constraint(), do_sd_constraint(), drop_overlapping_mem_locs(), duplicate_computed_gotos(), loop_distribution::execute(), execute_cleanup_eh_1(), execute_early_expand_coro_ifns(), execute_rtl_cprop(), execute_rtl_hoist(), execute_rtl_pre(), execute_split_paths(), expand_omp_target(), expand_omp_taskreg(), fini_copy_prop(), fixup_noreturn_call(), fold_rtx(), ccp_folder::fold_stmt(), fold_stmt_1(), fold_stmt_inplace(), gimple_fold_call(), gimple_purge_all_dead_abnormal_call_edges(), gimple_purge_all_dead_eh_edges(), gimple_purge_dead_abnormal_call_edges(), gimple_purge_dead_eh_edges(), gimple_value_profile_transformations(), gimplify_modify_expr_rhs(), gimplify_size_expressions(), graphds_domtree(), group_case_labels(), hoist_code(), hoist_memory_references(), init_alias_analysis(), modref_tree< T >::insert(), insert(), modref_tree< T >::insert_base(), modref_base_node< T >::insert_ref(), instantiate_virtual_regs_in_rtx(), frange::intersect(), ipa_propagate_frequency(), ipa_propagate_indirect_call_infos(), local_cprop_pass(), match_asm_constraints_1(), maybe_duplicate_computed_goto(), maybe_fold_tmr(), mention_regs(), modref_tree< T >::merge(), move2add_use_add2_insn(), move2add_use_add3_insn(), oacc_entry_exit_ok(), oacc_entry_exit_single_gang(), oacc_validate_dims(), object_sizes_set(), one_code_hoisting_pass(), one_cprop_pass(), one_pre_gcse_pass(), output_address(), output_min_issue_delay_table(), symbol_table::output_variables(), parallelize_loops(), phi_translate_1(), pre_delete(), pre_gcse(), gimple_ranger::prefill_stmt_dependencies(), propagate_malloc(), propagate_with_phi(), gimple_ranger::range_of_stmt(), recog_for_combine(), reload_cse_move2add(), remove_exits_and_undefined_stmts(), remove_redundant_iv_tests(), symbol_table::remove_unreachable_nodes(), replace_oldest_value_addr(), rewrite_expr_tree(), cgraph_node::set_const_flag(), set_const_flag_1(), ranger_cache::set_global_range(), cgraph_node::set_malloc_flag(), set_malloc_flag_1(), cgraph_node::set_noreturn_flag(), set_noreturn_flag_1(), cgraph_node::set_nothrow_flag(), set_nothrow_flag_1(), set_parm_default_def_partition(), set_parm_rtl(), set_union_with_increment(), predicate::simplify(), simplify_comparison(), simplify_loop_version(), simplify_context::simplify_plus_minus(), simplify_using_outer_evolutions(), solve_graph(), split_all_insns(), split_loop(), split_paths(), strip_predict_hints(), tail_duplicate(), back_threader::thread_blocks(), tm_memopt_compute_available(), transform_add_to_multiply(), tree_optimize_tail_calls_1(), tree_predictive_commoning(), tree_simplify_using_condition_1(), tree_ssa_iv_optimize_loop(), tree_ssa_split_loops(), tree_unroll_loops_completely(), tree_unroll_loops_completely_1(), tree_unswitch_outer_loop(), tree_unswitch_single_loop(), try_crossjump_bb(), try_forward_edges(), try_head_merge_bb(), try_optimize_cfg(), undistribute_ops_list(), unify_nodes(), frange::union_(), frange::union_nans(), unroll_loops(), unsplit_all_eh(), unsplit_eh_edges(), visit_nary_op(), visit_reference_op_call(), visit_reference_op_load(), visit_reference_op_store(), visit_stmt(), vn_reference_maybe_forwprop_address(), vt_find_locations(), and walk_alter_subreg().

◆ constraint_pool

object_allocator< constraint > constraint_pool("Constraint pool") ( "Constraint pool" )
static

◆ constraints

◆ equiv_class_obstack

◆ fake_var_decl_obstack

struct obstack fake_var_decl_obstack
Temporary storage for fake var decls.   

Referenced by build_fake_var_decl(), delete_points_to_sets(), and init_alias_vars().

◆ final_solutions

hash_map<varinfo_t, pt_solution *>* final_solutions
static
Map varinfo to final pt_solution.   

Referenced by delete_points_to_sets(), find_what_var_points_to(), init_alias_vars(), and ipa_pta_execute().

◆ final_solutions_obstack

◆ graph

◆ in_ipa_mode

◆ ipa_escaped_pt

struct pt_solution ipa_escaped_pt
Initial value:
= { true, false, false, false, false, false,
false, false, false, false, false, NULL }
#define NULL
Definition system.h:50
IPA PTA solutions for ESCAPED.   

Referenced by ipa_pta_execute(), pt_solution_empty_p(), pt_solution_includes_1(), pt_solution_includes_const_pool(), pt_solution_includes_global(), and pt_solutions_intersect_1().

◆ iteration_obstack

bitmap_obstack iteration_obstack
static
Used for per-solver-iteration bitmaps.   

Referenced by free_var_substitution_info(), perform_var_substitution(), solution_set_expand(), and solve_graph().

◆ location_equiv_class

int location_equiv_class
static
Current maximum location equivalence class id.   

Referenced by perform_var_substitution().

◆ location_equiv_class_table

hash_table<equiv_class_hasher>* location_equiv_class_table
static
A hashtable for mapping a bitmap of labels->location equivalence
classes.   

Referenced by free_var_substitution_info(), and perform_var_substitution().

◆ oldpta_obstack

bitmap_obstack oldpta_obstack
static
Used for oldsolution members of variables.  

Referenced by init_alias_vars(), and solve_graph().

◆ pointer_equiv_class

int pointer_equiv_class
static
Perform offline variable substitution.

This is a worst case quadratic time way of identifying variables
that must have equivalent points-to sets, including those caused by
static cycles, and single entry subgraphs, in the constraint graph.

The technique is described in "Exploiting Pointer and Location
Equivalence to Optimize Pointer Analysis. In the 14th International
Static Analysis Symposium (SAS), August 2007."  It is known as the
"HU" algorithm, and is equivalent to value numbering the collapsed
constraint graph including evaluating unions.

The general method of finding equivalence classes is as follows:
Add fake nodes (REF nodes) and edges for *a = b and a = *b constraints.
Initialize all non-REF nodes to be direct nodes.
For each constraint a = a U {b}, we set pts(a) = pts(a) u {fresh
variable}
For each constraint containing the dereference, we also do the same
thing.

We then compute SCC's in the graph and unify nodes in the same SCC,
including pts sets.

For each non-collapsed node x:
 Visit all unvisited explicit incoming edges.
 Ignoring all non-pointers, set pts(x) = Union of pts(a) for y
 where y->x.
 Lookup the equivalence class for pts(x).
  If we found one, equivalence_class(x) = found class.
  Otherwise, equivalence_class(x) = new class, and new_class is
 added to the lookup table.

All direct nodes with the same equivalence class can be replaced
with a single representative node.
All unlabeled nodes (label == 0) are not pointers and all edges
involving them can be eliminated.
We perform these optimizations during rewrite_constraints

In addition to pointer equivalence class finding, we also perform
location equivalence class finding.  This is the set of variables
that always appear together in points-to sets.  We use this to
compress the size of the points-to sets.   
Current maximum pointer equivalence class id.   

Referenced by label_visit(), and perform_var_substitution().

◆ pointer_equiv_class_table

hash_table<equiv_class_hasher>* pointer_equiv_class_table
static
A hashtable for mapping a bitmap of labels->pointer equivalence
classes.   

Referenced by free_var_substitution_info(), label_visit(), and perform_var_substitution().

◆ predbitmap_obstack

◆ pt_solution_includes_may_alias

unsigned HOST_WIDE_INT pt_solution_includes_may_alias

◆ pt_solution_includes_no_alias

unsigned HOST_WIDE_INT pt_solution_includes_no_alias

◆ pt_solutions_intersect_may_alias

unsigned HOST_WIDE_INT pt_solutions_intersect_may_alias

◆ pt_solutions_intersect_no_alias

unsigned HOST_WIDE_INT pt_solutions_intersect_no_alias

◆ pta_obstack

◆ [struct]

struct { ... } pta_stats
Query statistics for points-to solutions.   

Referenced by dump_pta_stats(), pt_solution_includes(), and pt_solutions_intersect().

◆ shared_bitmap_table

hash_table<shared_bitmap_hasher>* shared_bitmap_table
static

◆ stats

struct constraint_stats stats
static

◆ use_field_sensitive

bool use_field_sensitive = true
static
Tree based points-to analysis
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, 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/>.   
The idea behind this analyzer is to generate set constraints from the
 program, then solve the resulting constraints in order to generate the
 points-to sets.

 Set constraints are a way of modeling program analysis problems that
 involve sets.  They consist of an inclusion constraint language,
 describing the variables (each variable is a set) and operations that
 are involved on the variables, and a set of rules that derive facts
 from these operations.  To solve a system of set constraints, you derive
 all possible facts under the rules, which gives you the correct sets
 as a consequence.

 See  "Efficient Field-sensitive pointer analysis for C" by "David
 J. Pearce and Paul H. J. Kelly and Chris Hankin", at
 http://citeseer.ist.psu.edu/pearce04efficient.html

 Also see "Ultra-fast Aliasing Analysis using CLA: A Million Lines
 of C Code in a Second" by "Nevin Heintze and Olivier Tardieu" at
 http://citeseer.ist.psu.edu/heintze01ultrafast.html

 There are three types of real constraint expressions, DEREF,
 ADDRESSOF, and SCALAR.  Each constraint expression consists
 of a constraint type, a variable, and an offset.

 SCALAR is a constraint expression type used to represent x, whether
 it appears on the LHS or the RHS of a statement.
 DEREF is a constraint expression type used to represent *x, whether
 it appears on the LHS or the RHS of a statement.
 ADDRESSOF is a constraint expression used to represent &x, whether
 it appears on the LHS or the RHS of a statement.

 Each pointer variable in the program is assigned an integer id, and
 each field of a structure variable is assigned an integer id as well.

 Structure variables are linked to their list of fields through a "next
 field" in each variable that points to the next field in offset
 order.
 Each variable for a structure field has

 1. "size", that tells the size in bits of that field.
 2. "fullsize", that tells the size in bits of the entire structure.
 3. "offset", that tells the offset in bits from the beginning of the
 structure to this field.

 Thus,
 struct f
 {
   int a;
   int b;
 } foo;
 int *bar;

 looks like

 foo.a -> id 1, size 32, offset 0, fullsize 64, next foo.b
 foo.b -> id 2, size 32, offset 32, fullsize 64, next NULL
 bar -> id 3, size 32, offset 0, fullsize 32, next NULL


In order to solve the system of set constraints, the following is
done:

1. Each constraint variable x has a solution set associated with it,
Sol(x).

2. Constraints are separated into direct, copy, and complex.
Direct constraints are ADDRESSOF constraints that require no extra
processing, such as P = &Q
Copy constraints are those of the form P = Q.
Complex constraints are all the constraints involving dereferences
and offsets (including offsetted copies).

3. All direct constraints of the form P = &Q are processed, such
that Q is added to Sol(P)

4. All complex constraints for a given constraint variable are stored in a
linked list attached to that variable's node.

5. A directed graph is built out of the copy constraints. Each
constraint variable is a node in the graph, and an edge from
Q to P is added for each copy constraint of the form P = Q

6. The graph is then walked, and solution sets are
propagated along the copy edges, such that an edge from Q to P
causes Sol(P) <- Sol(P) union Sol(Q).

7.  As we visit each node, all complex constraints associated with
that node are processed by adding appropriate copy edges to the graph, or the
appropriate variables to the solution set.

8. The process of walking the graph is iterated until no solution
sets change.

Prior to walking the graph in steps 6 and 7, We perform static
cycle elimination on the constraint graph, as well
as off-line variable substitution.

TODO: Adding offsets to pointer-to-structures can be handled (IE not punted
on and turned into anything), but isn't.  You can just see what offset
inside the pointed-to struct it's going to access.

TODO: Constant bounded arrays can be handled as if they were structs of the
same number of elements.

TODO: Modeling heap and incoming pointers becomes much better if we
add fields to them as we discover them, which we could do.

TODO: We could handle unions, but to be honest, it's probably not
worth the pain or slowdown.   
IPA-PTA optimizations possible.

When the indirect function called is ANYTHING we can add disambiguation
based on the function signatures (or simply the parameter count which
is the varinfo size).  We also do not need to consider functions that
do not have their address taken.

The is_global_var bit which marks escape points is overly conservative
in IPA mode.  Split it to is_escape_point and is_global_var - only
externally visible globals are escape points in IPA mode.
There is now is_ipa_escape_point but this is only used in a few
selected places.

The way we introduce DECL_PT_UID to avoid fixing up all points-to
sets in the translation unit when we copy a DECL during inlining
pessimizes precision.  The advantage is that the DECL_PT_UID keeps
compile-time and memory usage overhead low - the points-to sets
do not grow or get unshared as they would during a fixup phase.
An alternative solution is to delay IPA PTA until after all
inlining transformations have been applied.

The way we propagate clobber/use information isn't optimized.
It should use a new complex constraint that properly filters
out local variables of the callee (though that would make
the sets invalid after inlining).  OTOH we might as well
admit defeat to WHOPR and simply do all the clobber/use analysis
and propagation after PTA finished but before we threw away
points-to information for memory variables.  WHOPR and PTA
do not play along well anyway - the whole constraint solving
would need to be done in WPA phase and it will be very interesting
to apply the results to local SSA names during LTRANS phase.

We probably should compute a per-function unit-ESCAPE solution
propagating it simply like the clobber / uses solutions.  The
solution can go alongside the non-IPA escaped solution and be
used to query which vars escape the unit through a function.
This is also required to make the escaped-HEAP trick work in IPA mode.

We never put function decls in points-to sets so we do not
keep the set of called functions for indirect calls.

And probably more.   

Referenced by create_variable_info_for_1(), get_constraint_for_ptr_offset(), and init_alias_vars().

◆ variable_info_pool

object_allocator< variable_info > variable_info_pool("Variable info pool") ( "Variable info pool" )
static
Pool of variable info structures.   

Referenced by delete_points_to_sets(), and new_var_info().

◆ varmap

vec<varinfo_t> varmap
static

◆ vi_for_tree

hash_map<tree, varinfo_t>* vi_for_tree
static