1 /* Tree based alias analysis and alias oracle.
2 Copyright (C) 2008-2017 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 /* The points-to solution.
26 The points-to solution is a union of pt_vars and the abstract
27 sets specified by the flags. */
28 struct GTY(()) pt_solution
30 /* Nonzero if points-to analysis couldn't determine where this pointer
32 unsigned int anything
: 1;
34 /* Nonzero if the points-to set includes any global memory. Note that
35 even if this is zero pt_vars can still include global variables. */
36 unsigned int nonlocal
: 1;
38 /* Nonzero if the points-to set includes the local escaped solution by
40 unsigned int escaped
: 1;
42 /* Nonzero if the points-to set includes the IPA escaped solution by
44 unsigned int ipa_escaped
: 1;
46 /* Nonzero if the points-to set includes 'nothing', the points-to set
47 includes memory at address NULL. */
48 unsigned int null
: 1;
50 /* Nonzero if the vars bitmap includes a variable included in 'nonlocal'. */
51 unsigned int vars_contains_nonlocal
: 1;
52 /* Nonzero if the vars bitmap includes a variable included in 'escaped'. */
53 unsigned int vars_contains_escaped
: 1;
54 /* Nonzero if the vars bitmap includes a anonymous heap variable that
55 escaped the function and thus became global. */
56 unsigned int vars_contains_escaped_heap
: 1;
57 /* Nonzero if the vars bitmap includes a anonymous variable used to
58 represent storage pointed to by a restrict qualified pointer. */
59 unsigned int vars_contains_restrict
: 1;
60 /* Nonzero if the vars bitmap includes an interposable variable. */
61 unsigned int vars_contains_interposable
: 1;
63 /* Set of variables that this pointer may point to. */
68 /* Simplified and cached information about a memory reference tree.
69 Used by the alias-oracle internally and externally in alternate
73 /* The original full memory reference tree or NULL_TREE if that is
77 /* The following fields are the decomposed reference as returned
78 by get_ref_base_and_extent. */
79 /* The base object of the memory reference or NULL_TREE if all of
80 the following fields are not yet computed. */
82 /* The offset relative to the base. */
84 /* The size of the access. */
86 /* The maximum possible extent of the access or -1 if unconstrained. */
87 HOST_WIDE_INT max_size
;
89 /* The alias set of the access or -1 if not yet computed. */
90 alias_set_type ref_alias_set
;
92 /* The alias set of the base object or -1 if not yet computed. */
93 alias_set_type base_alias_set
;
95 /* Whether the memory is considered a volatile access. */
100 /* In tree-ssa-alias.c */
101 extern void ao_ref_init (ao_ref
*, tree
);
102 extern void ao_ref_init_from_ptr_and_size (ao_ref
*, tree
, tree
);
103 extern tree
ao_ref_base (ao_ref
*);
104 extern alias_set_type
ao_ref_alias_set (ao_ref
*);
105 extern alias_set_type
ao_ref_base_alias_set (ao_ref
*);
106 extern bool ptr_deref_may_alias_global_p (tree
);
107 extern bool ptr_derefs_may_alias_p (tree
, tree
);
108 extern bool ptrs_compare_unequal (tree
, tree
);
109 extern bool ref_may_alias_global_p (tree
);
110 extern bool ref_may_alias_global_p (ao_ref
*);
111 extern bool refs_may_alias_p (tree
, tree
);
112 extern bool refs_may_alias_p_1 (ao_ref
*, ao_ref
*, bool);
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 ref_maybe_used_by_stmt_p (gimple
*, ao_ref
*);
117 extern bool stmt_may_clobber_global_p (gimple
*);
118 extern bool stmt_may_clobber_ref_p (gimple
*, tree
);
119 extern bool stmt_may_clobber_ref_p_1 (gimple
*, ao_ref
*);
120 extern bool call_may_clobber_ref_p (gcall
*, tree
);
121 extern bool call_may_clobber_ref_p_1 (gcall
*, ao_ref
*);
122 extern bool stmt_kills_ref_p (gimple
*, tree
);
123 extern bool stmt_kills_ref_p (gimple
*, ao_ref
*);
124 extern tree
get_continuation_for_phi (gimple
*, ao_ref
*,
125 unsigned int *, bitmap
*, bool,
126 void *(*)(ao_ref
*, tree
, void *, bool *),
128 extern void *walk_non_aliased_vuses (ao_ref
*, tree
,
129 void *(*)(ao_ref
*, tree
,
130 unsigned int, void *),
131 void *(*)(ao_ref
*, tree
, void *, bool *),
134 extern int walk_aliased_vdefs (ao_ref
*, tree
,
135 bool (*)(ao_ref
*, tree
, void *),
137 bool *function_entry_reached
= NULL
,
138 unsigned int limit
= 0);
139 extern void dump_alias_info (FILE *);
140 extern void debug_alias_info (void);
141 extern void dump_points_to_solution (FILE *, struct pt_solution
*);
142 extern void debug (pt_solution
&ref
);
143 extern void debug (pt_solution
*ptr
);
144 extern void dump_points_to_info_for (FILE *, tree
);
145 extern void debug_points_to_info_for (tree
);
146 extern void dump_alias_stats (FILE *);
149 /* In tree-ssa-structalias.c */
150 extern unsigned int compute_may_aliases (void);
151 extern bool pt_solution_empty_p (struct pt_solution
*);
152 extern bool pt_solution_singleton_or_null_p (struct pt_solution
*, unsigned *);
153 extern bool pt_solution_includes_global (struct pt_solution
*);
154 extern bool pt_solution_includes (struct pt_solution
*, const_tree
);
155 extern bool pt_solutions_intersect (struct pt_solution
*, struct pt_solution
*);
156 extern void pt_solution_reset (struct pt_solution
*);
157 extern void pt_solution_set (struct pt_solution
*, bitmap
, bool);
158 extern void pt_solution_set_var (struct pt_solution
*, tree
);
160 extern void dump_pta_stats (FILE *);
162 extern GTY(()) struct pt_solution ipa_escaped_pt
;
164 /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
165 overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
166 range is open-ended. Otherwise return false. */
169 ranges_overlap_p (HOST_WIDE_INT pos1
,
170 unsigned HOST_WIDE_INT size1
,
172 unsigned HOST_WIDE_INT size2
)
174 if (size1
== 0 || size2
== 0)
177 && (size2
== (unsigned HOST_WIDE_INT
)-1
178 || pos1
< (pos2
+ (HOST_WIDE_INT
) size2
)))
181 && (size1
== (unsigned HOST_WIDE_INT
)-1
182 || pos2
< (pos1
+ (HOST_WIDE_INT
) size1
)))
190 #endif /* TREE_SSA_ALIAS_H */