[i386] Fold __builtin_ia32_shufpd to VEC_PERM_EXPR
[official-gcc.git] / gcc / cgraph.h
blob18839a4a5ecf6c2451356f0b5cfd4146b59bafae
1 /* Callgraph handling code.
2 Copyright (C) 2003-2019 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 "profile-count.h"
25 #include "ipa-ref.h"
26 #include "plugin-api.h"
28 extern void debuginfo_early_init (void);
29 extern void debuginfo_init (void);
30 extern void debuginfo_fini (void);
31 extern void debuginfo_start (void);
32 extern void debuginfo_stop (void);
33 extern void debuginfo_early_start (void);
34 extern void debuginfo_early_stop (void);
36 class ipa_opt_pass_d;
37 typedef ipa_opt_pass_d *ipa_opt_pass;
39 /* Symbol table consists of functions and variables.
40 TODO: add labels and CONST_DECLs. */
41 enum symtab_type
43 SYMTAB_SYMBOL,
44 SYMTAB_FUNCTION,
45 SYMTAB_VARIABLE
48 /* Section names are stored as reference counted strings in GGC safe hashtable
49 (to make them survive through PCH). */
51 struct GTY((for_user)) section_hash_entry
53 int ref_count;
54 char *name; /* As long as this datastructure stays in GGC, we cannot put
55 string at the tail of structure of GGC dies in horrible
56 way */
59 struct section_name_hasher : ggc_ptr_hash<section_hash_entry>
61 typedef const char *compare_type;
63 static hashval_t hash (section_hash_entry *);
64 static bool equal (section_hash_entry *, const char *);
67 enum availability
69 /* Not yet set by cgraph_function_body_availability. */
70 AVAIL_UNSET,
71 /* Function body/variable initializer is unknown. */
72 AVAIL_NOT_AVAILABLE,
73 /* Function body/variable initializer is known but might be replaced
74 by a different one from other compilation unit and thus needs to
75 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
76 arbitrary side effects on escaping variables and functions, while
77 like AVAILABLE it might access static variables. */
78 AVAIL_INTERPOSABLE,
79 /* Function body/variable initializer is known and will be used in final
80 program. */
81 AVAIL_AVAILABLE,
82 /* Function body/variable initializer is known and all it's uses are
83 explicitly visible within current unit (ie it's address is never taken and
84 it is not exported to other units). Currently used only for functions. */
85 AVAIL_LOCAL
88 /* Classification of symbols WRT partitioning. */
89 enum symbol_partitioning_class
91 /* External declarations are ignored by partitioning algorithms and they are
92 added into the boundary later via compute_ltrans_boundary. */
93 SYMBOL_EXTERNAL,
94 /* Partitioned symbols are pur into one of partitions. */
95 SYMBOL_PARTITION,
96 /* Duplicated symbols (such as comdat or constant pool references) are
97 copied into every node needing them via add_symbol_to_partition. */
98 SYMBOL_DUPLICATE
101 /* Base of all entries in the symbol table.
102 The symtab_node is inherited by cgraph and varpol nodes. */
103 class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
104 chain_next ("%h.next"), chain_prev ("%h.previous")))
105 symtab_node
107 public:
108 friend class symbol_table;
110 /* Return name. */
111 const char *name () const;
113 /* Return dump name. */
114 const char *dump_name () const;
116 /* Return asm name. */
117 const char *asm_name () const;
119 /* Return dump name with assembler name. */
120 const char *dump_asm_name () const;
122 /* Return visibility name. */
123 const char *get_visibility_string () const;
125 /* Return type_name name. */
126 const char *get_symtab_type_string () const;
128 /* Add node into symbol table. This function is not used directly, but via
129 cgraph/varpool node creation routines. */
130 void register_symbol (void);
132 /* Remove symbol from symbol table. */
133 void remove (void);
135 /* Dump symtab node to F. */
136 void dump (FILE *f);
138 /* Dump symtab node to stderr. */
139 void DEBUG_FUNCTION debug (void);
141 /* Verify consistency of node. */
142 void DEBUG_FUNCTION verify (void);
144 /* Return ipa reference from this symtab_node to
145 REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
146 of the use and STMT the statement (if it exists). */
147 ipa_ref *create_reference (symtab_node *referred_node,
148 enum ipa_ref_use use_type);
150 /* Return ipa reference from this symtab_node to
151 REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
152 of the use and STMT the statement (if it exists). */
153 ipa_ref *create_reference (symtab_node *referred_node,
154 enum ipa_ref_use use_type, gimple *stmt);
156 /* If VAL is a reference to a function or a variable, add a reference from
157 this symtab_node to the corresponding symbol table node. Return the new
158 reference or NULL if none was created. */
159 ipa_ref *maybe_create_reference (tree val, gimple *stmt);
161 /* Clone all references from symtab NODE to this symtab_node. */
162 void clone_references (symtab_node *node);
164 /* Remove all stmt references in non-speculative references.
165 Those are not maintained during inlining & clonning.
166 The exception are speculative references that are updated along
167 with callgraph edges associated with them. */
168 void clone_referring (symtab_node *node);
170 /* Clone reference REF to this symtab_node and set its stmt to STMT. */
171 ipa_ref *clone_reference (ipa_ref *ref, gimple *stmt);
173 /* Find the structure describing a reference to REFERRED_NODE
174 and associated with statement STMT. */
175 ipa_ref *find_reference (symtab_node *referred_node, gimple *stmt,
176 unsigned int lto_stmt_uid);
178 /* Remove all references that are associated with statement STMT. */
179 void remove_stmt_references (gimple *stmt);
181 /* Remove all stmt references in non-speculative references.
182 Those are not maintained during inlining & clonning.
183 The exception are speculative references that are updated along
184 with callgraph edges associated with them. */
185 void clear_stmts_in_references (void);
187 /* Remove all references in ref list. */
188 void remove_all_references (void);
190 /* Remove all referring items in ref list. */
191 void remove_all_referring (void);
193 /* Dump references in ref list to FILE. */
194 void dump_references (FILE *file);
196 /* Dump referring in list to FILE. */
197 void dump_referring (FILE *);
199 /* Get number of references for this node. */
200 inline unsigned num_references (void)
202 return ref_list.references ? ref_list.references->length () : 0;
205 /* Iterates I-th reference in the list, REF is also set. */
206 ipa_ref *iterate_reference (unsigned i, ipa_ref *&ref);
208 /* Iterates I-th referring item in the list, REF is also set. */
209 ipa_ref *iterate_referring (unsigned i, ipa_ref *&ref);
211 /* Iterates I-th referring alias item in the list, REF is also set. */
212 ipa_ref *iterate_direct_aliases (unsigned i, ipa_ref *&ref);
214 /* Return true if symtab node and TARGET represents
215 semantically equivalent symbols. */
216 bool semantically_equivalent_p (symtab_node *target);
218 /* Classify symbol symtab node for partitioning. */
219 enum symbol_partitioning_class get_partitioning_class (void);
221 /* Return comdat group. */
222 tree get_comdat_group ()
224 return x_comdat_group;
227 /* Return comdat group as identifier_node. */
228 tree get_comdat_group_id ()
230 if (x_comdat_group && TREE_CODE (x_comdat_group) != IDENTIFIER_NODE)
231 x_comdat_group = DECL_ASSEMBLER_NAME (x_comdat_group);
232 return x_comdat_group;
235 /* Set comdat group. */
236 void set_comdat_group (tree group)
238 gcc_checking_assert (!group || TREE_CODE (group) == IDENTIFIER_NODE
239 || DECL_P (group));
240 x_comdat_group = group;
243 /* Return section as string. */
244 const char * get_section ()
246 if (!x_section)
247 return NULL;
248 return x_section->name;
251 /* Remove node from same comdat group. */
252 void remove_from_same_comdat_group (void);
254 /* Add this symtab_node to the same comdat group that OLD is in. */
255 void add_to_same_comdat_group (symtab_node *old_node);
257 /* Dissolve the same_comdat_group list in which NODE resides. */
258 void dissolve_same_comdat_group_list (void);
260 /* Return true when symtab_node is known to be used from other (non-LTO)
261 object file. Known only when doing LTO via linker plugin. */
262 bool used_from_object_file_p (void);
264 /* Walk the alias chain to return the symbol NODE is alias of.
265 If NODE is not an alias, return NODE.
266 When AVAILABILITY is non-NULL, get minimal availability in the chain.
267 When REF is non-NULL, assume that reference happens in symbol REF
268 when determining the availability. */
269 symtab_node *ultimate_alias_target (enum availability *avail = NULL,
270 struct symtab_node *ref = NULL);
272 /* Return next reachable static symbol with initializer after NODE. */
273 inline symtab_node *next_defined_symbol (void);
275 /* Add reference recording that symtab node is alias of TARGET.
276 If TRANSPARENT is true make the alias to be transparent alias.
277 The function can fail in the case of aliasing cycles; in this case
278 it returns false. */
279 bool resolve_alias (symtab_node *target, bool transparent = false);
281 /* C++ FE sometimes change linkage flags after producing same
282 body aliases. */
283 void fixup_same_cpp_alias_visibility (symtab_node *target);
285 /* Call callback on symtab node and aliases associated to this node.
286 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
287 skipped. */
288 bool call_for_symbol_and_aliases (bool (*callback) (symtab_node *, void *),
289 void *data,
290 bool include_overwrite);
292 /* If node cannot be interposable by static or dynamic linker to point to
293 different definition, return this symbol. Otherwise look for alias with
294 such property and if none exists, introduce new one. */
295 symtab_node *noninterposable_alias (void);
297 /* Return node that alias is aliasing. */
298 inline symtab_node *get_alias_target (void);
300 /* Set section for symbol and its aliases. */
301 void set_section (const char *section);
303 /* Set section, do not recurse into aliases.
304 When one wants to change section of symbol and its aliases,
305 use set_section. */
306 void set_section_for_node (const char *section);
308 /* Set initialization priority to PRIORITY. */
309 void set_init_priority (priority_type priority);
311 /* Return the initialization priority. */
312 priority_type get_init_priority ();
314 /* Return availability of NODE when referenced from REF. */
315 enum availability get_availability (symtab_node *ref = NULL);
317 /* During LTO stream-in this predicate can be used to check whether node
318 in question prevails in the linking to save some memory usage. */
319 bool prevailing_p (void);
321 /* Return true if NODE binds to current definition in final executable
322 when referenced from REF. If REF is NULL return conservative value
323 for any reference. */
324 bool binds_to_current_def_p (symtab_node *ref = NULL);
326 /* Make DECL local. */
327 void make_decl_local (void);
329 /* Copy visibility from N. */
330 void copy_visibility_from (symtab_node *n);
332 /* Return desired alignment of the definition. This is NOT alignment useful
333 to access THIS, because THIS may be interposable and DECL_ALIGN should
334 be used instead. It however must be guaranteed when output definition
335 of THIS. */
336 unsigned int definition_alignment ();
338 /* Return true if alignment can be increased. */
339 bool can_increase_alignment_p ();
341 /* Increase alignment of symbol to ALIGN. */
342 void increase_alignment (unsigned int align);
344 /* Return true if list contains an alias. */
345 bool has_aliases_p (void);
347 /* Return true when the symbol is real symbol, i.e. it is not inline clone
348 or abstract function kept for debug info purposes only. */
349 bool real_symbol_p (void);
351 /* Return true when the symbol needs to be output to the LTO symbol table. */
352 bool output_to_lto_symbol_table_p (void);
354 /* Determine if symbol declaration is needed. That is, visible to something
355 either outside this translation unit, something magic in the system
356 configury. This function is used just during symbol creation. */
357 bool needed_p (void);
359 /* Return true if this symbol is a function from the C frontend specified
360 directly in RTL form (with "__RTL"). */
361 bool native_rtl_p () const;
363 /* Return true when there are references to the node. */
364 bool referred_to_p (bool include_self = true);
366 /* Return true if symbol can be discarded by linker from the binary.
367 Assume that symbol is used (so there is no need to take into account
368 garbage collecting linkers)
370 This can happen for comdats, commons and weaks when they are previaled
371 by other definition at static linking time. */
372 inline bool
373 can_be_discarded_p (void)
375 return (DECL_EXTERNAL (decl)
376 || ((get_comdat_group ()
377 || DECL_COMMON (decl)
378 || (DECL_SECTION_NAME (decl) && DECL_WEAK (decl)))
379 && ((resolution != LDPR_PREVAILING_DEF
380 && resolution != LDPR_PREVAILING_DEF_IRONLY_EXP)
381 || flag_incremental_link)
382 && resolution != LDPR_PREVAILING_DEF_IRONLY));
385 /* Return true if NODE is local to a particular COMDAT group, and must not
386 be named from outside the COMDAT. This is used for C++ decloned
387 constructors. */
388 inline bool comdat_local_p (void)
390 return (same_comdat_group && !TREE_PUBLIC (decl));
393 /* Return true if ONE and TWO are part of the same COMDAT group. */
394 inline bool in_same_comdat_group_p (symtab_node *target);
396 /* Return true if symbol is known to be nonzero. */
397 bool nonzero_address ();
399 /* Return 0 if symbol is known to have different address than S2,
400 Return 1 if symbol is known to have same address as S2,
401 return 2 otherwise.
403 If MEMORY_ACCESSED is true, assume that both memory pointer to THIS
404 and S2 is going to be accessed. This eliminates the situations when
405 either THIS or S2 is NULL and is seful for comparing bases when deciding
406 about memory aliasing. */
407 int equal_address_to (symtab_node *s2, bool memory_accessed = false);
409 /* Return true if symbol's address may possibly be compared to other
410 symbol's address. */
411 bool address_matters_p ();
413 /* Return true if NODE's address can be compared. This use properties
414 of NODE only and does not look if the address is actually taken in
415 interesting way. For that use ADDRESS_MATTERS_P instead. */
416 bool address_can_be_compared_p (void);
418 /* Return symbol table node associated with DECL, if any,
419 and NULL otherwise. */
420 static inline symtab_node *get (const_tree decl)
422 /* Check that we are called for sane type of object - functions
423 and static or external variables. */
424 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
425 || (TREE_CODE (decl) == VAR_DECL
426 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
427 || in_lto_p)));
428 /* Check that the mapping is sane - perhaps this check can go away,
429 but at the moment frontends tends to corrupt the mapping by calling
430 memcpy/memset on the tree nodes. */
431 gcc_checking_assert (!decl->decl_with_vis.symtab_node
432 || decl->decl_with_vis.symtab_node->decl == decl);
433 return decl->decl_with_vis.symtab_node;
436 /* Try to find a symtab node for declaration DECL and if it does not
437 exist or if it corresponds to an inline clone, create a new one. */
438 static inline symtab_node * get_create (tree node);
440 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
441 Return NULL if there's no such node. */
442 static symtab_node *get_for_asmname (const_tree asmname);
444 /* Verify symbol table for internal consistency. */
445 static DEBUG_FUNCTION void verify_symtab_nodes (void);
447 /* Perform internal consistency checks, if they are enabled. */
448 static inline void checking_verify_symtab_nodes (void);
450 /* Type of the symbol. */
451 ENUM_BITFIELD (symtab_type) type : 8;
453 /* The symbols resolution. */
454 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
456 /*** Flags representing the symbol type. ***/
458 /* True when symbol corresponds to a definition in current unit.
459 set via finalize_function or finalize_decl */
460 unsigned definition : 1;
461 /* True when symbol is an alias.
462 Set by ssemble_alias. */
463 unsigned alias : 1;
464 /* When true the alias is translated into its target symbol either by GCC
465 or assembler (it also may just be a duplicate declaration of the same
466 linker name).
468 Currently transparent aliases come in three different flavors
469 - aliases having the same assembler name as their target (aka duplicated
470 declarations). In this case the assembler names compare via
471 assembler_names_equal_p and weakref is false
472 - aliases that are renamed at a time being output to final file
473 by varasm.c. For those DECL_ASSEMBLER_NAME have
474 IDENTIFIER_TRANSPARENT_ALIAS set and thus also their assembler
475 name must be unique.
476 Weakrefs belong to this cateogry when we target assembler without
477 .weakref directive.
478 - weakrefs that are renamed by assembler via .weakref directive.
479 In this case the alias may or may not be definition (depending if
480 target declaration was seen by the compiler), weakref is set.
481 Unless we are before renaming statics, assembler names are different.
483 Given that we now support duplicate declarations, the second option is
484 redundant and will be removed. */
485 unsigned transparent_alias : 1;
486 /* True when alias is a weakref. */
487 unsigned weakref : 1;
488 /* C++ frontend produce same body aliases and extra name aliases for
489 virtual functions and vtables that are obviously equivalent.
490 Those aliases are bit special, especially because C++ frontend
491 visibility code is so ugly it cannot get them right at first time
492 and their visibility needs to be copied from their "masters" at
493 the end of parsing. */
494 unsigned cpp_implicit_alias : 1;
495 /* Set once the definition was analyzed. The list of references and
496 other properties are built during analysis. */
497 unsigned analyzed : 1;
498 /* Set for write-only variables. */
499 unsigned writeonly : 1;
500 /* Visibility of symbol was used for further optimization; do not
501 permit further changes. */
502 unsigned refuse_visibility_changes : 1;
504 /*** Visibility and linkage flags. ***/
506 /* Set when function is visible by other units. */
507 unsigned externally_visible : 1;
508 /* Don't reorder to other symbols having this set. */
509 unsigned no_reorder : 1;
510 /* The symbol will be assumed to be used in an invisible way (like
511 by an toplevel asm statement). */
512 unsigned force_output : 1;
513 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
514 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
515 to static and it does not inhibit optimization. */
516 unsigned forced_by_abi : 1;
517 /* True when the name is known to be unique and thus it does not need mangling. */
518 unsigned unique_name : 1;
519 /* Specify whether the section was set by user or by
520 compiler via -ffunction-sections. */
521 unsigned implicit_section : 1;
522 /* True when body and other characteristics have been removed by
523 symtab_remove_unreachable_nodes. */
524 unsigned body_removed : 1;
526 /*** WHOPR Partitioning flags.
527 These flags are used at ltrans stage when only part of the callgraph is
528 available. ***/
530 /* Set when variable is used from other LTRANS partition. */
531 unsigned used_from_other_partition : 1;
532 /* Set when function is available in the other LTRANS partition.
533 During WPA output it is used to mark nodes that are present in
534 multiple partitions. */
535 unsigned in_other_partition : 1;
539 /*** other flags. ***/
541 /* Set when symbol has address taken. */
542 unsigned address_taken : 1;
543 /* Set when init priority is set. */
544 unsigned in_init_priority_hash : 1;
546 /* Set when symbol needs to be streamed into LTO bytecode for LTO, or in case
547 of offloading, for separate compilation for a different target. */
548 unsigned need_lto_streaming : 1;
550 /* Set when symbol can be streamed into bytecode for offloading. */
551 unsigned offloadable : 1;
553 /* Set when symbol is an IFUNC resolver. */
554 unsigned ifunc_resolver : 1;
557 /* Ordering of all symtab entries. */
558 int order;
560 /* Declaration representing the symbol. */
561 tree decl;
563 /* Linked list of symbol table entries starting with symtab_nodes. */
564 symtab_node *next;
565 symtab_node *previous;
567 /* Linked list of symbols with the same asm name. There may be multiple
568 entries for single symbol name during LTO, because symbols are renamed
569 only after partitioning.
571 Because inline clones are kept in the assembler name has, they also produce
572 duplicate entries.
574 There are also several long standing bugs where frontends and builtin
575 code produce duplicated decls. */
576 symtab_node *next_sharing_asm_name;
577 symtab_node *previous_sharing_asm_name;
579 /* Circular list of nodes in the same comdat group if non-NULL. */
580 symtab_node *same_comdat_group;
582 /* Vectors of referring and referenced entities. */
583 ipa_ref_list ref_list;
585 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
586 depending to what was known to frontend on the creation time.
587 Once alias is resolved, this pointer become NULL. */
588 tree alias_target;
590 /* File stream where this node is being written to. */
591 struct lto_file_decl_data * lto_file_data;
593 PTR GTY ((skip)) aux;
595 /* Comdat group the symbol is in. Can be private if GGC allowed that. */
596 tree x_comdat_group;
598 /* Section name. Again can be private, if allowed. */
599 section_hash_entry *x_section;
601 protected:
602 /* Dump base fields of symtab nodes to F. Not to be used directly. */
603 void dump_base (FILE *);
605 /* Verify common part of symtab node. */
606 bool DEBUG_FUNCTION verify_base (void);
608 /* Remove node from symbol table. This function is not used directly, but via
609 cgraph/varpool node removal routines. */
610 void unregister (void);
612 /* Return the initialization and finalization priority information for
613 DECL. If there is no previous priority information, a freshly
614 allocated structure is returned. */
615 struct symbol_priority_map *priority_info (void);
617 /* Worker for call_for_symbol_and_aliases_1. */
618 bool call_for_symbol_and_aliases_1 (bool (*callback) (symtab_node *, void *),
619 void *data,
620 bool include_overwrite);
621 private:
622 /* Worker for set_section. */
623 static bool set_section (symtab_node *n, void *s);
625 /* Worker for symtab_resolve_alias. */
626 static bool set_implicit_section (symtab_node *n, void *);
628 /* Worker searching noninterposable alias. */
629 static bool noninterposable_alias (symtab_node *node, void *data);
631 /* Worker for ultimate_alias_target. */
632 symtab_node *ultimate_alias_target_1 (enum availability *avail = NULL,
633 symtab_node *ref = NULL);
635 /* Get dump name with normal or assembly name. */
636 const char *get_dump_name (bool asm_name_p) const;
639 inline void
640 symtab_node::checking_verify_symtab_nodes (void)
642 if (flag_checking)
643 symtab_node::verify_symtab_nodes ();
646 /* Walk all aliases for NODE. */
647 #define FOR_EACH_ALIAS(node, alias) \
648 for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
650 /* This is the information that is put into the cgraph local structure
651 to recover a function. */
652 struct lto_file_decl_data;
654 extern const char * const cgraph_availability_names[];
655 extern const char * const ld_plugin_symbol_resolution_names[];
656 extern const char * const tls_model_names[];
658 /* Sub-structure of cgraph_node. Holds information about thunk, used only for
659 same body aliases.
661 Thunks are basically wrappers around methods which are introduced in case
662 of multiple inheritance in order to adjust the value of the "this" pointer
663 or of the returned value.
665 In the case of this-adjusting thunks, each back-end can override the
666 can_output_mi_thunk/output_mi_thunk target hooks to generate a minimal thunk
667 (with a tail call for instance) directly as assembly. For the default hook
668 or for the case where the can_output_mi_thunk hooks return false, the thunk
669 is gimplified and lowered using the regular machinery. */
671 struct GTY(()) cgraph_thunk_info {
672 /* Offset used to adjust "this". */
673 HOST_WIDE_INT fixed_offset;
675 /* Offset in the virtual table to get the offset to adjust "this". Valid iff
676 VIRTUAL_OFFSET_P is true. */
677 HOST_WIDE_INT virtual_value;
679 /* Offset from "this" to get the offset to adjust "this". Zero means: this
680 offset is to be ignored. */
681 HOST_WIDE_INT indirect_offset;
683 /* Thunk target, i.e. the method that this thunk wraps. Depending on the
684 TARGET_USE_LOCAL_THUNK_ALIAS_P macro, this may have to be a new alias. */
685 tree alias;
687 /* Nonzero for a "this" adjusting thunk and zero for a result adjusting
688 thunk. */
689 bool this_adjusting;
691 /* If true, this thunk is what we call a virtual thunk. In this case:
692 * for this-adjusting thunks, after the FIXED_OFFSET based adjustment is
693 done, add to the result the offset found in the vtable at:
694 vptr + VIRTUAL_VALUE
695 * for result-adjusting thunks, the FIXED_OFFSET adjustment is done after
696 the virtual one. */
697 bool virtual_offset_p;
699 /* Set to true when alias node (the cgraph_node to which this struct belong)
700 is a thunk. Access to any other fields is invalid if this is false. */
701 bool thunk_p;
704 /* Information about the function collected locally.
705 Available after function is analyzed. */
707 struct GTY(()) cgraph_local_info {
708 /* Set when function is visible in current compilation unit only and
709 its address is never taken. */
710 unsigned local : 1;
712 /* False when there is something makes versioning impossible. */
713 unsigned versionable : 1;
715 /* False when function calling convention and signature cannot be changed.
716 This is the case when __builtin_apply_args is used. */
717 unsigned can_change_signature : 1;
719 /* True when the function has been originally extern inline, but it is
720 redefined now. */
721 unsigned redefined_extern_inline : 1;
723 /* True if the function may enter serial irrevocable mode. */
724 unsigned tm_may_enter_irr : 1;
727 /* Information about the function that needs to be computed globally
728 once compilation is finished. Available only with -funit-at-a-time. */
730 struct GTY(()) cgraph_global_info {
731 /* For inline clones this points to the function they will be
732 inlined into. */
733 cgraph_node *inlined_to;
736 /* Represent which DECL tree (or reference to such tree)
737 will be replaced by another tree while versioning. */
738 struct GTY(()) ipa_replace_map
740 /* The tree that will be replaced. */
741 tree old_tree;
742 /* The new (replacing) tree. */
743 tree new_tree;
744 /* Parameter number to replace, when old_tree is NULL. */
745 int parm_num;
746 /* True when a substitution should be done, false otherwise. */
747 bool replace_p;
748 /* True when we replace a reference to old_tree. */
749 bool ref_p;
752 struct GTY(()) cgraph_clone_info
754 vec<ipa_replace_map *, va_gc> *tree_map;
755 bitmap args_to_skip;
756 bitmap combined_args_to_skip;
759 enum cgraph_simd_clone_arg_type
761 SIMD_CLONE_ARG_TYPE_VECTOR,
762 SIMD_CLONE_ARG_TYPE_UNIFORM,
763 /* These are only for integer/pointer arguments passed by value. */
764 SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
765 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
766 /* These 6 are only for reference type arguments or arguments passed
767 by reference. */
768 SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP,
769 SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP,
770 SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP,
771 SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP,
772 SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP,
773 SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP,
774 SIMD_CLONE_ARG_TYPE_MASK
777 /* Function arguments in the original function of a SIMD clone.
778 Supplementary data for `struct simd_clone'. */
780 struct GTY(()) cgraph_simd_clone_arg {
781 /* Original function argument as it originally existed in
782 DECL_ARGUMENTS. */
783 tree orig_arg;
785 /* orig_arg's function (or for extern functions type from
786 TYPE_ARG_TYPES). */
787 tree orig_type;
789 /* If argument is a vector, this holds the vector version of
790 orig_arg that after adjusting the argument types will live in
791 DECL_ARGUMENTS. Otherwise, this is NULL.
793 This basically holds:
794 vector(simdlen) __typeof__(orig_arg) new_arg. */
795 tree vector_arg;
797 /* vector_arg's type (or for extern functions new vector type. */
798 tree vector_type;
800 /* If argument is a vector, this holds the array where the simd
801 argument is held while executing the simd clone function. This
802 is a local variable in the cloned function. Its content is
803 copied from vector_arg upon entry to the clone.
805 This basically holds:
806 __typeof__(orig_arg) simd_array[simdlen]. */
807 tree simd_array;
809 /* A SIMD clone's argument can be either linear (constant or
810 variable), uniform, or vector. */
811 enum cgraph_simd_clone_arg_type arg_type;
813 /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_*CONSTANT_STEP this is
814 the constant linear step, if arg_type is
815 SIMD_CLONE_ARG_TYPE_LINEAR_*VARIABLE_STEP, this is index of
816 the uniform argument holding the step, otherwise 0. */
817 HOST_WIDE_INT linear_step;
819 /* Variable alignment if available, otherwise 0. */
820 unsigned int alignment;
823 /* Specific data for a SIMD function clone. */
825 struct GTY(()) cgraph_simd_clone {
826 /* Number of words in the SIMD lane associated with this clone. */
827 unsigned int simdlen;
829 /* Number of annotated function arguments in `args'. This is
830 usually the number of named arguments in FNDECL. */
831 unsigned int nargs;
833 /* Max hardware vector size in bits for integral vectors. */
834 unsigned int vecsize_int;
836 /* Max hardware vector size in bits for floating point vectors. */
837 unsigned int vecsize_float;
839 /* Machine mode of the mask argument(s), if they are to be passed
840 as bitmasks in integer argument(s). VOIDmode if masks are passed
841 as vectors of characteristic type. */
842 machine_mode mask_mode;
844 /* The mangling character for a given vector size. This is used
845 to determine the ISA mangling bit as specified in the Intel
846 Vector ABI. */
847 unsigned char vecsize_mangle;
849 /* True if this is the masked, in-branch version of the clone,
850 otherwise false. */
851 unsigned int inbranch : 1;
853 /* Doubly linked list of SIMD clones. */
854 cgraph_node *prev_clone, *next_clone;
856 /* Original cgraph node the SIMD clones were created for. */
857 cgraph_node *origin;
859 /* Annotated function arguments for the original function. */
860 cgraph_simd_clone_arg GTY((length ("%h.nargs"))) args[1];
863 /* Function Multiversioning info. */
864 struct GTY((for_user)) cgraph_function_version_info {
865 /* The cgraph_node for which the function version info is stored. */
866 cgraph_node *this_node;
867 /* Chains all the semantically identical function versions. The
868 first function in this chain is the version_info node of the
869 default function. */
870 cgraph_function_version_info *prev;
871 /* If this version node corresponds to a dispatcher for function
872 versions, this points to the version info node of the default
873 function, the first node in the chain. */
874 cgraph_function_version_info *next;
875 /* If this node corresponds to a function version, this points
876 to the dispatcher function decl, which is the function that must
877 be called to execute the right function version at run-time.
879 If this cgraph node is a dispatcher (if dispatcher_function is
880 true, in the cgraph_node struct) for function versions, this
881 points to resolver function, which holds the function body of the
882 dispatcher. The dispatcher decl is an alias to the resolver
883 function decl. */
884 tree dispatcher_resolver;
887 #define DEFCIFCODE(code, type, string) CIF_ ## code,
888 /* Reasons for inlining failures. */
890 enum cgraph_inline_failed_t {
891 #include "cif-code.def"
892 CIF_N_REASONS
895 enum cgraph_inline_failed_type_t
897 CIF_FINAL_NORMAL = 0,
898 CIF_FINAL_ERROR
901 struct cgraph_edge;
903 struct cgraph_edge_hasher : ggc_ptr_hash<cgraph_edge>
905 typedef gimple *compare_type;
907 static hashval_t hash (cgraph_edge *);
908 static hashval_t hash (gimple *);
909 static bool equal (cgraph_edge *, gimple *);
912 /* The cgraph data structure.
913 Each function decl has assigned cgraph_node listing callees and callers. */
915 struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node {
916 public:
917 friend class symbol_table;
919 /* Remove the node from cgraph and all inline clones inlined into it.
920 Skip however removal of FORBIDDEN_NODE and return true if it needs to be
921 removed. This allows to call the function from outer loop walking clone
922 tree. */
923 bool remove_symbol_and_inline_clones (cgraph_node *forbidden_node = NULL);
925 /* Record all references from cgraph_node that are taken
926 in statement STMT. */
927 void record_stmt_references (gimple *stmt);
929 /* Like cgraph_set_call_stmt but walk the clone tree and update all
930 clones sharing the same function body.
931 When WHOLE_SPECULATIVE_EDGES is true, all three components of
932 speculative edge gets updated. Otherwise we update only direct
933 call. */
934 void set_call_stmt_including_clones (gimple *old_stmt, gcall *new_stmt,
935 bool update_speculative = true);
937 /* Walk the alias chain to return the function cgraph_node is alias of.
938 Walk through thunk, too.
939 When AVAILABILITY is non-NULL, get minimal availability in the chain.
940 When REF is non-NULL, assume that reference happens in symbol REF
941 when determining the availability. */
942 cgraph_node *function_symbol (enum availability *avail = NULL,
943 struct symtab_node *ref = NULL);
945 /* Walk the alias chain to return the function cgraph_node is alias of.
946 Walk through non virtual thunks, too. Thus we return either a function
947 or a virtual thunk node.
948 When AVAILABILITY is non-NULL, get minimal availability in the chain.
949 When REF is non-NULL, assume that reference happens in symbol REF
950 when determining the availability. */
951 cgraph_node *function_or_virtual_thunk_symbol
952 (enum availability *avail = NULL,
953 struct symtab_node *ref = NULL);
955 /* Create node representing clone of N executed COUNT times. Decrease
956 the execution counts from original node too.
957 The new clone will have decl set to DECL that may or may not be the same
958 as decl of N.
960 When UPDATE_ORIGINAL is true, the counts are subtracted from the original
961 function's profile to reflect the fact that part of execution is handled
962 by node.
963 When CALL_DUPLICATOIN_HOOK is true, the ipa passes are acknowledged about
964 the new clone. Otherwise the caller is responsible for doing so later.
966 If the new node is being inlined into another one, NEW_INLINED_TO should be
967 the outline function the new one is (even indirectly) inlined to.
968 All hooks will see this in node's global.inlined_to, when invoked.
969 Can be NULL if the node is not inlined. SUFFIX is string that is appended
970 to the original name. */
971 cgraph_node *create_clone (tree decl, profile_count count,
972 bool update_original,
973 vec<cgraph_edge *> redirect_callers,
974 bool call_duplication_hook,
975 cgraph_node *new_inlined_to,
976 bitmap args_to_skip, const char *suffix = NULL);
978 /* Create callgraph node clone with new declaration. The actual body will be
979 copied later at compilation stage. The name of the new clone will be
980 constructed from the name of the original node, SUFFIX and NUM_SUFFIX. */
981 cgraph_node *create_virtual_clone (vec<cgraph_edge *> redirect_callers,
982 vec<ipa_replace_map *, va_gc> *tree_map,
983 bitmap args_to_skip, const char * suffix,
984 unsigned num_suffix);
986 /* cgraph node being removed from symbol table; see if its entry can be
987 replaced by other inline clone. */
988 cgraph_node *find_replacement (void);
990 /* Create a new cgraph node which is the new version of
991 callgraph node. REDIRECT_CALLERS holds the callers
992 edges which should be redirected to point to
993 NEW_VERSION. ALL the callees edges of the node
994 are cloned to the new version node. Return the new
995 version node.
997 If non-NULL BLOCK_TO_COPY determine what basic blocks
998 was copied to prevent duplications of calls that are dead
999 in the clone.
1001 SUFFIX is string that is appended to the original name. */
1003 cgraph_node *create_version_clone (tree new_decl,
1004 vec<cgraph_edge *> redirect_callers,
1005 bitmap bbs_to_copy,
1006 const char *suffix = NULL);
1008 /* Perform function versioning.
1009 Function versioning includes copying of the tree and
1010 a callgraph update (creating a new cgraph node and updating
1011 its callees and callers).
1013 REDIRECT_CALLERS varray includes the edges to be redirected
1014 to the new version.
1016 TREE_MAP is a mapping of tree nodes we want to replace with
1017 new ones (according to results of prior analysis).
1019 If non-NULL ARGS_TO_SKIP determine function parameters to remove
1020 from new version.
1021 If SKIP_RETURN is true, the new version will return void.
1022 If non-NULL BLOCK_TO_COPY determine what basic blocks to copy.
1023 If non_NULL NEW_ENTRY determine new entry BB of the clone.
1025 If TARGET_ATTRIBUTES is non-null, when creating a new declaration,
1026 add the attributes to DECL_ATTRIBUTES. And call valid_attribute_p
1027 that will promote value of the attribute DECL_FUNCTION_SPECIFIC_TARGET
1028 of the declaration.
1030 Return the new version's cgraph node. */
1031 cgraph_node *create_version_clone_with_body
1032 (vec<cgraph_edge *> redirect_callers,
1033 vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip,
1034 bool skip_return, bitmap bbs_to_copy, basic_block new_entry_block,
1035 const char *clone_name, tree target_attributes = NULL_TREE);
1037 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
1038 corresponding to cgraph_node. */
1039 cgraph_function_version_info *insert_new_function_version (void);
1041 /* Get the cgraph_function_version_info node corresponding to node. */
1042 cgraph_function_version_info *function_version (void);
1044 /* Discover all functions and variables that are trivially needed, analyze
1045 them as well as all functions and variables referred by them */
1046 void analyze (void);
1048 /* Add thunk alias into callgraph. The alias declaration is ALIAS and it
1049 aliases DECL with an adjustments made into the first parameter.
1050 See comments in struct cgraph_thunk_info for detail on the parameters. */
1051 cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
1052 HOST_WIDE_INT fixed_offset,
1053 HOST_WIDE_INT virtual_value,
1054 HOST_WIDE_INT indirect_offset,
1055 tree virtual_offset,
1056 tree real_alias);
1059 /* Return node that alias is aliasing. */
1060 inline cgraph_node *get_alias_target (void);
1062 /* Given function symbol, walk the alias chain to return the function node
1063 is alias of. Do not walk through thunks.
1064 When AVAILABILITY is non-NULL, get minimal availability in the chain.
1065 When REF is non-NULL, assume that reference happens in symbol REF
1066 when determining the availability. */
1068 cgraph_node *ultimate_alias_target (availability *availability = NULL,
1069 symtab_node *ref = NULL);
1071 /* Expand thunk NODE to gimple if possible.
1072 When FORCE_GIMPLE_THUNK is true, gimple thunk is created and
1073 no assembler is produced.
1074 When OUTPUT_ASM_THUNK is true, also produce assembler for
1075 thunks that are not lowered. */
1076 bool expand_thunk (bool output_asm_thunks, bool force_gimple_thunk);
1078 /* Call expand_thunk on all callers that are thunks and analyze those
1079 nodes that were expanded. */
1080 void expand_all_artificial_thunks ();
1082 /* Assemble thunks and aliases associated to node. */
1083 void assemble_thunks_and_aliases (void);
1085 /* Expand function specified by node. */
1086 void expand (void);
1088 /* As an GCC extension we allow redefinition of the function. The
1089 semantics when both copies of bodies differ is not well defined.
1090 We replace the old body with new body so in unit at a time mode
1091 we always use new body, while in normal mode we may end up with
1092 old body inlined into some functions and new body expanded and
1093 inlined in others. */
1094 void reset (void);
1096 /* Creates a wrapper from cgraph_node to TARGET node. Thunk is used for this
1097 kind of wrapper method. */
1098 void create_wrapper (cgraph_node *target);
1100 /* Verify cgraph nodes of the cgraph node. */
1101 void DEBUG_FUNCTION verify_node (void);
1103 /* Remove function from symbol table. */
1104 void remove (void);
1106 /* Dump call graph node to file F. */
1107 void dump (FILE *f);
1109 /* Dump call graph node to stderr. */
1110 void DEBUG_FUNCTION debug (void);
1112 /* When doing LTO, read cgraph_node's body from disk if it is not already
1113 present. */
1114 bool get_untransformed_body (void);
1116 /* Prepare function body. When doing LTO, read cgraph_node's body from disk
1117 if it is not already present. When some IPA transformations are scheduled,
1118 apply them. */
1119 bool get_body (void);
1121 /* Release memory used to represent body of function.
1122 Use this only for functions that are released before being translated to
1123 target code (i.e. RTL). Functions that are compiled to RTL and beyond
1124 are free'd in final.c via free_after_compilation(). */
1125 void release_body (bool keep_arguments = false);
1127 /* Return the DECL_STRUCT_FUNCTION of the function. */
1128 struct function *get_fun (void);
1130 /* cgraph_node is no longer nested function; update cgraph accordingly. */
1131 void unnest (void);
1133 /* Bring cgraph node local. */
1134 void make_local (void);
1136 /* Likewise indicate that a node is having address taken. */
1137 void mark_address_taken (void);
1139 /* Set fialization priority to PRIORITY. */
1140 void set_fini_priority (priority_type priority);
1142 /* Return the finalization priority. */
1143 priority_type get_fini_priority (void);
1145 /* Create edge from a given function to CALLEE in the cgraph. */
1146 cgraph_edge *create_edge (cgraph_node *callee,
1147 gcall *call_stmt, profile_count count);
1149 /* Create an indirect edge with a yet-undetermined callee where the call
1150 statement destination is a formal parameter of the caller with index
1151 PARAM_INDEX. */
1152 cgraph_edge *create_indirect_edge (gcall *call_stmt, int ecf_flags,
1153 profile_count count,
1154 bool compute_indirect_info = true);
1156 /* Like cgraph_create_edge walk the clone tree and update all clones sharing
1157 same function body. If clones already have edge for OLD_STMT; only
1158 update the edge same way as cgraph_set_call_stmt_including_clones does. */
1159 void create_edge_including_clones (cgraph_node *callee,
1160 gimple *old_stmt, gcall *stmt,
1161 profile_count count,
1162 cgraph_inline_failed_t reason);
1164 /* Return the callgraph edge representing the GIMPLE_CALL statement
1165 CALL_STMT. */
1166 cgraph_edge *get_edge (gimple *call_stmt);
1168 /* Collect all callers of cgraph_node and its aliases that are known to lead
1169 to NODE (i.e. are not overwritable) and that are not thunks. */
1170 vec<cgraph_edge *> collect_callers (void);
1172 /* Remove all callers from the node. */
1173 void remove_callers (void);
1175 /* Remove all callees from the node. */
1176 void remove_callees (void);
1178 /* Return function availability. See cgraph.h for description of individual
1179 return values. */
1180 enum availability get_availability (symtab_node *ref = NULL);
1182 /* Set TREE_NOTHROW on cgraph_node's decl and on aliases of the node
1183 if any to NOTHROW. */
1184 bool set_nothrow_flag (bool nothrow);
1186 /* SET DECL_IS_MALLOC on cgraph_node's decl and on aliases of the node
1187 if any. */
1188 bool set_malloc_flag (bool malloc_p);
1190 /* If SET_CONST is true, mark function, aliases and thunks to be ECF_CONST.
1191 If SET_CONST if false, clear the flag.
1193 When setting the flag be careful about possible interposition and
1194 do not set the flag for functions that can be interposet and set pure
1195 flag for functions that can bind to other definition.
1197 Return true if any change was done. */
1199 bool set_const_flag (bool set_const, bool looping);
1201 /* Set DECL_PURE_P on cgraph_node's decl and on aliases of the node
1202 if any to PURE.
1204 When setting the flag, be careful about possible interposition.
1205 Return true if any change was done. */
1207 bool set_pure_flag (bool pure, bool looping);
1209 /* Call callback on function and aliases associated to the function.
1210 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
1211 skipped. */
1213 bool call_for_symbol_and_aliases (bool (*callback) (cgraph_node *,
1214 void *),
1215 void *data, bool include_overwritable);
1217 /* Call callback on cgraph_node, thunks and aliases associated to NODE.
1218 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
1219 skipped. When EXCLUDE_VIRTUAL_THUNKS is true, virtual thunks are
1220 skipped. */
1221 bool call_for_symbol_thunks_and_aliases (bool (*callback) (cgraph_node *node,
1222 void *data),
1223 void *data,
1224 bool include_overwritable,
1225 bool exclude_virtual_thunks = false);
1227 /* Likewise indicate that a node is needed, i.e. reachable via some
1228 external means. */
1229 inline void mark_force_output (void);
1231 /* Return true when function can be marked local. */
1232 bool local_p (void);
1234 /* Return true if cgraph_node can be made local for API change.
1235 Extern inline functions and C++ COMDAT functions can be made local
1236 at the expense of possible code size growth if function is used in multiple
1237 compilation units. */
1238 bool can_be_local_p (void);
1240 /* Return true when cgraph_node cannot return or throw and thus
1241 it is safe to ignore its side effects for IPA analysis. */
1242 bool cannot_return_p (void);
1244 /* Return true when function cgraph_node and all its aliases are only called
1245 directly.
1246 i.e. it is not externally visible, address was not taken and
1247 it is not used in any other non-standard way. */
1248 bool only_called_directly_p (void);
1250 /* Return true when function is only called directly or it has alias.
1251 i.e. it is not externally visible, address was not taken and
1252 it is not used in any other non-standard way. */
1253 inline bool only_called_directly_or_aliased_p (void);
1255 /* Return true when function cgraph_node can be expected to be removed
1256 from program when direct calls in this compilation unit are removed.
1258 As a special case COMDAT functions are
1259 cgraph_can_remove_if_no_direct_calls_p while the are not
1260 cgraph_only_called_directly_p (it is possible they are called from other
1261 unit)
1263 This function behaves as cgraph_only_called_directly_p because eliminating
1264 all uses of COMDAT function does not make it necessarily disappear from
1265 the program unless we are compiling whole program or we do LTO. In this
1266 case we know we win since dynamic linking will not really discard the
1267 linkonce section.
1269 If WILL_INLINE is true, assume that function will be inlined into all the
1270 direct calls. */
1271 bool will_be_removed_from_program_if_no_direct_calls_p
1272 (bool will_inline = false);
1274 /* Return true when function can be removed from callgraph
1275 if all direct calls and references are eliminated. The function does
1276 not take into account comdat groups. */
1277 bool can_remove_if_no_direct_calls_and_refs_p (void);
1279 /* Return true when function cgraph_node and its aliases can be removed from
1280 callgraph if all direct calls are eliminated.
1281 If WILL_INLINE is true, assume that function will be inlined into all the
1282 direct calls. */
1283 bool can_remove_if_no_direct_calls_p (bool will_inline = false);
1285 /* Return true when callgraph node is a function with Gimple body defined
1286 in current unit. Functions can also be define externally or they
1287 can be thunks with no Gimple representation.
1289 Note that at WPA stage, the function body may not be present in memory. */
1290 inline bool has_gimple_body_p (void);
1292 /* Return true if this node represents a former, i.e. an expanded, thunk. */
1293 inline bool former_thunk_p (void);
1295 /* Return true if function should be optimized for size. */
1296 bool optimize_for_size_p (void);
1298 /* Dump the callgraph to file F. */
1299 static void dump_cgraph (FILE *f);
1301 /* Dump the call graph to stderr. */
1302 static inline
1303 void debug_cgraph (void)
1305 dump_cgraph (stderr);
1308 /* Get unique identifier of the node. */
1309 inline int get_uid ()
1311 return m_uid;
1314 /* Get summary id of the node. */
1315 inline int get_summary_id ()
1317 return m_summary_id;
1320 /* Record that DECL1 and DECL2 are semantically identical function
1321 versions. */
1322 static void record_function_versions (tree decl1, tree decl2);
1324 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
1325 DECL is a duplicate declaration. */
1326 static void delete_function_version_by_decl (tree decl);
1328 /* Add the function FNDECL to the call graph.
1329 Unlike finalize_function, this function is intended to be used
1330 by middle end and allows insertion of new function at arbitrary point
1331 of compilation. The function can be either in high, low or SSA form
1332 GIMPLE.
1334 The function is assumed to be reachable and have address taken (so no
1335 API breaking optimizations are performed on it).
1337 Main work done by this function is to enqueue the function for later
1338 processing to avoid need the passes to be re-entrant. */
1339 static void add_new_function (tree fndecl, bool lowered);
1341 /* Return callgraph node for given symbol and check it is a function. */
1342 static inline cgraph_node *get (const_tree decl)
1344 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
1345 return dyn_cast <cgraph_node *> (symtab_node::get (decl));
1348 /* DECL has been parsed. Take it, queue it, compile it at the whim of the
1349 logic in effect. If NO_COLLECT is true, then our caller cannot stand to
1350 have the garbage collector run at the moment. We would need to either
1351 create a new GC context, or just not compile right now. */
1352 static void finalize_function (tree, bool);
1354 /* Return cgraph node assigned to DECL. Create new one when needed. */
1355 static cgraph_node * create (tree decl);
1357 /* Try to find a call graph node for declaration DECL and if it does not
1358 exist or if it corresponds to an inline clone, create a new one. */
1359 static cgraph_node * get_create (tree);
1361 /* Return local info for the compiled function. */
1362 static cgraph_local_info *local_info (tree decl);
1364 /* Return local info for the compiled function. */
1365 static struct cgraph_rtl_info *rtl_info (tree);
1367 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
1368 Return NULL if there's no such node. */
1369 static cgraph_node *get_for_asmname (tree asmname);
1371 /* Attempt to mark ALIAS as an alias to DECL. Return alias node if
1372 successful and NULL otherwise.
1373 Same body aliases are output whenever the body of DECL is output,
1374 and cgraph_node::get (ALIAS) transparently
1375 returns cgraph_node::get (DECL). */
1376 static cgraph_node * create_same_body_alias (tree alias, tree decl);
1378 /* Verify whole cgraph structure. */
1379 static void DEBUG_FUNCTION verify_cgraph_nodes (void);
1381 /* Verify cgraph, if consistency checking is enabled. */
1382 static inline void checking_verify_cgraph_nodes (void);
1384 /* Worker to bring NODE local. */
1385 static bool make_local (cgraph_node *node, void *);
1387 /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing
1388 the function body is associated
1389 with (not necessarily cgraph_node (DECL). */
1390 static cgraph_node *create_alias (tree alias, tree target);
1392 /* Return true if NODE has thunk. */
1393 static bool has_thunk_p (cgraph_node *node, void *);
1395 cgraph_edge *callees;
1396 cgraph_edge *callers;
1397 /* List of edges representing indirect calls with a yet undetermined
1398 callee. */
1399 cgraph_edge *indirect_calls;
1400 /* For nested functions points to function the node is nested in. */
1401 cgraph_node *origin;
1402 /* Points to first nested function, if any. */
1403 cgraph_node *nested;
1404 /* Pointer to the next function with same origin, if any. */
1405 cgraph_node *next_nested;
1406 /* Pointer to the next clone. */
1407 cgraph_node *next_sibling_clone;
1408 cgraph_node *prev_sibling_clone;
1409 cgraph_node *clones;
1410 cgraph_node *clone_of;
1411 /* For functions with many calls sites it holds map from call expression
1412 to the edge to speed up cgraph_edge function. */
1413 hash_table<cgraph_edge_hasher> *GTY(()) call_site_hash;
1414 /* Declaration node used to be clone of. */
1415 tree former_clone_of;
1417 /* If this is a SIMD clone, this points to the SIMD specific
1418 information for it. */
1419 cgraph_simd_clone *simdclone;
1420 /* If this function has SIMD clones, this points to the first clone. */
1421 cgraph_node *simd_clones;
1423 /* Interprocedural passes scheduled to have their transform functions
1424 applied next time we execute local pass on them. We maintain it
1425 per-function in order to allow IPA passes to introduce new functions. */
1426 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
1428 cgraph_local_info local;
1429 cgraph_global_info global;
1430 struct cgraph_rtl_info *rtl;
1431 cgraph_clone_info clone;
1432 cgraph_thunk_info thunk;
1434 /* Expected number of executions: calculated in profile.c. */
1435 profile_count count;
1436 /* How to scale counts at materialization time; used to merge
1437 LTO units with different number of profile runs. */
1438 int count_materialization_scale;
1439 /* ID assigned by the profiling. */
1440 unsigned int profile_id;
1441 /* Time profiler: first run of function. */
1442 int tp_first_run;
1444 /* Set when decl is an abstract function pointed to by the
1445 ABSTRACT_DECL_ORIGIN of a reachable function. */
1446 unsigned used_as_abstract_origin : 1;
1447 /* Set once the function is lowered (i.e. its CFG is built). */
1448 unsigned lowered : 1;
1449 /* Set once the function has been instantiated and its callee
1450 lists created. */
1451 unsigned process : 1;
1452 /* How commonly executed the node is. Initialized during branch
1453 probabilities pass. */
1454 ENUM_BITFIELD (node_frequency) frequency : 2;
1455 /* True when function can only be called at startup (from static ctor). */
1456 unsigned only_called_at_startup : 1;
1457 /* True when function can only be called at startup (from static dtor). */
1458 unsigned only_called_at_exit : 1;
1459 /* True when function is the transactional clone of a function which
1460 is called only from inside transactions. */
1461 /* ?? We should be able to remove this. We have enough bits in
1462 cgraph to calculate it. */
1463 unsigned tm_clone : 1;
1464 /* True if this decl is a dispatcher for function versions. */
1465 unsigned dispatcher_function : 1;
1466 /* True if this decl calls a COMDAT-local function. This is set up in
1467 compute_fn_summary and inline_call. */
1468 unsigned calls_comdat_local : 1;
1469 /* True if node has been created by merge operation in IPA-ICF. */
1470 unsigned icf_merged: 1;
1471 /* True if call to node can't result in a call to free, munmap or
1472 other operation that could make previously non-trapping memory
1473 accesses trapping. */
1474 unsigned nonfreeing_fn : 1;
1475 /* True if there was multiple COMDAT bodies merged by lto-symtab. */
1476 unsigned merged_comdat : 1;
1477 /* True if function was created to be executed in parallel. */
1478 unsigned parallelized_function : 1;
1479 /* True if function is part split out by ipa-split. */
1480 unsigned split_part : 1;
1481 /* True if the function appears as possible target of indirect call. */
1482 unsigned indirect_call_target : 1;
1484 private:
1485 /* Unique id of the node. */
1486 int m_uid;
1488 /* Summary id that is recycled. */
1489 int m_summary_id;
1491 /* Worker for call_for_symbol_and_aliases. */
1492 bool call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *,
1493 void *),
1494 void *data, bool include_overwritable);
1497 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
1498 can appear in multiple sets. */
1499 struct cgraph_node_set_def
1501 hash_map<cgraph_node *, size_t> *map;
1502 vec<cgraph_node *> nodes;
1505 typedef cgraph_node_set_def *cgraph_node_set;
1506 typedef struct varpool_node_set_def *varpool_node_set;
1508 class varpool_node;
1510 /* A varpool node set is a collection of varpool nodes. A varpool node
1511 can appear in multiple sets. */
1512 struct varpool_node_set_def
1514 hash_map<varpool_node *, size_t> * map;
1515 vec<varpool_node *> nodes;
1518 /* Iterator structure for cgraph node sets. */
1519 struct cgraph_node_set_iterator
1521 cgraph_node_set set;
1522 unsigned index;
1525 /* Iterator structure for varpool node sets. */
1526 struct varpool_node_set_iterator
1528 varpool_node_set set;
1529 unsigned index;
1532 /* Context of polymorphic call. It represent information about the type of
1533 instance that may reach the call. This is used by ipa-devirt walkers of the
1534 type inheritance graph. */
1536 class GTY(()) ipa_polymorphic_call_context {
1537 public:
1538 /* The called object appears in an object of type OUTER_TYPE
1539 at offset OFFSET. When information is not 100% reliable, we
1540 use SPECULATIVE_OUTER_TYPE and SPECULATIVE_OFFSET. */
1541 HOST_WIDE_INT offset;
1542 HOST_WIDE_INT speculative_offset;
1543 tree outer_type;
1544 tree speculative_outer_type;
1545 /* True if outer object may be in construction or destruction. */
1546 unsigned maybe_in_construction : 1;
1547 /* True if outer object may be of derived type. */
1548 unsigned maybe_derived_type : 1;
1549 /* True if speculative outer object may be of derived type. We always
1550 speculate that construction does not happen. */
1551 unsigned speculative_maybe_derived_type : 1;
1552 /* True if the context is invalid and all calls should be redirected
1553 to BUILTIN_UNREACHABLE. */
1554 unsigned invalid : 1;
1555 /* True if the outer type is dynamic. */
1556 unsigned dynamic : 1;
1558 /* Build empty "I know nothing" context. */
1559 ipa_polymorphic_call_context ();
1560 /* Build polymorphic call context for indirect call E. */
1561 ipa_polymorphic_call_context (cgraph_edge *e);
1562 /* Build polymorphic call context for IP invariant CST.
1563 If specified, OTR_TYPE specify the type of polymorphic call
1564 that takes CST+OFFSET as a prameter. */
1565 ipa_polymorphic_call_context (tree cst, tree otr_type = NULL,
1566 HOST_WIDE_INT offset = 0);
1567 /* Build context for pointer REF contained in FNDECL at statement STMT.
1568 if INSTANCE is non-NULL, return pointer to the object described by
1569 the context. */
1570 ipa_polymorphic_call_context (tree fndecl, tree ref, gimple *stmt,
1571 tree *instance = NULL);
1573 /* Look for vtable stores or constructor calls to work out dynamic type
1574 of memory location. */
1575 bool get_dynamic_type (tree, tree, tree, gimple *, unsigned *);
1577 /* Make context non-speculative. */
1578 void clear_speculation ();
1580 /* Produce context specifying all derrived types of OTR_TYPE. If OTR_TYPE is
1581 NULL, the context is set to dummy "I know nothing" setting. */
1582 void clear_outer_type (tree otr_type = NULL);
1584 /* Walk container types and modify context to point to actual class
1585 containing OTR_TYPE (if non-NULL) as base class.
1586 Return true if resulting context is valid.
1588 When CONSIDER_PLACEMENT_NEW is false, reject contexts that may be made
1589 valid only via allocation of new polymorphic type inside by means
1590 of placement new.
1592 When CONSIDER_BASES is false, only look for actual fields, not base types
1593 of TYPE. */
1594 bool restrict_to_inner_class (tree otr_type,
1595 bool consider_placement_new = true,
1596 bool consider_bases = true);
1598 /* Adjust all offsets in contexts by given number of bits. */
1599 void offset_by (HOST_WIDE_INT);
1600 /* Use when we cannot track dynamic type change. This speculatively assume
1601 type change is not happening. */
1602 void possible_dynamic_type_change (bool, tree otr_type = NULL);
1603 /* Assume that both THIS and a given context is valid and strenghten THIS
1604 if possible. Return true if any strenghtening was made.
1605 If actual type the context is being used in is known, OTR_TYPE should be
1606 set accordingly. This improves quality of combined result. */
1607 bool combine_with (ipa_polymorphic_call_context, tree otr_type = NULL);
1608 bool meet_with (ipa_polymorphic_call_context, tree otr_type = NULL);
1610 /* Return TRUE if context is fully useless. */
1611 bool useless_p () const;
1612 /* Return TRUE if this context conveys the same information as X. */
1613 bool equal_to (const ipa_polymorphic_call_context &x) const;
1615 /* Dump human readable context to F. If NEWLINE is true, it will be
1616 terminated by a newline. */
1617 void dump (FILE *f, bool newline = true) const;
1618 void DEBUG_FUNCTION debug () const;
1620 /* LTO streaming. */
1621 void stream_out (struct output_block *) const;
1622 void stream_in (struct lto_input_block *, struct data_in *data_in);
1624 private:
1625 bool combine_speculation_with (tree, HOST_WIDE_INT, bool, tree);
1626 bool meet_speculation_with (tree, HOST_WIDE_INT, bool, tree);
1627 void set_by_decl (tree, HOST_WIDE_INT);
1628 bool set_by_invariant (tree, tree, HOST_WIDE_INT);
1629 bool speculation_consistent_p (tree, HOST_WIDE_INT, bool, tree) const;
1630 void make_speculative (tree otr_type = NULL);
1633 /* Structure containing additional information about an indirect call. */
1635 struct GTY(()) cgraph_indirect_call_info
1637 /* When agg_content is set, an offset where the call pointer is located
1638 within the aggregate. */
1639 HOST_WIDE_INT offset;
1640 /* Context of the polymorphic call; use only when POLYMORPHIC flag is set. */
1641 ipa_polymorphic_call_context context;
1642 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
1643 HOST_WIDE_INT otr_token;
1644 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
1645 tree otr_type;
1646 /* Index of the parameter that is called. */
1647 int param_index;
1648 /* ECF flags determined from the caller. */
1649 int ecf_flags;
1650 /* Profile_id of common target obtrained from profile. */
1651 int common_target_id;
1652 /* Probability that call will land in function with COMMON_TARGET_ID. */
1653 int common_target_probability;
1655 /* Set when the call is a virtual call with the parameter being the
1656 associated object pointer rather than a simple direct call. */
1657 unsigned polymorphic : 1;
1658 /* Set when the call is a call of a pointer loaded from contents of an
1659 aggregate at offset. */
1660 unsigned agg_contents : 1;
1661 /* Set when this is a call through a member pointer. */
1662 unsigned member_ptr : 1;
1663 /* When the agg_contents bit is set, this one determines whether the
1664 destination is loaded from a parameter passed by reference. */
1665 unsigned by_ref : 1;
1666 /* When the agg_contents bit is set, this one determines whether we can
1667 deduce from the function body that the loaded value from the reference is
1668 never modified between the invocation of the function and the load
1669 point. */
1670 unsigned guaranteed_unmodified : 1;
1671 /* For polymorphic calls this specify whether the virtual table pointer
1672 may have changed in between function entry and the call. */
1673 unsigned vptr_changed : 1;
1676 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
1677 for_user)) cgraph_edge {
1678 friend class cgraph_node;
1679 friend class symbol_table;
1681 /* Remove the edge in the cgraph. */
1682 void remove (void);
1684 /* Change field call_stmt of edge to NEW_STMT.
1685 If UPDATE_SPECULATIVE and E is any component of speculative
1686 edge, then update all components. */
1687 void set_call_stmt (gcall *new_stmt, bool update_speculative = true);
1689 /* Redirect callee of the edge to N. The function does not update underlying
1690 call expression. */
1691 void redirect_callee (cgraph_node *n);
1693 /* If the edge does not lead to a thunk, simply redirect it to N. Otherwise
1694 create one or more equivalent thunks for N and redirect E to the first in
1695 the chain. Note that it is then necessary to call
1696 n->expand_all_artificial_thunks once all callers are redirected. */
1697 void redirect_callee_duplicating_thunks (cgraph_node *n);
1699 /* Make an indirect edge with an unknown callee an ordinary edge leading to
1700 CALLEE. DELTA is an integer constant that is to be added to the this
1701 pointer (first parameter) to compensate for skipping
1702 a thunk adjustment. */
1703 cgraph_edge *make_direct (cgraph_node *callee);
1705 /* Turn edge into speculative call calling N2. Update
1706 the profile so the direct call is taken COUNT times
1707 with FREQUENCY. */
1708 cgraph_edge *make_speculative (cgraph_node *n2, profile_count direct_count);
1710 /* Given speculative call edge, return all three components. */
1711 void speculative_call_info (cgraph_edge *&direct, cgraph_edge *&indirect,
1712 ipa_ref *&reference);
1714 /* Speculative call edge turned out to be direct call to CALLE_DECL.
1715 Remove the speculative call sequence and return edge representing the call.
1716 It is up to caller to redirect the call as appropriate. */
1717 cgraph_edge *resolve_speculation (tree callee_decl = NULL);
1719 /* If necessary, change the function declaration in the call statement
1720 associated with the edge so that it corresponds to the edge callee. */
1721 gimple *redirect_call_stmt_to_callee (void);
1723 /* Create clone of edge in the node N represented
1724 by CALL_EXPR the callgraph. */
1725 cgraph_edge * clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
1726 profile_count num, profile_count den,
1727 bool update_original);
1729 /* Verify edge count and frequency. */
1730 bool verify_count ();
1732 /* Return true when call of edge cannot lead to return from caller
1733 and thus it is safe to ignore its side effects for IPA analysis
1734 when computing side effects of the caller. */
1735 bool cannot_lead_to_return_p (void);
1737 /* Return true when the edge represents a direct recursion. */
1738 bool recursive_p (void);
1740 /* Return true if the call can be hot. */
1741 bool maybe_hot_p (void);
1743 /* Get unique identifier of the edge. */
1744 inline int get_uid ()
1746 return m_uid;
1749 /* Get summary id of the edge. */
1750 inline int get_summary_id ()
1752 return m_summary_id;
1755 /* Rebuild cgraph edges for current function node. This needs to be run after
1756 passes that don't update the cgraph. */
1757 static unsigned int rebuild_edges (void);
1759 /* Rebuild cgraph references for current function node. This needs to be run
1760 after passes that don't update the cgraph. */
1761 static void rebuild_references (void);
1763 /* During LTO stream in this can be used to check whether call can possibly
1764 be internal to the current translation unit. */
1765 bool possibly_call_in_translation_unit_p (void);
1767 /* Expected number of executions: calculated in profile.c. */
1768 profile_count count;
1769 cgraph_node *caller;
1770 cgraph_node *callee;
1771 cgraph_edge *prev_caller;
1772 cgraph_edge *next_caller;
1773 cgraph_edge *prev_callee;
1774 cgraph_edge *next_callee;
1775 gcall *call_stmt;
1776 /* Additional information about an indirect call. Not cleared when an edge
1777 becomes direct. */
1778 cgraph_indirect_call_info *indirect_info;
1779 PTR GTY ((skip (""))) aux;
1780 /* When equal to CIF_OK, inline this call. Otherwise, points to the
1781 explanation why function was not inlined. */
1782 enum cgraph_inline_failed_t inline_failed;
1783 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
1784 when the function is serialized in. */
1785 unsigned int lto_stmt_uid;
1786 /* Whether this edge was made direct by indirect inlining. */
1787 unsigned int indirect_inlining_edge : 1;
1788 /* Whether this edge describes an indirect call with an undetermined
1789 callee. */
1790 unsigned int indirect_unknown_callee : 1;
1791 /* Whether this edge is still a dangling */
1792 /* True if the corresponding CALL stmt cannot be inlined. */
1793 unsigned int call_stmt_cannot_inline_p : 1;
1794 /* Can this call throw externally? */
1795 unsigned int can_throw_external : 1;
1796 /* Edges with SPECULATIVE flag represents indirect calls that was
1797 speculatively turned into direct (i.e. by profile feedback).
1798 The final code sequence will have form:
1800 if (call_target == expected_fn)
1801 expected_fn ();
1802 else
1803 call_target ();
1805 Every speculative call is represented by three components attached
1806 to a same call statement:
1807 1) a direct call (to expected_fn)
1808 2) an indirect call (to call_target)
1809 3) a IPA_REF_ADDR refrence to expected_fn.
1811 Optimizers may later redirect direct call to clone, so 1) and 3)
1812 do not need to necesarily agree with destination. */
1813 unsigned int speculative : 1;
1814 /* Set to true when caller is a constructor or destructor of polymorphic
1815 type. */
1816 unsigned in_polymorphic_cdtor : 1;
1818 /* Return true if call must bind to current definition. */
1819 bool binds_to_current_def_p ();
1821 /* Expected frequency of executions within the function.
1822 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
1823 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
1824 int frequency ();
1826 /* Expected frequency of executions within the function. */
1827 sreal sreal_frequency ();
1828 private:
1829 /* Unique id of the edge. */
1830 int m_uid;
1832 /* Summary id that is recycled. */
1833 int m_summary_id;
1835 /* Remove the edge from the list of the callers of the callee. */
1836 void remove_caller (void);
1838 /* Remove the edge from the list of the callees of the caller. */
1839 void remove_callee (void);
1841 /* Set callee N of call graph edge and add it to the corresponding set of
1842 callers. */
1843 void set_callee (cgraph_node *n);
1845 /* Output flags of edge to a file F. */
1846 void dump_edge_flags (FILE *f);
1848 /* Verify that call graph edge corresponds to DECL from the associated
1849 statement. Return true if the verification should fail. */
1850 bool verify_corresponds_to_fndecl (tree decl);
1853 #define CGRAPH_FREQ_BASE 1000
1854 #define CGRAPH_FREQ_MAX 100000
1856 /* The varpool data structure.
1857 Each static variable decl has assigned varpool_node. */
1859 class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node {
1860 public:
1861 /* Dump given varpool node to F. */
1862 void dump (FILE *f);
1864 /* Dump given varpool node to stderr. */
1865 void DEBUG_FUNCTION debug (void);
1867 /* Remove variable from symbol table. */
1868 void remove (void);
1870 /* Remove node initializer when it is no longer needed. */
1871 void remove_initializer (void);
1873 void analyze (void);
1875 /* Return variable availability. */
1876 availability get_availability (symtab_node *ref = NULL);
1878 /* When doing LTO, read variable's constructor from disk if
1879 it is not already present. */
1880 tree get_constructor (void);
1882 /* Return true if variable has constructor that can be used for folding. */
1883 bool ctor_useable_for_folding_p (void);
1885 /* For given variable pool node, walk the alias chain to return the function
1886 the variable is alias of. Do not walk through thunks.
1887 When AVAILABILITY is non-NULL, get minimal availability in the chain.
1888 When REF is non-NULL, assume that reference happens in symbol REF
1889 when determining the availability. */
1890 inline varpool_node *ultimate_alias_target
1891 (availability *availability = NULL, symtab_node *ref = NULL);
1893 /* Return node that alias is aliasing. */
1894 inline varpool_node *get_alias_target (void);
1896 /* Output one variable, if necessary. Return whether we output it. */
1897 bool assemble_decl (void);
1899 /* For variables in named sections make sure get_variable_section
1900 is called before we switch to those sections. Then section
1901 conflicts between read-only and read-only requiring relocations
1902 sections can be resolved. */
1903 void finalize_named_section_flags (void);
1905 /* Call calback on varpool symbol and aliases associated to varpool symbol.
1906 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
1907 skipped. */
1908 bool call_for_symbol_and_aliases (bool (*callback) (varpool_node *, void *),
1909 void *data,
1910 bool include_overwritable);
1912 /* Return true when variable should be considered externally visible. */
1913 bool externally_visible_p (void);
1915 /* Return true when all references to variable must be visible
1916 in ipa_ref_list.
1917 i.e. if the variable is not externally visible or not used in some magic
1918 way (asm statement or such).
1919 The magic uses are all summarized in force_output flag. */
1920 inline bool all_refs_explicit_p ();
1922 /* Return true when variable can be removed from variable pool
1923 if all direct calls are eliminated. */
1924 inline bool can_remove_if_no_refs_p (void);
1926 /* Add the variable DECL to the varpool.
1927 Unlike finalize_decl function is intended to be used
1928 by middle end and allows insertion of new variable at arbitrary point
1929 of compilation. */
1930 static void add (tree decl);
1932 /* Return varpool node for given symbol and check it is a function. */
1933 static inline varpool_node *get (const_tree decl);
1935 /* Mark DECL as finalized. By finalizing the declaration, frontend instruct
1936 the middle end to output the variable to asm file, if needed or externally
1937 visible. */
1938 static void finalize_decl (tree decl);
1940 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
1941 Extra name aliases are output whenever DECL is output. */
1942 static varpool_node * create_extra_name_alias (tree alias, tree decl);
1944 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
1945 Extra name aliases are output whenever DECL is output. */
1946 static varpool_node * create_alias (tree, tree);
1948 /* Dump the variable pool to F. */
1949 static void dump_varpool (FILE *f);
1951 /* Dump the variable pool to stderr. */
1952 static void DEBUG_FUNCTION debug_varpool (void);
1954 /* Allocate new callgraph node and insert it into basic data structures. */
1955 static varpool_node *create_empty (void);
1957 /* Return varpool node assigned to DECL. Create new one when needed. */
1958 static varpool_node *get_create (tree decl);
1960 /* Given an assembler name, lookup node. */
1961 static varpool_node *get_for_asmname (tree asmname);
1963 /* Set when variable is scheduled to be assembled. */
1964 unsigned output : 1;
1966 /* Set if the variable is dynamically initialized, except for
1967 function local statics. */
1968 unsigned dynamically_initialized : 1;
1970 ENUM_BITFIELD(tls_model) tls_model : 3;
1972 /* Set if the variable is known to be used by single function only.
1973 This is computed by ipa_signle_use pass and used by late optimizations
1974 in places where optimization would be valid for local static variable
1975 if we did not do any inter-procedural code movement. */
1976 unsigned used_by_single_function : 1;
1978 private:
1979 /* Assemble thunks and aliases associated to varpool node. */
1980 void assemble_aliases (void);
1982 /* Worker for call_for_node_and_aliases. */
1983 bool call_for_symbol_and_aliases_1 (bool (*callback) (varpool_node *, void *),
1984 void *data,
1985 bool include_overwritable);
1988 /* Every top level asm statement is put into a asm_node. */
1990 struct GTY(()) asm_node {
1993 /* Next asm node. */
1994 asm_node *next;
1995 /* String for this asm node. */
1996 tree asm_str;
1997 /* Ordering of all cgraph nodes. */
1998 int order;
2001 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
2003 template <>
2004 template <>
2005 inline bool
2006 is_a_helper <cgraph_node *>::test (symtab_node *p)
2008 return p && p->type == SYMTAB_FUNCTION;
2011 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
2013 template <>
2014 template <>
2015 inline bool
2016 is_a_helper <varpool_node *>::test (symtab_node *p)
2018 return p && p->type == SYMTAB_VARIABLE;
2021 /* Macros to access the next item in the list of free cgraph nodes and
2022 edges. */
2023 #define NEXT_FREE_NODE(NODE) dyn_cast<cgraph_node *> ((NODE)->next)
2024 #define SET_NEXT_FREE_NODE(NODE,NODE2) ((NODE))->next = NODE2
2025 #define NEXT_FREE_EDGE(EDGE) (EDGE)->prev_caller
2027 typedef void (*cgraph_edge_hook)(cgraph_edge *, void *);
2028 typedef void (*cgraph_node_hook)(cgraph_node *, void *);
2029 typedef void (*varpool_node_hook)(varpool_node *, void *);
2030 typedef void (*cgraph_2edge_hook)(cgraph_edge *, cgraph_edge *, void *);
2031 typedef void (*cgraph_2node_hook)(cgraph_node *, cgraph_node *, void *);
2033 struct cgraph_edge_hook_list;
2034 struct cgraph_node_hook_list;
2035 struct varpool_node_hook_list;
2036 struct cgraph_2edge_hook_list;
2037 struct cgraph_2node_hook_list;
2039 /* Map from a symbol to initialization/finalization priorities. */
2040 struct GTY(()) symbol_priority_map {
2041 priority_type init;
2042 priority_type fini;
2045 enum symtab_state
2047 /* Frontend is parsing and finalizing functions. */
2048 PARSING,
2049 /* Callgraph is being constructed. It is safe to add new functions. */
2050 CONSTRUCTION,
2051 /* Callgraph is being streamed-in at LTO time. */
2052 LTO_STREAMING,
2053 /* Callgraph is built and early IPA passes are being run. */
2054 IPA,
2055 /* Callgraph is built and all functions are transformed to SSA form. */
2056 IPA_SSA,
2057 /* All inline decisions are done; it is now possible to remove extern inline
2058 functions and virtual call targets. */
2059 IPA_SSA_AFTER_INLINING,
2060 /* Functions are now ordered and being passed to RTL expanders. */
2061 EXPANSION,
2062 /* All cgraph expansion is done. */
2063 FINISHED
2066 struct asmname_hasher : ggc_ptr_hash <symtab_node>
2068 typedef const_tree compare_type;
2070 static hashval_t hash (symtab_node *n);
2071 static bool equal (symtab_node *n, const_tree t);
2074 class GTY((tag ("SYMTAB"))) symbol_table
2076 public:
2077 friend class symtab_node;
2078 friend class cgraph_node;
2079 friend class cgraph_edge;
2081 symbol_table (): cgraph_max_uid (1), cgraph_max_summary_id (0),
2082 edges_max_uid (1), edges_max_summary_id (0)
2086 /* Initialize callgraph dump file. */
2087 void initialize (void);
2089 /* Register a top-level asm statement ASM_STR. */
2090 inline asm_node *finalize_toplevel_asm (tree asm_str);
2092 /* Analyze the whole compilation unit once it is parsed completely. */
2093 void finalize_compilation_unit (void);
2095 /* C++ frontend produce same body aliases all over the place, even before PCH
2096 gets streamed out. It relies on us linking the aliases with their function
2097 in order to do the fixups, but ipa-ref is not PCH safe. Consequentely we
2098 first produce aliases without links, but once C++ FE is sure he won't sream
2099 PCH we build the links via this function. */
2100 void process_same_body_aliases (void);
2102 /* Perform simple optimizations based on callgraph. */
2103 void compile (void);
2105 /* Process CGRAPH_NEW_FUNCTIONS and perform actions necessary to add these
2106 functions into callgraph in a way so they look like ordinary reachable
2107 functions inserted into callgraph already at construction time. */
2108 void process_new_functions (void);
2110 /* Once all functions from compilation unit are in memory, produce all clones
2111 and update all calls. We might also do this on demand if we don't want to
2112 bring all functions to memory prior compilation, but current WHOPR
2113 implementation does that and it is bit easier to keep everything right
2114 in this order. */
2115 void materialize_all_clones (void);
2117 /* Register a symbol NODE. */
2118 inline void register_symbol (symtab_node *node);
2120 inline void
2121 clear_asm_symbols (void)
2123 asmnodes = NULL;
2124 asm_last_node = NULL;
2127 /* Perform reachability analysis and reclaim all unreachable nodes. */
2128 bool remove_unreachable_nodes (FILE *file);
2130 /* Optimization of function bodies might've rendered some variables as
2131 unnecessary so we want to avoid these from being compiled. Re-do
2132 reachability starting from variables that are either externally visible
2133 or was referred from the asm output routines. */
2134 void remove_unreferenced_decls (void);
2136 /* Unregister a symbol NODE. */
2137 inline void unregister (symtab_node *node);
2139 /* Allocate new callgraph node and insert it into basic data structures. */
2140 cgraph_node *create_empty (void);
2142 /* Release a callgraph NODE. */
2143 void release_symbol (cgraph_node *node);
2145 /* Output all variables enqueued to be assembled. */
2146 bool output_variables (void);
2148 /* Weakrefs may be associated to external decls and thus not output
2149 at expansion time. Emit all necessary aliases. */
2150 void output_weakrefs (void);
2152 /* Return first static symbol with definition. */
2153 inline symtab_node *first_symbol (void);
2155 /* Return first assembler symbol. */
2156 inline asm_node *
2157 first_asm_symbol (void)
2159 return asmnodes;
2162 /* Return first static symbol with definition. */
2163 inline symtab_node *first_defined_symbol (void);
2165 /* Return first variable. */
2166 inline varpool_node *first_variable (void);
2168 /* Return next variable after NODE. */
2169 inline varpool_node *next_variable (varpool_node *node);
2171 /* Return first static variable with initializer. */
2172 inline varpool_node *first_static_initializer (void);
2174 /* Return next static variable with initializer after NODE. */
2175 inline varpool_node *next_static_initializer (varpool_node *node);
2177 /* Return first static variable with definition. */
2178 inline varpool_node *first_defined_variable (void);
2180 /* Return next static variable with definition after NODE. */
2181 inline varpool_node *next_defined_variable (varpool_node *node);
2183 /* Return first function with body defined. */
2184 inline cgraph_node *first_defined_function (void);
2186 /* Return next function with body defined after NODE. */
2187 inline cgraph_node *next_defined_function (cgraph_node *node);
2189 /* Return first function. */
2190 inline cgraph_node *first_function (void);
2192 /* Return next function. */
2193 inline cgraph_node *next_function (cgraph_node *node);
2195 /* Return first function with body defined. */
2196 cgraph_node *first_function_with_gimple_body (void);
2198 /* Return next reachable static variable with initializer after NODE. */
2199 inline cgraph_node *next_function_with_gimple_body (cgraph_node *node);
2201 /* Register HOOK to be called with DATA on each removed edge. */
2202 cgraph_edge_hook_list *add_edge_removal_hook (cgraph_edge_hook hook,
2203 void *data);
2205 /* Remove ENTRY from the list of hooks called on removing edges. */
2206 void remove_edge_removal_hook (cgraph_edge_hook_list *entry);
2208 /* Register HOOK to be called with DATA on each removed node. */
2209 cgraph_node_hook_list *add_cgraph_removal_hook (cgraph_node_hook hook,
2210 void *data);
2212 /* Remove ENTRY from the list of hooks called on removing nodes. */
2213 void remove_cgraph_removal_hook (cgraph_node_hook_list *entry);
2215 /* Register HOOK to be called with DATA on each removed node. */
2216 varpool_node_hook_list *add_varpool_removal_hook (varpool_node_hook hook,
2217 void *data);
2219 /* Remove ENTRY from the list of hooks called on removing nodes. */
2220 void remove_varpool_removal_hook (varpool_node_hook_list *entry);
2222 /* Register HOOK to be called with DATA on each inserted node. */
2223 cgraph_node_hook_list *add_cgraph_insertion_hook (cgraph_node_hook hook,
2224 void *data);
2226 /* Remove ENTRY from the list of hooks called on inserted nodes. */
2227 void remove_cgraph_insertion_hook (cgraph_node_hook_list *entry);
2229 /* Register HOOK to be called with DATA on each inserted node. */
2230 varpool_node_hook_list *add_varpool_insertion_hook (varpool_node_hook hook,
2231 void *data);
2233 /* Remove ENTRY from the list of hooks called on inserted nodes. */
2234 void remove_varpool_insertion_hook (varpool_node_hook_list *entry);
2236 /* Register HOOK to be called with DATA on each duplicated edge. */
2237 cgraph_2edge_hook_list *add_edge_duplication_hook (cgraph_2edge_hook hook,
2238 void *data);
2239 /* Remove ENTRY from the list of hooks called on duplicating edges. */
2240 void remove_edge_duplication_hook (cgraph_2edge_hook_list *entry);
2242 /* Register HOOK to be called with DATA on each duplicated node. */
2243 cgraph_2node_hook_list *add_cgraph_duplication_hook (cgraph_2node_hook hook,
2244 void *data);
2246 /* Remove ENTRY from the list of hooks called on duplicating nodes. */
2247 void remove_cgraph_duplication_hook (cgraph_2node_hook_list *entry);
2249 /* Call all edge removal hooks. */
2250 void call_edge_removal_hooks (cgraph_edge *e);
2252 /* Call all node insertion hooks. */
2253 void call_cgraph_insertion_hooks (cgraph_node *node);
2255 /* Call all node removal hooks. */
2256 void call_cgraph_removal_hooks (cgraph_node *node);
2258 /* Call all node duplication hooks. */
2259 void call_cgraph_duplication_hooks (cgraph_node *node, cgraph_node *node2);
2261 /* Call all edge duplication hooks. */
2262 void call_edge_duplication_hooks (cgraph_edge *cs1, cgraph_edge *cs2);
2264 /* Call all node removal hooks. */
2265 void call_varpool_removal_hooks (varpool_node *node);
2267 /* Call all node insertion hooks. */
2268 void call_varpool_insertion_hooks (varpool_node *node);
2270 /* Arrange node to be first in its entry of assembler_name_hash. */
2271 void symtab_prevail_in_asm_name_hash (symtab_node *node);
2273 /* Initalize asm name hash unless. */
2274 void symtab_initialize_asm_name_hash (void);
2276 /* Set the DECL_ASSEMBLER_NAME and update symtab hashtables. */
2277 void change_decl_assembler_name (tree decl, tree name);
2279 /* Dump symbol table to F. */
2280 void dump (FILE *f);
2282 /* Dump symbol table to stderr. */
2283 void DEBUG_FUNCTION debug (void);
2285 /* Assign a new summary ID for the callgraph NODE. */
2286 inline int assign_summary_id (cgraph_node *node)
2288 node->m_summary_id = cgraph_max_summary_id++;
2289 return node->m_summary_id;
2292 /* Assign a new summary ID for the callgraph EDGE. */
2293 inline int assign_summary_id (cgraph_edge *edge)
2295 edge->m_summary_id = edges_max_summary_id++;
2296 return edge->m_summary_id;
2299 /* Return true if assembler names NAME1 and NAME2 leads to the same symbol
2300 name. */
2301 static bool assembler_names_equal_p (const char *name1, const char *name2);
2303 int cgraph_count;
2304 int cgraph_max_uid;
2305 int cgraph_max_summary_id;
2307 int edges_count;
2308 int edges_max_uid;
2309 int edges_max_summary_id;
2311 symtab_node* GTY(()) nodes;
2312 asm_node* GTY(()) asmnodes;
2313 asm_node* GTY(()) asm_last_node;
2314 cgraph_node* GTY(()) free_nodes;
2316 /* Head of a linked list of unused (freed) call graph edges.
2317 Do not GTY((delete)) this list so UIDs gets reliably recycled. */
2318 cgraph_edge * GTY(()) free_edges;
2320 /* The order index of the next symtab node to be created. This is
2321 used so that we can sort the cgraph nodes in order by when we saw
2322 them, to support -fno-toplevel-reorder. */
2323 int order;
2325 /* Set when whole unit has been analyzed so we can access global info. */
2326 bool global_info_ready;
2327 /* What state callgraph is in right now. */
2328 enum symtab_state state;
2329 /* Set when the cgraph is fully build and the basic flags are computed. */
2330 bool function_flags_ready;
2332 bool cpp_implicit_aliases_done;
2334 /* Hash table used to hold sectoons. */
2335 hash_table<section_name_hasher> *GTY(()) section_hash;
2337 /* Hash table used to convert assembler names into nodes. */
2338 hash_table<asmname_hasher> *assembler_name_hash;
2340 /* Hash table used to hold init priorities. */
2341 hash_map<symtab_node *, symbol_priority_map> *init_priority_hash;
2343 FILE* GTY ((skip)) dump_file;
2345 /* Return symbol used to separate symbol name from suffix. */
2346 static char symbol_suffix_separator ();
2348 FILE* GTY ((skip)) ipa_clones_dump_file;
2350 hash_set <const cgraph_node *> GTY ((skip)) cloned_nodes;
2352 private:
2353 /* Allocate new callgraph node. */
2354 inline cgraph_node * allocate_cgraph_symbol (void);
2356 /* Allocate a cgraph_edge structure and fill it with data according to the
2357 parameters of which only CALLEE can be NULL (when creating an indirect call
2358 edge). */
2359 cgraph_edge *create_edge (cgraph_node *caller, cgraph_node *callee,
2360 gcall *call_stmt, profile_count count,
2361 bool indir_unknown_callee);
2363 /* Put the edge onto the free list. */
2364 void free_edge (cgraph_edge *e);
2366 /* Insert NODE to assembler name hash. */
2367 void insert_to_assembler_name_hash (symtab_node *node, bool with_clones);
2369 /* Remove NODE from assembler name hash. */
2370 void unlink_from_assembler_name_hash (symtab_node *node, bool with_clones);
2372 /* Hash asmnames ignoring the user specified marks. */
2373 static hashval_t decl_assembler_name_hash (const_tree asmname);
2375 /* Compare ASMNAME with the DECL_ASSEMBLER_NAME of DECL. */
2376 static bool decl_assembler_name_equal (tree decl, const_tree asmname);
2378 friend struct asmname_hasher;
2380 /* List of hooks triggered when an edge is removed. */
2381 cgraph_edge_hook_list * GTY((skip)) m_first_edge_removal_hook;
2382 /* List of hooks triggem_red when a cgraph node is removed. */
2383 cgraph_node_hook_list * GTY((skip)) m_first_cgraph_removal_hook;
2384 /* List of hooks triggered when an edge is duplicated. */
2385 cgraph_2edge_hook_list * GTY((skip)) m_first_edge_duplicated_hook;
2386 /* List of hooks triggered when a node is duplicated. */
2387 cgraph_2node_hook_list * GTY((skip)) m_first_cgraph_duplicated_hook;
2388 /* List of hooks triggered when an function is inserted. */
2389 cgraph_node_hook_list * GTY((skip)) m_first_cgraph_insertion_hook;
2390 /* List of hooks triggered when an variable is inserted. */
2391 varpool_node_hook_list * GTY((skip)) m_first_varpool_insertion_hook;
2392 /* List of hooks triggered when a node is removed. */
2393 varpool_node_hook_list * GTY((skip)) m_first_varpool_removal_hook;
2396 extern GTY(()) symbol_table *symtab;
2398 extern vec<cgraph_node *> cgraph_new_nodes;
2400 inline hashval_t
2401 asmname_hasher::hash (symtab_node *n)
2403 return symbol_table::decl_assembler_name_hash
2404 (DECL_ASSEMBLER_NAME (n->decl));
2407 inline bool
2408 asmname_hasher::equal (symtab_node *n, const_tree t)
2410 return symbol_table::decl_assembler_name_equal (n->decl, t);
2413 /* In cgraph.c */
2414 void cgraph_c_finalize (void);
2415 void release_function_body (tree);
2416 cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
2418 void cgraph_update_edges_for_call_stmt (gimple *, tree, gimple *);
2419 bool cgraph_function_possibly_inlined_p (tree);
2421 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
2422 cgraph_inline_failed_type_t cgraph_inline_failed_type (cgraph_inline_failed_t);
2424 extern bool gimple_check_call_matching_types (gimple *, tree, bool);
2426 /* In cgraphunit.c */
2427 void cgraphunit_c_finalize (void);
2429 /* Initialize datastructures so DECL is a function in lowered gimple form.
2430 IN_SSA is true if the gimple is in SSA. */
2431 basic_block init_lowered_empty_function (tree, bool, profile_count);
2433 tree thunk_adjust (gimple_stmt_iterator *, tree, bool, HOST_WIDE_INT, tree,
2434 HOST_WIDE_INT);
2435 /* In cgraphclones.c */
2437 tree clone_function_name_numbered (const char *name, const char *suffix);
2438 tree clone_function_name_numbered (tree decl, const char *suffix);
2439 tree clone_function_name (const char *name, const char *suffix,
2440 unsigned long number);
2441 tree clone_function_name (tree decl, const char *suffix,
2442 unsigned long number);
2443 tree clone_function_name (tree decl, const char *suffix);
2445 void tree_function_versioning (tree, tree, vec<ipa_replace_map *, va_gc> *,
2446 bool, bitmap, bool, bitmap, basic_block);
2448 void dump_callgraph_transformation (const cgraph_node *original,
2449 const cgraph_node *clone,
2450 const char *suffix);
2451 tree cgraph_build_function_type_skip_args (tree orig_type, bitmap args_to_skip,
2452 bool skip_return);
2454 /* In cgraphbuild.c */
2455 int compute_call_stmt_bb_frequency (tree, basic_block bb);
2456 void record_references_in_initializer (tree, bool);
2458 /* In ipa.c */
2459 void cgraph_build_static_cdtor (char which, tree body, int priority);
2460 bool ipa_discover_variable_flags (void);
2462 /* In varpool.c */
2463 tree ctor_for_folding (tree);
2465 /* In ipa-inline-analysis.c */
2466 void initialize_inline_failed (struct cgraph_edge *);
2467 bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining);
2469 /* Return true when the symbol is real symbol, i.e. it is not inline clone
2470 or abstract function kept for debug info purposes only. */
2471 inline bool
2472 symtab_node::real_symbol_p (void)
2474 cgraph_node *cnode;
2476 if (DECL_ABSTRACT_P (decl))
2477 return false;
2478 if (transparent_alias && definition)
2479 return false;
2480 if (!is_a <cgraph_node *> (this))
2481 return true;
2482 cnode = dyn_cast <cgraph_node *> (this);
2483 if (cnode->global.inlined_to)
2484 return false;
2485 return true;
2488 /* Return true if DECL should have entry in symbol table if used.
2489 Those are functions and static & external veriables*/
2491 static inline bool
2492 decl_in_symtab_p (const_tree decl)
2494 return (TREE_CODE (decl) == FUNCTION_DECL
2495 || (TREE_CODE (decl) == VAR_DECL
2496 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))));
2499 inline bool
2500 symtab_node::in_same_comdat_group_p (symtab_node *target)
2502 symtab_node *source = this;
2504 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
2506 if (cn->global.inlined_to)
2507 source = cn->global.inlined_to;
2509 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
2511 if (cn->global.inlined_to)
2512 target = cn->global.inlined_to;
2515 return source->get_comdat_group () == target->get_comdat_group ();
2518 /* Return node that alias is aliasing. */
2520 inline symtab_node *
2521 symtab_node::get_alias_target (void)
2523 ipa_ref *ref = NULL;
2524 iterate_reference (0, ref);
2525 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
2526 return ref->referred;
2529 /* Return next reachable static symbol with initializer after the node. */
2531 inline symtab_node *
2532 symtab_node::next_defined_symbol (void)
2534 symtab_node *node1 = next;
2536 for (; node1; node1 = node1->next)
2537 if (node1->definition)
2538 return node1;
2540 return NULL;
2543 /* Iterates I-th reference in the list, REF is also set. */
2545 inline ipa_ref *
2546 symtab_node::iterate_reference (unsigned i, ipa_ref *&ref)
2548 vec_safe_iterate (ref_list.references, i, &ref);
2550 return ref;
2553 /* Iterates I-th referring item in the list, REF is also set. */
2555 inline ipa_ref *
2556 symtab_node::iterate_referring (unsigned i, ipa_ref *&ref)
2558 ref_list.referring.iterate (i, &ref);
2560 return ref;
2563 /* Iterates I-th referring alias item in the list, REF is also set. */
2565 inline ipa_ref *
2566 symtab_node::iterate_direct_aliases (unsigned i, ipa_ref *&ref)
2568 ref_list.referring.iterate (i, &ref);
2570 if (ref && ref->use != IPA_REF_ALIAS)
2571 return NULL;
2573 return ref;
2576 /* Return true if list contains an alias. */
2578 inline bool
2579 symtab_node::has_aliases_p (void)
2581 ipa_ref *ref = NULL;
2583 return (iterate_direct_aliases (0, ref) != NULL);
2586 /* Return true when RESOLUTION indicate that linker will use
2587 the symbol from non-LTO object files. */
2589 inline bool
2590 resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
2592 return (resolution == LDPR_PREVAILING_DEF
2593 || resolution == LDPR_PREEMPTED_REG
2594 || resolution == LDPR_RESOLVED_EXEC
2595 || resolution == LDPR_RESOLVED_DYN);
2598 /* Return true when symtab_node is known to be used from other (non-LTO)
2599 object file. Known only when doing LTO via linker plugin. */
2601 inline bool
2602 symtab_node::used_from_object_file_p (void)
2604 if (!TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
2605 return false;
2606 if (resolution_used_from_other_file_p (resolution))
2607 return true;
2608 return false;
2611 /* Return varpool node for given symbol and check it is a function. */
2613 inline varpool_node *
2614 varpool_node::get (const_tree decl)
2616 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
2617 return dyn_cast<varpool_node *> (symtab_node::get (decl));
2620 /* Register a symbol NODE. */
2622 inline void
2623 symbol_table::register_symbol (symtab_node *node)
2625 node->next = nodes;
2626 node->previous = NULL;
2628 if (nodes)
2629 nodes->previous = node;
2630 nodes = node;
2632 node->order = order++;
2635 /* Register a top-level asm statement ASM_STR. */
2637 asm_node *
2638 symbol_table::finalize_toplevel_asm (tree asm_str)
2640 asm_node *node;
2642 node = ggc_cleared_alloc<asm_node> ();
2643 node->asm_str = asm_str;
2644 node->order = order++;
2645 node->next = NULL;
2647 if (asmnodes == NULL)
2648 asmnodes = node;
2649 else
2650 asm_last_node->next = node;
2652 asm_last_node = node;
2653 return node;
2656 /* Unregister a symbol NODE. */
2657 inline void
2658 symbol_table::unregister (symtab_node *node)
2660 if (node->previous)
2661 node->previous->next = node->next;
2662 else
2663 nodes = node->next;
2665 if (node->next)
2666 node->next->previous = node->previous;
2668 node->next = NULL;
2669 node->previous = NULL;
2672 /* Release a callgraph NODE with UID and put in to the list of free nodes. */
2674 inline void
2675 symbol_table::release_symbol (cgraph_node *node)
2677 cgraph_count--;
2679 /* Clear out the node to NULL all pointers and add the node to the free
2680 list. */
2681 int summary_id = node->m_summary_id;
2682 memset (node, 0, sizeof (*node));
2683 node->type = SYMTAB_FUNCTION;
2684 node->m_summary_id = summary_id;
2685 SET_NEXT_FREE_NODE (node, free_nodes);
2686 free_nodes = node;
2689 /* Allocate new callgraph node. */
2691 inline cgraph_node *
2692 symbol_table::allocate_cgraph_symbol (void)
2694 cgraph_node *node;
2696 if (free_nodes)
2698 node = free_nodes;
2699 free_nodes = NEXT_FREE_NODE (node);
2701 else
2703 node = ggc_cleared_alloc<cgraph_node> ();
2704 node->m_summary_id = -1;
2707 node->m_uid = cgraph_max_uid++;
2708 return node;
2712 /* Return first static symbol with definition. */
2713 inline symtab_node *
2714 symbol_table::first_symbol (void)
2716 return nodes;
2719 /* Walk all symbols. */
2720 #define FOR_EACH_SYMBOL(node) \
2721 for ((node) = symtab->first_symbol (); (node); (node) = (node)->next)
2723 /* Return first static symbol with definition. */
2724 inline symtab_node *
2725 symbol_table::first_defined_symbol (void)
2727 symtab_node *node;
2729 for (node = nodes; node; node = node->next)
2730 if (node->definition)
2731 return node;
2733 return NULL;
2736 /* Walk all symbols with definitions in current unit. */
2737 #define FOR_EACH_DEFINED_SYMBOL(node) \
2738 for ((node) = symtab->first_defined_symbol (); (node); \
2739 (node) = node->next_defined_symbol ())
2741 /* Return first variable. */
2742 inline varpool_node *
2743 symbol_table::first_variable (void)
2745 symtab_node *node;
2746 for (node = nodes; node; node = node->next)
2747 if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
2748 return vnode;
2749 return NULL;
2752 /* Return next variable after NODE. */
2753 inline varpool_node *
2754 symbol_table::next_variable (varpool_node *node)
2756 symtab_node *node1 = node->next;
2757 for (; node1; node1 = node1->next)
2758 if (varpool_node *vnode1 = dyn_cast <varpool_node *> (node1))
2759 return vnode1;
2760 return NULL;
2762 /* Walk all variables. */
2763 #define FOR_EACH_VARIABLE(node) \
2764 for ((node) = symtab->first_variable (); \
2765 (node); \
2766 (node) = symtab->next_variable ((node)))
2768 /* Return first static variable with initializer. */
2769 inline varpool_node *
2770 symbol_table::first_static_initializer (void)
2772 symtab_node *node;
2773 for (node = nodes; node; node = node->next)
2775 varpool_node *vnode = dyn_cast <varpool_node *> (node);
2776 if (vnode && DECL_INITIAL (node->decl))
2777 return vnode;
2779 return NULL;
2782 /* Return next static variable with initializer after NODE. */
2783 inline varpool_node *
2784 symbol_table::next_static_initializer (varpool_node *node)
2786 symtab_node *node1 = node->next;
2787 for (; node1; node1 = node1->next)
2789 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
2790 if (vnode1 && DECL_INITIAL (node1->decl))
2791 return vnode1;
2793 return NULL;
2796 /* Walk all static variables with initializer set. */
2797 #define FOR_EACH_STATIC_INITIALIZER(node) \
2798 for ((node) = symtab->first_static_initializer (); (node); \
2799 (node) = symtab->next_static_initializer (node))
2801 /* Return first static variable with definition. */
2802 inline varpool_node *
2803 symbol_table::first_defined_variable (void)
2805 symtab_node *node;
2806 for (node = nodes; node; node = node->next)
2808 varpool_node *vnode = dyn_cast <varpool_node *> (node);
2809 if (vnode && vnode->definition)
2810 return vnode;
2812 return NULL;
2815 /* Return next static variable with definition after NODE. */
2816 inline varpool_node *
2817 symbol_table::next_defined_variable (varpool_node *node)
2819 symtab_node *node1 = node->next;
2820 for (; node1; node1 = node1->next)
2822 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
2823 if (vnode1 && vnode1->definition)
2824 return vnode1;
2826 return NULL;
2828 /* Walk all variables with definitions in current unit. */
2829 #define FOR_EACH_DEFINED_VARIABLE(node) \
2830 for ((node) = symtab->first_defined_variable (); (node); \
2831 (node) = symtab->next_defined_variable (node))
2833 /* Return first function with body defined. */
2834 inline cgraph_node *
2835 symbol_table::first_defined_function (void)
2837 symtab_node *node;
2838 for (node = nodes; node; node = node->next)
2840 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
2841 if (cn && cn->definition)
2842 return cn;
2844 return NULL;
2847 /* Return next function with body defined after NODE. */
2848 inline cgraph_node *
2849 symbol_table::next_defined_function (cgraph_node *node)
2851 symtab_node *node1 = node->next;
2852 for (; node1; node1 = node1->next)
2854 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
2855 if (cn1 && cn1->definition)
2856 return cn1;
2858 return NULL;
2861 /* Walk all functions with body defined. */
2862 #define FOR_EACH_DEFINED_FUNCTION(node) \
2863 for ((node) = symtab->first_defined_function (); (node); \
2864 (node) = symtab->next_defined_function ((node)))
2866 /* Return first function. */
2867 inline cgraph_node *
2868 symbol_table::first_function (void)
2870 symtab_node *node;
2871 for (node = nodes; node; node = node->next)
2872 if (cgraph_node *cn = dyn_cast <cgraph_node *> (node))
2873 return cn;
2874 return NULL;
2877 /* Return next function. */
2878 inline cgraph_node *
2879 symbol_table::next_function (cgraph_node *node)
2881 symtab_node *node1 = node->next;
2882 for (; node1; node1 = node1->next)
2883 if (cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1))
2884 return cn1;
2885 return NULL;
2888 /* Return first function with body defined. */
2889 inline cgraph_node *
2890 symbol_table::first_function_with_gimple_body (void)
2892 symtab_node *node;
2893 for (node = nodes; node; node = node->next)
2895 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
2896 if (cn && cn->has_gimple_body_p ())
2897 return cn;
2899 return NULL;
2902 /* Return next reachable static variable with initializer after NODE. */
2903 inline cgraph_node *
2904 symbol_table::next_function_with_gimple_body (cgraph_node *node)
2906 symtab_node *node1 = node->next;
2907 for (; node1; node1 = node1->next)
2909 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
2910 if (cn1 && cn1->has_gimple_body_p ())
2911 return cn1;
2913 return NULL;
2916 /* Walk all functions. */
2917 #define FOR_EACH_FUNCTION(node) \
2918 for ((node) = symtab->first_function (); (node); \
2919 (node) = symtab->next_function ((node)))
2921 /* Return true when callgraph node is a function with Gimple body defined
2922 in current unit. Functions can also be define externally or they
2923 can be thunks with no Gimple representation.
2925 Note that at WPA stage, the function body may not be present in memory. */
2927 inline bool
2928 cgraph_node::has_gimple_body_p (void)
2930 return definition && !thunk.thunk_p && !alias;
2933 /* Return true if this node represents a former, i.e. an expanded, thunk. */
2935 inline bool
2936 cgraph_node::former_thunk_p (void)
2938 return (!thunk.thunk_p
2939 && (thunk.fixed_offset
2940 || thunk.virtual_offset_p
2941 || thunk.indirect_offset));
2944 /* Walk all functions with body defined. */
2945 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
2946 for ((node) = symtab->first_function_with_gimple_body (); (node); \
2947 (node) = symtab->next_function_with_gimple_body (node))
2949 /* Uniquize all constants that appear in memory.
2950 Each constant in memory thus far output is recorded
2951 in `const_desc_table'. */
2953 struct GTY((for_user)) constant_descriptor_tree {
2954 /* A MEM for the constant. */
2955 rtx rtl;
2957 /* The value of the constant. */
2958 tree value;
2960 /* Hash of value. Computing the hash from value each time
2961 hashfn is called can't work properly, as that means recursive
2962 use of the hash table during hash table expansion. */
2963 hashval_t hash;
2966 /* Return true when function is only called directly or it has alias.
2967 i.e. it is not externally visible, address was not taken and
2968 it is not used in any other non-standard way. */
2970 inline bool
2971 cgraph_node::only_called_directly_or_aliased_p (void)
2973 gcc_assert (!global.inlined_to);
2974 return (!force_output && !address_taken
2975 && !ifunc_resolver
2976 && !used_from_other_partition
2977 && !DECL_VIRTUAL_P (decl)
2978 && !DECL_STATIC_CONSTRUCTOR (decl)
2979 && !DECL_STATIC_DESTRUCTOR (decl)
2980 && !used_from_object_file_p ()
2981 && !externally_visible);
2984 /* Return true when function can be removed from callgraph
2985 if all direct calls are eliminated. */
2987 inline bool
2988 cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
2990 gcc_checking_assert (!global.inlined_to);
2991 /* Extern inlines can always go, we will use the external definition. */
2992 if (DECL_EXTERNAL (decl))
2993 return true;
2994 /* When function is needed, we cannot remove it. */
2995 if (force_output || used_from_other_partition)
2996 return false;
2997 if (DECL_STATIC_CONSTRUCTOR (decl)
2998 || DECL_STATIC_DESTRUCTOR (decl))
2999 return false;
3000 /* Only COMDAT functions can be removed if externally visible. */
3001 if (externally_visible
3002 && (!DECL_COMDAT (decl)
3003 || forced_by_abi
3004 || used_from_object_file_p ()))
3005 return false;
3006 return true;
3009 /* Verify cgraph, if consistency checking is enabled. */
3011 inline void
3012 cgraph_node::checking_verify_cgraph_nodes (void)
3014 if (flag_checking)
3015 cgraph_node::verify_cgraph_nodes ();
3018 /* Return true when variable can be removed from variable pool
3019 if all direct calls are eliminated. */
3021 inline bool
3022 varpool_node::can_remove_if_no_refs_p (void)
3024 if (DECL_EXTERNAL (decl))
3025 return true;
3026 return (!force_output && !used_from_other_partition
3027 && ((DECL_COMDAT (decl)
3028 && !forced_by_abi
3029 && !used_from_object_file_p ())
3030 || !externally_visible
3031 || DECL_HAS_VALUE_EXPR_P (decl)));
3034 /* Return true when all references to variable must be visible in ipa_ref_list.
3035 i.e. if the variable is not externally visible or not used in some magic
3036 way (asm statement or such).
3037 The magic uses are all summarized in force_output flag. */
3039 inline bool
3040 varpool_node::all_refs_explicit_p ()
3042 return (definition
3043 && !externally_visible
3044 && !used_from_other_partition
3045 && !force_output);
3048 struct tree_descriptor_hasher : ggc_ptr_hash<constant_descriptor_tree>
3050 static hashval_t hash (constant_descriptor_tree *);
3051 static bool equal (constant_descriptor_tree *, constant_descriptor_tree *);
3054 /* Constant pool accessor function. */
3055 hash_table<tree_descriptor_hasher> *constant_pool_htab (void);
3057 /* Return node that alias is aliasing. */
3059 inline cgraph_node *
3060 cgraph_node::get_alias_target (void)
3062 return dyn_cast <cgraph_node *> (symtab_node::get_alias_target ());
3065 /* Return node that alias is aliasing. */
3067 inline varpool_node *
3068 varpool_node::get_alias_target (void)
3070 return dyn_cast <varpool_node *> (symtab_node::get_alias_target ());
3073 /* Walk the alias chain to return the symbol NODE is alias of.
3074 If NODE is not an alias, return NODE.
3075 When AVAILABILITY is non-NULL, get minimal availability in the chain.
3076 When REF is non-NULL, assume that reference happens in symbol REF
3077 when determining the availability. */
3079 inline symtab_node *
3080 symtab_node::ultimate_alias_target (enum availability *availability,
3081 symtab_node *ref)
3083 if (!alias)
3085 if (availability)
3086 *availability = get_availability (ref);
3087 return this;
3090 return ultimate_alias_target_1 (availability, ref);
3093 /* Given function symbol, walk the alias chain to return the function node
3094 is alias of. Do not walk through thunks.
3095 When AVAILABILITY is non-NULL, get minimal availability in the chain.
3096 When REF is non-NULL, assume that reference happens in symbol REF
3097 when determining the availability. */
3099 inline cgraph_node *
3100 cgraph_node::ultimate_alias_target (enum availability *availability,
3101 symtab_node *ref)
3103 cgraph_node *n = dyn_cast <cgraph_node *>
3104 (symtab_node::ultimate_alias_target (availability, ref));
3105 if (!n && availability)
3106 *availability = AVAIL_NOT_AVAILABLE;
3107 return n;
3110 /* For given variable pool node, walk the alias chain to return the function
3111 the variable is alias of. Do not walk through thunks.
3112 When AVAILABILITY is non-NULL, get minimal availability in the chain.
3113 When REF is non-NULL, assume that reference happens in symbol REF
3114 when determining the availability. */
3116 inline varpool_node *
3117 varpool_node::ultimate_alias_target (availability *availability,
3118 symtab_node *ref)
3120 varpool_node *n = dyn_cast <varpool_node *>
3121 (symtab_node::ultimate_alias_target (availability, ref));
3123 if (!n && availability)
3124 *availability = AVAIL_NOT_AVAILABLE;
3125 return n;
3128 /* Set callee N of call graph edge and add it to the corresponding set of
3129 callers. */
3131 inline void
3132 cgraph_edge::set_callee (cgraph_node *n)
3134 prev_caller = NULL;
3135 if (n->callers)
3136 n->callers->prev_caller = this;
3137 next_caller = n->callers;
3138 n->callers = this;
3139 callee = n;
3142 /* Redirect callee of the edge to N. The function does not update underlying
3143 call expression. */
3145 inline void
3146 cgraph_edge::redirect_callee (cgraph_node *n)
3148 /* Remove from callers list of the current callee. */
3149 remove_callee ();
3151 /* Insert to callers list of the new callee. */
3152 set_callee (n);
3155 /* Return true when the edge represents a direct recursion. */
3157 inline bool
3158 cgraph_edge::recursive_p (void)
3160 cgraph_node *c = callee->ultimate_alias_target ();
3161 if (caller->global.inlined_to)
3162 return caller->global.inlined_to->decl == c->decl;
3163 else
3164 return caller->decl == c->decl;
3167 /* Remove the edge from the list of the callers of the callee. */
3169 inline void
3170 cgraph_edge::remove_callee (void)
3172 gcc_assert (!indirect_unknown_callee);
3173 if (prev_caller)
3174 prev_caller->next_caller = next_caller;
3175 if (next_caller)
3176 next_caller->prev_caller = prev_caller;
3177 if (!prev_caller)
3178 callee->callers = next_caller;
3181 /* Return true if call must bind to current definition. */
3183 inline bool
3184 cgraph_edge::binds_to_current_def_p ()
3186 if (callee)
3187 return callee->binds_to_current_def_p (caller);
3188 else
3189 return false;
3192 /* Expected frequency of executions within the function.
3193 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
3194 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
3196 inline int
3197 cgraph_edge::frequency ()
3199 return count.to_cgraph_frequency (caller->global.inlined_to
3200 ? caller->global.inlined_to->count
3201 : caller->count);
3205 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
3206 static inline bool
3207 decl_is_tm_clone (const_tree fndecl)
3209 cgraph_node *n = cgraph_node::get (fndecl);
3210 if (n)
3211 return n->tm_clone;
3212 return false;
3215 /* Likewise indicate that a node is needed, i.e. reachable via some
3216 external means. */
3218 inline void
3219 cgraph_node::mark_force_output (void)
3221 force_output = 1;
3222 gcc_checking_assert (!global.inlined_to);
3225 /* Return true if function should be optimized for size. */
3227 inline bool
3228 cgraph_node::optimize_for_size_p (void)
3230 if (opt_for_fn (decl, optimize_size))
3231 return true;
3232 if (frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)
3233 return true;
3234 else
3235 return false;
3238 /* Return symtab_node for NODE or create one if it is not present
3239 in symtab. */
3241 inline symtab_node *
3242 symtab_node::get_create (tree node)
3244 if (TREE_CODE (node) == VAR_DECL)
3245 return varpool_node::get_create (node);
3246 else
3247 return cgraph_node::get_create (node);
3250 /* Return availability of NODE when referenced from REF. */
3252 inline enum availability
3253 symtab_node::get_availability (symtab_node *ref)
3255 if (is_a <cgraph_node *> (this))
3256 return dyn_cast <cgraph_node *> (this)->get_availability (ref);
3257 else
3258 return dyn_cast <varpool_node *> (this)->get_availability (ref);
3261 /* Call calback on symtab node and aliases associated to this node.
3262 When INCLUDE_OVERWRITABLE is false, overwritable symbols are skipped. */
3264 inline bool
3265 symtab_node::call_for_symbol_and_aliases (bool (*callback) (symtab_node *,
3266 void *),
3267 void *data,
3268 bool include_overwritable)
3270 if (include_overwritable
3271 || get_availability () > AVAIL_INTERPOSABLE)
3273 if (callback (this, data))
3274 return true;
3276 if (has_aliases_p ())
3277 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
3278 return false;
3281 /* Call callback on function and aliases associated to the function.
3282 When INCLUDE_OVERWRITABLE is false, overwritable symbols are
3283 skipped. */
3285 inline bool
3286 cgraph_node::call_for_symbol_and_aliases (bool (*callback) (cgraph_node *,
3287 void *),
3288 void *data,
3289 bool include_overwritable)
3291 if (include_overwritable
3292 || get_availability () > AVAIL_INTERPOSABLE)
3294 if (callback (this, data))
3295 return true;
3297 if (has_aliases_p ())
3298 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
3299 return false;
3302 /* Call calback on varpool symbol and aliases associated to varpool symbol.
3303 When INCLUDE_OVERWRITABLE is false, overwritable symbols are
3304 skipped. */
3306 inline bool
3307 varpool_node::call_for_symbol_and_aliases (bool (*callback) (varpool_node *,
3308 void *),
3309 void *data,
3310 bool include_overwritable)
3312 if (include_overwritable
3313 || get_availability () > AVAIL_INTERPOSABLE)
3315 if (callback (this, data))
3316 return true;
3318 if (has_aliases_p ())
3319 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
3320 return false;
3323 /* Return true if refernece may be used in address compare. */
3325 inline bool
3326 ipa_ref::address_matters_p ()
3328 if (use != IPA_REF_ADDR)
3329 return false;
3330 /* Addresses taken from virtual tables are never compared. */
3331 if (is_a <varpool_node *> (referring)
3332 && DECL_VIRTUAL_P (referring->decl))
3333 return false;
3334 return referred->address_can_be_compared_p ();
3337 /* Build polymorphic call context for indirect call E. */
3339 inline
3340 ipa_polymorphic_call_context::ipa_polymorphic_call_context (cgraph_edge *e)
3342 gcc_checking_assert (e->indirect_info->polymorphic);
3343 *this = e->indirect_info->context;
3346 /* Build empty "I know nothing" context. */
3348 inline
3349 ipa_polymorphic_call_context::ipa_polymorphic_call_context ()
3351 clear_speculation ();
3352 clear_outer_type ();
3353 invalid = false;
3356 /* Make context non-speculative. */
3358 inline void
3359 ipa_polymorphic_call_context::clear_speculation ()
3361 speculative_outer_type = NULL;
3362 speculative_offset = 0;
3363 speculative_maybe_derived_type = false;
3366 /* Produce context specifying all derrived types of OTR_TYPE. If OTR_TYPE is
3367 NULL, the context is set to dummy "I know nothing" setting. */
3369 inline void
3370 ipa_polymorphic_call_context::clear_outer_type (tree otr_type)
3372 outer_type = otr_type ? TYPE_MAIN_VARIANT (otr_type) : NULL;
3373 offset = 0;
3374 maybe_derived_type = true;
3375 maybe_in_construction = true;
3376 dynamic = true;
3379 /* Adjust all offsets in contexts by OFF bits. */
3381 inline void
3382 ipa_polymorphic_call_context::offset_by (HOST_WIDE_INT off)
3384 if (outer_type)
3385 offset += off;
3386 if (speculative_outer_type)
3387 speculative_offset += off;
3390 /* Return TRUE if context is fully useless. */
3392 inline bool
3393 ipa_polymorphic_call_context::useless_p () const
3395 return (!outer_type && !speculative_outer_type);
3398 /* When using fprintf (or similar), problems can arise with
3399 transient generated strings. Many string-generation APIs
3400 only support one result being alive at once (e.g. by
3401 returning a pointer to a statically-allocated buffer).
3403 If there is more than one generated string within one
3404 fprintf call: the first string gets evicted or overwritten
3405 by the second, before fprintf is fully evaluated.
3406 See e.g. PR/53136.
3408 This function provides a workaround for this, by providing
3409 a simple way to create copies of these transient strings,
3410 without the need to have explicit cleanup:
3412 fprintf (dumpfile, "string 1: %s string 2:%s\n",
3413 xstrdup_for_dump (EXPR_1),
3414 xstrdup_for_dump (EXPR_2));
3416 This is actually a simple wrapper around ggc_strdup, but
3417 the name documents the intent. We require that no GC can occur
3418 within the fprintf call. */
3420 static inline const char *
3421 xstrdup_for_dump (const char *transient_str)
3423 return ggc_strdup (transient_str);
3426 /* During LTO stream-in this predicate can be used to check whether node
3427 in question prevails in the linking to save some memory usage. */
3428 inline bool
3429 symtab_node::prevailing_p (void)
3431 return definition && ((!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
3432 || previous_sharing_asm_name == NULL);
3435 extern GTY(()) symbol_table *saved_symtab;
3437 #if CHECKING_P
3439 namespace selftest {
3441 /* An RAII-style class for use in selftests for temporarily using a different
3442 symbol_table, so that such tests can be isolated from each other. */
3444 class symbol_table_test
3446 public:
3447 /* Constructor. Override "symtab". */
3448 symbol_table_test ();
3450 /* Destructor. Restore the saved_symtab. */
3451 ~symbol_table_test ();
3454 } // namespace selftest
3456 #endif /* CHECKING_P */
3458 #endif /* GCC_CGRAPH_H */