]>
Commit | Line | Data |
---|---|---|
1c4a429a | 1 | /* Callgraph handling code. |
24b97832 | 2 | Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
2bafad93 | 3 | Free Software Foundation, Inc. |
1c4a429a JH |
4 | Contributed by Jan Hubicka |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
9dcd6f09 | 10 | Software Foundation; either version 3, or (at your option) any later |
1c4a429a JH |
11 | version. |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
1c4a429a JH |
21 | |
22 | #ifndef GCC_CGRAPH_H | |
23 | #define GCC_CGRAPH_H | |
6674a6ce | 24 | #include "tree.h" |
e42922b1 | 25 | #include "basic-block.h" |
1c4a429a | 26 | |
6b02a499 JH |
27 | enum availability |
28 | { | |
29 | /* Not yet set by cgraph_function_body_availability. */ | |
30 | AVAIL_UNSET, | |
31 | /* Function body/variable initializer is unknown. */ | |
32 | AVAIL_NOT_AVAILABLE, | |
33 | /* Function body/variable initializer is known but might be replaced | |
34 | by a different one from other compilation unit and thus needs to | |
35 | be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have | |
36 | arbitrary side effects on escaping variables and functions, while | |
37 | like AVAILABLE it might access static variables. */ | |
38 | AVAIL_OVERWRITABLE, | |
39 | /* Function body/variable initializer is known and will be used in final | |
40 | program. */ | |
41 | AVAIL_AVAILABLE, | |
42 | /* Function body/variable initializer is known and all it's uses are explicitly | |
43 | visible within current unit (ie it's address is never taken and it is not | |
44 | exported to other units). | |
45 | Currently used only for functions. */ | |
46 | AVAIL_LOCAL | |
47 | }; | |
48 | ||
d7f09764 DN |
49 | /* This is the information that is put into the cgraph local structure |
50 | to recover a function. */ | |
51 | struct lto_file_decl_data; | |
52 | ||
8a4a83ed JH |
53 | extern const char * const cgraph_availability_names[]; |
54 | ||
24b97832 ILT |
55 | /* Function inlining information. */ |
56 | ||
57 | struct GTY(()) inline_summary | |
58 | { | |
59 | /* Estimated stack frame consumption by the function. */ | |
60 | HOST_WIDE_INT estimated_self_stack_size; | |
61 | ||
85057983 JH |
62 | /* Size of the function body. */ |
63 | int self_size; | |
64 | /* How many instructions are likely going to disappear after inlining. */ | |
65 | int size_inlining_benefit; | |
66 | /* Estimated time spent executing the function body. */ | |
67 | int self_time; | |
68 | /* How much time is going to be saved by inlining. */ | |
69 | int time_inlining_benefit; | |
24b97832 ILT |
70 | }; |
71 | ||
dafc5b82 | 72 | /* Information about the function collected locally. |
25c84396 | 73 | Available after function is analyzed. */ |
dafc5b82 | 74 | |
d1b38208 | 75 | struct GTY(()) cgraph_local_info { |
d7f09764 DN |
76 | /* File stream where this node is being written to. */ |
77 | struct lto_file_decl_data * GTY ((skip)) lto_file_data; | |
78 | ||
24b97832 | 79 | struct inline_summary inline_summary; |
6674a6ce | 80 | |
e0bb17a8 | 81 | /* Set when function function is visible in current compilation unit only |
e2209b03 | 82 | and its address is never taken. */ |
b4e19405 | 83 | unsigned local : 1; |
6674a6ce | 84 | |
e7d6beb0 | 85 | /* Set when function is visible by other units. */ |
b4e19405 | 86 | unsigned externally_visible : 1; |
e7d6beb0 | 87 | |
f6981e16 | 88 | /* Set once it has been finalized so we consider it to be output. */ |
b4e19405 | 89 | unsigned finalized : 1; |
b58b1157 | 90 | |
b3c3af2f | 91 | /* False when there something makes inlining impossible (such as va_arg). */ |
b4e19405 | 92 | unsigned inlinable : 1; |
6674a6ce | 93 | |
e2209b03 | 94 | /* True when function should be inlined independently on its size. */ |
b4e19405 | 95 | unsigned disregard_inline_limits : 1; |
6674a6ce | 96 | |
95c755e9 JH |
97 | /* True when the function has been originally extern inline, but it is |
98 | redefined now. */ | |
b4e19405 | 99 | unsigned redefined_extern_inline : 1; |
6674a6ce KZ |
100 | |
101 | /* True if statics_read_for_function and | |
102 | statics_written_for_function contain valid data. */ | |
b4e19405 | 103 | unsigned for_functions_valid : 1; |
8634c649 JJ |
104 | |
105 | /* True if the function is going to be emitted in some other translation | |
106 | unit, referenced from vtable. */ | |
b4e19405 | 107 | unsigned vtable_method : 1; |
dafc5b82 JH |
108 | }; |
109 | ||
110 | /* Information about the function that needs to be computed globally | |
726a989a | 111 | once compilation is finished. Available only with -funit-at-a-time. */ |
dafc5b82 | 112 | |
d1b38208 | 113 | struct GTY(()) cgraph_global_info { |
ff28a94d JH |
114 | /* Estimated stack frame consumption by the function. */ |
115 | HOST_WIDE_INT estimated_stack_size; | |
116 | /* Expected offset of the stack frame of inlined function. */ | |
117 | HOST_WIDE_INT stack_frame_offset; | |
118 | ||
726a989a RB |
119 | /* For inline clones this points to the function they will be |
120 | inlined into. */ | |
18c6ada9 JH |
121 | struct cgraph_node *inlined_to; |
122 | ||
b58b1157 | 123 | /* Estimated size of the function after inlining. */ |
85057983 JH |
124 | int time; |
125 | int size; | |
b58b1157 | 126 | |
670cd5c5 JH |
127 | /* Estimated growth after inlining. INT_MIN if not computed. */ |
128 | int estimated_growth; | |
129 | ||
18c6ada9 | 130 | /* Set iff the function has been inlined at least once. */ |
1bb17c21 | 131 | bool inlined; |
dafc5b82 JH |
132 | }; |
133 | ||
b255a036 JH |
134 | /* Information about the function that is propagated by the RTL backend. |
135 | Available only for functions that has been already assembled. */ | |
136 | ||
d1b38208 | 137 | struct GTY(()) cgraph_rtl_info { |
17b29c0a | 138 | unsigned int preferred_incoming_stack_boundary; |
b255a036 JH |
139 | }; |
140 | ||
9187e02d JH |
141 | /* Represent which DECL tree (or reference to such tree) |
142 | will be replaced by another tree while versioning. */ | |
143 | struct GTY(()) ipa_replace_map | |
144 | { | |
145 | /* The tree that will be replaced. */ | |
146 | tree old_tree; | |
147 | /* The new (replacing) tree. */ | |
148 | tree new_tree; | |
149 | /* True when a substitution should be done, false otherwise. */ | |
150 | bool replace_p; | |
151 | /* True when we replace a reference to old_tree. */ | |
152 | bool ref_p; | |
153 | }; | |
154 | typedef struct ipa_replace_map *ipa_replace_map_p; | |
155 | DEF_VEC_P(ipa_replace_map_p); | |
156 | DEF_VEC_ALLOC_P(ipa_replace_map_p,gc); | |
157 | ||
158 | struct GTY(()) cgraph_clone_info | |
159 | { | |
160 | VEC(ipa_replace_map_p,gc)* tree_map; | |
161 | bitmap args_to_skip; | |
08ad1d6d | 162 | bitmap combined_args_to_skip; |
9187e02d JH |
163 | }; |
164 | ||
ba228239 | 165 | /* The cgraph data structure. |
e0bb17a8 | 166 | Each function decl has assigned cgraph_node listing callees and callers. */ |
1c4a429a | 167 | |
d1b38208 | 168 | struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node { |
1c4a429a JH |
169 | tree decl; |
170 | struct cgraph_edge *callees; | |
171 | struct cgraph_edge *callers; | |
ed2df68b JH |
172 | struct cgraph_node *next; |
173 | struct cgraph_node *previous; | |
1c4a429a JH |
174 | /* For nested functions points to function the node is nested in. */ |
175 | struct cgraph_node *origin; | |
176 | /* Points to first nested function, if any. */ | |
177 | struct cgraph_node *nested; | |
178 | /* Pointer to the next function with same origin, if any. */ | |
179 | struct cgraph_node *next_nested; | |
8bd87c4e JH |
180 | /* Pointer to the next function in cgraph_nodes_queue. */ |
181 | struct cgraph_node *next_needed; | |
18c6ada9 | 182 | /* Pointer to the next clone. */ |
9187e02d JH |
183 | struct cgraph_node *next_sibling_clone; |
184 | struct cgraph_node *prev_sibling_clone; | |
185 | struct cgraph_node *clones; | |
186 | struct cgraph_node *clone_of; | |
70d539ce JH |
187 | /* For functions with many calls sites it holds map from call expression |
188 | to the edge to speed up cgraph_edge function. */ | |
189 | htab_t GTY((param_is (struct cgraph_edge))) call_site_hash; | |
c22cacf3 | 190 | |
1431042e | 191 | PTR GTY ((skip)) aux; |
1c4a429a | 192 | |
95c755e9 JH |
193 | struct cgraph_local_info local; |
194 | struct cgraph_global_info global; | |
195 | struct cgraph_rtl_info rtl; | |
9187e02d | 196 | struct cgraph_clone_info clone; |
c22cacf3 | 197 | |
e42922b1 JH |
198 | /* Expected number of executions: calculated in profile.c. */ |
199 | gcov_type count; | |
95c755e9 JH |
200 | /* Unique id of the node. */ |
201 | int uid; | |
474eccc6 ILT |
202 | /* Ordering of all cgraph nodes. */ |
203 | int order; | |
b4e19405 | 204 | |
3691626c RG |
205 | /* unique id for profiling. pid is not suitable because of different |
206 | number of cfg nodes with -fprofile-generate and -fprofile-use */ | |
207 | int pid; | |
208 | ||
1c4a429a | 209 | /* Set when function must be output - it is externally visible |
e2209b03 | 210 | or its address is taken. */ |
b4e19405 | 211 | unsigned needed : 1; |
39ff5a96 JH |
212 | /* Set when function has address taken. */ |
213 | unsigned address_taken : 1; | |
6b20f353 DS |
214 | /* Set when decl is an abstract function pointed to by the |
215 | ABSTRACT_DECL_ORIGIN of a reachable function. */ | |
216 | unsigned abstract_and_needed : 1; | |
1c4a429a | 217 | /* Set when function is reachable by call from other function |
e0bb17a8 | 218 | that is either reachable or needed. */ |
b4e19405 | 219 | unsigned reachable : 1; |
50674e96 | 220 | /* Set once the function is lowered (i.e. its CFG is built). */ |
b4e19405 | 221 | unsigned lowered : 1; |
25c84396 RH |
222 | /* Set once the function has been instantiated and its callee |
223 | lists created. */ | |
b4e19405 | 224 | unsigned analyzed : 1; |
257eb6e3 JH |
225 | /* Set when function is scheduled to be processed by local passes. */ |
226 | unsigned process : 1; | |
12527dce | 227 | /* Set for aliases once they got through assemble_alias. */ |
b4e19405 | 228 | unsigned alias : 1; |
d88e5c37 JH |
229 | /* Set for nodes that was constructed and finalized by frontend. */ |
230 | unsigned finalized_by_frontend : 1; | |
1c4a429a JH |
231 | }; |
232 | ||
fed5ae11 DK |
233 | typedef struct cgraph_node *cgraph_node_ptr; |
234 | ||
235 | DEF_VEC_P(cgraph_node_ptr); | |
236 | DEF_VEC_ALLOC_P(cgraph_node_ptr,heap); | |
237 | DEF_VEC_ALLOC_P(cgraph_node_ptr,gc); | |
238 | ||
239 | /* A cgraph node set is a collection of cgraph nodes. A cgraph node | |
240 | can appear in multiple sets. */ | |
d1b38208 | 241 | struct GTY(()) cgraph_node_set_def |
fed5ae11 DK |
242 | { |
243 | htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab; | |
244 | VEC(cgraph_node_ptr, gc) *nodes; | |
245 | PTR GTY ((skip)) aux; | |
246 | }; | |
247 | ||
248 | typedef struct cgraph_node_set_def *cgraph_node_set; | |
249 | ||
250 | DEF_VEC_P(cgraph_node_set); | |
251 | DEF_VEC_ALLOC_P(cgraph_node_set,gc); | |
252 | DEF_VEC_ALLOC_P(cgraph_node_set,heap); | |
253 | ||
254 | /* A cgraph node set element contains an index in the vector of nodes in | |
255 | the set. */ | |
d1b38208 | 256 | struct GTY(()) cgraph_node_set_element_def |
fed5ae11 DK |
257 | { |
258 | struct cgraph_node *node; | |
259 | HOST_WIDE_INT index; | |
260 | }; | |
261 | ||
262 | typedef struct cgraph_node_set_element_def *cgraph_node_set_element; | |
263 | typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element; | |
264 | ||
265 | /* Iterator structure for cgraph node sets. */ | |
266 | typedef struct | |
267 | { | |
268 | cgraph_node_set set; | |
269 | unsigned index; | |
270 | } cgraph_node_set_iterator; | |
271 | ||
61a05df1 JH |
272 | #define DEFCIFCODE(code, string) CIF_ ## code, |
273 | /* Reasons for inlining failures. */ | |
274 | typedef enum { | |
275 | #include "cif-code.def" | |
276 | CIF_N_REASONS | |
277 | } cgraph_inline_failed_t; | |
278 | ||
d1b38208 | 279 | struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge { |
ed2df68b JH |
280 | struct cgraph_node *caller; |
281 | struct cgraph_node *callee; | |
2563c224 | 282 | struct cgraph_edge *prev_caller; |
1c4a429a | 283 | struct cgraph_edge *next_caller; |
2563c224 | 284 | struct cgraph_edge *prev_callee; |
1c4a429a | 285 | struct cgraph_edge *next_callee; |
726a989a | 286 | gimple call_stmt; |
d7f09764 DN |
287 | /* The stmt_uid of this call stmt. This is used by LTO to recover |
288 | the call_stmt when the function is serialized in. */ | |
289 | unsigned int lto_stmt_uid; | |
18c6ada9 | 290 | PTR GTY ((skip (""))) aux; |
61a05df1 JH |
291 | /* When equal to CIF_OK, inline this call. Otherwise, points to the |
292 | explanation why function was not inlined. */ | |
293 | cgraph_inline_failed_t inline_failed; | |
e42922b1 JH |
294 | /* Expected number of executions: calculated in profile.c. */ |
295 | gcov_type count; | |
45a80bb9 JH |
296 | /* Expected frequency of executions within the function. |
297 | When set to CGRAPH_FREQ_BASE, the edge is expected to be called once | |
298 | per function call. The range is 0 to CGRAPH_FREQ_MAX. */ | |
299 | int frequency; | |
e42922b1 | 300 | /* Depth of loop nest, 1 means no loop nest. */ |
2505c5ed | 301 | unsigned int loop_nest : 30; |
3e293154 MJ |
302 | /* Whether this edge describes a call that was originally indirect. */ |
303 | unsigned int indirect_call : 1; | |
d7f09764 DN |
304 | /* True if the corresponding CALL stmt cannot be inlined. */ |
305 | unsigned int call_stmt_cannot_inline_p : 1; | |
2505c5ed JH |
306 | /* Can this call throw externally? */ |
307 | unsigned int can_throw_external : 1; | |
9088c1cc MJ |
308 | /* Unique id of the edge. */ |
309 | int uid; | |
1c4a429a JH |
310 | }; |
311 | ||
45a80bb9 JH |
312 | #define CGRAPH_FREQ_BASE 1000 |
313 | #define CGRAPH_FREQ_MAX 100000 | |
314 | ||
b2c0ad40 KH |
315 | typedef struct cgraph_edge *cgraph_edge_p; |
316 | ||
317 | DEF_VEC_P(cgraph_edge_p); | |
318 | DEF_VEC_ALLOC_P(cgraph_edge_p,heap); | |
319 | ||
8a4a83ed JH |
320 | /* The varpool data structure. |
321 | Each static variable decl has assigned varpool_node. */ | |
e69529cd | 322 | |
d1b38208 | 323 | struct GTY((chain_next ("%h.next"))) varpool_node { |
e69529cd | 324 | tree decl; |
8a4a83ed JH |
325 | /* Pointer to the next function in varpool_nodes. */ |
326 | struct varpool_node *next; | |
327 | /* Pointer to the next function in varpool_nodes_queue. */ | |
328 | struct varpool_node *next_needed; | |
474eccc6 ILT |
329 | /* Ordering of all cgraph nodes. */ |
330 | int order; | |
e69529cd JH |
331 | |
332 | /* Set when function must be output - it is externally visible | |
e2209b03 | 333 | or its address is taken. */ |
b4e19405 | 334 | unsigned needed : 1; |
cd9c7bd2 JH |
335 | /* Needed variables might become dead by optimization. This flag |
336 | forces the variable to be output even if it appears dead otherwise. */ | |
b4e19405 | 337 | unsigned force_output : 1; |
cd9c7bd2 JH |
338 | /* Set once the variable has been instantiated and its callee |
339 | lists created. */ | |
b4e19405 | 340 | unsigned analyzed : 1; |
e69529cd | 341 | /* Set once it has been finalized so we consider it to be output. */ |
b4e19405 | 342 | unsigned finalized : 1; |
6b02a499 | 343 | /* Set when variable is scheduled to be assembled. */ |
b4e19405 | 344 | unsigned output : 1; |
e7d6beb0 | 345 | /* Set when function is visible by other units. */ |
b4e19405 | 346 | unsigned externally_visible : 1; |
1a612e0a | 347 | /* Set for aliases once they got through assemble_alias. */ |
b4e19405 | 348 | unsigned alias : 1; |
e69529cd JH |
349 | }; |
350 | ||
474eccc6 ILT |
351 | /* Every top level asm statement is put into a cgraph_asm_node. */ |
352 | ||
d1b38208 | 353 | struct GTY(()) cgraph_asm_node { |
474eccc6 ILT |
354 | /* Next asm node. */ |
355 | struct cgraph_asm_node *next; | |
356 | /* String for this asm node. */ | |
357 | tree asm_str; | |
358 | /* Ordering of all cgraph nodes. */ | |
359 | int order; | |
360 | }; | |
361 | ||
ed2df68b JH |
362 | extern GTY(()) struct cgraph_node *cgraph_nodes; |
363 | extern GTY(()) int cgraph_n_nodes; | |
b58b1157 | 364 | extern GTY(()) int cgraph_max_uid; |
9088c1cc | 365 | extern GTY(()) int cgraph_edge_max_uid; |
6bad2617 | 366 | extern GTY(()) int cgraph_max_pid; |
dafc5b82 | 367 | extern bool cgraph_global_info_ready; |
f45e0ad1 JH |
368 | enum cgraph_state |
369 | { | |
370 | /* Callgraph is being constructed. It is safe to add new functions. */ | |
371 | CGRAPH_STATE_CONSTRUCTION, | |
372 | /* Callgraph is built and IPA passes are being run. */ | |
373 | CGRAPH_STATE_IPA, | |
7a388ee4 JH |
374 | /* Callgraph is built and all functions are transformed to SSA form. */ |
375 | CGRAPH_STATE_IPA_SSA, | |
f45e0ad1 JH |
376 | /* Functions are now ordered and being passed to RTL expanders. */ |
377 | CGRAPH_STATE_EXPANSION, | |
378 | /* All cgraph expansion is done. */ | |
379 | CGRAPH_STATE_FINISHED | |
380 | }; | |
381 | extern enum cgraph_state cgraph_state; | |
e7d6beb0 | 382 | extern bool cgraph_function_flags_ready; |
ed2df68b | 383 | extern GTY(()) struct cgraph_node *cgraph_nodes_queue; |
f45e0ad1 | 384 | extern GTY(()) struct cgraph_node *cgraph_new_nodes; |
1c4a429a | 385 | |
474eccc6 ILT |
386 | extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes; |
387 | extern GTY(()) int cgraph_order; | |
e69529cd | 388 | |
1c4a429a | 389 | /* In cgraph.c */ |
439f7bc3 | 390 | void dump_cgraph (FILE *); |
c4e622b6 | 391 | void debug_cgraph (void); |
18c6ada9 | 392 | void dump_cgraph_node (FILE *, struct cgraph_node *); |
c4e622b6 | 393 | void debug_cgraph_node (struct cgraph_node *); |
ea99e0be | 394 | void cgraph_insert_node_to_hashtable (struct cgraph_node *node); |
18c6ada9 | 395 | void cgraph_remove_edge (struct cgraph_edge *); |
439f7bc3 | 396 | void cgraph_remove_node (struct cgraph_node *); |
9187e02d | 397 | void cgraph_remove_node_and_inline_clones (struct cgraph_node *); |
3a40c18a | 398 | void cgraph_release_function_body (struct cgraph_node *); |
2563c224 | 399 | void cgraph_node_remove_callees (struct cgraph_node *node); |
18c6ada9 JH |
400 | struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, |
401 | struct cgraph_node *, | |
726a989a | 402 | gimple, gcov_type, int, int); |
f9329c35 DS |
403 | |
404 | struct cgraph_node * cgraph_get_node (tree); | |
e42922b1 | 405 | struct cgraph_node *cgraph_node (tree); |
4537ec0c DN |
406 | struct cgraph_node *cgraph_node_for_asm (tree); |
407 | struct cgraph_node *cgraph_node_for_decl (tree); | |
726a989a RB |
408 | struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple); |
409 | void cgraph_set_call_stmt (struct cgraph_edge *, gimple); | |
9187e02d JH |
410 | void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple); |
411 | void cgraph_create_edge_including_clones (struct cgraph_node *, | |
412 | struct cgraph_node *, | |
413 | gimple, gcov_type, int, int, | |
414 | cgraph_inline_failed_t); | |
4b685e14 | 415 | void cgraph_update_edges_for_call_stmt (gimple, tree, gimple); |
439f7bc3 AJ |
416 | struct cgraph_local_info *cgraph_local_info (tree); |
417 | struct cgraph_global_info *cgraph_global_info (tree); | |
418 | struct cgraph_rtl_info *cgraph_rtl_info (tree); | |
419 | const char * cgraph_node_name (struct cgraph_node *); | |
c5a4444c | 420 | struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, |
d7f09764 DN |
421 | struct cgraph_node *, gimple, |
422 | unsigned, gcov_type, int, int, bool); | |
45a80bb9 | 423 | struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int, |
03ec7d01 | 424 | int, bool, VEC(cgraph_edge_p,heap) *); |
1c4a429a | 425 | |
18c6ada9 | 426 | void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *); |
e69529cd | 427 | |
474eccc6 ILT |
428 | struct cgraph_asm_node *cgraph_add_asm_node (tree); |
429 | ||
1bb17c21 | 430 | bool cgraph_function_possibly_inlined_p (tree); |
e42922b1 | 431 | void cgraph_unnest_node (struct cgraph_node *); |
1bb17c21 | 432 | |
6b02a499 | 433 | enum availability cgraph_function_body_availability (struct cgraph_node *); |
f45e0ad1 | 434 | void cgraph_add_new_function (tree, bool); |
61a05df1 | 435 | const char* cgraph_inline_failed_string (cgraph_inline_failed_t); |
9187e02d JH |
436 | struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node, |
437 | VEC(cgraph_edge_p,heap)*, | |
438 | VEC(ipa_replace_map_p,gc)* tree_map, | |
439 | bitmap args_to_skip); | |
6b02a499 | 440 | |
1c4a429a | 441 | /* In cgraphunit.c */ |
6b00c969 | 442 | void cgraph_finalize_function (tree, bool); |
f0c882ab | 443 | void cgraph_mark_if_needed (tree); |
439f7bc3 | 444 | void cgraph_finalize_compilation_unit (void); |
d7f09764 | 445 | void cgraph_optimize (void); |
8dafba3c | 446 | void cgraph_mark_needed_node (struct cgraph_node *); |
39ff5a96 | 447 | void cgraph_mark_address_taken_node (struct cgraph_node *); |
8dafba3c | 448 | void cgraph_mark_reachable_node (struct cgraph_node *); |
61a05df1 | 449 | bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason); |
18c6ada9 JH |
450 | bool cgraph_preserve_function_body_p (tree); |
451 | void verify_cgraph (void); | |
452 | void verify_cgraph_node (struct cgraph_node *); | |
35b6fdcf | 453 | void cgraph_build_static_cdtor (char which, tree body, int priority); |
6674a6ce | 454 | void cgraph_reset_static_var_maps (void); |
9b3e897d | 455 | void init_cgraph (void); |
57fb5341 | 456 | struct cgraph_node *cgraph_function_versioning (struct cgraph_node *, |
c22cacf3 | 457 | VEC(cgraph_edge_p,heap)*, |
9187e02d | 458 | VEC(ipa_replace_map_p,gc)*, |
c6f7cfc1 | 459 | bitmap); |
9187e02d | 460 | void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap); |
ea99e0be | 461 | struct cgraph_node *save_inline_function_body (struct cgraph_node *); |
8a4a83ed | 462 | void record_references_in_initializer (tree); |
f45e0ad1 | 463 | bool cgraph_process_new_functions (void); |
1c4a429a | 464 | |
d7f09764 DN |
465 | bool cgraph_decide_is_function_needed (struct cgraph_node *, tree); |
466 | ||
9088c1cc MJ |
467 | typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *); |
468 | typedef void (*cgraph_node_hook)(struct cgraph_node *, void *); | |
469 | typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *, | |
470 | void *); | |
471 | typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *, | |
472 | void *); | |
473 | struct cgraph_edge_hook_list; | |
474 | struct cgraph_node_hook_list; | |
475 | struct cgraph_2edge_hook_list; | |
476 | struct cgraph_2node_hook_list; | |
477 | struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *); | |
478 | void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *); | |
479 | struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook, | |
480 | void *); | |
481 | void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *); | |
129a37fc JH |
482 | struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook, |
483 | void *); | |
484 | void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *); | |
485 | void cgraph_call_function_insertion_hooks (struct cgraph_node *node); | |
9088c1cc MJ |
486 | struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *); |
487 | void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *); | |
488 | struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *); | |
489 | void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *); | |
9187e02d | 490 | void cgraph_materialize_all_clones (void); |
9088c1cc | 491 | |
917948d3 ZD |
492 | /* In cgraphbuild.c */ |
493 | unsigned int rebuild_cgraph_edges (void); | |
d7f09764 | 494 | void reset_inline_failed (struct cgraph_node *); |
9187e02d | 495 | int compute_call_stmt_bb_frequency (tree, basic_block bb); |
917948d3 | 496 | |
ca31b95f JH |
497 | /* In ipa.c */ |
498 | bool cgraph_remove_unreachable_nodes (bool, FILE *); | |
499 | int cgraph_postorder (struct cgraph_node **); | |
fed5ae11 DK |
500 | cgraph_node_set cgraph_node_set_new (void); |
501 | cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set, | |
502 | struct cgraph_node *); | |
503 | void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *); | |
504 | void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *); | |
505 | void dump_cgraph_node_set (FILE *, cgraph_node_set); | |
506 | void debug_cgraph_node_set (cgraph_node_set); | |
507 | ||
ca31b95f | 508 | |
fed5ae11 | 509 | /* In predict.c */ |
ca30a539 JH |
510 | bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e); |
511 | ||
8a4a83ed | 512 | /* In varpool.c */ |
8a4a83ed JH |
513 | extern GTY(()) struct varpool_node *varpool_nodes_queue; |
514 | extern GTY(()) struct varpool_node *varpool_nodes; | |
515 | ||
516 | struct varpool_node *varpool_node (tree); | |
517 | struct varpool_node *varpool_node_for_asm (tree asmname); | |
518 | void varpool_mark_needed_node (struct varpool_node *); | |
d85478c2 | 519 | void debug_varpool (void); |
8a4a83ed JH |
520 | void dump_varpool (FILE *); |
521 | void dump_varpool_node (FILE *, struct varpool_node *); | |
522 | ||
523 | void varpool_finalize_decl (tree); | |
524 | bool decide_is_variable_needed (struct varpool_node *, tree); | |
525 | enum availability cgraph_variable_initializer_availability (struct varpool_node *); | |
a550d677 MJ |
526 | void cgraph_make_node_local (struct cgraph_node *); |
527 | bool cgraph_node_can_be_local_p (struct cgraph_node *); | |
8a4a83ed JH |
528 | |
529 | bool varpool_assemble_pending_decls (void); | |
530 | bool varpool_assemble_decl (struct varpool_node *node); | |
531 | bool varpool_analyze_pending_decls (void); | |
8a4a83ed | 532 | void varpool_remove_unreferenced_decls (void); |
7386e3ee | 533 | void varpool_empty_needed_queue (void); |
8a4a83ed | 534 | |
68e56cc4 JH |
535 | /* Walk all reachable static variables. */ |
536 | #define FOR_EACH_STATIC_VARIABLE(node) \ | |
537 | for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed) | |
538 | ||
539 | /* Return first reachable static variable with initializer. */ | |
540 | static inline struct varpool_node * | |
541 | varpool_first_static_initializer (void) | |
542 | { | |
543 | struct varpool_node *node; | |
544 | for (node = varpool_nodes_queue; node; node = node->next_needed) | |
545 | { | |
546 | gcc_assert (TREE_CODE (node->decl) == VAR_DECL); | |
547 | if (DECL_INITIAL (node->decl)) | |
548 | return node; | |
549 | } | |
550 | return NULL; | |
551 | } | |
552 | ||
553 | /* Return next reachable static variable with initializer after NODE. */ | |
554 | static inline struct varpool_node * | |
555 | varpool_next_static_initializer (struct varpool_node *node) | |
556 | { | |
557 | for (node = node->next_needed; node; node = node->next_needed) | |
558 | { | |
559 | gcc_assert (TREE_CODE (node->decl) == VAR_DECL); | |
560 | if (DECL_INITIAL (node->decl)) | |
561 | return node; | |
562 | } | |
563 | return NULL; | |
564 | } | |
565 | ||
566 | /* Walk all static variables with initializer set. */ | |
567 | #define FOR_EACH_STATIC_INITIALIZER(node) \ | |
568 | for ((node) = varpool_first_static_initializer (); (node); \ | |
569 | (node) = varpool_next_static_initializer (node)) | |
570 | ||
ca31b95f | 571 | /* In ipa-inline.c */ |
06191a23 | 572 | void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool); |
1920df6c | 573 | unsigned int compute_inline_parameters (struct cgraph_node *); |
43d861a5 RL |
574 | |
575 | ||
576 | /* Create a new static variable of type TYPE. */ | |
577 | tree add_new_static_var (tree type); | |
578 | ||
d7f09764 DN |
579 | /* lto-cgraph.c */ |
580 | ||
581 | enum LTO_cgraph_tags | |
582 | { | |
583 | /* Must leave 0 for the stopper. */ | |
584 | LTO_cgraph_avail_node = 1, | |
585 | LTO_cgraph_overwritable_node, | |
586 | LTO_cgraph_unavail_node, | |
587 | LTO_cgraph_edge, | |
588 | LTO_cgraph_last_tag | |
589 | }; | |
590 | ||
591 | extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag]; | |
592 | ||
593 | #define LCC_NOT_FOUND (-1) | |
594 | ||
fed5ae11 DK |
595 | |
596 | /* Return true if iterator CSI points to nothing. */ | |
597 | static inline bool | |
598 | csi_end_p (cgraph_node_set_iterator csi) | |
599 | { | |
600 | return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes); | |
601 | } | |
602 | ||
603 | /* Advance iterator CSI. */ | |
604 | static inline void | |
605 | csi_next (cgraph_node_set_iterator *csi) | |
606 | { | |
607 | csi->index++; | |
608 | } | |
609 | ||
610 | /* Return the node pointed to by CSI. */ | |
611 | static inline struct cgraph_node * | |
612 | csi_node (cgraph_node_set_iterator csi) | |
613 | { | |
614 | return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index); | |
615 | } | |
616 | ||
617 | /* Return an iterator to the first node in SET. */ | |
618 | static inline cgraph_node_set_iterator | |
619 | csi_start (cgraph_node_set set) | |
620 | { | |
621 | cgraph_node_set_iterator csi; | |
622 | ||
623 | csi.set = set; | |
624 | csi.index = 0; | |
625 | return csi; | |
626 | } | |
627 | ||
628 | /* Return true if SET contains NODE. */ | |
629 | static inline bool | |
630 | cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set) | |
631 | { | |
632 | cgraph_node_set_iterator csi; | |
633 | csi = cgraph_node_set_find (set, node); | |
634 | return !csi_end_p (csi); | |
635 | } | |
636 | ||
637 | /* Return number of nodes in SET. */ | |
638 | static inline size_t | |
639 | cgraph_node_set_size (cgraph_node_set set) | |
640 | { | |
641 | return htab_elements (set->hashtab); | |
642 | } | |
643 | ||
d48e9cea OR |
644 | /* Uniquize all constants that appear in memory. |
645 | Each constant in memory thus far output is recorded | |
646 | in `const_desc_table'. */ | |
647 | ||
648 | struct GTY(()) constant_descriptor_tree { | |
649 | /* A MEM for the constant. */ | |
650 | rtx rtl; | |
651 | ||
652 | /* The value of the constant. */ | |
653 | tree value; | |
654 | ||
655 | /* Hash of value. Computing the hash from value each time | |
656 | hashfn is called can't work properly, as that means recursive | |
657 | use of the hash table during hash table expansion. */ | |
658 | hashval_t hash; | |
659 | }; | |
660 | ||
661 | /* Constant pool accessor function. */ | |
662 | htab_t constant_pool_htab (void); | |
fed5ae11 | 663 | |
1c4a429a | 664 | #endif /* GCC_CGRAPH_H */ |