]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-ssa-alias.h
Update copyright years.
[thirdparty/gcc.git] / gcc / tree-ssa-alias.h
CommitLineData
dd277d48 1/* Tree based alias analysis and alias oracle.
fbd26352 2 Copyright (C) 2008-2019 Free Software Foundation, Inc.
dd277d48 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
dd277d48 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. */
fb1e4f4a 28struct GTY(()) pt_solution
dd277d48 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
1a981e1a 38 /* Nonzero if the points-to set includes the local escaped solution by
39 reference. */
dd277d48 40 unsigned int escaped : 1;
41
1a981e1a 42 /* Nonzero if the points-to set includes the IPA escaped solution by
43 reference. */
44 unsigned int ipa_escaped : 1;
45
dd277d48 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
420582bc 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;
5ffb4a0d 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;
76bc343a 60 /* Nonzero if the vars bitmap includes an interposable variable. */
61 unsigned int vars_contains_interposable : 1;
1c1f1bc0 62
dd277d48 63 /* Set of variables that this pointer may point to. */
64 bitmap vars;
65};
66
67
3918bd18 68/* Simplified and cached information about a memory reference tree.
69 Used by the alias-oracle internally and externally in alternate
70 interfaces. */
b3e7c666 71struct ao_ref
3918bd18 72{
73 /* The original full memory reference tree or NULL_TREE if that is
74 not available. */
75 tree ref;
76
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. */
81 tree base;
82 /* The offset relative to the base. */
fe60c82c 83 poly_int64 offset;
3918bd18 84 /* The size of the access. */
fe60c82c 85 poly_int64 size;
3918bd18 86 /* The maximum possible extent of the access or -1 if unconstrained. */
fe60c82c 87 poly_int64 max_size;
3918bd18 88
89 /* The alias set of the access or -1 if not yet computed. */
90 alias_set_type ref_alias_set;
91
92 /* The alias set of the base object or -1 if not yet computed. */
93 alias_set_type base_alias_set;
3787db52 94
95 /* Whether the memory is considered a volatile access. */
96 bool volatile_p;
fe60c82c 97
98 bool max_size_known_p () const;
b3e7c666 99};
3918bd18 100
fe60c82c 101/* Return true if the maximum size is known, rather than the special -1
102 marker. */
103
104inline bool
105ao_ref::max_size_known_p () const
106{
107 return known_size_p (max_size);
108}
3918bd18 109
dd277d48 110/* In tree-ssa-alias.c */
3918bd18 111extern void ao_ref_init (ao_ref *, tree);
134899ac 112extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree);
3918bd18 113extern tree ao_ref_base (ao_ref *);
114extern alias_set_type ao_ref_alias_set (ao_ref *);
8e92a5ee 115extern alias_set_type ao_ref_base_alias_set (ao_ref *);
dd277d48 116extern bool ptr_deref_may_alias_global_p (tree);
2760c0e3 117extern bool ptr_derefs_may_alias_p (tree, tree);
73447cc5 118extern bool ptrs_compare_unequal (tree, tree);
8763c223 119extern bool ref_may_alias_global_p (tree);
258bd648 120extern bool ref_may_alias_global_p (ao_ref *);
58cfef6b 121extern bool refs_may_alias_p (tree, tree, bool = true);
3a443843 122extern bool refs_may_alias_p_1 (ao_ref *, ao_ref *, bool);
2a3ebafa 123extern bool refs_anti_dependent_p (tree, tree);
124extern bool refs_output_dependent_p (tree, tree);
58cfef6b 125extern bool ref_maybe_used_by_stmt_p (gimple *, tree, bool = true);
126extern bool ref_maybe_used_by_stmt_p (gimple *, ao_ref *, bool = true);
42acab1c 127extern bool stmt_may_clobber_global_p (gimple *);
58cfef6b 128extern bool stmt_may_clobber_ref_p (gimple *, tree, bool = true);
129extern bool stmt_may_clobber_ref_p_1 (gimple *, ao_ref *, bool = true);
1a91d914 130extern bool call_may_clobber_ref_p (gcall *, tree);
131extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *);
42acab1c 132extern bool stmt_kills_ref_p (gimple *, tree);
133extern bool stmt_kills_ref_p (gimple *, ao_ref *);
134extern tree get_continuation_for_phi (gimple *, ao_ref *,
38168b16 135 unsigned int *, bitmap *, bool,
dddafd79 136 void *(*)(ao_ref *, tree, void *, bool *),
38168b16 137 void *);
3918bd18 138extern void *walk_non_aliased_vuses (ao_ref *, tree,
297a2110 139 void *(*)(ao_ref *, tree,
140 unsigned int, void *),
dddafd79 141 void *(*)(ao_ref *, tree, void *, bool *),
46816709 142 tree (*)(tree),
38168b16 143 void *);
4d2b9d1e 144extern int walk_aliased_vdefs (ao_ref *, tree,
145 bool (*)(ao_ref *, tree, void *),
146 void *, bitmap *,
147 bool *function_entry_reached = NULL,
148 unsigned int limit = 0);
dd277d48 149extern void dump_alias_info (FILE *);
150extern void debug_alias_info (void);
7f81b5ee 151extern void dump_points_to_solution (FILE *, struct pt_solution *);
c7d89805 152extern void debug (pt_solution &ref);
153extern void debug (pt_solution *ptr);
dd277d48 154extern void dump_points_to_info_for (FILE *, tree);
155extern void debug_points_to_info_for (tree);
156extern void dump_alias_stats (FILE *);
157
158
159/* In tree-ssa-structalias.c */
160extern unsigned int compute_may_aliases (void);
1a981e1a 161extern bool pt_solution_empty_p (struct pt_solution *);
5b48910f 162extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned *);
dd277d48 163extern bool pt_solution_includes_global (struct pt_solution *);
164extern bool pt_solution_includes (struct pt_solution *, const_tree);
165extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
166extern void pt_solution_reset (struct pt_solution *);
6fc56905 167extern void pt_solution_set (struct pt_solution *, bitmap, bool);
e1c894dd 168extern void pt_solution_set_var (struct pt_solution *, tree);
169
dd277d48 170extern void dump_pta_stats (FILE *);
171
1a981e1a 172extern GTY(()) struct pt_solution ipa_escaped_pt;
173
582791b0 174/* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
175 overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
176 range is open-ended. Otherwise return false. */
177
178static inline bool
234f1f79 179ranges_overlap_p (HOST_WIDE_INT pos1,
582791b0 180 unsigned HOST_WIDE_INT size1,
234f1f79 181 HOST_WIDE_INT pos2,
582791b0 182 unsigned HOST_WIDE_INT size2)
183{
f81dd217 184 if (size1 == 0 || size2 == 0)
185 return false;
582791b0 186 if (pos1 >= pos2
187 && (size2 == (unsigned HOST_WIDE_INT)-1
234f1f79 188 || pos1 < (pos2 + (HOST_WIDE_INT) size2)))
582791b0 189 return true;
190 if (pos2 >= pos1
191 && (size1 == (unsigned HOST_WIDE_INT)-1
234f1f79 192 || pos2 < (pos1 + (HOST_WIDE_INT) size1)))
582791b0 193 return true;
194
195 return false;
196}
197
198
dd277d48 199
200#endif /* TREE_SSA_ALIAS_H */