2013-06-18 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / cgraph.h
blob62591890182dc82df7fe10a5711fb8ab8d603048
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 and CONST_DECLs. */
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 /*** 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. */
58 unsigned alias : 1;
59 /* True when alias is a weakref. */
60 unsigned weakref : 1;
61 /* C++ frontend produce same body aliases and extra name aliases for
62 virutal 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
90 available. ***/
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. */
108 int order;
110 /* Declaration representing the symbol. */
111 tree decl;
113 /* Linked list of symbol table entries starting with symtab_nodes. */
114 symtab_node next;
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
122 duplicate entries.
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. */
138 tree alias_target;
140 /* File stream where this node is being written to. */
141 struct lto_file_decl_data * lto_file_data;
143 PTR GTY ((skip)) aux;
146 enum availability
148 /* Not yet set by cgraph_function_body_availability. */
149 AVAIL_UNSET,
150 /* Function body/variable initializer is unknown. */
151 AVAIL_NOT_AVAILABLE,
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. */
157 AVAIL_OVERWRITABLE,
158 /* Function body/variable initializer is known and will be used in final
159 program. */
160 AVAIL_AVAILABLE,
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. */
165 AVAIL_LOCAL
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;
181 tree alias;
182 bool this_adjusting;
183 bool virtual_offset_p;
184 /* Set to true when alias node is thunk. */
185 bool thunk_p;
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. */
194 unsigned local : 1;
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
204 redefined now. */
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
216 inlined into. */
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. */
232 tree old_tree;
233 /* The new (replacing) tree. */
234 tree new_tree;
235 /* Parameter number to replace, when old_tree is NULL. */
236 int parm_num;
237 /* True when a substitution should be done, false otherwise. */
238 bool replace_p;
239 /* True when we replace a reference to old_tree. */
240 bool ref_p;
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;
247 bitmap args_to_skip;
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
260 callee. */
261 struct cgraph_edge *indirect_calls;
262 /* For nested functions points to function the node is nested in. */
263 struct cgraph_node *
264 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
265 origin;
266 /* Points to first nested function, if any. */
267 struct cgraph_node *
268 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
269 nested;
270 /* Pointer to the next function with same origin, if any. */
271 struct cgraph_node *
272 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
273 next_nested;
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. */
297 gcov_type count;
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. */
302 int uid;
304 /* Set when decl is an abstract function pointed to by the
305 ABSTRACT_DECL_ORIGIN of a reachable function. */
306 unsigned abstract_and_needed : 1;
307 /* Set once the function is lowered (i.e. its CFG is built). */
308 unsigned lowered : 1;
309 /* Set once the function has been instantiated and its callee
310 lists created. */
311 unsigned process : 1;
312 /* How commonly executed the node is. Initialized during branch
313 probabilities pass. */
314 ENUM_BITFIELD (node_frequency) frequency : 2;
315 /* True when function can only be called at startup (from static ctor). */
316 unsigned only_called_at_startup : 1;
317 /* True when function can only be called at startup (from static dtor). */
318 unsigned only_called_at_exit : 1;
319 /* True when function is the transactional clone of a function which
320 is called only from inside transactions. */
321 /* ?? We should be able to remove this. We have enough bits in
322 cgraph to calculate it. */
323 unsigned tm_clone : 1;
324 /* True if this decl is a dispatcher for function versions. */
325 unsigned dispatcher_function : 1;
329 typedef struct cgraph_node *cgraph_node_ptr;
332 /* Function Multiversioning info. */
333 struct GTY(()) cgraph_function_version_info {
334 /* The cgraph_node for which the function version info is stored. */
335 struct cgraph_node *this_node;
336 /* Chains all the semantically identical function versions. The
337 first function in this chain is the version_info node of the
338 default function. */
339 struct cgraph_function_version_info *prev;
340 /* If this version node corresponds to a dispatcher for function
341 versions, this points to the version info node of the default
342 function, the first node in the chain. */
343 struct cgraph_function_version_info *next;
344 /* If this node corresponds to a function version, this points
345 to the dispatcher function decl, which is the function that must
346 be called to execute the right function version at run-time.
348 If this cgraph node is a dispatcher (if dispatcher_function is
349 true, in the cgraph_node struct) for function versions, this
350 points to resolver function, which holds the function body of the
351 dispatcher. The dispatcher decl is an alias to the resolver
352 function decl. */
353 tree dispatcher_resolver;
356 /* Get the cgraph_function_version_info node corresponding to node. */
357 struct cgraph_function_version_info *
358 get_cgraph_node_version (struct cgraph_node *node);
360 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
361 corresponding to cgraph_node NODE. */
362 struct cgraph_function_version_info *
363 insert_new_cgraph_node_version (struct cgraph_node *node);
365 /* Record that DECL1 and DECL2 are semantically identical function
366 versions. */
367 void record_function_versions (tree decl1, tree decl2);
369 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
370 DECL is a duplicate declaration. */
371 void delete_function_version (tree decl);
373 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
374 can appear in multiple sets. */
375 struct cgraph_node_set_def
377 struct pointer_map_t *map;
378 vec<cgraph_node_ptr> nodes;
381 typedef struct varpool_node *varpool_node_ptr;
384 /* A varpool node set is a collection of varpool nodes. A varpool node
385 can appear in multiple sets. */
386 struct varpool_node_set_def
388 struct pointer_map_t * map;
389 vec<varpool_node_ptr> nodes;
392 typedef struct cgraph_node_set_def *cgraph_node_set;
395 typedef struct varpool_node_set_def *varpool_node_set;
398 /* Iterator structure for cgraph node sets. */
399 typedef struct
401 cgraph_node_set set;
402 unsigned index;
403 } cgraph_node_set_iterator;
405 /* Iterator structure for varpool node sets. */
406 typedef struct
408 varpool_node_set set;
409 unsigned index;
410 } varpool_node_set_iterator;
412 #define DEFCIFCODE(code, string) CIF_ ## code,
413 /* Reasons for inlining failures. */
414 typedef enum cgraph_inline_failed_enum {
415 #include "cif-code.def"
416 CIF_N_REASONS
417 } cgraph_inline_failed_t;
419 /* Structure containing additional information about an indirect call. */
421 struct GTY(()) cgraph_indirect_call_info
423 /* When polymorphic is set, this field contains offset where the object which
424 was actually used in the polymorphic resides within a larger structure.
425 If agg_contents is set, the field contains the offset within the aggregate
426 from which the address to call was loaded. */
427 HOST_WIDE_INT offset;
428 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
429 HOST_WIDE_INT otr_token;
430 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
431 tree otr_type;
432 /* Index of the parameter that is called. */
433 int param_index;
434 /* ECF flags determined from the caller. */
435 int ecf_flags;
437 /* Set when the call is a virtual call with the parameter being the
438 associated object pointer rather than a simple direct call. */
439 unsigned polymorphic : 1;
440 /* Set when the call is a call of a pointer loaded from contents of an
441 aggregate at offset. */
442 unsigned agg_contents : 1;
443 /* When the previous bit is set, this one determines whether the destination
444 is loaded from a parameter passed by reference. */
445 unsigned by_ref : 1;
448 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
449 /* Expected number of executions: calculated in profile.c. */
450 gcov_type count;
451 struct cgraph_node *caller;
452 struct cgraph_node *callee;
453 struct cgraph_edge *prev_caller;
454 struct cgraph_edge *next_caller;
455 struct cgraph_edge *prev_callee;
456 struct cgraph_edge *next_callee;
457 gimple call_stmt;
458 /* Additional information about an indirect call. Not cleared when an edge
459 becomes direct. */
460 struct cgraph_indirect_call_info *indirect_info;
461 PTR GTY ((skip (""))) aux;
462 /* When equal to CIF_OK, inline this call. Otherwise, points to the
463 explanation why function was not inlined. */
464 cgraph_inline_failed_t inline_failed;
465 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
466 when the function is serialized in. */
467 unsigned int lto_stmt_uid;
468 /* Expected frequency of executions within the function.
469 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
470 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
471 int frequency;
472 /* Unique id of the edge. */
473 int uid;
474 /* Whether this edge was made direct by indirect inlining. */
475 unsigned int indirect_inlining_edge : 1;
476 /* Whether this edge describes an indirect call with an undetermined
477 callee. */
478 unsigned int indirect_unknown_callee : 1;
479 /* Whether this edge is still a dangling */
480 /* True if the corresponding CALL stmt cannot be inlined. */
481 unsigned int call_stmt_cannot_inline_p : 1;
482 /* Can this call throw externally? */
483 unsigned int can_throw_external : 1;
486 #define CGRAPH_FREQ_BASE 1000
487 #define CGRAPH_FREQ_MAX 100000
489 typedef struct cgraph_edge *cgraph_edge_p;
492 /* The varpool data structure.
493 Each static variable decl has assigned varpool_node. */
495 struct GTY(()) varpool_node {
496 struct symtab_node_base symbol;
498 /* Set when variable is scheduled to be assembled. */
499 unsigned output : 1;
502 /* Every top level asm statement is put into a asm_node. */
504 struct GTY(()) asm_node {
505 /* Next asm node. */
506 struct asm_node *next;
507 /* String for this asm node. */
508 tree asm_str;
509 /* Ordering of all cgraph nodes. */
510 int order;
513 /* Symbol table entry. */
514 union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
515 chain_prev ("%h.symbol.previous"))) symtab_node_def {
516 struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
517 /* To access the following fields,
518 use the use dyn_cast or as_a to obtain the concrete type. */
519 struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
520 struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
523 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
525 template <>
526 template <>
527 inline bool
528 is_a_helper <cgraph_node>::test (symtab_node_def *p)
530 return p->symbol.type == SYMTAB_FUNCTION;
533 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
535 template <>
536 template <>
537 inline bool
538 is_a_helper <varpool_node>::test (symtab_node_def *p)
540 return p->symbol.type == SYMTAB_VARIABLE;
543 extern GTY(()) symtab_node symtab_nodes;
544 extern GTY(()) int cgraph_n_nodes;
545 extern GTY(()) int cgraph_max_uid;
546 extern GTY(()) int cgraph_edge_max_uid;
547 extern bool cgraph_global_info_ready;
548 enum cgraph_state
550 /* Frontend is parsing and finalizing functions. */
551 CGRAPH_STATE_PARSING,
552 /* Callgraph is being constructed. It is safe to add new functions. */
553 CGRAPH_STATE_CONSTRUCTION,
554 /* Callgraph is being at LTO time. */
555 CGRAPH_LTO_STREAMING,
556 /* Callgraph is built and IPA passes are being run. */
557 CGRAPH_STATE_IPA,
558 /* Callgraph is built and all functions are transformed to SSA form. */
559 CGRAPH_STATE_IPA_SSA,
560 /* Functions are now ordered and being passed to RTL expanders. */
561 CGRAPH_STATE_EXPANSION,
562 /* All cgraph expansion is done. */
563 CGRAPH_STATE_FINISHED
565 extern enum cgraph_state cgraph_state;
566 extern bool cgraph_function_flags_ready;
567 extern cgraph_node_set cgraph_new_nodes;
569 extern GTY(()) struct asm_node *asm_nodes;
570 extern GTY(()) int symtab_order;
571 extern bool cpp_implicit_aliases_done;
573 /* In symtab.c */
574 void symtab_register_node (symtab_node);
575 void symtab_unregister_node (symtab_node);
576 void symtab_remove_node (symtab_node);
577 symtab_node symtab_get_node (const_tree);
578 symtab_node symtab_node_for_asm (const_tree asmname);
579 const char * symtab_node_asm_name (symtab_node);
580 const char * symtab_node_name (symtab_node);
581 void symtab_insert_node_to_hashtable (symtab_node);
582 void symtab_add_to_same_comdat_group (symtab_node, symtab_node);
583 void symtab_dissolve_same_comdat_group_list (symtab_node node);
584 void dump_symtab (FILE *);
585 void debug_symtab (void);
586 void dump_symtab_node (FILE *, symtab_node);
587 void debug_symtab_node (symtab_node);
588 void dump_symtab_base (FILE *, symtab_node);
589 void verify_symtab (void);
590 void verify_symtab_node (symtab_node);
591 bool verify_symtab_base (symtab_node);
592 bool symtab_used_from_object_file_p (symtab_node);
593 void symtab_make_decl_local (tree);
594 symtab_node symtab_alias_ultimate_target (symtab_node,
595 enum availability *avail = NULL);
596 bool symtab_resolve_alias (symtab_node node, symtab_node target);
597 void fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target);
599 /* In cgraph.c */
600 void dump_cgraph (FILE *);
601 void debug_cgraph (void);
602 void dump_cgraph_node (FILE *, struct cgraph_node *);
603 void debug_cgraph_node (struct cgraph_node *);
604 void cgraph_remove_edge (struct cgraph_edge *);
605 void cgraph_remove_node (struct cgraph_node *);
606 void cgraph_release_function_body (struct cgraph_node *);
607 void cgraph_node_remove_callees (struct cgraph_node *node);
608 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
609 struct cgraph_node *,
610 gimple, gcov_type, int);
611 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
612 int, gcov_type, int);
613 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
614 struct cgraph_node * cgraph_create_node (tree);
615 struct cgraph_node * cgraph_create_empty_node (void);
616 struct cgraph_node * cgraph_get_create_node (tree);
617 struct cgraph_node * cgraph_get_create_real_symbol_node (tree);
618 struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
619 struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
620 HOST_WIDE_INT, tree, tree);
621 struct cgraph_node *cgraph_node_for_asm (tree);
622 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
623 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
624 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
625 struct cgraph_local_info *cgraph_local_info (tree);
626 struct cgraph_global_info *cgraph_global_info (tree);
627 struct cgraph_rtl_info *cgraph_rtl_info (tree);
628 struct cgraph_node *cgraph_create_function_alias (tree, tree);
629 void cgraph_call_node_duplication_hooks (struct cgraph_node *,
630 struct cgraph_node *);
631 void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
632 struct cgraph_edge *);
634 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
635 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
636 bool cgraph_only_called_directly_p (struct cgraph_node *);
638 bool cgraph_function_possibly_inlined_p (tree);
639 void cgraph_unnest_node (struct cgraph_node *);
641 enum availability cgraph_function_body_availability (struct cgraph_node *);
642 void cgraph_add_new_function (tree, bool);
643 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
645 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
646 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
647 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
648 bool cgraph_node_cannot_return (struct cgraph_node *);
649 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
650 bool cgraph_will_be_removed_from_program_if_no_direct_calls
651 (struct cgraph_node *node);
652 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
653 (struct cgraph_node *node);
654 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
655 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
656 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
657 bool (*) (struct cgraph_node *, void *),
658 void *,
659 bool);
660 bool cgraph_for_node_and_aliases (struct cgraph_node *,
661 bool (*) (struct cgraph_node *, void *),
662 void *, bool);
663 vec<cgraph_edge_p> collect_callers_of_node (struct cgraph_node *node);
664 void verify_cgraph (void);
665 void verify_cgraph_node (struct cgraph_node *);
666 void cgraph_mark_address_taken_node (struct cgraph_node *);
668 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
669 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
670 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
671 void *);
672 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
673 void *);
674 struct cgraph_edge_hook_list;
675 struct cgraph_node_hook_list;
676 struct cgraph_2edge_hook_list;
677 struct cgraph_2node_hook_list;
678 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
679 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
680 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
681 void *);
682 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
683 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
684 void *);
685 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
686 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
687 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
688 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
689 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
690 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
691 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
692 bool cgraph_propagate_frequency (struct cgraph_node *node);
693 struct cgraph_node * cgraph_function_node (struct cgraph_node *,
694 enum availability *avail = NULL);
696 /* In cgraphunit.c */
697 struct asm_node *add_asm_node (tree);
698 extern FILE *cgraph_dump_file;
699 void cgraph_finalize_function (tree, bool);
700 void finalize_compilation_unit (void);
701 void compile (void);
702 void init_cgraph (void);
703 bool cgraph_process_new_functions (void);
704 void cgraph_process_same_body_aliases (void);
705 void fixup_same_cpp_alias_visibility (symtab_node, symtab_node target, tree);
706 /* Initialize datastructures so DECL is a function in lowered gimple form.
707 IN_SSA is true if the gimple is in SSA. */
708 basic_block init_lowered_empty_function (tree, bool);
709 void cgraph_reset_node (struct cgraph_node *);
711 /* In cgraphclones.c */
713 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
714 struct cgraph_node *, gimple,
715 unsigned, gcov_type, int, bool);
716 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
717 int, bool, vec<cgraph_edge_p>,
718 bool);
719 tree clone_function_name (tree decl, const char *);
720 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
721 vec<cgraph_edge_p>,
722 vec<ipa_replace_map_p, va_gc> *tree_map,
723 bitmap args_to_skip,
724 const char *clone_name);
725 struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
726 bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
727 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
728 void cgraph_create_edge_including_clones (struct cgraph_node *,
729 struct cgraph_node *,
730 gimple, gimple, gcov_type, int,
731 cgraph_inline_failed_t);
732 void cgraph_materialize_all_clones (void);
733 struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
734 tree, vec<cgraph_edge_p>, bitmap);
735 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
736 vec<cgraph_edge_p>,
737 vec<ipa_replace_map_p, va_gc> *,
738 bitmap, bool, bitmap,
739 basic_block, const char *);
740 void tree_function_versioning (tree, tree, vec<ipa_replace_map_p, va_gc> *,
741 bool, bitmap, bool, bitmap, basic_block);
743 /* In cgraphbuild.c */
744 unsigned int rebuild_cgraph_edges (void);
745 void cgraph_rebuild_references (void);
746 int compute_call_stmt_bb_frequency (tree, basic_block bb);
747 void record_references_in_initializer (tree, bool);
748 void ipa_record_stmt_references (struct cgraph_node *, gimple);
750 /* In ipa.c */
751 bool symtab_remove_unreachable_nodes (bool, FILE *);
752 cgraph_node_set cgraph_node_set_new (void);
753 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
754 struct cgraph_node *);
755 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
756 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
757 void dump_cgraph_node_set (FILE *, cgraph_node_set);
758 void debug_cgraph_node_set (cgraph_node_set);
759 void free_cgraph_node_set (cgraph_node_set);
760 void cgraph_build_static_cdtor (char which, tree body, int priority);
762 varpool_node_set varpool_node_set_new (void);
763 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
764 struct varpool_node *);
765 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
766 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
767 void dump_varpool_node_set (FILE *, varpool_node_set);
768 void debug_varpool_node_set (varpool_node_set);
769 void free_varpool_node_set (varpool_node_set);
770 void ipa_discover_readonly_nonaddressable_vars (void);
771 bool varpool_externally_visible_p (struct varpool_node *);
773 /* In predict.c */
774 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
775 bool cgraph_optimize_for_size_p (struct cgraph_node *);
777 /* In varpool.c */
778 struct varpool_node *varpool_create_empty_node (void);
779 struct varpool_node *varpool_node_for_decl (tree);
780 struct varpool_node *varpool_node_for_asm (tree asmname);
781 void varpool_mark_needed_node (struct varpool_node *);
782 void debug_varpool (void);
783 void dump_varpool (FILE *);
784 void dump_varpool_node (FILE *, struct varpool_node *);
786 void varpool_finalize_decl (tree);
787 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
788 void cgraph_make_node_local (struct cgraph_node *);
789 bool cgraph_node_can_be_local_p (struct cgraph_node *);
792 void varpool_remove_node (struct varpool_node *node);
793 void varpool_finalize_named_section_flags (struct varpool_node *node);
794 bool varpool_output_variables (void);
795 bool varpool_assemble_decl (struct varpool_node *node);
796 void varpool_analyze_node (struct varpool_node *);
797 struct varpool_node * varpool_extra_name_alias (tree, tree);
798 struct varpool_node * varpool_create_variable_alias (tree, tree);
799 void varpool_reset_queue (void);
800 bool const_value_known_p (tree);
801 bool varpool_for_node_and_aliases (struct varpool_node *,
802 bool (*) (struct varpool_node *, void *),
803 void *, bool);
804 void varpool_add_new_variable (tree);
805 void symtab_initialize_asm_name_hash (void);
806 void symtab_prevail_in_asm_name_hash (symtab_node node);
807 void varpool_remove_initializer (struct varpool_node *);
810 /* Return callgraph node for given symbol and check it is a function. */
811 static inline struct cgraph_node *
812 cgraph (symtab_node node)
814 gcc_checking_assert (!node || node->symbol.type == SYMTAB_FUNCTION);
815 return (struct cgraph_node *)node;
818 /* Return varpool node for given symbol and check it is a variable. */
819 static inline struct varpool_node *
820 varpool (symtab_node node)
822 gcc_checking_assert (!node || node->symbol.type == SYMTAB_VARIABLE);
823 return (struct varpool_node *)node;
826 /* Return callgraph node for given symbol and check it is a function. */
827 static inline struct cgraph_node *
828 cgraph_get_node (const_tree decl)
830 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
831 return cgraph (symtab_get_node (decl));
834 /* Return varpool node for given symbol and check it is a function. */
835 static inline struct varpool_node *
836 varpool_get_node (const_tree decl)
838 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
839 return varpool (symtab_get_node (decl));
842 /* Return asm name of cgraph node. */
843 static inline const char *
844 cgraph_node_asm_name (struct cgraph_node *node)
846 return symtab_node_asm_name ((symtab_node)node);
849 /* Return asm name of varpool node. */
850 static inline const char *
851 varpool_node_asm_name(struct varpool_node *node)
853 return symtab_node_asm_name ((symtab_node)node);
856 /* Return name of cgraph node. */
857 static inline const char *
858 cgraph_node_name(struct cgraph_node *node)
860 return symtab_node_name ((symtab_node)node);
863 /* Return name of varpool node. */
864 static inline const char *
865 varpool_node_name(struct varpool_node *node)
867 return symtab_node_name ((symtab_node)node);
870 /* Walk all symbols. */
871 #define FOR_EACH_SYMBOL(node) \
872 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
875 /* Return first variable. */
876 static inline struct varpool_node *
877 varpool_first_variable (void)
879 symtab_node node;
880 for (node = symtab_nodes; node; node = node->symbol.next)
881 if (varpool_node *vnode = dyn_cast <varpool_node> (node))
882 return vnode;
883 return NULL;
886 /* Return next variable after NODE. */
887 static inline struct varpool_node *
888 varpool_next_variable (struct varpool_node *node)
890 symtab_node node1 = (symtab_node) node->symbol.next;
891 for (; node1; node1 = node1->symbol.next)
892 if (varpool_node *vnode1 = dyn_cast <varpool_node> (node1))
893 return vnode1;
894 return NULL;
896 /* Walk all variables. */
897 #define FOR_EACH_VARIABLE(node) \
898 for ((node) = varpool_first_variable (); \
899 (node); \
900 (node) = varpool_next_variable ((node)))
902 /* Return first reachable static variable with initializer. */
903 static inline struct varpool_node *
904 varpool_first_static_initializer (void)
906 symtab_node node;
907 for (node = symtab_nodes; node; node = node->symbol.next)
909 varpool_node *vnode = dyn_cast <varpool_node> (node);
910 if (vnode && DECL_INITIAL (node->symbol.decl))
911 return vnode;
913 return NULL;
916 /* Return next reachable static variable with initializer after NODE. */
917 static inline struct varpool_node *
918 varpool_next_static_initializer (struct varpool_node *node)
920 symtab_node node1 = (symtab_node) node->symbol.next;
921 for (; node1; node1 = node1->symbol.next)
923 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
924 if (vnode1 && DECL_INITIAL (node1->symbol.decl))
925 return vnode1;
927 return NULL;
930 /* Walk all static variables with initializer set. */
931 #define FOR_EACH_STATIC_INITIALIZER(node) \
932 for ((node) = varpool_first_static_initializer (); (node); \
933 (node) = varpool_next_static_initializer (node))
935 /* Return first reachable static variable with initializer. */
936 static inline struct varpool_node *
937 varpool_first_defined_variable (void)
939 symtab_node node;
940 for (node = symtab_nodes; node; node = node->symbol.next)
942 varpool_node *vnode = dyn_cast <varpool_node> (node);
943 if (vnode && vnode->symbol.definition)
944 return vnode;
946 return NULL;
949 /* Return next reachable static variable with initializer after NODE. */
950 static inline struct varpool_node *
951 varpool_next_defined_variable (struct varpool_node *node)
953 symtab_node node1 = (symtab_node) node->symbol.next;
954 for (; node1; node1 = node1->symbol.next)
956 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
957 if (vnode1 && vnode1->symbol.definition)
958 return vnode1;
960 return NULL;
962 /* Walk all variables with definitions in current unit. */
963 #define FOR_EACH_DEFINED_VARIABLE(node) \
964 for ((node) = varpool_first_defined_variable (); (node); \
965 (node) = varpool_next_defined_variable (node))
967 /* Return first function with body defined. */
968 static inline struct cgraph_node *
969 cgraph_first_defined_function (void)
971 symtab_node node;
972 for (node = symtab_nodes; node; node = node->symbol.next)
974 cgraph_node *cn = dyn_cast <cgraph_node> (node);
975 if (cn && cn->symbol.definition)
976 return cn;
978 return NULL;
981 /* Return next function with body defined after NODE. */
982 static inline struct cgraph_node *
983 cgraph_next_defined_function (struct cgraph_node *node)
985 symtab_node node1 = (symtab_node) node->symbol.next;
986 for (; node1; node1 = node1->symbol.next)
988 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
989 if (cn1 && cn1->symbol.definition)
990 return cn1;
992 return NULL;
995 /* Walk all functions with body defined. */
996 #define FOR_EACH_DEFINED_FUNCTION(node) \
997 for ((node) = cgraph_first_defined_function (); (node); \
998 (node) = cgraph_next_defined_function ((node)))
1000 /* Return first function. */
1001 static inline struct cgraph_node *
1002 cgraph_first_function (void)
1004 symtab_node node;
1005 for (node = symtab_nodes; node; node = node->symbol.next)
1006 if (cgraph_node *cn = dyn_cast <cgraph_node> (node))
1007 return cn;
1008 return NULL;
1011 /* Return next function. */
1012 static inline struct cgraph_node *
1013 cgraph_next_function (struct cgraph_node *node)
1015 symtab_node node1 = (symtab_node) node->symbol.next;
1016 for (; node1; node1 = node1->symbol.next)
1017 if (cgraph_node *cn1 = dyn_cast <cgraph_node> (node1))
1018 return cn1;
1019 return NULL;
1021 /* Walk all functions. */
1022 #define FOR_EACH_FUNCTION(node) \
1023 for ((node) = cgraph_first_function (); (node); \
1024 (node) = cgraph_next_function ((node)))
1026 /* Return true when NODE is a function with Gimple body defined
1027 in current unit. Functions can also be define externally or they
1028 can be thunks with no Gimple representation.
1030 Note that at WPA stage, the function body may not be present in memory. */
1032 static inline bool
1033 cgraph_function_with_gimple_body_p (struct cgraph_node *node)
1035 return node->symbol.definition && !node->thunk.thunk_p && !node->symbol.alias;
1038 /* Return first function with body defined. */
1039 static inline struct cgraph_node *
1040 cgraph_first_function_with_gimple_body (void)
1042 symtab_node node;
1043 for (node = symtab_nodes; node; node = node->symbol.next)
1045 cgraph_node *cn = dyn_cast <cgraph_node> (node);
1046 if (cn && cgraph_function_with_gimple_body_p (cn))
1047 return cn;
1049 return NULL;
1052 /* Return next reachable static variable with initializer after NODE. */
1053 static inline struct cgraph_node *
1054 cgraph_next_function_with_gimple_body (struct cgraph_node *node)
1056 symtab_node node1 = node->symbol.next;
1057 for (; node1; node1 = node1->symbol.next)
1059 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
1060 if (cn1 && cgraph_function_with_gimple_body_p (cn1))
1061 return cn1;
1063 return NULL;
1066 /* Walk all functions with body defined. */
1067 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1068 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1069 (node) = cgraph_next_function_with_gimple_body (node))
1071 /* Create a new static variable of type TYPE. */
1072 tree add_new_static_var (tree type);
1074 /* Return true if iterator CSI points to nothing. */
1075 static inline bool
1076 csi_end_p (cgraph_node_set_iterator csi)
1078 return csi.index >= csi.set->nodes.length ();
1081 /* Advance iterator CSI. */
1082 static inline void
1083 csi_next (cgraph_node_set_iterator *csi)
1085 csi->index++;
1088 /* Return the node pointed to by CSI. */
1089 static inline struct cgraph_node *
1090 csi_node (cgraph_node_set_iterator csi)
1092 return csi.set->nodes[csi.index];
1095 /* Return an iterator to the first node in SET. */
1096 static inline cgraph_node_set_iterator
1097 csi_start (cgraph_node_set set)
1099 cgraph_node_set_iterator csi;
1101 csi.set = set;
1102 csi.index = 0;
1103 return csi;
1106 /* Return true if SET contains NODE. */
1107 static inline bool
1108 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1110 cgraph_node_set_iterator csi;
1111 csi = cgraph_node_set_find (set, node);
1112 return !csi_end_p (csi);
1115 /* Return number of nodes in SET. */
1116 static inline size_t
1117 cgraph_node_set_size (cgraph_node_set set)
1119 return set->nodes.length ();
1122 /* Return true if iterator VSI points to nothing. */
1123 static inline bool
1124 vsi_end_p (varpool_node_set_iterator vsi)
1126 return vsi.index >= vsi.set->nodes.length ();
1129 /* Advance iterator VSI. */
1130 static inline void
1131 vsi_next (varpool_node_set_iterator *vsi)
1133 vsi->index++;
1136 /* Return the node pointed to by VSI. */
1137 static inline struct varpool_node *
1138 vsi_node (varpool_node_set_iterator vsi)
1140 return vsi.set->nodes[vsi.index];
1143 /* Return an iterator to the first node in SET. */
1144 static inline varpool_node_set_iterator
1145 vsi_start (varpool_node_set set)
1147 varpool_node_set_iterator vsi;
1149 vsi.set = set;
1150 vsi.index = 0;
1151 return vsi;
1154 /* Return true if SET contains NODE. */
1155 static inline bool
1156 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
1158 varpool_node_set_iterator vsi;
1159 vsi = varpool_node_set_find (set, node);
1160 return !vsi_end_p (vsi);
1163 /* Return number of nodes in SET. */
1164 static inline size_t
1165 varpool_node_set_size (varpool_node_set set)
1167 return set->nodes.length ();
1170 /* Uniquize all constants that appear in memory.
1171 Each constant in memory thus far output is recorded
1172 in `const_desc_table'. */
1174 struct GTY(()) constant_descriptor_tree {
1175 /* A MEM for the constant. */
1176 rtx rtl;
1178 /* The value of the constant. */
1179 tree value;
1181 /* Hash of value. Computing the hash from value each time
1182 hashfn is called can't work properly, as that means recursive
1183 use of the hash table during hash table expansion. */
1184 hashval_t hash;
1187 /* Return true if set is nonempty. */
1188 static inline bool
1189 cgraph_node_set_nonempty_p (cgraph_node_set set)
1191 return !set->nodes.is_empty ();
1194 /* Return true if set is nonempty. */
1195 static inline bool
1196 varpool_node_set_nonempty_p (varpool_node_set set)
1198 return !set->nodes.is_empty ();
1201 /* Return true when function NODE is only called directly or it has alias.
1202 i.e. it is not externally visible, address was not taken and
1203 it is not used in any other non-standard way. */
1205 static inline bool
1206 cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
1208 gcc_assert (!node->global.inlined_to);
1209 return (!node->symbol.force_output && !node->symbol.address_taken
1210 && !node->symbol.used_from_other_partition
1211 && !DECL_VIRTUAL_P (node->symbol.decl)
1212 && !DECL_STATIC_CONSTRUCTOR (node->symbol.decl)
1213 && !DECL_STATIC_DESTRUCTOR (node->symbol.decl)
1214 && !node->symbol.externally_visible);
1217 /* Return true when function NODE can be removed from callgraph
1218 if all direct calls are eliminated. */
1220 static inline bool
1221 varpool_can_remove_if_no_refs (struct varpool_node *node)
1223 if (DECL_EXTERNAL (node->symbol.decl))
1224 return true;
1225 return (!node->symbol.force_output && !node->symbol.used_from_other_partition
1226 && ((DECL_COMDAT (node->symbol.decl)
1227 && !node->symbol.forced_by_abi
1228 && !symtab_used_from_object_file_p ((symtab_node) node))
1229 || !node->symbol.externally_visible
1230 || DECL_HAS_VALUE_EXPR_P (node->symbol.decl)));
1233 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1234 i.e. if the variable is not externally visible or not used in some magic
1235 way (asm statement or such).
1236 The magic uses are all summarized in force_output flag. */
1238 static inline bool
1239 varpool_all_refs_explicit_p (struct varpool_node *vnode)
1241 return (vnode->symbol.definition
1242 && !vnode->symbol.externally_visible
1243 && !vnode->symbol.used_from_other_partition
1244 && !vnode->symbol.force_output);
1247 /* Constant pool accessor function. */
1248 htab_t constant_pool_htab (void);
1250 /* FIXME: inappropriate dependency of cgraph on IPA. */
1251 #include "ipa-ref-inline.h"
1253 /* Return node that alias N is aliasing. */
1255 static inline symtab_node
1256 symtab_alias_target (symtab_node n)
1258 struct ipa_ref *ref;
1259 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
1260 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1261 return ref->referred;
1264 static inline struct cgraph_node *
1265 cgraph_alias_target (struct cgraph_node *n)
1267 return dyn_cast <cgraph_node> (symtab_alias_target ((symtab_node) n));
1270 static inline struct varpool_node *
1271 varpool_alias_target (struct varpool_node *n)
1273 return dyn_cast <varpool_node> (symtab_alias_target ((symtab_node) n));
1276 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1277 Do not walk through thunks.
1278 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1280 static inline struct cgraph_node *
1281 cgraph_function_or_thunk_node (struct cgraph_node *node,
1282 enum availability *availability = NULL)
1284 struct cgraph_node *n;
1286 n = dyn_cast <cgraph_node> (symtab_alias_ultimate_target ((symtab_node)node,
1287 availability));
1288 if (!n && availability)
1289 *availability = AVAIL_NOT_AVAILABLE;
1290 return n;
1292 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1293 Do not walk through thunks.
1294 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1296 static inline struct varpool_node *
1297 varpool_variable_node (struct varpool_node *node,
1298 enum availability *availability = NULL)
1300 struct varpool_node *n;
1302 n = dyn_cast <varpool_node> (symtab_alias_ultimate_target ((symtab_node)node,
1303 availability));
1304 if (!n && availability)
1305 *availability = AVAIL_NOT_AVAILABLE;
1306 return n;
1309 /* Return true when the edge E represents a direct recursion. */
1310 static inline bool
1311 cgraph_edge_recursive_p (struct cgraph_edge *e)
1313 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
1314 if (e->caller->global.inlined_to)
1315 return e->caller->global.inlined_to->symbol.decl == callee->symbol.decl;
1316 else
1317 return e->caller->symbol.decl == callee->symbol.decl;
1320 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1321 static inline bool
1322 decl_is_tm_clone (const_tree fndecl)
1324 struct cgraph_node *n = cgraph_get_node (fndecl);
1325 if (n)
1326 return n->tm_clone;
1327 return false;
1330 /* Likewise indicate that a node is needed, i.e. reachable via some
1331 external means. */
1333 static inline void
1334 cgraph_mark_force_output_node (struct cgraph_node *node)
1336 node->symbol.force_output = 1;
1337 gcc_checking_assert (!node->global.inlined_to);
1340 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1341 or abstract function kept for debug info purposes only. */
1343 static inline bool
1344 symtab_real_symbol_p (symtab_node node)
1346 struct cgraph_node *cnode;
1348 if (!is_a <cgraph_node> (node))
1349 return true;
1350 cnode = cgraph (node);
1351 if (cnode->global.inlined_to)
1352 return false;
1353 if (cnode->abstract_and_needed)
1354 return false;
1355 return true;
1357 #endif /* GCC_CGRAPH_H */