1 /* Callgraph handling code.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
25 #include "plugin-api.h"
28 #include "basic-block.h"
32 /* Symbol table consists of functions and variables.
33 TODO: add labels, constant pool and aliases. */
41 /* Base of all entries in the symbol table.
42 The symtab_node is inherited by cgraph and varpol nodes. */
43 struct GTY(()) symtab_node_base
45 /* Type of the symbol. */
46 ENUM_BITFIELD (symtab_type
) type
: 8;
48 /* The symbols resolution. */
49 ENUM_BITFIELD (ld_plugin_symbol_resolution
) resolution
: 8;
51 /* Set when function has address taken.
52 In current implementation it imply needed flag. */
53 unsigned address_taken
: 1;
54 /* Set when variable is used from other LTRANS partition. */
55 unsigned used_from_other_partition
: 1;
56 /* Set when function is available in the other LTRANS partition.
57 During WPA output it is used to mark nodes that are present in
58 multiple partitions. */
59 unsigned in_other_partition
: 1;
60 /* Set when function is visible by other units. */
61 unsigned externally_visible
: 1;
62 /* Needed variables might become dead by optimization. This flag
63 forces the variable to be output even if it appears dead otherwise. */
64 unsigned force_output
: 1;
66 /* Ordering of all symtab entries. */
71 /* Vectors of referring and referenced entities. */
72 struct ipa_ref_list ref_list
;
74 /* Circular list of nodes in the same comdat group if non-NULL. */
75 symtab_node same_comdat_group
;
77 /* File stream where this node is being written to. */
78 struct lto_file_decl_data
* lto_file_data
;
80 /* Linked list of symbol table entries starting with symtab_nodes. */
83 /* Linked list of symbols with the same asm name. There may be multiple
84 entries for single symbol name in the case of LTO resolutions,
85 existence of inline clones, or duplicated declaration. The last case
86 is a long standing bug frontends and builtin handling. */
87 symtab_node next_sharing_asm_name
;
88 symtab_node previous_sharing_asm_name
;
95 /* Not yet set by cgraph_function_body_availability. */
97 /* Function body/variable initializer is unknown. */
99 /* Function body/variable initializer is known but might be replaced
100 by a different one from other compilation unit and thus needs to
101 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
102 arbitrary side effects on escaping variables and functions, while
103 like AVAILABLE it might access static variables. */
105 /* Function body/variable initializer is known and will be used in final
108 /* Function body/variable initializer is known and all it's uses are explicitly
109 visible within current unit (ie it's address is never taken and it is not
110 exported to other units).
111 Currently used only for functions. */
115 /* This is the information that is put into the cgraph local structure
116 to recover a function. */
117 struct lto_file_decl_data
;
119 extern const char * const cgraph_availability_names
[];
120 extern const char * const ld_plugin_symbol_resolution_names
[];
122 /* Information about thunk, used only for same body aliases. */
124 struct GTY(()) cgraph_thunk_info
{
125 /* Information about the thunk. */
126 HOST_WIDE_INT fixed_offset
;
127 HOST_WIDE_INT virtual_value
;
130 bool virtual_offset_p
;
131 /* Set to true when alias node is thunk. */
135 /* Information about the function collected locally.
136 Available after function is analyzed. */
138 struct GTY(()) cgraph_local_info
{
139 /* Set when function function is visible in current compilation unit only
140 and its address is never taken. */
143 /* Set once it has been finalized so we consider it to be output. */
144 unsigned finalized
: 1;
146 /* False when there is something makes versioning impossible. */
147 unsigned versionable
: 1;
149 /* False when function calling convention and signature can not be changed.
150 This is the case when __builtin_apply_args is used. */
151 unsigned can_change_signature
: 1;
153 /* True when the function has been originally extern inline, but it is
155 unsigned redefined_extern_inline
: 1;
157 /* True if the function may enter serial irrevocable mode. */
158 unsigned tm_may_enter_irr
: 1;
161 /* Information about the function that needs to be computed globally
162 once compilation is finished. Available only with -funit-at-a-time. */
164 struct GTY(()) cgraph_global_info
{
165 /* Estimated stack frame consumption by the function. */
166 HOST_WIDE_INT estimated_stack_size
;
168 /* For inline clones this points to the function they will be
170 struct cgraph_node
*inlined_to
;
173 /* Information about the function that is propagated by the RTL backend.
174 Available only for functions that has been already assembled. */
176 struct GTY(()) cgraph_rtl_info
{
177 unsigned int preferred_incoming_stack_boundary
;
180 /* Represent which DECL tree (or reference to such tree)
181 will be replaced by another tree while versioning. */
182 struct GTY(()) ipa_replace_map
184 /* The tree that will be replaced. */
186 /* The new (replacing) tree. */
188 /* Parameter number to replace, when old_tree is NULL. */
190 /* True when a substitution should be done, false otherwise. */
192 /* True when we replace a reference to old_tree. */
195 typedef struct ipa_replace_map
*ipa_replace_map_p
;
197 struct GTY(()) cgraph_clone_info
199 vec
<ipa_replace_map_p
, va_gc
> *tree_map
;
201 bitmap combined_args_to_skip
;
205 /* The cgraph data structure.
206 Each function decl has assigned cgraph_node listing callees and callers. */
208 struct GTY(()) cgraph_node
{
209 struct symtab_node_base symbol
;
210 struct cgraph_edge
*callees
;
211 struct cgraph_edge
*callers
;
212 /* List of edges representing indirect calls with a yet undetermined
214 struct cgraph_edge
*indirect_calls
;
215 /* For nested functions points to function the node is nested in. */
217 GTY ((nested_ptr (union symtab_node_def
, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
219 /* Points to first nested function, if any. */
221 GTY ((nested_ptr (union symtab_node_def
, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
223 /* Pointer to the next function with same origin, if any. */
225 GTY ((nested_ptr (union symtab_node_def
, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
227 /* Pointer to the next clone. */
228 struct cgraph_node
*next_sibling_clone
;
229 struct cgraph_node
*prev_sibling_clone
;
230 struct cgraph_node
*clones
;
231 struct cgraph_node
*clone_of
;
232 /* For functions with many calls sites it holds map from call expression
233 to the edge to speed up cgraph_edge function. */
234 htab_t
GTY((param_is (struct cgraph_edge
))) call_site_hash
;
235 /* Declaration node used to be clone of. */
236 tree former_clone_of
;
238 /* Interprocedural passes scheduled to have their transform functions
239 applied next time we execute local pass on them. We maintain it
240 per-function in order to allow IPA passes to introduce new functions. */
241 vec
<ipa_opt_pass
> GTY((skip
)) ipa_transforms_to_apply
;
243 struct cgraph_local_info local
;
244 struct cgraph_global_info global
;
245 struct cgraph_rtl_info rtl
;
246 struct cgraph_clone_info clone
;
247 struct cgraph_thunk_info thunk
;
249 /* Expected number of executions: calculated in profile.c. */
251 /* Maximum count of any basic block in the function. */
252 gcov_type max_bb_count
;
253 /* How to scale counts at materialization time; used to merge
254 LTO units with different number of profile runs. */
255 int count_materialization_scale
;
256 /* Unique id of the node. */
259 /* Set when decl is an abstract function pointed to by the
260 ABSTRACT_DECL_ORIGIN of a reachable function. */
261 unsigned abstract_and_needed
: 1;
262 /* Set once the function is lowered (i.e. its CFG is built). */
263 unsigned lowered
: 1;
264 /* Set once the function has been instantiated and its callee
266 unsigned analyzed
: 1;
267 /* Set when function is scheduled to be processed by local passes. */
268 unsigned process
: 1;
269 /* Set for aliases once they got through assemble_alias. */
271 /* Set for nodes that was constructed and finalized by frontend. */
272 unsigned finalized_by_frontend
: 1;
273 /* Is this function cloned during versioning ? */
274 unsigned is_versioned_clone
: 1;
275 /* Set for aliases created as C++ same body aliases. */
276 unsigned same_body_alias
: 1;
277 /* How commonly executed the node is. Initialized during branch
278 probabilities pass. */
279 ENUM_BITFIELD (node_frequency
) frequency
: 2;
280 /* True when function can only be called at startup (from static ctor). */
281 unsigned only_called_at_startup
: 1;
282 /* True when function can only be called at startup (from static dtor). */
283 unsigned only_called_at_exit
: 1;
284 /* True when function is the transactional clone of a function which
285 is called only from inside transactions. */
286 /* ?? We should be able to remove this. We have enough bits in
287 cgraph to calculate it. */
288 unsigned tm_clone
: 1;
289 /* True if this decl is a dispatcher for function versions. */
290 unsigned dispatcher_function
: 1;
294 typedef struct cgraph_node
*cgraph_node_ptr
;
297 /* Function Multiversioning info. */
298 struct GTY(()) cgraph_function_version_info
{
299 /* The cgraph_node for which the function version info is stored. */
300 struct cgraph_node
*this_node
;
301 /* Chains all the semantically identical function versions. The
302 first function in this chain is the version_info node of the
304 struct cgraph_function_version_info
*prev
;
305 /* If this version node corresponds to a dispatcher for function
306 versions, this points to the version info node of the default
307 function, the first node in the chain. */
308 struct cgraph_function_version_info
*next
;
309 /* If this node corresponds to a function version, this points
310 to the dispatcher function decl, which is the function that must
311 be called to execute the right function version at run-time.
313 If this cgraph node is a dispatcher (if dispatcher_function is
314 true, in the cgraph_node struct) for function versions, this
315 points to resolver function, which holds the function body of the
316 dispatcher. The dispatcher decl is an alias to the resolver
318 tree dispatcher_resolver
;
321 /* Get the cgraph_function_version_info node corresponding to node. */
322 struct cgraph_function_version_info
*
323 get_cgraph_node_version (struct cgraph_node
*node
);
325 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
326 corresponding to cgraph_node NODE. */
327 struct cgraph_function_version_info
*
328 insert_new_cgraph_node_version (struct cgraph_node
*node
);
330 /* Record that DECL1 and DECL2 are semantically identical function
332 void record_function_versions (tree decl1
, tree decl2
);
334 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
335 DECL is a duplicate declaration. */
336 void delete_function_version (tree decl
);
338 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
339 can appear in multiple sets. */
340 struct cgraph_node_set_def
342 struct pointer_map_t
*map
;
343 vec
<cgraph_node_ptr
> nodes
;
346 typedef struct varpool_node
*varpool_node_ptr
;
349 /* A varpool node set is a collection of varpool nodes. A varpool node
350 can appear in multiple sets. */
351 struct varpool_node_set_def
353 struct pointer_map_t
* map
;
354 vec
<varpool_node_ptr
> nodes
;
357 typedef struct cgraph_node_set_def
*cgraph_node_set
;
360 typedef struct varpool_node_set_def
*varpool_node_set
;
363 /* Iterator structure for cgraph node sets. */
368 } cgraph_node_set_iterator
;
370 /* Iterator structure for varpool node sets. */
373 varpool_node_set set
;
375 } varpool_node_set_iterator
;
377 #define DEFCIFCODE(code, string) CIF_ ## code,
378 /* Reasons for inlining failures. */
379 typedef enum cgraph_inline_failed_enum
{
380 #include "cif-code.def"
382 } cgraph_inline_failed_t
;
384 /* Structure containing additional information about an indirect call. */
386 struct GTY(()) cgraph_indirect_call_info
388 /* When polymorphic is set, this field contains offset where the object which
389 was actually used in the polymorphic resides within a larger structure.
390 If agg_contents is set, the field contains the offset within the aggregate
391 from which the address to call was loaded. */
392 HOST_WIDE_INT 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. */
397 /* Index of the parameter that is called. */
399 /* ECF flags determined from the caller. */
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;
405 /* Set when the call is a call of a pointer loaded from contents of an
406 aggregate at offset. */
407 unsigned agg_contents
: 1;
408 /* When the previous bit is set, this one determines whether the destination
409 is loaded from a parameter passed by reference. */
413 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge
{
414 /* Expected number of executions: calculated in profile.c. */
416 struct cgraph_node
*caller
;
417 struct cgraph_node
*callee
;
418 struct cgraph_edge
*prev_caller
;
419 struct cgraph_edge
*next_caller
;
420 struct cgraph_edge
*prev_callee
;
421 struct cgraph_edge
*next_callee
;
423 /* Additional information about an indirect call. Not cleared when an edge
425 struct cgraph_indirect_call_info
*indirect_info
;
426 PTR
GTY ((skip (""))) aux
;
427 /* When equal to CIF_OK, inline this call. Otherwise, points to the
428 explanation why function was not inlined. */
429 cgraph_inline_failed_t inline_failed
;
430 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
431 when the function is serialized in. */
432 unsigned int lto_stmt_uid
;
433 /* Expected frequency of executions within the function.
434 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
435 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
437 /* Unique id of the edge. */
439 /* Whether this edge was made direct by indirect inlining. */
440 unsigned int indirect_inlining_edge
: 1;
441 /* Whether this edge describes an indirect call with an undetermined
443 unsigned int indirect_unknown_callee
: 1;
444 /* Whether this edge is still a dangling */
445 /* True if the corresponding CALL stmt cannot be inlined. */
446 unsigned int call_stmt_cannot_inline_p
: 1;
447 /* Can this call throw externally? */
448 unsigned int can_throw_external
: 1;
451 #define CGRAPH_FREQ_BASE 1000
452 #define CGRAPH_FREQ_MAX 100000
454 typedef struct cgraph_edge
*cgraph_edge_p
;
457 /* The varpool data structure.
458 Each static variable decl has assigned varpool_node. */
460 struct GTY(()) varpool_node
{
461 struct symtab_node_base symbol
;
462 /* For aliases points to declaration DECL is alias of. */
465 /* The module in which it is first declared. */
467 /* Set once the variable has been instantiated and its callee
469 unsigned analyzed
: 1;
470 /* Set once it has been finalized so we consider it to be output. */
471 unsigned finalized
: 1;
472 /* Set when variable is scheduled to be assembled. */
474 /* Set for aliases once they got through assemble_alias. Also set for
475 extra name aliases in varpool_extra_name_alias. */
477 unsigned extra_name_alias
: 1;
480 /* Every top level asm statement is put into a asm_node. */
482 struct GTY(()) asm_node
{
484 struct asm_node
*next
;
485 /* String for this asm node. */
487 /* Ordering of all cgraph nodes. */
491 /* Symbol table entry. */
492 union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
493 chain_prev ("%h.symbol.previous"))) symtab_node_def
{
494 struct symtab_node_base
GTY ((tag ("SYMTAB_SYMBOL"))) symbol
;
495 /* To access the following fields,
496 use the use dyn_cast or as_a to obtain the concrete type. */
497 struct cgraph_node
GTY ((tag ("SYMTAB_FUNCTION"))) x_function
;
498 struct varpool_node
GTY ((tag ("SYMTAB_VARIABLE"))) x_variable
;
501 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
506 is_a_helper
<cgraph_node
>::test (symtab_node_def
*p
)
508 return p
->symbol
.type
== SYMTAB_FUNCTION
;
511 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
516 is_a_helper
<varpool_node
>::test (symtab_node_def
*p
)
518 return p
->symbol
.type
== SYMTAB_VARIABLE
;
521 extern GTY(()) symtab_node symtab_nodes
;
522 extern GTY(()) int cgraph_n_nodes
;
523 extern GTY(()) int cgraph_max_uid
;
524 extern GTY(()) int cgraph_edge_max_uid
;
525 extern bool cgraph_global_info_ready
;
528 /* Frontend is parsing and finalizing functions. */
529 CGRAPH_STATE_PARSING
,
530 /* Callgraph is being constructed. It is safe to add new functions. */
531 CGRAPH_STATE_CONSTRUCTION
,
532 /* Callgraph is built and IPA passes are being run. */
534 /* Callgraph is built and all functions are transformed to SSA form. */
535 CGRAPH_STATE_IPA_SSA
,
536 /* Functions are now ordered and being passed to RTL expanders. */
537 CGRAPH_STATE_EXPANSION
,
538 /* All cgraph expansion is done. */
539 CGRAPH_STATE_FINISHED
541 extern enum cgraph_state cgraph_state
;
542 extern bool cgraph_function_flags_ready
;
543 extern cgraph_node_set cgraph_new_nodes
;
545 extern GTY(()) struct asm_node
*asm_nodes
;
546 extern GTY(()) int symtab_order
;
547 extern bool same_body_aliases_done
;
550 void symtab_register_node (symtab_node
);
551 void symtab_unregister_node (symtab_node
);
552 void symtab_remove_node (symtab_node
);
553 symtab_node
symtab_get_node (const_tree
);
554 symtab_node
symtab_node_for_asm (const_tree asmname
);
555 const char * symtab_node_asm_name (symtab_node
);
556 const char * symtab_node_name (symtab_node
);
557 void symtab_insert_node_to_hashtable (symtab_node
);
558 void symtab_add_to_same_comdat_group (symtab_node
, symtab_node
);
559 void symtab_dissolve_same_comdat_group_list (symtab_node node
);
560 void dump_symtab (FILE *);
561 void debug_symtab (void);
562 void dump_symtab_node (FILE *, symtab_node
);
563 void debug_symtab_node (symtab_node
);
564 void dump_symtab_base (FILE *, symtab_node
);
565 void verify_symtab (void);
566 void verify_symtab_node (symtab_node
);
567 bool verify_symtab_base (symtab_node
);
568 bool symtab_used_from_object_file_p (symtab_node
);
569 void symtab_make_decl_local (tree
);
570 void unlink_from_assembler_name_hash (symtab_node
);
571 void insert_to_assembler_name_hash (symtab_node
);
574 void dump_cgraph (FILE *);
575 void debug_cgraph (void);
576 void dump_cgraph_node (FILE *, struct cgraph_node
*);
577 void debug_cgraph_node (struct cgraph_node
*);
578 void cgraph_remove_edge (struct cgraph_edge
*);
579 void cgraph_remove_node (struct cgraph_node
*);
580 void cgraph_remove_fake_indirect_call_in_edges (struct cgraph_node
*);
581 extern bool cgraph_pre_profiling_inlining_done
;
582 extern bool cgraph_is_fake_indirect_call_edge (struct cgraph_edge
*e
);
583 void cgraph_add_to_same_comdat_group (struct cgraph_node
*, struct cgraph_node
*);
584 void cgraph_remove_node_and_inline_clones (struct cgraph_node
*);
585 void cgraph_release_function_body (struct cgraph_node
*);
586 void cgraph_node_remove_callees (struct cgraph_node
*node
);
587 struct cgraph_edge
*cgraph_create_edge (struct cgraph_node
*,
588 struct cgraph_node
*,
589 gimple
, gcov_type
, int);
590 struct cgraph_edge
*cgraph_create_indirect_edge (struct cgraph_node
*, gimple
,
591 int, gcov_type
, int);
592 struct cgraph_indirect_call_info
*cgraph_allocate_init_indirect_info (void);
593 struct cgraph_node
* cgraph_create_node (tree
);
594 struct cgraph_node
* cgraph_create_empty_node (void);
595 struct cgraph_node
* cgraph_get_create_node (tree
);
596 struct cgraph_node
* cgraph_get_create_real_symbol_node (tree
);
597 struct cgraph_node
* cgraph_same_body_alias (struct cgraph_node
*, tree
, tree
);
598 struct cgraph_node
* cgraph_add_thunk (struct cgraph_node
*, tree
, tree
, bool, HOST_WIDE_INT
,
599 HOST_WIDE_INT
, tree
, tree
);
600 struct cgraph_node
*cgraph_node_for_asm (tree
);
601 struct cgraph_edge
*cgraph_edge (struct cgraph_node
*, gimple
);
602 void cgraph_set_call_stmt (struct cgraph_edge
*, gimple
);
603 void cgraph_update_edges_for_call_stmt (gimple
, tree
, gimple
);
604 struct cgraph_local_info
*cgraph_local_info (tree
);
605 struct cgraph_global_info
*cgraph_global_info (tree
);
606 struct cgraph_rtl_info
*cgraph_rtl_info (tree
);
607 struct cgraph_node
*cgraph_create_function_alias (tree
, tree
);
608 void cgraph_call_node_duplication_hooks (struct cgraph_node
*,
609 struct cgraph_node
*);
610 void cgraph_call_edge_duplication_hooks (struct cgraph_edge
*,
611 struct cgraph_edge
*);
613 void cgraph_redirect_edge_callee (struct cgraph_edge
*, struct cgraph_node
*);
614 void cgraph_make_edge_direct (struct cgraph_edge
*, struct cgraph_node
*);
615 bool cgraph_only_called_directly_p (struct cgraph_node
*);
617 bool cgraph_function_possibly_inlined_p (tree
);
618 void cgraph_unnest_node (struct cgraph_node
*);
620 enum availability
cgraph_function_body_availability (struct cgraph_node
*);
621 void cgraph_add_new_function (tree
, bool);
622 const char* cgraph_inline_failed_string (cgraph_inline_failed_t
);
624 void cgraph_set_nothrow_flag (struct cgraph_node
*, bool);
625 void cgraph_set_const_flag (struct cgraph_node
*, bool, bool);
626 void cgraph_set_pure_flag (struct cgraph_node
*, bool, bool);
627 bool cgraph_node_cannot_return (struct cgraph_node
*);
628 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge
*);
629 bool cgraph_will_be_removed_from_program_if_no_direct_calls
630 (struct cgraph_node
*node
);
631 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
632 (struct cgraph_node
*node
);
633 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node
*node
);
634 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution
);
635 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node
*,
636 bool (*) (struct cgraph_node
*, void *),
639 bool cgraph_for_node_and_aliases (struct cgraph_node
*,
640 bool (*) (struct cgraph_node
*, void *),
642 vec
<cgraph_edge_p
> collect_callers_of_node (struct cgraph_node
*node
);
643 void verify_cgraph (void);
644 void verify_cgraph_node (struct cgraph_node
*);
645 void cgraph_mark_address_taken_node (struct cgraph_node
*);
647 /* Module info structure. */
648 struct GTY (()) cgraph_mod_info
653 /* LIPO linker symbol table entry for function symbols. */
654 struct GTY (()) cgraph_sym
657 struct cgraph_node
*rep_node
;
659 htab_t
GTY ((param_is (struct cgraph_mod_info
))) def_module_hash
;
660 bool is_promoted_static
;
663 void cgraph_init_gid_map (void);
664 void cgraph_add_fake_indirect_call_edges (void);
665 void cgraph_remove_zero_count_fake_edges (void);
666 void cgraph_do_link (void);
667 struct cgraph_sym
*cgraph_link_node (struct cgraph_node
*);
668 tree
cgraph_find_decl (tree asm_name
);
669 void cgraph_remove_link_node (struct cgraph_node
*node
);
670 struct cgraph_node
*cgraph_lipo_get_resolved_node (tree decl
);
671 struct cgraph_node
*cgraph_lipo_get_resolved_node_1 (tree decl
, bool);
672 unsigned cgraph_get_module_id (tree fndecl
);
673 bool cgraph_is_auxiliary (tree fndecl
);
674 void cgraph_process_module_scope_statics (void);
675 bool cgraph_is_promoted_static_func (tree fndecl
);
676 bool cgraph_is_inline_body_available_in_module (tree fndecl
, unsigned module_id
);
677 bool cgraph_is_aux_decl_external (struct cgraph_node
*);
678 void cgraph_unify_type_alias_sets (void);
679 void varpool_do_link (void);
680 void varpool_link_node (struct varpool_node
*);
681 void varpool_remove_link_node (struct varpool_node
*node
);
682 struct varpool_node
*real_varpool_node (tree decl
);
683 bool varpool_is_auxiliary (struct varpool_node
*node
);
684 void varpool_get_referenced_asm_ids (vec
<tree
, va_gc
> **);
685 void varpool_clear_asm_id_reference_bit (void);
686 void varpool_reset_queue (void);
687 void varpool_remove_duplicate_weak_decls (void);
689 bool cgraph_decide_is_function_needed (struct cgraph_node
*, tree
);
691 typedef void (*cgraph_edge_hook
)(struct cgraph_edge
*, void *);
692 typedef void (*cgraph_node_hook
)(struct cgraph_node
*, void *);
693 typedef void (*cgraph_2edge_hook
)(struct cgraph_edge
*, struct cgraph_edge
*,
695 typedef void (*cgraph_2node_hook
)(struct cgraph_node
*, struct cgraph_node
*,
697 struct cgraph_edge_hook_list
;
698 struct cgraph_node_hook_list
;
699 struct cgraph_2edge_hook_list
;
700 struct cgraph_2node_hook_list
;
701 struct cgraph_edge_hook_list
*cgraph_add_edge_removal_hook (cgraph_edge_hook
, void *);
702 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list
*);
703 struct cgraph_node_hook_list
*cgraph_add_node_removal_hook (cgraph_node_hook
,
705 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list
*);
706 struct cgraph_node_hook_list
*cgraph_add_function_insertion_hook (cgraph_node_hook
,
708 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list
*);
709 void cgraph_call_function_insertion_hooks (struct cgraph_node
*node
);
710 struct cgraph_2edge_hook_list
*cgraph_add_edge_duplication_hook (cgraph_2edge_hook
, void *);
711 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list
*);
712 struct cgraph_2node_hook_list
*cgraph_add_node_duplication_hook (cgraph_2node_hook
, void *);
713 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list
*);
714 gimple
cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge
*);
715 bool cgraph_propagate_frequency (struct cgraph_node
*node
);
717 /* In cgraphunit.c */
718 struct asm_node
*add_asm_node (tree
);
719 extern FILE *cgraph_dump_file
;
720 void cgraph_finalize_function (tree
, bool);
721 void finalize_compilation_unit (void);
723 void init_cgraph (void);
724 bool cgraph_process_new_functions (void);
725 void cgraph_process_same_body_aliases (void);
726 void fixup_same_cpp_alias_visibility (symtab_node node
, symtab_node target
, tree alias
);
727 /* Initialize datastructures so DECL is a function in lowered gimple form.
728 IN_SSA is true if the gimple is in SSA. */
729 basic_block
init_lowered_empty_function (tree decl
, bool in_ssa
);
731 /* In cgraphclones.c */
733 struct cgraph_edge
* cgraph_clone_edge (struct cgraph_edge
*,
734 struct cgraph_node
*, gimple
,
735 unsigned, gcov_type
, int, bool);
736 struct cgraph_node
* cgraph_clone_node (struct cgraph_node
*, tree
, gcov_type
,
737 int, bool, vec
<cgraph_edge_p
>,
739 tree
clone_function_name (tree decl
, const char *);
740 struct cgraph_node
* cgraph_create_virtual_clone (struct cgraph_node
*old_node
,
742 vec
<ipa_replace_map_p
, va_gc
> *tree_map
,
744 const char *clone_name
);
745 struct cgraph_node
*cgraph_find_replacement_node (struct cgraph_node
*);
746 bool cgraph_remove_node_and_inline_clones (struct cgraph_node
*, struct cgraph_node
*);
747 void cgraph_set_call_stmt_including_clones (struct cgraph_node
*, gimple
, gimple
);
748 void cgraph_create_edge_including_clones (struct cgraph_node
*,
749 struct cgraph_node
*,
750 gimple
, gimple
, gcov_type
, int,
751 cgraph_inline_failed_t
);
752 void cgraph_materialize_all_clones (void);
753 struct cgraph_node
* cgraph_copy_node_for_versioning (struct cgraph_node
*,
754 tree
, vec
<cgraph_edge_p
>, bitmap
);
755 struct cgraph_node
*cgraph_function_versioning (struct cgraph_node
*,
757 vec
<ipa_replace_map_p
, va_gc
> *,
758 bitmap
, bool, bitmap
,
759 basic_block
, const char *);
760 void tree_function_versioning (tree
, tree
, vec
<ipa_replace_map_p
, va_gc
> *,
761 bool, bitmap
, bool, bitmap
, basic_block
);
763 /* In cgraphbuild.c */
764 unsigned int rebuild_cgraph_edges (void);
765 void cgraph_rebuild_references (void);
766 int compute_call_stmt_bb_frequency (tree
, basic_block bb
);
767 void record_references_in_initializer (tree
, bool);
770 bool symtab_remove_unreachable_nodes (bool, FILE *);
771 cgraph_node_set
cgraph_node_set_new (void);
772 cgraph_node_set_iterator
cgraph_node_set_find (cgraph_node_set
,
773 struct cgraph_node
*);
774 void cgraph_node_set_add (cgraph_node_set
, struct cgraph_node
*);
775 void cgraph_node_set_remove (cgraph_node_set
, struct cgraph_node
*);
776 void dump_cgraph_node_set (FILE *, cgraph_node_set
);
777 void debug_cgraph_node_set (cgraph_node_set
);
778 void free_cgraph_node_set (cgraph_node_set
);
779 void cgraph_build_static_cdtor (char which
, tree body
, int priority
);
781 varpool_node_set
varpool_node_set_new (void);
782 varpool_node_set_iterator
varpool_node_set_find (varpool_node_set
,
783 struct varpool_node
*);
784 void varpool_node_set_add (varpool_node_set
, struct varpool_node
*);
785 void varpool_node_set_remove (varpool_node_set
, struct varpool_node
*);
786 void dump_varpool_node_set (FILE *, varpool_node_set
);
787 void debug_varpool_node_set (varpool_node_set
);
788 void free_varpool_node_set (varpool_node_set
);
789 void ipa_discover_readonly_nonaddressable_vars (void);
790 bool cgraph_comdat_can_be_unshared_p (struct cgraph_node
*);
791 bool varpool_externally_visible_p (struct varpool_node
*, bool);
794 bool cgraph_maybe_hot_edge_p (struct cgraph_edge
*e
);
795 bool cgraph_optimize_for_size_p (struct cgraph_node
*);
798 struct varpool_node
*varpool_node_for_decl (tree
);
799 struct varpool_node
*varpool_node_for_asm (tree asmname
);
800 void varpool_mark_needed_node (struct varpool_node
*);
801 void debug_varpool (void);
802 void dump_varpool (FILE *);
803 void dump_varpool_node (FILE *, struct varpool_node
*);
805 void varpool_finalize_decl (tree
);
806 bool decide_is_variable_needed (struct varpool_node
*, tree
);
807 enum availability
cgraph_variable_initializer_availability (struct varpool_node
*);
808 void cgraph_make_node_local (struct cgraph_node
*);
809 bool cgraph_node_can_be_local_p (struct cgraph_node
*);
812 void varpool_remove_node (struct varpool_node
*node
);
813 void varpool_finalize_named_section_flags (struct varpool_node
*node
);
814 bool varpool_output_variables (void);
815 bool varpool_assemble_decl (struct varpool_node
*node
);
816 void varpool_analyze_node (struct varpool_node
*);
817 struct varpool_node
* varpool_extra_name_alias (tree
, tree
);
818 struct varpool_node
* varpool_create_variable_alias (tree
, tree
);
819 void varpool_reset_queue (void);
820 bool const_value_known_p (tree
);
821 bool varpool_for_node_and_aliases (struct varpool_node
*,
822 bool (*) (struct varpool_node
*, void *),
824 void varpool_add_new_variable (tree
);
825 void symtab_initialize_asm_name_hash (void);
826 void symtab_prevail_in_asm_name_hash (symtab_node node
);
829 /* Return callgraph node for given symbol and check it is a function. */
830 static inline struct cgraph_node
*
831 cgraph (symtab_node node
)
833 gcc_checking_assert (!node
|| node
->symbol
.type
== SYMTAB_FUNCTION
);
834 return (struct cgraph_node
*)node
;
837 /* Return varpool node for given symbol and check it is a variable. */
838 static inline struct varpool_node
*
839 varpool (symtab_node node
)
841 gcc_checking_assert (!node
|| node
->symbol
.type
== SYMTAB_VARIABLE
);
842 return (struct varpool_node
*)node
;
845 /* Return callgraph node for given symbol and check it is a function. */
846 static inline struct cgraph_node
*
847 cgraph_get_node (const_tree decl
)
849 gcc_checking_assert (TREE_CODE (decl
) == FUNCTION_DECL
);
850 return cgraph (symtab_get_node (decl
));
853 /* Return varpool node for given symbol and check it is a function. */
854 static inline struct varpool_node
*
855 varpool_get_node (const_tree decl
)
857 gcc_checking_assert (TREE_CODE (decl
) == VAR_DECL
);
858 return varpool (symtab_get_node (decl
));
861 /* Return asm name of cgraph node. */
862 static inline const char *
863 cgraph_node_asm_name(struct cgraph_node
*node
)
865 return symtab_node_asm_name ((symtab_node
)node
);
868 /* Return asm name of varpool node. */
869 static inline const char *
870 varpool_node_asm_name(struct varpool_node
*node
)
872 return symtab_node_asm_name ((symtab_node
)node
);
875 /* Return name of cgraph node. */
876 static inline const char *
877 cgraph_node_name(struct cgraph_node
*node
)
879 return symtab_node_name ((symtab_node
)node
);
882 /* Return name of varpool node. */
883 static inline const char *
884 varpool_node_name(struct varpool_node
*node
)
886 return symtab_node_name ((symtab_node
)node
);
889 /* Walk all symbols. */
890 #define FOR_EACH_SYMBOL(node) \
891 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
894 /* Return first variable. */
895 static inline struct varpool_node
*
896 varpool_first_variable (void)
899 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
900 if (varpool_node
*vnode
= dyn_cast
<varpool_node
> (node
))
905 /* Return next variable after NODE. */
906 static inline struct varpool_node
*
907 varpool_next_variable (struct varpool_node
*node
)
909 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
910 for (; node1
; node1
= node1
->symbol
.next
)
911 if (varpool_node
*vnode1
= dyn_cast
<varpool_node
> (node1
))
915 /* Walk all variables. */
916 #define FOR_EACH_VARIABLE(node) \
917 for ((node) = varpool_first_variable (); \
919 (node) = varpool_next_variable ((node)))
921 /* Return first reachable static variable with initializer. */
922 static inline struct varpool_node
*
923 varpool_first_static_initializer (void)
926 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
928 varpool_node
*vnode
= dyn_cast
<varpool_node
> (node
);
929 if (vnode
&& DECL_INITIAL (node
->symbol
.decl
))
935 /* Return next reachable static variable with initializer after NODE. */
936 static inline struct varpool_node
*
937 varpool_next_static_initializer (struct varpool_node
*node
)
939 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
940 for (; node1
; node1
= node1
->symbol
.next
)
942 varpool_node
*vnode1
= dyn_cast
<varpool_node
> (node1
);
943 if (vnode1
&& DECL_INITIAL (node1
->symbol
.decl
))
949 /* Walk all static variables with initializer set. */
950 #define FOR_EACH_STATIC_INITIALIZER(node) \
951 for ((node) = varpool_first_static_initializer (); (node); \
952 (node) = varpool_next_static_initializer (node))
954 /* Return first reachable static variable with initializer. */
955 static inline struct varpool_node
*
956 varpool_first_defined_variable (void)
959 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
961 varpool_node
*vnode
= dyn_cast
<varpool_node
> (node
);
962 if (vnode
&& vnode
->analyzed
)
968 /* Return next reachable static variable with initializer after NODE. */
969 static inline struct varpool_node
*
970 varpool_next_defined_variable (struct varpool_node
*node
)
972 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
973 for (; node1
; node1
= node1
->symbol
.next
)
975 varpool_node
*vnode1
= dyn_cast
<varpool_node
> (node1
);
976 if (vnode1
&& vnode1
->analyzed
)
981 /* Walk all variables with definitions in current unit. */
982 #define FOR_EACH_DEFINED_VARIABLE(node) \
983 for ((node) = varpool_first_defined_variable (); (node); \
984 (node) = varpool_next_defined_variable (node))
986 /* Return first function with body defined. */
987 static inline struct cgraph_node
*
988 cgraph_first_defined_function (void)
991 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
993 cgraph_node
*cn
= dyn_cast
<cgraph_node
> (node
);
994 if (cn
&& cn
->analyzed
)
1000 /* Return next function with body defined after NODE. */
1001 static inline struct cgraph_node
*
1002 cgraph_next_defined_function (struct cgraph_node
*node
)
1004 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
1005 for (; node1
; node1
= node1
->symbol
.next
)
1007 cgraph_node
*cn1
= dyn_cast
<cgraph_node
> (node1
);
1008 if (cn1
&& cn1
->analyzed
)
1014 /* Walk all functions with body defined. */
1015 #define FOR_EACH_DEFINED_FUNCTION(node) \
1016 for ((node) = cgraph_first_defined_function (); (node); \
1017 (node) = cgraph_next_defined_function ((node)))
1019 /* Return first function. */
1020 static inline struct cgraph_node
*
1021 cgraph_first_function (void)
1024 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
1025 if (cgraph_node
*cn
= dyn_cast
<cgraph_node
> (node
))
1030 /* Return next function. */
1031 static inline struct cgraph_node
*
1032 cgraph_next_function (struct cgraph_node
*node
)
1034 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
1035 for (; node1
; node1
= node1
->symbol
.next
)
1036 if (cgraph_node
*cn1
= dyn_cast
<cgraph_node
> (node1
))
1040 /* Walk all functions. */
1041 #define FOR_EACH_FUNCTION(node) \
1042 for ((node) = cgraph_first_function (); (node); \
1043 (node) = cgraph_next_function ((node)))
1045 /* Return true when NODE is a function with Gimple body defined
1046 in current unit. Functions can also be define externally or they
1047 can be thunks with no Gimple representation.
1049 Note that at WPA stage, the function body may not be present in memory. */
1052 cgraph_function_with_gimple_body_p (struct cgraph_node
*node
)
1054 return node
->analyzed
&& !node
->thunk
.thunk_p
&& !node
->alias
;
1057 /* Return first function with body defined. */
1058 static inline struct cgraph_node
*
1059 cgraph_first_function_with_gimple_body (void)
1062 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
1064 cgraph_node
*cn
= dyn_cast
<cgraph_node
> (node
);
1065 if (cn
&& cgraph_function_with_gimple_body_p (cn
))
1071 /* Return next reachable static variable with initializer after NODE. */
1072 static inline struct cgraph_node
*
1073 cgraph_next_function_with_gimple_body (struct cgraph_node
*node
)
1075 symtab_node node1
= node
->symbol
.next
;
1076 for (; node1
; node1
= node1
->symbol
.next
)
1078 cgraph_node
*cn1
= dyn_cast
<cgraph_node
> (node1
);
1079 if (cn1
&& cgraph_function_with_gimple_body_p (cn1
))
1085 /* Walk all functions with body defined. */
1086 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1087 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1088 (node) = cgraph_next_function_with_gimple_body (node))
1090 /* Create a new static variable of type TYPE. */
1091 tree
add_new_static_var (tree type
);
1093 /* Return true if iterator CSI points to nothing. */
1095 csi_end_p (cgraph_node_set_iterator csi
)
1097 return csi
.index
>= csi
.set
->nodes
.length ();
1100 /* Advance iterator CSI. */
1102 csi_next (cgraph_node_set_iterator
*csi
)
1107 /* Return the node pointed to by CSI. */
1108 static inline struct cgraph_node
*
1109 csi_node (cgraph_node_set_iterator csi
)
1111 return csi
.set
->nodes
[csi
.index
];
1114 /* Return an iterator to the first node in SET. */
1115 static inline cgraph_node_set_iterator
1116 csi_start (cgraph_node_set set
)
1118 cgraph_node_set_iterator csi
;
1125 /* Return true if SET contains NODE. */
1127 cgraph_node_in_set_p (struct cgraph_node
*node
, cgraph_node_set set
)
1129 cgraph_node_set_iterator csi
;
1130 csi
= cgraph_node_set_find (set
, node
);
1131 return !csi_end_p (csi
);
1134 /* Return number of nodes in SET. */
1135 static inline size_t
1136 cgraph_node_set_size (cgraph_node_set set
)
1138 return set
->nodes
.length ();
1141 /* Return true if iterator VSI points to nothing. */
1143 vsi_end_p (varpool_node_set_iterator vsi
)
1145 return vsi
.index
>= vsi
.set
->nodes
.length ();
1148 /* Advance iterator VSI. */
1150 vsi_next (varpool_node_set_iterator
*vsi
)
1155 /* Return the node pointed to by VSI. */
1156 static inline struct varpool_node
*
1157 vsi_node (varpool_node_set_iterator vsi
)
1159 return vsi
.set
->nodes
[vsi
.index
];
1162 /* Return an iterator to the first node in SET. */
1163 static inline varpool_node_set_iterator
1164 vsi_start (varpool_node_set set
)
1166 varpool_node_set_iterator vsi
;
1173 /* Return true if SET contains NODE. */
1175 varpool_node_in_set_p (struct varpool_node
*node
, varpool_node_set set
)
1177 varpool_node_set_iterator vsi
;
1178 vsi
= varpool_node_set_find (set
, node
);
1179 return !vsi_end_p (vsi
);
1182 /* Return number of nodes in SET. */
1183 static inline size_t
1184 varpool_node_set_size (varpool_node_set set
)
1186 return set
->nodes
.length ();
1189 /* Uniquize all constants that appear in memory.
1190 Each constant in memory thus far output is recorded
1191 in `const_desc_table'. */
1193 struct GTY(()) constant_descriptor_tree
{
1194 /* A MEM for the constant. */
1197 /* The value of the constant. */
1200 /* Hash of value. Computing the hash from value each time
1201 hashfn is called can't work properly, as that means recursive
1202 use of the hash table during hash table expansion. */
1206 /* Return true if set is nonempty. */
1208 cgraph_node_set_nonempty_p (cgraph_node_set set
)
1210 return !set
->nodes
.is_empty ();
1213 /* Return true if set is nonempty. */
1215 varpool_node_set_nonempty_p (varpool_node_set set
)
1217 return !set
->nodes
.is_empty ();
1220 /* Return true when function NODE is only called directly or it has alias.
1221 i.e. it is not externally visible, address was not taken and
1222 it is not used in any other non-standard way. */
1225 cgraph_only_called_directly_or_aliased_p (struct cgraph_node
*node
)
1227 gcc_assert (!node
->global
.inlined_to
);
1228 return (!node
->symbol
.force_output
&& !node
->symbol
.address_taken
1229 && !node
->symbol
.used_from_other_partition
1230 && !DECL_VIRTUAL_P (node
->symbol
.decl
)
1231 && !DECL_STATIC_CONSTRUCTOR (node
->symbol
.decl
)
1232 && !DECL_STATIC_DESTRUCTOR (node
->symbol
.decl
)
1233 && !node
->symbol
.externally_visible
);
1236 /* Return true when function NODE can be removed from callgraph
1237 if all direct calls are eliminated. */
1240 varpool_can_remove_if_no_refs (struct varpool_node
*node
)
1242 if (DECL_EXTERNAL (node
->symbol
.decl
))
1244 return (!node
->symbol
.force_output
&& !node
->symbol
.used_from_other_partition
1245 && ((DECL_COMDAT (node
->symbol
.decl
)
1246 && !symtab_used_from_object_file_p ((symtab_node
) node
))
1247 || !node
->symbol
.externally_visible
1248 || DECL_HAS_VALUE_EXPR_P (node
->symbol
.decl
)));
1251 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1252 i.e. if the variable is not externally visible or not used in some magic
1253 way (asm statement or such).
1254 The magic uses are all summarized in force_output flag. */
1257 varpool_all_refs_explicit_p (struct varpool_node
*vnode
)
1259 return (vnode
->analyzed
1260 && !vnode
->symbol
.externally_visible
1261 && !vnode
->symbol
.used_from_other_partition
1262 && !vnode
->symbol
.force_output
);
1265 /* Constant pool accessor function. */
1266 htab_t
constant_pool_htab (void);
1268 /* FIXME: inappropriate dependency of cgraph on IPA. */
1269 #include "ipa-ref-inline.h"
1271 /* Return node that alias N is aliasing. */
1273 static inline struct cgraph_node
*
1274 cgraph_alias_aliased_node (struct cgraph_node
*n
)
1276 struct ipa_ref
*ref
;
1278 ipa_ref_list_reference_iterate (&n
->symbol
.ref_list
, 0, ref
);
1279 gcc_checking_assert (ref
->use
== IPA_REF_ALIAS
);
1280 if (is_a
<cgraph_node
> (ref
->referred
))
1281 return ipa_ref_node (ref
);
1285 /* Return node that alias N is aliasing. */
1287 static inline struct varpool_node
*
1288 varpool_alias_aliased_node (struct varpool_node
*n
)
1290 struct ipa_ref
*ref
;
1292 ipa_ref_list_reference_iterate (&n
->symbol
.ref_list
, 0, ref
);
1293 gcc_checking_assert (ref
->use
== IPA_REF_ALIAS
);
1294 if (is_a
<varpool_node
> (ref
->referred
))
1295 return ipa_ref_varpool_node (ref
);
1299 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1300 Walk through thunk, too.
1301 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1303 static inline struct cgraph_node
*
1304 cgraph_function_node (struct cgraph_node
*node
, enum availability
*availability
)
1307 *availability
= cgraph_function_body_availability (node
);
1310 if (node
->alias
&& node
->analyzed
)
1311 node
= cgraph_alias_aliased_node (node
);
1312 else if (node
->thunk
.thunk_p
)
1313 node
= node
->callees
->callee
;
1316 if (node
&& availability
)
1318 enum availability a
;
1319 a
= cgraph_function_body_availability (node
);
1320 if (a
< *availability
)
1325 *availability
= AVAIL_NOT_AVAILABLE
;
1329 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1330 Do not walk through thunks.
1331 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1333 static inline struct cgraph_node
*
1334 cgraph_function_or_thunk_node (struct cgraph_node
*node
, enum availability
*availability
)
1337 *availability
= cgraph_function_body_availability (node
);
1340 if (node
->alias
&& node
->analyzed
)
1341 node
= cgraph_alias_aliased_node (node
);
1344 if (node
&& availability
)
1346 enum availability a
;
1347 a
= cgraph_function_body_availability (node
);
1348 if (a
< *availability
)
1353 *availability
= AVAIL_NOT_AVAILABLE
;
1357 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1358 Do not walk through thunks.
1359 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1361 static inline struct varpool_node
*
1362 varpool_variable_node (struct varpool_node
*node
, enum availability
*availability
)
1365 *availability
= cgraph_variable_initializer_availability (node
);
1368 if (node
->alias
&& node
->analyzed
)
1369 node
= varpool_alias_aliased_node (node
);
1372 if (node
&& availability
)
1374 enum availability a
;
1375 a
= cgraph_variable_initializer_availability (node
);
1376 if (a
< *availability
)
1381 *availability
= AVAIL_NOT_AVAILABLE
;
1385 /* Return true when the edge E represents a direct recursion. */
1387 cgraph_edge_recursive_p (struct cgraph_edge
*e
)
1389 struct cgraph_node
*callee
= cgraph_function_or_thunk_node (e
->callee
, NULL
);
1390 if (e
->caller
->global
.inlined_to
)
1391 return e
->caller
->global
.inlined_to
->symbol
.decl
== callee
->symbol
.decl
;
1393 return e
->caller
->symbol
.decl
== callee
->symbol
.decl
;
1396 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1398 decl_is_tm_clone (const_tree fndecl
)
1400 struct cgraph_node
*n
= cgraph_get_node (fndecl
);
1406 /* Likewise indicate that a node is needed, i.e. reachable via some
1410 cgraph_mark_force_output_node (struct cgraph_node
*node
)
1412 node
->symbol
.force_output
= 1;
1413 gcc_checking_assert (!node
->global
.inlined_to
);
1416 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1417 or extern function kept around just for inlining. */
1420 symtab_real_symbol_p (symtab_node node
)
1422 struct cgraph_node
*cnode
;
1424 if (!is_a
<cgraph_node
> (node
))
1426 cnode
= cgraph (node
);
1427 if (cnode
->global
.inlined_to
)
1429 if (cnode
->abstract_and_needed
)
1433 #endif /* GCC_CGRAPH_H */