OSDN Git Service

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