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