]>
Commit | Line | Data |
---|---|---|
ea900239 | 1 | /* Utilities for ipa analysis. |
5624e564 | 2 | Copyright (C) 2004-2015 Free Software Foundation, Inc. |
ea900239 DB |
3 | Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9dcd6f09 | 9 | Software Foundation; either version 3, or (at your option) any later |
ea900239 DB |
10 | version. |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
ea900239 DB |
20 | |
21 | #ifndef GCC_IPA_UTILS_H | |
22 | #define GCC_IPA_UTILS_H | |
ea900239 | 23 | |
ea900239 DB |
24 | struct ipa_dfs_info { |
25 | int dfn_number; | |
26 | int low_link; | |
11026b51 MJ |
27 | /* This field will have the samy value for any two nodes in the same strongly |
28 | connected component. */ | |
29 | int scc_no; | |
c5274326 | 30 | bool new_node; |
ea900239 DB |
31 | bool on_stack; |
32 | struct cgraph_node* next_cycle; | |
33 | PTR aux; | |
34 | }; | |
35 | ||
a1981458 | 36 | |
ea900239 | 37 | /* In ipa-utils.c */ |
af8bca3c MJ |
38 | void ipa_print_order (FILE*, const char *, struct cgraph_node**, int); |
39 | int ipa_reduced_postorder (struct cgraph_node **, bool, bool, | |
40 | bool (*ignore_edge) (struct cgraph_edge *)); | |
41 | void ipa_free_postorder_info (void); | |
d52f5295 | 42 | vec<cgraph_node *> ipa_get_nodes_in_cycle (struct cgraph_node *); |
4cb13597 | 43 | bool ipa_edge_within_scc (struct cgraph_edge *); |
af8bca3c | 44 | int ipa_reverse_postorder (struct cgraph_node **); |
ea900239 | 45 | tree get_base_var (tree); |
5e581212 | 46 | void ipa_merge_profiles (struct cgraph_node *dst, |
b730d1c9 | 47 | struct cgraph_node *src, bool preserve_body = false); |
fc11f321 | 48 | bool recursive_call_p (tree, tree); |
ea900239 | 49 | |
08f835dc JH |
50 | /* In ipa-profile.c */ |
51 | bool ipa_propagate_frequency (struct cgraph_node *node); | |
52 | ||
eefe9a99 JH |
53 | /* In ipa-devirt.c */ |
54 | ||
55 | struct odr_type_d; | |
56 | typedef odr_type_d *odr_type; | |
57 | void build_type_inheritance_graph (void); | |
0e1474e5 | 58 | void update_type_inheritance_graph (void); |
eefe9a99 JH |
59 | vec <cgraph_node *> |
60 | possible_polymorphic_call_targets (tree, HOST_WIDE_INT, | |
68377e53 | 61 | ipa_polymorphic_call_context, |
6f8091fc | 62 | bool *copletep = NULL, |
ec77d61f | 63 | void **cache_token = NULL, |
2f28755f | 64 | bool speuclative = false); |
eefe9a99 | 65 | odr_type get_odr_type (tree, bool insert = false); |
259d29e3 JH |
66 | bool type_in_anonymous_namespace_p (const_tree); |
67 | bool type_with_linkage_p (const_tree); | |
68 | bool odr_type_p (const_tree); | |
6f8091fc | 69 | bool possible_polymorphic_call_target_p (tree ref, gimple stmt, struct cgraph_node *n); |
68377e53 JH |
70 | void dump_possible_polymorphic_call_targets (FILE *, tree, HOST_WIDE_INT, |
71 | const ipa_polymorphic_call_context &); | |
0e1474e5 | 72 | bool possible_polymorphic_call_target_p (tree, HOST_WIDE_INT, |
68377e53 | 73 | const ipa_polymorphic_call_context &, |
d570d364 | 74 | struct cgraph_node *); |
00a0ea64 | 75 | tree inlined_polymorphic_ctor_dtor_block_p (tree, bool); |
058d0a90 | 76 | bool decl_maybe_in_construction_p (tree, tree, gimple, tree); |
d570d364 JH |
77 | tree vtable_pointer_value_to_binfo (const_tree); |
78 | bool vtable_pointer_value_to_vtable (const_tree, tree *, unsigned HOST_WIDE_INT *); | |
aa803cc7 | 79 | tree subbinfo_with_vtable_at_offset (tree, unsigned HOST_WIDE_INT, tree); |
56b1f114 | 80 | void compare_virtual_tables (varpool_node *, varpool_node *); |
aa803cc7 | 81 | bool type_all_derivations_known_p (const_tree); |
4d6eb35a | 82 | bool type_known_to_have_no_derivations_p (tree); |
d570d364 | 83 | bool contains_polymorphic_type_p (const_tree); |
1ee85ee1 | 84 | void register_odr_type (tree); |
aa803cc7 | 85 | bool types_must_be_same_for_odr (tree, tree); |
609570b4 | 86 | bool types_odr_comparable (tree, tree, bool strict = false); |
5ce97055 JH |
87 | cgraph_node *try_speculative_devirtualization (tree, HOST_WIDE_INT, |
88 | ipa_polymorphic_call_context); | |
259d29e3 JH |
89 | void warn_types_mismatch (tree t1, tree t2); |
90 | bool odr_or_derived_type_p (const_tree t); | |
91 | bool odr_types_equivalent_p (tree type1, tree type2); | |
eefe9a99 JH |
92 | |
93 | /* Return vector containing possible targets of polymorphic call E. | |
1c5fd343 | 94 | If COMPLETEP is non-NULL, store true if the list is complete. |
eefe9a99 JH |
95 | CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry |
96 | in the target cache. If user needs to visit every target list | |
97 | just once, it can memoize them. | |
98 | ||
99 | Returned vector is placed into cache. It is NOT caller's responsibility | |
100 | to free it. The vector can be freed on cgraph_remove_node call if | |
101 | the particular node is a virtual function present in the cache. */ | |
102 | ||
103 | inline vec <cgraph_node *> | |
104 | possible_polymorphic_call_targets (struct cgraph_edge *e, | |
6f8091fc | 105 | bool *completep = NULL, |
ec77d61f | 106 | void **cache_token = NULL, |
2f28755f | 107 | bool speculative = false) |
eefe9a99 | 108 | { |
4d7cf10d | 109 | ipa_polymorphic_call_context context(e); |
6f8091fc | 110 | |
eefe9a99 JH |
111 | return possible_polymorphic_call_targets (e->indirect_info->otr_type, |
112 | e->indirect_info->otr_token, | |
68377e53 | 113 | context, |
6f8091fc | 114 | completep, cache_token, |
2f28755f | 115 | speculative); |
68377e53 JH |
116 | } |
117 | ||
118 | /* Same as above but taking OBJ_TYPE_REF as an parameter. */ | |
119 | ||
120 | inline vec <cgraph_node *> | |
058d0a90 JH |
121 | possible_polymorphic_call_targets (tree ref, |
122 | gimple call, | |
6f8091fc | 123 | bool *completep = NULL, |
68377e53 JH |
124 | void **cache_token = NULL) |
125 | { | |
6f8091fc | 126 | ipa_polymorphic_call_context context (current_function_decl, ref, call); |
61dd6a2e | 127 | |
058d0a90 | 128 | return possible_polymorphic_call_targets (obj_type_ref_class (ref), |
68377e53 | 129 | tree_to_uhwi |
058d0a90 | 130 | (OBJ_TYPE_REF_TOKEN (ref)), |
61dd6a2e | 131 | context, |
6f8091fc | 132 | completep, cache_token); |
eefe9a99 JH |
133 | } |
134 | ||
135 | /* Dump possible targets of a polymorphic call E into F. */ | |
b8698a0f | 136 | |
eefe9a99 JH |
137 | inline void |
138 | dump_possible_polymorphic_call_targets (FILE *f, struct cgraph_edge *e) | |
139 | { | |
4d7cf10d | 140 | ipa_polymorphic_call_context context(e); |
6f8091fc | 141 | |
eefe9a99 | 142 | dump_possible_polymorphic_call_targets (f, e->indirect_info->otr_type, |
68377e53 JH |
143 | e->indirect_info->otr_token, |
144 | context); | |
eefe9a99 | 145 | } |
0e1474e5 JH |
146 | |
147 | /* Return true if N can be possibly target of a polymorphic call of | |
148 | E. */ | |
149 | ||
150 | inline bool | |
151 | possible_polymorphic_call_target_p (struct cgraph_edge *e, | |
152 | struct cgraph_node *n) | |
153 | { | |
4d7cf10d | 154 | ipa_polymorphic_call_context context(e); |
6f8091fc | 155 | |
0e1474e5 | 156 | return possible_polymorphic_call_target_p (e->indirect_info->otr_type, |
68377e53 JH |
157 | e->indirect_info->otr_token, |
158 | context, n); | |
0e1474e5 | 159 | } |
450ad0cd | 160 | |
aa803cc7 JH |
161 | /* Return true if BINFO corresponds to a type with virtual methods. |
162 | ||
163 | Every type has several BINFOs. One is the BINFO associated by the type | |
164 | while other represents bases of derived types. The BINFOs representing | |
165 | bases do not have BINFO_VTABLE pointer set when this is the single | |
166 | inheritance (because vtables are shared). Look up the BINFO of type | |
167 | and check presence of its vtable. */ | |
168 | ||
169 | inline bool | |
170 | polymorphic_type_binfo_p (const_tree binfo) | |
171 | { | |
bf898b30 ML |
172 | /* See if BINFO's type has an virtual table associtated with it. |
173 | Check is defensive because of Java FE produces BINFOs | |
174 | without BINFO_TYPE set. */ | |
1be0e58d JH |
175 | return (BINFO_TYPE (binfo) && TYPE_BINFO (BINFO_TYPE (binfo)) |
176 | && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo)))); | |
aa803cc7 | 177 | } |
ea900239 DB |
178 | #endif /* GCC_IPA_UTILS_H */ |
179 | ||
180 |