source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/hardware/tools/avr/lib/gcc/avr/4.9.2/plugin/include/cgraph.h @ 4837

Last change on this file since 4837 was 4837, checked in by daduve, 2 years ago

Adding new version

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