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 and CONST_DECLs. */
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 /*** Flags representing the symbol type. ***/
53 /* True when symbol corresponds to a definition in current unit.
54 set via cgraph_finalize_function or varpool_finalize_decl */
55 unsigned definition
: 1;
56 /* True when symbol is an alias.
57 Set by assemble_alias. */
59 /* True when alias is a weakref. */
61 /* C++ frontend produce same body aliases and extra name aliases for
62 virtual functions and vtables that are obviously equivalent.
63 Those aliases are bit special, especially because C++ frontend
64 visibility code is so ugly it can not get them right at first time
65 and their visibility needs to be copied from their "masters" at
66 the end of parsing. */
67 unsigned cpp_implicit_alias
: 1;
68 /* Set once the definition was analyzed. The list of references and
69 other properties are built during analysis. */
70 unsigned analyzed
: 1;
73 /*** Visibility and linkage flags. ***/
75 /* Set when function is visible by other units. */
76 unsigned externally_visible
: 1;
77 /* The symbol will be assumed to be used in an invisiable way (like
78 by an toplevel asm statement). */
79 unsigned force_output
: 1;
80 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
81 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
82 to static and it does not inhibit optimization. */
83 unsigned forced_by_abi
: 1;
84 /* True when the name is known to be unique and thus it does not need mangling. */
85 unsigned unique_name
: 1;
88 /*** WHOPR Partitioning flags.
89 These flags are used at ltrans stage when only part of the callgraph is
92 /* Set when variable is used from other LTRANS partition. */
93 unsigned used_from_other_partition
: 1;
94 /* Set when function is available in the other LTRANS partition.
95 During WPA output it is used to mark nodes that are present in
96 multiple partitions. */
97 unsigned in_other_partition
: 1;
101 /*** other flags. ***/
103 /* Set when symbol has address taken. */
104 unsigned address_taken
: 1;
107 /* Ordering of all symtab entries. */
110 /* Declaration representing the symbol. */
113 /* Linked list of symbol table entries starting with symtab_nodes. */
115 symtab_node previous
;
117 /* Linked list of symbols with the same asm name. There may be multiple
118 entries for single symbol name during LTO, because symbols are renamed
119 only after partitioning.
121 Because inline clones are kept in the assembler name has, they also produce
124 There are also several long standing bugs where frontends and builtin
125 code produce duplicated decls. */
126 symtab_node next_sharing_asm_name
;
127 symtab_node previous_sharing_asm_name
;
129 /* Circular list of nodes in the same comdat group if non-NULL. */
130 symtab_node same_comdat_group
;
132 /* Vectors of referring and referenced entities. */
133 struct ipa_ref_list ref_list
;
135 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
136 depending to what was known to frontend on the creation time.
137 Once alias is resolved, this pointer become NULL. */
140 /* File stream where this node is being written to. */
141 struct lto_file_decl_data
* lto_file_data
;
143 PTR
GTY ((skip
)) aux
;
148 /* Not yet set by cgraph_function_body_availability. */
150 /* Function body/variable initializer is unknown. */
152 /* Function body/variable initializer is known but might be replaced
153 by a different one from other compilation unit and thus needs to
154 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
155 arbitrary side effects on escaping variables and functions, while
156 like AVAILABLE it might access static variables. */
158 /* Function body/variable initializer is known and will be used in final
161 /* Function body/variable initializer is known and all it's uses are explicitly
162 visible within current unit (ie it's address is never taken and it is not
163 exported to other units).
164 Currently used only for functions. */
168 /* This is the information that is put into the cgraph local structure
169 to recover a function. */
170 struct lto_file_decl_data
;
172 extern const char * const cgraph_availability_names
[];
173 extern const char * const ld_plugin_symbol_resolution_names
[];
175 /* Information about thunk, used only for same body aliases. */
177 struct GTY(()) cgraph_thunk_info
{
178 /* Information about the thunk. */
179 HOST_WIDE_INT fixed_offset
;
180 HOST_WIDE_INT virtual_value
;
183 bool virtual_offset_p
;
184 /* Set to true when alias node is thunk. */
188 /* Information about the function collected locally.
189 Available after function is analyzed. */
191 struct GTY(()) cgraph_local_info
{
192 /* Set when function function is visible in current compilation unit only
193 and its address is never taken. */
196 /* False when there is something makes versioning impossible. */
197 unsigned versionable
: 1;
199 /* False when function calling convention and signature can not be changed.
200 This is the case when __builtin_apply_args is used. */
201 unsigned can_change_signature
: 1;
203 /* True when the function has been originally extern inline, but it is
205 unsigned redefined_extern_inline
: 1;
207 /* True if the function may enter serial irrevocable mode. */
208 unsigned tm_may_enter_irr
: 1;
211 /* Information about the function that needs to be computed globally
212 once compilation is finished. Available only with -funit-at-a-time. */
214 struct GTY(()) cgraph_global_info
{
215 /* For inline clones this points to the function they will be
217 struct cgraph_node
*inlined_to
;
220 /* Information about the function that is propagated by the RTL backend.
221 Available only for functions that has been already assembled. */
223 struct GTY(()) cgraph_rtl_info
{
224 unsigned int preferred_incoming_stack_boundary
;
227 /* Represent which DECL tree (or reference to such tree)
228 will be replaced by another tree while versioning. */
229 struct GTY(()) ipa_replace_map
231 /* The tree that will be replaced. */
233 /* The new (replacing) tree. */
235 /* Parameter number to replace, when old_tree is NULL. */
237 /* True when a substitution should be done, false otherwise. */
239 /* True when we replace a reference to old_tree. */
242 typedef struct ipa_replace_map
*ipa_replace_map_p
;
244 struct GTY(()) cgraph_clone_info
246 vec
<ipa_replace_map_p
, va_gc
> *tree_map
;
248 bitmap combined_args_to_skip
;
252 /* The cgraph data structure.
253 Each function decl has assigned cgraph_node listing callees and callers. */
255 struct GTY(()) cgraph_node
{
256 struct symtab_node_base symbol
;
257 struct cgraph_edge
*callees
;
258 struct cgraph_edge
*callers
;
259 /* List of edges representing indirect calls with a yet undetermined
261 struct cgraph_edge
*indirect_calls
;
262 /* For nested functions points to function the node is nested in. */
264 GTY ((nested_ptr (union symtab_node_def
, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
266 /* Points to first nested function, if any. */
268 GTY ((nested_ptr (union symtab_node_def
, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
270 /* Pointer to the next function with same origin, if any. */
272 GTY ((nested_ptr (union symtab_node_def
, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
274 /* Pointer to the next clone. */
275 struct cgraph_node
*next_sibling_clone
;
276 struct cgraph_node
*prev_sibling_clone
;
277 struct cgraph_node
*clones
;
278 struct cgraph_node
*clone_of
;
279 /* For functions with many calls sites it holds map from call expression
280 to the edge to speed up cgraph_edge function. */
281 htab_t
GTY((param_is (struct cgraph_edge
))) call_site_hash
;
282 /* Declaration node used to be clone of. */
283 tree former_clone_of
;
285 /* Interprocedural passes scheduled to have their transform functions
286 applied next time we execute local pass on them. We maintain it
287 per-function in order to allow IPA passes to introduce new functions. */
288 vec
<ipa_opt_pass
> GTY((skip
)) ipa_transforms_to_apply
;
290 struct cgraph_local_info local
;
291 struct cgraph_global_info global
;
292 struct cgraph_rtl_info rtl
;
293 struct cgraph_clone_info clone
;
294 struct cgraph_thunk_info thunk
;
296 /* Expected number of executions: calculated in profile.c. */
298 /* How to scale counts at materialization time; used to merge
299 LTO units with different number of profile runs. */
300 int count_materialization_scale
;
301 /* Unique id of the node. */
303 /* ID assigned by the profiling. */
304 unsigned int profile_id
;
306 /* Set when decl is an abstract function pointed to by the
307 ABSTRACT_DECL_ORIGIN of a reachable function. */
308 unsigned used_as_abstract_origin
: 1;
309 /* Set once the function is lowered (i.e. its CFG is built). */
310 unsigned lowered
: 1;
311 /* Set once the function has been instantiated and its callee
313 unsigned process
: 1;
314 /* How commonly executed the node is. Initialized during branch
315 probabilities pass. */
316 ENUM_BITFIELD (node_frequency
) frequency
: 2;
317 /* True when function can only be called at startup (from static ctor). */
318 unsigned only_called_at_startup
: 1;
319 /* True when function can only be called at startup (from static dtor). */
320 unsigned only_called_at_exit
: 1;
321 /* True when function is the transactional clone of a function which
322 is called only from inside transactions. */
323 /* ?? We should be able to remove this. We have enough bits in
324 cgraph to calculate it. */
325 unsigned tm_clone
: 1;
326 /* True if this decl is a dispatcher for function versions. */
327 unsigned dispatcher_function
: 1;
331 typedef struct cgraph_node
*cgraph_node_ptr
;
334 /* Function Multiversioning info. */
335 struct GTY(()) cgraph_function_version_info
{
336 /* The cgraph_node for which the function version info is stored. */
337 struct cgraph_node
*this_node
;
338 /* Chains all the semantically identical function versions. The
339 first function in this chain is the version_info node of the
341 struct cgraph_function_version_info
*prev
;
342 /* If this version node corresponds to a dispatcher for function
343 versions, this points to the version info node of the default
344 function, the first node in the chain. */
345 struct cgraph_function_version_info
*next
;
346 /* If this node corresponds to a function version, this points
347 to the dispatcher function decl, which is the function that must
348 be called to execute the right function version at run-time.
350 If this cgraph node is a dispatcher (if dispatcher_function is
351 true, in the cgraph_node struct) for function versions, this
352 points to resolver function, which holds the function body of the
353 dispatcher. The dispatcher decl is an alias to the resolver
355 tree dispatcher_resolver
;
358 /* Get the cgraph_function_version_info node corresponding to node. */
359 struct cgraph_function_version_info
*
360 get_cgraph_node_version (struct cgraph_node
*node
);
362 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
363 corresponding to cgraph_node NODE. */
364 struct cgraph_function_version_info
*
365 insert_new_cgraph_node_version (struct cgraph_node
*node
);
367 /* Record that DECL1 and DECL2 are semantically identical function
369 void record_function_versions (tree decl1
, tree decl2
);
371 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
372 DECL is a duplicate declaration. */
373 void delete_function_version (tree decl
);
375 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
376 can appear in multiple sets. */
377 struct cgraph_node_set_def
379 struct pointer_map_t
*map
;
380 vec
<cgraph_node_ptr
> nodes
;
383 typedef struct varpool_node
*varpool_node_ptr
;
386 /* A varpool node set is a collection of varpool nodes. A varpool node
387 can appear in multiple sets. */
388 struct varpool_node_set_def
390 struct pointer_map_t
* map
;
391 vec
<varpool_node_ptr
> nodes
;
394 typedef struct cgraph_node_set_def
*cgraph_node_set
;
397 typedef struct varpool_node_set_def
*varpool_node_set
;
400 /* Iterator structure for cgraph node sets. */
405 } cgraph_node_set_iterator
;
407 /* Iterator structure for varpool node sets. */
410 varpool_node_set set
;
412 } varpool_node_set_iterator
;
414 #define DEFCIFCODE(code, string) CIF_ ## code,
415 /* Reasons for inlining failures. */
416 typedef enum cgraph_inline_failed_enum
{
417 #include "cif-code.def"
419 } cgraph_inline_failed_t
;
421 /* Structure containing additional information about an indirect call. */
423 struct GTY(()) cgraph_indirect_call_info
425 /* When polymorphic is set, this field contains offset where the object which
426 was actually used in the polymorphic resides within a larger structure.
427 If agg_contents is set, the field contains the offset within the aggregate
428 from which the address to call was loaded. */
429 HOST_WIDE_INT offset
;
430 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
431 HOST_WIDE_INT otr_token
;
432 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
434 /* Index of the parameter that is called. */
436 /* ECF flags determined from the caller. */
438 /* Profile_id of common target obtrained from profile. */
439 int common_target_id
;
440 /* Probability that call will land in function with COMMON_TARGET_ID. */
441 int common_target_probability
;
443 /* Set when the call is a virtual call with the parameter being the
444 associated object pointer rather than a simple direct call. */
445 unsigned polymorphic
: 1;
446 /* Set when the call is a call of a pointer loaded from contents of an
447 aggregate at offset. */
448 unsigned agg_contents
: 1;
449 /* Set when this is a call through a member pointer. */
450 unsigned member_ptr
: 1;
451 /* When the previous bit is set, this one determines whether the destination
452 is loaded from a parameter passed by reference. */
456 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge
{
457 /* Expected number of executions: calculated in profile.c. */
459 struct cgraph_node
*caller
;
460 struct cgraph_node
*callee
;
461 struct cgraph_edge
*prev_caller
;
462 struct cgraph_edge
*next_caller
;
463 struct cgraph_edge
*prev_callee
;
464 struct cgraph_edge
*next_callee
;
466 /* Additional information about an indirect call. Not cleared when an edge
468 struct cgraph_indirect_call_info
*indirect_info
;
469 PTR
GTY ((skip (""))) aux
;
470 /* When equal to CIF_OK, inline this call. Otherwise, points to the
471 explanation why function was not inlined. */
472 cgraph_inline_failed_t inline_failed
;
473 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
474 when the function is serialized in. */
475 unsigned int lto_stmt_uid
;
476 /* Expected frequency of executions within the function.
477 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
478 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
480 /* Unique id of the edge. */
482 /* Whether this edge was made direct by indirect inlining. */
483 unsigned int indirect_inlining_edge
: 1;
484 /* Whether this edge describes an indirect call with an undetermined
486 unsigned int indirect_unknown_callee
: 1;
487 /* Whether this edge is still a dangling */
488 /* True if the corresponding CALL stmt cannot be inlined. */
489 unsigned int call_stmt_cannot_inline_p
: 1;
490 /* Can this call throw externally? */
491 unsigned int can_throw_external
: 1;
492 /* Edges with SPECULATIVE flag represents indirect calls that was
493 speculatively turned into direct (i.e. by profile feedback).
494 The final code sequence will have form:
496 if (call_target == expected_fn)
501 Every speculative call is represented by three components attached
502 to a same call statement:
503 1) a direct call (to expected_fn)
504 2) an indirect call (to call_target)
505 3) a IPA_REF_ADDR refrence to expected_fn.
507 Optimizers may later redirect direct call to clone, so 1) and 3)
508 do not need to necesarily agree with destination. */
509 unsigned int speculative
: 1;
512 #define CGRAPH_FREQ_BASE 1000
513 #define CGRAPH_FREQ_MAX 100000
515 typedef struct cgraph_edge
*cgraph_edge_p
;
518 /* The varpool data structure.
519 Each static variable decl has assigned varpool_node. */
521 struct GTY(()) varpool_node
{
522 struct symtab_node_base symbol
;
524 /* Set when variable is scheduled to be assembled. */
528 /* Every top level asm statement is put into a asm_node. */
530 struct GTY(()) asm_node
{
532 struct asm_node
*next
;
533 /* String for this asm node. */
535 /* Ordering of all cgraph nodes. */
539 /* Symbol table entry. */
540 union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
541 chain_prev ("%h.symbol.previous"))) symtab_node_def
{
542 struct symtab_node_base
GTY ((tag ("SYMTAB_SYMBOL"))) symbol
;
543 /* To access the following fields,
544 use the use dyn_cast or as_a to obtain the concrete type. */
545 struct cgraph_node
GTY ((tag ("SYMTAB_FUNCTION"))) x_function
;
546 struct varpool_node
GTY ((tag ("SYMTAB_VARIABLE"))) x_variable
;
549 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
554 is_a_helper
<cgraph_node
>::test (symtab_node_def
*p
)
556 return p
->symbol
.type
== SYMTAB_FUNCTION
;
559 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
564 is_a_helper
<varpool_node
>::test (symtab_node_def
*p
)
566 return p
->symbol
.type
== SYMTAB_VARIABLE
;
569 extern GTY(()) symtab_node symtab_nodes
;
570 extern GTY(()) int cgraph_n_nodes
;
571 extern GTY(()) int cgraph_max_uid
;
572 extern GTY(()) int cgraph_edge_max_uid
;
573 extern bool cgraph_global_info_ready
;
576 /* Frontend is parsing and finalizing functions. */
577 CGRAPH_STATE_PARSING
,
578 /* Callgraph is being constructed. It is safe to add new functions. */
579 CGRAPH_STATE_CONSTRUCTION
,
580 /* Callgraph is being at LTO time. */
581 CGRAPH_LTO_STREAMING
,
582 /* Callgraph is built and IPA passes are being run. */
584 /* Callgraph is built and all functions are transformed to SSA form. */
585 CGRAPH_STATE_IPA_SSA
,
586 /* Functions are now ordered and being passed to RTL expanders. */
587 CGRAPH_STATE_EXPANSION
,
588 /* All cgraph expansion is done. */
589 CGRAPH_STATE_FINISHED
591 extern enum cgraph_state cgraph_state
;
592 extern bool cgraph_function_flags_ready
;
593 extern cgraph_node_set cgraph_new_nodes
;
595 extern GTY(()) struct asm_node
*asm_nodes
;
596 extern GTY(()) int symtab_order
;
597 extern bool cpp_implicit_aliases_done
;
600 void symtab_register_node (symtab_node
);
601 void symtab_unregister_node (symtab_node
);
602 void symtab_remove_node (symtab_node
);
603 symtab_node
symtab_get_node (const_tree
);
604 symtab_node
symtab_node_for_asm (const_tree asmname
);
605 const char * symtab_node_asm_name (symtab_node
);
606 const char * symtab_node_name (symtab_node
);
607 void symtab_insert_node_to_hashtable (symtab_node
);
608 void symtab_add_to_same_comdat_group (symtab_node
, symtab_node
);
609 void symtab_dissolve_same_comdat_group_list (symtab_node node
);
610 void dump_symtab (FILE *);
611 void debug_symtab (void);
612 void dump_symtab_node (FILE *, symtab_node
);
613 void debug_symtab_node (symtab_node
);
614 void dump_symtab_base (FILE *, symtab_node
);
615 void verify_symtab (void);
616 void verify_symtab_node (symtab_node
);
617 bool verify_symtab_base (symtab_node
);
618 bool symtab_used_from_object_file_p (symtab_node
);
619 void symtab_make_decl_local (tree
);
620 symtab_node
symtab_alias_ultimate_target (symtab_node
,
621 enum availability
*avail
= NULL
);
622 bool symtab_resolve_alias (symtab_node node
, symtab_node target
);
623 void fixup_same_cpp_alias_visibility (symtab_node node
, symtab_node target
);
624 bool symtab_for_node_and_aliases (symtab_node
,
625 bool (*) (symtab_node
, void *),
628 symtab_node
symtab_nonoverwritable_alias (symtab_node
);
629 enum availability
symtab_node_availability (symtab_node
);
630 bool symtab_semantically_equivalent_p (symtab_node
, symtab_node
);
633 void dump_cgraph (FILE *);
634 void debug_cgraph (void);
635 void dump_cgraph_node (FILE *, struct cgraph_node
*);
636 void debug_cgraph_node (struct cgraph_node
*);
637 void cgraph_remove_edge (struct cgraph_edge
*);
638 void cgraph_remove_node (struct cgraph_node
*);
639 void cgraph_release_function_body (struct cgraph_node
*);
640 void release_function_body (tree
);
641 void cgraph_node_remove_callees (struct cgraph_node
*node
);
642 struct cgraph_edge
*cgraph_create_edge (struct cgraph_node
*,
643 struct cgraph_node
*,
644 gimple
, gcov_type
, int);
645 struct cgraph_edge
*cgraph_create_indirect_edge (struct cgraph_node
*, gimple
,
646 int, gcov_type
, int);
647 struct cgraph_indirect_call_info
*cgraph_allocate_init_indirect_info (void);
648 struct cgraph_node
* cgraph_create_node (tree
);
649 struct cgraph_node
* cgraph_create_empty_node (void);
650 struct cgraph_node
* cgraph_get_create_node (tree
);
651 struct cgraph_node
* cgraph_get_create_real_symbol_node (tree
);
652 struct cgraph_node
* cgraph_same_body_alias (struct cgraph_node
*, tree
, tree
);
653 struct cgraph_node
* cgraph_add_thunk (struct cgraph_node
*, tree
, tree
, bool, HOST_WIDE_INT
,
654 HOST_WIDE_INT
, tree
, tree
);
655 struct cgraph_node
*cgraph_node_for_asm (tree
);
656 struct cgraph_edge
*cgraph_edge (struct cgraph_node
*, gimple
);
657 void cgraph_set_call_stmt (struct cgraph_edge
*, gimple
, bool update_speculative
= true);
658 void cgraph_update_edges_for_call_stmt (gimple
, tree
, gimple
);
659 struct cgraph_local_info
*cgraph_local_info (tree
);
660 struct cgraph_global_info
*cgraph_global_info (tree
);
661 struct cgraph_rtl_info
*cgraph_rtl_info (tree
);
662 struct cgraph_node
*cgraph_create_function_alias (tree
, tree
);
663 void cgraph_call_node_duplication_hooks (struct cgraph_node
*,
664 struct cgraph_node
*);
665 void cgraph_call_edge_duplication_hooks (struct cgraph_edge
*,
666 struct cgraph_edge
*);
668 void cgraph_redirect_edge_callee (struct cgraph_edge
*, struct cgraph_node
*);
669 struct cgraph_edge
*cgraph_make_edge_direct (struct cgraph_edge
*, struct cgraph_node
*);
670 bool cgraph_only_called_directly_p (struct cgraph_node
*);
672 bool cgraph_function_possibly_inlined_p (tree
);
673 void cgraph_unnest_node (struct cgraph_node
*);
675 enum availability
cgraph_function_body_availability (struct cgraph_node
*);
676 void cgraph_add_new_function (tree
, bool);
677 const char* cgraph_inline_failed_string (cgraph_inline_failed_t
);
679 void cgraph_set_nothrow_flag (struct cgraph_node
*, bool);
680 void cgraph_set_const_flag (struct cgraph_node
*, bool, bool);
681 void cgraph_set_pure_flag (struct cgraph_node
*, bool, bool);
682 bool cgraph_node_cannot_return (struct cgraph_node
*);
683 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge
*);
684 bool cgraph_will_be_removed_from_program_if_no_direct_calls
685 (struct cgraph_node
*node
);
686 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
687 (struct cgraph_node
*node
);
688 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node
*node
);
689 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution
);
690 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node
*,
691 bool (*) (struct cgraph_node
*, void *),
694 bool cgraph_for_node_and_aliases (struct cgraph_node
*,
695 bool (*) (struct cgraph_node
*, void *),
697 vec
<cgraph_edge_p
> collect_callers_of_node (struct cgraph_node
*node
);
698 void verify_cgraph (void);
699 void verify_cgraph_node (struct cgraph_node
*);
700 void cgraph_mark_address_taken_node (struct cgraph_node
*);
702 typedef void (*cgraph_edge_hook
)(struct cgraph_edge
*, void *);
703 typedef void (*cgraph_node_hook
)(struct cgraph_node
*, void *);
704 typedef void (*varpool_node_hook
)(struct varpool_node
*, void *);
705 typedef void (*cgraph_2edge_hook
)(struct cgraph_edge
*, struct cgraph_edge
*,
707 typedef void (*cgraph_2node_hook
)(struct cgraph_node
*, struct cgraph_node
*,
709 struct cgraph_edge_hook_list
;
710 struct cgraph_node_hook_list
;
711 struct varpool_node_hook_list
;
712 struct cgraph_2edge_hook_list
;
713 struct cgraph_2node_hook_list
;
714 struct cgraph_edge_hook_list
*cgraph_add_edge_removal_hook (cgraph_edge_hook
, void *);
715 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list
*);
716 struct cgraph_node_hook_list
*cgraph_add_node_removal_hook (cgraph_node_hook
,
718 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list
*);
719 struct varpool_node_hook_list
*varpool_add_node_removal_hook (varpool_node_hook
,
721 void varpool_remove_node_removal_hook (struct varpool_node_hook_list
*);
722 struct cgraph_node_hook_list
*cgraph_add_function_insertion_hook (cgraph_node_hook
,
724 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list
*);
725 struct varpool_node_hook_list
*varpool_add_variable_insertion_hook (varpool_node_hook
,
727 void varpool_remove_variable_insertion_hook (struct varpool_node_hook_list
*);
728 void cgraph_call_function_insertion_hooks (struct cgraph_node
*node
);
729 struct cgraph_2edge_hook_list
*cgraph_add_edge_duplication_hook (cgraph_2edge_hook
, void *);
730 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list
*);
731 struct cgraph_2node_hook_list
*cgraph_add_node_duplication_hook (cgraph_2node_hook
, void *);
732 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list
*);
733 gimple
cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge
*);
734 struct cgraph_node
* cgraph_function_node (struct cgraph_node
*,
735 enum availability
*avail
= NULL
);
736 bool cgraph_get_body (struct cgraph_node
*node
);
738 cgraph_turn_edge_to_speculative (struct cgraph_edge
*,
739 struct cgraph_node
*,
741 void cgraph_speculative_call_info (struct cgraph_edge
*,
742 struct cgraph_edge
*&,
743 struct cgraph_edge
*&,
746 /* In cgraphunit.c */
747 struct asm_node
*add_asm_node (tree
);
748 extern FILE *cgraph_dump_file
;
749 void cgraph_finalize_function (tree
, bool);
750 void finalize_compilation_unit (void);
752 void init_cgraph (void);
753 bool cgraph_process_new_functions (void);
754 void cgraph_process_same_body_aliases (void);
755 void fixup_same_cpp_alias_visibility (symtab_node
, symtab_node target
, tree
);
756 /* Initialize datastructures so DECL is a function in lowered gimple form.
757 IN_SSA is true if the gimple is in SSA. */
758 basic_block
init_lowered_empty_function (tree
, bool);
759 void cgraph_reset_node (struct cgraph_node
*);
760 bool expand_thunk (struct cgraph_node
*, bool);
762 /* In cgraphclones.c */
764 struct cgraph_edge
* cgraph_clone_edge (struct cgraph_edge
*,
765 struct cgraph_node
*, gimple
,
766 unsigned, gcov_type
, int, bool);
767 struct cgraph_node
* cgraph_clone_node (struct cgraph_node
*, tree
, gcov_type
,
768 int, bool, vec
<cgraph_edge_p
>,
769 bool, struct cgraph_node
*);
770 tree
clone_function_name (tree decl
, const char *);
771 struct cgraph_node
* cgraph_create_virtual_clone (struct cgraph_node
*old_node
,
773 vec
<ipa_replace_map_p
, va_gc
> *tree_map
,
775 const char *clone_name
);
776 struct cgraph_node
*cgraph_find_replacement_node (struct cgraph_node
*);
777 bool cgraph_remove_node_and_inline_clones (struct cgraph_node
*, struct cgraph_node
*);
778 void cgraph_set_call_stmt_including_clones (struct cgraph_node
*, gimple
, gimple
,
779 bool update_speculative
= true);
780 void cgraph_create_edge_including_clones (struct cgraph_node
*,
781 struct cgraph_node
*,
782 gimple
, gimple
, gcov_type
, int,
783 cgraph_inline_failed_t
);
784 void cgraph_materialize_all_clones (void);
785 struct cgraph_node
* cgraph_copy_node_for_versioning (struct cgraph_node
*,
786 tree
, vec
<cgraph_edge_p
>, bitmap
);
787 struct cgraph_node
*cgraph_function_versioning (struct cgraph_node
*,
789 vec
<ipa_replace_map_p
, va_gc
> *,
790 bitmap
, bool, bitmap
,
791 basic_block
, const char *);
792 void tree_function_versioning (tree
, tree
, vec
<ipa_replace_map_p
, va_gc
> *,
793 bool, bitmap
, bool, bitmap
, basic_block
);
794 struct cgraph_edge
*cgraph_resolve_speculation (struct cgraph_edge
*, tree
);
796 /* In cgraphbuild.c */
797 unsigned int rebuild_cgraph_edges (void);
798 void cgraph_rebuild_references (void);
799 int compute_call_stmt_bb_frequency (tree
, basic_block bb
);
800 void record_references_in_initializer (tree
, bool);
801 void ipa_record_stmt_references (struct cgraph_node
*, gimple
);
804 bool symtab_remove_unreachable_nodes (bool, FILE *);
805 cgraph_node_set
cgraph_node_set_new (void);
806 cgraph_node_set_iterator
cgraph_node_set_find (cgraph_node_set
,
807 struct cgraph_node
*);
808 void cgraph_node_set_add (cgraph_node_set
, struct cgraph_node
*);
809 void cgraph_node_set_remove (cgraph_node_set
, struct cgraph_node
*);
810 void dump_cgraph_node_set (FILE *, cgraph_node_set
);
811 void debug_cgraph_node_set (cgraph_node_set
);
812 void free_cgraph_node_set (cgraph_node_set
);
813 void cgraph_build_static_cdtor (char which
, tree body
, int priority
);
815 varpool_node_set
varpool_node_set_new (void);
816 varpool_node_set_iterator
varpool_node_set_find (varpool_node_set
,
817 struct varpool_node
*);
818 void varpool_node_set_add (varpool_node_set
, struct varpool_node
*);
819 void varpool_node_set_remove (varpool_node_set
, struct varpool_node
*);
820 void dump_varpool_node_set (FILE *, varpool_node_set
);
821 void debug_varpool_node_set (varpool_node_set
);
822 void free_varpool_node_set (varpool_node_set
);
823 void ipa_discover_readonly_nonaddressable_vars (void);
824 bool varpool_externally_visible_p (struct varpool_node
*);
827 bool cgraph_maybe_hot_edge_p (struct cgraph_edge
*e
);
828 bool cgraph_optimize_for_size_p (struct cgraph_node
*);
831 struct varpool_node
*varpool_create_empty_node (void);
832 struct varpool_node
*varpool_node_for_decl (tree
);
833 struct varpool_node
*varpool_node_for_asm (tree asmname
);
834 void varpool_mark_needed_node (struct varpool_node
*);
835 void debug_varpool (void);
836 void dump_varpool (FILE *);
837 void dump_varpool_node (FILE *, struct varpool_node
*);
839 void varpool_finalize_decl (tree
);
840 enum availability
cgraph_variable_initializer_availability (struct varpool_node
*);
841 void cgraph_make_node_local (struct cgraph_node
*);
842 bool cgraph_node_can_be_local_p (struct cgraph_node
*);
845 void varpool_remove_node (struct varpool_node
*node
);
846 void varpool_finalize_named_section_flags (struct varpool_node
*node
);
847 bool varpool_output_variables (void);
848 bool varpool_assemble_decl (struct varpool_node
*node
);
849 void varpool_analyze_node (struct varpool_node
*);
850 struct varpool_node
* varpool_extra_name_alias (tree
, tree
);
851 struct varpool_node
* varpool_create_variable_alias (tree
, tree
);
852 void varpool_reset_queue (void);
853 tree
ctor_for_folding (tree
);
854 bool varpool_for_node_and_aliases (struct varpool_node
*,
855 bool (*) (struct varpool_node
*, void *),
857 void varpool_add_new_variable (tree
);
858 void symtab_initialize_asm_name_hash (void);
859 void symtab_prevail_in_asm_name_hash (symtab_node node
);
860 void varpool_remove_initializer (struct varpool_node
*);
863 /* Return callgraph node for given symbol and check it is a function. */
864 static inline struct cgraph_node
*
865 cgraph (symtab_node node
)
867 gcc_checking_assert (!node
|| node
->symbol
.type
== SYMTAB_FUNCTION
);
868 return (struct cgraph_node
*)node
;
871 /* Return varpool node for given symbol and check it is a variable. */
872 static inline struct varpool_node
*
873 varpool (symtab_node node
)
875 gcc_checking_assert (!node
|| node
->symbol
.type
== SYMTAB_VARIABLE
);
876 return (struct varpool_node
*)node
;
879 /* Return callgraph node for given symbol and check it is a function. */
880 static inline struct cgraph_node
*
881 cgraph_get_node (const_tree decl
)
883 gcc_checking_assert (TREE_CODE (decl
) == FUNCTION_DECL
);
884 return cgraph (symtab_get_node (decl
));
887 /* Return varpool node for given symbol and check it is a function. */
888 static inline struct varpool_node
*
889 varpool_get_node (const_tree decl
)
891 gcc_checking_assert (TREE_CODE (decl
) == VAR_DECL
);
892 return varpool (symtab_get_node (decl
));
895 /* Return asm name of cgraph node. */
896 static inline const char *
897 cgraph_node_asm_name (struct cgraph_node
*node
)
899 return symtab_node_asm_name ((symtab_node
)node
);
902 /* Return asm name of varpool node. */
903 static inline const char *
904 varpool_node_asm_name(struct varpool_node
*node
)
906 return symtab_node_asm_name ((symtab_node
)node
);
909 /* Return name of cgraph node. */
910 static inline const char *
911 cgraph_node_name(struct cgraph_node
*node
)
913 return symtab_node_name ((symtab_node
)node
);
916 /* Return name of varpool node. */
917 static inline const char *
918 varpool_node_name(struct varpool_node
*node
)
920 return symtab_node_name ((symtab_node
)node
);
923 /* Walk all symbols. */
924 #define FOR_EACH_SYMBOL(node) \
925 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
928 /* Return first variable. */
929 static inline struct varpool_node
*
930 varpool_first_variable (void)
933 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
934 if (varpool_node
*vnode
= dyn_cast
<varpool_node
> (node
))
939 /* Return next variable after NODE. */
940 static inline struct varpool_node
*
941 varpool_next_variable (struct varpool_node
*node
)
943 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
944 for (; node1
; node1
= node1
->symbol
.next
)
945 if (varpool_node
*vnode1
= dyn_cast
<varpool_node
> (node1
))
949 /* Walk all variables. */
950 #define FOR_EACH_VARIABLE(node) \
951 for ((node) = varpool_first_variable (); \
953 (node) = varpool_next_variable ((node)))
955 /* Return first reachable static variable with initializer. */
956 static inline struct varpool_node
*
957 varpool_first_static_initializer (void)
960 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
962 varpool_node
*vnode
= dyn_cast
<varpool_node
> (node
);
963 if (vnode
&& DECL_INITIAL (node
->symbol
.decl
))
969 /* Return next reachable static variable with initializer after NODE. */
970 static inline struct varpool_node
*
971 varpool_next_static_initializer (struct varpool_node
*node
)
973 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
974 for (; node1
; node1
= node1
->symbol
.next
)
976 varpool_node
*vnode1
= dyn_cast
<varpool_node
> (node1
);
977 if (vnode1
&& DECL_INITIAL (node1
->symbol
.decl
))
983 /* Walk all static variables with initializer set. */
984 #define FOR_EACH_STATIC_INITIALIZER(node) \
985 for ((node) = varpool_first_static_initializer (); (node); \
986 (node) = varpool_next_static_initializer (node))
988 /* Return first reachable static variable with initializer. */
989 static inline struct varpool_node
*
990 varpool_first_defined_variable (void)
993 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
995 varpool_node
*vnode
= dyn_cast
<varpool_node
> (node
);
996 if (vnode
&& vnode
->symbol
.definition
)
1002 /* Return next reachable static variable with initializer after NODE. */
1003 static inline struct varpool_node
*
1004 varpool_next_defined_variable (struct varpool_node
*node
)
1006 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
1007 for (; node1
; node1
= node1
->symbol
.next
)
1009 varpool_node
*vnode1
= dyn_cast
<varpool_node
> (node1
);
1010 if (vnode1
&& vnode1
->symbol
.definition
)
1015 /* Walk all variables with definitions in current unit. */
1016 #define FOR_EACH_DEFINED_VARIABLE(node) \
1017 for ((node) = varpool_first_defined_variable (); (node); \
1018 (node) = varpool_next_defined_variable (node))
1020 /* Return first function with body defined. */
1021 static inline struct cgraph_node
*
1022 cgraph_first_defined_function (void)
1025 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
1027 cgraph_node
*cn
= dyn_cast
<cgraph_node
> (node
);
1028 if (cn
&& cn
->symbol
.definition
)
1034 /* Return next function with body defined after NODE. */
1035 static inline struct cgraph_node
*
1036 cgraph_next_defined_function (struct cgraph_node
*node
)
1038 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
1039 for (; node1
; node1
= node1
->symbol
.next
)
1041 cgraph_node
*cn1
= dyn_cast
<cgraph_node
> (node1
);
1042 if (cn1
&& cn1
->symbol
.definition
)
1048 /* Walk all functions with body defined. */
1049 #define FOR_EACH_DEFINED_FUNCTION(node) \
1050 for ((node) = cgraph_first_defined_function (); (node); \
1051 (node) = cgraph_next_defined_function ((node)))
1053 /* Return first function. */
1054 static inline struct cgraph_node
*
1055 cgraph_first_function (void)
1058 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
1059 if (cgraph_node
*cn
= dyn_cast
<cgraph_node
> (node
))
1064 /* Return next function. */
1065 static inline struct cgraph_node
*
1066 cgraph_next_function (struct cgraph_node
*node
)
1068 symtab_node node1
= (symtab_node
) node
->symbol
.next
;
1069 for (; node1
; node1
= node1
->symbol
.next
)
1070 if (cgraph_node
*cn1
= dyn_cast
<cgraph_node
> (node1
))
1074 /* Walk all functions. */
1075 #define FOR_EACH_FUNCTION(node) \
1076 for ((node) = cgraph_first_function (); (node); \
1077 (node) = cgraph_next_function ((node)))
1079 /* Return true when NODE is a function with Gimple body defined
1080 in current unit. Functions can also be define externally or they
1081 can be thunks with no Gimple representation.
1083 Note that at WPA stage, the function body may not be present in memory. */
1086 cgraph_function_with_gimple_body_p (struct cgraph_node
*node
)
1088 return node
->symbol
.definition
&& !node
->thunk
.thunk_p
&& !node
->symbol
.alias
;
1091 /* Return first function with body defined. */
1092 static inline struct cgraph_node
*
1093 cgraph_first_function_with_gimple_body (void)
1096 for (node
= symtab_nodes
; node
; node
= node
->symbol
.next
)
1098 cgraph_node
*cn
= dyn_cast
<cgraph_node
> (node
);
1099 if (cn
&& cgraph_function_with_gimple_body_p (cn
))
1105 /* Return next reachable static variable with initializer after NODE. */
1106 static inline struct cgraph_node
*
1107 cgraph_next_function_with_gimple_body (struct cgraph_node
*node
)
1109 symtab_node node1
= node
->symbol
.next
;
1110 for (; node1
; node1
= node1
->symbol
.next
)
1112 cgraph_node
*cn1
= dyn_cast
<cgraph_node
> (node1
);
1113 if (cn1
&& cgraph_function_with_gimple_body_p (cn1
))
1119 /* Walk all functions with body defined. */
1120 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1121 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1122 (node) = cgraph_next_function_with_gimple_body (node))
1124 /* Create a new static variable of type TYPE. */
1125 tree
add_new_static_var (tree type
);
1127 /* Return true if iterator CSI points to nothing. */
1129 csi_end_p (cgraph_node_set_iterator csi
)
1131 return csi
.index
>= csi
.set
->nodes
.length ();
1134 /* Advance iterator CSI. */
1136 csi_next (cgraph_node_set_iterator
*csi
)
1141 /* Return the node pointed to by CSI. */
1142 static inline struct cgraph_node
*
1143 csi_node (cgraph_node_set_iterator csi
)
1145 return csi
.set
->nodes
[csi
.index
];
1148 /* Return an iterator to the first node in SET. */
1149 static inline cgraph_node_set_iterator
1150 csi_start (cgraph_node_set set
)
1152 cgraph_node_set_iterator csi
;
1159 /* Return true if SET contains NODE. */
1161 cgraph_node_in_set_p (struct cgraph_node
*node
, cgraph_node_set set
)
1163 cgraph_node_set_iterator csi
;
1164 csi
= cgraph_node_set_find (set
, node
);
1165 return !csi_end_p (csi
);
1168 /* Return number of nodes in SET. */
1169 static inline size_t
1170 cgraph_node_set_size (cgraph_node_set set
)
1172 return set
->nodes
.length ();
1175 /* Return true if iterator VSI points to nothing. */
1177 vsi_end_p (varpool_node_set_iterator vsi
)
1179 return vsi
.index
>= vsi
.set
->nodes
.length ();
1182 /* Advance iterator VSI. */
1184 vsi_next (varpool_node_set_iterator
*vsi
)
1189 /* Return the node pointed to by VSI. */
1190 static inline struct varpool_node
*
1191 vsi_node (varpool_node_set_iterator vsi
)
1193 return vsi
.set
->nodes
[vsi
.index
];
1196 /* Return an iterator to the first node in SET. */
1197 static inline varpool_node_set_iterator
1198 vsi_start (varpool_node_set set
)
1200 varpool_node_set_iterator vsi
;
1207 /* Return true if SET contains NODE. */
1209 varpool_node_in_set_p (struct varpool_node
*node
, varpool_node_set set
)
1211 varpool_node_set_iterator vsi
;
1212 vsi
= varpool_node_set_find (set
, node
);
1213 return !vsi_end_p (vsi
);
1216 /* Return number of nodes in SET. */
1217 static inline size_t
1218 varpool_node_set_size (varpool_node_set set
)
1220 return set
->nodes
.length ();
1223 /* Uniquize all constants that appear in memory.
1224 Each constant in memory thus far output is recorded
1225 in `const_desc_table'. */
1227 struct GTY(()) constant_descriptor_tree
{
1228 /* A MEM for the constant. */
1231 /* The value of the constant. */
1234 /* Hash of value. Computing the hash from value each time
1235 hashfn is called can't work properly, as that means recursive
1236 use of the hash table during hash table expansion. */
1240 /* Return true if set is nonempty. */
1242 cgraph_node_set_nonempty_p (cgraph_node_set set
)
1244 return !set
->nodes
.is_empty ();
1247 /* Return true if set is nonempty. */
1249 varpool_node_set_nonempty_p (varpool_node_set set
)
1251 return !set
->nodes
.is_empty ();
1254 /* Return true when function NODE is only called directly or it has alias.
1255 i.e. it is not externally visible, address was not taken and
1256 it is not used in any other non-standard way. */
1259 cgraph_only_called_directly_or_aliased_p (struct cgraph_node
*node
)
1261 gcc_assert (!node
->global
.inlined_to
);
1262 return (!node
->symbol
.force_output
&& !node
->symbol
.address_taken
1263 && !node
->symbol
.used_from_other_partition
1264 && !DECL_VIRTUAL_P (node
->symbol
.decl
)
1265 && !DECL_STATIC_CONSTRUCTOR (node
->symbol
.decl
)
1266 && !DECL_STATIC_DESTRUCTOR (node
->symbol
.decl
)
1267 && !node
->symbol
.externally_visible
);
1270 /* Return true when function NODE can be removed from callgraph
1271 if all direct calls are eliminated. */
1274 varpool_can_remove_if_no_refs (struct varpool_node
*node
)
1276 if (DECL_EXTERNAL (node
->symbol
.decl
))
1278 return (!node
->symbol
.force_output
&& !node
->symbol
.used_from_other_partition
1279 && ((DECL_COMDAT (node
->symbol
.decl
)
1280 && !node
->symbol
.forced_by_abi
1281 && !symtab_used_from_object_file_p ((symtab_node
) node
))
1282 || !node
->symbol
.externally_visible
1283 || DECL_HAS_VALUE_EXPR_P (node
->symbol
.decl
)));
1286 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1287 i.e. if the variable is not externally visible or not used in some magic
1288 way (asm statement or such).
1289 The magic uses are all summarized in force_output flag. */
1292 varpool_all_refs_explicit_p (struct varpool_node
*vnode
)
1294 return (vnode
->symbol
.definition
1295 && !vnode
->symbol
.externally_visible
1296 && !vnode
->symbol
.used_from_other_partition
1297 && !vnode
->symbol
.force_output
);
1300 /* Constant pool accessor function. */
1301 htab_t
constant_pool_htab (void);
1303 /* FIXME: inappropriate dependency of cgraph on IPA. */
1304 #include "ipa-ref-inline.h"
1306 /* Return node that alias N is aliasing. */
1308 static inline symtab_node
1309 symtab_alias_target (symtab_node n
)
1311 struct ipa_ref
*ref
;
1312 ipa_ref_list_reference_iterate (&n
->symbol
.ref_list
, 0, ref
);
1313 gcc_checking_assert (ref
->use
== IPA_REF_ALIAS
);
1314 return ref
->referred
;
1317 static inline struct cgraph_node
*
1318 cgraph_alias_target (struct cgraph_node
*n
)
1320 return dyn_cast
<cgraph_node
> (symtab_alias_target ((symtab_node
) n
));
1323 static inline struct varpool_node
*
1324 varpool_alias_target (struct varpool_node
*n
)
1326 return dyn_cast
<varpool_node
> (symtab_alias_target ((symtab_node
) n
));
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
,
1335 enum availability
*availability
= NULL
)
1337 struct cgraph_node
*n
;
1339 n
= dyn_cast
<cgraph_node
> (symtab_alias_ultimate_target ((symtab_node
)node
,
1341 if (!n
&& availability
)
1342 *availability
= AVAIL_NOT_AVAILABLE
;
1345 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1346 Do not walk through thunks.
1347 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1349 static inline struct varpool_node
*
1350 varpool_variable_node (struct varpool_node
*node
,
1351 enum availability
*availability
= NULL
)
1353 struct varpool_node
*n
;
1355 n
= dyn_cast
<varpool_node
> (symtab_alias_ultimate_target ((symtab_node
)node
,
1357 if (!n
&& availability
)
1358 *availability
= AVAIL_NOT_AVAILABLE
;
1362 /* Return true when the edge E represents a direct recursion. */
1364 cgraph_edge_recursive_p (struct cgraph_edge
*e
)
1366 struct cgraph_node
*callee
= cgraph_function_or_thunk_node (e
->callee
, NULL
);
1367 if (e
->caller
->global
.inlined_to
)
1368 return e
->caller
->global
.inlined_to
->symbol
.decl
== callee
->symbol
.decl
;
1370 return e
->caller
->symbol
.decl
== callee
->symbol
.decl
;
1373 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1375 decl_is_tm_clone (const_tree fndecl
)
1377 struct cgraph_node
*n
= cgraph_get_node (fndecl
);
1383 /* Likewise indicate that a node is needed, i.e. reachable via some
1387 cgraph_mark_force_output_node (struct cgraph_node
*node
)
1389 node
->symbol
.force_output
= 1;
1390 gcc_checking_assert (!node
->global
.inlined_to
);
1393 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1394 or abstract function kept for debug info purposes only. */
1397 symtab_real_symbol_p (symtab_node node
)
1399 struct cgraph_node
*cnode
;
1401 if (DECL_ABSTRACT (node
->symbol
.decl
))
1403 if (!is_a
<cgraph_node
> (node
))
1405 cnode
= cgraph (node
);
1406 if (cnode
->global
.inlined_to
)
1411 /* Return true if NODE can be discarded by linker from the binary. */
1414 symtab_can_be_discarded (symtab_node node
)
1416 return (DECL_EXTERNAL (node
->symbol
.decl
)
1417 || (DECL_ONE_ONLY (node
->symbol
.decl
)
1418 && node
->symbol
.resolution
!= LDPR_PREVAILING_DEF
1419 && node
->symbol
.resolution
!= LDPR_PREVAILING_DEF_IRONLY
1420 && node
->symbol
.resolution
!= LDPR_PREVAILING_DEF_IRONLY_EXP
));
1422 #endif /* GCC_CGRAPH_H */