1 /* Utilities for ipa analysis.
2 Copyright (C) 2004-2013 Free Software Foundation, Inc.
3 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
5 This file is part of GCC.
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
9 Software Foundation; either version 3, or (at your option) any later
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
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 GCC_IPA_UTILS_H
22 #define GCC_IPA_UTILS_H
23 #include "tree-core.h"
29 /* This field will have the samy value for any two nodes in the same strongly
30 connected component. */
34 struct cgraph_node
* next_cycle
;
40 void ipa_print_order (FILE*, const char *, struct cgraph_node
**, int);
41 int ipa_reduced_postorder (struct cgraph_node
**, bool, bool,
42 bool (*ignore_edge
) (struct cgraph_edge
*));
43 void ipa_free_postorder_info (void);
44 vec
<cgraph_node_ptr
> ipa_get_nodes_in_cycle (struct cgraph_node
*);
45 bool ipa_edge_within_scc (struct cgraph_edge
*);
46 int ipa_reverse_postorder (struct cgraph_node
**);
47 tree
get_base_var (tree
);
48 void ipa_merge_profiles (struct cgraph_node
*dst
,
49 struct cgraph_node
*src
);
50 bool recursive_call_p (tree
, tree
);
52 /* In ipa-profile.c */
53 bool ipa_propagate_frequency (struct cgraph_node
*node
);
58 typedef odr_type_d
*odr_type
;
59 void build_type_inheritance_graph (void);
60 void update_type_inheritance_graph (void);
62 possible_polymorphic_call_targets (tree
, HOST_WIDE_INT
,
64 void **cache_token
= NULL
);
65 odr_type
get_odr_type (tree
, bool insert
= false);
66 void dump_possible_polymorphic_call_targets (FILE *, tree
, HOST_WIDE_INT
);
67 bool possible_polymorphic_call_target_p (tree
, HOST_WIDE_INT
,
68 struct cgraph_node
*n
);
69 tree
method_class_type (tree
);
71 /* Return vector containing possible targets of polymorphic call E.
72 If FINALP is non-NULL, store true if the list is complette.
73 CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry
74 in the target cache. If user needs to visit every target list
75 just once, it can memoize them.
77 Returned vector is placed into cache. It is NOT caller's responsibility
78 to free it. The vector can be freed on cgraph_remove_node call if
79 the particular node is a virtual function present in the cache. */
81 inline vec
<cgraph_node
*>
82 possible_polymorphic_call_targets (struct cgraph_edge
*e
,
84 void **cache_token
= NULL
)
86 gcc_checking_assert (e
->indirect_info
->polymorphic
);
87 return possible_polymorphic_call_targets (e
->indirect_info
->otr_type
,
88 e
->indirect_info
->otr_token
,
92 /* Dump possible targets of a polymorphic call E into F. */
95 dump_possible_polymorphic_call_targets (FILE *f
, struct cgraph_edge
*e
)
97 gcc_checking_assert (e
->indirect_info
->polymorphic
);
98 dump_possible_polymorphic_call_targets (f
, e
->indirect_info
->otr_type
,
99 e
->indirect_info
->otr_token
);
102 /* Return true if N can be possibly target of a polymorphic call of
106 possible_polymorphic_call_target_p (struct cgraph_edge
*e
,
107 struct cgraph_node
*n
)
109 return possible_polymorphic_call_target_p (e
->indirect_info
->otr_type
,
110 e
->indirect_info
->otr_token
, n
);
113 /* Return true if N can be possibly target of a polymorphic call of
114 OBJ_TYPE_REF expression CALL. */
117 possible_polymorphic_call_target_p (tree call
,
118 struct cgraph_node
*n
)
120 return possible_polymorphic_call_target_p (obj_type_ref_class (call
),
122 (OBJ_TYPE_REF_TOKEN (call
), 1),
125 #endif /* GCC_IPA_UTILS_H */