OSDN Git Service

Clarify copyright license agreement.
[pf3gnuchains/gcc-fork.git] / gcc / cgraph.h
1 /* Callgraph handling code.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3    Free Software Foundation, Inc.
4    Contributed by Jan Hubicka
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H
24
25 #include "plugin-api.h"
26 #include "vec.h"
27 #include "tree.h"
28 #include "basic-block.h"
29 #include "function.h"
30 #include "ipa-ref.h"    /* FIXME: inappropriate dependency of cgraph on IPA.  */
31
32 enum availability
33 {
34   /* Not yet set by cgraph_function_body_availability.  */
35   AVAIL_UNSET,
36   /* Function body/variable initializer is unknown.  */
37   AVAIL_NOT_AVAILABLE,
38   /* Function body/variable initializer is known but might be replaced
39      by a different one from other compilation unit and thus needs to
40      be dealt with a care.  Like AVAIL_NOT_AVAILABLE it can have
41      arbitrary side effects on escaping variables and functions, while
42      like AVAILABLE it might access static variables.  */
43   AVAIL_OVERWRITABLE,
44   /* Function body/variable initializer is known and will be used in final
45      program.  */
46   AVAIL_AVAILABLE,
47   /* Function body/variable initializer is known and all it's uses are explicitly
48      visible within current unit (ie it's address is never taken and it is not
49      exported to other units).
50      Currently used only for functions.  */
51   AVAIL_LOCAL
52 };
53
54 /* This is the information that is put into the cgraph local structure
55    to recover a function.  */
56 struct lto_file_decl_data;
57
58 extern const char * const cgraph_availability_names[];
59 extern const char * const ld_plugin_symbol_resolution_names[];
60
61 /* Function inlining information.  */
62
63 struct GTY(()) inline_summary
64 {
65   /* Estimated stack frame consumption by the function.  */
66   HOST_WIDE_INT estimated_self_stack_size;
67
68   /* Size of the function body.  */
69   int self_size;
70   /* How many instructions are likely going to disappear after inlining.  */
71   int size_inlining_benefit;
72   /* Estimated time spent executing the function body.  */
73   int self_time;
74   /* How much time is going to be saved by inlining.  */
75   int time_inlining_benefit;
76 };
77
78 /* Information about thunk, used only for same body aliases.  */
79
80 struct GTY(()) cgraph_thunk_info {
81   /* Information about the thunk.  */
82   HOST_WIDE_INT fixed_offset;
83   HOST_WIDE_INT virtual_value;
84   tree alias;
85   bool this_adjusting;
86   bool virtual_offset_p;
87   /* Set to true when alias node is thunk.  */
88   bool thunk_p;
89 };
90
91 /* Information about the function collected locally.
92    Available after function is analyzed.  */
93
94 struct GTY(()) cgraph_local_info {
95   /* File stream where this node is being written to.  */
96   struct lto_file_decl_data * lto_file_data;
97
98   struct inline_summary inline_summary;
99
100   /* Set when function function is visible in current compilation unit only
101      and its address is never taken.  */
102   unsigned local : 1;
103
104   /* Set when function is visible by other units.  */
105   unsigned externally_visible : 1;
106   
107   /* Set once it has been finalized so we consider it to be output.  */
108   unsigned finalized : 1;
109
110   /* False when there something makes inlining impossible (such as va_arg).  */
111   unsigned inlinable : 1;
112
113   /* False when there something makes versioning impossible.
114      Currently computed and used only by ipa-cp.  */
115   unsigned versionable : 1;
116
117   /* True when function should be inlined independently on its size.  */
118   unsigned disregard_inline_limits : 1;
119
120   /* True when the function has been originally extern inline, but it is
121      redefined now.  */
122   unsigned redefined_extern_inline : 1;
123
124   /* True if the function is going to be emitted in some other translation
125      unit, referenced from vtable.  */
126   unsigned vtable_method : 1;
127 };
128
129 /* Information about the function that needs to be computed globally
130    once compilation is finished.  Available only with -funit-at-a-time.  */
131
132 struct GTY(()) cgraph_global_info {
133   /* Estimated stack frame consumption by the function.  */
134   HOST_WIDE_INT estimated_stack_size;
135   /* Expected offset of the stack frame of inlined function.  */
136   HOST_WIDE_INT stack_frame_offset;
137
138   /* For inline clones this points to the function they will be
139      inlined into.  */
140   struct cgraph_node *inlined_to;
141
142   /* Estimated size of the function after inlining.  */
143   int time;
144   int size;
145
146   /* Estimated growth after inlining.  INT_MIN if not computed.  */
147   int estimated_growth;
148 };
149
150 /* Information about the function that is propagated by the RTL backend.
151    Available only for functions that has been already assembled.  */
152
153 struct GTY(()) cgraph_rtl_info {
154    unsigned int preferred_incoming_stack_boundary;
155 };
156
157 /* Represent which DECL tree (or reference to such tree)
158    will be replaced by another tree while versioning.  */
159 struct GTY(()) ipa_replace_map
160 {
161   /* The tree that will be replaced.  */
162   tree old_tree;
163   /* The new (replacing) tree.  */
164   tree new_tree;
165   /* Parameter number to replace, when old_tree is NULL.  */
166   int parm_num;
167   /* True when a substitution should be done, false otherwise.  */
168   bool replace_p;
169   /* True when we replace a reference to old_tree.  */
170   bool ref_p;
171 };
172 typedef struct ipa_replace_map *ipa_replace_map_p;
173 DEF_VEC_P(ipa_replace_map_p);
174 DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
175
176 struct GTY(()) cgraph_clone_info
177 {
178   VEC(ipa_replace_map_p,gc)* tree_map;
179   bitmap args_to_skip;
180   bitmap combined_args_to_skip;
181 };
182
183
184 /* The cgraph data structure.
185    Each function decl has assigned cgraph_node listing callees and callers.  */
186
187 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
188   tree decl;
189   struct cgraph_edge *callees;
190   struct cgraph_edge *callers;
191   struct cgraph_node *next;
192   struct cgraph_node *previous;
193   /* List of edges representing indirect calls with a yet undetermined
194      callee.  */
195   struct cgraph_edge *indirect_calls;
196   /* For nested functions points to function the node is nested in.  */
197   struct cgraph_node *origin;
198   /* Points to first nested function, if any.  */
199   struct cgraph_node *nested;
200   /* Pointer to the next function with same origin, if any.  */
201   struct cgraph_node *next_nested;
202   /* Pointer to the next function in cgraph_nodes_queue.  */
203   struct cgraph_node *next_needed;
204   /* Pointer to the next clone.  */
205   struct cgraph_node *next_sibling_clone;
206   struct cgraph_node *prev_sibling_clone;
207   struct cgraph_node *clones;
208   struct cgraph_node *clone_of;
209   /* For normal nodes pointer to the list of alias and thunk nodes,
210      in alias/thunk nodes pointer to the normal node.  */
211   struct cgraph_node *same_body;
212   /* Circular list of nodes in the same comdat group if non-NULL.  */
213   struct cgraph_node *same_comdat_group;
214   /* For functions with many calls sites it holds map from call expression
215      to the edge to speed up cgraph_edge function.  */
216   htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
217   /* Declaration node used to be clone of. */
218   tree former_clone_of;
219
220   PTR GTY ((skip)) aux;
221
222   /* Interprocedural passes scheduled to have their transform functions
223      applied next time we execute local pass on them.  We maintain it
224      per-function in order to allow IPA passes to introduce new functions.  */
225   VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
226
227   struct ipa_ref_list ref_list;
228   struct cgraph_local_info local;
229   struct cgraph_global_info global;
230   struct cgraph_rtl_info rtl;
231   struct cgraph_clone_info clone;
232   struct cgraph_thunk_info thunk;
233
234   /* Expected number of executions: calculated in profile.c.  */
235   gcov_type count;
236   /* Unique id of the node.  */
237   int uid;
238   /* Ordering of all cgraph nodes.  */
239   int order;
240
241   /* unique id for profiling. pid is not suitable because of different
242      number of cfg nodes with -fprofile-generate and -fprofile-use */
243   int pid;
244   enum ld_plugin_symbol_resolution resolution;
245
246   /* Set when function must be output for some reason.  The primary
247      use of this flag is to mark functions needed to be output for
248      non-standard reason.  Functions that are externally visible
249      or reachable from functions needed to be output are marked
250      by specialized flags.  */
251   unsigned needed : 1;
252   /* Set when function has address taken.
253      In current implementation it imply needed flag. */
254   unsigned address_taken : 1;
255   /* Set when decl is an abstract function pointed to by the
256      ABSTRACT_DECL_ORIGIN of a reachable function.  */
257   unsigned abstract_and_needed : 1;
258   /* Set when function is reachable by call from other function
259      that is either reachable or needed.
260      This flag is computed at original cgraph construction and then
261      updated in cgraph_remove_unreachable_nodes.  Note that after
262      cgraph_remove_unreachable_nodes cgraph still can contain unreachable
263      nodes when they are needed for virtual clone instantiation.  */
264   unsigned reachable : 1;
265   /* Set when function is reachable by call from other LTRANS partition.  */
266   unsigned reachable_from_other_partition : 1;
267   /* Set once the function is lowered (i.e. its CFG is built).  */
268   unsigned lowered : 1;
269   /* Set once the function has been instantiated and its callee
270      lists created.  */
271   unsigned analyzed : 1;
272   /* Set when function is available in the other LTRANS partition.  
273      During WPA output it is used to mark nodes that are present in
274      multiple partitions.  */
275   unsigned in_other_partition : 1;
276   /* Set when function is scheduled to be processed by local passes.  */
277   unsigned process : 1;
278   /* Set for aliases once they got through assemble_alias.  */
279   unsigned alias : 1;
280   /* Set for nodes that was constructed and finalized by frontend.  */
281   unsigned finalized_by_frontend : 1;
282   /* Set for alias and thunk nodes, same_body points to the node they are alias
283      of and they are linked through the next/previous pointers.  */
284   unsigned same_body_alias : 1;
285   /* How commonly executed the node is.  Initialized during branch
286      probabilities pass.  */
287   ENUM_BITFIELD (node_frequency) frequency : 2;
288   /* True when function can only be called at startup (from static ctor).  */
289   unsigned only_called_at_startup : 1;
290   /* True when function can only be called at startup (from static dtor).  */
291   unsigned only_called_at_exit : 1;
292 };
293
294 typedef struct cgraph_node *cgraph_node_ptr;
295
296 DEF_VEC_P(cgraph_node_ptr);
297 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
298 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
299
300 /* A cgraph node set is a collection of cgraph nodes.  A cgraph node
301    can appear in multiple sets.  */
302 struct GTY(()) cgraph_node_set_def
303 {
304   htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
305   VEC(cgraph_node_ptr, gc) *nodes;
306 };
307
308 typedef struct varpool_node *varpool_node_ptr;
309
310 DEF_VEC_P(varpool_node_ptr);
311 DEF_VEC_ALLOC_P(varpool_node_ptr,heap);
312 DEF_VEC_ALLOC_P(varpool_node_ptr,gc);
313
314 /* A varpool node set is a collection of varpool nodes.  A varpool node
315    can appear in multiple sets.  */
316 struct GTY(()) varpool_node_set_def
317 {
318   htab_t GTY((param_is (struct varpool_node_set_element_def))) hashtab;
319   VEC(varpool_node_ptr, gc) *nodes;
320 };
321
322 typedef struct cgraph_node_set_def *cgraph_node_set;
323
324 DEF_VEC_P(cgraph_node_set);
325 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
326 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
327
328 typedef struct varpool_node_set_def *varpool_node_set;
329
330 DEF_VEC_P(varpool_node_set);
331 DEF_VEC_ALLOC_P(varpool_node_set,gc);
332 DEF_VEC_ALLOC_P(varpool_node_set,heap);
333
334 /* A cgraph node set element contains an index in the vector of nodes in
335    the set.  */
336 struct GTY(()) cgraph_node_set_element_def
337 {
338   struct cgraph_node *node;
339   HOST_WIDE_INT index;
340 };
341
342 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
343 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
344
345 /* Iterator structure for cgraph node sets.  */
346 typedef struct
347 {
348   cgraph_node_set set;
349   unsigned index;
350 } cgraph_node_set_iterator;
351
352 /* A varpool node set element contains an index in the vector of nodes in
353    the set.  */
354 struct GTY(()) varpool_node_set_element_def
355 {
356   struct varpool_node *node;
357   HOST_WIDE_INT index;
358 };
359
360 typedef struct varpool_node_set_element_def *varpool_node_set_element;
361 typedef const struct varpool_node_set_element_def *const_varpool_node_set_element;
362
363 /* Iterator structure for varpool node sets.  */
364 typedef struct
365 {
366   varpool_node_set set;
367   unsigned index;
368 } varpool_node_set_iterator;
369
370 #define DEFCIFCODE(code, string)        CIF_ ## code,
371 /* Reasons for inlining failures.  */
372 typedef enum {
373 #include "cif-code.def"
374   CIF_N_REASONS
375 } cgraph_inline_failed_t;
376
377 /* Structure containing additional information about an indirect call.  */
378
379 struct GTY(()) cgraph_indirect_call_info
380 {
381   /* Offset accumulated from ancestor jump functions of inlined call graph
382      edges.  */
383   HOST_WIDE_INT anc_offset;
384   /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set).  */
385   HOST_WIDE_INT otr_token;
386   /* Type of the object from OBJ_TYPE_REF_OBJECT. */
387   tree otr_type;
388   /* Index of the parameter that is called.  */
389   int param_index;
390   /* ECF flags determined from the caller.  */
391   int ecf_flags;
392
393   /* Set when the call is a virtual call with the parameter being the
394      associated object pointer rather than a simple direct call.  */
395   unsigned polymorphic : 1;
396 };
397
398 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
399   /* Expected number of executions: calculated in profile.c.  */
400   gcov_type count;
401   struct cgraph_node *caller;
402   struct cgraph_node *callee;
403   struct cgraph_edge *prev_caller;
404   struct cgraph_edge *next_caller;
405   struct cgraph_edge *prev_callee;
406   struct cgraph_edge *next_callee;
407   gimple call_stmt;
408   /* Additional information about an indirect call.  Not cleared when an edge
409      becomes direct.  */
410   struct cgraph_indirect_call_info *indirect_info;
411   PTR GTY ((skip (""))) aux;
412   /* When equal to CIF_OK, inline this call.  Otherwise, points to the
413      explanation why function was not inlined.  */
414   cgraph_inline_failed_t inline_failed;
415   /* The stmt_uid of call_stmt.  This is used by LTO to recover the call_stmt
416      when the function is serialized in.  */
417   unsigned int lto_stmt_uid;
418   /* Expected frequency of executions within the function.
419      When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
420      per function call.  The range is 0 to CGRAPH_FREQ_MAX.  */
421   int frequency;
422   /* Unique id of the edge.  */
423   int uid;
424   /* Depth of loop nest, 1 means no loop nest.  */
425   unsigned short int loop_nest;
426   /* Whether this edge was made direct by indirect inlining.  */
427   unsigned int indirect_inlining_edge : 1;
428   /* Whether this edge describes an indirect call with an undetermined
429      callee.  */
430   unsigned int indirect_unknown_callee : 1;
431   /* Whether this edge is still a dangling  */
432   /* True if the corresponding CALL stmt cannot be inlined.  */
433   unsigned int call_stmt_cannot_inline_p : 1;
434   /* Can this call throw externally?  */
435   unsigned int can_throw_external : 1;
436 };
437
438 #define CGRAPH_FREQ_BASE 1000
439 #define CGRAPH_FREQ_MAX 100000
440
441 typedef struct cgraph_edge *cgraph_edge_p;
442
443 DEF_VEC_P(cgraph_edge_p);
444 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
445
446 /* The varpool data structure.
447    Each static variable decl has assigned varpool_node.  */
448
449 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node {
450   tree decl;
451   /* Pointer to the next function in varpool_nodes.  */
452   struct varpool_node *next, *prev;
453   /* Pointer to the next function in varpool_nodes_queue.  */
454   struct varpool_node *next_needed, *prev_needed;
455   /* For normal nodes a pointer to the first extra name alias.  For alias
456      nodes a pointer to the normal node.  */
457   struct varpool_node *extra_name;
458   /* Circular list of nodes in the same comdat group if non-NULL.  */
459   struct varpool_node *same_comdat_group;
460   struct ipa_ref_list ref_list;
461   /* File stream where this node is being written to.  */
462   struct lto_file_decl_data * lto_file_data;
463   PTR GTY ((skip)) aux;
464   /* Ordering of all cgraph nodes.  */
465   int order;
466   enum ld_plugin_symbol_resolution resolution;
467
468   /* Set when function must be output - it is externally visible
469      or its address is taken.  */
470   unsigned needed : 1;
471   /* Needed variables might become dead by optimization.  This flag
472      forces the variable to be output even if it appears dead otherwise.  */
473   unsigned force_output : 1;
474   /* Set once the variable has been instantiated and its callee
475      lists created.  */
476   unsigned analyzed : 1;
477   /* Set once it has been finalized so we consider it to be output.  */
478   unsigned finalized : 1;
479   /* Set when variable is scheduled to be assembled.  */
480   unsigned output : 1;
481   /* Set when function is visible by other units.  */
482   unsigned externally_visible : 1;
483   /* Set for aliases once they got through assemble_alias.  Also set for
484      extra name aliases in varpool_extra_name_alias.  */
485   unsigned alias : 1;
486   /* Set when variable is used from other LTRANS partition.  */
487   unsigned used_from_other_partition : 1;
488   /* Set when variable is available in the other LTRANS partition.
489      During WPA output it is used to mark nodes that are present in
490      multiple partitions.  */
491   unsigned in_other_partition : 1;
492 };
493
494 /* Every top level asm statement is put into a cgraph_asm_node.  */
495
496 struct GTY(()) cgraph_asm_node {
497   /* Next asm node.  */
498   struct cgraph_asm_node *next;
499   /* String for this asm node.  */
500   tree asm_str;
501   /* Ordering of all cgraph nodes.  */
502   int order;
503 };
504
505 extern GTY(()) struct cgraph_node *cgraph_nodes;
506 extern GTY(()) int cgraph_n_nodes;
507 extern GTY(()) int cgraph_max_uid;
508 extern GTY(()) int cgraph_edge_max_uid;
509 extern GTY(()) int cgraph_max_pid;
510 extern bool cgraph_global_info_ready;
511 enum cgraph_state
512 {
513   /* Callgraph is being constructed.  It is safe to add new functions.  */
514   CGRAPH_STATE_CONSTRUCTION,
515   /* Callgraph is built and IPA passes are being run.  */
516   CGRAPH_STATE_IPA,
517   /* Callgraph is built and all functions are transformed to SSA form.  */
518   CGRAPH_STATE_IPA_SSA,
519   /* Functions are now ordered and being passed to RTL expanders.  */
520   CGRAPH_STATE_EXPANSION,
521   /* All cgraph expansion is done.  */
522   CGRAPH_STATE_FINISHED
523 };
524 extern enum cgraph_state cgraph_state;
525 extern bool cgraph_function_flags_ready;
526 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
527 extern GTY(()) struct cgraph_node *cgraph_new_nodes;
528
529 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
530 extern GTY(()) int cgraph_order;
531
532 /* In cgraph.c  */
533 void dump_cgraph (FILE *);
534 void debug_cgraph (void);
535 void dump_cgraph_node (FILE *, struct cgraph_node *);
536 void debug_cgraph_node (struct cgraph_node *);
537 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
538 void cgraph_remove_edge (struct cgraph_edge *);
539 void cgraph_remove_node (struct cgraph_node *);
540 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
541 void cgraph_release_function_body (struct cgraph_node *);
542 void cgraph_node_remove_callees (struct cgraph_node *node);
543 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
544                                         struct cgraph_node *,
545                                         gimple, gcov_type, int, int);
546 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple, int,
547                                                  gcov_type, int, int);
548 struct cgraph_node * cgraph_get_node (const_tree);
549 struct cgraph_node * cgraph_get_node_or_alias (const_tree);
550 struct cgraph_node * cgraph_node (tree);
551 struct cgraph_node * cgraph_same_body_alias (tree, tree);
552 struct cgraph_node * cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT,
553                                        HOST_WIDE_INT, tree, tree);
554 void cgraph_remove_same_body_alias (struct cgraph_node *);
555 struct cgraph_node *cgraph_node_for_asm (tree);
556 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
557 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
558 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
559 void cgraph_create_edge_including_clones (struct cgraph_node *,
560                                           struct cgraph_node *,
561                                           gimple, gimple, gcov_type, int, int,
562                                           cgraph_inline_failed_t);
563 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
564 struct cgraph_local_info *cgraph_local_info (tree);
565 struct cgraph_global_info *cgraph_global_info (tree);
566 struct cgraph_rtl_info *cgraph_rtl_info (tree);
567 const char * cgraph_node_name (struct cgraph_node *);
568 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
569                                         struct cgraph_node *, gimple,
570                                         unsigned, gcov_type, int, int, bool);
571 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int,
572                                         int, bool, VEC(cgraph_edge_p,heap) *);
573
574 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
575 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
576
577 struct cgraph_asm_node *cgraph_add_asm_node (tree);
578
579 bool cgraph_function_possibly_inlined_p (tree);
580 void cgraph_unnest_node (struct cgraph_node *);
581
582 enum availability cgraph_function_body_availability (struct cgraph_node *);
583 void cgraph_add_new_function (tree, bool);
584 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
585 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
586                                                   VEC(cgraph_edge_p,heap)*,
587                                                   VEC(ipa_replace_map_p,gc)* tree_map,
588                                                   bitmap args_to_skip,
589                                                   const char *clone_name);
590
591 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
592 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
593 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
594 tree clone_function_name (tree decl, const char *);
595 bool cgraph_node_cannot_return (struct cgraph_node *);
596 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
597 bool cgraph_will_be_removed_from_program_if_no_direct_calls
598   (struct cgraph_node *node);
599 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
600   (struct cgraph_node *node);
601 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution);
602 bool cgraph_used_from_object_file_p (struct cgraph_node *node);
603 bool varpool_used_from_object_file_p (struct varpool_node *node);
604
605 /* In cgraphunit.c  */
606 extern FILE *cgraph_dump_file;
607 void cgraph_finalize_function (tree, bool);
608 void cgraph_mark_if_needed (tree);
609 void cgraph_finalize_compilation_unit (void);
610 void cgraph_optimize (void);
611 void cgraph_mark_needed_node (struct cgraph_node *);
612 void cgraph_mark_address_taken_node (struct cgraph_node *);
613 void cgraph_mark_reachable_node (struct cgraph_node *);
614 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
615 bool cgraph_preserve_function_body_p (tree);
616 void verify_cgraph (void);
617 void verify_cgraph_node (struct cgraph_node *);
618 void cgraph_build_static_cdtor (char which, tree body, int priority);
619 void cgraph_reset_static_var_maps (void);
620 void init_cgraph (void);
621 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
622                                                 VEC(cgraph_edge_p,heap)*,
623                                                 VEC(ipa_replace_map_p,gc)*,
624                                                 bitmap, bitmap, basic_block,
625                                                 const char *);
626 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap,
627                                bitmap, basic_block);
628 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
629 void record_references_in_initializer (tree, bool);
630 bool cgraph_process_new_functions (void);
631
632 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
633
634 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
635 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
636 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
637                                   void *);
638 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
639                                   void *);
640 struct cgraph_edge_hook_list;
641 struct cgraph_node_hook_list;
642 struct cgraph_2edge_hook_list;
643 struct cgraph_2node_hook_list;
644 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
645 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
646 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
647                                                             void *);
648 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
649 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
650                                                                   void *);
651 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
652 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
653 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
654 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
655 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
656 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
657 void cgraph_materialize_all_clones (void);
658 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
659 bool cgraph_propagate_frequency (struct cgraph_node *node);
660 /* In cgraphbuild.c  */
661 unsigned int rebuild_cgraph_edges (void);
662 void cgraph_rebuild_references (void);
663 void reset_inline_failed (struct cgraph_node *);
664 int compute_call_stmt_bb_frequency (tree, basic_block bb);
665
666 /* In ipa.c  */
667 bool cgraph_remove_unreachable_nodes (bool, FILE *);
668 int cgraph_postorder (struct cgraph_node **);
669 cgraph_node_set cgraph_node_set_new (void);
670 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
671                                                struct cgraph_node *);
672 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
673 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
674 void dump_cgraph_node_set (FILE *, cgraph_node_set);
675 void debug_cgraph_node_set (cgraph_node_set);
676
677 varpool_node_set varpool_node_set_new (void);
678 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
679                                                struct varpool_node *);
680 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
681 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
682 void dump_varpool_node_set (FILE *, varpool_node_set);
683 void debug_varpool_node_set (varpool_node_set);
684 void ipa_discover_readonly_nonaddressable_vars (void);
685 bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *);
686
687 /* In predict.c  */
688 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
689
690 /* In varpool.c  */
691 extern GTY(()) struct varpool_node *varpool_nodes_queue;
692 extern GTY(()) struct varpool_node *varpool_nodes;
693
694 struct varpool_node *varpool_node (tree);
695 struct varpool_node *varpool_node_for_asm (tree asmname);
696 void varpool_mark_needed_node (struct varpool_node *);
697 void debug_varpool (void);
698 void dump_varpool (FILE *);
699 void dump_varpool_node (FILE *, struct varpool_node *);
700
701 void varpool_finalize_decl (tree);
702 bool decide_is_variable_needed (struct varpool_node *, tree);
703 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
704 void cgraph_make_decl_local (tree);
705 void cgraph_make_node_local (struct cgraph_node *);
706 bool cgraph_node_can_be_local_p (struct cgraph_node *);
707
708
709 struct varpool_node * varpool_get_node (const_tree decl);
710 void varpool_remove_node (struct varpool_node *node);
711 bool varpool_assemble_pending_decls (void);
712 bool varpool_assemble_decl (struct varpool_node *node);
713 bool varpool_analyze_pending_decls (void);
714 void varpool_remove_unreferenced_decls (void);
715 void varpool_empty_needed_queue (void);
716 struct varpool_node * varpool_extra_name_alias (tree, tree);
717 const char * varpool_node_name (struct varpool_node *node);
718 void varpool_reset_queue (void);
719 bool const_value_known_p (tree);
720
721 /* Walk all reachable static variables.  */
722 #define FOR_EACH_STATIC_VARIABLE(node) \
723    for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
724
725 /* Return first reachable static variable with initializer.  */
726 static inline struct varpool_node *
727 varpool_first_static_initializer (void)
728 {
729   struct varpool_node *node;
730   for (node = varpool_nodes_queue; node; node = node->next_needed)
731     {
732       gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
733       if (DECL_INITIAL (node->decl))
734         return node;
735     }
736   return NULL;
737 }
738
739 /* Return next reachable static variable with initializer after NODE.  */
740 static inline struct varpool_node *
741 varpool_next_static_initializer (struct varpool_node *node)
742 {
743   for (node = node->next_needed; node; node = node->next_needed)
744     {
745       gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
746       if (DECL_INITIAL (node->decl))
747         return node;
748     }
749   return NULL;
750 }
751
752 /* Walk all static variables with initializer set.  */
753 #define FOR_EACH_STATIC_INITIALIZER(node) \
754    for ((node) = varpool_first_static_initializer (); (node); \
755         (node) = varpool_next_static_initializer (node))
756
757 /* In ipa-inline.c  */
758 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
759 unsigned int compute_inline_parameters (struct cgraph_node *);
760
761
762 /* Create a new static variable of type TYPE.  */
763 tree add_new_static_var (tree type);
764
765 /* Return true if iterator CSI points to nothing.  */
766 static inline bool
767 csi_end_p (cgraph_node_set_iterator csi)
768 {
769   return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
770 }
771
772 /* Advance iterator CSI.  */
773 static inline void
774 csi_next (cgraph_node_set_iterator *csi)
775 {
776   csi->index++;
777 }
778
779 /* Return the node pointed to by CSI.  */
780 static inline struct cgraph_node *
781 csi_node (cgraph_node_set_iterator csi)
782 {
783   return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
784 }
785
786 /* Return an iterator to the first node in SET.  */
787 static inline cgraph_node_set_iterator
788 csi_start (cgraph_node_set set)
789 {
790   cgraph_node_set_iterator csi;
791
792   csi.set = set;
793   csi.index = 0;
794   return csi;
795 }
796
797 /* Return true if SET contains NODE.  */
798 static inline bool
799 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
800 {
801   cgraph_node_set_iterator csi;
802   csi = cgraph_node_set_find (set, node);
803   return !csi_end_p (csi);
804 }
805
806 /* Return number of nodes in SET.  */
807 static inline size_t
808 cgraph_node_set_size (cgraph_node_set set)
809 {
810   return htab_elements (set->hashtab);
811 }
812
813 /* Return true if iterator VSI points to nothing.  */
814 static inline bool
815 vsi_end_p (varpool_node_set_iterator vsi)
816 {
817   return vsi.index >= VEC_length (varpool_node_ptr, vsi.set->nodes);
818 }
819
820 /* Advance iterator VSI.  */
821 static inline void
822 vsi_next (varpool_node_set_iterator *vsi)
823 {
824   vsi->index++;
825 }
826
827 /* Return the node pointed to by VSI.  */
828 static inline struct varpool_node *
829 vsi_node (varpool_node_set_iterator vsi)
830 {
831   return VEC_index (varpool_node_ptr, vsi.set->nodes, vsi.index);
832 }
833
834 /* Return an iterator to the first node in SET.  */
835 static inline varpool_node_set_iterator
836 vsi_start (varpool_node_set set)
837 {
838   varpool_node_set_iterator vsi;
839
840   vsi.set = set;
841   vsi.index = 0;
842   return vsi;
843 }
844
845 /* Return true if SET contains NODE.  */
846 static inline bool
847 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
848 {
849   varpool_node_set_iterator vsi;
850   vsi = varpool_node_set_find (set, node);
851   return !vsi_end_p (vsi);
852 }
853
854 /* Return number of nodes in SET.  */
855 static inline size_t
856 varpool_node_set_size (varpool_node_set set)
857 {
858   return htab_elements (set->hashtab);
859 }
860
861 /* Uniquize all constants that appear in memory.
862    Each constant in memory thus far output is recorded
863    in `const_desc_table'.  */
864
865 struct GTY(()) constant_descriptor_tree {
866   /* A MEM for the constant.  */
867   rtx rtl;
868
869   /* The value of the constant.  */
870   tree value;
871
872   /* Hash of value.  Computing the hash from value each time
873      hashfn is called can't work properly, as that means recursive
874      use of the hash table during hash table expansion.  */
875   hashval_t hash;
876 };
877
878 /* Return true if set is nonempty.  */
879 static inline bool
880 cgraph_node_set_nonempty_p (cgraph_node_set set)
881 {
882   return !VEC_empty (cgraph_node_ptr, set->nodes);
883 }
884
885 /* Return true if set is nonempty.  */
886 static inline bool
887 varpool_node_set_nonempty_p (varpool_node_set set)
888 {
889   return !VEC_empty (varpool_node_ptr, set->nodes);
890 }
891
892 /* Return true when function NODE is only called directly.
893    i.e. it is not externally visible, address was not taken and
894    it is not used in any other non-standard way.  */
895
896 static inline bool
897 cgraph_only_called_directly_p (struct cgraph_node *node)
898 {
899   gcc_assert (!node->global.inlined_to);
900   return (!node->needed && !node->address_taken
901           && !node->reachable_from_other_partition
902           && !DECL_STATIC_CONSTRUCTOR (node->decl)
903           && !DECL_STATIC_DESTRUCTOR (node->decl)
904           && !node->local.externally_visible);
905 }
906
907 /* Return true when function NODE can be removed from callgraph
908    if all direct calls are eliminated.  */
909
910 static inline bool
911 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
912 {
913   /* Extern inlines can always go, we will use the external definition.  */
914   if (DECL_EXTERNAL (node->decl))
915     return true;
916   return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
917 }
918
919 /* Return true when function NODE can be removed from callgraph
920    if all direct calls are eliminated.  */
921
922 static inline bool
923 varpool_can_remove_if_no_refs (struct varpool_node *node)
924 {
925   return (!node->force_output && !node->used_from_other_partition
926           && (flag_toplevel_reorder || DECL_COMDAT (node->decl)
927               || DECL_ARTIFICIAL (node->decl))
928           && (DECL_COMDAT (node->decl) || !node->externally_visible));
929 }
930
931 /* Return true when all references to VNODE must be visible in ipa_ref_list.
932    i.e. if the variable is not externally visible or not used in some magic
933    way (asm statement or such).
934    The magic uses are all sumarized in force_output flag.  */
935
936 static inline bool
937 varpool_all_refs_explicit_p (struct varpool_node *vnode)
938 {
939   return (!vnode->externally_visible
940           && !vnode->used_from_other_partition
941           && !vnode->force_output);
942 }
943
944 /* Constant pool accessor function.  */
945 htab_t constant_pool_htab (void);
946
947 /* FIXME: inappropriate dependency of cgraph on IPA.  */
948 #include "ipa-ref-inline.h"
949
950 #endif  /* GCC_CGRAPH_H  */