]>
Commit | Line | Data |
---|---|---|
5006671f | 1 | /* Tree based alias analysis and alias oracle. |
8d9254fc | 2 | Copyright (C) 2008-2020 Free Software Foundation, Inc. |
5006671f RG |
3 | Contributed by Richard Guenther <rguenther@suse.de> |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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/>. */ | |
20 | ||
21 | #ifndef TREE_SSA_ALIAS_H | |
22 | #define TREE_SSA_ALIAS_H | |
23 | ||
5006671f RG |
24 | /* The points-to solution. |
25 | ||
26 | The points-to solution is a union of pt_vars and the abstract | |
27 | sets specified by the flags. */ | |
d1b38208 | 28 | struct GTY(()) pt_solution |
5006671f RG |
29 | { |
30 | /* Nonzero if points-to analysis couldn't determine where this pointer | |
31 | is pointing to. */ | |
32 | unsigned int anything : 1; | |
33 | ||
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; | |
37 | ||
25a6a873 RG |
38 | /* Nonzero if the points-to set includes the local escaped solution by |
39 | reference. */ | |
5006671f RG |
40 | unsigned int escaped : 1; |
41 | ||
25a6a873 RG |
42 | /* Nonzero if the points-to set includes the IPA escaped solution by |
43 | reference. */ | |
44 | unsigned int ipa_escaped : 1; | |
45 | ||
5006671f RG |
46 | /* Nonzero if the points-to set includes 'nothing', the points-to set |
47 | includes memory at address NULL. */ | |
48 | unsigned int null : 1; | |
49 | ||
11924f8b RB |
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; | |
763baff6 RB |
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; | |
da42ac7b RB |
60 | /* Nonzero if the vars bitmap includes an interposable variable. */ |
61 | unsigned int vars_contains_interposable : 1; | |
74d27244 | 62 | |
5006671f RG |
63 | /* Set of variables that this pointer may point to. */ |
64 | bitmap vars; | |
65 | }; | |
66 | ||
67 | ||
b45d2719 RG |
68 | /* Simplified and cached information about a memory reference tree. |
69 | Used by the alias-oracle internally and externally in alternate | |
70 | interfaces. */ | |
6c1dae73 | 71 | class ao_ref |
b45d2719 | 72 | { |
6c1dae73 | 73 | public: |
b45d2719 RG |
74 | /* The original full memory reference tree or NULL_TREE if that is |
75 | not available. */ | |
76 | tree ref; | |
77 | ||
78 | /* The following fields are the decomposed reference as returned | |
79 | by get_ref_base_and_extent. */ | |
80 | /* The base object of the memory reference or NULL_TREE if all of | |
81 | the following fields are not yet computed. */ | |
82 | tree base; | |
83 | /* The offset relative to the base. */ | |
b9c25734 | 84 | poly_int64 offset; |
b45d2719 | 85 | /* The size of the access. */ |
b9c25734 | 86 | poly_int64 size; |
b45d2719 | 87 | /* The maximum possible extent of the access or -1 if unconstrained. */ |
b9c25734 | 88 | poly_int64 max_size; |
b45d2719 RG |
89 | |
90 | /* The alias set of the access or -1 if not yet computed. */ | |
91 | alias_set_type ref_alias_set; | |
92 | ||
93 | /* The alias set of the base object or -1 if not yet computed. */ | |
94 | alias_set_type base_alias_set; | |
14cd91f9 RG |
95 | |
96 | /* Whether the memory is considered a volatile access. */ | |
97 | bool volatile_p; | |
b9c25734 RS |
98 | |
99 | bool max_size_known_p () const; | |
84562394 | 100 | }; |
b45d2719 | 101 | |
b9c25734 RS |
102 | /* Return true if the maximum size is known, rather than the special -1 |
103 | marker. */ | |
104 | ||
105 | inline bool | |
106 | ao_ref::max_size_known_p () const | |
107 | { | |
108 | return known_size_p (max_size); | |
109 | } | |
b45d2719 | 110 | |
5006671f | 111 | /* In tree-ssa-alias.c */ |
b45d2719 | 112 | extern void ao_ref_init (ao_ref *, tree); |
a778c4e7 | 113 | extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree); |
b45d2719 RG |
114 | extern tree ao_ref_base (ao_ref *); |
115 | extern alias_set_type ao_ref_alias_set (ao_ref *); | |
bf898b30 | 116 | extern alias_set_type ao_ref_base_alias_set (ao_ref *); |
5006671f | 117 | extern bool ptr_deref_may_alias_global_p (tree); |
7d36e538 | 118 | extern bool ptr_derefs_may_alias_p (tree, tree); |
98998245 | 119 | extern bool ptrs_compare_unequal (tree, tree); |
209be553 | 120 | extern bool ref_may_alias_global_p (tree); |
8cb65b37 | 121 | extern bool ref_may_alias_global_p (ao_ref *); |
27312bf2 | 122 | extern bool refs_may_alias_p (tree, tree, bool = true); |
55b34b5f | 123 | extern bool refs_may_alias_p_1 (ao_ref *, ao_ref *, bool); |
4d7a65ea RG |
124 | extern bool refs_anti_dependent_p (tree, tree); |
125 | extern bool refs_output_dependent_p (tree, tree); | |
27312bf2 RB |
126 | extern bool ref_maybe_used_by_stmt_p (gimple *, tree, bool = true); |
127 | extern bool ref_maybe_used_by_stmt_p (gimple *, ao_ref *, bool = true); | |
355fe088 | 128 | extern bool stmt_may_clobber_global_p (gimple *); |
27312bf2 RB |
129 | extern bool stmt_may_clobber_ref_p (gimple *, tree, bool = true); |
130 | extern bool stmt_may_clobber_ref_p_1 (gimple *, ao_ref *, bool = true); | |
538dd0b7 DM |
131 | extern bool call_may_clobber_ref_p (gcall *, tree); |
132 | extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *); | |
355fe088 TS |
133 | extern bool stmt_kills_ref_p (gimple *, tree); |
134 | extern bool stmt_kills_ref_p (gimple *, ao_ref *); | |
10f30ac9 RB |
135 | enum translate_flags |
136 | { TR_TRANSLATE, TR_VALUEIZE_AND_DISAMBIGUATE, TR_DISAMBIGUATE }; | |
fb4697e3 | 137 | extern tree get_continuation_for_phi (gimple *, ao_ref *, bool, |
3cf8b3e3 | 138 | unsigned int &, bitmap *, bool, |
10f30ac9 RB |
139 | void *(*)(ao_ref *, tree, void *, |
140 | translate_flags *), | |
141 | void *, translate_flags | |
142 | = TR_VALUEIZE_AND_DISAMBIGUATE); | |
fb4697e3 | 143 | extern void *walk_non_aliased_vuses (ao_ref *, tree, bool, |
3cf8b3e3 | 144 | void *(*)(ao_ref *, tree, void *), |
10f30ac9 RB |
145 | void *(*)(ao_ref *, tree, void *, |
146 | translate_flags *), | |
3cf8b3e3 | 147 | tree (*)(tree), unsigned &, void *); |
e80facb4 RB |
148 | extern int walk_aliased_vdefs (ao_ref *, tree, |
149 | bool (*)(ao_ref *, tree, void *), | |
150 | void *, bitmap *, | |
151 | bool *function_entry_reached = NULL, | |
152 | unsigned int limit = 0); | |
5006671f RG |
153 | extern void dump_alias_info (FILE *); |
154 | extern void debug_alias_info (void); | |
6b8ed145 | 155 | extern void dump_points_to_solution (FILE *, struct pt_solution *); |
7b3b6ae4 LC |
156 | extern void debug (pt_solution &ref); |
157 | extern void debug (pt_solution *ptr); | |
5006671f RG |
158 | extern void dump_points_to_info_for (FILE *, tree); |
159 | extern void debug_points_to_info_for (tree); | |
160 | extern void dump_alias_stats (FILE *); | |
161 | ||
162 | ||
163 | /* In tree-ssa-structalias.c */ | |
164 | extern unsigned int compute_may_aliases (void); | |
0e7b6a51 | 165 | extern bool pt_solution_empty_p (const pt_solution *); |
735b8f9f | 166 | extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned *); |
5006671f RG |
167 | extern bool pt_solution_includes_global (struct pt_solution *); |
168 | extern bool pt_solution_includes (struct pt_solution *, const_tree); | |
169 | extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *); | |
170 | extern void pt_solution_reset (struct pt_solution *); | |
d3553615 | 171 | extern void pt_solution_set (struct pt_solution *, bitmap, bool); |
90fa9e17 RG |
172 | extern void pt_solution_set_var (struct pt_solution *, tree); |
173 | ||
5006671f RG |
174 | extern void dump_pta_stats (FILE *); |
175 | ||
25a6a873 RG |
176 | extern GTY(()) struct pt_solution ipa_escaped_pt; |
177 | ||
cc524fc7 AM |
178 | /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2] |
179 | overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the | |
180 | range is open-ended. Otherwise return false. */ | |
181 | ||
182 | static inline bool | |
75081240 | 183 | ranges_overlap_p (HOST_WIDE_INT pos1, |
cc524fc7 | 184 | unsigned HOST_WIDE_INT size1, |
75081240 | 185 | HOST_WIDE_INT pos2, |
cc524fc7 AM |
186 | unsigned HOST_WIDE_INT size2) |
187 | { | |
7fc53ba4 RS |
188 | if (size1 == 0 || size2 == 0) |
189 | return false; | |
cc524fc7 AM |
190 | if (pos1 >= pos2 |
191 | && (size2 == (unsigned HOST_WIDE_INT)-1 | |
75081240 | 192 | || pos1 < (pos2 + (HOST_WIDE_INT) size2))) |
cc524fc7 AM |
193 | return true; |
194 | if (pos2 >= pos1 | |
195 | && (size1 == (unsigned HOST_WIDE_INT)-1 | |
75081240 | 196 | || pos2 < (pos1 + (HOST_WIDE_INT) size1))) |
cc524fc7 AM |
197 | return true; |
198 | ||
199 | return false; | |
200 | } | |
201 | ||
202 | ||
5006671f RG |
203 | |
204 | #endif /* TREE_SSA_ALIAS_H */ |