re PR rtl-optimization/45621 (ICE: verify_cgraph_node failed: inlined_to pointer...
[official-gcc.git] / gcc / cgraph.h
blobd7ca67c692f6283f874ce42bdb8940fb3271e257
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
25 #include "plugin-api.h"
26 #include "vec.h"
27 #include "tree.h"
28 #include "basic-block.h"
29 #include "function.h"
30 #include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA. */
32 enum availability
34 /* Not yet set by cgraph_function_body_availability. */
35 AVAIL_UNSET,
36 /* Function body/variable initializer is unknown. */
37 AVAIL_NOT_AVAILABLE,
38 /* Function body/variable initializer is known but might be replaced
39 by a different one from other compilation unit and thus needs to
40 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
41 arbitrary side effects on escaping variables and functions, while
42 like AVAILABLE it might access static variables. */
43 AVAIL_OVERWRITABLE,
44 /* Function body/variable initializer is known and will be used in final
45 program. */
46 AVAIL_AVAILABLE,
47 /* Function body/variable initializer is known and all it's uses are explicitly
48 visible within current unit (ie it's address is never taken and it is not
49 exported to other units).
50 Currently used only for functions. */
51 AVAIL_LOCAL
54 /* This is the information that is put into the cgraph local structure
55 to recover a function. */
56 struct lto_file_decl_data;
58 extern const char * const cgraph_availability_names[];
60 /* Function inlining information. */
62 struct GTY(()) inline_summary
64 /* Estimated stack frame consumption by the function. */
65 HOST_WIDE_INT estimated_self_stack_size;
67 /* Size of the function body. */
68 int self_size;
69 /* How many instructions are likely going to disappear after inlining. */
70 int size_inlining_benefit;
71 /* Estimated time spent executing the function body. */
72 int self_time;
73 /* How much time is going to be saved by inlining. */
74 int time_inlining_benefit;
77 /* Information about thunk, used only for same body aliases. */
79 struct GTY(()) cgraph_thunk_info {
80 /* Information about the thunk. */
81 HOST_WIDE_INT fixed_offset;
82 HOST_WIDE_INT virtual_value;
83 tree alias;
84 bool this_adjusting;
85 bool virtual_offset_p;
86 /* Set to true when alias node is thunk. */
87 bool thunk_p;
90 /* Information about the function collected locally.
91 Available after function is analyzed. */
93 struct GTY(()) cgraph_local_info {
94 /* File stream where this node is being written to. */
95 struct lto_file_decl_data * lto_file_data;
97 struct inline_summary inline_summary;
99 /* Set when function function is visible in current compilation unit only
100 and its address is never taken. */
101 unsigned local : 1;
103 /* Set when function is visible by other units. */
104 unsigned externally_visible : 1;
106 /* Set once it has been finalized so we consider it to be output. */
107 unsigned finalized : 1;
109 /* False when there something makes inlining impossible (such as va_arg). */
110 unsigned inlinable : 1;
112 /* False when there something makes versioning impossible.
113 Currently computed and used only by ipa-cp. */
114 unsigned versionable : 1;
116 /* True when function should be inlined independently on its size. */
117 unsigned disregard_inline_limits : 1;
119 /* True when the function has been originally extern inline, but it is
120 redefined now. */
121 unsigned redefined_extern_inline : 1;
123 /* True if the function is going to be emitted in some other translation
124 unit, referenced from vtable. */
125 unsigned vtable_method : 1;
128 /* Information about the function that needs to be computed globally
129 once compilation is finished. Available only with -funit-at-a-time. */
131 struct GTY(()) cgraph_global_info {
132 /* Estimated stack frame consumption by the function. */
133 HOST_WIDE_INT estimated_stack_size;
134 /* Expected offset of the stack frame of inlined function. */
135 HOST_WIDE_INT stack_frame_offset;
137 /* For inline clones this points to the function they will be
138 inlined into. */
139 struct cgraph_node *inlined_to;
141 /* Estimated size of the function after inlining. */
142 int time;
143 int size;
145 /* Estimated growth after inlining. INT_MIN if not computed. */
146 int estimated_growth;
149 /* Information about the function that is propagated by the RTL backend.
150 Available only for functions that has been already assembled. */
152 struct GTY(()) cgraph_rtl_info {
153 unsigned int preferred_incoming_stack_boundary;
156 /* Represent which DECL tree (or reference to such tree)
157 will be replaced by another tree while versioning. */
158 struct GTY(()) ipa_replace_map
160 /* The tree that will be replaced. */
161 tree old_tree;
162 /* The new (replacing) tree. */
163 tree new_tree;
164 /* Parameter number to replace, when old_tree is NULL. */
165 int parm_num;
166 /* True when a substitution should be done, false otherwise. */
167 bool replace_p;
168 /* True when we replace a reference to old_tree. */
169 bool ref_p;
171 typedef struct ipa_replace_map *ipa_replace_map_p;
172 DEF_VEC_P(ipa_replace_map_p);
173 DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
175 struct GTY(()) cgraph_clone_info
177 VEC(ipa_replace_map_p,gc)* tree_map;
178 bitmap args_to_skip;
179 bitmap combined_args_to_skip;
182 enum node_frequency {
183 /* This function most likely won't be executed at all.
184 (set only when profile feedback is available or via function attribute). */
185 NODE_FREQUENCY_UNLIKELY_EXECUTED,
186 /* For functions that are known to be executed once (i.e. constructors, destructors
187 and main function. */
188 NODE_FREQUENCY_EXECUTED_ONCE,
189 /* The default value. */
190 NODE_FREQUENCY_NORMAL,
191 /* Optimize this function hard
192 (set only when profile feedback is available or via function attribute). */
193 NODE_FREQUENCY_HOT
197 /* The cgraph data structure.
198 Each function decl has assigned cgraph_node listing callees and callers. */
200 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
201 tree decl;
202 struct cgraph_edge *callees;
203 struct cgraph_edge *callers;
204 struct cgraph_node *next;
205 struct cgraph_node *previous;
206 /* List of edges representing indirect calls with a yet undetermined
207 callee. */
208 struct cgraph_edge *indirect_calls;
209 /* For nested functions points to function the node is nested in. */
210 struct cgraph_node *origin;
211 /* Points to first nested function, if any. */
212 struct cgraph_node *nested;
213 /* Pointer to the next function with same origin, if any. */
214 struct cgraph_node *next_nested;
215 /* Pointer to the next function in cgraph_nodes_queue. */
216 struct cgraph_node *next_needed;
217 /* Pointer to the next clone. */
218 struct cgraph_node *next_sibling_clone;
219 struct cgraph_node *prev_sibling_clone;
220 struct cgraph_node *clones;
221 struct cgraph_node *clone_of;
222 /* For normal nodes pointer to the list of alias and thunk nodes,
223 in alias/thunk nodes pointer to the normal node. */
224 struct cgraph_node *same_body;
225 /* Circular list of nodes in the same comdat group if non-NULL. */
226 struct cgraph_node *same_comdat_group;
227 /* For functions with many calls sites it holds map from call expression
228 to the edge to speed up cgraph_edge function. */
229 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
230 /* Declaration node used to be clone of. */
231 tree former_clone_of;
233 PTR GTY ((skip)) aux;
235 /* Interprocedural passes scheduled to have their transform functions
236 applied next time we execute local pass on them. We maintain it
237 per-function in order to allow IPA passes to introduce new functions. */
238 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
240 struct ipa_ref_list ref_list;
241 struct cgraph_local_info local;
242 struct cgraph_global_info global;
243 struct cgraph_rtl_info rtl;
244 struct cgraph_clone_info clone;
245 struct cgraph_thunk_info thunk;
247 /* Expected number of executions: calculated in profile.c. */
248 gcov_type count;
249 /* Unique id of the node. */
250 int uid;
251 /* Ordering of all cgraph nodes. */
252 int order;
254 /* unique id for profiling. pid is not suitable because of different
255 number of cfg nodes with -fprofile-generate and -fprofile-use */
256 int pid;
257 enum ld_plugin_symbol_resolution resolution;
259 /* Set when function must be output for some reason. The primary
260 use of this flag is to mark functions needed to be output for
261 non-standard reason. Functions that are externally visible
262 or reachable from functions needed to be output are marked
263 by specialized flags. */
264 unsigned needed : 1;
265 /* Set when function has address taken.
266 In current implementation it imply needed flag. */
267 unsigned address_taken : 1;
268 /* Set when decl is an abstract function pointed to by the
269 ABSTRACT_DECL_ORIGIN of a reachable function. */
270 unsigned abstract_and_needed : 1;
271 /* Set when function is reachable by call from other function
272 that is either reachable or needed.
273 This flag is computed at original cgraph construction and then
274 updated in cgraph_remove_unreachable_nodes. Note that after
275 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
276 nodes when they are needed for virtual clone instantiation. */
277 unsigned reachable : 1;
278 /* Set when function is reachable by call from other LTRANS partition. */
279 unsigned reachable_from_other_partition : 1;
280 /* Set once the function is lowered (i.e. its CFG is built). */
281 unsigned lowered : 1;
282 /* Set once the function has been instantiated and its callee
283 lists created. */
284 unsigned analyzed : 1;
285 /* Set when function is available in the other LTRANS partition.
286 During WPA output it is used to mark nodes that are present in
287 multiple partitions. */
288 unsigned in_other_partition : 1;
289 /* Set when function is scheduled to be processed by local passes. */
290 unsigned process : 1;
291 /* Set for aliases once they got through assemble_alias. */
292 unsigned alias : 1;
293 /* Set for nodes that was constructed and finalized by frontend. */
294 unsigned finalized_by_frontend : 1;
295 /* Set for alias and thunk nodes, same_body points to the node they are alias
296 of and they are linked through the next/previous pointers. */
297 unsigned same_body_alias : 1;
298 /* How commonly executed the node is. Initialized during branch
299 probabilities pass. */
300 ENUM_BITFIELD (node_frequency) frequency : 2;
303 typedef struct cgraph_node *cgraph_node_ptr;
305 DEF_VEC_P(cgraph_node_ptr);
306 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
307 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
309 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
310 can appear in multiple sets. */
311 struct GTY(()) cgraph_node_set_def
313 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
314 VEC(cgraph_node_ptr, gc) *nodes;
317 typedef struct varpool_node *varpool_node_ptr;
319 DEF_VEC_P(varpool_node_ptr);
320 DEF_VEC_ALLOC_P(varpool_node_ptr,heap);
321 DEF_VEC_ALLOC_P(varpool_node_ptr,gc);
323 /* A varpool node set is a collection of varpool nodes. A varpool node
324 can appear in multiple sets. */
325 struct GTY(()) varpool_node_set_def
327 htab_t GTY((param_is (struct varpool_node_set_element_def))) hashtab;
328 VEC(varpool_node_ptr, gc) *nodes;
331 typedef struct cgraph_node_set_def *cgraph_node_set;
333 DEF_VEC_P(cgraph_node_set);
334 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
335 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
337 typedef struct varpool_node_set_def *varpool_node_set;
339 DEF_VEC_P(varpool_node_set);
340 DEF_VEC_ALLOC_P(varpool_node_set,gc);
341 DEF_VEC_ALLOC_P(varpool_node_set,heap);
343 /* A cgraph node set element contains an index in the vector of nodes in
344 the set. */
345 struct GTY(()) cgraph_node_set_element_def
347 struct cgraph_node *node;
348 HOST_WIDE_INT index;
351 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
352 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
354 /* Iterator structure for cgraph node sets. */
355 typedef struct
357 cgraph_node_set set;
358 unsigned index;
359 } cgraph_node_set_iterator;
361 /* A varpool node set element contains an index in the vector of nodes in
362 the set. */
363 struct GTY(()) varpool_node_set_element_def
365 struct varpool_node *node;
366 HOST_WIDE_INT index;
369 typedef struct varpool_node_set_element_def *varpool_node_set_element;
370 typedef const struct varpool_node_set_element_def *const_varpool_node_set_element;
372 /* Iterator structure for varpool node sets. */
373 typedef struct
375 varpool_node_set set;
376 unsigned index;
377 } varpool_node_set_iterator;
379 #define DEFCIFCODE(code, string) CIF_ ## code,
380 /* Reasons for inlining failures. */
381 typedef enum {
382 #include "cif-code.def"
383 CIF_N_REASONS
384 } cgraph_inline_failed_t;
386 /* Structure containing additional information about an indirect call. */
388 struct GTY(()) cgraph_indirect_call_info
390 /* Offset accumulated from ancestor jump functions of inlined call graph
391 edges. */
392 HOST_WIDE_INT anc_offset;
393 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
394 HOST_WIDE_INT otr_token;
395 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
396 tree otr_type;
397 /* Index of the parameter that is called. */
398 int param_index;
399 /* ECF flags determined from the caller. */
400 int ecf_flags;
402 /* Set when the call is a virtual call with the parameter being the
403 associated object pointer rather than a simple direct call. */
404 unsigned polymorphic : 1;
407 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
408 /* Expected number of executions: calculated in profile.c. */
409 gcov_type count;
410 struct cgraph_node *caller;
411 struct cgraph_node *callee;
412 struct cgraph_edge *prev_caller;
413 struct cgraph_edge *next_caller;
414 struct cgraph_edge *prev_callee;
415 struct cgraph_edge *next_callee;
416 gimple call_stmt;
417 /* Additional information about an indirect call. Not cleared when an edge
418 becomes direct. */
419 struct cgraph_indirect_call_info *indirect_info;
420 PTR GTY ((skip (""))) aux;
421 /* When equal to CIF_OK, inline this call. Otherwise, points to the
422 explanation why function was not inlined. */
423 cgraph_inline_failed_t inline_failed;
424 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
425 when the function is serialized in. */
426 unsigned int lto_stmt_uid;
427 /* Expected frequency of executions within the function.
428 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
429 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
430 int frequency;
431 /* Unique id of the edge. */
432 int uid;
433 /* Depth of loop nest, 1 means no loop nest. */
434 unsigned short int loop_nest;
435 /* Whether this edge was made direct by indirect inlining. */
436 unsigned int indirect_inlining_edge : 1;
437 /* Whether this edge describes an indirect call with an undetermined
438 callee. */
439 unsigned int indirect_unknown_callee : 1;
440 /* Whether this edge is still a dangling */
441 /* True if the corresponding CALL stmt cannot be inlined. */
442 unsigned int call_stmt_cannot_inline_p : 1;
443 /* Can this call throw externally? */
444 unsigned int can_throw_external : 1;
447 #define CGRAPH_FREQ_BASE 1000
448 #define CGRAPH_FREQ_MAX 100000
450 typedef struct cgraph_edge *cgraph_edge_p;
452 DEF_VEC_P(cgraph_edge_p);
453 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
455 /* The varpool data structure.
456 Each static variable decl has assigned varpool_node. */
458 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node {
459 tree decl;
460 /* Pointer to the next function in varpool_nodes. */
461 struct varpool_node *next, *prev;
462 /* Pointer to the next function in varpool_nodes_queue. */
463 struct varpool_node *next_needed, *prev_needed;
464 /* For normal nodes a pointer to the first extra name alias. For alias
465 nodes a pointer to the normal node. */
466 struct varpool_node *extra_name;
467 /* Circular list of nodes in the same comdat group if non-NULL. */
468 struct varpool_node *same_comdat_group;
469 struct ipa_ref_list ref_list;
470 /* File stream where this node is being written to. */
471 struct lto_file_decl_data * lto_file_data;
472 PTR GTY ((skip)) aux;
473 /* Ordering of all cgraph nodes. */
474 int order;
475 enum ld_plugin_symbol_resolution resolution;
477 /* Set when function must be output - it is externally visible
478 or its address is taken. */
479 unsigned needed : 1;
480 /* Needed variables might become dead by optimization. This flag
481 forces the variable to be output even if it appears dead otherwise. */
482 unsigned force_output : 1;
483 /* Set once the variable has been instantiated and its callee
484 lists created. */
485 unsigned analyzed : 1;
486 /* Set once it has been finalized so we consider it to be output. */
487 unsigned finalized : 1;
488 /* Set when variable is scheduled to be assembled. */
489 unsigned output : 1;
490 /* Set when function is visible by other units. */
491 unsigned externally_visible : 1;
492 /* Set for aliases once they got through assemble_alias. Also set for
493 extra name aliases in varpool_extra_name_alias. */
494 unsigned alias : 1;
495 /* Set when variable is used from other LTRANS partition. */
496 unsigned used_from_other_partition : 1;
497 /* Set when variable is available in the other LTRANS partition.
498 During WPA output it is used to mark nodes that are present in
499 multiple partitions. */
500 unsigned in_other_partition : 1;
503 /* Every top level asm statement is put into a cgraph_asm_node. */
505 struct GTY(()) cgraph_asm_node {
506 /* Next asm node. */
507 struct cgraph_asm_node *next;
508 /* String for this asm node. */
509 tree asm_str;
510 /* Ordering of all cgraph nodes. */
511 int order;
514 extern GTY(()) struct cgraph_node *cgraph_nodes;
515 extern GTY(()) int cgraph_n_nodes;
516 extern GTY(()) int cgraph_max_uid;
517 extern GTY(()) int cgraph_edge_max_uid;
518 extern GTY(()) int cgraph_max_pid;
519 extern bool cgraph_global_info_ready;
520 enum cgraph_state
522 /* Callgraph is being constructed. It is safe to add new functions. */
523 CGRAPH_STATE_CONSTRUCTION,
524 /* Callgraph is built and IPA passes are being run. */
525 CGRAPH_STATE_IPA,
526 /* Callgraph is built and all functions are transformed to SSA form. */
527 CGRAPH_STATE_IPA_SSA,
528 /* Functions are now ordered and being passed to RTL expanders. */
529 CGRAPH_STATE_EXPANSION,
530 /* All cgraph expansion is done. */
531 CGRAPH_STATE_FINISHED
533 extern enum cgraph_state cgraph_state;
534 extern bool cgraph_function_flags_ready;
535 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
536 extern GTY(()) struct cgraph_node *cgraph_new_nodes;
538 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
539 extern GTY(()) int cgraph_order;
541 /* In cgraph.c */
542 void dump_cgraph (FILE *);
543 void debug_cgraph (void);
544 void dump_cgraph_node (FILE *, struct cgraph_node *);
545 void debug_cgraph_node (struct cgraph_node *);
546 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
547 void cgraph_remove_edge (struct cgraph_edge *);
548 void cgraph_remove_node (struct cgraph_node *);
549 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
550 void cgraph_release_function_body (struct cgraph_node *);
551 void cgraph_node_remove_callees (struct cgraph_node *node);
552 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
553 struct cgraph_node *,
554 gimple, gcov_type, int, int);
555 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple, int,
556 gcov_type, int, int);
557 struct cgraph_node * cgraph_get_node (const_tree);
558 struct cgraph_node * cgraph_get_node_or_alias (const_tree);
559 struct cgraph_node * cgraph_node (tree);
560 struct cgraph_node * cgraph_same_body_alias (tree, tree);
561 struct cgraph_node * cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT,
562 HOST_WIDE_INT, tree, tree);
563 void cgraph_remove_same_body_alias (struct cgraph_node *);
564 struct cgraph_node *cgraph_node_for_asm (tree);
565 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
566 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
567 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
568 void cgraph_create_edge_including_clones (struct cgraph_node *,
569 struct cgraph_node *,
570 gimple, gimple, gcov_type, int, int,
571 cgraph_inline_failed_t);
572 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
573 struct cgraph_local_info *cgraph_local_info (tree);
574 struct cgraph_global_info *cgraph_global_info (tree);
575 struct cgraph_rtl_info *cgraph_rtl_info (tree);
576 const char * cgraph_node_name (struct cgraph_node *);
577 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
578 struct cgraph_node *, gimple,
579 unsigned, gcov_type, int, int, bool);
580 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int,
581 int, bool, VEC(cgraph_edge_p,heap) *);
583 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
584 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
586 struct cgraph_asm_node *cgraph_add_asm_node (tree);
588 bool cgraph_function_possibly_inlined_p (tree);
589 void cgraph_unnest_node (struct cgraph_node *);
591 enum availability cgraph_function_body_availability (struct cgraph_node *);
592 void cgraph_add_new_function (tree, bool);
593 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
594 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
595 VEC(cgraph_edge_p,heap)*,
596 VEC(ipa_replace_map_p,gc)* tree_map,
597 bitmap args_to_skip,
598 const char *clone_name);
600 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
601 void cgraph_set_readonly_flag (struct cgraph_node *, bool);
602 void cgraph_set_pure_flag (struct cgraph_node *, bool);
603 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool);
604 tree clone_function_name (tree decl, const char *);
605 bool cgraph_node_cannot_return (struct cgraph_node *);
606 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
607 bool cgraph_will_be_removed_from_program_if_no_direct_calls
608 (struct cgraph_node *node);
609 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
610 (struct cgraph_node *node);
611 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution);
612 bool cgraph_used_from_object_file_p (struct cgraph_node *node);
613 bool varpool_used_from_object_file_p (struct varpool_node *node);
615 /* In cgraphunit.c */
616 extern FILE *cgraph_dump_file;
617 void cgraph_finalize_function (tree, bool);
618 void cgraph_mark_if_needed (tree);
619 void cgraph_finalize_compilation_unit (void);
620 void cgraph_optimize (void);
621 void cgraph_mark_needed_node (struct cgraph_node *);
622 void cgraph_mark_address_taken_node (struct cgraph_node *);
623 void cgraph_mark_reachable_node (struct cgraph_node *);
624 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
625 bool cgraph_preserve_function_body_p (tree);
626 void verify_cgraph (void);
627 void verify_cgraph_node (struct cgraph_node *);
628 void cgraph_build_static_cdtor (char which, tree body, int priority);
629 void cgraph_reset_static_var_maps (void);
630 void init_cgraph (void);
631 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
632 VEC(cgraph_edge_p,heap)*,
633 VEC(ipa_replace_map_p,gc)*,
634 bitmap, bitmap, basic_block,
635 const char *);
636 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap,
637 bitmap, basic_block);
638 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
639 void record_references_in_initializer (tree, bool);
640 bool cgraph_process_new_functions (void);
642 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
644 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
645 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
646 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
647 void *);
648 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
649 void *);
650 struct cgraph_edge_hook_list;
651 struct cgraph_node_hook_list;
652 struct cgraph_2edge_hook_list;
653 struct cgraph_2node_hook_list;
654 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
655 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
656 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
657 void *);
658 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
659 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
660 void *);
661 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
662 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
663 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
664 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
665 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
666 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
667 void cgraph_materialize_all_clones (void);
668 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
669 bool cgraph_propagate_frequency (struct cgraph_node *node);
670 /* In cgraphbuild.c */
671 unsigned int rebuild_cgraph_edges (void);
672 void cgraph_rebuild_references (void);
673 void reset_inline_failed (struct cgraph_node *);
674 int compute_call_stmt_bb_frequency (tree, basic_block bb);
676 /* In ipa.c */
677 bool cgraph_remove_unreachable_nodes (bool, FILE *);
678 int cgraph_postorder (struct cgraph_node **);
679 cgraph_node_set cgraph_node_set_new (void);
680 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
681 struct cgraph_node *);
682 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
683 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
684 void dump_cgraph_node_set (FILE *, cgraph_node_set);
685 void debug_cgraph_node_set (cgraph_node_set);
687 varpool_node_set varpool_node_set_new (void);
688 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
689 struct varpool_node *);
690 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
691 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
692 void dump_varpool_node_set (FILE *, varpool_node_set);
693 void debug_varpool_node_set (varpool_node_set);
694 void ipa_discover_readonly_nonaddressable_vars (void);
696 /* In predict.c */
697 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
699 /* In varpool.c */
700 extern GTY(()) struct varpool_node *varpool_nodes_queue;
701 extern GTY(()) struct varpool_node *varpool_nodes;
703 struct varpool_node *varpool_node (tree);
704 struct varpool_node *varpool_node_for_asm (tree asmname);
705 void varpool_mark_needed_node (struct varpool_node *);
706 void debug_varpool (void);
707 void dump_varpool (FILE *);
708 void dump_varpool_node (FILE *, struct varpool_node *);
710 void varpool_finalize_decl (tree);
711 bool decide_is_variable_needed (struct varpool_node *, tree);
712 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
713 void cgraph_make_decl_local (tree);
714 void cgraph_make_node_local (struct cgraph_node *);
715 bool cgraph_node_can_be_local_p (struct cgraph_node *);
718 struct varpool_node * varpool_get_node (const_tree decl);
719 void varpool_remove_node (struct varpool_node *node);
720 bool varpool_assemble_pending_decls (void);
721 bool varpool_assemble_decl (struct varpool_node *node);
722 bool varpool_analyze_pending_decls (void);
723 void varpool_remove_unreferenced_decls (void);
724 void varpool_empty_needed_queue (void);
725 struct varpool_node * varpool_extra_name_alias (tree, tree);
726 const char * varpool_node_name (struct varpool_node *node);
727 void varpool_reset_queue (void);
728 bool const_value_known_p (tree);
730 /* Walk all reachable static variables. */
731 #define FOR_EACH_STATIC_VARIABLE(node) \
732 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
734 /* Return first reachable static variable with initializer. */
735 static inline struct varpool_node *
736 varpool_first_static_initializer (void)
738 struct varpool_node *node;
739 for (node = varpool_nodes_queue; node; node = node->next_needed)
741 gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
742 if (DECL_INITIAL (node->decl))
743 return node;
745 return NULL;
748 /* Return next reachable static variable with initializer after NODE. */
749 static inline struct varpool_node *
750 varpool_next_static_initializer (struct varpool_node *node)
752 for (node = node->next_needed; node; node = node->next_needed)
754 gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
755 if (DECL_INITIAL (node->decl))
756 return node;
758 return NULL;
761 /* Walk all static variables with initializer set. */
762 #define FOR_EACH_STATIC_INITIALIZER(node) \
763 for ((node) = varpool_first_static_initializer (); (node); \
764 (node) = varpool_next_static_initializer (node))
766 /* In ipa-inline.c */
767 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
768 unsigned int compute_inline_parameters (struct cgraph_node *);
771 /* Create a new static variable of type TYPE. */
772 tree add_new_static_var (tree type);
774 /* Return true if iterator CSI points to nothing. */
775 static inline bool
776 csi_end_p (cgraph_node_set_iterator csi)
778 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
781 /* Advance iterator CSI. */
782 static inline void
783 csi_next (cgraph_node_set_iterator *csi)
785 csi->index++;
788 /* Return the node pointed to by CSI. */
789 static inline struct cgraph_node *
790 csi_node (cgraph_node_set_iterator csi)
792 return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
795 /* Return an iterator to the first node in SET. */
796 static inline cgraph_node_set_iterator
797 csi_start (cgraph_node_set set)
799 cgraph_node_set_iterator csi;
801 csi.set = set;
802 csi.index = 0;
803 return csi;
806 /* Return true if SET contains NODE. */
807 static inline bool
808 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
810 cgraph_node_set_iterator csi;
811 csi = cgraph_node_set_find (set, node);
812 return !csi_end_p (csi);
815 /* Return number of nodes in SET. */
816 static inline size_t
817 cgraph_node_set_size (cgraph_node_set set)
819 return htab_elements (set->hashtab);
822 /* Return true if iterator VSI points to nothing. */
823 static inline bool
824 vsi_end_p (varpool_node_set_iterator vsi)
826 return vsi.index >= VEC_length (varpool_node_ptr, vsi.set->nodes);
829 /* Advance iterator VSI. */
830 static inline void
831 vsi_next (varpool_node_set_iterator *vsi)
833 vsi->index++;
836 /* Return the node pointed to by VSI. */
837 static inline struct varpool_node *
838 vsi_node (varpool_node_set_iterator vsi)
840 return VEC_index (varpool_node_ptr, vsi.set->nodes, vsi.index);
843 /* Return an iterator to the first node in SET. */
844 static inline varpool_node_set_iterator
845 vsi_start (varpool_node_set set)
847 varpool_node_set_iterator vsi;
849 vsi.set = set;
850 vsi.index = 0;
851 return vsi;
854 /* Return true if SET contains NODE. */
855 static inline bool
856 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
858 varpool_node_set_iterator vsi;
859 vsi = varpool_node_set_find (set, node);
860 return !vsi_end_p (vsi);
863 /* Return number of nodes in SET. */
864 static inline size_t
865 varpool_node_set_size (varpool_node_set set)
867 return htab_elements (set->hashtab);
870 /* Uniquize all constants that appear in memory.
871 Each constant in memory thus far output is recorded
872 in `const_desc_table'. */
874 struct GTY(()) constant_descriptor_tree {
875 /* A MEM for the constant. */
876 rtx rtl;
878 /* The value of the constant. */
879 tree value;
881 /* Hash of value. Computing the hash from value each time
882 hashfn is called can't work properly, as that means recursive
883 use of the hash table during hash table expansion. */
884 hashval_t hash;
887 /* Return true if set is nonempty. */
888 static inline bool
889 cgraph_node_set_nonempty_p (cgraph_node_set set)
891 return !VEC_empty (cgraph_node_ptr, set->nodes);
894 /* Return true if set is nonempty. */
895 static inline bool
896 varpool_node_set_nonempty_p (varpool_node_set set)
898 return !VEC_empty (varpool_node_ptr, set->nodes);
901 /* Return true when function NODE is only called directly.
902 i.e. it is not externally visible, address was not taken and
903 it is not used in any other non-standard way. */
905 static inline bool
906 cgraph_only_called_directly_p (struct cgraph_node *node)
908 return (!node->needed && !node->address_taken
909 && !node->reachable_from_other_partition
910 && !DECL_STATIC_CONSTRUCTOR (node->decl)
911 && !DECL_STATIC_DESTRUCTOR (node->decl)
912 && !node->local.externally_visible);
915 /* Return true when function NODE can be removed from callgraph
916 if all direct calls are eliminated. */
918 static inline bool
919 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
921 return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
924 /* Return true when all references to VNODE must be visible in ipa_ref_list.
925 i.e. if the variable is not externally visible or not used in some magic
926 way (asm statement or such).
927 The magic uses are all sumarized in force_output flag. */
929 static inline bool
930 varpool_all_refs_explicit_p (struct varpool_node *vnode)
932 return (!vnode->externally_visible
933 && !vnode->used_from_other_partition
934 && !vnode->force_output);
937 /* Constant pool accessor function. */
938 htab_t constant_pool_htab (void);
940 /* FIXME: inappropriate dependency of cgraph on IPA. */
941 #include "ipa-ref-inline.h"
943 #endif /* GCC_CGRAPH_H */