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