OSDN Git Service

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