2013-06-06 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / cgraph.h
blobdda4402e07715fad5b9fbaa63f3200e0b3a0d6d4
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 /* C++ frontend produce same body aliases and extra name aliases for
60 virutal functions and vtables that are obviously equivalent.
61 Those aliases are bit special, especially because C++ frontend
62 visibility code is so ugly it can not get them right at first time
63 and their visibility needs to be copied from their "masters" at
64 the end of parsing. */
65 unsigned cpp_implicit_alias : 1;
66 /* Set once the definition was analyzed. The list of references and
67 other properties are built during analysis. */
68 unsigned analyzed : 1;
71 /*** Visibility and linkage flags. ***/
73 /* Set when function is visible by other units. */
74 unsigned externally_visible : 1;
75 /* The symbol will be assumed to be used in an invisiable way (like
76 by an toplevel asm statement). */
77 unsigned force_output : 1;
78 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
79 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
80 to static and it does not inhibit optimization. */
81 unsigned forced_by_abi : 1;
82 /* True when the name is known to be unique and thus it does not need mangling. */
83 unsigned unique_name : 1;
86 /*** WHOPR Partitioning flags.
87 These flags are used at ltrans stage when only part of the callgraph is
88 available. ***/
90 /* Set when variable is used from other LTRANS partition. */
91 unsigned used_from_other_partition : 1;
92 /* Set when function is available in the other LTRANS partition.
93 During WPA output it is used to mark nodes that are present in
94 multiple partitions. */
95 unsigned in_other_partition : 1;
99 /*** other flags. ***/
101 /* Set when symbol has address taken. */
102 unsigned address_taken : 1;
105 /* Ordering of all symtab entries. */
106 int order;
108 /* Declaration representing the symbol. */
109 tree decl;
111 /* Linked list of symbol table entries starting with symtab_nodes. */
112 symtab_node next;
113 symtab_node previous;
115 /* Linked list of symbols with the same asm name. There may be multiple
116 entries for single symbol name during LTO, because symbols are renamed
117 only after partitioning.
119 Because inline clones are kept in the assembler name has, they also produce
120 duplicate entries.
122 There are also several long standing bugs where frontends and builtin
123 code produce duplicated decls. */
124 symtab_node next_sharing_asm_name;
125 symtab_node previous_sharing_asm_name;
127 /* Circular list of nodes in the same comdat group if non-NULL. */
128 symtab_node same_comdat_group;
130 /* Vectors of referring and referenced entities. */
131 struct ipa_ref_list ref_list;
133 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
134 depending to what was known to frontend on the creation time.
135 Once alias is resolved, this pointer become NULL. */
136 tree alias_target;
138 /* File stream where this node is being written to. */
139 struct lto_file_decl_data * lto_file_data;
141 PTR GTY ((skip)) aux;
144 enum availability
146 /* Not yet set by cgraph_function_body_availability. */
147 AVAIL_UNSET,
148 /* Function body/variable initializer is unknown. */
149 AVAIL_NOT_AVAILABLE,
150 /* Function body/variable initializer is known but might be replaced
151 by a different one from other compilation unit and thus needs to
152 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
153 arbitrary side effects on escaping variables and functions, while
154 like AVAILABLE it might access static variables. */
155 AVAIL_OVERWRITABLE,
156 /* Function body/variable initializer is known and will be used in final
157 program. */
158 AVAIL_AVAILABLE,
159 /* Function body/variable initializer is known and all it's uses are explicitly
160 visible within current unit (ie it's address is never taken and it is not
161 exported to other units).
162 Currently used only for functions. */
163 AVAIL_LOCAL
166 /* This is the information that is put into the cgraph local structure
167 to recover a function. */
168 struct lto_file_decl_data;
170 extern const char * const cgraph_availability_names[];
171 extern const char * const ld_plugin_symbol_resolution_names[];
173 /* Information about thunk, used only for same body aliases. */
175 struct GTY(()) cgraph_thunk_info {
176 /* Information about the thunk. */
177 HOST_WIDE_INT fixed_offset;
178 HOST_WIDE_INT virtual_value;
179 tree alias;
180 bool this_adjusting;
181 bool virtual_offset_p;
182 /* Set to true when alias node is thunk. */
183 bool thunk_p;
186 /* Information about the function collected locally.
187 Available after function is analyzed. */
189 struct GTY(()) cgraph_local_info {
190 /* Set when function function is visible in current compilation unit only
191 and its address is never taken. */
192 unsigned local : 1;
194 /* False when there is something makes versioning impossible. */
195 unsigned versionable : 1;
197 /* False when function calling convention and signature can not be changed.
198 This is the case when __builtin_apply_args is used. */
199 unsigned can_change_signature : 1;
201 /* True when the function has been originally extern inline, but it is
202 redefined now. */
203 unsigned redefined_extern_inline : 1;
205 /* True if the function may enter serial irrevocable mode. */
206 unsigned tm_may_enter_irr : 1;
209 /* Information about the function that needs to be computed globally
210 once compilation is finished. Available only with -funit-at-a-time. */
212 struct GTY(()) cgraph_global_info {
213 /* For inline clones this points to the function they will be
214 inlined into. */
215 struct cgraph_node *inlined_to;
218 /* Information about the function that is propagated by the RTL backend.
219 Available only for functions that has been already assembled. */
221 struct GTY(()) cgraph_rtl_info {
222 unsigned int preferred_incoming_stack_boundary;
225 /* Represent which DECL tree (or reference to such tree)
226 will be replaced by another tree while versioning. */
227 struct GTY(()) ipa_replace_map
229 /* The tree that will be replaced. */
230 tree old_tree;
231 /* The new (replacing) tree. */
232 tree new_tree;
233 /* Parameter number to replace, when old_tree is NULL. */
234 int parm_num;
235 /* True when a substitution should be done, false otherwise. */
236 bool replace_p;
237 /* True when we replace a reference to old_tree. */
238 bool ref_p;
240 typedef struct ipa_replace_map *ipa_replace_map_p;
242 struct GTY(()) cgraph_clone_info
244 vec<ipa_replace_map_p, va_gc> *tree_map;
245 bitmap args_to_skip;
246 bitmap combined_args_to_skip;
250 /* The cgraph data structure.
251 Each function decl has assigned cgraph_node listing callees and callers. */
253 struct GTY(()) cgraph_node {
254 struct symtab_node_base symbol;
255 struct cgraph_edge *callees;
256 struct cgraph_edge *callers;
257 /* List of edges representing indirect calls with a yet undetermined
258 callee. */
259 struct cgraph_edge *indirect_calls;
260 /* For nested functions points to function the node is nested in. */
261 struct cgraph_node *
262 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
263 origin;
264 /* Points to first nested function, if any. */
265 struct cgraph_node *
266 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
267 nested;
268 /* Pointer to the next function with same origin, if any. */
269 struct cgraph_node *
270 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
271 next_nested;
272 /* Pointer to the next clone. */
273 struct cgraph_node *next_sibling_clone;
274 struct cgraph_node *prev_sibling_clone;
275 struct cgraph_node *clones;
276 struct cgraph_node *clone_of;
277 /* For functions with many calls sites it holds map from call expression
278 to the edge to speed up cgraph_edge function. */
279 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
280 /* Declaration node used to be clone of. */
281 tree former_clone_of;
283 /* Interprocedural passes scheduled to have their transform functions
284 applied next time we execute local pass on them. We maintain it
285 per-function in order to allow IPA passes to introduce new functions. */
286 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
288 struct cgraph_local_info local;
289 struct cgraph_global_info global;
290 struct cgraph_rtl_info rtl;
291 struct cgraph_clone_info clone;
292 struct cgraph_thunk_info thunk;
294 /* Expected number of executions: calculated in profile.c. */
295 gcov_type count;
296 /* How to scale counts at materialization time; used to merge
297 LTO units with different number of profile runs. */
298 int count_materialization_scale;
299 /* Unique id of the node. */
300 int uid;
302 /* Set when decl is an abstract function pointed to by the
303 ABSTRACT_DECL_ORIGIN of a reachable function. */
304 unsigned abstract_and_needed : 1;
305 /* Set once the function is lowered (i.e. its CFG is built). */
306 unsigned lowered : 1;
307 /* Set once the function has been instantiated and its callee
308 lists created. */
309 unsigned process : 1;
310 /* How commonly executed the node is. Initialized during branch
311 probabilities pass. */
312 ENUM_BITFIELD (node_frequency) frequency : 2;
313 /* True when function can only be called at startup (from static ctor). */
314 unsigned only_called_at_startup : 1;
315 /* True when function can only be called at startup (from static dtor). */
316 unsigned only_called_at_exit : 1;
317 /* True when function is the transactional clone of a function which
318 is called only from inside transactions. */
319 /* ?? We should be able to remove this. We have enough bits in
320 cgraph to calculate it. */
321 unsigned tm_clone : 1;
322 /* True if this decl is a dispatcher for function versions. */
323 unsigned dispatcher_function : 1;
327 typedef struct cgraph_node *cgraph_node_ptr;
330 /* Function Multiversioning info. */
331 struct GTY(()) cgraph_function_version_info {
332 /* The cgraph_node for which the function version info is stored. */
333 struct cgraph_node *this_node;
334 /* Chains all the semantically identical function versions. The
335 first function in this chain is the version_info node of the
336 default function. */
337 struct cgraph_function_version_info *prev;
338 /* If this version node corresponds to a dispatcher for function
339 versions, this points to the version info node of the default
340 function, the first node in the chain. */
341 struct cgraph_function_version_info *next;
342 /* If this node corresponds to a function version, this points
343 to the dispatcher function decl, which is the function that must
344 be called to execute the right function version at run-time.
346 If this cgraph node is a dispatcher (if dispatcher_function is
347 true, in the cgraph_node struct) for function versions, this
348 points to resolver function, which holds the function body of the
349 dispatcher. The dispatcher decl is an alias to the resolver
350 function decl. */
351 tree dispatcher_resolver;
354 /* Get the cgraph_function_version_info node corresponding to node. */
355 struct cgraph_function_version_info *
356 get_cgraph_node_version (struct cgraph_node *node);
358 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
359 corresponding to cgraph_node NODE. */
360 struct cgraph_function_version_info *
361 insert_new_cgraph_node_version (struct cgraph_node *node);
363 /* Record that DECL1 and DECL2 are semantically identical function
364 versions. */
365 void record_function_versions (tree decl1, tree decl2);
367 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
368 DECL is a duplicate declaration. */
369 void delete_function_version (tree decl);
371 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
372 can appear in multiple sets. */
373 struct cgraph_node_set_def
375 struct pointer_map_t *map;
376 vec<cgraph_node_ptr> nodes;
379 typedef struct varpool_node *varpool_node_ptr;
382 /* A varpool node set is a collection of varpool nodes. A varpool node
383 can appear in multiple sets. */
384 struct varpool_node_set_def
386 struct pointer_map_t * map;
387 vec<varpool_node_ptr> nodes;
390 typedef struct cgraph_node_set_def *cgraph_node_set;
393 typedef struct varpool_node_set_def *varpool_node_set;
396 /* Iterator structure for cgraph node sets. */
397 typedef struct
399 cgraph_node_set set;
400 unsigned index;
401 } cgraph_node_set_iterator;
403 /* Iterator structure for varpool node sets. */
404 typedef struct
406 varpool_node_set set;
407 unsigned index;
408 } varpool_node_set_iterator;
410 #define DEFCIFCODE(code, string) CIF_ ## code,
411 /* Reasons for inlining failures. */
412 typedef enum cgraph_inline_failed_enum {
413 #include "cif-code.def"
414 CIF_N_REASONS
415 } cgraph_inline_failed_t;
417 /* Structure containing additional information about an indirect call. */
419 struct GTY(()) cgraph_indirect_call_info
421 /* When polymorphic is set, this field contains offset where the object which
422 was actually used in the polymorphic resides within a larger structure.
423 If agg_contents is set, the field contains the offset within the aggregate
424 from which the address to call was loaded. */
425 HOST_WIDE_INT offset;
426 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
427 HOST_WIDE_INT otr_token;
428 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
429 tree otr_type;
430 /* Index of the parameter that is called. */
431 int param_index;
432 /* ECF flags determined from the caller. */
433 int ecf_flags;
435 /* Set when the call is a virtual call with the parameter being the
436 associated object pointer rather than a simple direct call. */
437 unsigned polymorphic : 1;
438 /* Set when the call is a call of a pointer loaded from contents of an
439 aggregate at offset. */
440 unsigned agg_contents : 1;
441 /* When the previous bit is set, this one determines whether the destination
442 is loaded from a parameter passed by reference. */
443 unsigned by_ref : 1;
446 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
447 /* Expected number of executions: calculated in profile.c. */
448 gcov_type count;
449 struct cgraph_node *caller;
450 struct cgraph_node *callee;
451 struct cgraph_edge *prev_caller;
452 struct cgraph_edge *next_caller;
453 struct cgraph_edge *prev_callee;
454 struct cgraph_edge *next_callee;
455 gimple call_stmt;
456 /* Additional information about an indirect call. Not cleared when an edge
457 becomes direct. */
458 struct cgraph_indirect_call_info *indirect_info;
459 PTR GTY ((skip (""))) aux;
460 /* When equal to CIF_OK, inline this call. Otherwise, points to the
461 explanation why function was not inlined. */
462 cgraph_inline_failed_t inline_failed;
463 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
464 when the function is serialized in. */
465 unsigned int lto_stmt_uid;
466 /* Expected frequency of executions within the function.
467 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
468 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
469 int frequency;
470 /* Unique id of the edge. */
471 int uid;
472 /* Whether this edge was made direct by indirect inlining. */
473 unsigned int indirect_inlining_edge : 1;
474 /* Whether this edge describes an indirect call with an undetermined
475 callee. */
476 unsigned int indirect_unknown_callee : 1;
477 /* Whether this edge is still a dangling */
478 /* True if the corresponding CALL stmt cannot be inlined. */
479 unsigned int call_stmt_cannot_inline_p : 1;
480 /* Can this call throw externally? */
481 unsigned int can_throw_external : 1;
484 #define CGRAPH_FREQ_BASE 1000
485 #define CGRAPH_FREQ_MAX 100000
487 typedef struct cgraph_edge *cgraph_edge_p;
490 /* The varpool data structure.
491 Each static variable decl has assigned varpool_node. */
493 struct GTY(()) varpool_node {
494 struct symtab_node_base symbol;
496 /* Set when variable is scheduled to be assembled. */
497 unsigned output : 1;
500 /* Every top level asm statement is put into a asm_node. */
502 struct GTY(()) asm_node {
503 /* Next asm node. */
504 struct asm_node *next;
505 /* String for this asm node. */
506 tree asm_str;
507 /* Ordering of all cgraph nodes. */
508 int order;
511 /* Symbol table entry. */
512 union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
513 chain_prev ("%h.symbol.previous"))) symtab_node_def {
514 struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
515 /* To access the following fields,
516 use the use dyn_cast or as_a to obtain the concrete type. */
517 struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
518 struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
521 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
523 template <>
524 template <>
525 inline bool
526 is_a_helper <cgraph_node>::test (symtab_node_def *p)
528 return p->symbol.type == SYMTAB_FUNCTION;
531 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
533 template <>
534 template <>
535 inline bool
536 is_a_helper <varpool_node>::test (symtab_node_def *p)
538 return p->symbol.type == SYMTAB_VARIABLE;
541 extern GTY(()) symtab_node symtab_nodes;
542 extern GTY(()) int cgraph_n_nodes;
543 extern GTY(()) int cgraph_max_uid;
544 extern GTY(()) int cgraph_edge_max_uid;
545 extern bool cgraph_global_info_ready;
546 enum cgraph_state
548 /* Frontend is parsing and finalizing functions. */
549 CGRAPH_STATE_PARSING,
550 /* Callgraph is being constructed. It is safe to add new functions. */
551 CGRAPH_STATE_CONSTRUCTION,
552 /* Callgraph is built and IPA passes are being run. */
553 CGRAPH_STATE_IPA,
554 /* Callgraph is built and all functions are transformed to SSA form. */
555 CGRAPH_STATE_IPA_SSA,
556 /* Functions are now ordered and being passed to RTL expanders. */
557 CGRAPH_STATE_EXPANSION,
558 /* All cgraph expansion is done. */
559 CGRAPH_STATE_FINISHED
561 extern enum cgraph_state cgraph_state;
562 extern bool cgraph_function_flags_ready;
563 extern cgraph_node_set cgraph_new_nodes;
565 extern GTY(()) struct asm_node *asm_nodes;
566 extern GTY(()) int symtab_order;
567 extern bool cpp_implicit_aliases_done;
569 /* In symtab.c */
570 void symtab_register_node (symtab_node);
571 void symtab_unregister_node (symtab_node);
572 void symtab_remove_node (symtab_node);
573 symtab_node symtab_get_node (const_tree);
574 symtab_node symtab_node_for_asm (const_tree asmname);
575 const char * symtab_node_asm_name (symtab_node);
576 const char * symtab_node_name (symtab_node);
577 void symtab_insert_node_to_hashtable (symtab_node);
578 void symtab_add_to_same_comdat_group (symtab_node, symtab_node);
579 void symtab_dissolve_same_comdat_group_list (symtab_node node);
580 void dump_symtab (FILE *);
581 void debug_symtab (void);
582 void dump_symtab_node (FILE *, symtab_node);
583 void debug_symtab_node (symtab_node);
584 void dump_symtab_base (FILE *, symtab_node);
585 void verify_symtab (void);
586 void verify_symtab_node (symtab_node);
587 bool verify_symtab_base (symtab_node);
588 bool symtab_used_from_object_file_p (symtab_node);
589 void symtab_make_decl_local (tree);
590 symtab_node symtab_alias_ultimate_target (symtab_node,
591 enum availability *avail = NULL);
592 bool symtab_resolve_alias (symtab_node node, symtab_node target);
593 void fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target);
595 /* In cgraph.c */
596 void dump_cgraph (FILE *);
597 void debug_cgraph (void);
598 void dump_cgraph_node (FILE *, struct cgraph_node *);
599 void debug_cgraph_node (struct cgraph_node *);
600 void cgraph_remove_edge (struct cgraph_edge *);
601 void cgraph_remove_node (struct cgraph_node *);
602 void cgraph_release_function_body (struct cgraph_node *);
603 void cgraph_node_remove_callees (struct cgraph_node *node);
604 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
605 struct cgraph_node *,
606 gimple, gcov_type, int);
607 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
608 int, gcov_type, int);
609 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
610 struct cgraph_node * cgraph_create_node (tree);
611 struct cgraph_node * cgraph_create_empty_node (void);
612 struct cgraph_node * cgraph_get_create_node (tree);
613 struct cgraph_node * cgraph_get_create_real_symbol_node (tree);
614 struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
615 struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
616 HOST_WIDE_INT, tree, tree);
617 struct cgraph_node *cgraph_node_for_asm (tree);
618 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
619 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
620 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
621 struct cgraph_local_info *cgraph_local_info (tree);
622 struct cgraph_global_info *cgraph_global_info (tree);
623 struct cgraph_rtl_info *cgraph_rtl_info (tree);
624 struct cgraph_node *cgraph_create_function_alias (tree, tree);
625 void cgraph_call_node_duplication_hooks (struct cgraph_node *,
626 struct cgraph_node *);
627 void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
628 struct cgraph_edge *);
630 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
631 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
632 bool cgraph_only_called_directly_p (struct cgraph_node *);
634 bool cgraph_function_possibly_inlined_p (tree);
635 void cgraph_unnest_node (struct cgraph_node *);
637 enum availability cgraph_function_body_availability (struct cgraph_node *);
638 void cgraph_add_new_function (tree, bool);
639 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
641 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
642 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
643 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
644 bool cgraph_node_cannot_return (struct cgraph_node *);
645 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
646 bool cgraph_will_be_removed_from_program_if_no_direct_calls
647 (struct cgraph_node *node);
648 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
649 (struct cgraph_node *node);
650 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
651 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
652 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
653 bool (*) (struct cgraph_node *, void *),
654 void *,
655 bool);
656 bool cgraph_for_node_and_aliases (struct cgraph_node *,
657 bool (*) (struct cgraph_node *, void *),
658 void *, bool);
659 vec<cgraph_edge_p> collect_callers_of_node (struct cgraph_node *node);
660 void verify_cgraph (void);
661 void verify_cgraph_node (struct cgraph_node *);
662 void cgraph_mark_address_taken_node (struct cgraph_node *);
664 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
665 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
666 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
667 void *);
668 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
669 void *);
670 struct cgraph_edge_hook_list;
671 struct cgraph_node_hook_list;
672 struct cgraph_2edge_hook_list;
673 struct cgraph_2node_hook_list;
674 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
675 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
676 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
677 void *);
678 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
679 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
680 void *);
681 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
682 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
683 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
684 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
685 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
686 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
687 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
688 bool cgraph_propagate_frequency (struct cgraph_node *node);
689 struct cgraph_node * cgraph_function_node (struct cgraph_node *,
690 enum availability *avail = NULL);
692 /* In cgraphunit.c */
693 struct asm_node *add_asm_node (tree);
694 extern FILE *cgraph_dump_file;
695 void cgraph_finalize_function (tree, bool);
696 void finalize_compilation_unit (void);
697 void compile (void);
698 void init_cgraph (void);
699 bool cgraph_process_new_functions (void);
700 void cgraph_process_same_body_aliases (void);
701 void fixup_same_cpp_alias_visibility (symtab_node, symtab_node target, tree);
702 /* Initialize datastructures so DECL is a function in lowered gimple form.
703 IN_SSA is true if the gimple is in SSA. */
704 basic_block init_lowered_empty_function (tree, bool);
705 void cgraph_reset_node (struct cgraph_node *);
707 /* In cgraphclones.c */
709 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
710 struct cgraph_node *, gimple,
711 unsigned, gcov_type, int, bool);
712 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
713 int, bool, vec<cgraph_edge_p>,
714 bool);
715 tree clone_function_name (tree decl, const char *);
716 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
717 vec<cgraph_edge_p>,
718 vec<ipa_replace_map_p, va_gc> *tree_map,
719 bitmap args_to_skip,
720 const char *clone_name);
721 struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
722 bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
723 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
724 void cgraph_create_edge_including_clones (struct cgraph_node *,
725 struct cgraph_node *,
726 gimple, gimple, gcov_type, int,
727 cgraph_inline_failed_t);
728 void cgraph_materialize_all_clones (void);
729 struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
730 tree, vec<cgraph_edge_p>, bitmap);
731 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
732 vec<cgraph_edge_p>,
733 vec<ipa_replace_map_p, va_gc> *,
734 bitmap, bool, bitmap,
735 basic_block, const char *);
736 void tree_function_versioning (tree, tree, vec<ipa_replace_map_p, va_gc> *,
737 bool, bitmap, bool, bitmap, basic_block);
739 /* In cgraphbuild.c */
740 unsigned int rebuild_cgraph_edges (void);
741 void cgraph_rebuild_references (void);
742 int compute_call_stmt_bb_frequency (tree, basic_block bb);
743 void record_references_in_initializer (tree, bool);
744 void ipa_record_stmt_references (struct cgraph_node *, gimple);
746 /* In ipa.c */
747 bool symtab_remove_unreachable_nodes (bool, FILE *);
748 cgraph_node_set cgraph_node_set_new (void);
749 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
750 struct cgraph_node *);
751 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
752 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
753 void dump_cgraph_node_set (FILE *, cgraph_node_set);
754 void debug_cgraph_node_set (cgraph_node_set);
755 void free_cgraph_node_set (cgraph_node_set);
756 void cgraph_build_static_cdtor (char which, tree body, int priority);
758 varpool_node_set varpool_node_set_new (void);
759 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
760 struct varpool_node *);
761 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
762 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
763 void dump_varpool_node_set (FILE *, varpool_node_set);
764 void debug_varpool_node_set (varpool_node_set);
765 void free_varpool_node_set (varpool_node_set);
766 void ipa_discover_readonly_nonaddressable_vars (void);
767 bool varpool_externally_visible_p (struct varpool_node *);
769 /* In predict.c */
770 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
771 bool cgraph_optimize_for_size_p (struct cgraph_node *);
773 /* In varpool.c */
774 struct varpool_node *varpool_node_for_decl (tree);
775 struct varpool_node *varpool_node_for_asm (tree asmname);
776 void varpool_mark_needed_node (struct varpool_node *);
777 void debug_varpool (void);
778 void dump_varpool (FILE *);
779 void dump_varpool_node (FILE *, struct varpool_node *);
781 void varpool_finalize_decl (tree);
782 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
783 void cgraph_make_node_local (struct cgraph_node *);
784 bool cgraph_node_can_be_local_p (struct cgraph_node *);
787 void varpool_remove_node (struct varpool_node *node);
788 void varpool_finalize_named_section_flags (struct varpool_node *node);
789 bool varpool_output_variables (void);
790 bool varpool_assemble_decl (struct varpool_node *node);
791 void varpool_analyze_node (struct varpool_node *);
792 struct varpool_node * varpool_extra_name_alias (tree, tree);
793 struct varpool_node * varpool_create_variable_alias (tree, tree);
794 void varpool_reset_queue (void);
795 bool const_value_known_p (tree);
796 bool varpool_for_node_and_aliases (struct varpool_node *,
797 bool (*) (struct varpool_node *, void *),
798 void *, bool);
799 void varpool_add_new_variable (tree);
800 void symtab_initialize_asm_name_hash (void);
801 void symtab_prevail_in_asm_name_hash (symtab_node node);
802 void varpool_remove_initializer (struct varpool_node *);
805 /* Return callgraph node for given symbol and check it is a function. */
806 static inline struct cgraph_node *
807 cgraph (symtab_node node)
809 gcc_checking_assert (!node || node->symbol.type == SYMTAB_FUNCTION);
810 return (struct cgraph_node *)node;
813 /* Return varpool node for given symbol and check it is a variable. */
814 static inline struct varpool_node *
815 varpool (symtab_node node)
817 gcc_checking_assert (!node || node->symbol.type == SYMTAB_VARIABLE);
818 return (struct varpool_node *)node;
821 /* Return callgraph node for given symbol and check it is a function. */
822 static inline struct cgraph_node *
823 cgraph_get_node (const_tree decl)
825 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
826 return cgraph (symtab_get_node (decl));
829 /* Return varpool node for given symbol and check it is a function. */
830 static inline struct varpool_node *
831 varpool_get_node (const_tree decl)
833 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
834 return varpool (symtab_get_node (decl));
837 /* Return asm name of cgraph node. */
838 static inline const char *
839 cgraph_node_asm_name (struct cgraph_node *node)
841 return symtab_node_asm_name ((symtab_node)node);
844 /* Return asm name of varpool node. */
845 static inline const char *
846 varpool_node_asm_name(struct varpool_node *node)
848 return symtab_node_asm_name ((symtab_node)node);
851 /* Return name of cgraph node. */
852 static inline const char *
853 cgraph_node_name(struct cgraph_node *node)
855 return symtab_node_name ((symtab_node)node);
858 /* Return name of varpool node. */
859 static inline const char *
860 varpool_node_name(struct varpool_node *node)
862 return symtab_node_name ((symtab_node)node);
865 /* Walk all symbols. */
866 #define FOR_EACH_SYMBOL(node) \
867 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
870 /* Return first variable. */
871 static inline struct varpool_node *
872 varpool_first_variable (void)
874 symtab_node node;
875 for (node = symtab_nodes; node; node = node->symbol.next)
876 if (varpool_node *vnode = dyn_cast <varpool_node> (node))
877 return vnode;
878 return NULL;
881 /* Return next variable after NODE. */
882 static inline struct varpool_node *
883 varpool_next_variable (struct varpool_node *node)
885 symtab_node node1 = (symtab_node) node->symbol.next;
886 for (; node1; node1 = node1->symbol.next)
887 if (varpool_node *vnode1 = dyn_cast <varpool_node> (node1))
888 return vnode1;
889 return NULL;
891 /* Walk all variables. */
892 #define FOR_EACH_VARIABLE(node) \
893 for ((node) = varpool_first_variable (); \
894 (node); \
895 (node) = varpool_next_variable ((node)))
897 /* Return first reachable static variable with initializer. */
898 static inline struct varpool_node *
899 varpool_first_static_initializer (void)
901 symtab_node node;
902 for (node = symtab_nodes; node; node = node->symbol.next)
904 varpool_node *vnode = dyn_cast <varpool_node> (node);
905 if (vnode && DECL_INITIAL (node->symbol.decl))
906 return vnode;
908 return NULL;
911 /* Return next reachable static variable with initializer after NODE. */
912 static inline struct varpool_node *
913 varpool_next_static_initializer (struct varpool_node *node)
915 symtab_node node1 = (symtab_node) node->symbol.next;
916 for (; node1; node1 = node1->symbol.next)
918 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
919 if (vnode1 && DECL_INITIAL (node1->symbol.decl))
920 return vnode1;
922 return NULL;
925 /* Walk all static variables with initializer set. */
926 #define FOR_EACH_STATIC_INITIALIZER(node) \
927 for ((node) = varpool_first_static_initializer (); (node); \
928 (node) = varpool_next_static_initializer (node))
930 /* Return first reachable static variable with initializer. */
931 static inline struct varpool_node *
932 varpool_first_defined_variable (void)
934 symtab_node node;
935 for (node = symtab_nodes; node; node = node->symbol.next)
937 varpool_node *vnode = dyn_cast <varpool_node> (node);
938 if (vnode && vnode->symbol.definition)
939 return vnode;
941 return NULL;
944 /* Return next reachable static variable with initializer after NODE. */
945 static inline struct varpool_node *
946 varpool_next_defined_variable (struct varpool_node *node)
948 symtab_node node1 = (symtab_node) node->symbol.next;
949 for (; node1; node1 = node1->symbol.next)
951 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
952 if (vnode1 && vnode1->symbol.definition)
953 return vnode1;
955 return NULL;
957 /* Walk all variables with definitions in current unit. */
958 #define FOR_EACH_DEFINED_VARIABLE(node) \
959 for ((node) = varpool_first_defined_variable (); (node); \
960 (node) = varpool_next_defined_variable (node))
962 /* Return first function with body defined. */
963 static inline struct cgraph_node *
964 cgraph_first_defined_function (void)
966 symtab_node node;
967 for (node = symtab_nodes; node; node = node->symbol.next)
969 cgraph_node *cn = dyn_cast <cgraph_node> (node);
970 if (cn && cn->symbol.definition)
971 return cn;
973 return NULL;
976 /* Return next function with body defined after NODE. */
977 static inline struct cgraph_node *
978 cgraph_next_defined_function (struct cgraph_node *node)
980 symtab_node node1 = (symtab_node) node->symbol.next;
981 for (; node1; node1 = node1->symbol.next)
983 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
984 if (cn1 && cn1->symbol.definition)
985 return cn1;
987 return NULL;
990 /* Walk all functions with body defined. */
991 #define FOR_EACH_DEFINED_FUNCTION(node) \
992 for ((node) = cgraph_first_defined_function (); (node); \
993 (node) = cgraph_next_defined_function ((node)))
995 /* Return first function. */
996 static inline struct cgraph_node *
997 cgraph_first_function (void)
999 symtab_node node;
1000 for (node = symtab_nodes; node; node = node->symbol.next)
1001 if (cgraph_node *cn = dyn_cast <cgraph_node> (node))
1002 return cn;
1003 return NULL;
1006 /* Return next function. */
1007 static inline struct cgraph_node *
1008 cgraph_next_function (struct cgraph_node *node)
1010 symtab_node node1 = (symtab_node) node->symbol.next;
1011 for (; node1; node1 = node1->symbol.next)
1012 if (cgraph_node *cn1 = dyn_cast <cgraph_node> (node1))
1013 return cn1;
1014 return NULL;
1016 /* Walk all functions. */
1017 #define FOR_EACH_FUNCTION(node) \
1018 for ((node) = cgraph_first_function (); (node); \
1019 (node) = cgraph_next_function ((node)))
1021 /* Return true when NODE is a function with Gimple body defined
1022 in current unit. Functions can also be define externally or they
1023 can be thunks with no Gimple representation.
1025 Note that at WPA stage, the function body may not be present in memory. */
1027 static inline bool
1028 cgraph_function_with_gimple_body_p (struct cgraph_node *node)
1030 return node->symbol.definition && !node->thunk.thunk_p && !node->symbol.alias;
1033 /* Return first function with body defined. */
1034 static inline struct cgraph_node *
1035 cgraph_first_function_with_gimple_body (void)
1037 symtab_node node;
1038 for (node = symtab_nodes; node; node = node->symbol.next)
1040 cgraph_node *cn = dyn_cast <cgraph_node> (node);
1041 if (cn && cgraph_function_with_gimple_body_p (cn))
1042 return cn;
1044 return NULL;
1047 /* Return next reachable static variable with initializer after NODE. */
1048 static inline struct cgraph_node *
1049 cgraph_next_function_with_gimple_body (struct cgraph_node *node)
1051 symtab_node node1 = node->symbol.next;
1052 for (; node1; node1 = node1->symbol.next)
1054 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
1055 if (cn1 && cgraph_function_with_gimple_body_p (cn1))
1056 return cn1;
1058 return NULL;
1061 /* Walk all functions with body defined. */
1062 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1063 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1064 (node) = cgraph_next_function_with_gimple_body (node))
1066 /* Create a new static variable of type TYPE. */
1067 tree add_new_static_var (tree type);
1069 /* Return true if iterator CSI points to nothing. */
1070 static inline bool
1071 csi_end_p (cgraph_node_set_iterator csi)
1073 return csi.index >= csi.set->nodes.length ();
1076 /* Advance iterator CSI. */
1077 static inline void
1078 csi_next (cgraph_node_set_iterator *csi)
1080 csi->index++;
1083 /* Return the node pointed to by CSI. */
1084 static inline struct cgraph_node *
1085 csi_node (cgraph_node_set_iterator csi)
1087 return csi.set->nodes[csi.index];
1090 /* Return an iterator to the first node in SET. */
1091 static inline cgraph_node_set_iterator
1092 csi_start (cgraph_node_set set)
1094 cgraph_node_set_iterator csi;
1096 csi.set = set;
1097 csi.index = 0;
1098 return csi;
1101 /* Return true if SET contains NODE. */
1102 static inline bool
1103 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1105 cgraph_node_set_iterator csi;
1106 csi = cgraph_node_set_find (set, node);
1107 return !csi_end_p (csi);
1110 /* Return number of nodes in SET. */
1111 static inline size_t
1112 cgraph_node_set_size (cgraph_node_set set)
1114 return set->nodes.length ();
1117 /* Return true if iterator VSI points to nothing. */
1118 static inline bool
1119 vsi_end_p (varpool_node_set_iterator vsi)
1121 return vsi.index >= vsi.set->nodes.length ();
1124 /* Advance iterator VSI. */
1125 static inline void
1126 vsi_next (varpool_node_set_iterator *vsi)
1128 vsi->index++;
1131 /* Return the node pointed to by VSI. */
1132 static inline struct varpool_node *
1133 vsi_node (varpool_node_set_iterator vsi)
1135 return vsi.set->nodes[vsi.index];
1138 /* Return an iterator to the first node in SET. */
1139 static inline varpool_node_set_iterator
1140 vsi_start (varpool_node_set set)
1142 varpool_node_set_iterator vsi;
1144 vsi.set = set;
1145 vsi.index = 0;
1146 return vsi;
1149 /* Return true if SET contains NODE. */
1150 static inline bool
1151 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
1153 varpool_node_set_iterator vsi;
1154 vsi = varpool_node_set_find (set, node);
1155 return !vsi_end_p (vsi);
1158 /* Return number of nodes in SET. */
1159 static inline size_t
1160 varpool_node_set_size (varpool_node_set set)
1162 return set->nodes.length ();
1165 /* Uniquize all constants that appear in memory.
1166 Each constant in memory thus far output is recorded
1167 in `const_desc_table'. */
1169 struct GTY(()) constant_descriptor_tree {
1170 /* A MEM for the constant. */
1171 rtx rtl;
1173 /* The value of the constant. */
1174 tree value;
1176 /* Hash of value. Computing the hash from value each time
1177 hashfn is called can't work properly, as that means recursive
1178 use of the hash table during hash table expansion. */
1179 hashval_t hash;
1182 /* Return true if set is nonempty. */
1183 static inline bool
1184 cgraph_node_set_nonempty_p (cgraph_node_set set)
1186 return !set->nodes.is_empty ();
1189 /* Return true if set is nonempty. */
1190 static inline bool
1191 varpool_node_set_nonempty_p (varpool_node_set set)
1193 return !set->nodes.is_empty ();
1196 /* Return true when function NODE is only called directly or it has alias.
1197 i.e. it is not externally visible, address was not taken and
1198 it is not used in any other non-standard way. */
1200 static inline bool
1201 cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
1203 gcc_assert (!node->global.inlined_to);
1204 return (!node->symbol.force_output && !node->symbol.address_taken
1205 && !node->symbol.used_from_other_partition
1206 && !DECL_VIRTUAL_P (node->symbol.decl)
1207 && !DECL_STATIC_CONSTRUCTOR (node->symbol.decl)
1208 && !DECL_STATIC_DESTRUCTOR (node->symbol.decl)
1209 && !node->symbol.externally_visible);
1212 /* Return true when function NODE can be removed from callgraph
1213 if all direct calls are eliminated. */
1215 static inline bool
1216 varpool_can_remove_if_no_refs (struct varpool_node *node)
1218 if (DECL_EXTERNAL (node->symbol.decl))
1219 return true;
1220 return (!node->symbol.force_output && !node->symbol.used_from_other_partition
1221 && ((DECL_COMDAT (node->symbol.decl)
1222 && !node->symbol.forced_by_abi
1223 && !symtab_used_from_object_file_p ((symtab_node) node))
1224 || !node->symbol.externally_visible
1225 || DECL_HAS_VALUE_EXPR_P (node->symbol.decl)));
1228 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1229 i.e. if the variable is not externally visible or not used in some magic
1230 way (asm statement or such).
1231 The magic uses are all summarized in force_output flag. */
1233 static inline bool
1234 varpool_all_refs_explicit_p (struct varpool_node *vnode)
1236 return (vnode->symbol.definition
1237 && !vnode->symbol.externally_visible
1238 && !vnode->symbol.used_from_other_partition
1239 && !vnode->symbol.force_output);
1242 /* Constant pool accessor function. */
1243 htab_t constant_pool_htab (void);
1245 /* FIXME: inappropriate dependency of cgraph on IPA. */
1246 #include "ipa-ref-inline.h"
1248 /* Return node that alias N is aliasing. */
1250 static inline symtab_node
1251 symtab_alias_target (symtab_node n)
1253 struct ipa_ref *ref;
1254 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
1255 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1256 return ref->referred;
1259 static inline struct cgraph_node *
1260 cgraph_alias_target (struct cgraph_node *n)
1262 return dyn_cast <cgraph_node> (symtab_alias_target ((symtab_node) n));
1265 static inline struct varpool_node *
1266 varpool_alias_target (struct varpool_node *n)
1268 return dyn_cast <varpool_node> (symtab_alias_target ((symtab_node) n));
1271 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1272 Do not walk through thunks.
1273 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1275 static inline struct cgraph_node *
1276 cgraph_function_or_thunk_node (struct cgraph_node *node,
1277 enum availability *availability = NULL)
1279 struct cgraph_node *n;
1281 n = dyn_cast <cgraph_node> (symtab_alias_ultimate_target ((symtab_node)node,
1282 availability));
1283 if (!n && availability)
1284 *availability = AVAIL_NOT_AVAILABLE;
1285 return n;
1287 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1288 Do not walk through thunks.
1289 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1291 static inline struct varpool_node *
1292 varpool_variable_node (struct varpool_node *node,
1293 enum availability *availability = NULL)
1295 struct varpool_node *n;
1297 n = dyn_cast <varpool_node> (symtab_alias_ultimate_target ((symtab_node)node,
1298 availability));
1299 if (!n && availability)
1300 *availability = AVAIL_NOT_AVAILABLE;
1301 return n;
1304 /* Return true when the edge E represents a direct recursion. */
1305 static inline bool
1306 cgraph_edge_recursive_p (struct cgraph_edge *e)
1308 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
1309 if (e->caller->global.inlined_to)
1310 return e->caller->global.inlined_to->symbol.decl == callee->symbol.decl;
1311 else
1312 return e->caller->symbol.decl == callee->symbol.decl;
1315 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1316 static inline bool
1317 decl_is_tm_clone (const_tree fndecl)
1319 struct cgraph_node *n = cgraph_get_node (fndecl);
1320 if (n)
1321 return n->tm_clone;
1322 return false;
1325 /* Likewise indicate that a node is needed, i.e. reachable via some
1326 external means. */
1328 static inline void
1329 cgraph_mark_force_output_node (struct cgraph_node *node)
1331 node->symbol.force_output = 1;
1332 gcc_checking_assert (!node->global.inlined_to);
1335 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1336 or abstract function kept for debug info purposes only. */
1338 static inline bool
1339 symtab_real_symbol_p (symtab_node node)
1341 struct cgraph_node *cnode;
1343 if (!is_a <cgraph_node> (node))
1344 return true;
1345 cnode = cgraph (node);
1346 if (cnode->global.inlined_to)
1347 return false;
1348 if (cnode->abstract_and_needed)
1349 return false;
1350 return true;
1352 #endif /* GCC_CGRAPH_H */