2014-08-11 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / cgraph.h
blob13c09af2a0583cb470ebc9eca3bab1bda6488145
1 /* Callgraph handling code.
2 Copyright (C) 2003-2014 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 "hash-map.h"
25 #include "is-a.h"
26 #include "plugin-api.h"
27 #include "vec.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 /* Section names are stored as reference counted strings in GGC safe hashtable
42 (to make them survive through PCH). */
44 struct GTY(()) section_hash_entry_d
46 int ref_count;
47 char *name; /* As long as this datastructure stays in GGC, we can not put
48 string at the tail of structure of GGC dies in horrible
49 way */
52 typedef struct section_hash_entry_d section_hash_entry;
54 enum availability
56 /* Not yet set by cgraph_function_body_availability. */
57 AVAIL_UNSET,
58 /* Function body/variable initializer is unknown. */
59 AVAIL_NOT_AVAILABLE,
60 /* Function body/variable initializer is known but might be replaced
61 by a different one from other compilation unit and thus needs to
62 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
63 arbitrary side effects on escaping variables and functions, while
64 like AVAILABLE it might access static variables. */
65 AVAIL_INTERPOSABLE,
66 /* Function body/variable initializer is known and will be used in final
67 program. */
68 AVAIL_AVAILABLE,
69 /* Function body/variable initializer is known and all it's uses are
70 explicitly visible within current unit (ie it's address is never taken and
71 it is not exported to other units). Currently used only for functions. */
72 AVAIL_LOCAL
75 /* Classification of symbols WRT partitioning. */
76 enum symbol_partitioning_class
78 /* External declarations are ignored by partitioning algorithms and they are
79 added into the boundary later via compute_ltrans_boundary. */
80 SYMBOL_EXTERNAL,
81 /* Partitioned symbols are pur into one of partitions. */
82 SYMBOL_PARTITION,
83 /* Duplicated symbols (such as comdat or constant pool references) are
84 copied into every node needing them via add_symbol_to_partition. */
85 SYMBOL_DUPLICATE
88 /* Base of all entries in the symbol table.
89 The symtab_node is inherited by cgraph and varpol nodes. */
90 class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
91 chain_next ("%h.next"), chain_prev ("%h.previous")))
92 symtab_node
94 public:
95 /* Return name. */
96 const char *name () const;
98 /* Return asm name. */
99 const char * asm_name () const;
101 /* Add node into symbol table. This function is not used directly, but via
102 cgraph/varpool node creation routines. */
103 void register_symbol (void);
105 /* Remove symbol from symbol table. */
106 void remove (void);
108 /* Dump symtab node to F. */
109 void dump (FILE *f);
111 /* Dump symtab node to stderr. */
112 void DEBUG_FUNCTION debug (void);
114 /* Verify consistency of node. */
115 void DEBUG_FUNCTION verify (void);
117 /* Return ipa reference from this symtab_node to
118 REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
119 of the use and STMT the statement (if it exists). */
120 struct ipa_ref *add_reference (symtab_node *referred_node,
121 enum ipa_ref_use use_type);
123 /* Return ipa reference from this symtab_node to
124 REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
125 of the use and STMT the statement (if it exists). */
126 struct ipa_ref *add_reference (symtab_node *referred_node,
127 enum ipa_ref_use use_type, gimple stmt);
129 /* If VAL is a reference to a function or a variable, add a reference from
130 this symtab_node to the corresponding symbol table node. USE_TYPE specify
131 type of the use and STMT the statement (if it exists). Return the new
132 reference or NULL if none was created. */
133 struct ipa_ref *maybe_add_reference (tree val, enum ipa_ref_use use_type,
134 gimple stmt);
136 /* Clone all references from symtab NODE to this symtab_node. */
137 void clone_references (symtab_node *node);
139 /* Remove all stmt references in non-speculative references.
140 Those are not maintained during inlining & clonning.
141 The exception are speculative references that are updated along
142 with callgraph edges associated with them. */
143 void clone_referring (symtab_node *node);
145 /* Clone reference REF to this symtab_node and set its stmt to STMT. */
146 struct ipa_ref *clone_reference (struct ipa_ref *ref, gimple stmt);
148 /* Find the structure describing a reference to REFERRED_NODE
149 and associated with statement STMT. */
150 struct ipa_ref *find_reference (symtab_node *referred_node, gimple stmt,
151 unsigned int lto_stmt_uid);
153 /* Remove all references that are associated with statement STMT. */
154 void remove_stmt_references (gimple stmt);
156 /* Remove all stmt references in non-speculative references.
157 Those are not maintained during inlining & clonning.
158 The exception are speculative references that are updated along
159 with callgraph edges associated with them. */
160 void clear_stmts_in_references (void);
162 /* Remove all references in ref list. */
163 void remove_all_references (void);
165 /* Remove all referring items in ref list. */
166 void remove_all_referring (void);
168 /* Dump references in ref list to FILE. */
169 void dump_references (FILE *file);
171 /* Dump referring in list to FILE. */
172 void dump_referring (FILE *);
174 /* Iterates I-th reference in the list, REF is also set. */
175 struct ipa_ref *iterate_reference (unsigned i, struct ipa_ref *&ref);
177 /* Iterates I-th referring item in the list, REF is also set. */
178 struct ipa_ref *iterate_referring (unsigned i, struct ipa_ref *&ref);
180 /* Iterates I-th referring alias item in the list, REF is also set. */
181 struct ipa_ref *iterate_direct_aliases (unsigned i, struct ipa_ref *&ref);
183 /* Return true if symtab node and TARGET represents
184 semantically equivalent symbols. */
185 bool semantically_equivalent_p (symtab_node *target);
187 /* Classify symbol symtab node for partitioning. */
188 enum symbol_partitioning_class get_partitioning_class (void);
190 /* Return comdat group. */
191 tree get_comdat_group ()
193 return x_comdat_group;
196 /* Return comdat group as identifier_node. */
197 tree get_comdat_group_id ()
199 if (x_comdat_group && TREE_CODE (x_comdat_group) != IDENTIFIER_NODE)
200 x_comdat_group = DECL_ASSEMBLER_NAME (x_comdat_group);
201 return x_comdat_group;
204 /* Set comdat group. */
205 void set_comdat_group (tree group)
207 gcc_checking_assert (!group || TREE_CODE (group) == IDENTIFIER_NODE
208 || DECL_P (group));
209 x_comdat_group = group;
212 /* Return section as string. */
213 const char * get_section ()
215 if (!x_section)
216 return NULL;
217 return x_section->name;
220 /* Remove node from same comdat group. */
221 void remove_from_same_comdat_group (void);
223 /* Add this symtab_node to the same comdat group that OLD is in. */
224 void add_to_same_comdat_group (symtab_node *old_node);
226 /* Dissolve the same_comdat_group list in which NODE resides. */
227 void dissolve_same_comdat_group_list (void);
229 /* Return true when symtab_node is known to be used from other (non-LTO)
230 object file. Known only when doing LTO via linker plugin. */
231 bool used_from_object_file_p (void);
233 /* Walk the alias chain to return the symbol NODE is alias of.
234 If NODE is not an alias, return NODE.
235 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
236 symtab_node *ultimate_alias_target (enum availability *avail = NULL);
238 /* Return next reachable static symbol with initializer after NODE. */
239 inline symtab_node *next_defined_symbol (void);
241 /* Add reference recording that symtab node is alias of TARGET.
242 The function can fail in the case of aliasing cycles; in this case
243 it returns false. */
244 bool resolve_alias (symtab_node *target);
246 /* C++ FE sometimes change linkage flags after producing same
247 body aliases. */
248 void fixup_same_cpp_alias_visibility (symtab_node *target);
250 /* Call calback on symtab node and aliases associated to this node.
251 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
252 skipped. */
253 bool call_for_symbol_and_aliases (bool (*callback) (symtab_node *, void *),
254 void *data,
255 bool include_overwrite);
257 /* If node can not be interposable by static or dynamic linker to point to
258 different definition, return this symbol. Otherwise look for alias with
259 such property and if none exists, introduce new one. */
260 symtab_node *noninterposable_alias (void);
262 /* Return node that alias is aliasing. */
263 inline symtab_node *get_alias_target (void);
265 /* Set section for symbol and its aliases. */
266 void set_section (const char *section);
268 /* Set section, do not recurse into aliases.
269 When one wants to change section of symbol and its aliases,
270 use set_section. */
271 void set_section_for_node (const char *section);
273 /* Set initialization priority to PRIORITY. */
274 void set_init_priority (priority_type priority);
276 /* Return the initialization priority. */
277 priority_type get_init_priority ();
279 /* Return availability of NODE. */
280 enum availability get_availability (void);
282 /* Make DECL local. */
283 void make_decl_local (void);
285 /* Return true if list contains an alias. */
286 bool has_aliases_p (void);
288 /* Return true when the symbol is real symbol, i.e. it is not inline clone
289 or abstract function kept for debug info purposes only. */
290 bool real_symbol_p (void);
292 /* Return true if NODE can be discarded by linker from the binary. */
293 inline bool
294 can_be_discarded_p (void)
296 return (DECL_EXTERNAL (decl)
297 || (get_comdat_group ()
298 && resolution != LDPR_PREVAILING_DEF
299 && resolution != LDPR_PREVAILING_DEF_IRONLY
300 && resolution != LDPR_PREVAILING_DEF_IRONLY_EXP));
303 /* Return true if NODE is local to a particular COMDAT group, and must not
304 be named from outside the COMDAT. This is used for C++ decloned
305 constructors. */
306 inline bool comdat_local_p (void)
308 return (same_comdat_group && !TREE_PUBLIC (decl));
311 /* Return true if ONE and TWO are part of the same COMDAT group. */
312 inline bool in_same_comdat_group_p (symtab_node *target);
314 /* Return true when there is a reference to node and it is not vtable. */
315 bool address_taken_from_non_vtable_p (void);
317 /* Return true if symbol is known to be nonzero. */
318 bool nonzero_address ();
320 /* Return symbol table node associated with DECL, if any,
321 and NULL otherwise. */
322 static inline symtab_node *get (const_tree decl)
324 #ifdef ENABLE_CHECKING
325 /* Check that we are called for sane type of object - functions
326 and static or external variables. */
327 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
328 || (TREE_CODE (decl) == VAR_DECL
329 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
330 || in_lto_p)));
331 /* Check that the mapping is sane - perhaps this check can go away,
332 but at the moment frontends tends to corrupt the mapping by calling
333 memcpy/memset on the tree nodes. */
334 gcc_checking_assert (!decl->decl_with_vis.symtab_node
335 || decl->decl_with_vis.symtab_node->decl == decl);
336 #endif
337 return decl->decl_with_vis.symtab_node;
340 /* Dump symbol table to F. */
341 static void dump_table (FILE *);
343 /* Dump symbol table to stderr. */
344 static inline DEBUG_FUNCTION void debug_symtab (void)
346 dump_table (stderr);
349 /* Verify symbol table for internal consistency. */
350 static DEBUG_FUNCTION void verify_symtab_nodes (void);
352 /* Return true when NODE is known to be used from other (non-LTO)
353 object file. Known only when doing LTO via linker plugin. */
354 static bool used_from_object_file_p_worker (symtab_node *node);
356 /* Type of the symbol. */
357 ENUM_BITFIELD (symtab_type) type : 8;
359 /* The symbols resolution. */
360 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
362 /*** Flags representing the symbol type. ***/
364 /* True when symbol corresponds to a definition in current unit.
365 set via cgraph_finalize_function or varpool_finalize_decl */
366 unsigned definition : 1;
367 /* True when symbol is an alias.
368 Set by ssemble_alias. */
369 unsigned alias : 1;
370 /* True when alias is a weakref. */
371 unsigned weakref : 1;
372 /* C++ frontend produce same body aliases and extra name aliases for
373 virtual functions and vtables that are obviously equivalent.
374 Those aliases are bit special, especially because C++ frontend
375 visibility code is so ugly it can not get them right at first time
376 and their visibility needs to be copied from their "masters" at
377 the end of parsing. */
378 unsigned cpp_implicit_alias : 1;
379 /* Set once the definition was analyzed. The list of references and
380 other properties are built during analysis. */
381 unsigned analyzed : 1;
382 /* Set for write-only variables. */
383 unsigned writeonly : 1;
386 /*** Visibility and linkage flags. ***/
388 /* Set when function is visible by other units. */
389 unsigned externally_visible : 1;
390 /* The symbol will be assumed to be used in an invisible way (like
391 by an toplevel asm statement). */
392 unsigned force_output : 1;
393 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
394 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
395 to static and it does not inhibit optimization. */
396 unsigned forced_by_abi : 1;
397 /* True when the name is known to be unique and thus it does not need mangling. */
398 unsigned unique_name : 1;
399 /* Specify whether the section was set by user or by
400 compiler via -ffunction-sections. */
401 unsigned implicit_section : 1;
402 /* True when body and other characteristics have been removed by
403 symtab_remove_unreachable_nodes. */
404 unsigned body_removed : 1;
406 /*** WHOPR Partitioning flags.
407 These flags are used at ltrans stage when only part of the callgraph is
408 available. ***/
410 /* Set when variable is used from other LTRANS partition. */
411 unsigned used_from_other_partition : 1;
412 /* Set when function is available in the other LTRANS partition.
413 During WPA output it is used to mark nodes that are present in
414 multiple partitions. */
415 unsigned in_other_partition : 1;
419 /*** other flags. ***/
421 /* Set when symbol has address taken. */
422 unsigned address_taken : 1;
423 /* Set when init priority is set. */
424 unsigned in_init_priority_hash : 1;
427 /* Ordering of all symtab entries. */
428 int order;
430 /* Declaration representing the symbol. */
431 tree decl;
433 /* Linked list of symbol table entries starting with symtab_nodes. */
434 symtab_node *next;
435 symtab_node *previous;
437 /* Linked list of symbols with the same asm name. There may be multiple
438 entries for single symbol name during LTO, because symbols are renamed
439 only after partitioning.
441 Because inline clones are kept in the assembler name has, they also produce
442 duplicate entries.
444 There are also several long standing bugs where frontends and builtin
445 code produce duplicated decls. */
446 symtab_node *next_sharing_asm_name;
447 symtab_node *previous_sharing_asm_name;
449 /* Circular list of nodes in the same comdat group if non-NULL. */
450 symtab_node *same_comdat_group;
452 /* Vectors of referring and referenced entities. */
453 struct ipa_ref_list ref_list;
455 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
456 depending to what was known to frontend on the creation time.
457 Once alias is resolved, this pointer become NULL. */
458 tree alias_target;
460 /* File stream where this node is being written to. */
461 struct lto_file_decl_data * lto_file_data;
463 PTR GTY ((skip)) aux;
465 /* Comdat group the symbol is in. Can be private if GGC allowed that. */
466 tree x_comdat_group;
468 /* Section name. Again can be private, if allowed. */
469 section_hash_entry *x_section;
471 protected:
472 /* Dump base fields of symtab nodes to F. Not to be used directly. */
473 void dump_base (FILE *);
475 /* Verify common part of symtab node. */
476 bool DEBUG_FUNCTION verify_base (void);
478 /* Remove node from symbol table. This function is not used directly, but via
479 cgraph/varpool node removal routines. */
480 void unregister (void);
482 /* Return the initialization and finalization priority information for
483 DECL. If there is no previous priority information, a freshly
484 allocated structure is returned. */
485 struct symbol_priority_map *priority_info (void);
487 private:
488 /* Worker for set_section. */
489 static bool set_section (symtab_node *n, void *s);
491 /* Worker for symtab_resolve_alias. */
492 static bool set_implicit_section (symtab_node *n, void *);
494 /* Worker searching noninterposable alias. */
495 static bool noninterposable_alias (symtab_node *node, void *data);
498 /* Walk all aliases for NODE. */
499 #define FOR_EACH_ALIAS(node, alias) \
500 for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
502 /* This is the information that is put into the cgraph local structure
503 to recover a function. */
504 struct lto_file_decl_data;
506 extern const char * const cgraph_availability_names[];
507 extern const char * const ld_plugin_symbol_resolution_names[];
508 extern const char * const tls_model_names[];
510 /* Information about thunk, used only for same body aliases. */
512 struct GTY(()) cgraph_thunk_info {
513 /* Information about the thunk. */
514 HOST_WIDE_INT fixed_offset;
515 HOST_WIDE_INT virtual_value;
516 tree alias;
517 bool this_adjusting;
518 bool virtual_offset_p;
519 /* Set to true when alias node is thunk. */
520 bool thunk_p;
523 /* Information about the function collected locally.
524 Available after function is analyzed. */
526 struct GTY(()) cgraph_local_info {
527 /* Set when function function is visible in current compilation unit only
528 and its address is never taken. */
529 unsigned local : 1;
531 /* False when there is something makes versioning impossible. */
532 unsigned versionable : 1;
534 /* False when function calling convention and signature can not be changed.
535 This is the case when __builtin_apply_args is used. */
536 unsigned can_change_signature : 1;
538 /* True when the function has been originally extern inline, but it is
539 redefined now. */
540 unsigned redefined_extern_inline : 1;
542 /* True if the function may enter serial irrevocable mode. */
543 unsigned tm_may_enter_irr : 1;
546 /* Information about the function that needs to be computed globally
547 once compilation is finished. Available only with -funit-at-a-time. */
549 struct GTY(()) cgraph_global_info {
550 /* For inline clones this points to the function they will be
551 inlined into. */
552 cgraph_node *inlined_to;
555 /* Information about the function that is propagated by the RTL backend.
556 Available only for functions that has been already assembled. */
558 struct GTY(()) cgraph_rtl_info {
559 unsigned int preferred_incoming_stack_boundary;
561 /* Call unsaved hard registers really used by the corresponding
562 function (including ones used by functions called by the
563 function). */
564 HARD_REG_SET function_used_regs;
565 /* Set if function_used_regs is valid. */
566 unsigned function_used_regs_valid: 1;
569 /* Represent which DECL tree (or reference to such tree)
570 will be replaced by another tree while versioning. */
571 struct GTY(()) ipa_replace_map
573 /* The tree that will be replaced. */
574 tree old_tree;
575 /* The new (replacing) tree. */
576 tree new_tree;
577 /* Parameter number to replace, when old_tree is NULL. */
578 int parm_num;
579 /* True when a substitution should be done, false otherwise. */
580 bool replace_p;
581 /* True when we replace a reference to old_tree. */
582 bool ref_p;
585 struct GTY(()) cgraph_clone_info
587 vec<ipa_replace_map *, va_gc> *tree_map;
588 bitmap args_to_skip;
589 bitmap combined_args_to_skip;
592 enum cgraph_simd_clone_arg_type
594 SIMD_CLONE_ARG_TYPE_VECTOR,
595 SIMD_CLONE_ARG_TYPE_UNIFORM,
596 SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
597 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
598 SIMD_CLONE_ARG_TYPE_MASK
601 /* Function arguments in the original function of a SIMD clone.
602 Supplementary data for `struct simd_clone'. */
604 struct GTY(()) cgraph_simd_clone_arg {
605 /* Original function argument as it originally existed in
606 DECL_ARGUMENTS. */
607 tree orig_arg;
609 /* orig_arg's function (or for extern functions type from
610 TYPE_ARG_TYPES). */
611 tree orig_type;
613 /* If argument is a vector, this holds the vector version of
614 orig_arg that after adjusting the argument types will live in
615 DECL_ARGUMENTS. Otherwise, this is NULL.
617 This basically holds:
618 vector(simdlen) __typeof__(orig_arg) new_arg. */
619 tree vector_arg;
621 /* vector_arg's type (or for extern functions new vector type. */
622 tree vector_type;
624 /* If argument is a vector, this holds the array where the simd
625 argument is held while executing the simd clone function. This
626 is a local variable in the cloned function. Its content is
627 copied from vector_arg upon entry to the clone.
629 This basically holds:
630 __typeof__(orig_arg) simd_array[simdlen]. */
631 tree simd_array;
633 /* A SIMD clone's argument can be either linear (constant or
634 variable), uniform, or vector. */
635 enum cgraph_simd_clone_arg_type arg_type;
637 /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP this is
638 the constant linear step, if arg_type is
639 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP, this is index of
640 the uniform argument holding the step, otherwise 0. */
641 HOST_WIDE_INT linear_step;
643 /* Variable alignment if available, otherwise 0. */
644 unsigned int alignment;
647 /* Specific data for a SIMD function clone. */
649 struct GTY(()) cgraph_simd_clone {
650 /* Number of words in the SIMD lane associated with this clone. */
651 unsigned int simdlen;
653 /* Number of annotated function arguments in `args'. This is
654 usually the number of named arguments in FNDECL. */
655 unsigned int nargs;
657 /* Max hardware vector size in bits for integral vectors. */
658 unsigned int vecsize_int;
660 /* Max hardware vector size in bits for floating point vectors. */
661 unsigned int vecsize_float;
663 /* The mangling character for a given vector size. This is is used
664 to determine the ISA mangling bit as specified in the Intel
665 Vector ABI. */
666 unsigned char vecsize_mangle;
668 /* True if this is the masked, in-branch version of the clone,
669 otherwise false. */
670 unsigned int inbranch : 1;
672 /* True if this is a Cilk Plus variant. */
673 unsigned int cilk_elemental : 1;
675 /* Doubly linked list of SIMD clones. */
676 cgraph_node *prev_clone, *next_clone;
678 /* Original cgraph node the SIMD clones were created for. */
679 cgraph_node *origin;
681 /* Annotated function arguments for the original function. */
682 struct cgraph_simd_clone_arg GTY((length ("%h.nargs"))) args[1];
685 /* Function Multiversioning info. */
686 struct GTY(()) cgraph_function_version_info {
687 /* The cgraph_node for which the function version info is stored. */
688 cgraph_node *this_node;
689 /* Chains all the semantically identical function versions. The
690 first function in this chain is the version_info node of the
691 default function. */
692 struct cgraph_function_version_info *prev;
693 /* If this version node corresponds to a dispatcher for function
694 versions, this points to the version info node of the default
695 function, the first node in the chain. */
696 struct cgraph_function_version_info *next;
697 /* If this node corresponds to a function version, this points
698 to the dispatcher function decl, which is the function that must
699 be called to execute the right function version at run-time.
701 If this cgraph node is a dispatcher (if dispatcher_function is
702 true, in the cgraph_node struct) for function versions, this
703 points to resolver function, which holds the function body of the
704 dispatcher. The dispatcher decl is an alias to the resolver
705 function decl. */
706 tree dispatcher_resolver;
709 #define DEFCIFCODE(code, type, string) CIF_ ## code,
710 /* Reasons for inlining failures. */
712 enum cgraph_inline_failed_t {
713 #include "cif-code.def"
714 CIF_N_REASONS
717 enum cgraph_inline_failed_type_t
719 CIF_FINAL_NORMAL = 0,
720 CIF_FINAL_ERROR
723 struct cgraph_edge;
725 /* The cgraph data structure.
726 Each function decl has assigned cgraph_node listing callees and callers. */
728 struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node {
729 public:
730 /* Remove the node from cgraph and all inline clones inlined into it.
731 Skip however removal of FORBIDDEN_NODE and return true if it needs to be
732 removed. This allows to call the function from outer loop walking clone
733 tree. */
734 bool remove_symbol_and_inline_clones (cgraph_node *forbidden_node = NULL);
736 /* Record all references from cgraph_node that are taken
737 in statement STMT. */
738 void record_stmt_references (gimple stmt);
740 /* Like cgraph_set_call_stmt but walk the clone tree and update all
741 clones sharing the same function body.
742 When WHOLE_SPECULATIVE_EDGES is true, all three components of
743 speculative edge gets updated. Otherwise we update only direct
744 call. */
745 void set_call_stmt_including_clones (gimple old_stmt, gimple new_stmt,
746 bool update_speculative = true);
748 /* Walk the alias chain to return the function cgraph_node is alias of.
749 Walk through thunk, too.
750 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
751 cgraph_node *function_symbol (enum availability *avail = NULL);
753 /* Create node representing clone of N executed COUNT times. Decrease
754 the execution counts from original node too.
755 The new clone will have decl set to DECL that may or may not be the same
756 as decl of N.
758 When UPDATE_ORIGINAL is true, the counts are subtracted from the original
759 function's profile to reflect the fact that part of execution is handled
760 by node.
761 When CALL_DUPLICATOIN_HOOK is true, the ipa passes are acknowledged about
762 the new clone. Otherwise the caller is responsible for doing so later.
764 If the new node is being inlined into another one, NEW_INLINED_TO should be
765 the outline function the new one is (even indirectly) inlined to.
766 All hooks will see this in node's global.inlined_to, when invoked.
767 Can be NULL if the node is not inlined. */
768 cgraph_node *create_clone (tree decl, gcov_type count, int freq,
769 bool update_original,
770 vec<cgraph_edge *> redirect_callers,
771 bool call_duplication_hook,
772 struct cgraph_node *new_inlined_to,
773 bitmap args_to_skip);
775 /* Create callgraph node clone with new declaration. The actual body will
776 be copied later at compilation stage. */
777 cgraph_node *create_virtual_clone (vec<cgraph_edge *> redirect_callers,
778 vec<ipa_replace_map *, va_gc> *tree_map,
779 bitmap args_to_skip, const char * suffix);
781 /* cgraph node being removed from symbol table; see if its entry can be
782 replaced by other inline clone. */
783 cgraph_node *find_replacement (void);
785 /* Create a new cgraph node which is the new version of
786 callgraph node. REDIRECT_CALLERS holds the callers
787 edges which should be redirected to point to
788 NEW_VERSION. ALL the callees edges of the node
789 are cloned to the new version node. Return the new
790 version node.
792 If non-NULL BLOCK_TO_COPY determine what basic blocks
793 was copied to prevent duplications of calls that are dead
794 in the clone. */
796 cgraph_node *create_version_clone (tree new_decl,
797 vec<cgraph_edge *> redirect_callers,
798 bitmap bbs_to_copy);
800 /* Perform function versioning.
801 Function versioning includes copying of the tree and
802 a callgraph update (creating a new cgraph node and updating
803 its callees and callers).
805 REDIRECT_CALLERS varray includes the edges to be redirected
806 to the new version.
808 TREE_MAP is a mapping of tree nodes we want to replace with
809 new ones (according to results of prior analysis).
811 If non-NULL ARGS_TO_SKIP determine function parameters to remove
812 from new version.
813 If SKIP_RETURN is true, the new version will return void.
814 If non-NULL BLOCK_TO_COPY determine what basic blocks to copy.
815 If non_NULL NEW_ENTRY determine new entry BB of the clone.
817 Return the new version's cgraph node. */
818 cgraph_node *create_version_clone_with_body
819 (vec<cgraph_edge *> redirect_callers,
820 vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip,
821 bool skip_return, bitmap bbs_to_copy, basic_block new_entry_block,
822 const char *clone_name);
824 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
825 corresponding to cgraph_node. */
826 struct cgraph_function_version_info *insert_new_function_version (void);
828 /* Get the cgraph_function_version_info node corresponding to node. */
829 struct cgraph_function_version_info *function_version (void);
831 /* Discover all functions and variables that are trivially needed, analyze
832 them as well as all functions and variables referred by them */
833 void analyze (void);
835 /* Add thunk alias into callgraph. The alias declaration is ALIAS and it
836 aliases DECL with an adjustments made into the first parameter.
837 See comments in thunk_adjust for detail on the parameters. */
838 cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
839 HOST_WIDE_INT fixed_offset,
840 HOST_WIDE_INT virtual_value,
841 tree virtual_offset,
842 tree real_alias);
845 /* Return node that alias is aliasing. */
846 inline cgraph_node *get_alias_target (void);
848 /* Given function symbol, walk the alias chain to return the function node
849 is alias of. Do not walk through thunks.
850 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
852 cgraph_node *ultimate_alias_target (availability *availability = NULL);
854 /* Expand thunk NODE to gimple if possible.
855 When FORCE_GIMPLE_THUNK is true, gimple thunk is created and
856 no assembler is produced.
857 When OUTPUT_ASM_THUNK is true, also produce assembler for
858 thunks that are not lowered. */
859 bool expand_thunk (bool output_asm_thunks, bool force_gimple_thunk);
861 /* As an GCC extension we allow redefinition of the function. The
862 semantics when both copies of bodies differ is not well defined.
863 We replace the old body with new body so in unit at a time mode
864 we always use new body, while in normal mode we may end up with
865 old body inlined into some functions and new body expanded and
866 inlined in others. */
867 void reset (void);
869 /* Creates a wrapper from cgraph_node to TARGET node. Thunk is used for this
870 kind of wrapper method. */
871 void create_wrapper (cgraph_node *target);
873 /* Verify cgraph nodes of the cgraph node. */
874 void DEBUG_FUNCTION verify_node (void);
876 /* Remove function from symbol table. */
877 void remove (void);
879 /* Dump call graph node to file F. */
880 void dump (FILE *f);
882 /* Dump call graph node to stderr. */
883 void DEBUG_FUNCTION debug (void);
885 /* When doing LTO, read cgraph_node's body from disk if it is not already
886 present. */
887 bool get_body (void);
889 /* Release memory used to represent body of function.
890 Use this only for functions that are released before being translated to
891 target code (i.e. RTL). Functions that are compiled to RTL and beyond
892 are free'd in final.c via free_after_compilation(). */
893 void release_body (void);
895 /* cgraph_node is no longer nested function; update cgraph accordingly. */
896 void unnest (void);
898 /* Bring cgraph node local. */
899 void make_local (void);
901 /* Likewise indicate that a node is having address taken. */
902 void mark_address_taken (void);
904 /* Set fialization priority to PRIORITY. */
905 void set_fini_priority (priority_type priority);
907 /* Return the finalization priority. */
908 priority_type get_fini_priority (void);
910 /* Create edge from a given function to CALLEE in the cgraph. */
911 struct cgraph_edge *create_edge (cgraph_node *callee,
912 gimple call_stmt, gcov_type count,
913 int freq);
914 /* Create an indirect edge with a yet-undetermined callee where the call
915 statement destination is a formal parameter of the caller with index
916 PARAM_INDEX. */
917 struct cgraph_edge *create_indirect_edge (gimple call_stmt, int ecf_flags,
918 gcov_type count, int freq);
920 /* Like cgraph_create_edge walk the clone tree and update all clones sharing
921 same function body. If clones already have edge for OLD_STMT; only
922 update the edge same way as cgraph_set_call_stmt_including_clones does. */
923 void create_edge_including_clones (struct cgraph_node *callee,
924 gimple old_stmt, gimple stmt,
925 gcov_type count,
926 int freq,
927 cgraph_inline_failed_t reason);
929 /* Return the callgraph edge representing the GIMPLE_CALL statement
930 CALL_STMT. */
931 cgraph_edge *get_edge (gimple call_stmt);
933 /* Collect all callers of cgraph_node and its aliases that are known to lead
934 to NODE (i.e. are not overwritable). */
935 vec<cgraph_edge *> collect_callers (void);
937 /* Remove all callers from the node. */
938 void remove_callers (void);
940 /* Remove all callees from the node. */
941 void remove_callees (void);
943 /* Return function availability. See cgraph.h for description of individual
944 return values. */
945 enum availability get_availability (void);
947 /* Set TREE_NOTHROW on cgraph_node's decl and on aliases of the node
948 if any to NOTHROW. */
949 void set_nothrow_flag (bool nothrow);
951 /* Set TREE_READONLY on cgraph_node's decl and on aliases of the node
952 if any to READONLY. */
953 void set_const_flag (bool readonly, bool looping);
955 /* Set DECL_PURE_P on cgraph_node's decl and on aliases of the node
956 if any to PURE. */
957 void set_pure_flag (bool pure, bool looping);
959 /* Call all node duplication hooks. */
960 void call_duplication_hooks (cgraph_node *node2);
962 /* Call calback on function and aliases associated to the function.
963 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
964 skipped. */
966 bool call_for_symbol_and_aliases (bool (*callback) (cgraph_node *,
967 void *),
968 void *data, bool include_overwritable);
970 /* Call calback on cgraph_node, thunks and aliases associated to NODE.
971 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
972 skipped. */
973 bool call_for_symbol_thunks_and_aliases (bool (*callback) (cgraph_node *node,
974 void *data),
975 void *data,
976 bool include_overwritable);
978 /* Call all node insertion hooks. */
979 void call_function_insertion_hooks (void);
981 /* Likewise indicate that a node is needed, i.e. reachable via some
982 external means. */
983 inline void mark_force_output (void);
985 /* Return true when function can be marked local. */
986 bool local_p (void);
988 /* Return true if cgraph_node can be made local for API change.
989 Extern inline functions and C++ COMDAT functions can be made local
990 at the expense of possible code size growth if function is used in multiple
991 compilation units. */
992 bool can_be_local_p (void);
994 /* Return true when cgraph_node can not return or throw and thus
995 it is safe to ignore its side effects for IPA analysis. */
996 bool cannot_return_p (void);
998 /* Return true when function cgraph_node and all its aliases are only called
999 directly.
1000 i.e. it is not externally visible, address was not taken and
1001 it is not used in any other non-standard way. */
1002 bool only_called_directly_p (void);
1004 /* Return true when function is only called directly or it has alias.
1005 i.e. it is not externally visible, address was not taken and
1006 it is not used in any other non-standard way. */
1007 inline bool only_called_directly_or_aliased_p (void);
1009 /* Return true when function cgraph_node can be expected to be removed
1010 from program when direct calls in this compilation unit are removed.
1012 As a special case COMDAT functions are
1013 cgraph_can_remove_if_no_direct_calls_p while the are not
1014 cgraph_only_called_directly_p (it is possible they are called from other
1015 unit)
1017 This function behaves as cgraph_only_called_directly_p because eliminating
1018 all uses of COMDAT function does not make it necessarily disappear from
1019 the program unless we are compiling whole program or we do LTO. In this
1020 case we know we win since dynamic linking will not really discard the
1021 linkonce section. */
1022 bool will_be_removed_from_program_if_no_direct_calls_p (void);
1024 /* Return true when function can be removed from callgraph
1025 if all direct calls are eliminated. */
1026 bool can_remove_if_no_direct_calls_and_refs_p (void);
1028 /* Return true when function cgraph_node and its aliases can be removed from
1029 callgraph if all direct calls are eliminated. */
1030 bool can_remove_if_no_direct_calls_p (void);
1032 /* Return true when callgraph node is a function with Gimple body defined
1033 in current unit. Functions can also be define externally or they
1034 can be thunks with no Gimple representation.
1036 Note that at WPA stage, the function body may not be present in memory. */
1037 inline bool has_gimple_body_p (void);
1039 /* Return true if function should be optimized for size. */
1040 bool optimize_for_size_p (void);
1042 /* Dump the callgraph to file F. */
1043 static void dump_cgraph (FILE *f);
1045 /* Dump the call graph to stderr. */
1046 static inline void debug_cgraph (void)
1048 dump_cgraph (stderr);
1051 /* Record that DECL1 and DECL2 are semantically identical function
1052 versions. */
1053 static void record_function_versions (tree decl1, tree decl2);
1055 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
1056 DECL is a duplicate declaration. */
1057 static void delete_function_version (tree decl);
1059 /* Add the function FNDECL to the call graph.
1060 Unlike cgraph_finalize_function, this function is intended to be used
1061 by middle end and allows insertion of new function at arbitrary point
1062 of compilation. The function can be either in high, low or SSA form
1063 GIMPLE.
1065 The function is assumed to be reachable and have address taken (so no
1066 API breaking optimizations are performed on it).
1068 Main work done by this function is to enqueue the function for later
1069 processing to avoid need the passes to be re-entrant. */
1070 static void add_new_function (tree fndecl, bool lowered);
1072 /* Return callgraph node for given symbol and check it is a function. */
1073 static inline cgraph_node *get (const_tree decl)
1075 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
1076 return dyn_cast <cgraph_node *> (symtab_node::get (decl));
1079 /* Return cgraph node assigned to DECL. Create new one when needed. */
1080 static cgraph_node * create (tree decl);
1082 /* Allocate new callgraph node and insert it into basic data structures. */
1083 static cgraph_node * create_empty (void);
1085 /* Try to find a call graph node for declaration DECL and if it does not
1086 exist or if it corresponds to an inline clone, create a new one. */
1087 static cgraph_node * get_create (tree);
1089 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
1090 Return NULL if there's no such node. */
1091 static cgraph_node *get_for_asmname (tree asmname);
1093 /* Attempt to mark ALIAS as an alias to DECL. Return alias node if
1094 successful and NULL otherwise.
1095 Same body aliases are output whenever the body of DECL is output,
1096 and cgraph_node::get (ALIAS) transparently
1097 returns cgraph_node::get (DECL). */
1098 static cgraph_node * create_same_body_alias (tree alias, tree decl);
1100 /* Worker for cgraph_can_remove_if_no_direct_calls_p. */
1101 static bool used_from_object_file_p_worker (cgraph_node *node, void *)
1103 return node->used_from_object_file_p ();
1106 /* Return true when cgraph_node can not be local.
1107 Worker for cgraph_local_node_p. */
1108 static bool non_local_p (cgraph_node *node, void *);
1110 /* Verify whole cgraph structure. */
1111 static void DEBUG_FUNCTION verify_cgraph_nodes (void);
1113 /* Worker to bring NODE local. */
1114 static bool make_local (cgraph_node *node, void *);
1116 /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing
1117 the function body is associated
1118 with (not necessarily cgraph_node (DECL). */
1119 static cgraph_node *create_alias (tree alias, tree target);
1121 static cgraph_edge * create_edge (cgraph_node *caller, cgraph_node *callee,
1122 gimple call_stmt, gcov_type count,
1123 int freq,
1124 bool indir_unknown_callee);
1126 struct cgraph_edge *callees;
1127 struct cgraph_edge *callers;
1128 /* List of edges representing indirect calls with a yet undetermined
1129 callee. */
1130 struct cgraph_edge *indirect_calls;
1131 /* For nested functions points to function the node is nested in. */
1132 cgraph_node *origin;
1133 /* Points to first nested function, if any. */
1134 cgraph_node *nested;
1135 /* Pointer to the next function with same origin, if any. */
1136 cgraph_node *next_nested;
1137 /* Pointer to the next clone. */
1138 cgraph_node *next_sibling_clone;
1139 cgraph_node *prev_sibling_clone;
1140 cgraph_node *clones;
1141 cgraph_node *clone_of;
1142 /* For functions with many calls sites it holds map from call expression
1143 to the edge to speed up cgraph_edge function. */
1144 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
1145 /* Declaration node used to be clone of. */
1146 tree former_clone_of;
1148 /* If this is a SIMD clone, this points to the SIMD specific
1149 information for it. */
1150 struct cgraph_simd_clone *simdclone;
1151 /* If this function has SIMD clones, this points to the first clone. */
1152 cgraph_node *simd_clones;
1154 /* Interprocedural passes scheduled to have their transform functions
1155 applied next time we execute local pass on them. We maintain it
1156 per-function in order to allow IPA passes to introduce new functions. */
1157 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
1159 struct cgraph_local_info local;
1160 struct cgraph_global_info global;
1161 struct cgraph_rtl_info rtl;
1162 struct cgraph_clone_info clone;
1163 struct cgraph_thunk_info thunk;
1165 /* Expected number of executions: calculated in profile.c. */
1166 gcov_type count;
1167 /* How to scale counts at materialization time; used to merge
1168 LTO units with different number of profile runs. */
1169 int count_materialization_scale;
1170 /* Unique id of the node. */
1171 int uid;
1172 /* ID assigned by the profiling. */
1173 unsigned int profile_id;
1174 /* Time profiler: first run of function. */
1175 int tp_first_run;
1177 /* Set when decl is an abstract function pointed to by the
1178 ABSTRACT_DECL_ORIGIN of a reachable function. */
1179 unsigned used_as_abstract_origin : 1;
1180 /* Set once the function is lowered (i.e. its CFG is built). */
1181 unsigned lowered : 1;
1182 /* Set once the function has been instantiated and its callee
1183 lists created. */
1184 unsigned process : 1;
1185 /* How commonly executed the node is. Initialized during branch
1186 probabilities pass. */
1187 ENUM_BITFIELD (node_frequency) frequency : 2;
1188 /* True when function can only be called at startup (from static ctor). */
1189 unsigned only_called_at_startup : 1;
1190 /* True when function can only be called at startup (from static dtor). */
1191 unsigned only_called_at_exit : 1;
1192 /* True when function is the transactional clone of a function which
1193 is called only from inside transactions. */
1194 /* ?? We should be able to remove this. We have enough bits in
1195 cgraph to calculate it. */
1196 unsigned tm_clone : 1;
1197 /* True if this decl is a dispatcher for function versions. */
1198 unsigned dispatcher_function : 1;
1199 /* True if this decl calls a COMDAT-local function. This is set up in
1200 compute_inline_parameters and inline_call. */
1201 unsigned calls_comdat_local : 1;
1204 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
1205 can appear in multiple sets. */
1206 struct cgraph_node_set_def
1208 hash_map<cgraph_node *, size_t> *map;
1209 vec<cgraph_node *> nodes;
1212 typedef cgraph_node_set_def *cgraph_node_set;
1213 typedef struct varpool_node_set_def *varpool_node_set;
1215 class varpool_node;
1217 /* A varpool node set is a collection of varpool nodes. A varpool node
1218 can appear in multiple sets. */
1219 struct varpool_node_set_def
1221 hash_map<varpool_node *, size_t> * map;
1222 vec<varpool_node *> nodes;
1225 /* Iterator structure for cgraph node sets. */
1226 struct cgraph_node_set_iterator
1228 cgraph_node_set set;
1229 unsigned index;
1232 /* Iterator structure for varpool node sets. */
1233 struct varpool_node_set_iterator
1235 varpool_node_set set;
1236 unsigned index;
1239 /* Structure containing additional information about an indirect call. */
1241 struct GTY(()) cgraph_indirect_call_info
1243 /* When polymorphic is set, this field contains offset where the object which
1244 was actually used in the polymorphic resides within a larger structure.
1245 If agg_contents is set, the field contains the offset within the aggregate
1246 from which the address to call was loaded. */
1247 HOST_WIDE_INT offset, speculative_offset;
1248 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
1249 HOST_WIDE_INT otr_token;
1250 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
1251 tree otr_type, outer_type, speculative_outer_type;
1252 /* Index of the parameter that is called. */
1253 int param_index;
1254 /* ECF flags determined from the caller. */
1255 int ecf_flags;
1256 /* Profile_id of common target obtrained from profile. */
1257 int common_target_id;
1258 /* Probability that call will land in function with COMMON_TARGET_ID. */
1259 int common_target_probability;
1261 /* Set when the call is a virtual call with the parameter being the
1262 associated object pointer rather than a simple direct call. */
1263 unsigned polymorphic : 1;
1264 /* Set when the call is a call of a pointer loaded from contents of an
1265 aggregate at offset. */
1266 unsigned agg_contents : 1;
1267 /* Set when this is a call through a member pointer. */
1268 unsigned member_ptr : 1;
1269 /* When the previous bit is set, this one determines whether the destination
1270 is loaded from a parameter passed by reference. */
1271 unsigned by_ref : 1;
1272 unsigned int maybe_in_construction : 1;
1273 unsigned int maybe_derived_type : 1;
1274 unsigned int speculative_maybe_derived_type : 1;
1277 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
1278 /* Expected number of executions: calculated in profile.c. */
1279 gcov_type count;
1280 cgraph_node *caller;
1281 cgraph_node *callee;
1282 struct cgraph_edge *prev_caller;
1283 struct cgraph_edge *next_caller;
1284 struct cgraph_edge *prev_callee;
1285 struct cgraph_edge *next_callee;
1286 gimple call_stmt;
1287 /* Additional information about an indirect call. Not cleared when an edge
1288 becomes direct. */
1289 struct cgraph_indirect_call_info *indirect_info;
1290 PTR GTY ((skip (""))) aux;
1291 /* When equal to CIF_OK, inline this call. Otherwise, points to the
1292 explanation why function was not inlined. */
1293 enum cgraph_inline_failed_t inline_failed;
1294 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
1295 when the function is serialized in. */
1296 unsigned int lto_stmt_uid;
1297 /* Expected frequency of executions within the function.
1298 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
1299 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
1300 int frequency;
1301 /* Unique id of the edge. */
1302 int uid;
1303 /* Whether this edge was made direct by indirect inlining. */
1304 unsigned int indirect_inlining_edge : 1;
1305 /* Whether this edge describes an indirect call with an undetermined
1306 callee. */
1307 unsigned int indirect_unknown_callee : 1;
1308 /* Whether this edge is still a dangling */
1309 /* True if the corresponding CALL stmt cannot be inlined. */
1310 unsigned int call_stmt_cannot_inline_p : 1;
1311 /* Can this call throw externally? */
1312 unsigned int can_throw_external : 1;
1313 /* Edges with SPECULATIVE flag represents indirect calls that was
1314 speculatively turned into direct (i.e. by profile feedback).
1315 The final code sequence will have form:
1317 if (call_target == expected_fn)
1318 expected_fn ();
1319 else
1320 call_target ();
1322 Every speculative call is represented by three components attached
1323 to a same call statement:
1324 1) a direct call (to expected_fn)
1325 2) an indirect call (to call_target)
1326 3) a IPA_REF_ADDR refrence to expected_fn.
1328 Optimizers may later redirect direct call to clone, so 1) and 3)
1329 do not need to necesarily agree with destination. */
1330 unsigned int speculative : 1;
1333 #define CGRAPH_FREQ_BASE 1000
1334 #define CGRAPH_FREQ_MAX 100000
1336 /* The varpool data structure.
1337 Each static variable decl has assigned varpool_node. */
1339 class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node {
1340 public:
1341 /* Dump given varpool node to F. */
1342 void dump (FILE *f);
1344 /* Dump given varpool node to stderr. */
1345 void DEBUG_FUNCTION debug (void);
1347 /* Remove variable from symbol table. */
1348 void remove (void);
1350 /* Remove node initializer when it is no longer needed. */
1351 void remove_initializer (void);
1353 void analyze (void);
1355 /* Return variable availability. */
1356 availability get_availability (void);
1358 /* When doing LTO, read variable's constructor from disk if
1359 it is not already present. */
1360 tree get_constructor (void);
1362 /* Return true if variable has constructor that can be used for folding. */
1363 bool ctor_useable_for_folding_p (void);
1365 /* For given variable pool node, walk the alias chain to return the function
1366 the variable is alias of. Do not walk through thunks.
1367 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1368 inline varpool_node *ultimate_alias_target
1369 (availability *availability = NULL);
1371 /* Return node that alias is aliasing. */
1372 inline varpool_node *get_alias_target (void);
1374 /* Output one variable, if necessary. Return whether we output it. */
1375 bool assemble_decl (void);
1377 /* For variables in named sections make sure get_variable_section
1378 is called before we switch to those sections. Then section
1379 conflicts between read-only and read-only requiring relocations
1380 sections can be resolved. */
1381 void finalize_named_section_flags (void);
1383 /* Call calback on varpool symbol and aliases associated to varpool symbol.
1384 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
1385 skipped. */
1386 bool call_for_node_and_aliases (bool (*callback) (varpool_node *, void *),
1387 void *data,
1388 bool include_overwritable);
1390 /* Return true when variable should be considered externally visible. */
1391 bool externally_visible_p (void);
1393 /* Return true when all references to variable must be visible
1394 in ipa_ref_list.
1395 i.e. if the variable is not externally visible or not used in some magic
1396 way (asm statement or such).
1397 The magic uses are all summarized in force_output flag. */
1398 inline bool all_refs_explicit_p ();
1400 /* Return true when variable can be removed from variable pool
1401 if all direct calls are eliminated. */
1402 inline bool can_remove_if_no_refs_p (void);
1404 /* Return varpool node for given symbol and check it is a function. */
1405 static inline varpool_node *get (const_tree decl);
1407 /* Mark DECL as finalized. By finalizing the declaration, frontend instruct
1408 the middle end to output the variable to asm file, if needed or externally
1409 visible. */
1410 static void finalize_decl (tree decl);
1412 /* Output all variables enqueued to be assembled. */
1413 static bool output_variables (void);
1415 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
1416 Extra name aliases are output whenever DECL is output. */
1417 static varpool_node * create_extra_name_alias (tree alias, tree decl);
1419 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
1420 Extra name aliases are output whenever DECL is output. */
1421 static varpool_node * create_alias (tree, tree);
1423 /* Dump the variable pool to F. */
1424 static void dump_varpool (FILE *f);
1426 /* Dump the variable pool to stderr. */
1427 static void DEBUG_FUNCTION debug_varpool (void);
1429 /* Allocate new callgraph node and insert it into basic data structures. */
1430 static varpool_node *create_empty (void);
1432 /* Return varpool node assigned to DECL. Create new one when needed. */
1433 static varpool_node *get_create (tree decl);
1435 /* Given an assembler name, lookup node. */
1436 static varpool_node *get_for_asmname (tree asmname);
1438 /* Set when variable is scheduled to be assembled. */
1439 unsigned output : 1;
1441 /* Set if the variable is dynamically initialized, except for
1442 function local statics. */
1443 unsigned dynamically_initialized : 1;
1445 ENUM_BITFIELD(tls_model) tls_model : 3;
1447 /* Set if the variable is known to be used by single function only.
1448 This is computed by ipa_signle_use pass and used by late optimizations
1449 in places where optimization would be valid for local static variable
1450 if we did not do any inter-procedural code movement. */
1451 unsigned used_by_single_function : 1;
1453 private:
1454 /* Assemble thunks and aliases associated to varpool node. */
1455 void assemble_aliases (void);
1458 /* Every top level asm statement is put into a asm_node. */
1460 struct GTY(()) asm_node {
1461 /* Next asm node. */
1462 struct asm_node *next;
1463 /* String for this asm node. */
1464 tree asm_str;
1465 /* Ordering of all cgraph nodes. */
1466 int order;
1469 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
1471 template <>
1472 template <>
1473 inline bool
1474 is_a_helper <cgraph_node *>::test (symtab_node *p)
1476 return p && p->type == SYMTAB_FUNCTION;
1479 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
1481 template <>
1482 template <>
1483 inline bool
1484 is_a_helper <varpool_node *>::test (symtab_node *p)
1486 return p && p->type == SYMTAB_VARIABLE;
1489 extern GTY(()) symtab_node *symtab_nodes;
1490 extern GTY(()) int cgraph_n_nodes;
1491 extern GTY(()) int cgraph_max_uid;
1492 extern GTY(()) int cgraph_edge_max_uid;
1493 extern bool cgraph_global_info_ready;
1494 enum cgraph_state
1496 /* Frontend is parsing and finalizing functions. */
1497 CGRAPH_STATE_PARSING,
1498 /* Callgraph is being constructed. It is safe to add new functions. */
1499 CGRAPH_STATE_CONSTRUCTION,
1500 /* Callgraph is being at LTO time. */
1501 CGRAPH_LTO_STREAMING,
1502 /* Callgraph is built and IPA passes are being run. */
1503 CGRAPH_STATE_IPA,
1504 /* Callgraph is built and all functions are transformed to SSA form. */
1505 CGRAPH_STATE_IPA_SSA,
1506 /* Functions are now ordered and being passed to RTL expanders. */
1507 CGRAPH_STATE_EXPANSION,
1508 /* All cgraph expansion is done. */
1509 CGRAPH_STATE_FINISHED
1511 extern enum cgraph_state cgraph_state;
1512 extern bool cgraph_function_flags_ready;
1513 extern vec<cgraph_node *> cgraph_new_nodes;
1515 extern GTY(()) struct asm_node *asm_nodes;
1516 extern GTY(()) int symtab_order;
1517 extern bool cpp_implicit_aliases_done;
1519 /* In symtab.c */
1520 symtab_node *symtab_node_for_asm (const_tree asmname);
1522 /* In cgraph.c */
1523 void release_function_body (tree);
1524 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
1525 void cgraph_remove_edge (struct cgraph_edge *);
1527 void cgraph_set_call_stmt (struct cgraph_edge *, gimple, bool update_speculative = true);
1528 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
1529 struct cgraph_local_info *cgraph_local_info (tree);
1530 struct cgraph_global_info *cgraph_global_info (tree);
1531 struct cgraph_rtl_info *cgraph_rtl_info (tree);
1532 void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
1533 struct cgraph_edge *);
1535 bool cgraph_function_possibly_inlined_p (tree);
1536 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
1537 void cgraph_redirect_edge_callee (struct cgraph_edge *, cgraph_node *);
1538 struct cgraph_edge *cgraph_make_edge_direct (struct cgraph_edge *,
1539 cgraph_node *);
1541 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
1542 cgraph_inline_failed_type_t cgraph_inline_failed_type (cgraph_inline_failed_t);
1544 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
1545 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
1546 typedef void (*cgraph_node_hook)(cgraph_node *, void *);
1547 typedef void (*varpool_node_hook)(varpool_node *, void *);
1548 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
1549 void *);
1550 typedef void (*cgraph_2node_hook)(cgraph_node *, cgraph_node *,
1551 void *);
1552 struct cgraph_edge_hook_list;
1553 struct cgraph_node_hook_list;
1554 struct varpool_node_hook_list;
1555 struct cgraph_2edge_hook_list;
1556 struct cgraph_2node_hook_list;
1557 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
1558 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
1559 cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
1560 void *);
1561 void cgraph_remove_node_removal_hook (cgraph_node_hook_list *);
1562 struct varpool_node_hook_list *varpool_add_node_removal_hook (varpool_node_hook,
1563 void *);
1564 void varpool_remove_node_removal_hook (struct varpool_node_hook_list *);
1565 cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
1566 void *);
1567 void cgraph_remove_function_insertion_hook (cgraph_node_hook_list *);
1568 struct varpool_node_hook_list *varpool_add_variable_insertion_hook (varpool_node_hook,
1569 void *);
1570 void varpool_remove_variable_insertion_hook (struct varpool_node_hook_list *);
1571 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
1572 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
1573 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
1574 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
1575 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
1576 struct cgraph_edge *
1577 cgraph_turn_edge_to_speculative (struct cgraph_edge *,
1578 cgraph_node *,
1579 gcov_type, int);
1580 void cgraph_speculative_call_info (struct cgraph_edge *,
1581 struct cgraph_edge *&,
1582 struct cgraph_edge *&,
1583 struct ipa_ref *&);
1584 extern bool gimple_check_call_matching_types (gimple, tree, bool);
1586 /* In cgraphunit.c */
1587 struct asm_node *add_asm_node (tree);
1588 extern FILE *cgraph_dump_file;
1589 void cgraph_finalize_function (tree, bool);
1590 void finalize_compilation_unit (void);
1591 void compile (void);
1592 void init_cgraph (void);
1593 void cgraph_process_new_functions (void);
1594 void cgraph_process_same_body_aliases (void);
1595 /* Initialize datastructures so DECL is a function in lowered gimple form.
1596 IN_SSA is true if the gimple is in SSA. */
1597 basic_block init_lowered_empty_function (tree, bool);
1599 /* In cgraphclones.c */
1601 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
1602 cgraph_node *, gimple,
1603 unsigned, gcov_type, int, bool);
1604 tree clone_function_name (tree decl, const char *);
1606 void cgraph_materialize_all_clones (void);
1607 void tree_function_versioning (tree, tree, vec<ipa_replace_map *, va_gc> *,
1608 bool, bitmap, bool, bitmap, basic_block);
1609 struct cgraph_edge *cgraph_resolve_speculation (struct cgraph_edge *, tree);
1611 /* In cgraphbuild.c */
1612 unsigned int rebuild_cgraph_edges (void);
1613 void cgraph_rebuild_references (void);
1614 int compute_call_stmt_bb_frequency (tree, basic_block bb);
1615 void record_references_in_initializer (tree, bool);
1617 /* In ipa.c */
1618 bool symtab_remove_unreachable_nodes (bool, FILE *);
1619 void cgraph_build_static_cdtor (char which, tree body, int priority);
1620 void ipa_discover_readonly_nonaddressable_vars (void);
1622 /* In predict.c */
1623 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
1625 /* In varpool.c */
1626 void varpool_reset_queue (void);
1627 tree ctor_for_folding (tree);
1628 void varpool_add_new_variable (tree);
1629 void symtab_initialize_asm_name_hash (void);
1630 void symtab_prevail_in_asm_name_hash (symtab_node *node);
1632 /* In cgraph.c */
1633 extern void change_decl_assembler_name (tree, tree);
1635 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1636 or abstract function kept for debug info purposes only. */
1637 inline bool
1638 symtab_node::real_symbol_p (void)
1640 cgraph_node *cnode;
1642 if (DECL_ABSTRACT (decl))
1643 return false;
1644 if (!is_a <cgraph_node *> (this))
1645 return true;
1646 cnode = dyn_cast <cgraph_node *> (this);
1647 if (cnode->global.inlined_to)
1648 return false;
1649 return true;
1652 /* Return true if DECL should have entry in symbol table if used.
1653 Those are functions and static & external veriables*/
1655 static inline bool
1656 decl_in_symtab_p (const_tree decl)
1658 return (TREE_CODE (decl) == FUNCTION_DECL
1659 || (TREE_CODE (decl) == VAR_DECL
1660 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))));
1663 inline bool
1664 symtab_node::in_same_comdat_group_p (symtab_node *target)
1666 symtab_node *source = this;
1668 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
1670 if (cn->global.inlined_to)
1671 source = cn->global.inlined_to;
1673 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
1675 if (cn->global.inlined_to)
1676 target = cn->global.inlined_to;
1679 return source->get_comdat_group () == target->get_comdat_group ();
1682 /* Return node that alias is aliasing. */
1684 inline symtab_node *
1685 symtab_node::get_alias_target (void)
1687 struct ipa_ref *ref = NULL;
1688 iterate_reference (0, ref);
1689 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1690 return ref->referred;
1693 /* Return next reachable static symbol with initializer after the node. */
1694 inline symtab_node *
1695 symtab_node::next_defined_symbol (void)
1697 symtab_node *node1 = next;
1699 for (; node1; node1 = node1->next)
1700 if (node1->definition)
1701 return node1;
1703 return NULL;
1706 /* Return varpool node for given symbol and check it is a function. */
1707 inline varpool_node *
1708 varpool_node::get (const_tree decl)
1710 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
1711 return dyn_cast<varpool_node *> (symtab_node::get (decl));
1714 /* Walk all symbols. */
1715 #define FOR_EACH_SYMBOL(node) \
1716 for ((node) = symtab_nodes; (node); (node) = (node)->next)
1718 /* Return first static symbol with definition. */
1719 static inline symtab_node *
1720 symtab_first_defined_symbol (void)
1722 symtab_node *node;
1724 for (node = symtab_nodes; node; node = node->next)
1725 if (node->definition)
1726 return node;
1728 return NULL;
1731 /* Walk all symbols with definitions in current unit. */
1732 #define FOR_EACH_DEFINED_SYMBOL(node) \
1733 for ((node) = symtab_first_defined_symbol (); (node); \
1734 (node) = node->next_defined_symbol ())
1736 /* Return first variable. */
1737 static inline varpool_node *
1738 varpool_first_variable (void)
1740 symtab_node *node;
1741 for (node = symtab_nodes; node; node = node->next)
1742 if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
1743 return vnode;
1744 return NULL;
1747 /* Return next variable after NODE. */
1748 static inline varpool_node *
1749 varpool_next_variable (varpool_node *node)
1751 symtab_node *node1 = node->next;
1752 for (; node1; node1 = node1->next)
1753 if (varpool_node *vnode1 = dyn_cast <varpool_node *> (node1))
1754 return vnode1;
1755 return NULL;
1757 /* Walk all variables. */
1758 #define FOR_EACH_VARIABLE(node) \
1759 for ((node) = varpool_first_variable (); \
1760 (node); \
1761 (node) = varpool_next_variable ((node)))
1763 /* Return first static variable with initializer. */
1764 static inline varpool_node *
1765 varpool_first_static_initializer (void)
1767 symtab_node *node;
1768 for (node = symtab_nodes; node; node = node->next)
1770 varpool_node *vnode = dyn_cast <varpool_node *> (node);
1771 if (vnode && DECL_INITIAL (node->decl))
1772 return vnode;
1774 return NULL;
1777 /* Return next static variable with initializer after NODE. */
1778 static inline varpool_node *
1779 varpool_next_static_initializer (varpool_node *node)
1781 symtab_node *node1 = node->next;
1782 for (; node1; node1 = node1->next)
1784 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
1785 if (vnode1 && DECL_INITIAL (node1->decl))
1786 return vnode1;
1788 return NULL;
1791 /* Walk all static variables with initializer set. */
1792 #define FOR_EACH_STATIC_INITIALIZER(node) \
1793 for ((node) = varpool_first_static_initializer (); (node); \
1794 (node) = varpool_next_static_initializer (node))
1796 /* Return first static variable with definition. */
1797 static inline varpool_node *
1798 varpool_first_defined_variable (void)
1800 symtab_node *node;
1801 for (node = symtab_nodes; node; node = node->next)
1803 varpool_node *vnode = dyn_cast <varpool_node *> (node);
1804 if (vnode && vnode->definition)
1805 return vnode;
1807 return NULL;
1810 /* Return next static variable with definition after NODE. */
1811 static inline varpool_node *
1812 varpool_next_defined_variable (varpool_node *node)
1814 symtab_node *node1 = node->next;
1815 for (; node1; node1 = node1->next)
1817 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
1818 if (vnode1 && vnode1->definition)
1819 return vnode1;
1821 return NULL;
1823 /* Walk all variables with definitions in current unit. */
1824 #define FOR_EACH_DEFINED_VARIABLE(node) \
1825 for ((node) = varpool_first_defined_variable (); (node); \
1826 (node) = varpool_next_defined_variable (node))
1828 /* Return first function with body defined. */
1829 static inline cgraph_node *
1830 cgraph_first_defined_function (void)
1832 symtab_node *node;
1833 for (node = symtab_nodes; node; node = node->next)
1835 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
1836 if (cn && cn->definition)
1837 return cn;
1839 return NULL;
1842 /* Return next function with body defined after NODE. */
1843 static inline cgraph_node *
1844 cgraph_next_defined_function (cgraph_node *node)
1846 symtab_node *node1 = node->next;
1847 for (; node1; node1 = node1->next)
1849 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
1850 if (cn1 && cn1->definition)
1851 return cn1;
1853 return NULL;
1856 /* Walk all functions with body defined. */
1857 #define FOR_EACH_DEFINED_FUNCTION(node) \
1858 for ((node) = cgraph_first_defined_function (); (node); \
1859 (node) = cgraph_next_defined_function ((node)))
1861 /* Return first function. */
1862 static inline cgraph_node *
1863 cgraph_first_function (void)
1865 symtab_node *node;
1866 for (node = symtab_nodes; node; node = node->next)
1867 if (cgraph_node *cn = dyn_cast <cgraph_node *> (node))
1868 return cn;
1869 return NULL;
1872 /* Return next function. */
1873 static inline cgraph_node *
1874 cgraph_next_function (cgraph_node *node)
1876 symtab_node *node1 = node->next;
1877 for (; node1; node1 = node1->next)
1878 if (cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1))
1879 return cn1;
1880 return NULL;
1882 /* Walk all functions. */
1883 #define FOR_EACH_FUNCTION(node) \
1884 for ((node) = cgraph_first_function (); (node); \
1885 (node) = cgraph_next_function ((node)))
1887 /* Return true when callgraph node is a function with Gimple body defined
1888 in current unit. Functions can also be define externally or they
1889 can be thunks with no Gimple representation.
1891 Note that at WPA stage, the function body may not be present in memory. */
1893 inline bool
1894 cgraph_node::has_gimple_body_p (void)
1896 return definition && !thunk.thunk_p && !alias;
1899 /* Return first function with body defined. */
1900 static inline cgraph_node *
1901 cgraph_first_function_with_gimple_body (void)
1903 symtab_node *node;
1904 for (node = symtab_nodes; node; node = node->next)
1906 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
1907 if (cn && cn->has_gimple_body_p ())
1908 return cn;
1910 return NULL;
1913 /* Return next reachable static variable with initializer after NODE. */
1914 static inline cgraph_node *
1915 cgraph_next_function_with_gimple_body (cgraph_node *node)
1917 symtab_node *node1 = node->next;
1918 for (; node1; node1 = node1->next)
1920 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
1921 if (cn1 && cn1->has_gimple_body_p ())
1922 return cn1;
1924 return NULL;
1927 /* Walk all functions with body defined. */
1928 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1929 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1930 (node) = cgraph_next_function_with_gimple_body (node))
1932 /* Create a new static variable of type TYPE. */
1933 tree add_new_static_var (tree type);
1935 /* Uniquize all constants that appear in memory.
1936 Each constant in memory thus far output is recorded
1937 in `const_desc_table'. */
1939 struct GTY(()) constant_descriptor_tree {
1940 /* A MEM for the constant. */
1941 rtx rtl;
1943 /* The value of the constant. */
1944 tree value;
1946 /* Hash of value. Computing the hash from value each time
1947 hashfn is called can't work properly, as that means recursive
1948 use of the hash table during hash table expansion. */
1949 hashval_t hash;
1952 /* Return true when function is only called directly or it has alias.
1953 i.e. it is not externally visible, address was not taken and
1954 it is not used in any other non-standard way. */
1956 inline bool
1957 cgraph_node::only_called_directly_or_aliased_p (void)
1959 gcc_assert (!global.inlined_to);
1960 return (!force_output && !address_taken
1961 && !used_from_other_partition
1962 && !DECL_VIRTUAL_P (decl)
1963 && !DECL_STATIC_CONSTRUCTOR (decl)
1964 && !DECL_STATIC_DESTRUCTOR (decl)
1965 && !externally_visible);
1968 /* Return true when variable can be removed from variable pool
1969 if all direct calls are eliminated. */
1971 inline bool
1972 varpool_node::can_remove_if_no_refs_p (void)
1974 if (DECL_EXTERNAL (decl))
1975 return true;
1976 return (!force_output && !used_from_other_partition
1977 && ((DECL_COMDAT (decl)
1978 && !forced_by_abi
1979 && !used_from_object_file_p ())
1980 || !externally_visible
1981 || DECL_HAS_VALUE_EXPR_P (decl)));
1984 /* Return true when all references to variable must be visible in ipa_ref_list.
1985 i.e. if the variable is not externally visible or not used in some magic
1986 way (asm statement or such).
1987 The magic uses are all summarized in force_output flag. */
1989 inline bool
1990 varpool_node::all_refs_explicit_p ()
1992 return (definition
1993 && !externally_visible
1994 && !used_from_other_partition
1995 && !force_output);
1998 /* Constant pool accessor function. */
1999 htab_t constant_pool_htab (void);
2001 /* Return node that alias is aliasing. */
2003 inline cgraph_node *
2004 cgraph_node::get_alias_target (void)
2006 return dyn_cast <cgraph_node *> (symtab_node::get_alias_target ());
2009 /* Return node that alias is aliasing. */
2011 inline varpool_node *
2012 varpool_node::get_alias_target (void)
2014 return dyn_cast <varpool_node *> (symtab_node::get_alias_target ());
2017 /* Given function symbol, walk the alias chain to return the function node
2018 is alias of. Do not walk through thunks.
2019 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
2021 inline cgraph_node *
2022 cgraph_node::ultimate_alias_target (enum availability *availability)
2024 cgraph_node *n = dyn_cast <cgraph_node *> (symtab_node::ultimate_alias_target
2025 (availability));
2026 if (!n && availability)
2027 *availability = AVAIL_NOT_AVAILABLE;
2028 return n;
2031 /* For given variable pool node, walk the alias chain to return the function
2032 the variable is alias of. Do not walk through thunks.
2033 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
2035 inline varpool_node *
2036 varpool_node::ultimate_alias_target (availability *availability)
2038 varpool_node *n = dyn_cast <varpool_node *>
2039 (symtab_node::ultimate_alias_target (availability));
2041 if (!n && availability)
2042 *availability = AVAIL_NOT_AVAILABLE;
2043 return n;
2046 /* Return true when the edge E represents a direct recursion. */
2047 static inline bool
2048 cgraph_edge_recursive_p (struct cgraph_edge *e)
2050 cgraph_node *callee = e->callee->ultimate_alias_target ();
2051 if (e->caller->global.inlined_to)
2052 return e->caller->global.inlined_to->decl == callee->decl;
2053 else
2054 return e->caller->decl == callee->decl;
2057 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
2058 static inline bool
2059 decl_is_tm_clone (const_tree fndecl)
2061 cgraph_node *n = cgraph_node::get (fndecl);
2062 if (n)
2063 return n->tm_clone;
2064 return false;
2067 /* Likewise indicate that a node is needed, i.e. reachable via some
2068 external means. */
2070 inline void
2071 cgraph_node::mark_force_output (void)
2073 force_output = 1;
2074 gcc_checking_assert (!global.inlined_to);
2077 #endif /* GCC_CGRAPH_H */