1 /* Tree based alias analysis and alias oracle.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Contributed by Richard Guenther <rguenther@suse.de>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef TREE_SSA_ALIAS_H
22 #define TREE_SSA_ALIAS_H
24 #include "coretypes.h"
27 /* The reasons a variable may escape a function. */
30 NO_ESCAPE = 0, /* Doesn't escape. */
31 ESCAPE_STORED_IN_GLOBAL = 1 << 0,
32 ESCAPE_TO_ASM = 1 << 1, /* Passed by address to an assembly
34 ESCAPE_TO_CALL = 1 << 2, /* Escapes to a function call. */
35 ESCAPE_BAD_CAST = 1 << 3, /* Cast from pointer to integer */
36 ESCAPE_TO_RETURN = 1 << 4, /* Returned from function. */
37 ESCAPE_TO_PURE_CONST = 1 << 5, /* Escapes to a pure or constant
39 ESCAPE_IS_GLOBAL = 1 << 6, /* Is a global variable. */
40 ESCAPE_IS_PARM = 1 << 7, /* Is an incoming function argument. */
41 ESCAPE_UNKNOWN = 1 << 8 /* We believe it escapes for
42 some reason not enumerated
47 /* The points-to solution.
49 The points-to solution is a union of pt_vars and the abstract
50 sets specified by the flags. */
51 struct GTY(()) pt_solution
53 /* Nonzero if points-to analysis couldn't determine where this pointer
55 unsigned int anything : 1;
57 /* Nonzero if the points-to set includes any global memory. Note that
58 even if this is zero pt_vars can still include global variables. */
59 unsigned int nonlocal : 1;
61 /* Nonzero if the points-to set includes any escaped local variable. */
62 unsigned int escaped : 1;
64 /* Nonzero if the points-to set includes 'nothing', the points-to set
65 includes memory at address NULL. */
66 unsigned int null : 1;
69 /* Nonzero if the pt_vars bitmap includes a global variable. */
70 unsigned int vars_contains_global : 1;
72 /* Set of variables that this pointer may point to. */
77 /* Simplified and cached information about a memory reference tree.
78 Used by the alias-oracle internally and externally in alternate
80 typedef struct ao_ref_s
82 /* The original full memory reference tree or NULL_TREE if that is
86 /* The following fields are the decomposed reference as returned
87 by get_ref_base_and_extent. */
88 /* The base object of the memory reference or NULL_TREE if all of
89 the following fields are not yet computed. */
91 /* The offset relative to the base. */
93 /* The size of the access. */
95 /* The maximum possible extent of the access or -1 if unconstrained. */
96 HOST_WIDE_INT max_size;
98 /* The alias set of the access or -1 if not yet computed. */
99 alias_set_type ref_alias_set;
101 /* The alias set of the base object or -1 if not yet computed. */
102 alias_set_type base_alias_set;
106 /* In tree-ssa-alias.c */
107 extern void ao_ref_init (ao_ref *, tree);
108 extern tree ao_ref_base (ao_ref *);
109 extern alias_set_type ao_ref_alias_set (ao_ref *);
110 extern enum escape_type is_escape_site (gimple);
111 extern bool ptr_deref_may_alias_global_p (tree);
112 extern bool refs_may_alias_p (tree, tree);
113 extern bool refs_anti_dependent_p (tree, tree);
114 extern bool refs_output_dependent_p (tree, tree);
115 extern bool ref_maybe_used_by_stmt_p (gimple, tree);
116 extern bool stmt_may_clobber_ref_p (gimple, tree);
117 extern bool stmt_may_clobber_ref_p_1 (gimple, ao_ref *);
118 extern void *walk_non_aliased_vuses (ao_ref *, tree,
119 void *(*)(ao_ref *, tree, void *),
120 void *(*)(ao_ref *, tree, void *), void *);
121 extern unsigned int walk_aliased_vdefs (tree, tree,
122 bool (*)(tree, tree, void *), void *,
124 extern struct ptr_info_def *get_ptr_info (tree);
125 extern void dump_alias_info (FILE *);
126 extern void debug_alias_info (void);
127 extern void dump_points_to_solution (FILE *, struct pt_solution *);
128 extern void dump_points_to_info_for (FILE *, tree);
129 extern void debug_points_to_info_for (tree);
130 extern void dump_alias_stats (FILE *);
133 /* In tree-ssa-structalias.c */
134 extern unsigned int compute_may_aliases (void);
135 extern void delete_alias_heapvars (void);
136 extern bool pt_solution_includes_global (struct pt_solution *);
137 extern bool pt_solution_includes (struct pt_solution *, const_tree);
138 extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
139 extern void pt_solution_reset (struct pt_solution *);
140 extern void dump_pta_stats (FILE *);
143 #endif /* TREE_SSA_ALIAS_H */