PR c++/43856
[official-gcc/constexpr.git] / gcc / cgraph.h
blobc208cfaeb636c22a15845204021aee0c9a534b8b
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
6 This file is part of GCC.
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.
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.
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/>. */
22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H
24 #include "tree.h"
25 #include "basic-block.h"
27 enum availability
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
49 /* This is the information that is put into the cgraph local structure
50 to recover a function. */
51 struct lto_file_decl_data;
53 extern const char * const cgraph_availability_names[];
55 /* Function inlining information. */
57 struct GTY(()) inline_summary
59 /* Estimated stack frame consumption by the function. */
60 HOST_WIDE_INT estimated_self_stack_size;
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;
72 /* Information about thunk, used only for same body aliases. */
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;
85 /* Information about the function collected locally.
86 Available after function is analyzed. */
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;
92 struct inline_summary inline_summary;
94 /* Set when function function is visible in current compilation unit only
95 and its address is never taken. */
96 unsigned local : 1;
98 /* Set when function is visible by other units. */
99 unsigned externally_visible : 1;
101 /* Set once it has been finalized so we consider it to be output. */
102 unsigned finalized : 1;
104 /* False when there something makes inlining impossible (such as va_arg). */
105 unsigned inlinable : 1;
107 /* True when function should be inlined independently on its size. */
108 unsigned disregard_inline_limits : 1;
110 /* True when the function has been originally extern inline, but it is
111 redefined now. */
112 unsigned redefined_extern_inline : 1;
114 /* True if statics_read_for_function and
115 statics_written_for_function contain valid data. */
116 unsigned for_functions_valid : 1;
118 /* True if the function is going to be emitted in some other translation
119 unit, referenced from vtable. */
120 unsigned vtable_method : 1;
123 /* Information about the function that needs to be computed globally
124 once compilation is finished. Available only with -funit-at-a-time. */
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;
132 /* For inline clones this points to the function they will be
133 inlined into. */
134 struct cgraph_node *inlined_to;
136 /* Estimated size of the function after inlining. */
137 int time;
138 int size;
140 /* Estimated growth after inlining. INT_MIN if not computed. */
141 int estimated_growth;
143 /* Set iff the function has been inlined at least once. */
144 bool inlined;
147 /* Information about the function that is propagated by the RTL backend.
148 Available only for functions that has been already assembled. */
150 struct GTY(()) cgraph_rtl_info {
151 unsigned int preferred_incoming_stack_boundary;
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
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;
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);
171 struct GTY(()) cgraph_clone_info
173 VEC(ipa_replace_map_p,gc)* tree_map;
174 bitmap args_to_skip;
175 bitmap combined_args_to_skip;
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
193 /* The cgraph data structure.
194 Each function decl has assigned cgraph_node listing callees and callers. */
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 /* For nested functions points to function the node is nested in. */
203 struct cgraph_node *origin;
204 /* Points to first nested function, if any. */
205 struct cgraph_node *nested;
206 /* Pointer to the next function with same origin, if any. */
207 struct cgraph_node *next_nested;
208 /* Pointer to the next function in cgraph_nodes_queue. */
209 struct cgraph_node *next_needed;
210 /* Pointer to the next clone. */
211 struct cgraph_node *next_sibling_clone;
212 struct cgraph_node *prev_sibling_clone;
213 struct cgraph_node *clones;
214 struct cgraph_node *clone_of;
215 /* For normal nodes pointer to the list of alias and thunk nodes,
216 in alias/thunk nodes pointer to the normal node. */
217 struct cgraph_node *same_body;
218 /* Circular list of nodes in the same comdat group if non-NULL. */
219 struct cgraph_node *same_comdat_group;
220 /* For functions with many calls sites it holds map from call expression
221 to the edge to speed up cgraph_edge function. */
222 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
224 PTR GTY ((skip)) aux;
226 /* Interprocedural passes scheduled to have their transform functions
227 applied next time we execute local pass on them. We maintain it
228 per-function in order to allow IPA passes to introduce new functions. */
229 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
231 struct cgraph_local_info local;
232 struct cgraph_global_info global;
233 struct cgraph_rtl_info rtl;
234 struct cgraph_clone_info clone;
235 struct cgraph_thunk_info thunk;
237 /* Expected number of executions: calculated in profile.c. */
238 gcov_type count;
239 /* Unique id of the node. */
240 int uid;
241 /* Ordering of all cgraph nodes. */
242 int order;
244 /* unique id for profiling. pid is not suitable because of different
245 number of cfg nodes with -fprofile-generate and -fprofile-use */
246 int pid;
248 /* Set when function must be output for some reason. The primary
249 use of this flag is to mark functions needed to be output for
250 non-standard reason. Functions that are externally visible
251 or reachable from functions needed to be output are marked
252 by specialized flags. */
253 unsigned needed : 1;
254 /* Set when function has address taken.
255 In current implementation it imply needed flag. */
256 unsigned address_taken : 1;
257 /* Set when decl is an abstract function pointed to by the
258 ABSTRACT_DECL_ORIGIN of a reachable function. */
259 unsigned abstract_and_needed : 1;
260 /* Set when function is reachable by call from other function
261 that is either reachable or needed.
262 This flag is computed at original cgraph construction and then
263 updated in cgraph_remove_unreachable_nodes. Note that after
264 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
265 nodes when they are needed for virtual clone instantiation. */
266 unsigned reachable : 1;
267 /* Set when function is reachable by call from other LTRANS partition. */
268 unsigned reachable_from_other_partition : 1;
269 /* Set once the function is lowered (i.e. its CFG is built). */
270 unsigned lowered : 1;
271 /* Set once the function has been instantiated and its callee
272 lists created. */
273 unsigned analyzed : 1;
274 /* Set when function is available in the other LTO partition. */
275 unsigned in_other_partition : 1;
276 /* Set when function is scheduled to be processed by local passes. */
277 unsigned process : 1;
278 /* Set for aliases once they got through assemble_alias. */
279 unsigned alias : 1;
280 /* Set for nodes that was constructed and finalized by frontend. */
281 unsigned finalized_by_frontend : 1;
282 /* Set for alias and thunk nodes, same_body points to the node they are alias
283 of and they are linked through the next/previous pointers. */
284 unsigned same_body_alias : 1;
285 /* How commonly executed the node is. Initialized during branch
286 probabilities pass. */
287 ENUM_BITFIELD (node_frequency) frequency : 2;
290 typedef struct cgraph_node *cgraph_node_ptr;
292 DEF_VEC_P(cgraph_node_ptr);
293 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
294 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
296 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
297 can appear in multiple sets. */
298 struct GTY(()) cgraph_node_set_def
300 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
301 VEC(cgraph_node_ptr, gc) *nodes;
302 PTR GTY ((skip)) aux;
305 typedef struct cgraph_node_set_def *cgraph_node_set;
307 DEF_VEC_P(cgraph_node_set);
308 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
309 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
311 /* A cgraph node set element contains an index in the vector of nodes in
312 the set. */
313 struct GTY(()) cgraph_node_set_element_def
315 struct cgraph_node *node;
316 HOST_WIDE_INT index;
319 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
320 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
322 /* Iterator structure for cgraph node sets. */
323 typedef struct
325 cgraph_node_set set;
326 unsigned index;
327 } cgraph_node_set_iterator;
329 #define DEFCIFCODE(code, string) CIF_ ## code,
330 /* Reasons for inlining failures. */
331 typedef enum {
332 #include "cif-code.def"
333 CIF_N_REASONS
334 } cgraph_inline_failed_t;
336 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
337 /* Expected number of executions: calculated in profile.c. */
338 gcov_type count;
339 struct cgraph_node *caller;
340 struct cgraph_node *callee;
341 struct cgraph_edge *prev_caller;
342 struct cgraph_edge *next_caller;
343 struct cgraph_edge *prev_callee;
344 struct cgraph_edge *next_callee;
345 gimple call_stmt;
346 PTR GTY ((skip (""))) aux;
347 /* When equal to CIF_OK, inline this call. Otherwise, points to the
348 explanation why function was not inlined. */
349 cgraph_inline_failed_t inline_failed;
350 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
351 when the function is serialized in. */
352 unsigned int lto_stmt_uid;
353 /* Expected frequency of executions within the function.
354 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
355 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
356 int frequency;
357 /* Unique id of the edge. */
358 int uid;
359 /* Depth of loop nest, 1 means no loop nest. */
360 unsigned short int loop_nest;
361 /* Whether this edge describes a call that was originally indirect. */
362 unsigned int indirect_call : 1;
363 /* True if the corresponding CALL stmt cannot be inlined. */
364 unsigned int call_stmt_cannot_inline_p : 1;
365 /* Can this call throw externally? */
366 unsigned int can_throw_external : 1;
369 #define CGRAPH_FREQ_BASE 1000
370 #define CGRAPH_FREQ_MAX 100000
372 typedef struct cgraph_edge *cgraph_edge_p;
374 DEF_VEC_P(cgraph_edge_p);
375 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
377 /* The varpool data structure.
378 Each static variable decl has assigned varpool_node. */
380 struct GTY((chain_next ("%h.next"))) varpool_node {
381 tree decl;
382 /* Pointer to the next function in varpool_nodes. */
383 struct varpool_node *next;
384 /* Pointer to the next function in varpool_nodes_queue. */
385 struct varpool_node *next_needed;
386 /* For normal nodes a pointer to the first extra name alias. For alias
387 nodes a pointer to the normal node. */
388 struct varpool_node *extra_name;
389 /* Ordering of all cgraph nodes. */
390 int order;
392 /* Set when function must be output - it is externally visible
393 or its address is taken. */
394 unsigned needed : 1;
395 /* Needed variables might become dead by optimization. This flag
396 forces the variable to be output even if it appears dead otherwise. */
397 unsigned force_output : 1;
398 /* Set once the variable has been instantiated and its callee
399 lists created. */
400 unsigned analyzed : 1;
401 /* Set once it has been finalized so we consider it to be output. */
402 unsigned finalized : 1;
403 /* Set when variable is scheduled to be assembled. */
404 unsigned output : 1;
405 /* Set when function is visible by other units. */
406 unsigned externally_visible : 1;
407 /* Set for aliases once they got through assemble_alias. Also set for
408 extra name aliases in varpool_extra_name_alias. */
409 unsigned alias : 1;
412 /* Every top level asm statement is put into a cgraph_asm_node. */
414 struct GTY(()) cgraph_asm_node {
415 /* Next asm node. */
416 struct cgraph_asm_node *next;
417 /* String for this asm node. */
418 tree asm_str;
419 /* Ordering of all cgraph nodes. */
420 int order;
423 extern GTY(()) struct cgraph_node *cgraph_nodes;
424 extern GTY(()) int cgraph_n_nodes;
425 extern GTY(()) int cgraph_max_uid;
426 extern GTY(()) int cgraph_edge_max_uid;
427 extern GTY(()) int cgraph_max_pid;
428 extern bool cgraph_global_info_ready;
429 enum cgraph_state
431 /* Callgraph is being constructed. It is safe to add new functions. */
432 CGRAPH_STATE_CONSTRUCTION,
433 /* Callgraph is built and IPA passes are being run. */
434 CGRAPH_STATE_IPA,
435 /* Callgraph is built and all functions are transformed to SSA form. */
436 CGRAPH_STATE_IPA_SSA,
437 /* Functions are now ordered and being passed to RTL expanders. */
438 CGRAPH_STATE_EXPANSION,
439 /* All cgraph expansion is done. */
440 CGRAPH_STATE_FINISHED
442 extern enum cgraph_state cgraph_state;
443 extern bool cgraph_function_flags_ready;
444 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
445 extern GTY(()) struct cgraph_node *cgraph_new_nodes;
447 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
448 extern GTY(()) int cgraph_order;
450 /* In cgraph.c */
451 void dump_cgraph (FILE *);
452 void debug_cgraph (void);
453 void dump_cgraph_node (FILE *, struct cgraph_node *);
454 void debug_cgraph_node (struct cgraph_node *);
455 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
456 void cgraph_remove_edge (struct cgraph_edge *);
457 void cgraph_remove_node (struct cgraph_node *);
458 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
459 void cgraph_release_function_body (struct cgraph_node *);
460 void cgraph_node_remove_callees (struct cgraph_node *node);
461 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
462 struct cgraph_node *,
463 gimple, gcov_type, int, int);
465 struct cgraph_node * cgraph_get_node (tree);
466 struct cgraph_node *cgraph_node (tree);
467 bool cgraph_same_body_alias (tree, tree);
468 void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree);
469 void cgraph_remove_same_body_alias (struct cgraph_node *);
470 struct cgraph_node *cgraph_node_for_asm (tree);
471 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
472 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
473 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
474 void cgraph_create_edge_including_clones (struct cgraph_node *,
475 struct cgraph_node *,
476 gimple, gimple, gcov_type, int, int,
477 cgraph_inline_failed_t);
478 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
479 struct cgraph_local_info *cgraph_local_info (tree);
480 struct cgraph_global_info *cgraph_global_info (tree);
481 struct cgraph_rtl_info *cgraph_rtl_info (tree);
482 const char * cgraph_node_name (struct cgraph_node *);
483 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
484 struct cgraph_node *, gimple,
485 unsigned, gcov_type, int, int, bool);
486 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int,
487 int, bool, VEC(cgraph_edge_p,heap) *);
489 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
491 struct cgraph_asm_node *cgraph_add_asm_node (tree);
493 bool cgraph_function_possibly_inlined_p (tree);
494 void cgraph_unnest_node (struct cgraph_node *);
496 enum availability cgraph_function_body_availability (struct cgraph_node *);
497 void cgraph_add_new_function (tree, bool);
498 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
499 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
500 VEC(cgraph_edge_p,heap)*,
501 VEC(ipa_replace_map_p,gc)* tree_map,
502 bitmap args_to_skip);
504 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
505 void cgraph_set_readonly_flag (struct cgraph_node *, bool);
506 void cgraph_set_pure_flag (struct cgraph_node *, bool);
507 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool);
509 /* In cgraphunit.c */
510 void cgraph_finalize_function (tree, bool);
511 void cgraph_mark_if_needed (tree);
512 void cgraph_finalize_compilation_unit (void);
513 void cgraph_optimize (void);
514 void cgraph_mark_needed_node (struct cgraph_node *);
515 void cgraph_mark_address_taken_node (struct cgraph_node *);
516 void cgraph_mark_reachable_node (struct cgraph_node *);
517 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
518 bool cgraph_preserve_function_body_p (tree);
519 void verify_cgraph (void);
520 void verify_cgraph_node (struct cgraph_node *);
521 void cgraph_build_static_cdtor (char which, tree body, int priority);
522 void cgraph_reset_static_var_maps (void);
523 void init_cgraph (void);
524 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
525 VEC(cgraph_edge_p,heap)*,
526 VEC(ipa_replace_map_p,gc)*,
527 bitmap);
528 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
529 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
530 void record_references_in_initializer (tree, bool);
531 bool cgraph_process_new_functions (void);
533 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
535 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
536 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
537 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
538 void *);
539 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
540 void *);
541 struct cgraph_edge_hook_list;
542 struct cgraph_node_hook_list;
543 struct cgraph_2edge_hook_list;
544 struct cgraph_2node_hook_list;
545 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
546 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
547 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
548 void *);
549 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
550 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
551 void *);
552 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
553 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
554 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
555 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
556 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
557 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
558 void cgraph_materialize_all_clones (void);
559 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
560 bool cgraph_propagate_frequency (struct cgraph_node *node);
561 /* In cgraphbuild.c */
562 unsigned int rebuild_cgraph_edges (void);
563 void reset_inline_failed (struct cgraph_node *);
564 int compute_call_stmt_bb_frequency (tree, basic_block bb);
566 /* In ipa.c */
567 bool cgraph_remove_unreachable_nodes (bool, FILE *);
568 int cgraph_postorder (struct cgraph_node **);
569 cgraph_node_set cgraph_node_set_new (void);
570 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
571 struct cgraph_node *);
572 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
573 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
574 void dump_cgraph_node_set (FILE *, cgraph_node_set);
575 void debug_cgraph_node_set (cgraph_node_set);
578 /* In predict.c */
579 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
581 /* In varpool.c */
582 extern GTY(()) struct varpool_node *varpool_nodes_queue;
583 extern GTY(()) struct varpool_node *varpool_nodes;
585 struct varpool_node *varpool_node (tree);
586 struct varpool_node *varpool_node_for_asm (tree asmname);
587 void varpool_mark_needed_node (struct varpool_node *);
588 void debug_varpool (void);
589 void dump_varpool (FILE *);
590 void dump_varpool_node (FILE *, struct varpool_node *);
592 void varpool_finalize_decl (tree);
593 bool decide_is_variable_needed (struct varpool_node *, tree);
594 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
595 void cgraph_make_decl_local (tree);
596 void cgraph_make_node_local (struct cgraph_node *);
597 bool cgraph_node_can_be_local_p (struct cgraph_node *);
599 bool varpool_assemble_pending_decls (void);
600 bool varpool_assemble_decl (struct varpool_node *node);
601 bool varpool_analyze_pending_decls (void);
602 void varpool_remove_unreferenced_decls (void);
603 void varpool_empty_needed_queue (void);
604 bool varpool_extra_name_alias (tree, tree);
605 const char * varpool_node_name (struct varpool_node *node);
607 /* Walk all reachable static variables. */
608 #define FOR_EACH_STATIC_VARIABLE(node) \
609 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
611 /* Return first reachable static variable with initializer. */
612 static inline struct varpool_node *
613 varpool_first_static_initializer (void)
615 struct varpool_node *node;
616 for (node = varpool_nodes_queue; node; node = node->next_needed)
618 gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
619 if (DECL_INITIAL (node->decl))
620 return node;
622 return NULL;
625 /* Return next reachable static variable with initializer after NODE. */
626 static inline struct varpool_node *
627 varpool_next_static_initializer (struct varpool_node *node)
629 for (node = node->next_needed; node; node = node->next_needed)
631 gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
632 if (DECL_INITIAL (node->decl))
633 return node;
635 return NULL;
638 /* Walk all static variables with initializer set. */
639 #define FOR_EACH_STATIC_INITIALIZER(node) \
640 for ((node) = varpool_first_static_initializer (); (node); \
641 (node) = varpool_next_static_initializer (node))
643 /* In ipa-inline.c */
644 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
645 unsigned int compute_inline_parameters (struct cgraph_node *);
648 /* Create a new static variable of type TYPE. */
649 tree add_new_static_var (tree type);
651 /* lto-cgraph.c */
653 enum LTO_cgraph_tags
655 /* Must leave 0 for the stopper. */
656 LTO_cgraph_avail_node = 1,
657 LTO_cgraph_overwritable_node,
658 LTO_cgraph_unavail_node,
659 LTO_cgraph_edge,
660 LTO_cgraph_last_tag
663 extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag];
665 #define LCC_NOT_FOUND (-1)
668 /* Return true if iterator CSI points to nothing. */
669 static inline bool
670 csi_end_p (cgraph_node_set_iterator csi)
672 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
675 /* Advance iterator CSI. */
676 static inline void
677 csi_next (cgraph_node_set_iterator *csi)
679 csi->index++;
682 /* Return the node pointed to by CSI. */
683 static inline struct cgraph_node *
684 csi_node (cgraph_node_set_iterator csi)
686 return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
689 /* Return an iterator to the first node in SET. */
690 static inline cgraph_node_set_iterator
691 csi_start (cgraph_node_set set)
693 cgraph_node_set_iterator csi;
695 csi.set = set;
696 csi.index = 0;
697 return csi;
700 /* Return true if SET contains NODE. */
701 static inline bool
702 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
704 cgraph_node_set_iterator csi;
705 csi = cgraph_node_set_find (set, node);
706 return !csi_end_p (csi);
709 /* Return number of nodes in SET. */
710 static inline size_t
711 cgraph_node_set_size (cgraph_node_set set)
713 return htab_elements (set->hashtab);
716 /* Uniquize all constants that appear in memory.
717 Each constant in memory thus far output is recorded
718 in `const_desc_table'. */
720 struct GTY(()) constant_descriptor_tree {
721 /* A MEM for the constant. */
722 rtx rtl;
724 /* The value of the constant. */
725 tree value;
727 /* Hash of value. Computing the hash from value each time
728 hashfn is called can't work properly, as that means recursive
729 use of the hash table during hash table expansion. */
730 hashval_t hash;
733 /* Return true when function NODE is only called directly.
734 i.e. it is not externally visible, address was not taken and
735 it is not used in any other non-standard way. */
737 static inline bool
738 cgraph_only_called_directly_p (struct cgraph_node *node)
740 return !node->needed && !node->local.externally_visible;
743 /* Return true when function NODE can be removed from callgraph
744 if all direct calls are eliminated. */
746 static inline bool
747 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
749 return (!node->needed && !node->reachable_from_other_partition
750 && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
753 /* Constant pool accessor function. */
754 htab_t constant_pool_htab (void);
756 #endif /* GCC_CGRAPH_H */