- Remove SVN merge marker.
[official-gcc.git] / gcc / cgraph.h
blob9103a2547c4bd8a0ac537844c3c93e271673eed3
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
10 version.
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
15 for more details.
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/>. */
21 #ifndef GCC_CGRAPH_H
22 #define GCC_CGRAPH_H
24 #include "is-a.h"
25 #include "plugin-api.h"
26 #include "vec.h"
27 #include "tree.h"
28 #include "basic-block.h"
29 #include "function.h"
30 #include "ipa-ref.h"
32 /* Symbol table consists of functions and variables.
33 TODO: add labels, constant pool and aliases. */
34 enum symtab_type
36 SYMTAB_SYMBOL,
37 SYMTAB_FUNCTION,
38 SYMTAB_VARIABLE
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;
65 /* True when the name is known to be unique and thus it does not need mangling. */
66 unsigned unique_name : 1;
68 /* Ordering of all symtab entries. */
69 int order;
71 tree decl;
73 /* Vectors of referring and referenced entities. */
74 struct ipa_ref_list ref_list;
76 /* Circular list of nodes in the same comdat group if non-NULL. */
77 symtab_node same_comdat_group;
79 /* File stream where this node is being written to. */
80 struct lto_file_decl_data * lto_file_data;
82 /* Linked list of symbol table entries starting with symtab_nodes. */
83 symtab_node next;
84 symtab_node previous;
85 /* Linked list of symbols with the same asm name. There may be multiple
86 entries for single symbol name in the case of LTO resolutions,
87 existence of inline clones, or duplicated declaration. The last case
88 is a long standing bug frontends and builtin handling. */
89 symtab_node next_sharing_asm_name;
90 symtab_node previous_sharing_asm_name;
92 PTR GTY ((skip)) aux;
95 enum availability
97 /* Not yet set by cgraph_function_body_availability. */
98 AVAIL_UNSET,
99 /* Function body/variable initializer is unknown. */
100 AVAIL_NOT_AVAILABLE,
101 /* Function body/variable initializer is known but might be replaced
102 by a different one from other compilation unit and thus needs to
103 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
104 arbitrary side effects on escaping variables and functions, while
105 like AVAILABLE it might access static variables. */
106 AVAIL_OVERWRITABLE,
107 /* Function body/variable initializer is known and will be used in final
108 program. */
109 AVAIL_AVAILABLE,
110 /* Function body/variable initializer is known and all it's uses are explicitly
111 visible within current unit (ie it's address is never taken and it is not
112 exported to other units).
113 Currently used only for functions. */
114 AVAIL_LOCAL
117 /* This is the information that is put into the cgraph local structure
118 to recover a function. */
119 struct lto_file_decl_data;
121 extern const char * const cgraph_availability_names[];
122 extern const char * const ld_plugin_symbol_resolution_names[];
124 /* Information about thunk, used only for same body aliases. */
126 struct GTY(()) cgraph_thunk_info {
127 /* Information about the thunk. */
128 HOST_WIDE_INT fixed_offset;
129 HOST_WIDE_INT virtual_value;
130 tree alias;
131 bool this_adjusting;
132 bool virtual_offset_p;
133 /* Set to true when alias node is thunk. */
134 bool thunk_p;
137 /* Information about the function collected locally.
138 Available after function is analyzed. */
140 struct GTY(()) cgraph_local_info {
141 /* Set when function function is visible in current compilation unit only
142 and its address is never taken. */
143 unsigned local : 1;
145 /* Set once it has been finalized so we consider it to be output. */
146 unsigned finalized : 1;
148 /* False when there is something makes versioning impossible. */
149 unsigned versionable : 1;
151 /* False when function calling convention and signature can not be changed.
152 This is the case when __builtin_apply_args is used. */
153 unsigned can_change_signature : 1;
155 /* True when the function has been originally extern inline, but it is
156 redefined now. */
157 unsigned redefined_extern_inline : 1;
159 /* True if the function may enter serial irrevocable mode. */
160 unsigned tm_may_enter_irr : 1;
163 /* Information about the function that needs to be computed globally
164 once compilation is finished. Available only with -funit-at-a-time. */
166 struct GTY(()) cgraph_global_info {
167 /* For inline clones this points to the function they will be
168 inlined into. */
169 struct cgraph_node *inlined_to;
172 /* Information about the function that is propagated by the RTL backend.
173 Available only for functions that has been already assembled. */
175 struct GTY(()) cgraph_rtl_info {
176 unsigned int preferred_incoming_stack_boundary;
179 /* Represent which DECL tree (or reference to such tree)
180 will be replaced by another tree while versioning. */
181 struct GTY(()) ipa_replace_map
183 /* The tree that will be replaced. */
184 tree old_tree;
185 /* The new (replacing) tree. */
186 tree new_tree;
187 /* Parameter number to replace, when old_tree is NULL. */
188 int parm_num;
189 /* True when a substitution should be done, false otherwise. */
190 bool replace_p;
191 /* True when we replace a reference to old_tree. */
192 bool ref_p;
194 typedef struct ipa_replace_map *ipa_replace_map_p;
196 struct GTY(()) cgraph_clone_info
198 vec<ipa_replace_map_p, va_gc> *tree_map;
199 bitmap args_to_skip;
200 bitmap combined_args_to_skip;
204 /* The cgraph data structure.
205 Each function decl has assigned cgraph_node listing callees and callers. */
207 struct GTY(()) cgraph_node {
208 struct symtab_node_base symbol;
209 struct cgraph_edge *callees;
210 struct cgraph_edge *callers;
211 /* List of edges representing indirect calls with a yet undetermined
212 callee. */
213 struct cgraph_edge *indirect_calls;
214 /* For nested functions points to function the node is nested in. */
215 struct cgraph_node *
216 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
217 origin;
218 /* Points to first nested function, if any. */
219 struct cgraph_node *
220 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
221 nested;
222 /* Pointer to the next function with same origin, if any. */
223 struct cgraph_node *
224 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
225 next_nested;
226 /* Pointer to the next clone. */
227 struct cgraph_node *next_sibling_clone;
228 struct cgraph_node *prev_sibling_clone;
229 struct cgraph_node *clones;
230 struct cgraph_node *clone_of;
231 /* For functions with many calls sites it holds map from call expression
232 to the edge to speed up cgraph_edge function. */
233 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
234 /* Declaration node used to be clone of. */
235 tree former_clone_of;
237 /* Interprocedural passes scheduled to have their transform functions
238 applied next time we execute local pass on them. We maintain it
239 per-function in order to allow IPA passes to introduce new functions. */
240 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
242 struct cgraph_local_info local;
243 struct cgraph_global_info global;
244 struct cgraph_rtl_info rtl;
245 struct cgraph_clone_info clone;
246 struct cgraph_thunk_info thunk;
248 /* Expected number of executions: calculated in profile.c. */
249 gcov_type count;
250 /* How to scale counts at materialization time; used to merge
251 LTO units with different number of profile runs. */
252 int count_materialization_scale;
253 /* Unique id of the node. */
254 int uid;
256 /* Set when decl is an abstract function pointed to by the
257 ABSTRACT_DECL_ORIGIN of a reachable function. */
258 unsigned abstract_and_needed : 1;
259 /* Set once the function is lowered (i.e. its CFG is built). */
260 unsigned lowered : 1;
261 /* Set once the function has been instantiated and its callee
262 lists created. */
263 unsigned analyzed : 1;
264 /* Set when function is scheduled to be processed by local passes. */
265 unsigned process : 1;
266 /* Set for aliases once they got through assemble_alias. */
267 unsigned alias : 1;
268 /* Set for aliases created as C++ same body aliases. */
269 unsigned same_body_alias : 1;
270 /* How commonly executed the node is. Initialized during branch
271 probabilities pass. */
272 ENUM_BITFIELD (node_frequency) frequency : 2;
273 /* True when function can only be called at startup (from static ctor). */
274 unsigned only_called_at_startup : 1;
275 /* True when function can only be called at startup (from static dtor). */
276 unsigned only_called_at_exit : 1;
277 /* True when function is the transactional clone of a function which
278 is called only from inside transactions. */
279 /* ?? We should be able to remove this. We have enough bits in
280 cgraph to calculate it. */
281 unsigned tm_clone : 1;
282 /* True if this decl is a dispatcher for function versions. */
283 unsigned dispatcher_function : 1;
287 typedef struct cgraph_node *cgraph_node_ptr;
290 /* Function Multiversioning info. */
291 struct GTY(()) cgraph_function_version_info {
292 /* The cgraph_node for which the function version info is stored. */
293 struct cgraph_node *this_node;
294 /* Chains all the semantically identical function versions. The
295 first function in this chain is the version_info node of the
296 default function. */
297 struct cgraph_function_version_info *prev;
298 /* If this version node corresponds to a dispatcher for function
299 versions, this points to the version info node of the default
300 function, the first node in the chain. */
301 struct cgraph_function_version_info *next;
302 /* If this node corresponds to a function version, this points
303 to the dispatcher function decl, which is the function that must
304 be called to execute the right function version at run-time.
306 If this cgraph node is a dispatcher (if dispatcher_function is
307 true, in the cgraph_node struct) for function versions, this
308 points to resolver function, which holds the function body of the
309 dispatcher. The dispatcher decl is an alias to the resolver
310 function decl. */
311 tree dispatcher_resolver;
314 /* Get the cgraph_function_version_info node corresponding to node. */
315 struct cgraph_function_version_info *
316 get_cgraph_node_version (struct cgraph_node *node);
318 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
319 corresponding to cgraph_node NODE. */
320 struct cgraph_function_version_info *
321 insert_new_cgraph_node_version (struct cgraph_node *node);
323 /* Record that DECL1 and DECL2 are semantically identical function
324 versions. */
325 void record_function_versions (tree decl1, tree decl2);
327 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
328 DECL is a duplicate declaration. */
329 void delete_function_version (tree decl);
331 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
332 can appear in multiple sets. */
333 struct cgraph_node_set_def
335 struct pointer_map_t *map;
336 vec<cgraph_node_ptr> nodes;
339 typedef struct varpool_node *varpool_node_ptr;
342 /* A varpool node set is a collection of varpool nodes. A varpool node
343 can appear in multiple sets. */
344 struct varpool_node_set_def
346 struct pointer_map_t * map;
347 vec<varpool_node_ptr> nodes;
350 typedef struct cgraph_node_set_def *cgraph_node_set;
353 typedef struct varpool_node_set_def *varpool_node_set;
356 /* Iterator structure for cgraph node sets. */
357 typedef struct
359 cgraph_node_set set;
360 unsigned index;
361 } cgraph_node_set_iterator;
363 /* Iterator structure for varpool node sets. */
364 typedef struct
366 varpool_node_set set;
367 unsigned index;
368 } varpool_node_set_iterator;
370 #define DEFCIFCODE(code, string) CIF_ ## code,
371 /* Reasons for inlining failures. */
372 typedef enum cgraph_inline_failed_enum {
373 #include "cif-code.def"
374 CIF_N_REASONS
375 } cgraph_inline_failed_t;
377 /* Structure containing additional information about an indirect call. */
379 struct GTY(()) cgraph_indirect_call_info
381 /* When polymorphic is set, this field contains offset where the object which
382 was actually used in the polymorphic resides within a larger structure.
383 If agg_contents is set, the field contains the offset within the aggregate
384 from which the address to call was loaded. */
385 HOST_WIDE_INT offset;
386 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
387 HOST_WIDE_INT otr_token;
388 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
389 tree otr_type;
390 /* Index of the parameter that is called. */
391 int param_index;
392 /* ECF flags determined from the caller. */
393 int ecf_flags;
395 /* Set when the call is a virtual call with the parameter being the
396 associated object pointer rather than a simple direct call. */
397 unsigned polymorphic : 1;
398 /* Set when the call is a call of a pointer loaded from contents of an
399 aggregate at offset. */
400 unsigned agg_contents : 1;
401 /* When the previous bit is set, this one determines whether the destination
402 is loaded from a parameter passed by reference. */
403 unsigned by_ref : 1;
406 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
407 /* Expected number of executions: calculated in profile.c. */
408 gcov_type count;
409 struct cgraph_node *caller;
410 struct cgraph_node *callee;
411 struct cgraph_edge *prev_caller;
412 struct cgraph_edge *next_caller;
413 struct cgraph_edge *prev_callee;
414 struct cgraph_edge *next_callee;
415 gimple call_stmt;
416 /* Additional information about an indirect call. Not cleared when an edge
417 becomes direct. */
418 struct cgraph_indirect_call_info *indirect_info;
419 PTR GTY ((skip (""))) aux;
420 /* When equal to CIF_OK, inline this call. Otherwise, points to the
421 explanation why function was not inlined. */
422 cgraph_inline_failed_t inline_failed;
423 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
424 when the function is serialized in. */
425 unsigned int lto_stmt_uid;
426 /* Expected frequency of executions within the function.
427 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
428 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
429 int frequency;
430 /* Unique id of the edge. */
431 int uid;
432 /* Whether this edge was made direct by indirect inlining. */
433 unsigned int indirect_inlining_edge : 1;
434 /* Whether this edge describes an indirect call with an undetermined
435 callee. */
436 unsigned int indirect_unknown_callee : 1;
437 /* Whether this edge is still a dangling */
438 /* True if the corresponding CALL stmt cannot be inlined. */
439 unsigned int call_stmt_cannot_inline_p : 1;
440 /* Can this call throw externally? */
441 unsigned int can_throw_external : 1;
444 #define CGRAPH_FREQ_BASE 1000
445 #define CGRAPH_FREQ_MAX 100000
447 typedef struct cgraph_edge *cgraph_edge_p;
450 /* The varpool data structure.
451 Each static variable decl has assigned varpool_node. */
453 struct GTY(()) varpool_node {
454 struct symtab_node_base symbol;
455 /* For aliases points to declaration DECL is alias of. */
456 tree alias_of;
458 /* Set once the variable has been instantiated and its callee
459 lists created. */
460 unsigned analyzed : 1;
461 /* Set once it has been finalized so we consider it to be output. */
462 unsigned finalized : 1;
463 /* Set when variable is scheduled to be assembled. */
464 unsigned output : 1;
465 /* Set for aliases once they got through assemble_alias. Also set for
466 extra name aliases in varpool_extra_name_alias. */
467 unsigned alias : 1;
468 unsigned extra_name_alias : 1;
471 /* Every top level asm statement is put into a asm_node. */
473 struct GTY(()) asm_node {
474 /* Next asm node. */
475 struct asm_node *next;
476 /* String for this asm node. */
477 tree asm_str;
478 /* Ordering of all cgraph nodes. */
479 int order;
482 /* Symbol table entry. */
483 union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
484 chain_prev ("%h.symbol.previous"))) symtab_node_def {
485 struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
486 /* To access the following fields,
487 use the use dyn_cast or as_a to obtain the concrete type. */
488 struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
489 struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
492 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
494 template <>
495 template <>
496 inline bool
497 is_a_helper <cgraph_node>::test (symtab_node_def *p)
499 return p->symbol.type == SYMTAB_FUNCTION;
502 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
504 template <>
505 template <>
506 inline bool
507 is_a_helper <varpool_node>::test (symtab_node_def *p)
509 return p->symbol.type == SYMTAB_VARIABLE;
512 extern GTY(()) symtab_node symtab_nodes;
513 extern GTY(()) int cgraph_n_nodes;
514 extern GTY(()) int cgraph_max_uid;
515 extern GTY(()) int cgraph_edge_max_uid;
516 extern bool cgraph_global_info_ready;
517 enum cgraph_state
519 /* Frontend is parsing and finalizing functions. */
520 CGRAPH_STATE_PARSING,
521 /* Callgraph is being constructed. It is safe to add new functions. */
522 CGRAPH_STATE_CONSTRUCTION,
523 /* Callgraph is built and IPA passes are being run. */
524 CGRAPH_STATE_IPA,
525 /* Callgraph is built and all functions are transformed to SSA form. */
526 CGRAPH_STATE_IPA_SSA,
527 /* Functions are now ordered and being passed to RTL expanders. */
528 CGRAPH_STATE_EXPANSION,
529 /* All cgraph expansion is done. */
530 CGRAPH_STATE_FINISHED
532 extern enum cgraph_state cgraph_state;
533 extern bool cgraph_function_flags_ready;
534 extern cgraph_node_set cgraph_new_nodes;
536 extern GTY(()) struct asm_node *asm_nodes;
537 extern GTY(()) int symtab_order;
538 extern bool same_body_aliases_done;
540 /* In symtab.c */
541 void symtab_register_node (symtab_node);
542 void symtab_unregister_node (symtab_node);
543 void symtab_remove_node (symtab_node);
544 symtab_node symtab_get_node (const_tree);
545 symtab_node symtab_node_for_asm (const_tree asmname);
546 const char * symtab_node_asm_name (symtab_node);
547 const char * symtab_node_name (symtab_node);
548 void symtab_insert_node_to_hashtable (symtab_node);
549 void symtab_add_to_same_comdat_group (symtab_node, symtab_node);
550 void symtab_dissolve_same_comdat_group_list (symtab_node node);
551 void dump_symtab (FILE *);
552 void debug_symtab (void);
553 void dump_symtab_node (FILE *, symtab_node);
554 void debug_symtab_node (symtab_node);
555 void dump_symtab_base (FILE *, symtab_node);
556 void verify_symtab (void);
557 void verify_symtab_node (symtab_node);
558 bool verify_symtab_base (symtab_node);
559 bool symtab_used_from_object_file_p (symtab_node);
560 void symtab_make_decl_local (tree);
562 /* In cgraph.c */
563 void dump_cgraph (FILE *);
564 void debug_cgraph (void);
565 void dump_cgraph_node (FILE *, struct cgraph_node *);
566 void debug_cgraph_node (struct cgraph_node *);
567 void cgraph_remove_edge (struct cgraph_edge *);
568 void cgraph_remove_node (struct cgraph_node *);
569 void cgraph_release_function_body (struct cgraph_node *);
570 void cgraph_node_remove_callees (struct cgraph_node *node);
571 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
572 struct cgraph_node *,
573 gimple, gcov_type, int);
574 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
575 int, gcov_type, int);
576 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
577 struct cgraph_node * cgraph_create_node (tree);
578 struct cgraph_node * cgraph_create_empty_node (void);
579 struct cgraph_node * cgraph_get_create_node (tree);
580 struct cgraph_node * cgraph_get_create_real_symbol_node (tree);
581 struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
582 struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
583 HOST_WIDE_INT, tree, tree);
584 struct cgraph_node *cgraph_node_for_asm (tree);
585 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
586 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
587 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
588 struct cgraph_local_info *cgraph_local_info (tree);
589 struct cgraph_global_info *cgraph_global_info (tree);
590 struct cgraph_rtl_info *cgraph_rtl_info (tree);
591 struct cgraph_node *cgraph_create_function_alias (tree, tree);
592 void cgraph_call_node_duplication_hooks (struct cgraph_node *,
593 struct cgraph_node *);
594 void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
595 struct cgraph_edge *);
597 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
598 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
599 bool cgraph_only_called_directly_p (struct cgraph_node *);
601 bool cgraph_function_possibly_inlined_p (tree);
602 void cgraph_unnest_node (struct cgraph_node *);
604 enum availability cgraph_function_body_availability (struct cgraph_node *);
605 void cgraph_add_new_function (tree, bool);
606 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
608 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
609 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
610 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
611 bool cgraph_node_cannot_return (struct cgraph_node *);
612 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
613 bool cgraph_will_be_removed_from_program_if_no_direct_calls
614 (struct cgraph_node *node);
615 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
616 (struct cgraph_node *node);
617 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
618 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
619 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
620 bool (*) (struct cgraph_node *, void *),
621 void *,
622 bool);
623 bool cgraph_for_node_and_aliases (struct cgraph_node *,
624 bool (*) (struct cgraph_node *, void *),
625 void *, bool);
626 vec<cgraph_edge_p> collect_callers_of_node (struct cgraph_node *node);
627 void verify_cgraph (void);
628 void verify_cgraph_node (struct cgraph_node *);
629 void cgraph_mark_address_taken_node (struct cgraph_node *);
631 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
632 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
633 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
634 void *);
635 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
636 void *);
637 struct cgraph_edge_hook_list;
638 struct cgraph_node_hook_list;
639 struct cgraph_2edge_hook_list;
640 struct cgraph_2node_hook_list;
641 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
642 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
643 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
644 void *);
645 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
646 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
647 void *);
648 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
649 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
650 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
651 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
652 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
653 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
654 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
655 bool cgraph_propagate_frequency (struct cgraph_node *node);
657 /* In cgraphunit.c */
658 struct asm_node *add_asm_node (tree);
659 extern FILE *cgraph_dump_file;
660 void cgraph_finalize_function (tree, bool);
661 void finalize_compilation_unit (void);
662 void compile (void);
663 void init_cgraph (void);
664 bool cgraph_process_new_functions (void);
665 void cgraph_process_same_body_aliases (void);
666 void fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target, tree alias);
667 /* Initialize datastructures so DECL is a function in lowered gimple form.
668 IN_SSA is true if the gimple is in SSA. */
669 basic_block init_lowered_empty_function (tree decl, bool in_ssa);
671 /* In cgraphclones.c */
673 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
674 struct cgraph_node *, gimple,
675 unsigned, gcov_type, int, bool);
676 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
677 int, bool, vec<cgraph_edge_p>,
678 bool);
679 tree clone_function_name (tree decl, const char *);
680 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
681 vec<cgraph_edge_p>,
682 vec<ipa_replace_map_p, va_gc> *tree_map,
683 bitmap args_to_skip,
684 const char *clone_name);
685 struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
686 bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
687 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
688 void cgraph_create_edge_including_clones (struct cgraph_node *,
689 struct cgraph_node *,
690 gimple, gimple, gcov_type, int,
691 cgraph_inline_failed_t);
692 void cgraph_materialize_all_clones (void);
693 struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
694 tree, vec<cgraph_edge_p>, bitmap);
695 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
696 vec<cgraph_edge_p>,
697 vec<ipa_replace_map_p, va_gc> *,
698 bitmap, bool, bitmap,
699 basic_block, const char *);
700 void tree_function_versioning (tree, tree, vec<ipa_replace_map_p, va_gc> *,
701 bool, bitmap, bool, bitmap, basic_block);
703 /* In cgraphbuild.c */
704 unsigned int rebuild_cgraph_edges (void);
705 void cgraph_rebuild_references (void);
706 int compute_call_stmt_bb_frequency (tree, basic_block bb);
707 void record_references_in_initializer (tree, bool);
709 /* In ipa.c */
710 bool symtab_remove_unreachable_nodes (bool, FILE *);
711 cgraph_node_set cgraph_node_set_new (void);
712 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
713 struct cgraph_node *);
714 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
715 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
716 void dump_cgraph_node_set (FILE *, cgraph_node_set);
717 void debug_cgraph_node_set (cgraph_node_set);
718 void free_cgraph_node_set (cgraph_node_set);
719 void cgraph_build_static_cdtor (char which, tree body, int priority);
721 varpool_node_set varpool_node_set_new (void);
722 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
723 struct varpool_node *);
724 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
725 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
726 void dump_varpool_node_set (FILE *, varpool_node_set);
727 void debug_varpool_node_set (varpool_node_set);
728 void free_varpool_node_set (varpool_node_set);
729 void ipa_discover_readonly_nonaddressable_vars (void);
730 bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *);
731 bool varpool_externally_visible_p (struct varpool_node *);
733 /* In predict.c */
734 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
735 bool cgraph_optimize_for_size_p (struct cgraph_node *);
737 /* In varpool.c */
738 struct varpool_node *varpool_node_for_decl (tree);
739 struct varpool_node *varpool_node_for_asm (tree asmname);
740 void varpool_mark_needed_node (struct varpool_node *);
741 void debug_varpool (void);
742 void dump_varpool (FILE *);
743 void dump_varpool_node (FILE *, struct varpool_node *);
745 void varpool_finalize_decl (tree);
746 bool decide_is_variable_needed (struct varpool_node *, tree);
747 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
748 void cgraph_make_node_local (struct cgraph_node *);
749 bool cgraph_node_can_be_local_p (struct cgraph_node *);
752 void varpool_remove_node (struct varpool_node *node);
753 void varpool_finalize_named_section_flags (struct varpool_node *node);
754 bool varpool_output_variables (void);
755 bool varpool_assemble_decl (struct varpool_node *node);
756 void varpool_analyze_node (struct varpool_node *);
757 struct varpool_node * varpool_extra_name_alias (tree, tree);
758 struct varpool_node * varpool_create_variable_alias (tree, tree);
759 void varpool_reset_queue (void);
760 bool const_value_known_p (tree);
761 bool varpool_for_node_and_aliases (struct varpool_node *,
762 bool (*) (struct varpool_node *, void *),
763 void *, bool);
764 void varpool_add_new_variable (tree);
765 void symtab_initialize_asm_name_hash (void);
766 void symtab_prevail_in_asm_name_hash (symtab_node node);
769 /* Return callgraph node for given symbol and check it is a function. */
770 static inline struct cgraph_node *
771 cgraph (symtab_node node)
773 gcc_checking_assert (!node || node->symbol.type == SYMTAB_FUNCTION);
774 return (struct cgraph_node *)node;
777 /* Return varpool node for given symbol and check it is a variable. */
778 static inline struct varpool_node *
779 varpool (symtab_node node)
781 gcc_checking_assert (!node || node->symbol.type == SYMTAB_VARIABLE);
782 return (struct varpool_node *)node;
785 /* Return callgraph node for given symbol and check it is a function. */
786 static inline struct cgraph_node *
787 cgraph_get_node (const_tree decl)
789 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
790 return cgraph (symtab_get_node (decl));
793 /* Return varpool node for given symbol and check it is a function. */
794 static inline struct varpool_node *
795 varpool_get_node (const_tree decl)
797 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
798 return varpool (symtab_get_node (decl));
801 /* Return asm name of cgraph node. */
802 static inline const char *
803 cgraph_node_asm_name(struct cgraph_node *node)
805 return symtab_node_asm_name ((symtab_node)node);
808 /* Return asm name of varpool node. */
809 static inline const char *
810 varpool_node_asm_name(struct varpool_node *node)
812 return symtab_node_asm_name ((symtab_node)node);
815 /* Return name of cgraph node. */
816 static inline const char *
817 cgraph_node_name(struct cgraph_node *node)
819 return symtab_node_name ((symtab_node)node);
822 /* Return name of varpool node. */
823 static inline const char *
824 varpool_node_name(struct varpool_node *node)
826 return symtab_node_name ((symtab_node)node);
829 /* Walk all symbols. */
830 #define FOR_EACH_SYMBOL(node) \
831 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
834 /* Return first variable. */
835 static inline struct varpool_node *
836 varpool_first_variable (void)
838 symtab_node node;
839 for (node = symtab_nodes; node; node = node->symbol.next)
840 if (varpool_node *vnode = dyn_cast <varpool_node> (node))
841 return vnode;
842 return NULL;
845 /* Return next variable after NODE. */
846 static inline struct varpool_node *
847 varpool_next_variable (struct varpool_node *node)
849 symtab_node node1 = (symtab_node) node->symbol.next;
850 for (; node1; node1 = node1->symbol.next)
851 if (varpool_node *vnode1 = dyn_cast <varpool_node> (node1))
852 return vnode1;
853 return NULL;
855 /* Walk all variables. */
856 #define FOR_EACH_VARIABLE(node) \
857 for ((node) = varpool_first_variable (); \
858 (node); \
859 (node) = varpool_next_variable ((node)))
861 /* Return first reachable static variable with initializer. */
862 static inline struct varpool_node *
863 varpool_first_static_initializer (void)
865 symtab_node node;
866 for (node = symtab_nodes; node; node = node->symbol.next)
868 varpool_node *vnode = dyn_cast <varpool_node> (node);
869 if (vnode && DECL_INITIAL (node->symbol.decl))
870 return vnode;
872 return NULL;
875 /* Return next reachable static variable with initializer after NODE. */
876 static inline struct varpool_node *
877 varpool_next_static_initializer (struct varpool_node *node)
879 symtab_node node1 = (symtab_node) node->symbol.next;
880 for (; node1; node1 = node1->symbol.next)
882 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
883 if (vnode1 && DECL_INITIAL (node1->symbol.decl))
884 return vnode1;
886 return NULL;
889 /* Walk all static variables with initializer set. */
890 #define FOR_EACH_STATIC_INITIALIZER(node) \
891 for ((node) = varpool_first_static_initializer (); (node); \
892 (node) = varpool_next_static_initializer (node))
894 /* Return first reachable static variable with initializer. */
895 static inline struct varpool_node *
896 varpool_first_defined_variable (void)
898 symtab_node node;
899 for (node = symtab_nodes; node; node = node->symbol.next)
901 varpool_node *vnode = dyn_cast <varpool_node> (node);
902 if (vnode && vnode->analyzed)
903 return vnode;
905 return NULL;
908 /* Return next reachable static variable with initializer after NODE. */
909 static inline struct varpool_node *
910 varpool_next_defined_variable (struct varpool_node *node)
912 symtab_node node1 = (symtab_node) node->symbol.next;
913 for (; node1; node1 = node1->symbol.next)
915 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
916 if (vnode1 && vnode1->analyzed)
917 return vnode1;
919 return NULL;
921 /* Walk all variables with definitions in current unit. */
922 #define FOR_EACH_DEFINED_VARIABLE(node) \
923 for ((node) = varpool_first_defined_variable (); (node); \
924 (node) = varpool_next_defined_variable (node))
926 /* Return first function with body defined. */
927 static inline struct cgraph_node *
928 cgraph_first_defined_function (void)
930 symtab_node node;
931 for (node = symtab_nodes; node; node = node->symbol.next)
933 cgraph_node *cn = dyn_cast <cgraph_node> (node);
934 if (cn && cn->analyzed)
935 return cn;
937 return NULL;
940 /* Return next function with body defined after NODE. */
941 static inline struct cgraph_node *
942 cgraph_next_defined_function (struct cgraph_node *node)
944 symtab_node node1 = (symtab_node) node->symbol.next;
945 for (; node1; node1 = node1->symbol.next)
947 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
948 if (cn1 && cn1->analyzed)
949 return cn1;
951 return NULL;
954 /* Walk all functions with body defined. */
955 #define FOR_EACH_DEFINED_FUNCTION(node) \
956 for ((node) = cgraph_first_defined_function (); (node); \
957 (node) = cgraph_next_defined_function ((node)))
959 /* Return first function. */
960 static inline struct cgraph_node *
961 cgraph_first_function (void)
963 symtab_node node;
964 for (node = symtab_nodes; node; node = node->symbol.next)
965 if (cgraph_node *cn = dyn_cast <cgraph_node> (node))
966 return cn;
967 return NULL;
970 /* Return next function. */
971 static inline struct cgraph_node *
972 cgraph_next_function (struct cgraph_node *node)
974 symtab_node node1 = (symtab_node) node->symbol.next;
975 for (; node1; node1 = node1->symbol.next)
976 if (cgraph_node *cn1 = dyn_cast <cgraph_node> (node1))
977 return cn1;
978 return NULL;
980 /* Walk all functions. */
981 #define FOR_EACH_FUNCTION(node) \
982 for ((node) = cgraph_first_function (); (node); \
983 (node) = cgraph_next_function ((node)))
985 /* Return true when NODE is a function with Gimple body defined
986 in current unit. Functions can also be define externally or they
987 can be thunks with no Gimple representation.
989 Note that at WPA stage, the function body may not be present in memory. */
991 static inline bool
992 cgraph_function_with_gimple_body_p (struct cgraph_node *node)
994 return node->analyzed && !node->thunk.thunk_p && !node->alias;
997 /* Return first function with body defined. */
998 static inline struct cgraph_node *
999 cgraph_first_function_with_gimple_body (void)
1001 symtab_node node;
1002 for (node = symtab_nodes; node; node = node->symbol.next)
1004 cgraph_node *cn = dyn_cast <cgraph_node> (node);
1005 if (cn && cgraph_function_with_gimple_body_p (cn))
1006 return cn;
1008 return NULL;
1011 /* Return next reachable static variable with initializer after NODE. */
1012 static inline struct cgraph_node *
1013 cgraph_next_function_with_gimple_body (struct cgraph_node *node)
1015 symtab_node node1 = node->symbol.next;
1016 for (; node1; node1 = node1->symbol.next)
1018 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
1019 if (cn1 && cgraph_function_with_gimple_body_p (cn1))
1020 return cn1;
1022 return NULL;
1025 /* Walk all functions with body defined. */
1026 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1027 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1028 (node) = cgraph_next_function_with_gimple_body (node))
1030 /* Create a new static variable of type TYPE. */
1031 tree add_new_static_var (tree type);
1033 /* Return true if iterator CSI points to nothing. */
1034 static inline bool
1035 csi_end_p (cgraph_node_set_iterator csi)
1037 return csi.index >= csi.set->nodes.length ();
1040 /* Advance iterator CSI. */
1041 static inline void
1042 csi_next (cgraph_node_set_iterator *csi)
1044 csi->index++;
1047 /* Return the node pointed to by CSI. */
1048 static inline struct cgraph_node *
1049 csi_node (cgraph_node_set_iterator csi)
1051 return csi.set->nodes[csi.index];
1054 /* Return an iterator to the first node in SET. */
1055 static inline cgraph_node_set_iterator
1056 csi_start (cgraph_node_set set)
1058 cgraph_node_set_iterator csi;
1060 csi.set = set;
1061 csi.index = 0;
1062 return csi;
1065 /* Return true if SET contains NODE. */
1066 static inline bool
1067 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1069 cgraph_node_set_iterator csi;
1070 csi = cgraph_node_set_find (set, node);
1071 return !csi_end_p (csi);
1074 /* Return number of nodes in SET. */
1075 static inline size_t
1076 cgraph_node_set_size (cgraph_node_set set)
1078 return set->nodes.length ();
1081 /* Return true if iterator VSI points to nothing. */
1082 static inline bool
1083 vsi_end_p (varpool_node_set_iterator vsi)
1085 return vsi.index >= vsi.set->nodes.length ();
1088 /* Advance iterator VSI. */
1089 static inline void
1090 vsi_next (varpool_node_set_iterator *vsi)
1092 vsi->index++;
1095 /* Return the node pointed to by VSI. */
1096 static inline struct varpool_node *
1097 vsi_node (varpool_node_set_iterator vsi)
1099 return vsi.set->nodes[vsi.index];
1102 /* Return an iterator to the first node in SET. */
1103 static inline varpool_node_set_iterator
1104 vsi_start (varpool_node_set set)
1106 varpool_node_set_iterator vsi;
1108 vsi.set = set;
1109 vsi.index = 0;
1110 return vsi;
1113 /* Return true if SET contains NODE. */
1114 static inline bool
1115 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
1117 varpool_node_set_iterator vsi;
1118 vsi = varpool_node_set_find (set, node);
1119 return !vsi_end_p (vsi);
1122 /* Return number of nodes in SET. */
1123 static inline size_t
1124 varpool_node_set_size (varpool_node_set set)
1126 return set->nodes.length ();
1129 /* Uniquize all constants that appear in memory.
1130 Each constant in memory thus far output is recorded
1131 in `const_desc_table'. */
1133 struct GTY(()) constant_descriptor_tree {
1134 /* A MEM for the constant. */
1135 rtx rtl;
1137 /* The value of the constant. */
1138 tree value;
1140 /* Hash of value. Computing the hash from value each time
1141 hashfn is called can't work properly, as that means recursive
1142 use of the hash table during hash table expansion. */
1143 hashval_t hash;
1146 /* Return true if set is nonempty. */
1147 static inline bool
1148 cgraph_node_set_nonempty_p (cgraph_node_set set)
1150 return !set->nodes.is_empty ();
1153 /* Return true if set is nonempty. */
1154 static inline bool
1155 varpool_node_set_nonempty_p (varpool_node_set set)
1157 return !set->nodes.is_empty ();
1160 /* Return true when function NODE is only called directly or it has alias.
1161 i.e. it is not externally visible, address was not taken and
1162 it is not used in any other non-standard way. */
1164 static inline bool
1165 cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
1167 gcc_assert (!node->global.inlined_to);
1168 return (!node->symbol.force_output && !node->symbol.address_taken
1169 && !node->symbol.used_from_other_partition
1170 && !DECL_VIRTUAL_P (node->symbol.decl)
1171 && !DECL_STATIC_CONSTRUCTOR (node->symbol.decl)
1172 && !DECL_STATIC_DESTRUCTOR (node->symbol.decl)
1173 && !node->symbol.externally_visible);
1176 /* Return true when function NODE can be removed from callgraph
1177 if all direct calls are eliminated. */
1179 static inline bool
1180 varpool_can_remove_if_no_refs (struct varpool_node *node)
1182 if (DECL_EXTERNAL (node->symbol.decl))
1183 return true;
1184 return (!node->symbol.force_output && !node->symbol.used_from_other_partition
1185 && ((DECL_COMDAT (node->symbol.decl)
1186 && !symtab_used_from_object_file_p ((symtab_node) node))
1187 || !node->symbol.externally_visible
1188 || DECL_HAS_VALUE_EXPR_P (node->symbol.decl)));
1191 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1192 i.e. if the variable is not externally visible or not used in some magic
1193 way (asm statement or such).
1194 The magic uses are all summarized in force_output flag. */
1196 static inline bool
1197 varpool_all_refs_explicit_p (struct varpool_node *vnode)
1199 return (vnode->analyzed
1200 && !vnode->symbol.externally_visible
1201 && !vnode->symbol.used_from_other_partition
1202 && !vnode->symbol.force_output);
1205 /* Constant pool accessor function. */
1206 htab_t constant_pool_htab (void);
1208 /* FIXME: inappropriate dependency of cgraph on IPA. */
1209 #include "ipa-ref-inline.h"
1211 /* Return node that alias N is aliasing. */
1213 static inline struct cgraph_node *
1214 cgraph_alias_aliased_node (struct cgraph_node *n)
1216 struct ipa_ref *ref;
1218 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
1219 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1220 if (is_a <cgraph_node> (ref->referred))
1221 return ipa_ref_node (ref);
1222 return NULL;
1225 /* Return node that alias N is aliasing. */
1227 static inline struct varpool_node *
1228 varpool_alias_aliased_node (struct varpool_node *n)
1230 struct ipa_ref *ref;
1232 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
1233 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1234 if (is_a <varpool_node> (ref->referred))
1235 return ipa_ref_varpool_node (ref);
1236 return NULL;
1239 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1240 Walk through thunk, too.
1241 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1243 static inline struct cgraph_node *
1244 cgraph_function_node (struct cgraph_node *node, enum availability *availability)
1246 if (availability)
1247 *availability = cgraph_function_body_availability (node);
1248 while (node)
1250 if (node->alias && node->analyzed)
1251 node = cgraph_alias_aliased_node (node);
1252 else if (node->thunk.thunk_p)
1253 node = node->callees->callee;
1254 else
1255 return node;
1256 if (node && availability)
1258 enum availability a;
1259 a = cgraph_function_body_availability (node);
1260 if (a < *availability)
1261 *availability = a;
1264 if (availability)
1265 *availability = AVAIL_NOT_AVAILABLE;
1266 return NULL;
1269 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1270 Do not walk through thunks.
1271 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1273 static inline struct cgraph_node *
1274 cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability *availability)
1276 if (availability)
1277 *availability = cgraph_function_body_availability (node);
1278 while (node)
1280 if (node->alias && node->analyzed)
1281 node = cgraph_alias_aliased_node (node);
1282 else
1283 return node;
1284 if (node && availability)
1286 enum availability a;
1287 a = cgraph_function_body_availability (node);
1288 if (a < *availability)
1289 *availability = a;
1292 if (availability)
1293 *availability = AVAIL_NOT_AVAILABLE;
1294 return NULL;
1297 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1298 Do not walk through thunks.
1299 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1301 static inline struct varpool_node *
1302 varpool_variable_node (struct varpool_node *node, enum availability *availability)
1304 if (availability)
1305 *availability = cgraph_variable_initializer_availability (node);
1306 while (node)
1308 if (node->alias && node->analyzed)
1309 node = varpool_alias_aliased_node (node);
1310 else
1311 return node;
1312 if (node && availability)
1314 enum availability a;
1315 a = cgraph_variable_initializer_availability (node);
1316 if (a < *availability)
1317 *availability = a;
1320 if (availability)
1321 *availability = AVAIL_NOT_AVAILABLE;
1322 return NULL;
1325 /* Return true when the edge E represents a direct recursion. */
1326 static inline bool
1327 cgraph_edge_recursive_p (struct cgraph_edge *e)
1329 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
1330 if (e->caller->global.inlined_to)
1331 return e->caller->global.inlined_to->symbol.decl == callee->symbol.decl;
1332 else
1333 return e->caller->symbol.decl == callee->symbol.decl;
1336 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1337 static inline bool
1338 decl_is_tm_clone (const_tree fndecl)
1340 struct cgraph_node *n = cgraph_get_node (fndecl);
1341 if (n)
1342 return n->tm_clone;
1343 return false;
1346 /* Likewise indicate that a node is needed, i.e. reachable via some
1347 external means. */
1349 static inline void
1350 cgraph_mark_force_output_node (struct cgraph_node *node)
1352 node->symbol.force_output = 1;
1353 gcc_checking_assert (!node->global.inlined_to);
1356 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1357 or extern function kept around just for inlining. */
1359 static inline bool
1360 symtab_real_symbol_p (symtab_node node)
1362 struct cgraph_node *cnode;
1364 if (!is_a <cgraph_node> (node))
1365 return true;
1366 cnode = cgraph (node);
1367 if (cnode->global.inlined_to)
1368 return false;
1369 if (cnode->abstract_and_needed)
1370 return false;
1371 return true;
1373 #endif /* GCC_CGRAPH_H */