OSDN Git Service

Daily bump.
[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 * GTY ((skip)) 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 /* The cgraph data structure.
179    Each function decl has assigned cgraph_node listing callees and callers.  */
180
181 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
182   tree decl;
183   struct cgraph_edge *callees;
184   struct cgraph_edge *callers;
185   struct cgraph_node *next;
186   struct cgraph_node *previous;
187   /* For nested functions points to function the node is nested in.  */
188   struct cgraph_node *origin;
189   /* Points to first nested function, if any.  */
190   struct cgraph_node *nested;
191   /* Pointer to the next function with same origin, if any.  */
192   struct cgraph_node *next_nested;
193   /* Pointer to the next function in cgraph_nodes_queue.  */
194   struct cgraph_node *next_needed;
195   /* Pointer to the next clone.  */
196   struct cgraph_node *next_sibling_clone;
197   struct cgraph_node *prev_sibling_clone;
198   struct cgraph_node *clones;
199   struct cgraph_node *clone_of;
200   /* For normal nodes pointer to the list of alias and thunk nodes,
201      in alias/thunk nodes pointer to the normal node.  */
202   struct cgraph_node *same_body;
203   /* Circular list of nodes in the same comdat group if non-NULL.  */
204   struct cgraph_node *same_comdat_group;
205   /* For functions with many calls sites it holds map from call expression
206      to the edge to speed up cgraph_edge function.  */
207   htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
208
209   PTR GTY ((skip)) aux;
210
211   /* Interprocedural passes scheduled to have their transform functions
212      applied next time we execute local pass on them.  We maintain it
213      per-function in order to allow IPA passes to introduce new functions.  */
214   VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
215
216   struct cgraph_local_info local;
217   struct cgraph_global_info global;
218   struct cgraph_rtl_info rtl;
219   struct cgraph_clone_info clone;
220   struct cgraph_thunk_info thunk;
221
222   /* Expected number of executions: calculated in profile.c.  */
223   gcov_type count;
224   /* Unique id of the node.  */
225   int uid;
226   /* Ordering of all cgraph nodes.  */
227   int order;
228
229   /* unique id for profiling. pid is not suitable because of different
230      number of cfg nodes with -fprofile-generate and -fprofile-use */
231   int pid;
232
233   /* Set when function must be output for some reason.  The primary
234      use of this flag is to mark functions needed to be output for
235      non-standard reason.  Functions that are externally visible
236      or reachable from functions needed to be output are marked
237      by specialized flags.  */
238   unsigned needed : 1;
239   /* Set when function has address taken.
240      In current implementation it imply needed flag. */
241   unsigned address_taken : 1;
242   /* Set when decl is an abstract function pointed to by the
243      ABSTRACT_DECL_ORIGIN of a reachable function.  */
244   unsigned abstract_and_needed : 1;
245   /* Set when function is reachable by call from other function
246      that is either reachable or needed.
247      This flag is computed at original cgraph construction and then
248      updated in cgraph_remove_unreachable_nodes.  Note that after
249      cgraph_remove_unreachable_nodes cgraph still can contain unreachable
250      nodes when they are needed for virtual clone instantiation.  */
251   unsigned reachable : 1;
252   /* Set when function is reachable by call from other LTRANS partition.  */
253   unsigned reachable_from_other_partition : 1;
254   /* Set once the function is lowered (i.e. its CFG is built).  */
255   unsigned lowered : 1;
256   /* Set once the function has been instantiated and its callee
257      lists created.  */
258   unsigned analyzed : 1;
259   /* Set when function is available in the other LTO partition.  */
260   unsigned in_other_partition : 1;
261   /* Set when function is scheduled to be processed by local passes.  */
262   unsigned process : 1;
263   /* Set for aliases once they got through assemble_alias.  */
264   unsigned alias : 1;
265   /* Set for nodes that was constructed and finalized by frontend.  */
266   unsigned finalized_by_frontend : 1;
267   /* Set for alias and thunk nodes, same_body points to the node they are alias
268      of and they are linked through the next/previous pointers.  */
269   unsigned same_body_alias : 1;
270 };
271
272 typedef struct cgraph_node *cgraph_node_ptr;
273
274 DEF_VEC_P(cgraph_node_ptr);
275 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
276 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
277
278 /* A cgraph node set is a collection of cgraph nodes.  A cgraph node
279    can appear in multiple sets.  */
280 struct GTY(()) cgraph_node_set_def
281 {
282   htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
283   VEC(cgraph_node_ptr, gc) *nodes;
284   PTR GTY ((skip)) aux;
285 };
286
287 typedef struct cgraph_node_set_def *cgraph_node_set;
288
289 DEF_VEC_P(cgraph_node_set);
290 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
291 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
292
293 /* A cgraph node set element contains an index in the vector of nodes in
294    the set.  */
295 struct GTY(()) cgraph_node_set_element_def
296 {
297   struct cgraph_node *node;
298   HOST_WIDE_INT index;
299 };
300
301 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
302 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
303
304 /* Iterator structure for cgraph node sets.  */
305 typedef struct
306 {
307   cgraph_node_set set;
308   unsigned index;
309 } cgraph_node_set_iterator;
310
311 #define DEFCIFCODE(code, string)        CIF_ ## code,
312 /* Reasons for inlining failures.  */
313 typedef enum {
314 #include "cif-code.def"
315   CIF_N_REASONS
316 } cgraph_inline_failed_t;
317
318 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
319   /* Expected number of executions: calculated in profile.c.  */
320   gcov_type count;
321   struct cgraph_node *caller;
322   struct cgraph_node *callee;
323   struct cgraph_edge *prev_caller;
324   struct cgraph_edge *next_caller;
325   struct cgraph_edge *prev_callee;
326   struct cgraph_edge *next_callee;
327   gimple call_stmt;
328   PTR GTY ((skip (""))) aux;
329   /* When equal to CIF_OK, inline this call.  Otherwise, points to the
330      explanation why function was not inlined.  */
331   cgraph_inline_failed_t inline_failed;
332   /* The stmt_uid of call_stmt.  This is used by LTO to recover the call_stmt
333      when the function is serialized in.  */
334   unsigned int lto_stmt_uid;
335   /* Expected frequency of executions within the function.
336      When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
337      per function call.  The range is 0 to CGRAPH_FREQ_MAX.  */
338   int frequency;
339   /* Unique id of the edge.  */
340   int uid;
341   /* Depth of loop nest, 1 means no loop nest.  */
342   unsigned short int loop_nest;
343   /* Whether this edge describes a call that was originally indirect.  */
344   unsigned int indirect_call : 1;
345   /* True if the corresponding CALL stmt cannot be inlined.  */
346   unsigned int call_stmt_cannot_inline_p : 1;
347   /* Can this call throw externally?  */
348   unsigned int can_throw_external : 1;
349 };
350
351 #define CGRAPH_FREQ_BASE 1000
352 #define CGRAPH_FREQ_MAX 100000
353
354 typedef struct cgraph_edge *cgraph_edge_p;
355
356 DEF_VEC_P(cgraph_edge_p);
357 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
358
359 /* The varpool data structure.
360    Each static variable decl has assigned varpool_node.  */
361
362 struct GTY((chain_next ("%h.next"))) varpool_node {
363   tree decl;
364   /* Pointer to the next function in varpool_nodes.  */
365   struct varpool_node *next;
366   /* Pointer to the next function in varpool_nodes_queue.  */
367   struct varpool_node *next_needed;
368   /* For normal nodes a pointer to the first extra name alias.  For alias
369      nodes a pointer to the normal node.  */
370   struct varpool_node *extra_name;
371   /* Ordering of all cgraph nodes.  */
372   int order;
373
374   /* Set when function must be output - it is externally visible
375      or its address is taken.  */
376   unsigned needed : 1;
377   /* Needed variables might become dead by optimization.  This flag
378      forces the variable to be output even if it appears dead otherwise.  */
379   unsigned force_output : 1;
380   /* Set once the variable has been instantiated and its callee
381      lists created.  */
382   unsigned analyzed : 1;
383   /* Set once it has been finalized so we consider it to be output.  */
384   unsigned finalized : 1;
385   /* Set when variable is scheduled to be assembled.  */
386   unsigned output : 1;
387   /* Set when function is visible by other units.  */
388   unsigned externally_visible : 1;
389   /* Set for aliases once they got through assemble_alias.  Also set for
390      extra name aliases in varpool_extra_name_alias.  */
391   unsigned alias : 1;
392 };
393
394 /* Every top level asm statement is put into a cgraph_asm_node.  */
395
396 struct GTY(()) cgraph_asm_node {
397   /* Next asm node.  */
398   struct cgraph_asm_node *next;
399   /* String for this asm node.  */
400   tree asm_str;
401   /* Ordering of all cgraph nodes.  */
402   int order;
403 };
404
405 extern GTY(()) struct cgraph_node *cgraph_nodes;
406 extern GTY(()) int cgraph_n_nodes;
407 extern GTY(()) int cgraph_max_uid;
408 extern GTY(()) int cgraph_edge_max_uid;
409 extern GTY(()) int cgraph_max_pid;
410 extern bool cgraph_global_info_ready;
411 enum cgraph_state
412 {
413   /* Callgraph is being constructed.  It is safe to add new functions.  */
414   CGRAPH_STATE_CONSTRUCTION,
415   /* Callgraph is built and IPA passes are being run.  */
416   CGRAPH_STATE_IPA,
417   /* Callgraph is built and all functions are transformed to SSA form.  */
418   CGRAPH_STATE_IPA_SSA,
419   /* Functions are now ordered and being passed to RTL expanders.  */
420   CGRAPH_STATE_EXPANSION,
421   /* All cgraph expansion is done.  */
422   CGRAPH_STATE_FINISHED
423 };
424 extern enum cgraph_state cgraph_state;
425 extern bool cgraph_function_flags_ready;
426 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
427 extern GTY(()) struct cgraph_node *cgraph_new_nodes;
428
429 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
430 extern GTY(()) int cgraph_order;
431
432 /* In cgraph.c  */
433 void dump_cgraph (FILE *);
434 void debug_cgraph (void);
435 void dump_cgraph_node (FILE *, struct cgraph_node *);
436 void debug_cgraph_node (struct cgraph_node *);
437 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
438 void cgraph_remove_edge (struct cgraph_edge *);
439 void cgraph_remove_node (struct cgraph_node *);
440 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
441 void cgraph_release_function_body (struct cgraph_node *);
442 void cgraph_node_remove_callees (struct cgraph_node *node);
443 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
444                                         struct cgraph_node *,
445                                         gimple, gcov_type, int, int);
446
447 struct cgraph_node * cgraph_get_node (tree);
448 struct cgraph_node *cgraph_node (tree);
449 bool cgraph_same_body_alias (tree, tree);
450 void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree);
451 void cgraph_remove_same_body_alias (struct cgraph_node *);
452 struct cgraph_node *cgraph_node_for_asm (tree);
453 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
454 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
455 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
456 void cgraph_create_edge_including_clones (struct cgraph_node *,
457                                           struct cgraph_node *,
458                                           gimple, gimple, gcov_type, int, int,
459                                           cgraph_inline_failed_t);
460 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
461 struct cgraph_local_info *cgraph_local_info (tree);
462 struct cgraph_global_info *cgraph_global_info (tree);
463 struct cgraph_rtl_info *cgraph_rtl_info (tree);
464 const char * cgraph_node_name (struct cgraph_node *);
465 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
466                                         struct cgraph_node *, gimple,
467                                         unsigned, gcov_type, int, int, bool);
468 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int,
469                                         int, bool, VEC(cgraph_edge_p,heap) *);
470
471 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
472
473 struct cgraph_asm_node *cgraph_add_asm_node (tree);
474
475 bool cgraph_function_possibly_inlined_p (tree);
476 void cgraph_unnest_node (struct cgraph_node *);
477
478 enum availability cgraph_function_body_availability (struct cgraph_node *);
479 void cgraph_add_new_function (tree, bool);
480 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
481 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
482                                                   VEC(cgraph_edge_p,heap)*,
483                                                   VEC(ipa_replace_map_p,gc)* tree_map,
484                                                   bitmap args_to_skip);
485
486 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
487 void cgraph_set_readonly_flag (struct cgraph_node *, bool);
488 void cgraph_set_pure_flag (struct cgraph_node *, bool);
489 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool);
490
491 /* In cgraphunit.c  */
492 void cgraph_finalize_function (tree, bool);
493 void cgraph_mark_if_needed (tree);
494 void cgraph_finalize_compilation_unit (void);
495 void cgraph_optimize (void);
496 void cgraph_mark_needed_node (struct cgraph_node *);
497 void cgraph_mark_address_taken_node (struct cgraph_node *);
498 void cgraph_mark_reachable_node (struct cgraph_node *);
499 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
500 bool cgraph_preserve_function_body_p (tree);
501 void verify_cgraph (void);
502 void verify_cgraph_node (struct cgraph_node *);
503 void cgraph_build_static_cdtor (char which, tree body, int priority);
504 void cgraph_reset_static_var_maps (void);
505 void init_cgraph (void);
506 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
507                                                 VEC(cgraph_edge_p,heap)*,
508                                                 VEC(ipa_replace_map_p,gc)*,
509                                                 bitmap);
510 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
511 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
512 void record_references_in_initializer (tree, bool);
513 bool cgraph_process_new_functions (void);
514
515 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
516
517 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
518 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
519 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
520                                   void *);
521 typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
522                                   void *);
523 struct cgraph_edge_hook_list;
524 struct cgraph_node_hook_list;
525 struct cgraph_2edge_hook_list;
526 struct cgraph_2node_hook_list;
527 struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
528 void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
529 struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
530                                                             void *);
531 void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
532 struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
533                                                                   void *);
534 void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
535 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
536 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
537 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
538 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
539 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
540 void cgraph_materialize_all_clones (void);
541 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
542 /* In cgraphbuild.c  */
543 unsigned int rebuild_cgraph_edges (void);
544 void reset_inline_failed (struct cgraph_node *);
545 int compute_call_stmt_bb_frequency (tree, basic_block bb);
546
547 /* In ipa.c  */
548 bool cgraph_remove_unreachable_nodes (bool, FILE *);
549 int cgraph_postorder (struct cgraph_node **);
550 cgraph_node_set cgraph_node_set_new (void);
551 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
552                                                struct cgraph_node *);
553 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
554 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
555 void dump_cgraph_node_set (FILE *, cgraph_node_set);
556 void debug_cgraph_node_set (cgraph_node_set);
557
558
559 /* In predict.c  */
560 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
561
562 /* In varpool.c  */
563 extern GTY(()) struct varpool_node *varpool_nodes_queue;
564 extern GTY(()) struct varpool_node *varpool_nodes;
565
566 struct varpool_node *varpool_node (tree);
567 struct varpool_node *varpool_node_for_asm (tree asmname);
568 void varpool_mark_needed_node (struct varpool_node *);
569 void debug_varpool (void);
570 void dump_varpool (FILE *);
571 void dump_varpool_node (FILE *, struct varpool_node *);
572
573 void varpool_finalize_decl (tree);
574 bool decide_is_variable_needed (struct varpool_node *, tree);
575 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
576 void cgraph_make_decl_local (tree);
577 void cgraph_make_node_local (struct cgraph_node *);
578 bool cgraph_node_can_be_local_p (struct cgraph_node *);
579
580 bool varpool_assemble_pending_decls (void);
581 bool varpool_assemble_decl (struct varpool_node *node);
582 bool varpool_analyze_pending_decls (void);
583 void varpool_remove_unreferenced_decls (void);
584 void varpool_empty_needed_queue (void);
585 bool varpool_extra_name_alias (tree, tree);
586 const char * varpool_node_name (struct varpool_node *node);
587
588 /* Walk all reachable static variables.  */
589 #define FOR_EACH_STATIC_VARIABLE(node) \
590    for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
591
592 /* Return first reachable static variable with initializer.  */
593 static inline struct varpool_node *
594 varpool_first_static_initializer (void)
595 {
596   struct varpool_node *node;
597   for (node = varpool_nodes_queue; node; node = node->next_needed)
598     {
599       gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
600       if (DECL_INITIAL (node->decl))
601         return node;
602     }
603   return NULL;
604 }
605
606 /* Return next reachable static variable with initializer after NODE.  */
607 static inline struct varpool_node *
608 varpool_next_static_initializer (struct varpool_node *node)
609 {
610   for (node = node->next_needed; node; node = node->next_needed)
611     {
612       gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
613       if (DECL_INITIAL (node->decl))
614         return node;
615     }
616   return NULL;
617 }
618
619 /* Walk all static variables with initializer set.  */
620 #define FOR_EACH_STATIC_INITIALIZER(node) \
621    for ((node) = varpool_first_static_initializer (); (node); \
622         (node) = varpool_next_static_initializer (node))
623
624 /* In ipa-inline.c  */
625 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
626 unsigned int compute_inline_parameters (struct cgraph_node *);
627
628
629 /* Create a new static variable of type TYPE.  */
630 tree add_new_static_var (tree type);
631
632 /* lto-cgraph.c */
633
634 enum LTO_cgraph_tags
635 {
636   /* Must leave 0 for the stopper.  */
637   LTO_cgraph_avail_node = 1,
638   LTO_cgraph_overwritable_node,
639   LTO_cgraph_unavail_node,
640   LTO_cgraph_edge,
641   LTO_cgraph_last_tag
642 };
643
644 extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag];
645
646 #define LCC_NOT_FOUND   (-1)
647
648
649 /* Return true if iterator CSI points to nothing.  */
650 static inline bool
651 csi_end_p (cgraph_node_set_iterator csi)
652 {
653   return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
654 }
655
656 /* Advance iterator CSI.  */
657 static inline void
658 csi_next (cgraph_node_set_iterator *csi)
659 {
660   csi->index++;
661 }
662
663 /* Return the node pointed to by CSI.  */
664 static inline struct cgraph_node *
665 csi_node (cgraph_node_set_iterator csi)
666 {
667   return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
668 }
669
670 /* Return an iterator to the first node in SET.  */
671 static inline cgraph_node_set_iterator
672 csi_start (cgraph_node_set set)
673 {
674   cgraph_node_set_iterator csi;
675
676   csi.set = set;
677   csi.index = 0;
678   return csi;
679 }
680
681 /* Return true if SET contains NODE.  */
682 static inline bool
683 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
684 {
685   cgraph_node_set_iterator csi;
686   csi = cgraph_node_set_find (set, node);
687   return !csi_end_p (csi);
688 }
689
690 /* Return number of nodes in SET.  */
691 static inline size_t
692 cgraph_node_set_size (cgraph_node_set set)
693 {
694   return htab_elements (set->hashtab);
695 }
696
697 /* Uniquize all constants that appear in memory.
698    Each constant in memory thus far output is recorded
699    in `const_desc_table'.  */
700
701 struct GTY(()) constant_descriptor_tree {
702   /* A MEM for the constant.  */
703   rtx rtl;
704
705   /* The value of the constant.  */
706   tree value;
707
708   /* Hash of value.  Computing the hash from value each time
709      hashfn is called can't work properly, as that means recursive
710      use of the hash table during hash table expansion.  */
711   hashval_t hash;
712 };
713
714 /* Return true when function NODE is only called directly.
715    i.e. it is not externally visible, address was not taken and
716    it is not used in any other non-standard way.  */
717
718 static inline bool
719 cgraph_only_called_directly_p (struct cgraph_node *node)
720 {
721   return !node->needed && !node->local.externally_visible;
722 }
723
724 /* Return true when function NODE can be removed from callgraph
725    if all direct calls are eliminated.  */
726
727 static inline bool
728 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
729 {
730   return (!node->needed && !node->reachable_from_other_partition
731           && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
732 }
733
734 /* Constant pool accessor function.  */
735 htab_t constant_pool_htab (void);
736
737 #endif  /* GCC_CGRAPH_H  */