PR other/54324
[official-gcc.git] / gcc / cgraph.h
blob28c3497c5666c6f75566406ce84bd6d517d5a3f0
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
3 2012 Free Software Foundation, Inc.
4 Contributed by Jan Hubicka
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H
25 #include "is-a.h"
26 #include "plugin-api.h"
27 #include "vec.h"
28 #include "tree.h"
29 #include "basic-block.h"
30 #include "function.h"
31 #include "ipa-ref.h"
33 /* Symbol table consists of functions and variables.
34 TODO: add labels, constant pool and aliases. */
35 enum symtab_type
37 SYMTAB_SYMBOL,
38 SYMTAB_FUNCTION,
39 SYMTAB_VARIABLE
42 /* Base of all entries in the symbol table.
43 The symtab_node is inherited by cgraph and varpol nodes. */
44 struct GTY(()) symtab_node_base
46 /* Type of the symbol. */
47 ENUM_BITFIELD (symtab_type) type : 8;
49 /* The symbols resolution. */
50 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
52 /* Set when function has address taken.
53 In current implementation it imply needed flag. */
54 unsigned address_taken : 1;
55 /* Set when variable is used from other LTRANS partition. */
56 unsigned used_from_other_partition : 1;
57 /* Set when function is available in the other LTRANS partition.
58 During WPA output it is used to mark nodes that are present in
59 multiple partitions. */
60 unsigned in_other_partition : 1;
61 /* Set when function is visible by other units. */
62 unsigned externally_visible : 1;
63 /* Needed variables might become dead by optimization. This flag
64 forces the variable to be output even if it appears dead otherwise. */
65 unsigned force_output : 1;
67 /* Ordering of all symtab entries. */
68 int order;
70 tree decl;
72 /* Vectors of referring and referenced entities. */
73 struct ipa_ref_list ref_list;
75 /* Circular list of nodes in the same comdat group if non-NULL. */
76 symtab_node same_comdat_group;
78 /* File stream where this node is being written to. */
79 struct lto_file_decl_data * lto_file_data;
81 /* Linked list of symbol table entries starting with symtab_nodes. */
82 symtab_node next;
83 symtab_node previous;
84 /* Linked list of symbols with the same asm name. There may be multiple
85 entries for single symbol name in the case of LTO resolutions,
86 existence of inline clones, or duplicated declaration. The last case
87 is a long standing bug frontends and builtin handling. */
88 symtab_node next_sharing_asm_name;
89 symtab_node previous_sharing_asm_name;
91 PTR GTY ((skip)) aux;
94 enum availability
96 /* Not yet set by cgraph_function_body_availability. */
97 AVAIL_UNSET,
98 /* Function body/variable initializer is unknown. */
99 AVAIL_NOT_AVAILABLE,
100 /* Function body/variable initializer is known but might be replaced
101 by a different one from other compilation unit and thus needs to
102 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
103 arbitrary side effects on escaping variables and functions, while
104 like AVAILABLE it might access static variables. */
105 AVAIL_OVERWRITABLE,
106 /* Function body/variable initializer is known and will be used in final
107 program. */
108 AVAIL_AVAILABLE,
109 /* Function body/variable initializer is known and all it's uses are explicitly
110 visible within current unit (ie it's address is never taken and it is not
111 exported to other units).
112 Currently used only for functions. */
113 AVAIL_LOCAL
116 /* This is the information that is put into the cgraph local structure
117 to recover a function. */
118 struct lto_file_decl_data;
120 extern const char * const cgraph_availability_names[];
121 extern const char * const ld_plugin_symbol_resolution_names[];
123 /* Information about thunk, used only for same body aliases. */
125 struct GTY(()) cgraph_thunk_info {
126 /* Information about the thunk. */
127 HOST_WIDE_INT fixed_offset;
128 HOST_WIDE_INT virtual_value;
129 tree alias;
130 bool this_adjusting;
131 bool virtual_offset_p;
132 /* Set to true when alias node is thunk. */
133 bool thunk_p;
136 /* Information about the function collected locally.
137 Available after function is analyzed. */
139 struct GTY(()) cgraph_local_info {
140 /* Set when function function is visible in current compilation unit only
141 and its address is never taken. */
142 unsigned local : 1;
144 /* Set once it has been finalized so we consider it to be output. */
145 unsigned finalized : 1;
147 /* False when there is something makes versioning impossible. */
148 unsigned versionable : 1;
150 /* False when function calling convention and signature can not be changed.
151 This is the case when __builtin_apply_args is used. */
152 unsigned can_change_signature : 1;
154 /* True when the function has been originally extern inline, but it is
155 redefined now. */
156 unsigned redefined_extern_inline : 1;
158 /* True if the function may enter serial irrevocable mode. */
159 unsigned tm_may_enter_irr : 1;
162 /* Information about the function that needs to be computed globally
163 once compilation is finished. Available only with -funit-at-a-time. */
165 struct GTY(()) cgraph_global_info {
166 /* For inline clones this points to the function they will be
167 inlined into. */
168 struct cgraph_node *inlined_to;
171 /* Information about the function that is propagated by the RTL backend.
172 Available only for functions that has been already assembled. */
174 struct GTY(()) cgraph_rtl_info {
175 unsigned int preferred_incoming_stack_boundary;
178 /* Represent which DECL tree (or reference to such tree)
179 will be replaced by another tree while versioning. */
180 struct GTY(()) ipa_replace_map
182 /* The tree that will be replaced. */
183 tree old_tree;
184 /* The new (replacing) tree. */
185 tree new_tree;
186 /* Parameter number to replace, when old_tree is NULL. */
187 int parm_num;
188 /* True when a substitution should be done, false otherwise. */
189 bool replace_p;
190 /* True when we replace a reference to old_tree. */
191 bool ref_p;
193 typedef struct ipa_replace_map *ipa_replace_map_p;
195 struct GTY(()) cgraph_clone_info
197 vec<ipa_replace_map_p, va_gc> *tree_map;
198 bitmap args_to_skip;
199 bitmap combined_args_to_skip;
203 /* The cgraph data structure.
204 Each function decl has assigned cgraph_node listing callees and callers. */
206 struct GTY(()) cgraph_node {
207 struct symtab_node_base symbol;
208 struct cgraph_edge *callees;
209 struct cgraph_edge *callers;
210 /* List of edges representing indirect calls with a yet undetermined
211 callee. */
212 struct cgraph_edge *indirect_calls;
213 /* For nested functions points to function the node is nested in. */
214 struct cgraph_node *
215 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
216 origin;
217 /* Points to first nested function, if any. */
218 struct cgraph_node *
219 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
220 nested;
221 /* Pointer to the next function with same origin, if any. */
222 struct cgraph_node *
223 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
224 next_nested;
225 /* Pointer to the next clone. */
226 struct cgraph_node *next_sibling_clone;
227 struct cgraph_node *prev_sibling_clone;
228 struct cgraph_node *clones;
229 struct cgraph_node *clone_of;
230 /* For functions with many calls sites it holds map from call expression
231 to the edge to speed up cgraph_edge function. */
232 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
233 /* Declaration node used to be clone of. */
234 tree former_clone_of;
236 /* Interprocedural passes scheduled to have their transform functions
237 applied next time we execute local pass on them. We maintain it
238 per-function in order to allow IPA passes to introduce new functions. */
239 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
241 struct cgraph_local_info local;
242 struct cgraph_global_info global;
243 struct cgraph_rtl_info rtl;
244 struct cgraph_clone_info clone;
245 struct cgraph_thunk_info thunk;
247 /* Expected number of executions: calculated in profile.c. */
248 gcov_type count;
249 /* How to scale counts at materialization time; used to merge
250 LTO units with different number of profile runs. */
251 int count_materialization_scale;
252 /* Unique id of the node. */
253 int uid;
255 /* Set when decl is an abstract function pointed to by the
256 ABSTRACT_DECL_ORIGIN of a reachable function. */
257 unsigned abstract_and_needed : 1;
258 /* Set once the function is lowered (i.e. its CFG is built). */
259 unsigned lowered : 1;
260 /* Set once the function has been instantiated and its callee
261 lists created. */
262 unsigned analyzed : 1;
263 /* Set when function is scheduled to be processed by local passes. */
264 unsigned process : 1;
265 /* Set for aliases once they got through assemble_alias. */
266 unsigned alias : 1;
267 /* Set for aliases created as C++ same body aliases. */
268 unsigned same_body_alias : 1;
269 /* How commonly executed the node is. Initialized during branch
270 probabilities pass. */
271 ENUM_BITFIELD (node_frequency) frequency : 2;
272 /* True when function can only be called at startup (from static ctor). */
273 unsigned only_called_at_startup : 1;
274 /* True when function can only be called at startup (from static dtor). */
275 unsigned only_called_at_exit : 1;
276 /* True when function is the transactional clone of a function which
277 is called only from inside transactions. */
278 /* ?? We should be able to remove this. We have enough bits in
279 cgraph to calculate it. */
280 unsigned tm_clone : 1;
281 /* True if this decl is a dispatcher for function versions. */
282 unsigned dispatcher_function : 1;
286 typedef struct cgraph_node *cgraph_node_ptr;
289 /* Function Multiversioning info. */
290 struct GTY(()) cgraph_function_version_info {
291 /* The cgraph_node for which the function version info is stored. */
292 struct cgraph_node *this_node;
293 /* Chains all the semantically identical function versions. The
294 first function in this chain is the version_info node of the
295 default function. */
296 struct cgraph_function_version_info *prev;
297 /* If this version node corresponds to a dispatcher for function
298 versions, this points to the version info node of the default
299 function, the first node in the chain. */
300 struct cgraph_function_version_info *next;
301 /* If this node corresponds to a function version, this points
302 to the dispatcher function decl, which is the function that must
303 be called to execute the right function version at run-time.
305 If this cgraph node is a dispatcher (if dispatcher_function is
306 true, in the cgraph_node struct) for function versions, this
307 points to resolver function, which holds the function body of the
308 dispatcher. The dispatcher decl is an alias to the resolver
309 function decl. */
310 tree dispatcher_resolver;
313 /* Get the cgraph_function_version_info node corresponding to node. */
314 struct cgraph_function_version_info *
315 get_cgraph_node_version (struct cgraph_node *node);
317 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
318 corresponding to cgraph_node NODE. */
319 struct cgraph_function_version_info *
320 insert_new_cgraph_node_version (struct cgraph_node *node);
322 /* Record that DECL1 and DECL2 are semantically identical function
323 versions. */
324 void record_function_versions (tree decl1, tree decl2);
326 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
327 DECL is a duplicate declaration. */
328 void delete_function_version (tree decl);
330 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
331 can appear in multiple sets. */
332 struct cgraph_node_set_def
334 struct pointer_map_t *map;
335 vec<cgraph_node_ptr> nodes;
338 typedef struct varpool_node *varpool_node_ptr;
341 /* A varpool node set is a collection of varpool nodes. A varpool node
342 can appear in multiple sets. */
343 struct varpool_node_set_def
345 struct pointer_map_t * map;
346 vec<varpool_node_ptr> nodes;
349 typedef struct cgraph_node_set_def *cgraph_node_set;
352 typedef struct varpool_node_set_def *varpool_node_set;
355 /* Iterator structure for cgraph node sets. */
356 typedef struct
358 cgraph_node_set set;
359 unsigned index;
360 } cgraph_node_set_iterator;
362 /* Iterator structure for varpool node sets. */
363 typedef struct
365 varpool_node_set set;
366 unsigned index;
367 } varpool_node_set_iterator;
369 #define DEFCIFCODE(code, string) CIF_ ## code,
370 /* Reasons for inlining failures. */
371 typedef enum cgraph_inline_failed_enum {
372 #include "cif-code.def"
373 CIF_N_REASONS
374 } cgraph_inline_failed_t;
376 /* Structure containing additional information about an indirect call. */
378 struct GTY(()) cgraph_indirect_call_info
380 /* When polymorphic is set, this field contains offset where the object which
381 was actually used in the polymorphic resides within a larger structure.
382 If agg_contents is set, the field contains the offset within the aggregate
383 from which the address to call was loaded. */
384 HOST_WIDE_INT offset;
385 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
386 HOST_WIDE_INT otr_token;
387 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
388 tree otr_type;
389 /* Index of the parameter that is called. */
390 int param_index;
391 /* ECF flags determined from the caller. */
392 int ecf_flags;
394 /* Set when the call is a virtual call with the parameter being the
395 associated object pointer rather than a simple direct call. */
396 unsigned polymorphic : 1;
397 /* Set when the call is a call of a pointer loaded from contents of an
398 aggregate at offset. */
399 unsigned agg_contents : 1;
400 /* When the previous bit is set, this one determines whether the destination
401 is loaded from a parameter passed by reference. */
402 unsigned by_ref : 1;
405 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
406 /* Expected number of executions: calculated in profile.c. */
407 gcov_type count;
408 struct cgraph_node *caller;
409 struct cgraph_node *callee;
410 struct cgraph_edge *prev_caller;
411 struct cgraph_edge *next_caller;
412 struct cgraph_edge *prev_callee;
413 struct cgraph_edge *next_callee;
414 gimple call_stmt;
415 /* Additional information about an indirect call. Not cleared when an edge
416 becomes direct. */
417 struct cgraph_indirect_call_info *indirect_info;
418 PTR GTY ((skip (""))) aux;
419 /* When equal to CIF_OK, inline this call. Otherwise, points to the
420 explanation why function was not inlined. */
421 cgraph_inline_failed_t inline_failed;
422 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
423 when the function is serialized in. */
424 unsigned int lto_stmt_uid;
425 /* Expected frequency of executions within the function.
426 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
427 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
428 int frequency;
429 /* Unique id of the edge. */
430 int uid;
431 /* Whether this edge was made direct by indirect inlining. */
432 unsigned int indirect_inlining_edge : 1;
433 /* Whether this edge describes an indirect call with an undetermined
434 callee. */
435 unsigned int indirect_unknown_callee : 1;
436 /* Whether this edge is still a dangling */
437 /* True if the corresponding CALL stmt cannot be inlined. */
438 unsigned int call_stmt_cannot_inline_p : 1;
439 /* Can this call throw externally? */
440 unsigned int can_throw_external : 1;
443 #define CGRAPH_FREQ_BASE 1000
444 #define CGRAPH_FREQ_MAX 100000
446 typedef struct cgraph_edge *cgraph_edge_p;
449 /* The varpool data structure.
450 Each static variable decl has assigned varpool_node. */
452 struct GTY(()) varpool_node {
453 struct symtab_node_base symbol;
454 /* For aliases points to declaration DECL is alias of. */
455 tree alias_of;
457 /* Set once the variable has been instantiated and its callee
458 lists created. */
459 unsigned analyzed : 1;
460 /* Set once it has been finalized so we consider it to be output. */
461 unsigned finalized : 1;
462 /* Set when variable is scheduled to be assembled. */
463 unsigned output : 1;
464 /* Set for aliases once they got through assemble_alias. Also set for
465 extra name aliases in varpool_extra_name_alias. */
466 unsigned alias : 1;
467 unsigned extra_name_alias : 1;
470 /* Every top level asm statement is put into a asm_node. */
472 struct GTY(()) asm_node {
473 /* Next asm node. */
474 struct asm_node *next;
475 /* String for this asm node. */
476 tree asm_str;
477 /* Ordering of all cgraph nodes. */
478 int order;
481 /* Symbol table entry. */
482 union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
483 chain_prev ("%h.symbol.previous"))) symtab_node_def {
484 struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
485 /* To access the following fields,
486 use the use dyn_cast or as_a to obtain the concrete type. */
487 struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
488 struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
491 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
493 template <>
494 template <>
495 inline bool
496 is_a_helper <cgraph_node>::test (symtab_node_def *p)
498 return p->symbol.type == SYMTAB_FUNCTION;
501 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
503 template <>
504 template <>
505 inline bool
506 is_a_helper <varpool_node>::test (symtab_node_def *p)
508 return p->symbol.type == SYMTAB_VARIABLE;
511 extern GTY(()) symtab_node symtab_nodes;
512 extern GTY(()) int cgraph_n_nodes;
513 extern GTY(()) int cgraph_max_uid;
514 extern GTY(()) int cgraph_edge_max_uid;
515 extern bool cgraph_global_info_ready;
516 enum cgraph_state
518 /* Frontend is parsing and finalizing functions. */
519 CGRAPH_STATE_PARSING,
520 /* Callgraph is being constructed. It is safe to add new functions. */
521 CGRAPH_STATE_CONSTRUCTION,
522 /* Callgraph is built and IPA passes are being run. */
523 CGRAPH_STATE_IPA,
524 /* Callgraph is built and all functions are transformed to SSA form. */
525 CGRAPH_STATE_IPA_SSA,
526 /* Functions are now ordered and being passed to RTL expanders. */
527 CGRAPH_STATE_EXPANSION,
528 /* All cgraph expansion is done. */
529 CGRAPH_STATE_FINISHED
531 extern enum cgraph_state cgraph_state;
532 extern bool cgraph_function_flags_ready;
533 extern cgraph_node_set cgraph_new_nodes;
535 extern GTY(()) struct asm_node *asm_nodes;
536 extern GTY(()) int symtab_order;
537 extern bool same_body_aliases_done;
539 /* In symtab.c */
540 void symtab_register_node (symtab_node);
541 void symtab_unregister_node (symtab_node);
542 void symtab_remove_node (symtab_node);
543 symtab_node symtab_get_node (const_tree);
544 symtab_node symtab_node_for_asm (const_tree asmname);
545 const char * symtab_node_asm_name (symtab_node);
546 const char * symtab_node_name (symtab_node);
547 void symtab_insert_node_to_hashtable (symtab_node);
548 void symtab_add_to_same_comdat_group (symtab_node, symtab_node);
549 void symtab_dissolve_same_comdat_group_list (symtab_node node);
550 void dump_symtab (FILE *);
551 void debug_symtab (void);
552 void dump_symtab_node (FILE *, symtab_node);
553 void debug_symtab_node (symtab_node);
554 void dump_symtab_base (FILE *, symtab_node);
555 void verify_symtab (void);
556 void verify_symtab_node (symtab_node);
557 bool verify_symtab_base (symtab_node);
558 bool symtab_used_from_object_file_p (symtab_node);
559 void symtab_make_decl_local (tree);
561 /* In cgraph.c */
562 void dump_cgraph (FILE *);
563 void debug_cgraph (void);
564 void dump_cgraph_node (FILE *, struct cgraph_node *);
565 void debug_cgraph_node (struct cgraph_node *);
566 void cgraph_remove_edge (struct cgraph_edge *);
567 void cgraph_remove_node (struct cgraph_node *);
568 void cgraph_release_function_body (struct cgraph_node *);
569 void cgraph_node_remove_callees (struct cgraph_node *node);
570 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
571 struct cgraph_node *,
572 gimple, gcov_type, int);
573 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
574 int, gcov_type, int);
575 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
576 struct cgraph_node * cgraph_create_node (tree);
577 struct cgraph_node * cgraph_create_empty_node (void);
578 struct cgraph_node * cgraph_get_create_node (tree);
579 struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
580 struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
581 HOST_WIDE_INT, tree, tree);
582 struct cgraph_node *cgraph_node_for_asm (tree);
583 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
584 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
585 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
586 struct cgraph_local_info *cgraph_local_info (tree);
587 struct cgraph_global_info *cgraph_global_info (tree);
588 struct cgraph_rtl_info *cgraph_rtl_info (tree);
589 struct cgraph_node *cgraph_create_function_alias (tree, tree);
590 void cgraph_call_node_duplication_hooks (struct cgraph_node *,
591 struct cgraph_node *);
592 void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
593 struct cgraph_edge *);
595 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
596 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
597 bool cgraph_only_called_directly_p (struct cgraph_node *);
599 bool cgraph_function_possibly_inlined_p (tree);
600 void cgraph_unnest_node (struct cgraph_node *);
602 enum availability cgraph_function_body_availability (struct cgraph_node *);
603 void cgraph_add_new_function (tree, bool);
604 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
606 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
607 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
608 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
609 bool cgraph_node_cannot_return (struct cgraph_node *);
610 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
611 bool cgraph_will_be_removed_from_program_if_no_direct_calls
612 (struct cgraph_node *node);
613 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
614 (struct cgraph_node *node);
615 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
616 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
617 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
618 bool (*) (struct cgraph_node *, void *),
619 void *,
620 bool);
621 bool cgraph_for_node_and_aliases (struct cgraph_node *,
622 bool (*) (struct cgraph_node *, void *),
623 void *, bool);
624 vec<cgraph_edge_p> collect_callers_of_node (struct cgraph_node *node);
625 void verify_cgraph (void);
626 void verify_cgraph_node (struct cgraph_node *);
627 void cgraph_mark_address_taken_node (struct cgraph_node *);
629 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
630 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
631 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
632 void *);
633 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
634 void *);
635 struct cgraph_edge_hook_list;
636 struct cgraph_node_hook_list;
637 struct cgraph_2edge_hook_list;
638 struct cgraph_2node_hook_list;
639 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
640 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
641 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
642 void *);
643 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
644 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
645 void *);
646 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
647 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
648 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
649 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
650 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
651 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
652 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
653 bool cgraph_propagate_frequency (struct cgraph_node *node);
655 /* In cgraphunit.c */
656 struct asm_node *add_asm_node (tree);
657 extern FILE *cgraph_dump_file;
658 void cgraph_finalize_function (tree, bool);
659 void finalize_compilation_unit (void);
660 void compile (void);
661 void init_cgraph (void);
662 bool cgraph_process_new_functions (void);
663 void cgraph_process_same_body_aliases (void);
664 void fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target, tree alias);
665 /* Initialize datastructures so DECL is a function in lowered gimple form.
666 IN_SSA is true if the gimple is in SSA. */
667 basic_block init_lowered_empty_function (tree decl, bool in_ssa);
669 /* In cgraphclones.c */
671 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
672 struct cgraph_node *, gimple,
673 unsigned, gcov_type, int, bool);
674 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
675 int, bool, vec<cgraph_edge_p>,
676 bool);
677 tree clone_function_name (tree decl, const char *);
678 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
679 vec<cgraph_edge_p>,
680 vec<ipa_replace_map_p, va_gc> *tree_map,
681 bitmap args_to_skip,
682 const char *clone_name);
683 struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
684 bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
685 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
686 void cgraph_create_edge_including_clones (struct cgraph_node *,
687 struct cgraph_node *,
688 gimple, gimple, gcov_type, int,
689 cgraph_inline_failed_t);
690 void cgraph_materialize_all_clones (void);
691 struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
692 tree, vec<cgraph_edge_p>, bitmap);
693 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
694 vec<cgraph_edge_p>,
695 vec<ipa_replace_map_p, va_gc> *,
696 bitmap, bool, bitmap,
697 basic_block, const char *);
698 void tree_function_versioning (tree, tree, vec<ipa_replace_map_p, va_gc> *,
699 bool, bitmap, bool, bitmap, basic_block);
701 /* In cgraphbuild.c */
702 unsigned int rebuild_cgraph_edges (void);
703 void cgraph_rebuild_references (void);
704 int compute_call_stmt_bb_frequency (tree, basic_block bb);
705 void record_references_in_initializer (tree, bool);
707 /* In ipa.c */
708 bool symtab_remove_unreachable_nodes (bool, FILE *);
709 cgraph_node_set cgraph_node_set_new (void);
710 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
711 struct cgraph_node *);
712 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
713 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
714 void dump_cgraph_node_set (FILE *, cgraph_node_set);
715 void debug_cgraph_node_set (cgraph_node_set);
716 void free_cgraph_node_set (cgraph_node_set);
717 void cgraph_build_static_cdtor (char which, tree body, int priority);
719 varpool_node_set varpool_node_set_new (void);
720 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
721 struct varpool_node *);
722 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
723 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
724 void dump_varpool_node_set (FILE *, varpool_node_set);
725 void debug_varpool_node_set (varpool_node_set);
726 void free_varpool_node_set (varpool_node_set);
727 void ipa_discover_readonly_nonaddressable_vars (void);
728 bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *);
729 bool varpool_externally_visible_p (struct varpool_node *, bool);
731 /* In predict.c */
732 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
733 bool cgraph_optimize_for_size_p (struct cgraph_node *);
735 /* In varpool.c */
736 struct varpool_node *varpool_node_for_decl (tree);
737 struct varpool_node *varpool_node_for_asm (tree asmname);
738 void varpool_mark_needed_node (struct varpool_node *);
739 void debug_varpool (void);
740 void dump_varpool (FILE *);
741 void dump_varpool_node (FILE *, struct varpool_node *);
743 void varpool_finalize_decl (tree);
744 bool decide_is_variable_needed (struct varpool_node *, tree);
745 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
746 void cgraph_make_node_local (struct cgraph_node *);
747 bool cgraph_node_can_be_local_p (struct cgraph_node *);
750 void varpool_remove_node (struct varpool_node *node);
751 void varpool_finalize_named_section_flags (struct varpool_node *node);
752 bool varpool_output_variables (void);
753 bool varpool_assemble_decl (struct varpool_node *node);
754 void varpool_analyze_node (struct varpool_node *);
755 struct varpool_node * varpool_extra_name_alias (tree, tree);
756 struct varpool_node * varpool_create_variable_alias (tree, tree);
757 void varpool_reset_queue (void);
758 bool const_value_known_p (tree);
759 bool varpool_for_node_and_aliases (struct varpool_node *,
760 bool (*) (struct varpool_node *, void *),
761 void *, bool);
762 void varpool_add_new_variable (tree);
763 void symtab_initialize_asm_name_hash (void);
764 void symtab_prevail_in_asm_name_hash (symtab_node node);
767 /* Return callgraph node for given symbol and check it is a function. */
768 static inline struct cgraph_node *
769 cgraph (symtab_node node)
771 gcc_checking_assert (!node || node->symbol.type == SYMTAB_FUNCTION);
772 return (struct cgraph_node *)node;
775 /* Return varpool node for given symbol and check it is a variable. */
776 static inline struct varpool_node *
777 varpool (symtab_node node)
779 gcc_checking_assert (!node || node->symbol.type == SYMTAB_VARIABLE);
780 return (struct varpool_node *)node;
783 /* Return callgraph node for given symbol and check it is a function. */
784 static inline struct cgraph_node *
785 cgraph_get_node (const_tree decl)
787 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
788 return cgraph (symtab_get_node (decl));
791 /* Return varpool node for given symbol and check it is a function. */
792 static inline struct varpool_node *
793 varpool_get_node (const_tree decl)
795 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
796 return varpool (symtab_get_node (decl));
799 /* Return asm name of cgraph node. */
800 static inline const char *
801 cgraph_node_asm_name(struct cgraph_node *node)
803 return symtab_node_asm_name ((symtab_node)node);
806 /* Return asm name of varpool node. */
807 static inline const char *
808 varpool_node_asm_name(struct varpool_node *node)
810 return symtab_node_asm_name ((symtab_node)node);
813 /* Return name of cgraph node. */
814 static inline const char *
815 cgraph_node_name(struct cgraph_node *node)
817 return symtab_node_name ((symtab_node)node);
820 /* Return name of varpool node. */
821 static inline const char *
822 varpool_node_name(struct varpool_node *node)
824 return symtab_node_name ((symtab_node)node);
827 /* Walk all symbols. */
828 #define FOR_EACH_SYMBOL(node) \
829 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
832 /* Return first variable. */
833 static inline struct varpool_node *
834 varpool_first_variable (void)
836 symtab_node node;
837 for (node = symtab_nodes; node; node = node->symbol.next)
838 if (varpool_node *vnode = dyn_cast <varpool_node> (node))
839 return vnode;
840 return NULL;
843 /* Return next variable after NODE. */
844 static inline struct varpool_node *
845 varpool_next_variable (struct varpool_node *node)
847 symtab_node node1 = (symtab_node) node->symbol.next;
848 for (; node1; node1 = node1->symbol.next)
849 if (varpool_node *vnode1 = dyn_cast <varpool_node> (node1))
850 return vnode1;
851 return NULL;
853 /* Walk all variables. */
854 #define FOR_EACH_VARIABLE(node) \
855 for ((node) = varpool_first_variable (); \
856 (node); \
857 (node) = varpool_next_variable ((node)))
859 /* Return first reachable static variable with initializer. */
860 static inline struct varpool_node *
861 varpool_first_static_initializer (void)
863 symtab_node node;
864 for (node = symtab_nodes; node; node = node->symbol.next)
866 varpool_node *vnode = dyn_cast <varpool_node> (node);
867 if (vnode && DECL_INITIAL (node->symbol.decl))
868 return vnode;
870 return NULL;
873 /* Return next reachable static variable with initializer after NODE. */
874 static inline struct varpool_node *
875 varpool_next_static_initializer (struct varpool_node *node)
877 symtab_node node1 = (symtab_node) node->symbol.next;
878 for (; node1; node1 = node1->symbol.next)
880 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
881 if (vnode1 && DECL_INITIAL (node1->symbol.decl))
882 return vnode1;
884 return NULL;
887 /* Walk all static variables with initializer set. */
888 #define FOR_EACH_STATIC_INITIALIZER(node) \
889 for ((node) = varpool_first_static_initializer (); (node); \
890 (node) = varpool_next_static_initializer (node))
892 /* Return first reachable static variable with initializer. */
893 static inline struct varpool_node *
894 varpool_first_defined_variable (void)
896 symtab_node node;
897 for (node = symtab_nodes; node; node = node->symbol.next)
899 varpool_node *vnode = dyn_cast <varpool_node> (node);
900 if (vnode && vnode->analyzed)
901 return vnode;
903 return NULL;
906 /* Return next reachable static variable with initializer after NODE. */
907 static inline struct varpool_node *
908 varpool_next_defined_variable (struct varpool_node *node)
910 symtab_node node1 = (symtab_node) node->symbol.next;
911 for (; node1; node1 = node1->symbol.next)
913 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
914 if (vnode1 && vnode1->analyzed)
915 return vnode1;
917 return NULL;
919 /* Walk all variables with definitions in current unit. */
920 #define FOR_EACH_DEFINED_VARIABLE(node) \
921 for ((node) = varpool_first_defined_variable (); (node); \
922 (node) = varpool_next_defined_variable (node))
924 /* Return first function with body defined. */
925 static inline struct cgraph_node *
926 cgraph_first_defined_function (void)
928 symtab_node node;
929 for (node = symtab_nodes; node; node = node->symbol.next)
931 cgraph_node *cn = dyn_cast <cgraph_node> (node);
932 if (cn && cn->analyzed)
933 return cn;
935 return NULL;
938 /* Return next function with body defined after NODE. */
939 static inline struct cgraph_node *
940 cgraph_next_defined_function (struct cgraph_node *node)
942 symtab_node node1 = (symtab_node) node->symbol.next;
943 for (; node1; node1 = node1->symbol.next)
945 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
946 if (cn1 && cn1->analyzed)
947 return cn1;
949 return NULL;
952 /* Walk all functions with body defined. */
953 #define FOR_EACH_DEFINED_FUNCTION(node) \
954 for ((node) = cgraph_first_defined_function (); (node); \
955 (node) = cgraph_next_defined_function ((node)))
957 /* Return first function. */
958 static inline struct cgraph_node *
959 cgraph_first_function (void)
961 symtab_node node;
962 for (node = symtab_nodes; node; node = node->symbol.next)
963 if (cgraph_node *cn = dyn_cast <cgraph_node> (node))
964 return cn;
965 return NULL;
968 /* Return next function. */
969 static inline struct cgraph_node *
970 cgraph_next_function (struct cgraph_node *node)
972 symtab_node node1 = (symtab_node) node->symbol.next;
973 for (; node1; node1 = node1->symbol.next)
974 if (cgraph_node *cn1 = dyn_cast <cgraph_node> (node1))
975 return cn1;
976 return NULL;
978 /* Walk all functions. */
979 #define FOR_EACH_FUNCTION(node) \
980 for ((node) = cgraph_first_function (); (node); \
981 (node) = cgraph_next_function ((node)))
983 /* Return true when NODE is a function with Gimple body defined
984 in current unit. Functions can also be define externally or they
985 can be thunks with no Gimple representation.
987 Note that at WPA stage, the function body may not be present in memory. */
989 static inline bool
990 cgraph_function_with_gimple_body_p (struct cgraph_node *node)
992 return node->analyzed && !node->thunk.thunk_p && !node->alias;
995 /* Return first function with body defined. */
996 static inline struct cgraph_node *
997 cgraph_first_function_with_gimple_body (void)
999 symtab_node node;
1000 for (node = symtab_nodes; node; node = node->symbol.next)
1002 cgraph_node *cn = dyn_cast <cgraph_node> (node);
1003 if (cn && cgraph_function_with_gimple_body_p (cn))
1004 return cn;
1006 return NULL;
1009 /* Return next reachable static variable with initializer after NODE. */
1010 static inline struct cgraph_node *
1011 cgraph_next_function_with_gimple_body (struct cgraph_node *node)
1013 symtab_node node1 = node->symbol.next;
1014 for (; node1; node1 = node1->symbol.next)
1016 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
1017 if (cn1 && cgraph_function_with_gimple_body_p (cn1))
1018 return cn1;
1020 return NULL;
1023 /* Walk all functions with body defined. */
1024 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1025 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1026 (node) = cgraph_next_function_with_gimple_body (node))
1028 /* Create a new static variable of type TYPE. */
1029 tree add_new_static_var (tree type);
1031 /* Return true if iterator CSI points to nothing. */
1032 static inline bool
1033 csi_end_p (cgraph_node_set_iterator csi)
1035 return csi.index >= csi.set->nodes.length ();
1038 /* Advance iterator CSI. */
1039 static inline void
1040 csi_next (cgraph_node_set_iterator *csi)
1042 csi->index++;
1045 /* Return the node pointed to by CSI. */
1046 static inline struct cgraph_node *
1047 csi_node (cgraph_node_set_iterator csi)
1049 return csi.set->nodes[csi.index];
1052 /* Return an iterator to the first node in SET. */
1053 static inline cgraph_node_set_iterator
1054 csi_start (cgraph_node_set set)
1056 cgraph_node_set_iterator csi;
1058 csi.set = set;
1059 csi.index = 0;
1060 return csi;
1063 /* Return true if SET contains NODE. */
1064 static inline bool
1065 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1067 cgraph_node_set_iterator csi;
1068 csi = cgraph_node_set_find (set, node);
1069 return !csi_end_p (csi);
1072 /* Return number of nodes in SET. */
1073 static inline size_t
1074 cgraph_node_set_size (cgraph_node_set set)
1076 return set->nodes.length ();
1079 /* Return true if iterator VSI points to nothing. */
1080 static inline bool
1081 vsi_end_p (varpool_node_set_iterator vsi)
1083 return vsi.index >= vsi.set->nodes.length ();
1086 /* Advance iterator VSI. */
1087 static inline void
1088 vsi_next (varpool_node_set_iterator *vsi)
1090 vsi->index++;
1093 /* Return the node pointed to by VSI. */
1094 static inline struct varpool_node *
1095 vsi_node (varpool_node_set_iterator vsi)
1097 return vsi.set->nodes[vsi.index];
1100 /* Return an iterator to the first node in SET. */
1101 static inline varpool_node_set_iterator
1102 vsi_start (varpool_node_set set)
1104 varpool_node_set_iterator vsi;
1106 vsi.set = set;
1107 vsi.index = 0;
1108 return vsi;
1111 /* Return true if SET contains NODE. */
1112 static inline bool
1113 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
1115 varpool_node_set_iterator vsi;
1116 vsi = varpool_node_set_find (set, node);
1117 return !vsi_end_p (vsi);
1120 /* Return number of nodes in SET. */
1121 static inline size_t
1122 varpool_node_set_size (varpool_node_set set)
1124 return set->nodes.length ();
1127 /* Uniquize all constants that appear in memory.
1128 Each constant in memory thus far output is recorded
1129 in `const_desc_table'. */
1131 struct GTY(()) constant_descriptor_tree {
1132 /* A MEM for the constant. */
1133 rtx rtl;
1135 /* The value of the constant. */
1136 tree value;
1138 /* Hash of value. Computing the hash from value each time
1139 hashfn is called can't work properly, as that means recursive
1140 use of the hash table during hash table expansion. */
1141 hashval_t hash;
1144 /* Return true if set is nonempty. */
1145 static inline bool
1146 cgraph_node_set_nonempty_p (cgraph_node_set set)
1148 return !set->nodes.is_empty ();
1151 /* Return true if set is nonempty. */
1152 static inline bool
1153 varpool_node_set_nonempty_p (varpool_node_set set)
1155 return !set->nodes.is_empty ();
1158 /* Return true when function NODE is only called directly or it has alias.
1159 i.e. it is not externally visible, address was not taken and
1160 it is not used in any other non-standard way. */
1162 static inline bool
1163 cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
1165 gcc_assert (!node->global.inlined_to);
1166 return (!node->symbol.force_output && !node->symbol.address_taken
1167 && !node->symbol.used_from_other_partition
1168 && !DECL_STATIC_CONSTRUCTOR (node->symbol.decl)
1169 && !DECL_STATIC_DESTRUCTOR (node->symbol.decl)
1170 && !node->symbol.externally_visible);
1173 /* Return true when function NODE can be removed from callgraph
1174 if all direct calls are eliminated. */
1176 static inline bool
1177 varpool_can_remove_if_no_refs (struct varpool_node *node)
1179 if (DECL_EXTERNAL (node->symbol.decl))
1180 return true;
1181 return (!node->symbol.force_output && !node->symbol.used_from_other_partition
1182 && ((DECL_COMDAT (node->symbol.decl)
1183 && !symtab_used_from_object_file_p ((symtab_node) node))
1184 || !node->symbol.externally_visible
1185 || DECL_HAS_VALUE_EXPR_P (node->symbol.decl)));
1188 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1189 i.e. if the variable is not externally visible or not used in some magic
1190 way (asm statement or such).
1191 The magic uses are all summarized in force_output flag. */
1193 static inline bool
1194 varpool_all_refs_explicit_p (struct varpool_node *vnode)
1196 return (vnode->analyzed
1197 && !vnode->symbol.externally_visible
1198 && !vnode->symbol.used_from_other_partition
1199 && !vnode->symbol.force_output);
1202 /* Constant pool accessor function. */
1203 htab_t constant_pool_htab (void);
1205 /* FIXME: inappropriate dependency of cgraph on IPA. */
1206 #include "ipa-ref-inline.h"
1208 /* Return node that alias N is aliasing. */
1210 static inline struct cgraph_node *
1211 cgraph_alias_aliased_node (struct cgraph_node *n)
1213 struct ipa_ref *ref;
1215 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
1216 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1217 if (is_a <cgraph_node> (ref->referred))
1218 return ipa_ref_node (ref);
1219 return NULL;
1222 /* Return node that alias N is aliasing. */
1224 static inline struct varpool_node *
1225 varpool_alias_aliased_node (struct varpool_node *n)
1227 struct ipa_ref *ref;
1229 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
1230 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1231 if (is_a <varpool_node> (ref->referred))
1232 return ipa_ref_varpool_node (ref);
1233 return NULL;
1236 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1237 Walk through thunk, too.
1238 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1240 static inline struct cgraph_node *
1241 cgraph_function_node (struct cgraph_node *node, enum availability *availability)
1243 if (availability)
1244 *availability = cgraph_function_body_availability (node);
1245 while (node)
1247 if (node->alias && node->analyzed)
1248 node = cgraph_alias_aliased_node (node);
1249 else if (node->thunk.thunk_p)
1250 node = node->callees->callee;
1251 else
1252 return node;
1253 if (node && availability)
1255 enum availability a;
1256 a = cgraph_function_body_availability (node);
1257 if (a < *availability)
1258 *availability = a;
1261 if (availability)
1262 *availability = AVAIL_NOT_AVAILABLE;
1263 return NULL;
1266 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1267 Do not walk through thunks.
1268 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1270 static inline struct cgraph_node *
1271 cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability *availability)
1273 if (availability)
1274 *availability = cgraph_function_body_availability (node);
1275 while (node)
1277 if (node->alias && node->analyzed)
1278 node = cgraph_alias_aliased_node (node);
1279 else
1280 return node;
1281 if (node && availability)
1283 enum availability a;
1284 a = cgraph_function_body_availability (node);
1285 if (a < *availability)
1286 *availability = a;
1289 if (availability)
1290 *availability = AVAIL_NOT_AVAILABLE;
1291 return NULL;
1294 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1295 Do not walk through thunks.
1296 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1298 static inline struct varpool_node *
1299 varpool_variable_node (struct varpool_node *node, enum availability *availability)
1301 if (availability)
1302 *availability = cgraph_variable_initializer_availability (node);
1303 while (node)
1305 if (node->alias && node->analyzed)
1306 node = varpool_alias_aliased_node (node);
1307 else
1308 return node;
1309 if (node && availability)
1311 enum availability a;
1312 a = cgraph_variable_initializer_availability (node);
1313 if (a < *availability)
1314 *availability = a;
1317 if (availability)
1318 *availability = AVAIL_NOT_AVAILABLE;
1319 return NULL;
1322 /* Return true when the edge E represents a direct recursion. */
1323 static inline bool
1324 cgraph_edge_recursive_p (struct cgraph_edge *e)
1326 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
1327 if (e->caller->global.inlined_to)
1328 return e->caller->global.inlined_to->symbol.decl == callee->symbol.decl;
1329 else
1330 return e->caller->symbol.decl == callee->symbol.decl;
1333 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1334 static inline bool
1335 decl_is_tm_clone (const_tree fndecl)
1337 struct cgraph_node *n = cgraph_get_node (fndecl);
1338 if (n)
1339 return n->tm_clone;
1340 return false;
1343 /* Likewise indicate that a node is needed, i.e. reachable via some
1344 external means. */
1346 static inline void
1347 cgraph_mark_force_output_node (struct cgraph_node *node)
1349 node->symbol.force_output = 1;
1350 gcc_checking_assert (!node->global.inlined_to);
1353 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1354 or extern function kept around just for inlining. */
1356 static inline bool
1357 symtab_real_symbol_p (symtab_node node)
1359 struct cgraph_node *cnode;
1360 struct ipa_ref *ref;
1362 if (!is_a <cgraph_node> (node))
1363 return true;
1364 cnode = cgraph (node);
1365 if (cnode->global.inlined_to)
1366 return false;
1367 if (cnode->abstract_and_needed)
1368 return false;
1369 /* We keep virtual clones in symtab. */
1370 if (!cnode->analyzed
1371 || DECL_EXTERNAL (cnode->symbol.decl))
1372 return (cnode->callers
1373 || ipa_ref_list_referring_iterate (&cnode->symbol.ref_list, 0, ref));
1374 return true;
1376 #endif /* GCC_CGRAPH_H */