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