OSDN Git Service

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