PR target/58115
[official-gcc.git] / gcc / cgraph.h
blob7ce54014e1ef26e59dfb4c45c1892de1faf2eac3
1 /* Callgraph handling code.
2 Copyright (C) 2003-2014 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_CGRAPH_H
22 #define GCC_CGRAPH_H
24 #include "is-a.h"
25 #include "plugin-api.h"
26 #include "vec.h"
27 #include "basic-block.h"
28 #include "function.h"
29 #include "ipa-ref.h"
31 /* Symbol table consists of functions and variables.
32 TODO: add labels and CONST_DECLs. */
33 enum symtab_type
35 SYMTAB_SYMBOL,
36 SYMTAB_FUNCTION,
37 SYMTAB_VARIABLE
40 /* Base of all entries in the symbol table.
41 The symtab_node is inherited by cgraph and varpol nodes. */
42 class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
43 chain_next ("%h.next"), chain_prev ("%h.previous")))
44 symtab_node
46 public:
47 /* Return name. */
48 const char *name () const;
50 /* Return asm name. */
51 const char * asm_name () const;
53 /* Type of the symbol. */
54 ENUM_BITFIELD (symtab_type) type : 8;
56 /* The symbols resolution. */
57 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
59 /*** Flags representing the symbol type. ***/
61 /* True when symbol corresponds to a definition in current unit.
62 set via cgraph_finalize_function or varpool_finalize_decl */
63 unsigned definition : 1;
64 /* True when symbol is an alias.
65 Set by assemble_alias. */
66 unsigned alias : 1;
67 /* True when alias is a weakref. */
68 unsigned weakref : 1;
69 /* C++ frontend produce same body aliases and extra name aliases for
70 virtual functions and vtables that are obviously equivalent.
71 Those aliases are bit special, especially because C++ frontend
72 visibility code is so ugly it can not get them right at first time
73 and their visibility needs to be copied from their "masters" at
74 the end of parsing. */
75 unsigned cpp_implicit_alias : 1;
76 /* Set once the definition was analyzed. The list of references and
77 other properties are built during analysis. */
78 unsigned analyzed : 1;
81 /*** Visibility and linkage flags. ***/
83 /* Set when function is visible by other units. */
84 unsigned externally_visible : 1;
85 /* The symbol will be assumed to be used in an invisiable way (like
86 by an toplevel asm statement). */
87 unsigned force_output : 1;
88 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
89 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
90 to static and it does not inhibit optimization. */
91 unsigned forced_by_abi : 1;
92 /* True when the name is known to be unique and thus it does not need mangling. */
93 unsigned unique_name : 1;
96 /*** WHOPR Partitioning flags.
97 These flags are used at ltrans stage when only part of the callgraph is
98 available. ***/
100 /* Set when variable is used from other LTRANS partition. */
101 unsigned used_from_other_partition : 1;
102 /* Set when function is available in the other LTRANS partition.
103 During WPA output it is used to mark nodes that are present in
104 multiple partitions. */
105 unsigned in_other_partition : 1;
109 /*** other flags. ***/
111 /* Set when symbol has address taken. */
112 unsigned address_taken : 1;
115 /* Ordering of all symtab entries. */
116 int order;
118 /* Declaration representing the symbol. */
119 tree decl;
121 /* Linked list of symbol table entries starting with symtab_nodes. */
122 symtab_node *next;
123 symtab_node *previous;
125 /* Linked list of symbols with the same asm name. There may be multiple
126 entries for single symbol name during LTO, because symbols are renamed
127 only after partitioning.
129 Because inline clones are kept in the assembler name has, they also produce
130 duplicate entries.
132 There are also several long standing bugs where frontends and builtin
133 code produce duplicated decls. */
134 symtab_node *next_sharing_asm_name;
135 symtab_node *previous_sharing_asm_name;
137 /* Circular list of nodes in the same comdat group if non-NULL. */
138 symtab_node *same_comdat_group;
140 /* Vectors of referring and referenced entities. */
141 struct ipa_ref_list ref_list;
143 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
144 depending to what was known to frontend on the creation time.
145 Once alias is resolved, this pointer become NULL. */
146 tree alias_target;
148 /* File stream where this node is being written to. */
149 struct lto_file_decl_data * lto_file_data;
151 PTR GTY ((skip)) aux;
154 enum availability
156 /* Not yet set by cgraph_function_body_availability. */
157 AVAIL_UNSET,
158 /* Function body/variable initializer is unknown. */
159 AVAIL_NOT_AVAILABLE,
160 /* Function body/variable initializer is known but might be replaced
161 by a different one from other compilation unit and thus needs to
162 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
163 arbitrary side effects on escaping variables and functions, while
164 like AVAILABLE it might access static variables. */
165 AVAIL_OVERWRITABLE,
166 /* Function body/variable initializer is known and will be used in final
167 program. */
168 AVAIL_AVAILABLE,
169 /* Function body/variable initializer is known and all it's uses are explicitly
170 visible within current unit (ie it's address is never taken and it is not
171 exported to other units).
172 Currently used only for functions. */
173 AVAIL_LOCAL
176 /* This is the information that is put into the cgraph local structure
177 to recover a function. */
178 struct lto_file_decl_data;
180 extern const char * const cgraph_availability_names[];
181 extern const char * const ld_plugin_symbol_resolution_names[];
183 /* Information about thunk, used only for same body aliases. */
185 struct GTY(()) cgraph_thunk_info {
186 /* Information about the thunk. */
187 HOST_WIDE_INT fixed_offset;
188 HOST_WIDE_INT virtual_value;
189 tree alias;
190 bool this_adjusting;
191 bool virtual_offset_p;
192 /* Set to true when alias node is thunk. */
193 bool thunk_p;
196 /* Information about the function collected locally.
197 Available after function is analyzed. */
199 struct GTY(()) cgraph_local_info {
200 /* Set when function function is visible in current compilation unit only
201 and its address is never taken. */
202 unsigned local : 1;
204 /* False when there is something makes versioning impossible. */
205 unsigned versionable : 1;
207 /* False when function calling convention and signature can not be changed.
208 This is the case when __builtin_apply_args is used. */
209 unsigned can_change_signature : 1;
211 /* True when the function has been originally extern inline, but it is
212 redefined now. */
213 unsigned redefined_extern_inline : 1;
215 /* True if the function may enter serial irrevocable mode. */
216 unsigned tm_may_enter_irr : 1;
219 /* Information about the function that needs to be computed globally
220 once compilation is finished. Available only with -funit-at-a-time. */
222 struct GTY(()) cgraph_global_info {
223 /* For inline clones this points to the function they will be
224 inlined into. */
225 struct cgraph_node *inlined_to;
228 /* Information about the function that is propagated by the RTL backend.
229 Available only for functions that has been already assembled. */
231 struct GTY(()) cgraph_rtl_info {
232 unsigned int preferred_incoming_stack_boundary;
235 /* Represent which DECL tree (or reference to such tree)
236 will be replaced by another tree while versioning. */
237 struct GTY(()) ipa_replace_map
239 /* The tree that will be replaced. */
240 tree old_tree;
241 /* The new (replacing) tree. */
242 tree new_tree;
243 /* Parameter number to replace, when old_tree is NULL. */
244 int parm_num;
245 /* True when a substitution should be done, false otherwise. */
246 bool replace_p;
247 /* True when we replace a reference to old_tree. */
248 bool ref_p;
250 typedef struct ipa_replace_map *ipa_replace_map_p;
252 struct GTY(()) cgraph_clone_info
254 vec<ipa_replace_map_p, va_gc> *tree_map;
255 bitmap args_to_skip;
256 bitmap combined_args_to_skip;
259 enum cgraph_simd_clone_arg_type
261 SIMD_CLONE_ARG_TYPE_VECTOR,
262 SIMD_CLONE_ARG_TYPE_UNIFORM,
263 SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
264 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
265 SIMD_CLONE_ARG_TYPE_MASK
268 /* Function arguments in the original function of a SIMD clone.
269 Supplementary data for `struct simd_clone'. */
271 struct GTY(()) cgraph_simd_clone_arg {
272 /* Original function argument as it originally existed in
273 DECL_ARGUMENTS. */
274 tree orig_arg;
276 /* orig_arg's function (or for extern functions type from
277 TYPE_ARG_TYPES). */
278 tree orig_type;
280 /* If argument is a vector, this holds the vector version of
281 orig_arg that after adjusting the argument types will live in
282 DECL_ARGUMENTS. Otherwise, this is NULL.
284 This basically holds:
285 vector(simdlen) __typeof__(orig_arg) new_arg. */
286 tree vector_arg;
288 /* vector_arg's type (or for extern functions new vector type. */
289 tree vector_type;
291 /* If argument is a vector, this holds the array where the simd
292 argument is held while executing the simd clone function. This
293 is a local variable in the cloned function. Its content is
294 copied from vector_arg upon entry to the clone.
296 This basically holds:
297 __typeof__(orig_arg) simd_array[simdlen]. */
298 tree simd_array;
300 /* A SIMD clone's argument can be either linear (constant or
301 variable), uniform, or vector. */
302 enum cgraph_simd_clone_arg_type arg_type;
304 /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP this is
305 the constant linear step, if arg_type is
306 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP, this is index of
307 the uniform argument holding the step, otherwise 0. */
308 HOST_WIDE_INT linear_step;
310 /* Variable alignment if available, otherwise 0. */
311 unsigned int alignment;
314 /* Specific data for a SIMD function clone. */
316 struct GTY(()) cgraph_simd_clone {
317 /* Number of words in the SIMD lane associated with this clone. */
318 unsigned int simdlen;
320 /* Number of annotated function arguments in `args'. This is
321 usually the number of named arguments in FNDECL. */
322 unsigned int nargs;
324 /* Max hardware vector size in bits for integral vectors. */
325 unsigned int vecsize_int;
327 /* Max hardware vector size in bits for floating point vectors. */
328 unsigned int vecsize_float;
330 /* The mangling character for a given vector size. This is is used
331 to determine the ISA mangling bit as specified in the Intel
332 Vector ABI. */
333 unsigned char vecsize_mangle;
335 /* True if this is the masked, in-branch version of the clone,
336 otherwise false. */
337 unsigned int inbranch : 1;
339 /* True if this is a Cilk Plus variant. */
340 unsigned int cilk_elemental : 1;
342 /* Doubly linked list of SIMD clones. */
343 struct cgraph_node *prev_clone, *next_clone;
345 /* Original cgraph node the SIMD clones were created for. */
346 struct cgraph_node *origin;
348 /* Annotated function arguments for the original function. */
349 struct cgraph_simd_clone_arg GTY((length ("%h.nargs"))) args[1];
353 /* The cgraph data structure.
354 Each function decl has assigned cgraph_node listing callees and callers. */
356 struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node {
357 public:
358 struct cgraph_edge *callees;
359 struct cgraph_edge *callers;
360 /* List of edges representing indirect calls with a yet undetermined
361 callee. */
362 struct cgraph_edge *indirect_calls;
363 /* For nested functions points to function the node is nested in. */
364 struct cgraph_node *origin;
365 /* Points to first nested function, if any. */
366 struct cgraph_node *nested;
367 /* Pointer to the next function with same origin, if any. */
368 struct cgraph_node *next_nested;
369 /* Pointer to the next clone. */
370 struct cgraph_node *next_sibling_clone;
371 struct cgraph_node *prev_sibling_clone;
372 struct cgraph_node *clones;
373 struct cgraph_node *clone_of;
374 /* For functions with many calls sites it holds map from call expression
375 to the edge to speed up cgraph_edge function. */
376 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
377 /* Declaration node used to be clone of. */
378 tree former_clone_of;
380 /* If this is a SIMD clone, this points to the SIMD specific
381 information for it. */
382 struct cgraph_simd_clone *simdclone;
383 /* If this function has SIMD clones, this points to the first clone. */
384 struct cgraph_node *simd_clones;
386 /* Interprocedural passes scheduled to have their transform functions
387 applied next time we execute local pass on them. We maintain it
388 per-function in order to allow IPA passes to introduce new functions. */
389 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
391 struct cgraph_local_info local;
392 struct cgraph_global_info global;
393 struct cgraph_rtl_info rtl;
394 struct cgraph_clone_info clone;
395 struct cgraph_thunk_info thunk;
397 /* Expected number of executions: calculated in profile.c. */
398 gcov_type count;
399 /* How to scale counts at materialization time; used to merge
400 LTO units with different number of profile runs. */
401 int count_materialization_scale;
402 /* Unique id of the node. */
403 int uid;
404 /* ID assigned by the profiling. */
405 unsigned int profile_id;
406 /* Time profiler: first run of function. */
407 int tp_first_run;
409 /* Set when decl is an abstract function pointed to by the
410 ABSTRACT_DECL_ORIGIN of a reachable function. */
411 unsigned used_as_abstract_origin : 1;
412 /* Set once the function is lowered (i.e. its CFG is built). */
413 unsigned lowered : 1;
414 /* Set once the function has been instantiated and its callee
415 lists created. */
416 unsigned process : 1;
417 /* How commonly executed the node is. Initialized during branch
418 probabilities pass. */
419 ENUM_BITFIELD (node_frequency) frequency : 2;
420 /* True when function can only be called at startup (from static ctor). */
421 unsigned only_called_at_startup : 1;
422 /* True when function can only be called at startup (from static dtor). */
423 unsigned only_called_at_exit : 1;
424 /* True when function is the transactional clone of a function which
425 is called only from inside transactions. */
426 /* ?? We should be able to remove this. We have enough bits in
427 cgraph to calculate it. */
428 unsigned tm_clone : 1;
429 /* True if this decl is a dispatcher for function versions. */
430 unsigned dispatcher_function : 1;
431 /* True if this decl calls a COMDAT-local function. This is set up in
432 compute_inline_parameters and inline_call. */
433 unsigned calls_comdat_local : 1;
437 typedef struct cgraph_node *cgraph_node_ptr;
440 /* Function Multiversioning info. */
441 struct GTY(()) cgraph_function_version_info {
442 /* The cgraph_node for which the function version info is stored. */
443 struct cgraph_node *this_node;
444 /* Chains all the semantically identical function versions. The
445 first function in this chain is the version_info node of the
446 default function. */
447 struct cgraph_function_version_info *prev;
448 /* If this version node corresponds to a dispatcher for function
449 versions, this points to the version info node of the default
450 function, the first node in the chain. */
451 struct cgraph_function_version_info *next;
452 /* If this node corresponds to a function version, this points
453 to the dispatcher function decl, which is the function that must
454 be called to execute the right function version at run-time.
456 If this cgraph node is a dispatcher (if dispatcher_function is
457 true, in the cgraph_node struct) for function versions, this
458 points to resolver function, which holds the function body of the
459 dispatcher. The dispatcher decl is an alias to the resolver
460 function decl. */
461 tree dispatcher_resolver;
464 /* Get the cgraph_function_version_info node corresponding to node. */
465 struct cgraph_function_version_info *
466 get_cgraph_node_version (struct cgraph_node *node);
468 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
469 corresponding to cgraph_node NODE. */
470 struct cgraph_function_version_info *
471 insert_new_cgraph_node_version (struct cgraph_node *node);
473 /* Record that DECL1 and DECL2 are semantically identical function
474 versions. */
475 void record_function_versions (tree decl1, tree decl2);
477 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
478 DECL is a duplicate declaration. */
479 void delete_function_version (tree decl);
481 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
482 can appear in multiple sets. */
483 struct cgraph_node_set_def
485 struct pointer_map_t *map;
486 vec<cgraph_node_ptr> nodes;
489 class varpool_node;
490 typedef varpool_node *varpool_node_ptr;
493 /* A varpool node set is a collection of varpool nodes. A varpool node
494 can appear in multiple sets. */
495 struct varpool_node_set_def
497 struct pointer_map_t * map;
498 vec<varpool_node_ptr> nodes;
501 typedef struct cgraph_node_set_def *cgraph_node_set;
504 typedef struct varpool_node_set_def *varpool_node_set;
507 /* Iterator structure for cgraph node sets. */
508 struct cgraph_node_set_iterator
510 cgraph_node_set set;
511 unsigned index;
514 /* Iterator structure for varpool node sets. */
515 struct varpool_node_set_iterator
517 varpool_node_set set;
518 unsigned index;
521 #define DEFCIFCODE(code, string) CIF_ ## code,
522 /* Reasons for inlining failures. */
523 enum cgraph_inline_failed_t {
524 #include "cif-code.def"
525 CIF_N_REASONS
528 /* Structure containing additional information about an indirect call. */
530 struct GTY(()) cgraph_indirect_call_info
532 /* When polymorphic is set, this field contains offset where the object which
533 was actually used in the polymorphic resides within a larger structure.
534 If agg_contents is set, the field contains the offset within the aggregate
535 from which the address to call was loaded. */
536 HOST_WIDE_INT offset;
537 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
538 HOST_WIDE_INT otr_token;
539 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
540 tree otr_type, outer_type;
541 /* Index of the parameter that is called. */
542 int param_index;
543 /* ECF flags determined from the caller. */
544 int ecf_flags;
545 /* Profile_id of common target obtrained from profile. */
546 int common_target_id;
547 /* Probability that call will land in function with COMMON_TARGET_ID. */
548 int common_target_probability;
550 /* Set when the call is a virtual call with the parameter being the
551 associated object pointer rather than a simple direct call. */
552 unsigned polymorphic : 1;
553 /* Set when the call is a call of a pointer loaded from contents of an
554 aggregate at offset. */
555 unsigned agg_contents : 1;
556 /* Set when this is a call through a member pointer. */
557 unsigned member_ptr : 1;
558 /* When the previous bit is set, this one determines whether the destination
559 is loaded from a parameter passed by reference. */
560 unsigned by_ref : 1;
561 unsigned int maybe_in_construction : 1;
562 unsigned int maybe_derived_type : 1;
565 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
566 /* Expected number of executions: calculated in profile.c. */
567 gcov_type count;
568 struct cgraph_node *caller;
569 struct cgraph_node *callee;
570 struct cgraph_edge *prev_caller;
571 struct cgraph_edge *next_caller;
572 struct cgraph_edge *prev_callee;
573 struct cgraph_edge *next_callee;
574 gimple call_stmt;
575 /* Additional information about an indirect call. Not cleared when an edge
576 becomes direct. */
577 struct cgraph_indirect_call_info *indirect_info;
578 PTR GTY ((skip (""))) aux;
579 /* When equal to CIF_OK, inline this call. Otherwise, points to the
580 explanation why function was not inlined. */
581 enum cgraph_inline_failed_t inline_failed;
582 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
583 when the function is serialized in. */
584 unsigned int lto_stmt_uid;
585 /* Expected frequency of executions within the function.
586 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
587 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
588 int frequency;
589 /* Unique id of the edge. */
590 int uid;
591 /* Whether this edge was made direct by indirect inlining. */
592 unsigned int indirect_inlining_edge : 1;
593 /* Whether this edge describes an indirect call with an undetermined
594 callee. */
595 unsigned int indirect_unknown_callee : 1;
596 /* Whether this edge is still a dangling */
597 /* True if the corresponding CALL stmt cannot be inlined. */
598 unsigned int call_stmt_cannot_inline_p : 1;
599 /* Can this call throw externally? */
600 unsigned int can_throw_external : 1;
601 /* Edges with SPECULATIVE flag represents indirect calls that was
602 speculatively turned into direct (i.e. by profile feedback).
603 The final code sequence will have form:
605 if (call_target == expected_fn)
606 expected_fn ();
607 else
608 call_target ();
610 Every speculative call is represented by three components attached
611 to a same call statement:
612 1) a direct call (to expected_fn)
613 2) an indirect call (to call_target)
614 3) a IPA_REF_ADDR refrence to expected_fn.
616 Optimizers may later redirect direct call to clone, so 1) and 3)
617 do not need to necesarily agree with destination. */
618 unsigned int speculative : 1;
621 #define CGRAPH_FREQ_BASE 1000
622 #define CGRAPH_FREQ_MAX 100000
624 typedef struct cgraph_edge *cgraph_edge_p;
627 /* The varpool data structure.
628 Each static variable decl has assigned varpool_node. */
630 class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node {
631 public:
632 /* Set when variable is scheduled to be assembled. */
633 unsigned output : 1;
635 /* Set if the variable is dynamically initialized, except for
636 function local statics. */
637 unsigned dynamically_initialized : 1;
640 /* Every top level asm statement is put into a asm_node. */
642 struct GTY(()) asm_node {
643 /* Next asm node. */
644 struct asm_node *next;
645 /* String for this asm node. */
646 tree asm_str;
647 /* Ordering of all cgraph nodes. */
648 int order;
651 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
653 template <>
654 template <>
655 inline bool
656 is_a_helper <cgraph_node>::test (symtab_node *p)
658 return p->type == SYMTAB_FUNCTION;
661 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
663 template <>
664 template <>
665 inline bool
666 is_a_helper <varpool_node>::test (symtab_node *p)
668 return p->type == SYMTAB_VARIABLE;
671 extern GTY(()) symtab_node *symtab_nodes;
672 extern GTY(()) int cgraph_n_nodes;
673 extern GTY(()) int cgraph_max_uid;
674 extern GTY(()) int cgraph_edge_max_uid;
675 extern bool cgraph_global_info_ready;
676 enum cgraph_state
678 /* Frontend is parsing and finalizing functions. */
679 CGRAPH_STATE_PARSING,
680 /* Callgraph is being constructed. It is safe to add new functions. */
681 CGRAPH_STATE_CONSTRUCTION,
682 /* Callgraph is being at LTO time. */
683 CGRAPH_LTO_STREAMING,
684 /* Callgraph is built and IPA passes are being run. */
685 CGRAPH_STATE_IPA,
686 /* Callgraph is built and all functions are transformed to SSA form. */
687 CGRAPH_STATE_IPA_SSA,
688 /* Functions are now ordered and being passed to RTL expanders. */
689 CGRAPH_STATE_EXPANSION,
690 /* All cgraph expansion is done. */
691 CGRAPH_STATE_FINISHED
693 extern enum cgraph_state cgraph_state;
694 extern bool cgraph_function_flags_ready;
695 extern cgraph_node_set cgraph_new_nodes;
697 extern GTY(()) struct asm_node *asm_nodes;
698 extern GTY(()) int symtab_order;
699 extern bool cpp_implicit_aliases_done;
701 /* In symtab.c */
702 void symtab_register_node (symtab_node *);
703 void symtab_unregister_node (symtab_node *);
704 void symtab_remove_node (symtab_node *);
705 symtab_node *symtab_get_node (const_tree);
706 symtab_node *symtab_node_for_asm (const_tree asmname);
707 void symtab_insert_node_to_hashtable (symtab_node *);
708 void symtab_add_to_same_comdat_group (symtab_node *, symtab_node *);
709 void symtab_dissolve_same_comdat_group_list (symtab_node *node);
710 void dump_symtab (FILE *);
711 void debug_symtab (void);
712 void dump_symtab_node (FILE *, symtab_node *);
713 void debug_symtab_node (symtab_node *);
714 void dump_symtab_base (FILE *, symtab_node *);
715 void verify_symtab (void);
716 void verify_symtab_node (symtab_node *);
717 bool verify_symtab_base (symtab_node *);
718 bool symtab_used_from_object_file_p (symtab_node *);
719 void symtab_make_decl_local (tree);
720 symtab_node *symtab_alias_ultimate_target (symtab_node *,
721 enum availability *avail = NULL);
722 bool symtab_resolve_alias (symtab_node *node, symtab_node *target);
723 void fixup_same_cpp_alias_visibility (symtab_node *node, symtab_node *target);
724 bool symtab_for_node_and_aliases (symtab_node *,
725 bool (*) (symtab_node *, void *),
726 void *,
727 bool);
728 symtab_node *symtab_nonoverwritable_alias (symtab_node *);
729 enum availability symtab_node_availability (symtab_node *);
730 bool symtab_semantically_equivalent_p (symtab_node *, symtab_node *);
732 /* In cgraph.c */
733 void dump_cgraph (FILE *);
734 void debug_cgraph (void);
735 void dump_cgraph_node (FILE *, struct cgraph_node *);
736 void debug_cgraph_node (struct cgraph_node *);
737 void cgraph_remove_edge (struct cgraph_edge *);
738 void cgraph_remove_node (struct cgraph_node *);
739 void cgraph_release_function_body (struct cgraph_node *);
740 void release_function_body (tree);
741 void cgraph_node_remove_callees (struct cgraph_node *node);
742 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
743 struct cgraph_node *,
744 gimple, gcov_type, int);
745 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
746 int, gcov_type, int);
747 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
748 struct cgraph_node * cgraph_create_node (tree);
749 struct cgraph_node * cgraph_create_empty_node (void);
750 struct cgraph_node * cgraph_get_create_node (tree);
751 struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
752 struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
753 HOST_WIDE_INT, tree, tree);
754 struct cgraph_node *cgraph_node_for_asm (tree);
755 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
756 void cgraph_set_call_stmt (struct cgraph_edge *, gimple, bool update_speculative = true);
757 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
758 struct cgraph_local_info *cgraph_local_info (tree);
759 struct cgraph_global_info *cgraph_global_info (tree);
760 struct cgraph_rtl_info *cgraph_rtl_info (tree);
761 struct cgraph_node *cgraph_create_function_alias (tree, tree);
762 void cgraph_call_node_duplication_hooks (struct cgraph_node *,
763 struct cgraph_node *);
764 void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
765 struct cgraph_edge *);
767 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
768 struct cgraph_edge *cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
769 bool cgraph_only_called_directly_p (struct cgraph_node *);
771 bool cgraph_function_possibly_inlined_p (tree);
772 void cgraph_unnest_node (struct cgraph_node *);
774 enum availability cgraph_function_body_availability (struct cgraph_node *);
775 void cgraph_add_new_function (tree, bool);
776 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
778 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
779 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
780 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
781 bool cgraph_node_cannot_return (struct cgraph_node *);
782 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
783 bool cgraph_will_be_removed_from_program_if_no_direct_calls
784 (struct cgraph_node *node);
785 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
786 (struct cgraph_node *node);
787 bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
788 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
789 bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
790 bool (*) (struct cgraph_node *, void *),
791 void *,
792 bool);
793 bool cgraph_for_node_and_aliases (struct cgraph_node *,
794 bool (*) (struct cgraph_node *, void *),
795 void *, bool);
796 vec<cgraph_edge_p> collect_callers_of_node (struct cgraph_node *node);
797 void verify_cgraph (void);
798 void verify_cgraph_node (struct cgraph_node *);
799 void cgraph_mark_address_taken_node (struct cgraph_node *);
801 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
802 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
803 typedef void (*varpool_node_hook)(varpool_node *, void *);
804 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
805 void *);
806 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
807 void *);
808 struct cgraph_edge_hook_list;
809 struct cgraph_node_hook_list;
810 struct varpool_node_hook_list;
811 struct cgraph_2edge_hook_list;
812 struct cgraph_2node_hook_list;
813 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
814 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
815 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
816 void *);
817 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
818 struct varpool_node_hook_list *varpool_add_node_removal_hook (varpool_node_hook,
819 void *);
820 void varpool_remove_node_removal_hook (struct varpool_node_hook_list *);
821 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
822 void *);
823 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
824 struct varpool_node_hook_list *varpool_add_variable_insertion_hook (varpool_node_hook,
825 void *);
826 void varpool_remove_variable_insertion_hook (struct varpool_node_hook_list *);
827 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
828 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
829 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
830 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
831 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
832 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
833 struct cgraph_node * cgraph_function_node (struct cgraph_node *,
834 enum availability *avail = NULL);
835 bool cgraph_get_body (struct cgraph_node *node);
836 struct cgraph_edge *
837 cgraph_turn_edge_to_speculative (struct cgraph_edge *,
838 struct cgraph_node *,
839 gcov_type, int);
840 void cgraph_speculative_call_info (struct cgraph_edge *,
841 struct cgraph_edge *&,
842 struct cgraph_edge *&,
843 struct ipa_ref *&);
844 extern bool gimple_check_call_matching_types (gimple, tree, bool);
846 /* In cgraphunit.c */
847 struct asm_node *add_asm_node (tree);
848 extern FILE *cgraph_dump_file;
849 void cgraph_finalize_function (tree, bool);
850 void finalize_compilation_unit (void);
851 void compile (void);
852 void init_cgraph (void);
853 void cgraph_process_new_functions (void);
854 void cgraph_process_same_body_aliases (void);
855 void fixup_same_cpp_alias_visibility (symtab_node *, symtab_node *target, tree);
856 /* Initialize datastructures so DECL is a function in lowered gimple form.
857 IN_SSA is true if the gimple is in SSA. */
858 basic_block init_lowered_empty_function (tree, bool);
859 void cgraph_reset_node (struct cgraph_node *);
860 bool expand_thunk (struct cgraph_node *, bool);
862 /* In cgraphclones.c */
864 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
865 struct cgraph_node *, gimple,
866 unsigned, gcov_type, int, bool);
867 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
868 int, bool, vec<cgraph_edge_p>,
869 bool, struct cgraph_node *);
870 tree clone_function_name (tree decl, const char *);
871 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
872 vec<cgraph_edge_p>,
873 vec<ipa_replace_map_p, va_gc> *tree_map,
874 bitmap args_to_skip,
875 const char *clone_name);
876 struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
877 bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
878 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple,
879 bool update_speculative = true);
880 void cgraph_create_edge_including_clones (struct cgraph_node *,
881 struct cgraph_node *,
882 gimple, gimple, gcov_type, int,
883 cgraph_inline_failed_t);
884 void cgraph_materialize_all_clones (void);
885 struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
886 tree, vec<cgraph_edge_p>, bitmap);
887 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
888 vec<cgraph_edge_p>,
889 vec<ipa_replace_map_p, va_gc> *,
890 bitmap, bool, bitmap,
891 basic_block, const char *);
892 void tree_function_versioning (tree, tree, vec<ipa_replace_map_p, va_gc> *,
893 bool, bitmap, bool, bitmap, basic_block);
894 struct cgraph_edge *cgraph_resolve_speculation (struct cgraph_edge *, tree);
896 /* In cgraphbuild.c */
897 unsigned int rebuild_cgraph_edges (void);
898 void cgraph_rebuild_references (void);
899 int compute_call_stmt_bb_frequency (tree, basic_block bb);
900 void record_references_in_initializer (tree, bool);
901 void ipa_record_stmt_references (struct cgraph_node *, gimple);
903 /* In ipa.c */
904 bool symtab_remove_unreachable_nodes (bool, FILE *);
905 cgraph_node_set cgraph_node_set_new (void);
906 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
907 struct cgraph_node *);
908 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
909 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
910 void dump_cgraph_node_set (FILE *, cgraph_node_set);
911 void debug_cgraph_node_set (cgraph_node_set);
912 void free_cgraph_node_set (cgraph_node_set);
913 void cgraph_build_static_cdtor (char which, tree body, int priority);
915 varpool_node_set varpool_node_set_new (void);
916 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
917 varpool_node *);
918 void varpool_node_set_add (varpool_node_set, varpool_node *);
919 void varpool_node_set_remove (varpool_node_set, varpool_node *);
920 void dump_varpool_node_set (FILE *, varpool_node_set);
921 void debug_varpool_node_set (varpool_node_set);
922 void free_varpool_node_set (varpool_node_set);
923 void ipa_discover_readonly_nonaddressable_vars (void);
924 bool varpool_externally_visible_p (varpool_node *);
926 /* In predict.c */
927 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
928 bool cgraph_optimize_for_size_p (struct cgraph_node *);
930 /* In varpool.c */
931 varpool_node *varpool_create_empty_node (void);
932 varpool_node *varpool_node_for_decl (tree);
933 varpool_node *varpool_node_for_asm (tree asmname);
934 void varpool_mark_needed_node (varpool_node *);
935 void debug_varpool (void);
936 void dump_varpool (FILE *);
937 void dump_varpool_node (FILE *, varpool_node *);
939 void varpool_finalize_decl (tree);
940 enum availability cgraph_variable_initializer_availability (varpool_node *);
941 void cgraph_make_node_local (struct cgraph_node *);
942 bool cgraph_node_can_be_local_p (struct cgraph_node *);
945 void varpool_remove_node (varpool_node *node);
946 void varpool_finalize_named_section_flags (varpool_node *node);
947 bool varpool_output_variables (void);
948 bool varpool_assemble_decl (varpool_node *node);
949 void varpool_analyze_node (varpool_node *);
950 varpool_node * varpool_extra_name_alias (tree, tree);
951 varpool_node * varpool_create_variable_alias (tree, tree);
952 void varpool_reset_queue (void);
953 tree ctor_for_folding (tree);
954 bool varpool_for_node_and_aliases (varpool_node *,
955 bool (*) (varpool_node *, void *),
956 void *, bool);
957 void varpool_add_new_variable (tree);
958 void symtab_initialize_asm_name_hash (void);
959 void symtab_prevail_in_asm_name_hash (symtab_node *node);
960 void varpool_remove_initializer (varpool_node *);
962 /* In cgraph.c */
963 extern void change_decl_assembler_name (tree, tree);
965 /* Return callgraph node for given symbol and check it is a function. */
966 static inline struct cgraph_node *
967 cgraph (symtab_node *node)
969 gcc_checking_assert (!node || node->type == SYMTAB_FUNCTION);
970 return (struct cgraph_node *)node;
973 /* Return varpool node for given symbol and check it is a variable. */
974 static inline varpool_node *
975 varpool (symtab_node *node)
977 gcc_checking_assert (!node || node->type == SYMTAB_VARIABLE);
978 return (varpool_node *)node;
981 /* Return callgraph node for given symbol and check it is a function. */
982 static inline struct cgraph_node *
983 cgraph_get_node (const_tree decl)
985 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
986 return cgraph (symtab_get_node (decl));
989 /* Return varpool node for given symbol and check it is a function. */
990 static inline varpool_node *
991 varpool_get_node (const_tree decl)
993 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
994 return varpool (symtab_get_node (decl));
997 /* Walk all symbols. */
998 #define FOR_EACH_SYMBOL(node) \
999 for ((node) = symtab_nodes; (node); (node) = (node)->next)
1002 /* Return first variable. */
1003 static inline varpool_node *
1004 varpool_first_variable (void)
1006 symtab_node *node;
1007 for (node = symtab_nodes; node; node = node->next)
1008 if (varpool_node *vnode = dyn_cast <varpool_node> (node))
1009 return vnode;
1010 return NULL;
1013 /* Return next variable after NODE. */
1014 static inline varpool_node *
1015 varpool_next_variable (varpool_node *node)
1017 symtab_node *node1 = node->next;
1018 for (; node1; node1 = node1->next)
1019 if (varpool_node *vnode1 = dyn_cast <varpool_node> (node1))
1020 return vnode1;
1021 return NULL;
1023 /* Walk all variables. */
1024 #define FOR_EACH_VARIABLE(node) \
1025 for ((node) = varpool_first_variable (); \
1026 (node); \
1027 (node) = varpool_next_variable ((node)))
1029 /* Return first reachable static variable with initializer. */
1030 static inline varpool_node *
1031 varpool_first_static_initializer (void)
1033 symtab_node *node;
1034 for (node = symtab_nodes; node; node = node->next)
1036 varpool_node *vnode = dyn_cast <varpool_node> (node);
1037 if (vnode && DECL_INITIAL (node->decl))
1038 return vnode;
1040 return NULL;
1043 /* Return next reachable static variable with initializer after NODE. */
1044 static inline varpool_node *
1045 varpool_next_static_initializer (varpool_node *node)
1047 symtab_node *node1 = node->next;
1048 for (; node1; node1 = node1->next)
1050 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
1051 if (vnode1 && DECL_INITIAL (node1->decl))
1052 return vnode1;
1054 return NULL;
1057 /* Walk all static variables with initializer set. */
1058 #define FOR_EACH_STATIC_INITIALIZER(node) \
1059 for ((node) = varpool_first_static_initializer (); (node); \
1060 (node) = varpool_next_static_initializer (node))
1062 /* Return first reachable static variable with initializer. */
1063 static inline varpool_node *
1064 varpool_first_defined_variable (void)
1066 symtab_node *node;
1067 for (node = symtab_nodes; node; node = node->next)
1069 varpool_node *vnode = dyn_cast <varpool_node> (node);
1070 if (vnode && vnode->definition)
1071 return vnode;
1073 return NULL;
1076 /* Return next reachable static variable with initializer after NODE. */
1077 static inline varpool_node *
1078 varpool_next_defined_variable (varpool_node *node)
1080 symtab_node *node1 = node->next;
1081 for (; node1; node1 = node1->next)
1083 varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
1084 if (vnode1 && vnode1->definition)
1085 return vnode1;
1087 return NULL;
1089 /* Walk all variables with definitions in current unit. */
1090 #define FOR_EACH_DEFINED_VARIABLE(node) \
1091 for ((node) = varpool_first_defined_variable (); (node); \
1092 (node) = varpool_next_defined_variable (node))
1094 /* Return first function with body defined. */
1095 static inline struct cgraph_node *
1096 cgraph_first_defined_function (void)
1098 symtab_node *node;
1099 for (node = symtab_nodes; node; node = node->next)
1101 cgraph_node *cn = dyn_cast <cgraph_node> (node);
1102 if (cn && cn->definition)
1103 return cn;
1105 return NULL;
1108 /* Return next function with body defined after NODE. */
1109 static inline struct cgraph_node *
1110 cgraph_next_defined_function (struct cgraph_node *node)
1112 symtab_node *node1 = node->next;
1113 for (; node1; node1 = node1->next)
1115 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
1116 if (cn1 && cn1->definition)
1117 return cn1;
1119 return NULL;
1122 /* Walk all functions with body defined. */
1123 #define FOR_EACH_DEFINED_FUNCTION(node) \
1124 for ((node) = cgraph_first_defined_function (); (node); \
1125 (node) = cgraph_next_defined_function ((node)))
1127 /* Return first function. */
1128 static inline struct cgraph_node *
1129 cgraph_first_function (void)
1131 symtab_node *node;
1132 for (node = symtab_nodes; node; node = node->next)
1133 if (cgraph_node *cn = dyn_cast <cgraph_node> (node))
1134 return cn;
1135 return NULL;
1138 /* Return next function. */
1139 static inline struct cgraph_node *
1140 cgraph_next_function (struct cgraph_node *node)
1142 symtab_node *node1 = node->next;
1143 for (; node1; node1 = node1->next)
1144 if (cgraph_node *cn1 = dyn_cast <cgraph_node> (node1))
1145 return cn1;
1146 return NULL;
1148 /* Walk all functions. */
1149 #define FOR_EACH_FUNCTION(node) \
1150 for ((node) = cgraph_first_function (); (node); \
1151 (node) = cgraph_next_function ((node)))
1153 /* Return true when NODE is a function with Gimple body defined
1154 in current unit. Functions can also be define externally or they
1155 can be thunks with no Gimple representation.
1157 Note that at WPA stage, the function body may not be present in memory. */
1159 static inline bool
1160 cgraph_function_with_gimple_body_p (struct cgraph_node *node)
1162 return node->definition && !node->thunk.thunk_p && !node->alias;
1165 /* Return first function with body defined. */
1166 static inline struct cgraph_node *
1167 cgraph_first_function_with_gimple_body (void)
1169 symtab_node *node;
1170 for (node = symtab_nodes; node; node = node->next)
1172 cgraph_node *cn = dyn_cast <cgraph_node> (node);
1173 if (cn && cgraph_function_with_gimple_body_p (cn))
1174 return cn;
1176 return NULL;
1179 /* Return next reachable static variable with initializer after NODE. */
1180 static inline struct cgraph_node *
1181 cgraph_next_function_with_gimple_body (struct cgraph_node *node)
1183 symtab_node *node1 = node->next;
1184 for (; node1; node1 = node1->next)
1186 cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
1187 if (cn1 && cgraph_function_with_gimple_body_p (cn1))
1188 return cn1;
1190 return NULL;
1193 /* Walk all functions with body defined. */
1194 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1195 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1196 (node) = cgraph_next_function_with_gimple_body (node))
1198 /* Create a new static variable of type TYPE. */
1199 tree add_new_static_var (tree type);
1201 /* Return true if iterator CSI points to nothing. */
1202 static inline bool
1203 csi_end_p (cgraph_node_set_iterator csi)
1205 return csi.index >= csi.set->nodes.length ();
1208 /* Advance iterator CSI. */
1209 static inline void
1210 csi_next (cgraph_node_set_iterator *csi)
1212 csi->index++;
1215 /* Return the node pointed to by CSI. */
1216 static inline struct cgraph_node *
1217 csi_node (cgraph_node_set_iterator csi)
1219 return csi.set->nodes[csi.index];
1222 /* Return an iterator to the first node in SET. */
1223 static inline cgraph_node_set_iterator
1224 csi_start (cgraph_node_set set)
1226 cgraph_node_set_iterator csi;
1228 csi.set = set;
1229 csi.index = 0;
1230 return csi;
1233 /* Return true if SET contains NODE. */
1234 static inline bool
1235 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1237 cgraph_node_set_iterator csi;
1238 csi = cgraph_node_set_find (set, node);
1239 return !csi_end_p (csi);
1242 /* Return number of nodes in SET. */
1243 static inline size_t
1244 cgraph_node_set_size (cgraph_node_set set)
1246 return set->nodes.length ();
1249 /* Return true if iterator VSI points to nothing. */
1250 static inline bool
1251 vsi_end_p (varpool_node_set_iterator vsi)
1253 return vsi.index >= vsi.set->nodes.length ();
1256 /* Advance iterator VSI. */
1257 static inline void
1258 vsi_next (varpool_node_set_iterator *vsi)
1260 vsi->index++;
1263 /* Return the node pointed to by VSI. */
1264 static inline varpool_node *
1265 vsi_node (varpool_node_set_iterator vsi)
1267 return vsi.set->nodes[vsi.index];
1270 /* Return an iterator to the first node in SET. */
1271 static inline varpool_node_set_iterator
1272 vsi_start (varpool_node_set set)
1274 varpool_node_set_iterator vsi;
1276 vsi.set = set;
1277 vsi.index = 0;
1278 return vsi;
1281 /* Return true if SET contains NODE. */
1282 static inline bool
1283 varpool_node_in_set_p (varpool_node *node, varpool_node_set set)
1285 varpool_node_set_iterator vsi;
1286 vsi = varpool_node_set_find (set, node);
1287 return !vsi_end_p (vsi);
1290 /* Return number of nodes in SET. */
1291 static inline size_t
1292 varpool_node_set_size (varpool_node_set set)
1294 return set->nodes.length ();
1297 /* Uniquize all constants that appear in memory.
1298 Each constant in memory thus far output is recorded
1299 in `const_desc_table'. */
1301 struct GTY(()) constant_descriptor_tree {
1302 /* A MEM for the constant. */
1303 rtx rtl;
1305 /* The value of the constant. */
1306 tree value;
1308 /* Hash of value. Computing the hash from value each time
1309 hashfn is called can't work properly, as that means recursive
1310 use of the hash table during hash table expansion. */
1311 hashval_t hash;
1314 /* Return true if set is nonempty. */
1315 static inline bool
1316 cgraph_node_set_nonempty_p (cgraph_node_set set)
1318 return !set->nodes.is_empty ();
1321 /* Return true if set is nonempty. */
1322 static inline bool
1323 varpool_node_set_nonempty_p (varpool_node_set set)
1325 return !set->nodes.is_empty ();
1328 /* Return true when function NODE is only called directly or it has alias.
1329 i.e. it is not externally visible, address was not taken and
1330 it is not used in any other non-standard way. */
1332 static inline bool
1333 cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
1335 gcc_assert (!node->global.inlined_to);
1336 return (!node->force_output && !node->address_taken
1337 && !node->used_from_other_partition
1338 && !DECL_VIRTUAL_P (node->decl)
1339 && !DECL_STATIC_CONSTRUCTOR (node->decl)
1340 && !DECL_STATIC_DESTRUCTOR (node->decl)
1341 && !node->externally_visible);
1344 /* Return true when function NODE can be removed from callgraph
1345 if all direct calls are eliminated. */
1347 static inline bool
1348 varpool_can_remove_if_no_refs (varpool_node *node)
1350 if (DECL_EXTERNAL (node->decl))
1351 return true;
1352 return (!node->force_output && !node->used_from_other_partition
1353 && ((DECL_COMDAT (node->decl)
1354 && !node->forced_by_abi
1355 && !symtab_used_from_object_file_p (node))
1356 || !node->externally_visible
1357 || DECL_HAS_VALUE_EXPR_P (node->decl)));
1360 /* Return true when all references to VNODE must be visible in ipa_ref_list.
1361 i.e. if the variable is not externally visible or not used in some magic
1362 way (asm statement or such).
1363 The magic uses are all summarized in force_output flag. */
1365 static inline bool
1366 varpool_all_refs_explicit_p (varpool_node *vnode)
1368 return (vnode->definition
1369 && !vnode->externally_visible
1370 && !vnode->used_from_other_partition
1371 && !vnode->force_output);
1374 /* Constant pool accessor function. */
1375 htab_t constant_pool_htab (void);
1377 /* FIXME: inappropriate dependency of cgraph on IPA. */
1378 #include "ipa-ref-inline.h"
1380 /* Return node that alias N is aliasing. */
1382 static inline symtab_node *
1383 symtab_alias_target (symtab_node *n)
1385 struct ipa_ref *ref;
1386 ipa_ref_list_reference_iterate (&n->ref_list, 0, ref);
1387 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
1388 return ref->referred;
1391 static inline struct cgraph_node *
1392 cgraph_alias_target (struct cgraph_node *n)
1394 return dyn_cast <cgraph_node> (symtab_alias_target (n));
1397 static inline varpool_node *
1398 varpool_alias_target (varpool_node *n)
1400 return dyn_cast <varpool_node> (symtab_alias_target (n));
1403 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1404 Do not walk through thunks.
1405 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1407 static inline struct cgraph_node *
1408 cgraph_function_or_thunk_node (struct cgraph_node *node,
1409 enum availability *availability = NULL)
1411 struct cgraph_node *n;
1413 n = dyn_cast <cgraph_node> (symtab_alias_ultimate_target (node,
1414 availability));
1415 if (!n && availability)
1416 *availability = AVAIL_NOT_AVAILABLE;
1417 return n;
1419 /* Given NODE, walk the alias chain to return the function NODE is alias of.
1420 Do not walk through thunks.
1421 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
1423 static inline varpool_node *
1424 varpool_variable_node (varpool_node *node,
1425 enum availability *availability = NULL)
1427 varpool_node *n;
1429 if (node)
1430 n = dyn_cast <varpool_node> (symtab_alias_ultimate_target (node,
1431 availability));
1432 else
1433 n = NULL;
1435 if (!n && availability)
1436 *availability = AVAIL_NOT_AVAILABLE;
1437 return n;
1440 /* Return true when the edge E represents a direct recursion. */
1441 static inline bool
1442 cgraph_edge_recursive_p (struct cgraph_edge *e)
1444 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
1445 if (e->caller->global.inlined_to)
1446 return e->caller->global.inlined_to->decl == callee->decl;
1447 else
1448 return e->caller->decl == callee->decl;
1451 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
1452 static inline bool
1453 decl_is_tm_clone (const_tree fndecl)
1455 struct cgraph_node *n = cgraph_get_node (fndecl);
1456 if (n)
1457 return n->tm_clone;
1458 return false;
1461 /* Likewise indicate that a node is needed, i.e. reachable via some
1462 external means. */
1464 static inline void
1465 cgraph_mark_force_output_node (struct cgraph_node *node)
1467 node->force_output = 1;
1468 gcc_checking_assert (!node->global.inlined_to);
1471 /* Return true when the symbol is real symbol, i.e. it is not inline clone
1472 or abstract function kept for debug info purposes only. */
1474 static inline bool
1475 symtab_real_symbol_p (symtab_node *node)
1477 struct cgraph_node *cnode;
1479 if (DECL_ABSTRACT (node->decl))
1480 return false;
1481 if (!is_a <cgraph_node> (node))
1482 return true;
1483 cnode = cgraph (node);
1484 if (cnode->global.inlined_to)
1485 return false;
1486 return true;
1489 /* Return true if NODE can be discarded by linker from the binary. */
1491 static inline bool
1492 symtab_can_be_discarded (symtab_node *node)
1494 return (DECL_EXTERNAL (node->decl)
1495 || (DECL_ONE_ONLY (node->decl)
1496 && node->resolution != LDPR_PREVAILING_DEF
1497 && node->resolution != LDPR_PREVAILING_DEF_IRONLY
1498 && node->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP));
1501 /* Return true if NODE is local to a particular COMDAT group, and must not
1502 be named from outside the COMDAT. This is used for C++ decloned
1503 constructors. */
1505 static inline bool
1506 symtab_comdat_local_p (symtab_node *node)
1508 return (node->same_comdat_group && !TREE_PUBLIC (node->decl));
1511 /* Return true if ONE and TWO are part of the same COMDAT group. */
1513 static inline bool
1514 symtab_in_same_comdat_p (symtab_node *one, symtab_node *two)
1516 return DECL_COMDAT_GROUP (one->decl) == DECL_COMDAT_GROUP (two->decl);
1518 #endif /* GCC_CGRAPH_H */