]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cgraph.h
s-osprim-mingw.adb (Get_Base_Time): Make sure that the base time is taken at a clock...
[thirdparty/gcc.git] / gcc / cgraph.h
CommitLineData
1c4a429a 1/* Callgraph handling code.
24b97832 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
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
6674a6ce 24#include "tree.h"
e42922b1 25#include "basic-block.h"
1c4a429a 26
6b02a499
JH
27enum 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
d7f09764
DN
49/* This is the information that is put into the cgraph local structure
50 to recover a function. */
51struct lto_file_decl_data;
52
8a4a83ed
JH
53extern const char * const cgraph_availability_names[];
54
24b97832
ILT
55/* Function inlining information. */
56
57struct GTY(()) inline_summary
58{
59 /* Estimated stack frame consumption by the function. */
60 HOST_WIDE_INT estimated_self_stack_size;
61
85057983
JH
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;
24b97832
ILT
70};
71
6744a6ab
JH
72/* Information about thunk, used only for same body aliases. */
73
74struct 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
dafc5b82 85/* Information about the function collected locally.
25c84396 86 Available after function is analyzed. */
dafc5b82 87
d1b38208 88struct GTY(()) cgraph_local_info {
d7f09764
DN
89 /* File stream where this node is being written to. */
90 struct lto_file_decl_data * GTY ((skip)) lto_file_data;
91
24b97832 92 struct inline_summary inline_summary;
6674a6ce 93
e0bb17a8 94 /* Set when function function is visible in current compilation unit only
e2209b03 95 and its address is never taken. */
b4e19405 96 unsigned local : 1;
6674a6ce 97
e7d6beb0 98 /* Set when function is visible by other units. */
b4e19405 99 unsigned externally_visible : 1;
e7d6beb0 100
f6981e16 101 /* Set once it has been finalized so we consider it to be output. */
b4e19405 102 unsigned finalized : 1;
b58b1157 103
b3c3af2f 104 /* False when there something makes inlining impossible (such as va_arg). */
b4e19405 105 unsigned inlinable : 1;
6674a6ce 106
e2209b03 107 /* True when function should be inlined independently on its size. */
b4e19405 108 unsigned disregard_inline_limits : 1;
6674a6ce 109
95c755e9
JH
110 /* True when the function has been originally extern inline, but it is
111 redefined now. */
b4e19405 112 unsigned redefined_extern_inline : 1;
6674a6ce
KZ
113
114 /* True if statics_read_for_function and
115 statics_written_for_function contain valid data. */
b4e19405 116 unsigned for_functions_valid : 1;
8634c649
JJ
117
118 /* True if the function is going to be emitted in some other translation
119 unit, referenced from vtable. */
b4e19405 120 unsigned vtable_method : 1;
dafc5b82
JH
121};
122
123/* Information about the function that needs to be computed globally
726a989a 124 once compilation is finished. Available only with -funit-at-a-time. */
dafc5b82 125
d1b38208 126struct GTY(()) cgraph_global_info {
ff28a94d
JH
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
726a989a
RB
132 /* For inline clones this points to the function they will be
133 inlined into. */
18c6ada9
JH
134 struct cgraph_node *inlined_to;
135
b58b1157 136 /* Estimated size of the function after inlining. */
85057983
JH
137 int time;
138 int size;
b58b1157 139
670cd5c5
JH
140 /* Estimated growth after inlining. INT_MIN if not computed. */
141 int estimated_growth;
142
18c6ada9 143 /* Set iff the function has been inlined at least once. */
1bb17c21 144 bool inlined;
dafc5b82
JH
145};
146
b255a036
JH
147/* Information about the function that is propagated by the RTL backend.
148 Available only for functions that has been already assembled. */
149
d1b38208 150struct GTY(()) cgraph_rtl_info {
17b29c0a 151 unsigned int preferred_incoming_stack_boundary;
b255a036
JH
152};
153
9187e02d
JH
154/* Represent which DECL tree (or reference to such tree)
155 will be replaced by another tree while versioning. */
156struct 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};
167typedef struct ipa_replace_map *ipa_replace_map_p;
168DEF_VEC_P(ipa_replace_map_p);
169DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
170
171struct GTY(()) cgraph_clone_info
172{
173 VEC(ipa_replace_map_p,gc)* tree_map;
174 bitmap args_to_skip;
08ad1d6d 175 bitmap combined_args_to_skip;
9187e02d
JH
176};
177
ba228239 178/* The cgraph data structure.
e0bb17a8 179 Each function decl has assigned cgraph_node listing callees and callers. */
1c4a429a 180
d1b38208 181struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
1c4a429a
JH
182 tree decl;
183 struct cgraph_edge *callees;
184 struct cgraph_edge *callers;
ed2df68b
JH
185 struct cgraph_node *next;
186 struct cgraph_node *previous;
1c4a429a
JH
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;
8bd87c4e
JH
193 /* Pointer to the next function in cgraph_nodes_queue. */
194 struct cgraph_node *next_needed;
18c6ada9 195 /* Pointer to the next clone. */
9187e02d
JH
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;
6744a6ab
JH
200 /* For normal nodes pointer to the list of alias and thunk nodes,
201 in alias/thunk nodes pointer to the normal node. */
b2583345 202 struct cgraph_node *same_body;
70d539ce
JH
203 /* For functions with many calls sites it holds map from call expression
204 to the edge to speed up cgraph_edge function. */
205 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
c22cacf3 206
1431042e 207 PTR GTY ((skip)) aux;
1c4a429a 208
0e3776db
JH
209 /* Interprocedural passes scheduled to have their transform functions
210 applied next time we execute local pass on them. We maintain it
211 per-function in order to allow IPA passes to introduce new functions. */
212 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
213
95c755e9
JH
214 struct cgraph_local_info local;
215 struct cgraph_global_info global;
216 struct cgraph_rtl_info rtl;
9187e02d 217 struct cgraph_clone_info clone;
6744a6ab 218 struct cgraph_thunk_info thunk;
c22cacf3 219
e42922b1
JH
220 /* Expected number of executions: calculated in profile.c. */
221 gcov_type count;
95c755e9
JH
222 /* Unique id of the node. */
223 int uid;
474eccc6
ILT
224 /* Ordering of all cgraph nodes. */
225 int order;
b4e19405 226
3691626c
RG
227 /* unique id for profiling. pid is not suitable because of different
228 number of cfg nodes with -fprofile-generate and -fprofile-use */
229 int pid;
230
0e3776db
JH
231 /* Set when function must be output for some reason. The primary
232 use of this flag is to mark functions needed to be output for
233 non-standard reason. Functions that are externally visible
234 or reachable from functions needed to be output are marked
235 by specialized flags. */
b4e19405 236 unsigned needed : 1;
0e3776db
JH
237 /* Set when function has address taken.
238 In current implementation it imply needed flag. */
39ff5a96 239 unsigned address_taken : 1;
6b20f353
DS
240 /* Set when decl is an abstract function pointed to by the
241 ABSTRACT_DECL_ORIGIN of a reachable function. */
242 unsigned abstract_and_needed : 1;
1c4a429a 243 /* Set when function is reachable by call from other function
b8698a0f 244 that is either reachable or needed.
0e3776db
JH
245 This flag is computed at original cgraph construction and then
246 updated in cgraph_remove_unreachable_nodes. Note that after
247 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
248 nodes when they are needed for virtual clone instantiation. */
b4e19405 249 unsigned reachable : 1;
50674e96 250 /* Set once the function is lowered (i.e. its CFG is built). */
b4e19405 251 unsigned lowered : 1;
25c84396
RH
252 /* Set once the function has been instantiated and its callee
253 lists created. */
b4e19405 254 unsigned analyzed : 1;
257eb6e3
JH
255 /* Set when function is scheduled to be processed by local passes. */
256 unsigned process : 1;
12527dce 257 /* Set for aliases once they got through assemble_alias. */
b4e19405 258 unsigned alias : 1;
d88e5c37
JH
259 /* Set for nodes that was constructed and finalized by frontend. */
260 unsigned finalized_by_frontend : 1;
6744a6ab
JH
261 /* Set for alias and thunk nodes, same_body points to the node they are alias
262 of and they are linked through the next/previous pointers. */
b2583345 263 unsigned same_body_alias : 1;
1c4a429a
JH
264};
265
fed5ae11
DK
266typedef struct cgraph_node *cgraph_node_ptr;
267
268DEF_VEC_P(cgraph_node_ptr);
269DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
270DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
271
272/* A cgraph node set is a collection of cgraph nodes. A cgraph node
273 can appear in multiple sets. */
d1b38208 274struct GTY(()) cgraph_node_set_def
fed5ae11
DK
275{
276 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
277 VEC(cgraph_node_ptr, gc) *nodes;
278 PTR GTY ((skip)) aux;
279};
280
281typedef struct cgraph_node_set_def *cgraph_node_set;
282
283DEF_VEC_P(cgraph_node_set);
284DEF_VEC_ALLOC_P(cgraph_node_set,gc);
285DEF_VEC_ALLOC_P(cgraph_node_set,heap);
286
287/* A cgraph node set element contains an index in the vector of nodes in
288 the set. */
d1b38208 289struct GTY(()) cgraph_node_set_element_def
fed5ae11
DK
290{
291 struct cgraph_node *node;
292 HOST_WIDE_INT index;
293};
294
295typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
296typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
297
298/* Iterator structure for cgraph node sets. */
299typedef struct
300{
301 cgraph_node_set set;
302 unsigned index;
303} cgraph_node_set_iterator;
304
61a05df1
JH
305#define DEFCIFCODE(code, string) CIF_ ## code,
306/* Reasons for inlining failures. */
307typedef enum {
308#include "cif-code.def"
309 CIF_N_REASONS
310} cgraph_inline_failed_t;
311
d1b38208 312struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
ed2df68b
JH
313 struct cgraph_node *caller;
314 struct cgraph_node *callee;
2563c224 315 struct cgraph_edge *prev_caller;
1c4a429a 316 struct cgraph_edge *next_caller;
2563c224 317 struct cgraph_edge *prev_callee;
1c4a429a 318 struct cgraph_edge *next_callee;
726a989a 319 gimple call_stmt;
d7f09764
DN
320 /* The stmt_uid of this call stmt. This is used by LTO to recover
321 the call_stmt when the function is serialized in. */
322 unsigned int lto_stmt_uid;
18c6ada9 323 PTR GTY ((skip (""))) aux;
61a05df1
JH
324 /* When equal to CIF_OK, inline this call. Otherwise, points to the
325 explanation why function was not inlined. */
326 cgraph_inline_failed_t inline_failed;
e42922b1
JH
327 /* Expected number of executions: calculated in profile.c. */
328 gcov_type count;
b8698a0f 329 /* Expected frequency of executions within the function.
45a80bb9
JH
330 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
331 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
332 int frequency;
e42922b1 333 /* Depth of loop nest, 1 means no loop nest. */
2505c5ed 334 unsigned int loop_nest : 30;
3e293154
MJ
335 /* Whether this edge describes a call that was originally indirect. */
336 unsigned int indirect_call : 1;
d7f09764
DN
337 /* True if the corresponding CALL stmt cannot be inlined. */
338 unsigned int call_stmt_cannot_inline_p : 1;
2505c5ed
JH
339 /* Can this call throw externally? */
340 unsigned int can_throw_external : 1;
9088c1cc
MJ
341 /* Unique id of the edge. */
342 int uid;
1c4a429a
JH
343};
344
45a80bb9
JH
345#define CGRAPH_FREQ_BASE 1000
346#define CGRAPH_FREQ_MAX 100000
347
b2c0ad40
KH
348typedef struct cgraph_edge *cgraph_edge_p;
349
350DEF_VEC_P(cgraph_edge_p);
351DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
352
8a4a83ed
JH
353/* The varpool data structure.
354 Each static variable decl has assigned varpool_node. */
e69529cd 355
d1b38208 356struct GTY((chain_next ("%h.next"))) varpool_node {
e69529cd 357 tree decl;
8a4a83ed
JH
358 /* Pointer to the next function in varpool_nodes. */
359 struct varpool_node *next;
360 /* Pointer to the next function in varpool_nodes_queue. */
361 struct varpool_node *next_needed;
474eccc6
ILT
362 /* Ordering of all cgraph nodes. */
363 int order;
e69529cd
JH
364
365 /* Set when function must be output - it is externally visible
e2209b03 366 or its address is taken. */
b4e19405 367 unsigned needed : 1;
cd9c7bd2
JH
368 /* Needed variables might become dead by optimization. This flag
369 forces the variable to be output even if it appears dead otherwise. */
b4e19405 370 unsigned force_output : 1;
cd9c7bd2
JH
371 /* Set once the variable has been instantiated and its callee
372 lists created. */
b4e19405 373 unsigned analyzed : 1;
e69529cd 374 /* Set once it has been finalized so we consider it to be output. */
b4e19405 375 unsigned finalized : 1;
6b02a499 376 /* Set when variable is scheduled to be assembled. */
b4e19405 377 unsigned output : 1;
e7d6beb0 378 /* Set when function is visible by other units. */
b4e19405 379 unsigned externally_visible : 1;
1a612e0a 380 /* Set for aliases once they got through assemble_alias. */
b4e19405 381 unsigned alias : 1;
e69529cd
JH
382};
383
474eccc6
ILT
384/* Every top level asm statement is put into a cgraph_asm_node. */
385
d1b38208 386struct GTY(()) cgraph_asm_node {
474eccc6
ILT
387 /* Next asm node. */
388 struct cgraph_asm_node *next;
389 /* String for this asm node. */
390 tree asm_str;
391 /* Ordering of all cgraph nodes. */
392 int order;
393};
394
ed2df68b
JH
395extern GTY(()) struct cgraph_node *cgraph_nodes;
396extern GTY(()) int cgraph_n_nodes;
b58b1157 397extern GTY(()) int cgraph_max_uid;
9088c1cc 398extern GTY(()) int cgraph_edge_max_uid;
6bad2617 399extern GTY(()) int cgraph_max_pid;
dafc5b82 400extern bool cgraph_global_info_ready;
f45e0ad1
JH
401enum cgraph_state
402{
403 /* Callgraph is being constructed. It is safe to add new functions. */
404 CGRAPH_STATE_CONSTRUCTION,
405 /* Callgraph is built and IPA passes are being run. */
406 CGRAPH_STATE_IPA,
7a388ee4
JH
407 /* Callgraph is built and all functions are transformed to SSA form. */
408 CGRAPH_STATE_IPA_SSA,
f45e0ad1
JH
409 /* Functions are now ordered and being passed to RTL expanders. */
410 CGRAPH_STATE_EXPANSION,
411 /* All cgraph expansion is done. */
412 CGRAPH_STATE_FINISHED
413};
414extern enum cgraph_state cgraph_state;
e7d6beb0 415extern bool cgraph_function_flags_ready;
ed2df68b 416extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
f45e0ad1 417extern GTY(()) struct cgraph_node *cgraph_new_nodes;
1c4a429a 418
474eccc6
ILT
419extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
420extern GTY(()) int cgraph_order;
e69529cd 421
1c4a429a 422/* In cgraph.c */
439f7bc3 423void dump_cgraph (FILE *);
c4e622b6 424void debug_cgraph (void);
18c6ada9 425void dump_cgraph_node (FILE *, struct cgraph_node *);
c4e622b6 426void debug_cgraph_node (struct cgraph_node *);
ea99e0be 427void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
18c6ada9 428void cgraph_remove_edge (struct cgraph_edge *);
439f7bc3 429void cgraph_remove_node (struct cgraph_node *);
9187e02d 430void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
3a40c18a 431void cgraph_release_function_body (struct cgraph_node *);
2563c224 432void cgraph_node_remove_callees (struct cgraph_node *node);
18c6ada9
JH
433struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
434 struct cgraph_node *,
726a989a 435 gimple, gcov_type, int, int);
f9329c35
DS
436
437struct cgraph_node * cgraph_get_node (tree);
e42922b1 438struct cgraph_node *cgraph_node (tree);
b2583345 439bool cgraph_same_body_alias (tree, tree);
6744a6ab 440void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree);
b2583345 441void cgraph_remove_same_body_alias (struct cgraph_node *);
4537ec0c 442struct cgraph_node *cgraph_node_for_asm (tree);
726a989a
RB
443struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
444void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
9187e02d
JH
445void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
446void cgraph_create_edge_including_clones (struct cgraph_node *,
447 struct cgraph_node *,
448 gimple, gcov_type, int, int,
449 cgraph_inline_failed_t);
4b685e14 450void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
439f7bc3
AJ
451struct cgraph_local_info *cgraph_local_info (tree);
452struct cgraph_global_info *cgraph_global_info (tree);
453struct cgraph_rtl_info *cgraph_rtl_info (tree);
454const char * cgraph_node_name (struct cgraph_node *);
c5a4444c 455struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
d7f09764
DN
456 struct cgraph_node *, gimple,
457 unsigned, gcov_type, int, int, bool);
45a80bb9 458struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int,
03ec7d01 459 int, bool, VEC(cgraph_edge_p,heap) *);
1c4a429a 460
18c6ada9 461void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
e69529cd 462
474eccc6
ILT
463struct cgraph_asm_node *cgraph_add_asm_node (tree);
464
1bb17c21 465bool cgraph_function_possibly_inlined_p (tree);
e42922b1 466void cgraph_unnest_node (struct cgraph_node *);
1bb17c21 467
6b02a499 468enum availability cgraph_function_body_availability (struct cgraph_node *);
f45e0ad1 469void cgraph_add_new_function (tree, bool);
61a05df1 470const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
9187e02d
JH
471struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
472 VEC(cgraph_edge_p,heap)*,
473 VEC(ipa_replace_map_p,gc)* tree_map,
474 bitmap args_to_skip);
6b02a499 475
1c4a429a 476/* In cgraphunit.c */
6b00c969 477void cgraph_finalize_function (tree, bool);
f0c882ab 478void cgraph_mark_if_needed (tree);
439f7bc3 479void cgraph_finalize_compilation_unit (void);
d7f09764 480void cgraph_optimize (void);
8dafba3c 481void cgraph_mark_needed_node (struct cgraph_node *);
39ff5a96 482void cgraph_mark_address_taken_node (struct cgraph_node *);
8dafba3c 483void cgraph_mark_reachable_node (struct cgraph_node *);
61a05df1 484bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
18c6ada9
JH
485bool cgraph_preserve_function_body_p (tree);
486void verify_cgraph (void);
487void verify_cgraph_node (struct cgraph_node *);
35b6fdcf 488void cgraph_build_static_cdtor (char which, tree body, int priority);
6674a6ce 489void cgraph_reset_static_var_maps (void);
9b3e897d 490void init_cgraph (void);
57fb5341 491struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
c22cacf3 492 VEC(cgraph_edge_p,heap)*,
9187e02d 493 VEC(ipa_replace_map_p,gc)*,
c6f7cfc1 494 bitmap);
9187e02d 495void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
ea99e0be 496struct cgraph_node *save_inline_function_body (struct cgraph_node *);
625f802c 497void record_references_in_initializer (tree, bool);
f45e0ad1 498bool cgraph_process_new_functions (void);
1c4a429a 499
d7f09764
DN
500bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
501
9088c1cc
MJ
502typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
503typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
504typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
505 void *);
506typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
507 void *);
508struct cgraph_edge_hook_list;
509struct cgraph_node_hook_list;
510struct cgraph_2edge_hook_list;
511struct cgraph_2node_hook_list;
512struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
513void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
514struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
515 void *);
516void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
129a37fc
JH
517struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
518 void *);
519void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
520void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
9088c1cc
MJ
521struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
522void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
523struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
524void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
9187e02d 525void cgraph_materialize_all_clones (void);
9088c1cc 526
917948d3
ZD
527/* In cgraphbuild.c */
528unsigned int rebuild_cgraph_edges (void);
d7f09764 529void reset_inline_failed (struct cgraph_node *);
9187e02d 530int compute_call_stmt_bb_frequency (tree, basic_block bb);
917948d3 531
ca31b95f
JH
532/* In ipa.c */
533bool cgraph_remove_unreachable_nodes (bool, FILE *);
534int cgraph_postorder (struct cgraph_node **);
fed5ae11
DK
535cgraph_node_set cgraph_node_set_new (void);
536cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
537 struct cgraph_node *);
538void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
539void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
540void dump_cgraph_node_set (FILE *, cgraph_node_set);
541void debug_cgraph_node_set (cgraph_node_set);
542
ca31b95f 543
fed5ae11 544/* In predict.c */
ca30a539
JH
545bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
546
8a4a83ed 547/* In varpool.c */
8a4a83ed
JH
548extern GTY(()) struct varpool_node *varpool_nodes_queue;
549extern GTY(()) struct varpool_node *varpool_nodes;
550
551struct varpool_node *varpool_node (tree);
552struct varpool_node *varpool_node_for_asm (tree asmname);
553void varpool_mark_needed_node (struct varpool_node *);
d85478c2 554void debug_varpool (void);
8a4a83ed
JH
555void dump_varpool (FILE *);
556void dump_varpool_node (FILE *, struct varpool_node *);
557
558void varpool_finalize_decl (tree);
559bool decide_is_variable_needed (struct varpool_node *, tree);
560enum availability cgraph_variable_initializer_availability (struct varpool_node *);
a550d677
MJ
561void cgraph_make_node_local (struct cgraph_node *);
562bool cgraph_node_can_be_local_p (struct cgraph_node *);
8a4a83ed
JH
563
564bool varpool_assemble_pending_decls (void);
565bool varpool_assemble_decl (struct varpool_node *node);
566bool varpool_analyze_pending_decls (void);
8a4a83ed 567void varpool_remove_unreferenced_decls (void);
7386e3ee 568void varpool_empty_needed_queue (void);
a8289259 569const char * varpool_node_name (struct varpool_node *node);
8a4a83ed 570
68e56cc4
JH
571/* Walk all reachable static variables. */
572#define FOR_EACH_STATIC_VARIABLE(node) \
573 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
574
575/* Return first reachable static variable with initializer. */
576static inline struct varpool_node *
577varpool_first_static_initializer (void)
578{
579 struct varpool_node *node;
580 for (node = varpool_nodes_queue; node; node = node->next_needed)
581 {
582 gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
583 if (DECL_INITIAL (node->decl))
584 return node;
585 }
586 return NULL;
587}
588
589/* Return next reachable static variable with initializer after NODE. */
590static inline struct varpool_node *
591varpool_next_static_initializer (struct varpool_node *node)
592{
593 for (node = node->next_needed; node; node = node->next_needed)
594 {
595 gcc_assert (TREE_CODE (node->decl) == VAR_DECL);
596 if (DECL_INITIAL (node->decl))
597 return node;
598 }
599 return NULL;
600}
601
602/* Walk all static variables with initializer set. */
603#define FOR_EACH_STATIC_INITIALIZER(node) \
604 for ((node) = varpool_first_static_initializer (); (node); \
605 (node) = varpool_next_static_initializer (node))
606
ca31b95f 607/* In ipa-inline.c */
06191a23 608void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
1920df6c 609unsigned int compute_inline_parameters (struct cgraph_node *);
43d861a5
RL
610
611
612/* Create a new static variable of type TYPE. */
613tree add_new_static_var (tree type);
614
d7f09764
DN
615/* lto-cgraph.c */
616
617enum LTO_cgraph_tags
618{
619 /* Must leave 0 for the stopper. */
620 LTO_cgraph_avail_node = 1,
621 LTO_cgraph_overwritable_node,
622 LTO_cgraph_unavail_node,
623 LTO_cgraph_edge,
624 LTO_cgraph_last_tag
625};
626
627extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag];
628
629#define LCC_NOT_FOUND (-1)
630
fed5ae11
DK
631
632/* Return true if iterator CSI points to nothing. */
633static inline bool
634csi_end_p (cgraph_node_set_iterator csi)
635{
636 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
637}
638
639/* Advance iterator CSI. */
640static inline void
641csi_next (cgraph_node_set_iterator *csi)
642{
643 csi->index++;
644}
645
646/* Return the node pointed to by CSI. */
647static inline struct cgraph_node *
648csi_node (cgraph_node_set_iterator csi)
649{
650 return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
651}
652
653/* Return an iterator to the first node in SET. */
654static inline cgraph_node_set_iterator
655csi_start (cgraph_node_set set)
656{
657 cgraph_node_set_iterator csi;
658
659 csi.set = set;
660 csi.index = 0;
661 return csi;
662}
663
664/* Return true if SET contains NODE. */
665static inline bool
666cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
667{
668 cgraph_node_set_iterator csi;
669 csi = cgraph_node_set_find (set, node);
670 return !csi_end_p (csi);
671}
672
673/* Return number of nodes in SET. */
674static inline size_t
675cgraph_node_set_size (cgraph_node_set set)
676{
677 return htab_elements (set->hashtab);
678}
679
d48e9cea
OR
680/* Uniquize all constants that appear in memory.
681 Each constant in memory thus far output is recorded
682 in `const_desc_table'. */
683
684struct GTY(()) constant_descriptor_tree {
685 /* A MEM for the constant. */
686 rtx rtl;
b8698a0f 687
d48e9cea
OR
688 /* The value of the constant. */
689 tree value;
690
691 /* Hash of value. Computing the hash from value each time
692 hashfn is called can't work properly, as that means recursive
693 use of the hash table during hash table expansion. */
694 hashval_t hash;
695};
696
b20996ff
JH
697/* Return true when function NODE is only called directly.
698 i.e. it is not externally visible, address was not taken and
699 it is not used in any other non-standard way. */
700
701static inline bool
702cgraph_only_called_directly_p (struct cgraph_node *node)
703{
704 return !node->needed && !node->local.externally_visible;
705}
706
707/* Return true when function NODE can be removed from callgraph
708 if all direct calls are eliminated. */
709
710static inline bool
711cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
712{
713 return (!node->needed
714 && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
715}
716
d48e9cea
OR
717/* Constant pool accessor function. */
718htab_t constant_pool_htab (void);
fed5ae11 719
1c4a429a 720#endif /* GCC_CGRAPH_H */