annotate gcc/ipa-utils.h @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Utilities for ipa analysis.
111
kono
parents: 55
diff changeset
2 Copyright (C) 2004-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #ifndef GCC_IPA_UTILS_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define GCC_IPA_UTILS_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 struct ipa_dfs_info {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 int dfn_number;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 int low_link;
111
kono
parents: 55
diff changeset
27 /* This field will have the samy value for any two nodes in the same strongly
kono
parents: 55
diff changeset
28 connected component. */
kono
parents: 55
diff changeset
29 int scc_no;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 bool new_node;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 bool on_stack;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 struct cgraph_node* next_cycle;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 PTR aux;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
111
kono
parents: 55
diff changeset
37 /* In ipa-utils.c */
kono
parents: 55
diff changeset
38 void ipa_print_order (FILE*, const char *, struct cgraph_node**, int);
kono
parents: 55
diff changeset
39 int ipa_reduced_postorder (struct cgraph_node **, bool, bool,
kono
parents: 55
diff changeset
40 bool (*ignore_edge) (struct cgraph_edge *));
kono
parents: 55
diff changeset
41 void ipa_free_postorder_info (void);
kono
parents: 55
diff changeset
42 vec<cgraph_node *> ipa_get_nodes_in_cycle (struct cgraph_node *);
kono
parents: 55
diff changeset
43 bool ipa_edge_within_scc (struct cgraph_edge *);
kono
parents: 55
diff changeset
44 int ipa_reverse_postorder (struct cgraph_node **);
kono
parents: 55
diff changeset
45 tree get_base_var (tree);
kono
parents: 55
diff changeset
46 void ipa_merge_profiles (struct cgraph_node *dst,
kono
parents: 55
diff changeset
47 struct cgraph_node *src, bool preserve_body = false);
kono
parents: 55
diff changeset
48 bool recursive_call_p (tree, tree);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
111
kono
parents: 55
diff changeset
50 /* In ipa-profile.c */
kono
parents: 55
diff changeset
51 bool ipa_propagate_frequency (struct cgraph_node *node);
kono
parents: 55
diff changeset
52
kono
parents: 55
diff changeset
53 /* In ipa-devirt.c */
kono
parents: 55
diff changeset
54
kono
parents: 55
diff changeset
55 struct odr_type_d;
kono
parents: 55
diff changeset
56 typedef odr_type_d *odr_type;
kono
parents: 55
diff changeset
57 void build_type_inheritance_graph (void);
kono
parents: 55
diff changeset
58 void update_type_inheritance_graph (void);
kono
parents: 55
diff changeset
59 vec <cgraph_node *>
kono
parents: 55
diff changeset
60 possible_polymorphic_call_targets (tree, HOST_WIDE_INT,
kono
parents: 55
diff changeset
61 ipa_polymorphic_call_context,
kono
parents: 55
diff changeset
62 bool *copletep = NULL,
kono
parents: 55
diff changeset
63 void **cache_token = NULL,
kono
parents: 55
diff changeset
64 bool speuclative = false);
kono
parents: 55
diff changeset
65 odr_type get_odr_type (tree, bool insert = false);
kono
parents: 55
diff changeset
66 bool odr_type_p (const_tree);
kono
parents: 55
diff changeset
67 bool possible_polymorphic_call_target_p (tree ref, gimple *stmt, struct cgraph_node *n);
kono
parents: 55
diff changeset
68 void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT,
kono
parents: 55
diff changeset
69 const ipa_polymorphic_call_context &);
kono
parents: 55
diff changeset
70 bool possible_polymorphic_call_target_p (tree, HOST_WIDE_INT,
kono
parents: 55
diff changeset
71 const ipa_polymorphic_call_context &,
kono
parents: 55
diff changeset
72 struct cgraph_node *);
kono
parents: 55
diff changeset
73 tree polymorphic_ctor_dtor_p (tree, bool);
kono
parents: 55
diff changeset
74 tree inlined_polymorphic_ctor_dtor_block_p (tree, bool);
kono
parents: 55
diff changeset
75 bool decl_maybe_in_construction_p (tree, tree, gimple *, tree);
kono
parents: 55
diff changeset
76 tree vtable_pointer_value_to_binfo (const_tree);
kono
parents: 55
diff changeset
77 bool vtable_pointer_value_to_vtable (const_tree, tree *, unsigned HOST_WIDE_INT *);
kono
parents: 55
diff changeset
78 tree subbinfo_with_vtable_at_offset (tree, unsigned HOST_WIDE_INT, tree);
kono
parents: 55
diff changeset
79 void compare_virtual_tables (varpool_node *, varpool_node *);
kono
parents: 55
diff changeset
80 bool type_all_derivations_known_p (const_tree);
kono
parents: 55
diff changeset
81 bool type_known_to_have_no_derivations_p (tree);
kono
parents: 55
diff changeset
82 bool contains_polymorphic_type_p (const_tree);
kono
parents: 55
diff changeset
83 void register_odr_type (tree);
kono
parents: 55
diff changeset
84 bool types_must_be_same_for_odr (tree, tree);
kono
parents: 55
diff changeset
85 bool types_odr_comparable (tree, tree, bool strict = false);
kono
parents: 55
diff changeset
86 cgraph_node *try_speculative_devirtualization (tree, HOST_WIDE_INT,
kono
parents: 55
diff changeset
87 ipa_polymorphic_call_context);
kono
parents: 55
diff changeset
88 void warn_types_mismatch (tree t1, tree t2, location_t loc1 = UNKNOWN_LOCATION,
kono
parents: 55
diff changeset
89 location_t loc2 = UNKNOWN_LOCATION);
kono
parents: 55
diff changeset
90 bool odr_or_derived_type_p (const_tree t);
kono
parents: 55
diff changeset
91 bool odr_types_equivalent_p (tree type1, tree type2);
kono
parents: 55
diff changeset
92
kono
parents: 55
diff changeset
93 /* Return vector containing possible targets of polymorphic call E.
kono
parents: 55
diff changeset
94 If COMPLETEP is non-NULL, store true if the list is complete.
kono
parents: 55
diff changeset
95 CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry
kono
parents: 55
diff changeset
96 in the target cache. If user needs to visit every target list
kono
parents: 55
diff changeset
97 just once, it can memoize them.
kono
parents: 55
diff changeset
98
kono
parents: 55
diff changeset
99 Returned vector is placed into cache. It is NOT caller's responsibility
kono
parents: 55
diff changeset
100 to free it. The vector can be freed on cgraph_remove_node call if
kono
parents: 55
diff changeset
101 the particular node is a virtual function present in the cache. */
kono
parents: 55
diff changeset
102
kono
parents: 55
diff changeset
103 inline vec <cgraph_node *>
kono
parents: 55
diff changeset
104 possible_polymorphic_call_targets (struct cgraph_edge *e,
kono
parents: 55
diff changeset
105 bool *completep = NULL,
kono
parents: 55
diff changeset
106 void **cache_token = NULL,
kono
parents: 55
diff changeset
107 bool speculative = false)
kono
parents: 55
diff changeset
108 {
kono
parents: 55
diff changeset
109 ipa_polymorphic_call_context context(e);
kono
parents: 55
diff changeset
110
kono
parents: 55
diff changeset
111 return possible_polymorphic_call_targets (e->indirect_info->otr_type,
kono
parents: 55
diff changeset
112 e->indirect_info->otr_token,
kono
parents: 55
diff changeset
113 context,
kono
parents: 55
diff changeset
114 completep, cache_token,
kono
parents: 55
diff changeset
115 speculative);
kono
parents: 55
diff changeset
116 }
kono
parents: 55
diff changeset
117
kono
parents: 55
diff changeset
118 /* Same as above but taking OBJ_TYPE_REF as an parameter. */
kono
parents: 55
diff changeset
119
kono
parents: 55
diff changeset
120 inline vec <cgraph_node *>
kono
parents: 55
diff changeset
121 possible_polymorphic_call_targets (tree ref,
kono
parents: 55
diff changeset
122 gimple *call,
kono
parents: 55
diff changeset
123 bool *completep = NULL,
kono
parents: 55
diff changeset
124 void **cache_token = NULL)
kono
parents: 55
diff changeset
125 {
kono
parents: 55
diff changeset
126 ipa_polymorphic_call_context context (current_function_decl, ref, call);
kono
parents: 55
diff changeset
127
kono
parents: 55
diff changeset
128 return possible_polymorphic_call_targets (obj_type_ref_class (ref),
kono
parents: 55
diff changeset
129 tree_to_uhwi
kono
parents: 55
diff changeset
130 (OBJ_TYPE_REF_TOKEN (ref)),
kono
parents: 55
diff changeset
131 context,
kono
parents: 55
diff changeset
132 completep, cache_token);
kono
parents: 55
diff changeset
133 }
kono
parents: 55
diff changeset
134
kono
parents: 55
diff changeset
135 /* Dump possible targets of a polymorphic call E into F. */
kono
parents: 55
diff changeset
136
kono
parents: 55
diff changeset
137 inline void
kono
parents: 55
diff changeset
138 dump_possible_polymorphic_call_targets (FILE *f, struct cgraph_edge *e)
kono
parents: 55
diff changeset
139 {
kono
parents: 55
diff changeset
140 ipa_polymorphic_call_context context(e);
kono
parents: 55
diff changeset
141
kono
parents: 55
diff changeset
142 dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type,
kono
parents: 55
diff changeset
143 e->indirect_info->otr_token,
kono
parents: 55
diff changeset
144 context);
kono
parents: 55
diff changeset
145 }
kono
parents: 55
diff changeset
146
kono
parents: 55
diff changeset
147 /* Return true if N can be possibly target of a polymorphic call of
kono
parents: 55
diff changeset
148 E. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
111
kono
parents: 55
diff changeset
150 inline bool
kono
parents: 55
diff changeset
151 possible_polymorphic_call_target_p (struct cgraph_edge *e,
kono
parents: 55
diff changeset
152 struct cgraph_node *n)
kono
parents: 55
diff changeset
153 {
kono
parents: 55
diff changeset
154 ipa_polymorphic_call_context context(e);
kono
parents: 55
diff changeset
155
kono
parents: 55
diff changeset
156 return possible_polymorphic_call_target_p (e->indirect_info->otr_type,
kono
parents: 55
diff changeset
157 e->indirect_info->otr_token,
kono
parents: 55
diff changeset
158 context, n);
kono
parents: 55
diff changeset
159 }
kono
parents: 55
diff changeset
160
kono
parents: 55
diff changeset
161 /* Return true if BINFO corresponds to a type with virtual methods.
kono
parents: 55
diff changeset
162
kono
parents: 55
diff changeset
163 Every type has several BINFOs. One is the BINFO associated by the type
kono
parents: 55
diff changeset
164 while other represents bases of derived types. The BINFOs representing
kono
parents: 55
diff changeset
165 bases do not have BINFO_VTABLE pointer set when this is the single
kono
parents: 55
diff changeset
166 inheritance (because vtables are shared). Look up the BINFO of type
kono
parents: 55
diff changeset
167 and check presence of its vtable. */
kono
parents: 55
diff changeset
168
kono
parents: 55
diff changeset
169 inline bool
kono
parents: 55
diff changeset
170 polymorphic_type_binfo_p (const_tree binfo)
kono
parents: 55
diff changeset
171 {
kono
parents: 55
diff changeset
172 return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo))
kono
parents: 55
diff changeset
173 && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo))));
kono
parents: 55
diff changeset
174 }
kono
parents: 55
diff changeset
175
kono
parents: 55
diff changeset
176 /* Return true if T is a type with linkage defined. */
kono
parents: 55
diff changeset
177
kono
parents: 55
diff changeset
178 inline bool
kono
parents: 55
diff changeset
179 type_with_linkage_p (const_tree t)
kono
parents: 55
diff changeset
180 {
kono
parents: 55
diff changeset
181 if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
kono
parents: 55
diff changeset
182 || !TYPE_STUB_DECL (t))
kono
parents: 55
diff changeset
183 return false;
kono
parents: 55
diff changeset
184 /* In LTO do not get confused by non-C++ produced types or types built
kono
parents: 55
diff changeset
185 with -fno-lto-odr-type-merigng. */
kono
parents: 55
diff changeset
186 if (in_lto_p)
kono
parents: 55
diff changeset
187 {
kono
parents: 55
diff changeset
188 /* To support -fno-lto-odr-type-merigng recognize types with vtables
kono
parents: 55
diff changeset
189 to have linkage. */
kono
parents: 55
diff changeset
190 if (RECORD_OR_UNION_TYPE_P (t)
kono
parents: 55
diff changeset
191 && TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
kono
parents: 55
diff changeset
192 return true;
kono
parents: 55
diff changeset
193 /* With -flto-odr-type-merging C++ FE specify mangled names
kono
parents: 55
diff changeset
194 for all types with the linkage. */
kono
parents: 55
diff changeset
195 return DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
kono
parents: 55
diff changeset
196 }
kono
parents: 55
diff changeset
197
kono
parents: 55
diff changeset
198 if (!RECORD_OR_UNION_TYPE_P (t) && TREE_CODE (t) != ENUMERAL_TYPE)
kono
parents: 55
diff changeset
199 return false;
kono
parents: 55
diff changeset
200
kono
parents: 55
diff changeset
201 /* Builtin types do not define linkage, their TYPE_CONTEXT is NULL. */
kono
parents: 55
diff changeset
202 if (!TYPE_CONTEXT (t))
kono
parents: 55
diff changeset
203 return false;
kono
parents: 55
diff changeset
204
kono
parents: 55
diff changeset
205 return true;
kono
parents: 55
diff changeset
206 }
kono
parents: 55
diff changeset
207
kono
parents: 55
diff changeset
208 /* Return true if T is in anonymous namespace.
kono
parents: 55
diff changeset
209 This works only on those C++ types with linkage defined. */
kono
parents: 55
diff changeset
210
kono
parents: 55
diff changeset
211 inline bool
kono
parents: 55
diff changeset
212 type_in_anonymous_namespace_p (const_tree t)
kono
parents: 55
diff changeset
213 {
kono
parents: 55
diff changeset
214 gcc_checking_assert (type_with_linkage_p (t));
kono
parents: 55
diff changeset
215
kono
parents: 55
diff changeset
216 if (!TREE_PUBLIC (TYPE_STUB_DECL (t)))
kono
parents: 55
diff changeset
217 {
kono
parents: 55
diff changeset
218 /* C++ FE uses magic <anon> as assembler names of anonymous types.
kono
parents: 55
diff changeset
219 verify that this match with type_in_anonymous_namespace_p. */
kono
parents: 55
diff changeset
220 gcc_checking_assert (!in_lto_p
kono
parents: 55
diff changeset
221 || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))
kono
parents: 55
diff changeset
222 || !strcmp ("<anon>",
kono
parents: 55
diff changeset
223 IDENTIFIER_POINTER
kono
parents: 55
diff changeset
224 (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
kono
parents: 55
diff changeset
225 return true;
kono
parents: 55
diff changeset
226 }
kono
parents: 55
diff changeset
227 return false;
kono
parents: 55
diff changeset
228 }
kono
parents: 55
diff changeset
229
kono
parents: 55
diff changeset
230 /* Return true of T is type with One Definition Rule info attached.
kono
parents: 55
diff changeset
231 It means that either it is anonymous type or it has assembler name
kono
parents: 55
diff changeset
232 set. */
kono
parents: 55
diff changeset
233
kono
parents: 55
diff changeset
234 inline bool
kono
parents: 55
diff changeset
235 odr_type_p (const_tree t)
kono
parents: 55
diff changeset
236 {
kono
parents: 55
diff changeset
237 /* We do not have this information when not in LTO, but we do not need
kono
parents: 55
diff changeset
238 to care, since it is used only for type merging. */
kono
parents: 55
diff changeset
239 gcc_checking_assert (in_lto_p || flag_lto);
kono
parents: 55
diff changeset
240
kono
parents: 55
diff changeset
241 if (!type_with_linkage_p (t))
kono
parents: 55
diff changeset
242 return false;
kono
parents: 55
diff changeset
243
kono
parents: 55
diff changeset
244 /* To support -fno-lto-odr-type-merging consider types with vtables ODR. */
kono
parents: 55
diff changeset
245 if (type_in_anonymous_namespace_p (t))
kono
parents: 55
diff changeset
246 return true;
kono
parents: 55
diff changeset
247
kono
parents: 55
diff changeset
248 if (TYPE_NAME (t) && DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
kono
parents: 55
diff changeset
249 {
kono
parents: 55
diff changeset
250 /* C++ FE uses magic <anon> as assembler names of anonymous types.
kono
parents: 55
diff changeset
251 verify that this match with type_in_anonymous_namespace_p. */
kono
parents: 55
diff changeset
252 gcc_checking_assert (strcmp ("<anon>",
kono
parents: 55
diff changeset
253 IDENTIFIER_POINTER
kono
parents: 55
diff changeset
254 (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
kono
parents: 55
diff changeset
255 return true;
kono
parents: 55
diff changeset
256 }
kono
parents: 55
diff changeset
257 return false;
kono
parents: 55
diff changeset
258 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
259
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 #endif /* GCC_IPA_UTILS_H */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262