1bd4b2c2d4cc2f8c43e3d1bf0cbfa04b96cdd034
[gcc.git] / gcc / cgraph.h
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
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
10 Software Foundation; either version 3, or (at your option) any later
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
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H
24 #include "tree.h"
25 #include "basic-block.h"
26
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
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
53 extern const char * const cgraph_availability_names[];
54
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
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;
70 };
71
72 /* Information about thunk, used only for same body aliases. */
73
74 struct GTY(()) cgraph_thunk_info {
75 /* Information about the thunk. */
76 HOST_WIDE_INT fixed_offset;
77 HOST_WIDE_INT virtual_value;
78 tree alias;
79 bool this_adjusting;
80 bool virtual_offset_p;
81 /* Set to true when alias node is thunk. */
82 bool thunk_p;
83 };
84
85 /* Information about the function collected locally.
86 Available after function is analyzed. */
87
88 struct GTY(()) cgraph_local_info {
89 /* File stream where this node is being written to. */
90 struct lto_file_decl_data * GTY ((skip)) lto_file_data;
91
92 struct inline_summary inline_summary;
93
94 /* Set when function function is visible in current compilation unit only
95 and its address is never taken. */
96 unsigned local : 1;
97
98 /* Set when function is visible by other units. */
99 unsigned externally_visible : 1;
100
101 /* Set once it has been finalized so we consider it to be output. */
102 unsigned finalized : 1;
103
104 /* False when there something makes inlining impossible (such as va_arg). */
105 unsigned inlinable : 1;
106
107 /* True when function should be inlined independently on its size. */
108 unsigned disregard_inline_limits : 1;
109
110 /* True when the function has been originally extern inline, but it is
111 redefined now. */
112 unsigned redefined_extern_inline : 1;
113
114 /* True if statics_read_for_function and
115 statics_written_for_function contain valid data. */
116 unsigned for_functions_valid : 1;
117
118 /* True if the function is going to be emitted in some other translation
119 unit, referenced from vtable. */
120 unsigned vtable_method : 1;
121 };
122
123 /* Information about the function that needs to be computed globally
124 once compilation is finished. Available only with -funit-at-a-time. */
125
126 struct GTY(()) cgraph_global_info {
127 /* Estimated stack frame consumption by the function. */
128 HOST_WIDE_INT estimated_stack_size;
129 /* Expected offset of the stack frame of inlined function. */
130 HOST_WIDE_INT stack_frame_offset;
131
132 /* For inline clones this points to the function they will be
133 inlined into. */
134 struct cgraph_node *inlined_to;
135
136 /* Estimated size of the function after inlining. */
137 int time;
138 int size;
139
140 /* Estimated growth after inlining. INT_MIN if not computed. */
141 int estimated_growth;
142
143 /* Set iff the function has been inlined at least once. */
144 bool inlined;
145 };
146
147 /* Information about the function that is propagated by the RTL backend.
148 Available only for functions that has been already assembled. */
149
150 struct GTY(()) cgraph_rtl_info {
151 unsigned int preferred_incoming_stack_boundary;
152 };
153
154 /* Represent which DECL tree (or reference to such tree)
155 will be replaced by another tree while versioning. */
156 struct GTY(()) ipa_replace_map
157 {
158 /* The tree that will be replaced. */
159 tree old_tree;
160 /* The new (replacing) tree. */
161 tree new_tree;
162 /* True when a substitution should be done, false otherwise. */
163 bool replace_p;
164 /* True when we replace a reference to old_tree. */
165 bool ref_p;
166 };
167 typedef struct ipa_replace_map *ipa_replace_map_p;
168 DEF_VEC_P(ipa_replace_map_p);
169 DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
170
171 struct GTY(()) cgraph_clone_info
172 {
173 VEC(ipa_replace_map_p,gc)* tree_map;
174 bitmap args_to_skip;
175 bitmap combined_args_to_skip;
176 };
177
178 enum node_frequency {
179 /* This function most likely won't be executed at all.
180 (set only when profile feedback is available or via function attribute). */
181 NODE_FREQUENCY_UNLIKELY_EXECUTED,
182 /* For functions that are known to be executed once (i.e. constructors, destructors
183 and main function. */
184 NODE_FREQUENCY_EXECUTED_ONCE,
185 /* The default value. */
186 NODE_FREQUENCY_NORMAL,
187 /* Optimize this function hard
188 (set only when profile feedback is available or via function attribute). */
189 NODE_FREQUENCY_HOT
190 };
191
192
193 /* The cgraph data structure.
194 Each function decl has assigned cgraph_node listing callees and callers. */
195
196 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
197 tree decl;
198 struct cgraph_edge *callees;
199 struct cgraph_edge *callers;
200 struct cgraph_node *next;
201 struct cgraph_node *previous;
202 /* List of edges representing indirect calls with a yet undetermined
203 callee. */
204 struct cgraph_edge *indirect_calls;
205 /* For nested functions points to function the node is nested in. */
206 struct cgraph_node *origin;
207 /* Points to first nested function, if any. */
208 struct cgraph_node *nested;
209 /* Pointer to the next function with same origin, if any. */
210 struct cgraph_node *next_nested;
211 /* Pointer to the next function in cgraph_nodes_queue. */
212 struct cgraph_node *next_needed;
213 /* Pointer to the next clone. */
214 struct cgraph_node *next_sibling_clone;
215 struct cgraph_node *prev_sibling_clone;
216 struct cgraph_node *clones;
217 struct cgraph_node *clone_of;
218 /* For normal nodes pointer to the list of alias and thunk nodes,
219 in alias/thunk nodes pointer to the normal node. */
220 struct cgraph_node *same_body;
221 /* Circular list of nodes in the same comdat group if non-NULL. */
222 struct cgraph_node *same_comdat_group;
223 /* For functions with many calls sites it holds map from call expression
224 to the edge to speed up cgraph_edge function. */
225 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
226
227 PTR GTY ((skip)) aux;
228
229 /* Interprocedural passes scheduled to have their transform functions
230 applied next time we execute local pass on them. We maintain it
231 per-function in order to allow IPA passes to introduce new functions. */
232 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
233
234 struct cgraph_local_info local;
235 struct cgraph_global_info global;
236 struct cgraph_rtl_info rtl;
237 struct cgraph_clone_info clone;
238 struct cgraph_thunk_info thunk;
239
240 /* Expected number of executions: calculated in profile.c. */
241 gcov_type count;
242 /* Unique id of the node. */
243 int uid;
244 /* Ordering of all cgraph nodes. */
245 int order;
246
247 /* unique id for profiling. pid is not suitable because of different
248 number of cfg nodes with -fprofile-generate and -fprofile-use */
249 int pid;
250
251 /* Set when function must be output for some reason. The primary
252 use of this flag is to mark functions needed to be output for
253 non-standard reason. Functions that are externally visible
254 or reachable from functions needed to be output are marked
255 by specialized flags. */
256 unsigned needed : 1;
257 /* Set when function has address taken.
258 In current implementation it imply needed flag. */
259 unsigned address_taken : 1;
260 /* Set when decl is an abstract function pointed to by the
261 ABSTRACT_DECL_ORIGIN of a reachable function. */
262 unsigned abstract_and_needed : 1;
263 /* Set when function is reachable by call from other function
264 that is either reachable or needed.
265 This flag is computed at original cgraph construction and then
266 updated in cgraph_remove_unreachable_nodes. Note that after
267 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
268 nodes when they are needed for virtual clone instantiation. */
269 unsigned reachable : 1;
270 /* Set when function is reachable by call from other LTRANS partition. */
271 unsigned reachable_from_other_partition : 1;
272 /* Set once the function is lowered (i.e. its CFG is built). */
273 unsigned lowered : 1;
274 /* Set once the function has been instantiated and its callee
275 lists created. */
276 unsigned analyzed : 1;
277 /* Set when function is available in the other LTO partition. */
278 unsigned in_other_partition : 1;
279 /* Set when function is scheduled to be processed by local passes. */
280 unsigned process : 1;
281 /* Set for aliases once they got through assemble_alias. */
282 unsigned alias : 1;
283 /* Set for nodes that was constructed and finalized by frontend. */
284 unsigned finalized_by_frontend : 1;
285 /* Set for alias and thunk nodes, same_body points to the node they are alias
286 of and they are linked through the next/previous pointers. */
287 unsigned same_body_alias : 1;
288 /* How commonly executed the node is. Initialized during branch
289 probabilities pass. */
290 ENUM_BITFIELD (node_frequency) frequency : 2;
291 };
292
293 typedef struct cgraph_node *cgraph_node_ptr;
294
295 DEF_VEC_P(cgraph_node_ptr);
296 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
297 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
298
299 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
300 can appear in multiple sets. */
301 struct GTY(()) cgraph_node_set_def
302 {
303 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
304 VEC(cgraph_node_ptr, gc) *nodes;
305 PTR GTY ((skip)) aux;
306 };
307
308 typedef struct cgraph_node_set_def *cgraph_node_set;
309
310 DEF_VEC_P(cgraph_node_set);
311 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
312 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
313
314 /* A cgraph node set element contains an index in the vector of nodes in
315 the set. */
316 struct GTY(()) cgraph_node_set_element_def
317 {
318 struct cgraph_node *node;
319 HOST_WIDE_INT index;
320 };
321
322 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
323 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
324
325 /* Iterator structure for cgraph node sets. */
326 typedef struct
327 {
328 cgraph_node_set set;
329 unsigned index;
330 } cgraph_node_set_iterator;
331
332 #define DEFCIFCODE(code, string) CIF_ ## code,
333 /* Reasons for inlining failures. */
334 typedef enum {
335 #include "cif-code.def"
336 CIF_N_REASONS
337 } cgraph_inline_failed_t;
338
339 /* Structure containing additional information about an indirect call. */
340
341 struct GTY(()) cgraph_indirect_call_info
342 {
343 /* Index of the parameter that is called. */
344 int param_index;
345 };
346
347 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
348 /* Expected number of executions: calculated in profile.c. */
349 gcov_type count;
350 struct cgraph_node *caller;
351 struct cgraph_node *callee;
352 struct cgraph_edge *prev_caller;
353 struct cgraph_edge *next_caller;
354 struct cgraph_edge *prev_callee;
355 struct cgraph_edge *next_callee;
356 gimple call_stmt;
357 /* Additional information about an indirect call. Not cleared when an edge
358 becomes direct. */
359 struct cgraph_indirect_call_info *indirect_info;
360 PTR GTY ((skip (""))) aux;
361 /* When equal to CIF_OK, inline this call. Otherwise, points to the
362 explanation why function was not inlined. */
363 cgraph_inline_failed_t inline_failed;
364 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
365 when the function is serialized in. */
366 unsigned int lto_stmt_uid;
367 /* Expected frequency of executions within the function.
368 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
369 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
370 int frequency;
371 /* Unique id of the edge. */
372 int uid;
373 /* Depth of loop nest, 1 means no loop nest. */
374 unsigned short int loop_nest;
375 /* Whether this edge was made direct by indirect inlining. */
376 unsigned int indirect_inlining_edge : 1;
377 /* Whether this edge describes an indirect call with an undetermined
378 callee. */
379 unsigned int indirect_unknown_callee : 1;
380 /* Whether this edge is still a dangling */
381 /* True if the corresponding CALL stmt cannot be inlined. */
382 unsigned int call_stmt_cannot_inline_p : 1;
383 /* Can this call throw externally? */
384 unsigned int can_throw_external : 1;
385 };
386
387 #define CGRAPH_FREQ_BASE 1000
388 #define CGRAPH_FREQ_MAX 100000
389
390 typedef struct cgraph_edge *cgraph_edge_p;
391
392 DEF_VEC_P(cgraph_edge_p);
393 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
394
395 /* The varpool data structure.
396 Each static variable decl has assigned varpool_node. */
397
398 struct GTY((chain_next ("%h.next"))) varpool_node {
399 tree decl;
400 /* Pointer to the next function in varpool_nodes. */
401 struct varpool_node *next;
402 /* Pointer to the next function in varpool_nodes_queue. */
403 struct varpool_node *next_needed;
404 /* For normal nodes a pointer to the first extra name alias. For alias
405 nodes a pointer to the normal node. */
406 struct varpool_node *extra_name;
407 /* Ordering of all cgraph nodes. */
408 int order;
409
410 /* Set when function must be output - it is externally visible
411 or its address is taken. */
412 unsigned needed : 1;
413 /* Needed variables might become dead by optimization. This flag
414 forces the variable to be output even if it appears dead otherwise. */
415 unsigned force_output : 1;
416 /* Set once the variable has been instantiated and its callee
417 lists created. */
418 unsigned analyzed : 1;
419 /* Set once it has been finalized so we consider it to be output. */
420 unsigned finalized : 1;
421 /* Set when variable is scheduled to be assembled. */
422 unsigned output : 1;
423 /* Set when function is visible by other units. */
424 unsigned externally_visible : 1;
425 /* Set for aliases once they got through assemble_alias. Also set for
426 extra name aliases in varpool_extra_name_alias. */
427 unsigned alias : 1;
428 };
429
430 /* Every top level asm statement is put into a cgraph_asm_node. */
431
432 struct GTY(()) cgraph_asm_node {
433 /* Next asm node. */
434 struct cgraph_asm_node *next;
435 /* String for this asm node. */
436 tree asm_str;
437 /* Ordering of all cgraph nodes. */
438 int order;
439 };
440
441 extern GTY(()) struct cgraph_node *cgraph_nodes;
442 extern GTY(()) int cgraph_n_nodes;
443 extern GTY(()) int cgraph_max_uid;
444 extern GTY(()) int cgraph_edge_max_uid;
445 extern GTY(()) int cgraph_max_pid;
446 extern bool cgraph_global_info_ready;
447 enum cgraph_state
448 {
449 /* Callgraph is being constructed. It is safe to add new functions. */
450 CGRAPH_STATE_CONSTRUCTION,
451 /* Callgraph is built and IPA passes are being run. */
452 CGRAPH_STATE_IPA,
453 /* Callgraph is built and all functions are transformed to SSA form. */
454 CGRAPH_STATE_IPA_SSA,
455 /* Functions are now ordered and being passed to RTL expanders. */
456 CGRAPH_STATE_EXPANSION,
457 /* All cgraph expansion is done. */
458 CGRAPH_STATE_FINISHED
459 };
460 extern enum cgraph_state cgraph_state;
461 extern bool cgraph_function_flags_ready;
462 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
463 extern GTY(()) struct cgraph_node *cgraph_new_nodes;
464
465 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
466 extern GTY(()) int cgraph_order;
467
468 /* In cgraph.c */
469 void dump_cgraph (FILE *);
470 void debug_cgraph (void);
471 void dump_cgraph_node (FILE *, struct cgraph_node *);
472 void debug_cgraph_node (struct cgraph_node *);
473 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
474 void cgraph_remove_edge (struct cgraph_edge *);
475 void cgraph_remove_node (struct cgraph_node *);
476 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
477 void cgraph_release_function_body (struct cgraph_node *);
478 void cgraph_node_remove_callees (struct cgraph_node *node);
479 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
480 struct cgraph_node *,
481 gimple, gcov_type, int, int);
482 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
483 gcov_type, int, int);
484 struct cgraph_node * cgraph_get_node (tree);
485 struct cgraph_node *cgraph_node (tree);
486 bool cgraph_same_body_alias (tree, tree);
487 void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree);
488 void cgraph_remove_same_body_alias (struct cgraph_node *);
489 struct cgraph_node *cgraph_node_for_asm (tree);
490 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
491 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
492 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
493 void cgraph_create_edge_including_clones (struct cgraph_node *,
494 struct cgraph_node *,
495 gimple, gimple, gcov_type, int, int,
496 cgraph_inline_failed_t);
497 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
498 struct cgraph_local_info *cgraph_local_info (tree);
499 struct cgraph_global_info *cgraph_global_info (tree);
500 struct cgraph_rtl_info *cgraph_rtl_info (tree);
501 const char * cgraph_node_name (struct cgraph_node *);
502 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
503 struct cgraph_node *, gimple,
504 unsigned, gcov_type, int, int, bool);
505 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int,
506 int, bool, VEC(cgraph_edge_p,heap) *);
507
508 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
509 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
510
511 struct cgraph_asm_node *cgraph_add_asm_node (tree);
512
513 bool cgraph_function_possibly_inlined_p (tree);
514 void cgraph_unnest_node (struct cgraph_node *);
515
516 enum availability cgraph_function_body_availability (struct cgraph_node *);
517 void cgraph_add_new_function (tree, bool);
518 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
519 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
520 VEC(cgraph_edge_p,heap)*,
521 VEC(ipa_replace_map_p,gc)* tree_map,
522 bitmap args_to_skip);
523
524 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
525 void cgraph_set_readonly_flag (struct cgraph_node *, bool);
526 void cgraph_set_pure_flag (struct cgraph_node *, bool);
527 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool);
528
529 /* In cgraphunit.c */
530 void cgraph_finalize_function (tree, bool);
531 void cgraph_mark_if_needed (tree);
532 void cgraph_finalize_compilation_unit (void);
533 void cgraph_optimize (void);
534 void cgraph_mark_needed_node (struct cgraph_node *);
535 void cgraph_mark_address_taken_node (struct cgraph_node *);
536 void cgraph_mark_reachable_node (struct cgraph_node *);
537 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
538 bool cgraph_preserve_function_body_p (tree);
539 void verify_cgraph (void);
540 void verify_cgraph_node (struct cgraph_node *);
541 void cgraph_build_static_cdtor (char which, tree body, int priority);
542 void cgraph_reset_static_var_maps (void);
543 void init_cgraph (void);
544 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
545 VEC(cgraph_edge_p,heap)*,
546 VEC(ipa_replace_map_p,gc)*,
547 bitmap);
548 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
549 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
550 void record_references_in_initializer (tree, bool);
551 bool cgraph_process_new_functions (void);
552
553 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
554
555 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
556 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
557 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
558 void *);
559 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
560 void *);
561 struct cgraph_edge_hook_list;
562 struct cgraph_node_hook_list;
563 struct cgraph_2edge_hook_list;
564 struct cgraph_2node_hook_list;
565 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
566 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
567 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
568 void *);
569 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
570 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
571 void *);
572 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
573 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
574 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
575 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
576 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
577 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
578 void cgraph_materialize_all_clones (void);
579 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
580 bool cgraph_propagate_frequency (struct cgraph_node *node);
581 /* In cgraphbuild.c */
582 unsigned int rebuild_cgraph_edges (void);
583 void reset_inline_failed (struct cgraph_node *);
584 int compute_call_stmt_bb_frequency (tree, basic_block bb);
585
586 /* In ipa.c */
587 bool cgraph_remove_unreachable_nodes (bool, FILE *);
588 int cgraph_postorder (struct cgraph_node **);
589 cgraph_node_set cgraph_node_set_new (void);
590 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
591 struct cgraph_node *);
592 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
593 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
594 void dump_cgraph_node_set (FILE *, cgraph_node_set);
595 void debug_cgraph_node_set (cgraph_node_set);
596
597
598 /* In predict.c */
599 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
600
601 /* In varpool.c */
602 extern GTY(()) struct varpool_node *varpool_nodes_queue;
603 extern GTY(()) struct varpool_node *varpool_nodes;
604
605 struct varpool_node *varpool_node (tree);
606 struct varpool_node *varpool_node_for_asm (tree asmname);
607 void varpool_mark_needed_node (struct varpool_node *);
608 void debug_varpool (void);
609 void dump_varpool (FILE *);
610 void dump_varpool_node (FILE *, struct varpool_node *);
611
612 void varpool_finalize_decl (tree);
613 bool decide_is_variable_needed (struct varpool_node *, tree);
614 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
615 void cgraph_make_decl_local (tree);
616 void cgraph_make_node_local (struct cgraph_node *);
617 bool cgraph_node_can_be_local_p (struct cgraph_node *);
618
619 bool varpool_assemble_pending_decls (void);
620 bool varpool_assemble_decl (struct varpool_node *node);
621 bool varpool_analyze_pending_decls (void);
622 void varpool_remove_unreferenced_decls (void);
623 void varpool_empty_needed_queue (void);
624 bool varpool_extra_name_alias (tree, tree);
625 const char * varpool_node_name (struct varpool_node *node);
626
627 /* Walk all reachable static variables. */
628 #define FOR_EACH_STATIC_VARIABLE(node) \
629 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
630
631 /* Return first reachable static variable with initializer. */
632 static inline struct varpool_node *
633 varpool_first_static_initializer (void)
634 {
635 struct varpool_node *node;
636 for (node = varpool_nodes_queue; node; node = node->next_needed)
637 {
638 gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
639 if (DECL_INITIAL (node->decl))
640 return node;
641 }
642 return NULL;
643 }
644
645 /* Return next reachable static variable with initializer after NODE. */
646 static inline struct varpool_node *
647 varpool_next_static_initializer (struct varpool_node *node)
648 {
649 for (node = node->next_needed; node; node = node->next_needed)
650 {
651 gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
652 if (DECL_INITIAL (node->decl))
653 return node;
654 }
655 return NULL;
656 }
657
658 /* Walk all static variables with initializer set. */
659 #define FOR_EACH_STATIC_INITIALIZER(node) \
660 for ((node) = varpool_first_static_initializer (); (node); \
661 (node) = varpool_next_static_initializer (node))
662
663 /* In ipa-inline.c */
664 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
665 unsigned int compute_inline_parameters (struct cgraph_node *);
666
667
668 /* Create a new static variable of type TYPE. */
669 tree add_new_static_var (tree type);
670
671 /* lto-cgraph.c */
672
673 enum LTO_cgraph_tags
674 {
675 /* Must leave 0 for the stopper. */
676 LTO_cgraph_avail_node = 1,
677 LTO_cgraph_overwritable_node,
678 LTO_cgraph_unavail_node,
679 LTO_cgraph_edge,
680 LTO_cgraph_indirect_edge,
681 LTO_cgraph_last_tag
682 };
683
684 extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag];
685
686 #define LCC_NOT_FOUND (-1)
687
688
689 /* Return true if iterator CSI points to nothing. */
690 static inline bool
691 csi_end_p (cgraph_node_set_iterator csi)
692 {
693 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
694 }
695
696 /* Advance iterator CSI. */
697 static inline void
698 csi_next (cgraph_node_set_iterator *csi)
699 {
700 csi->index++;
701 }
702
703 /* Return the node pointed to by CSI. */
704 static inline struct cgraph_node *
705 csi_node (cgraph_node_set_iterator csi)
706 {
707 return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
708 }
709
710 /* Return an iterator to the first node in SET. */
711 static inline cgraph_node_set_iterator
712 csi_start (cgraph_node_set set)
713 {
714 cgraph_node_set_iterator csi;
715
716 csi.set = set;
717 csi.index = 0;
718 return csi;
719 }
720
721 /* Return true if SET contains NODE. */
722 static inline bool
723 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
724 {
725 cgraph_node_set_iterator csi;
726 csi = cgraph_node_set_find (set, node);
727 return !csi_end_p (csi);
728 }
729
730 /* Return number of nodes in SET. */
731 static inline size_t
732 cgraph_node_set_size (cgraph_node_set set)
733 {
734 return htab_elements (set->hashtab);
735 }
736
737 /* Uniquize all constants that appear in memory.
738 Each constant in memory thus far output is recorded
739 in `const_desc_table'. */
740
741 struct GTY(()) constant_descriptor_tree {
742 /* A MEM for the constant. */
743 rtx rtl;
744
745 /* The value of the constant. */
746 tree value;
747
748 /* Hash of value. Computing the hash from value each time
749 hashfn is called can't work properly, as that means recursive
750 use of the hash table during hash table expansion. */
751 hashval_t hash;
752 };
753
754 /* Return true when function NODE is only called directly.
755 i.e. it is not externally visible, address was not taken and
756 it is not used in any other non-standard way. */
757
758 static inline bool
759 cgraph_only_called_directly_p (struct cgraph_node *node)
760 {
761 return !node->needed && !node->local.externally_visible;
762 }
763
764 /* Return true when function NODE can be removed from callgraph
765 if all direct calls are eliminated. */
766
767 static inline bool
768 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
769 {
770 return (!node->needed && !node->reachable_from_other_partition
771 && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
772 }
773
774 /* Constant pool accessor function. */
775 htab_t constant_pool_htab (void);
776
777 #endif /* GCC_CGRAPH_H */