GCC Middle and Back End API Reference
pointer_analysis Namespace Reference

Data Structures

struct  constraint
struct  constraint_expr
struct  constraint_stats
struct  variable_info

Typedefs

typedef struct constraint_expr ce_s
typedef struct constraintconstraint_t
typedef struct variable_infovarinfo_t

Enumerations

enum  constraint_expr_type { SCALAR , DEREF , ADDRESSOF }
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  {
  fi_clobbers = 1 , fi_uses = 2 , fi_static_chain = 3 , fi_result = 4 ,
  fi_parm_base = 5
}

Functions

varinfo_t lookup_vi_for_tree (tree t)
varinfo_t lookup_call_use_vi (gcall *call)
varinfo_t lookup_call_clobber_vi (gcall *call)
varinfo_t get_fi_for_callee (gcall *call)
void init_constraint_builder (void)
void delete_constraint_builder (void)
void intra_build_constraints (void)
void ipa_build_constraints (void)
void solve_constraints (void)
varinfo_t first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
varinfo_t first_or_preceding_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
void determine_global_memory_access (gcall *stmt, bool *writes_global_memory, bool *reads_global_memory, bool *uses_global_memory)
bool fndecl_maybe_in_other_partition (tree fndecl)
varinfo_t new_var_info (tree t, const char *name, bool add_id)
void dump_constraint (FILE *file, constraint_t c)
DEBUG_FUNCTION void debug_constraint (constraint_t c)
void dump_constraints (FILE *file, int from)
DEBUG_FUNCTION void debug_constraints (void)
void dump_solution_for_var (FILE *file, unsigned int var)
DEBUG_FUNCTION void debug_solution_for_var (unsigned int var)
void dump_sa_stats (FILE *outfile)
void dump_sa_points_to_info (FILE *outfile)
DEBUG_FUNCTION void debug_sa_points_to_info (void)
void dump_varinfo (FILE *file, varinfo_t vi)
DEBUG_FUNCTION void debug_varinfo (varinfo_t vi)
void dump_varmap (FILE *file)
DEBUG_FUNCTION void debug_varmap (void)
varinfo_t get_varinfo (unsigned int n)
varinfo_t vi_next (varinfo_t vi)

Variables

bool use_field_sensitive = true
int in_ipa_mode = 0
bitmap_obstack pta_obstack
bitmap_obstack oldpta_obstack
vec< varinfo_tvarmap
vec< constraint_tconstraints
unsigned int * var_rep
struct constraint_stats stats

Detailed Description

Constraint builder for tree based points-to analysis
Copyright (C) 2005-2025 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/>.   
Andersen-style solver for tree based points-to analysis
Copyright (C) 2005-2025 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/>.   
Tree based points-to analysis
Copyright (C) 2005-2025 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/>.   
NOTE: This file declares the internal interface of the points-to analyzer.
Outward-facing function declarations can be found in tree-ssa-alias.h.   

Typedef Documentation

◆ ce_s

◆ constraint_t

◆ varinfo_t

Enumeration Type Documentation

◆ anonymous enum

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

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

◆ debug_constraint()

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

References dump_constraint().

◆ debug_constraints()

void pointer_analysis::debug_constraints ( void )
Print out all constraints to stderr.   

References dump_constraints().

◆ debug_sa_points_to_info()

void pointer_analysis::debug_sa_points_to_info ( void )
Debug points-to information to stderr.   

References dump_sa_points_to_info().

◆ debug_solution_for_var()

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

References dump_solution_for_var().

◆ debug_varinfo()

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

References dump_varinfo().

◆ debug_varmap()

void pointer_analysis::debug_varmap ( void )
Dump varmap to stderr.   

References dump_varmap().

◆ delete_constraint_builder()

void pointer_analysis::delete_constraint_builder ( void )
Deallocate constraint builder globals.   

References call_stmt_vars, constraint_pool, fake_var_decl_obstack, NULL, and vi_for_tree.

Referenced by delete_points_to_sets().

◆ determine_global_memory_access()

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

◆ dump_constraint()

void pointer_analysis::dump_constraint ( FILE * file,
constraint_t c )

◆ dump_constraints()

void pointer_analysis::dump_constraints ( FILE * file,
int from )

◆ dump_sa_points_to_info()

void pointer_analysis::dump_sa_points_to_info ( FILE * outfile)

◆ dump_sa_stats()

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

References stats.

Referenced by compute_points_to_sets(), and ipa_pta_execute().

◆ dump_solution_for_var()

void pointer_analysis::dump_solution_for_var ( FILE * file,
unsigned int var )

◆ dump_varinfo()

◆ dump_varmap()

void pointer_analysis::dump_varmap ( FILE * file)
Dump varmap to FILE.   

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

Referenced by debug_varmap().

◆ first_or_preceding_vi_for_offset()

varinfo_t pointer_analysis::first_or_preceding_vi_for_offset ( varinfo_t start,
unsigned HOST_WIDE_INT offset )
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(), 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()

varinfo_t pointer_analysis::first_vi_for_offset ( varinfo_t start,
unsigned HOST_WIDE_INT offset )
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, 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()

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

References cgraph_node::get(), symtab_node::in_other_partition, and NULL.

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

◆ get_fi_for_callee()

varinfo_t pointer_analysis::get_fi_for_callee ( gcall * call)

◆ get_varinfo()

◆ init_constraint_builder()

void pointer_analysis::init_constraint_builder ( void )
Initialize constraint builder.   

References call_stmt_vars, fake_var_decl_obstack, gcc_obstack_init, init_base_vars(), and vi_for_tree.

Referenced by init_alias_vars().

◆ intra_build_constraints()

void pointer_analysis::intra_build_constraints ( void )

◆ ipa_build_constraints()

◆ lookup_call_clobber_vi()

varinfo_t pointer_analysis::lookup_call_clobber_vi ( gcall * call)
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()

varinfo_t pointer_analysis::lookup_call_use_vi ( gcall * call)
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, and NULL.

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

◆ lookup_vi_for_tree()

varinfo_t pointer_analysis::lookup_vi_for_tree ( tree t)
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().

◆ new_var_info()

varinfo_t pointer_analysis::new_var_info ( tree t,
const char * name,
bool add_id )
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 pointer_analysis::variable_info::address_taken, BITMAP_ALLOC, pointer_analysis::variable_info::decl, DECL_HARD_REGISTER, DECL_P, dump_file, free(), ggc_strdup, pointer_analysis::variable_info::head, pointer_analysis::variable_info::id, pointer_analysis::variable_info::is_artificial_var, pointer_analysis::variable_info::is_fn_info, pointer_analysis::variable_info::is_full_var, is_global_var(), pointer_analysis::variable_info::is_global_var, pointer_analysis::variable_info::is_heap_var, pointer_analysis::variable_info::is_ipa_escape_point, pointer_analysis::variable_info::is_reg_var, pointer_analysis::variable_info::is_restrict_var, pointer_analysis::variable_info::is_special_var, pointer_analysis::variable_info::is_unknown_size_var, pointer_analysis::variable_info::may_have_pointers, pointer_analysis::variable_info::name, pointer_analysis::variable_info::next, NULL, NULL_TREE, pointer_analysis::variable_info::oldsolution, pointer_analysis::variable_info::only_restrict_pointers, pta_obstack, pointer_analysis::variable_info::ruid, pointer_analysis::variable_info::shadow_var_uid, pointer_analysis::variable_info::solution, stats, 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().

◆ solve_constraints()

◆ vi_next()

Variable Documentation

◆ constraints

◆ in_ipa_mode

◆ oldpta_obstack

bitmap_obstack pointer_analysis::oldpta_obstack
Used for oldsolution members of variables.   

Referenced by init_alias_vars(), and solve_graph().

◆ pta_obstack

bitmap_obstack pointer_analysis::pta_obstack

◆ stats

struct constraint_stats pointer_analysis::stats

Referenced by dump_sa_stats(), and new_var_info().

◆ use_field_sensitive

bool pointer_analysis::use_field_sensitive = true

◆ var_rep

unsigned int * pointer_analysis::var_rep
The representative variable for a variable.  The points-to solution for a
var can be found in its rep.  Trivially, a var can be its own rep.

The solver provides this array once it is done solving.   

Referenced by compute_dependence_clique(), delete_points_to_sets(), dump_solution_for_var(), find_what_var_points_to(), ipa_pta_execute(), set_uids_in_ptset(), solve_constraints(), and visit_loadstore().

◆ varmap

vec< varinfo_t > pointer_analysis::varmap