1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
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
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
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/>. */
25 #include "basic-block.h"
29 /* Not yet set by cgraph_function_body_availability. */
31 /* Function body/variable initializer is unknown. */
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. */
39 /* Function body/variable initializer is known and will be used in final
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. */
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. */
64 /* How many instructions are likely going to disappear after inlining. */
65 int size_inlining_benefit
;
66 /* Estimated time spent executing the function body. */
68 /* How much time is going to be saved by inlining. */
69 int time_inlining_benefit
;
72 /* Information about the function collected locally.
73 Available after function is analyzed. */
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
;
79 struct inline_summary inline_summary
;
81 /* Set when function function is visible in current compilation unit only
82 and its address is never taken. */
85 /* Set when function is visible by other units. */
86 unsigned externally_visible
: 1;
88 /* Set once it has been finalized so we consider it to be output. */
89 unsigned finalized
: 1;
91 /* False when there something makes inlining impossible (such as va_arg). */
92 unsigned inlinable
: 1;
94 /* True when function should be inlined independently on its size. */
95 unsigned disregard_inline_limits
: 1;
97 /* True when the function has been originally extern inline, but it is
99 unsigned redefined_extern_inline
: 1;
101 /* True if statics_read_for_function and
102 statics_written_for_function contain valid data. */
103 unsigned for_functions_valid
: 1;
105 /* True if the function is going to be emitted in some other translation
106 unit, referenced from vtable. */
107 unsigned vtable_method
: 1;
110 /* Information about the function that needs to be computed globally
111 once compilation is finished. Available only with -funit-at-a-time. */
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
;
119 /* For inline clones this points to the function they will be
121 struct cgraph_node
*inlined_to
;
123 /* Estimated size of the function after inlining. */
127 /* Estimated growth after inlining. INT_MIN if not computed. */
128 int estimated_growth
;
130 /* Set iff the function has been inlined at least once. */
134 /* Information about the function that is propagated by the RTL backend.
135 Available only for functions that has been already assembled. */
137 struct GTY(()) cgraph_rtl_info
{
138 unsigned int preferred_incoming_stack_boundary
;
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
145 /* The tree that will be replaced. */
147 /* The new (replacing) tree. */
149 /* True when a substitution should be done, false otherwise. */
151 /* True when we replace a reference to old_tree. */
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
);
158 struct GTY(()) cgraph_clone_info
160 VEC(ipa_replace_map_p
,gc
)* tree_map
;
162 bitmap combined_args_to_skip
;
165 /* The cgraph data structure.
166 Each function decl has assigned cgraph_node listing callees and callers. */
168 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node
{
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
;
194 PTR
GTY ((skip
)) aux
;
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
;
201 struct cgraph_local_info local
;
202 struct cgraph_global_info global
;
203 struct cgraph_rtl_info rtl
;
204 struct cgraph_clone_info clone
;
206 /* Expected number of executions: calculated in profile.c. */
208 /* Unique id of the node. */
210 /* Ordering of all cgraph nodes. */
213 /* unique id for profiling. pid is not suitable because of different
214 number of cfg nodes with -fprofile-generate and -fprofile-use */
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. */
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
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. */
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;
252 typedef struct cgraph_node
*cgraph_node_ptr
;
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
);
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
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
;
267 typedef struct cgraph_node_set_def
*cgraph_node_set
;
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
);
273 /* A cgraph node set element contains an index in the vector of nodes in
275 struct GTY(()) cgraph_node_set_element_def
277 struct cgraph_node
*node
;
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
;
284 /* Iterator structure for cgraph node sets. */
289 } cgraph_node_set_iterator
;
291 #define DEFCIFCODE(code, string) CIF_ ## code,
292 /* Reasons for inlining failures. */
294 #include "cif-code.def"
296 } cgraph_inline_failed_t
;
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
;
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. */
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. */
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. */
331 #define CGRAPH_FREQ_BASE 1000
332 #define CGRAPH_FREQ_MAX 100000
334 typedef struct cgraph_edge
*cgraph_edge_p
;
336 DEF_VEC_P(cgraph_edge_p
);
337 DEF_VEC_ALLOC_P(cgraph_edge_p
,heap
);
339 /* The varpool data structure.
340 Each static variable decl has assigned varpool_node. */
342 struct GTY((chain_next ("%h.next"))) varpool_node
{
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. */
351 /* Set when function must be output - it is externally visible
352 or its address is taken. */
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
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. */
364 /* Set when function is visible by other units. */
365 unsigned externally_visible
: 1;
366 /* Set for aliases once they got through assemble_alias. */
370 /* Every top level asm statement is put into a cgraph_asm_node. */
372 struct GTY(()) cgraph_asm_node
{
374 struct cgraph_asm_node
*next
;
375 /* String for this asm node. */
377 /* Ordering of all cgraph nodes. */
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
;
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. */
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
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
;
405 extern GTY(()) struct cgraph_asm_node
*cgraph_asm_nodes
;
406 extern GTY(()) int cgraph_order
;
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);
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
) *);
447 void cgraph_redirect_edge_callee (struct cgraph_edge
*, struct cgraph_node
*);
449 struct cgraph_asm_node
*cgraph_add_asm_node (tree
);
451 bool cgraph_function_possibly_inlined_p (tree
);
452 void cgraph_unnest_node (struct cgraph_node
*);
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
);
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
)*,
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);
486 bool cgraph_decide_is_function_needed (struct cgraph_node
*, tree
);
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
*,
492 typedef void (*cgraph_2node_hook
)(struct cgraph_node
*, struct cgraph_node
*,
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
,
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
,
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);
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
);
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
);
531 bool cgraph_maybe_hot_edge_p (struct cgraph_edge
*e
);
534 extern GTY(()) struct varpool_node
*varpool_nodes_queue
;
535 extern GTY(()) struct varpool_node
*varpool_nodes
;
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
*);
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
*);
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
);
557 /* Walk all reachable static variables. */
558 #define FOR_EACH_STATIC_VARIABLE(node) \
559 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
561 /* Return first reachable static variable with initializer. */
562 static inline struct varpool_node
*
563 varpool_first_static_initializer (void)
565 struct varpool_node
*node
;
566 for (node
= varpool_nodes_queue
; node
; node
= node
->next_needed
)
568 gcc_assert (TREE_CODE (node
->decl
) == VAR_DECL
);
569 if (DECL_INITIAL (node
->decl
))
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
)
579 for (node
= node
->next_needed
; node
; node
= node
->next_needed
)
581 gcc_assert (TREE_CODE (node
->decl
) == VAR_DECL
);
582 if (DECL_INITIAL (node
->decl
))
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))
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
*);
598 /* Create a new static variable of type TYPE. */
599 tree
add_new_static_var (tree type
);
605 /* Must leave 0 for the stopper. */
606 LTO_cgraph_avail_node
= 1,
607 LTO_cgraph_overwritable_node
,
608 LTO_cgraph_unavail_node
,
613 extern const char * LTO_cgraph_tag_names
[LTO_cgraph_last_tag
];
615 #define LCC_NOT_FOUND (-1)
618 /* Return true if iterator CSI points to nothing. */
620 csi_end_p (cgraph_node_set_iterator csi
)
622 return csi
.index
>= VEC_length (cgraph_node_ptr
, csi
.set
->nodes
);
625 /* Advance iterator CSI. */
627 csi_next (cgraph_node_set_iterator
*csi
)
632 /* Return the node pointed to by CSI. */
633 static inline struct cgraph_node
*
634 csi_node (cgraph_node_set_iterator csi
)
636 return VEC_index (cgraph_node_ptr
, csi
.set
->nodes
, csi
.index
);
639 /* Return an iterator to the first node in SET. */
640 static inline cgraph_node_set_iterator
641 csi_start (cgraph_node_set set
)
643 cgraph_node_set_iterator csi
;
650 /* Return true if SET contains NODE. */
652 cgraph_node_in_set_p (struct cgraph_node
*node
, cgraph_node_set set
)
654 cgraph_node_set_iterator csi
;
655 csi
= cgraph_node_set_find (set
, node
);
656 return !csi_end_p (csi
);
659 /* Return number of nodes in SET. */
661 cgraph_node_set_size (cgraph_node_set set
)
663 return htab_elements (set
->hashtab
);
666 /* Uniquize all constants that appear in memory.
667 Each constant in memory thus far output is recorded
668 in `const_desc_table'. */
670 struct GTY(()) constant_descriptor_tree
{
671 /* A MEM for the constant. */
674 /* The value of the constant. */
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. */
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. */
688 cgraph_only_called_directly_p (struct cgraph_node
*node
)
690 return !node
->needed
&& !node
->local
.externally_visible
;
693 /* Return true when function NODE can be removed from callgraph
694 if all direct calls are eliminated. */
697 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node
*node
)
699 return (!node
->needed
700 && (DECL_COMDAT (node
->decl
) || !node
->local
.externally_visible
));
703 /* Constant pool accessor function. */
704 htab_t
constant_pool_htab (void);
706 #endif /* GCC_CGRAPH_H */