]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cgraph.h
mksysinfo: More fixes to emulate master Go library.
[thirdparty/gcc.git] / gcc / cgraph.h
CommitLineData
1c4a429a 1/* Callgraph handling code.
960bfb69
JH
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
3 2012 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 24
051f8cc6 25#include "plugin-api.h"
7a8cba34 26#include "vec.h"
6674a6ce 27#include "tree.h"
e42922b1 28#include "basic-block.h"
7a8cba34 29#include "function.h"
1f00098b
JH
30#include "ipa-ref.h"
31
32/* Symbol table consists of functions and variables.
33 TODO: add labels, constant pool and aliases. */
34enum symtab_type
35{
960bfb69 36 SYMTAB_SYMBOL,
1f00098b
JH
37 SYMTAB_FUNCTION,
38 SYMTAB_VARIABLE
39};
40
41/* Base of all entries in the symbol table.
42 The symtab_node is inherited by cgraph and varpol nodes. */
960bfb69 43struct GTY(()) symtab_node_base
1f00098b
JH
44{
45 /* Type of the symbol. */
46 enum symtab_type type;
960bfb69
JH
47 tree decl;
48 struct ipa_ref_list ref_list;
49 /* Circular list of nodes in the same comdat group if non-NULL. */
50 symtab_node same_comdat_group;
51 /* Ordering of all symtab entries. */
52 int order;
53 enum ld_plugin_symbol_resolution resolution;
54 /* File stream where this node is being written to. */
55 struct lto_file_decl_data * lto_file_data;
56
2aae7680
JH
57 /* Linked list of symbol table entries starting with symtab_nodes. */
58 symtab_node next;
59 symtab_node previous;
1ab24192
JH
60 /* Linked list of symbols with the same asm name. There may be multiple
61 entries for single symbol name in the case of LTO resolutions,
62 existence of inline clones, or duplicated declaration. The last case
63 is a long standing bug frontends and builtin handling. */
64 symtab_node next_sharing_asm_name;
65 symtab_node previous_sharing_asm_name;
2aae7680 66
960bfb69
JH
67 PTR GTY ((skip)) aux;
68
69 /* Set when function has address taken.
70 In current implementation it imply needed flag. */
71 unsigned address_taken : 1;
72 /* Set when variable is used from other LTRANS partition. */
73 unsigned used_from_other_partition : 1;
74 /* Set when function is available in the other LTRANS partition.
75 During WPA output it is used to mark nodes that are present in
76 multiple partitions. */
77 unsigned in_other_partition : 1;
78 /* Set when function is visible by other units. */
79 unsigned externally_visible : 1;
ead84f73
JH
80 /* Needed variables might become dead by optimization. This flag
81 forces the variable to be output even if it appears dead otherwise. */
82 unsigned force_output : 1;
1f00098b 83};
1c4a429a 84
6b02a499
JH
85enum availability
86{
87 /* Not yet set by cgraph_function_body_availability. */
88 AVAIL_UNSET,
89 /* Function body/variable initializer is unknown. */
90 AVAIL_NOT_AVAILABLE,
91 /* Function body/variable initializer is known but might be replaced
92 by a different one from other compilation unit and thus needs to
93 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
94 arbitrary side effects on escaping variables and functions, while
95 like AVAILABLE it might access static variables. */
96 AVAIL_OVERWRITABLE,
97 /* Function body/variable initializer is known and will be used in final
98 program. */
99 AVAIL_AVAILABLE,
100 /* Function body/variable initializer is known and all it's uses are explicitly
101 visible within current unit (ie it's address is never taken and it is not
102 exported to other units).
103 Currently used only for functions. */
104 AVAIL_LOCAL
105};
106
d7f09764
DN
107/* This is the information that is put into the cgraph local structure
108 to recover a function. */
109struct lto_file_decl_data;
110
8a4a83ed 111extern const char * const cgraph_availability_names[];
430c6ceb 112extern const char * const ld_plugin_symbol_resolution_names[];
8a4a83ed 113
6744a6ab
JH
114/* Information about thunk, used only for same body aliases. */
115
116struct GTY(()) cgraph_thunk_info {
117 /* Information about the thunk. */
118 HOST_WIDE_INT fixed_offset;
119 HOST_WIDE_INT virtual_value;
120 tree alias;
121 bool this_adjusting;
122 bool virtual_offset_p;
123 /* Set to true when alias node is thunk. */
124 bool thunk_p;
125};
126
dafc5b82 127/* Information about the function collected locally.
25c84396 128 Available after function is analyzed. */
dafc5b82 129
d1b38208 130struct GTY(()) cgraph_local_info {
e0bb17a8 131 /* Set when function function is visible in current compilation unit only
e2209b03 132 and its address is never taken. */
b4e19405 133 unsigned local : 1;
6674a6ce 134
f6981e16 135 /* Set once it has been finalized so we consider it to be output. */
b4e19405 136 unsigned finalized : 1;
b58b1157 137
124f1be6
MJ
138 /* False when there is something makes versioning impossible. */
139 unsigned versionable : 1;
140
61e03ffc
JH
141 /* False when function calling convention and signature can not be changed.
142 This is the case when __builtin_apply_args is used. */
143 unsigned can_change_signature : 1;
144
95c755e9
JH
145 /* True when the function has been originally extern inline, but it is
146 redefined now. */
b4e19405 147 unsigned redefined_extern_inline : 1;
0a35513e
AH
148
149 /* True if the function may enter serial irrevocable mode. */
150 unsigned tm_may_enter_irr : 1;
dafc5b82
JH
151};
152
153/* Information about the function that needs to be computed globally
726a989a 154 once compilation is finished. Available only with -funit-at-a-time. */
dafc5b82 155
d1b38208 156struct GTY(()) cgraph_global_info {
726a989a
RB
157 /* For inline clones this points to the function they will be
158 inlined into. */
18c6ada9 159 struct cgraph_node *inlined_to;
dafc5b82
JH
160};
161
b255a036
JH
162/* Information about the function that is propagated by the RTL backend.
163 Available only for functions that has been already assembled. */
164
d1b38208 165struct GTY(()) cgraph_rtl_info {
17b29c0a 166 unsigned int preferred_incoming_stack_boundary;
b255a036
JH
167};
168
9187e02d
JH
169/* Represent which DECL tree (or reference to such tree)
170 will be replaced by another tree while versioning. */
171struct GTY(()) ipa_replace_map
172{
173 /* The tree that will be replaced. */
174 tree old_tree;
175 /* The new (replacing) tree. */
176 tree new_tree;
922f15c2
JH
177 /* Parameter number to replace, when old_tree is NULL. */
178 int parm_num;
9187e02d
JH
179 /* True when a substitution should be done, false otherwise. */
180 bool replace_p;
181 /* True when we replace a reference to old_tree. */
182 bool ref_p;
183};
184typedef struct ipa_replace_map *ipa_replace_map_p;
185DEF_VEC_P(ipa_replace_map_p);
186DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
187
188struct GTY(()) cgraph_clone_info
189{
190 VEC(ipa_replace_map_p,gc)* tree_map;
191 bitmap args_to_skip;
08ad1d6d 192 bitmap combined_args_to_skip;
9187e02d
JH
193};
194
5fefcf92 195
ba228239 196/* The cgraph data structure.
e0bb17a8 197 Each function decl has assigned cgraph_node listing callees and callers. */
1c4a429a 198
960bfb69
JH
199struct GTY(()) cgraph_node {
200 struct symtab_node_base symbol;
1c4a429a
JH
201 struct cgraph_edge *callees;
202 struct cgraph_edge *callers;
e33c6cd6
MJ
203 /* List of edges representing indirect calls with a yet undetermined
204 callee. */
205 struct cgraph_edge *indirect_calls;
1c4a429a 206 /* For nested functions points to function the node is nested in. */
960bfb69
JH
207 struct cgraph_node *
208 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
209 origin;
1c4a429a 210 /* Points to first nested function, if any. */
960bfb69
JH
211 struct cgraph_node *
212 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
213 nested;
1c4a429a 214 /* Pointer to the next function with same origin, if any. */
960bfb69
JH
215 struct cgraph_node *
216 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
217 next_nested;
8bd87c4e 218 /* Pointer to the next function in cgraph_nodes_queue. */
960bfb69
JH
219 struct cgraph_node *
220 GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
221 next_needed;
18c6ada9 222 /* Pointer to the next clone. */
9187e02d
JH
223 struct cgraph_node *next_sibling_clone;
224 struct cgraph_node *prev_sibling_clone;
225 struct cgraph_node *clones;
226 struct cgraph_node *clone_of;
70d539ce
JH
227 /* For functions with many calls sites it holds map from call expression
228 to the edge to speed up cgraph_edge function. */
229 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
97ba0040
JH
230 /* Declaration node used to be clone of. */
231 tree former_clone_of;
c22cacf3 232
0e3776db
JH
233 /* Interprocedural passes scheduled to have their transform functions
234 applied next time we execute local pass on them. We maintain it
235 per-function in order to allow IPA passes to introduce new functions. */
236 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
237
95c755e9
JH
238 struct cgraph_local_info local;
239 struct cgraph_global_info global;
240 struct cgraph_rtl_info rtl;
9187e02d 241 struct cgraph_clone_info clone;
6744a6ab 242 struct cgraph_thunk_info thunk;
c22cacf3 243
e42922b1
JH
244 /* Expected number of executions: calculated in profile.c. */
245 gcov_type count;
db0bf14f
JH
246 /* How to scale counts at materialization time; used to merge
247 LTO units with different number of profile runs. */
248 int count_materialization_scale;
95c755e9
JH
249 /* Unique id of the node. */
250 int uid;
3691626c 251
6b20f353
DS
252 /* Set when decl is an abstract function pointed to by the
253 ABSTRACT_DECL_ORIGIN of a reachable function. */
254 unsigned abstract_and_needed : 1;
1c4a429a 255 /* Set when function is reachable by call from other function
b8698a0f 256 that is either reachable or needed.
0e3776db
JH
257 This flag is computed at original cgraph construction and then
258 updated in cgraph_remove_unreachable_nodes. Note that after
259 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
260 nodes when they are needed for virtual clone instantiation. */
b4e19405 261 unsigned reachable : 1;
50674e96 262 /* Set once the function is lowered (i.e. its CFG is built). */
b4e19405 263 unsigned lowered : 1;
25c84396
RH
264 /* Set once the function has been instantiated and its callee
265 lists created. */
b4e19405 266 unsigned analyzed : 1;
257eb6e3
JH
267 /* Set when function is scheduled to be processed by local passes. */
268 unsigned process : 1;
12527dce 269 /* Set for aliases once they got through assemble_alias. */
b4e19405 270 unsigned alias : 1;
39e2db00 271 /* Set for aliases created as C++ same body aliases. */
b2583345 272 unsigned same_body_alias : 1;
5fefcf92
JH
273 /* How commonly executed the node is. Initialized during branch
274 probabilities pass. */
275 ENUM_BITFIELD (node_frequency) frequency : 2;
844db5d0
JH
276 /* True when function can only be called at startup (from static ctor). */
277 unsigned only_called_at_startup : 1;
278 /* True when function can only be called at startup (from static dtor). */
279 unsigned only_called_at_exit : 1;
0a35513e
AH
280 /* True when function is the transactional clone of a function which
281 is called only from inside transactions. */
282 /* ?? We should be able to remove this. We have enough bits in
283 cgraph to calculate it. */
284 unsigned tm_clone : 1;
1c4a429a
JH
285};
286
fed5ae11
DK
287typedef struct cgraph_node *cgraph_node_ptr;
288
289DEF_VEC_P(cgraph_node_ptr);
290DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
291DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
292
293/* A cgraph node set is a collection of cgraph nodes. A cgraph node
294 can appear in multiple sets. */
1cb1a99f 295struct cgraph_node_set_def
fed5ae11 296{
1cb1a99f
JH
297 struct pointer_map_t *map;
298 VEC(cgraph_node_ptr, heap) *nodes;
fed5ae11
DK
299};
300
2942c502
JH
301typedef struct varpool_node *varpool_node_ptr;
302
303DEF_VEC_P(varpool_node_ptr);
304DEF_VEC_ALLOC_P(varpool_node_ptr,heap);
305DEF_VEC_ALLOC_P(varpool_node_ptr,gc);
306
307/* A varpool node set is a collection of varpool nodes. A varpool node
308 can appear in multiple sets. */
1cb1a99f 309struct varpool_node_set_def
2942c502 310{
1cb1a99f
JH
311 struct pointer_map_t * map;
312 VEC(varpool_node_ptr, heap) *nodes;
2942c502
JH
313};
314
fed5ae11
DK
315typedef struct cgraph_node_set_def *cgraph_node_set;
316
317DEF_VEC_P(cgraph_node_set);
318DEF_VEC_ALLOC_P(cgraph_node_set,gc);
319DEF_VEC_ALLOC_P(cgraph_node_set,heap);
320
2942c502
JH
321typedef struct varpool_node_set_def *varpool_node_set;
322
323DEF_VEC_P(varpool_node_set);
324DEF_VEC_ALLOC_P(varpool_node_set,gc);
325DEF_VEC_ALLOC_P(varpool_node_set,heap);
326
fed5ae11
DK
327/* Iterator structure for cgraph node sets. */
328typedef struct
329{
330 cgraph_node_set set;
331 unsigned index;
332} cgraph_node_set_iterator;
333
2942c502
JH
334/* Iterator structure for varpool node sets. */
335typedef struct
336{
337 varpool_node_set set;
338 unsigned index;
339} varpool_node_set_iterator;
340
61a05df1
JH
341#define DEFCIFCODE(code, string) CIF_ ## code,
342/* Reasons for inlining failures. */
533c07c5 343typedef enum cgraph_inline_failed_enum {
61a05df1
JH
344#include "cif-code.def"
345 CIF_N_REASONS
346} cgraph_inline_failed_t;
347
e33c6cd6
MJ
348/* Structure containing additional information about an indirect call. */
349
350struct GTY(()) cgraph_indirect_call_info
351{
b258210c
MJ
352 /* Offset accumulated from ancestor jump functions of inlined call graph
353 edges. */
354 HOST_WIDE_INT anc_offset;
355 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
356 HOST_WIDE_INT otr_token;
357 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
358 tree otr_type;
e33c6cd6
MJ
359 /* Index of the parameter that is called. */
360 int param_index;
5f902d76
JH
361 /* ECF flags determined from the caller. */
362 int ecf_flags;
b258210c
MJ
363
364 /* Set when the call is a virtual call with the parameter being the
365 associated object pointer rather than a simple direct call. */
366 unsigned polymorphic : 1;
e33c6cd6
MJ
367};
368
d1b38208 369struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
6009ee7b
MJ
370 /* Expected number of executions: calculated in profile.c. */
371 gcov_type count;
ed2df68b
JH
372 struct cgraph_node *caller;
373 struct cgraph_node *callee;
2563c224 374 struct cgraph_edge *prev_caller;
1c4a429a 375 struct cgraph_edge *next_caller;
2563c224 376 struct cgraph_edge *prev_callee;
1c4a429a 377 struct cgraph_edge *next_callee;
726a989a 378 gimple call_stmt;
e33c6cd6
MJ
379 /* Additional information about an indirect call. Not cleared when an edge
380 becomes direct. */
381 struct cgraph_indirect_call_info *indirect_info;
18c6ada9 382 PTR GTY ((skip (""))) aux;
61a05df1
JH
383 /* When equal to CIF_OK, inline this call. Otherwise, points to the
384 explanation why function was not inlined. */
385 cgraph_inline_failed_t inline_failed;
6009ee7b
MJ
386 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
387 when the function is serialized in. */
388 unsigned int lto_stmt_uid;
b8698a0f 389 /* Expected frequency of executions within the function.
45a80bb9
JH
390 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
391 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
392 int frequency;
6009ee7b
MJ
393 /* Unique id of the edge. */
394 int uid;
e33c6cd6
MJ
395 /* Whether this edge was made direct by indirect inlining. */
396 unsigned int indirect_inlining_edge : 1;
397 /* Whether this edge describes an indirect call with an undetermined
398 callee. */
399 unsigned int indirect_unknown_callee : 1;
400 /* Whether this edge is still a dangling */
d7f09764
DN
401 /* True if the corresponding CALL stmt cannot be inlined. */
402 unsigned int call_stmt_cannot_inline_p : 1;
2505c5ed
JH
403 /* Can this call throw externally? */
404 unsigned int can_throw_external : 1;
1c4a429a
JH
405};
406
45a80bb9
JH
407#define CGRAPH_FREQ_BASE 1000
408#define CGRAPH_FREQ_MAX 100000
409
b2c0ad40
KH
410typedef struct cgraph_edge *cgraph_edge_p;
411
412DEF_VEC_P(cgraph_edge_p);
413DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
414
8a4a83ed
JH
415/* The varpool data structure.
416 Each static variable decl has assigned varpool_node. */
e69529cd 417
2aae7680 418struct GTY(()) varpool_node {
960bfb69 419 struct symtab_node_base symbol;
cd35bcf7
JH
420 /* For aliases points to declaration DECL is alias of. */
421 tree alias_of;
8a4a83ed 422 /* Pointer to the next function in varpool_nodes_queue. */
960bfb69
JH
423 struct varpool_node *
424 GTY ((nested_ptr (union symtab_node_def, "(struct varpool_node *)(%h)", "(symtab_node)%h")))
425 next_needed;
426 struct varpool_node *
427 GTY ((nested_ptr (union symtab_node_def, "(struct varpool_node *)(%h)", "(symtab_node)%h")))
428 prev_needed;
e69529cd
JH
429
430 /* Set when function must be output - it is externally visible
e2209b03 431 or its address is taken. */
b4e19405 432 unsigned needed : 1;
cd9c7bd2
JH
433 /* Set once the variable has been instantiated and its callee
434 lists created. */
b4e19405 435 unsigned analyzed : 1;
e69529cd 436 /* Set once it has been finalized so we consider it to be output. */
b4e19405 437 unsigned finalized : 1;
6b02a499 438 /* Set when variable is scheduled to be assembled. */
b4e19405 439 unsigned output : 1;
2c71ac78
JM
440 /* Set for aliases once they got through assemble_alias. Also set for
441 extra name aliases in varpool_extra_name_alias. */
b4e19405 442 unsigned alias : 1;
cd35bcf7 443 unsigned extra_name_alias : 1;
e69529cd
JH
444};
445
474eccc6
ILT
446/* Every top level asm statement is put into a cgraph_asm_node. */
447
d1b38208 448struct GTY(()) cgraph_asm_node {
474eccc6
ILT
449 /* Next asm node. */
450 struct cgraph_asm_node *next;
451 /* String for this asm node. */
452 tree asm_str;
453 /* Ordering of all cgraph nodes. */
454 int order;
455};
456
960bfb69 457/* Symbol table entry. */
2aae7680
JH
458union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
459 chain_prev ("%h.symbol.previous"))) symtab_node_def {
960bfb69
JH
460 struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
461 /* Use cgraph (symbol) accessor to get cgraph_node. */
462 struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
463 /* Use varpool (symbol) accessor to get varpool_node. */
464 struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
465};
466
2aae7680 467extern GTY(()) symtab_node symtab_nodes;
ed2df68b 468extern GTY(()) int cgraph_n_nodes;
b58b1157 469extern GTY(()) int cgraph_max_uid;
9088c1cc 470extern GTY(()) int cgraph_edge_max_uid;
dafc5b82 471extern bool cgraph_global_info_ready;
f45e0ad1
JH
472enum cgraph_state
473{
474 /* Callgraph is being constructed. It is safe to add new functions. */
475 CGRAPH_STATE_CONSTRUCTION,
476 /* Callgraph is built and IPA passes are being run. */
477 CGRAPH_STATE_IPA,
7a388ee4
JH
478 /* Callgraph is built and all functions are transformed to SSA form. */
479 CGRAPH_STATE_IPA_SSA,
f45e0ad1
JH
480 /* Functions are now ordered and being passed to RTL expanders. */
481 CGRAPH_STATE_EXPANSION,
482 /* All cgraph expansion is done. */
483 CGRAPH_STATE_FINISHED
484};
485extern enum cgraph_state cgraph_state;
e7d6beb0 486extern bool cgraph_function_flags_ready;
960bfb69
JH
487extern GTY(()) symtab_node x_cgraph_nodes_queue;
488#define cgraph_nodes_queue ((struct cgraph_node *)x_cgraph_nodes_queue)
f45e0ad1 489extern GTY(()) struct cgraph_node *cgraph_new_nodes;
1c4a429a 490
474eccc6 491extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
2aae7680 492extern GTY(()) int symtab_order;
39e2db00 493extern bool same_body_aliases_done;
e69529cd 494
2aae7680
JH
495/* In symtab.c */
496void symtab_register_node (symtab_node);
497void symtab_unregister_node (symtab_node);
498void symtab_remove_node (symtab_node);
1ab24192
JH
499symtab_node symtab_get_node (const_tree);
500symtab_node symtab_node_for_asm (const_tree asmname);
8f940ee6
JH
501const char * symtab_node_asm_name (symtab_node);
502const char * symtab_node_name (symtab_node);
1ab24192 503void symtab_insert_node_to_hashtable (symtab_node);
8f940ee6
JH
504void dump_symtab (FILE *);
505void debug_symtab (void);
506void dump_symtab_node (FILE *, symtab_node);
507void debug_symtab_node (symtab_node);
508void dump_symtab_base (FILE *, symtab_node);
474ffc72
JH
509void verify_symtab (void);
510void verify_symtab_node (symtab_node);
511bool verify_symtab_base (symtab_node);
2aae7680 512
1c4a429a 513/* In cgraph.c */
439f7bc3 514void dump_cgraph (FILE *);
c4e622b6 515void debug_cgraph (void);
18c6ada9 516void dump_cgraph_node (FILE *, struct cgraph_node *);
c4e622b6 517void debug_cgraph_node (struct cgraph_node *);
18c6ada9 518void cgraph_remove_edge (struct cgraph_edge *);
439f7bc3 519void cgraph_remove_node (struct cgraph_node *);
1ab24192 520struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
2fda8e14 521void cgraph_add_to_same_comdat_group (struct cgraph_node *, struct cgraph_node *);
b4e93f45 522bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
3a40c18a 523void cgraph_release_function_body (struct cgraph_node *);
2563c224 524void cgraph_node_remove_callees (struct cgraph_node *node);
18c6ada9
JH
525struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
526 struct cgraph_node *,
898b8927 527 gimple, gcov_type, int);
ce47fda3 528struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
898b8927 529 int, gcov_type, int);
ce47fda3 530struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
a358e188
MJ
531struct cgraph_node * cgraph_create_node (tree);
532struct cgraph_node * cgraph_get_create_node (tree);
87e7b310
JH
533struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
534struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
051f8cc6 535 HOST_WIDE_INT, tree, tree);
4537ec0c 536struct cgraph_node *cgraph_node_for_asm (tree);
726a989a
RB
537struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
538void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
9187e02d
JH
539void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
540void cgraph_create_edge_including_clones (struct cgraph_node *,
541 struct cgraph_node *,
898b8927 542 gimple, gimple, gcov_type, int,
9187e02d 543 cgraph_inline_failed_t);
4b685e14 544void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
439f7bc3
AJ
545struct cgraph_local_info *cgraph_local_info (tree);
546struct cgraph_global_info *cgraph_global_info (tree);
547struct cgraph_rtl_info *cgraph_rtl_info (tree);
c5a4444c 548struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
d7f09764 549 struct cgraph_node *, gimple,
898b8927
JH
550 unsigned, gcov_type, int, bool);
551struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
74605a11
JH
552 int, bool, VEC(cgraph_edge_p,heap) *,
553 bool);
39e2db00 554struct cgraph_node *cgraph_create_function_alias (tree, tree);
b0d0a291
PM
555void cgraph_call_node_duplication_hooks (struct cgraph_node *node1,
556 struct cgraph_node *node2);
1c4a429a 557
18c6ada9 558void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
81fa35bd 559void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
be330ed4 560bool cgraph_only_called_directly_p (struct cgraph_node *);
e69529cd 561
474eccc6
ILT
562struct cgraph_asm_node *cgraph_add_asm_node (tree);
563
1bb17c21 564bool cgraph_function_possibly_inlined_p (tree);
e42922b1 565void cgraph_unnest_node (struct cgraph_node *);
1bb17c21 566
6b02a499 567enum availability cgraph_function_body_availability (struct cgraph_node *);
f45e0ad1 568void cgraph_add_new_function (tree, bool);
61a05df1 569const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
9187e02d
JH
570struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
571 VEC(cgraph_edge_p,heap)*,
572 VEC(ipa_replace_map_p,gc)* tree_map,
036546e5
JH
573 bitmap args_to_skip,
574 const char *clone_name);
6b02a499 575
20cdc2be 576void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
530f3a1b
JH
577void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
578void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
036546e5 579tree clone_function_name (tree decl, const char *);
d56026c2
JH
580bool cgraph_node_cannot_return (struct cgraph_node *);
581bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
508e4757
JH
582bool cgraph_will_be_removed_from_program_if_no_direct_calls
583 (struct cgraph_node *node);
584bool cgraph_can_remove_if_no_direct_calls_and_refs_p
585 (struct cgraph_node *node);
9aa3f5c5 586bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
be330ed4
JH
587bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
588bool cgraph_used_from_object_file_p (struct cgraph_node *);
589bool varpool_used_from_object_file_p (struct varpool_node *);
590bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
591 bool (*) (struct cgraph_node *, void *),
592 void *,
593 bool);
594bool cgraph_for_node_and_aliases (struct cgraph_node *,
595 bool (*) (struct cgraph_node *, void *),
596 void *, bool);
597VEC (cgraph_edge_p, heap) * collect_callers_of_node (struct cgraph_node *node);
598
20cdc2be 599
1c4a429a 600/* In cgraphunit.c */
0a5fa5a1 601extern FILE *cgraph_dump_file;
6b00c969 602void cgraph_finalize_function (tree, bool);
f0c882ab 603void cgraph_mark_if_needed (tree);
322dd859 604void cgraph_analyze_function (struct cgraph_node *);
439f7bc3 605void cgraph_finalize_compilation_unit (void);
d7f09764 606void cgraph_optimize (void);
ead84f73 607void cgraph_mark_force_output_node (struct cgraph_node *);
39ff5a96 608void cgraph_mark_address_taken_node (struct cgraph_node *);
8dafba3c 609void cgraph_mark_reachable_node (struct cgraph_node *);
61a05df1 610bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
85ad2ef5 611bool cgraph_preserve_function_body_p (struct cgraph_node *);
18c6ada9
JH
612void verify_cgraph (void);
613void verify_cgraph_node (struct cgraph_node *);
35b6fdcf 614void cgraph_build_static_cdtor (char which, tree body, int priority);
6674a6ce 615void cgraph_reset_static_var_maps (void);
9b3e897d 616void init_cgraph (void);
0a35513e
AH
617struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
618 tree, VEC(cgraph_edge_p,heap)*, bitmap);
57fb5341 619struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
c22cacf3 620 VEC(cgraph_edge_p,heap)*,
9187e02d 621 VEC(ipa_replace_map_p,gc)*,
1a2c27e9
EB
622 bitmap, bool, bitmap,
623 basic_block, const char *);
624void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*,
625 bool, bitmap, bool, bitmap, basic_block);
625f802c 626void record_references_in_initializer (tree, bool);
f45e0ad1 627bool cgraph_process_new_functions (void);
39e2db00 628void cgraph_process_same_body_aliases (void);
1c4a429a 629
d7f09764
DN
630bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
631
9088c1cc
MJ
632typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
633typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
634typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
635 void *);
636typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
637 void *);
638struct cgraph_edge_hook_list;
639struct cgraph_node_hook_list;
640struct cgraph_2edge_hook_list;
641struct cgraph_2node_hook_list;
642struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
643void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
644struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
645 void *);
646void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
129a37fc
JH
647struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
648 void *);
649void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
650void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
9088c1cc
MJ
651struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
652void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
653struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
654void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
8132a837 655gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
fa5f5e27 656bool cgraph_propagate_frequency (struct cgraph_node *node);
917948d3
ZD
657/* In cgraphbuild.c */
658unsigned int rebuild_cgraph_edges (void);
99b766fc 659void cgraph_rebuild_references (void);
9187e02d 660int compute_call_stmt_bb_frequency (tree, basic_block bb);
917948d3 661
ca31b95f
JH
662/* In ipa.c */
663bool cgraph_remove_unreachable_nodes (bool, FILE *);
fed5ae11
DK
664cgraph_node_set cgraph_node_set_new (void);
665cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
666 struct cgraph_node *);
667void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
668void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
669void dump_cgraph_node_set (FILE *, cgraph_node_set);
670void debug_cgraph_node_set (cgraph_node_set);
1cb1a99f 671void free_cgraph_node_set (cgraph_node_set);
fed5ae11 672
2942c502
JH
673varpool_node_set varpool_node_set_new (void);
674varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
675 struct varpool_node *);
676void varpool_node_set_add (varpool_node_set, struct varpool_node *);
677void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
678void dump_varpool_node_set (FILE *, varpool_node_set);
679void debug_varpool_node_set (varpool_node_set);
1cb1a99f 680void free_varpool_node_set (varpool_node_set);
4a444e58 681void ipa_discover_readonly_nonaddressable_vars (void);
430c6ceb 682bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *);
38877e98 683bool varpool_externally_visible_p (struct varpool_node *, bool);
ca31b95f 684
fed5ae11 685/* In predict.c */
ca30a539 686bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
e6416b30 687bool cgraph_optimize_for_size_p (struct cgraph_node *);
ca30a539 688
8a4a83ed 689/* In varpool.c */
960bfb69 690extern GTY(()) symtab_node x_varpool_nodes_queue;
960bfb69 691#define varpool_nodes_queue ((struct varpool_node *)x_varpool_nodes_queue)
8a4a83ed
JH
692
693struct varpool_node *varpool_node (tree);
694struct varpool_node *varpool_node_for_asm (tree asmname);
695void varpool_mark_needed_node (struct varpool_node *);
d85478c2 696void debug_varpool (void);
8a4a83ed
JH
697void dump_varpool (FILE *);
698void dump_varpool_node (FILE *, struct varpool_node *);
699
700void varpool_finalize_decl (tree);
701bool decide_is_variable_needed (struct varpool_node *, tree);
702enum availability cgraph_variable_initializer_availability (struct varpool_node *);
715a4e08 703void cgraph_make_decl_local (tree);
a550d677
MJ
704void cgraph_make_node_local (struct cgraph_node *);
705bool cgraph_node_can_be_local_p (struct cgraph_node *);
8a4a83ed 706
2942c502 707
2942c502 708void varpool_remove_node (struct varpool_node *node);
7fece979 709void varpool_finalize_named_section_flags (struct varpool_node *node);
8a4a83ed
JH
710bool varpool_assemble_pending_decls (void);
711bool varpool_assemble_decl (struct varpool_node *node);
712bool varpool_analyze_pending_decls (void);
8a4a83ed 713void varpool_remove_unreferenced_decls (void);
7386e3ee 714void varpool_empty_needed_queue (void);
051f8cc6 715struct varpool_node * varpool_extra_name_alias (tree, tree);
cd35bcf7 716struct varpool_node * varpool_create_variable_alias (tree, tree);
b34fd25c 717void varpool_reset_queue (void);
64e0f5ff 718bool const_value_known_p (tree);
cd35bcf7
JH
719bool varpool_for_node_and_aliases (struct varpool_node *,
720 bool (*) (struct varpool_node *, void *),
721 void *, bool);
38877e98 722void varpool_add_new_variable (tree);
8a4a83ed 723
2aae7680
JH
724/* Return true when NODE is function. */
725static inline bool
726symtab_function_p (symtab_node node)
727{
728 return node->symbol.type == SYMTAB_FUNCTION;
729}
730
731/* Return true when NODE is variable. */
732static inline bool
733symtab_variable_p (symtab_node node)
734{
735 return node->symbol.type == SYMTAB_VARIABLE;
736}
68e56cc4 737
1f00098b
JH
738/* Return callgraph node for given symbol and check it is a function. */
739static inline struct cgraph_node *
960bfb69 740cgraph (symtab_node node)
1f00098b 741{
960bfb69 742 gcc_checking_assert (!node || node->symbol.type == SYMTAB_FUNCTION);
1ab24192 743 return (struct cgraph_node *)node;
1f00098b
JH
744}
745
746/* Return varpool node for given symbol and check it is a variable. */
747static inline struct varpool_node *
960bfb69 748varpool (symtab_node node)
1f00098b 749{
960bfb69 750 gcc_checking_assert (!node || node->symbol.type == SYMTAB_VARIABLE);
1ab24192 751 return (struct varpool_node *)node;
1f00098b
JH
752}
753
1ab24192
JH
754/* Return callgraph node for given symbol and check it is a function. */
755static inline struct cgraph_node *
756cgraph_get_node (const_tree decl)
757{
758 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
759 return cgraph (symtab_get_node (decl));
760}
761
762/* Return varpool node for given symbol and check it is a function. */
763static inline struct varpool_node *
764varpool_get_node (const_tree decl)
765{
766 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
767 return varpool (symtab_get_node (decl));
768}
769
8f940ee6
JH
770/* Return asm name of cgraph node. */
771static inline const char *
772cgraph_node_asm_name(struct cgraph_node *node)
773{
774 return symtab_node_asm_name ((symtab_node)node);
775}
776
777/* Return asm name of varpool node. */
778static inline const char *
779varpool_node_asm_name(struct varpool_node *node)
780{
781 return symtab_node_asm_name ((symtab_node)node);
782}
783
784/* Return name of cgraph node. */
785static inline const char *
786cgraph_node_name(struct cgraph_node *node)
787{
788 return symtab_node_name ((symtab_node)node);
789}
790
791/* Return name of varpool node. */
792static inline const char *
793varpool_node_name(struct varpool_node *node)
794{
795 return symtab_node_name ((symtab_node)node);
796}
797
1ab24192
JH
798/* Walk all symbols. */
799#define FOR_EACH_SYMBOL(node) \
800 for ((node) = symtab_nodes; (node); (node) = (node)->symbol.next)
1f00098b 801
68e56cc4
JH
802/* Return first reachable static variable with initializer. */
803static inline struct varpool_node *
804varpool_first_static_initializer (void)
805{
806 struct varpool_node *node;
807 for (node = varpool_nodes_queue; node; node = node->next_needed)
808 {
960bfb69
JH
809 gcc_checking_assert (TREE_CODE (node->symbol.decl) == VAR_DECL);
810 if (DECL_INITIAL (node->symbol.decl))
68e56cc4
JH
811 return node;
812 }
813 return NULL;
814}
815
816/* Return next reachable static variable with initializer after NODE. */
817static inline struct varpool_node *
818varpool_next_static_initializer (struct varpool_node *node)
819{
820 for (node = node->next_needed; node; node = node->next_needed)
821 {
960bfb69
JH
822 gcc_checking_assert (TREE_CODE (node->symbol.decl) == VAR_DECL);
823 if (DECL_INITIAL (node->symbol.decl))
68e56cc4
JH
824 return node;
825 }
826 return NULL;
827}
828
2aae7680
JH
829/* Walk all reachable static variables. */
830#define FOR_EACH_STATIC_VARIABLE(node) \
831 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
68e56cc4
JH
832/* Walk all static variables with initializer set. */
833#define FOR_EACH_STATIC_INITIALIZER(node) \
834 for ((node) = varpool_first_static_initializer (); (node); \
835 (node) = varpool_next_static_initializer (node))
2aae7680
JH
836
837/* Return first variable. */
838static inline struct varpool_node *
839varpool_first_variable (void)
840{
841 symtab_node node;
842 for (node = symtab_nodes; node; node = node->symbol.next)
843 {
844 if (symtab_variable_p (node))
845 return varpool (node);
846 }
847 return NULL;
848}
849
850/* Return next variable after NODE. */
851static inline struct varpool_node *
852varpool_next_variable (struct varpool_node *node)
853{
854 symtab_node node1 = (symtab_node) node->symbol.next;
855 for (; node1; node1 = node1->symbol.next)
856 {
857 if (symtab_variable_p (node1))
858 return varpool (node1);
859 }
860 return NULL;
861}
65c70e6b
JH
862/* Walk all variables. */
863#define FOR_EACH_VARIABLE(node) \
2aae7680
JH
864 for ((node) = varpool_first_variable (); \
865 (node); \
866 (node) = varpool_next_variable ((node)))
65c70e6b
JH
867/* Walk all variables with definitions in current unit. */
868#define FOR_EACH_DEFINED_VARIABLE(node) \
869 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
68e56cc4 870
c47d0034
JH
871/* Return first function with body defined. */
872static inline struct cgraph_node *
873cgraph_first_defined_function (void)
874{
2aae7680
JH
875 symtab_node node;
876 for (node = symtab_nodes; node; node = node->symbol.next)
c47d0034 877 {
2aae7680
JH
878 if (symtab_function_p (node) && cgraph (node)->analyzed)
879 return cgraph (node);
c47d0034
JH
880 }
881 return NULL;
882}
883
45896127 884/* Return next function with body defined after NODE. */
c47d0034
JH
885static inline struct cgraph_node *
886cgraph_next_defined_function (struct cgraph_node *node)
887{
2aae7680
JH
888 symtab_node node1 = (symtab_node) node->symbol.next;
889 for (; node1; node1 = node1->symbol.next)
c47d0034 890 {
2aae7680
JH
891 if (symtab_function_p (node1) && cgraph (node1)->analyzed)
892 return cgraph (node1);
c47d0034
JH
893 }
894 return NULL;
895}
896
897/* Walk all functions with body defined. */
898#define FOR_EACH_DEFINED_FUNCTION(node) \
899 for ((node) = cgraph_first_defined_function (); (node); \
2aae7680
JH
900 (node) = cgraph_next_defined_function ((node)))
901
902/* Return first function. */
903static inline struct cgraph_node *
904cgraph_first_function (void)
905{
906 symtab_node node;
907 for (node = symtab_nodes; node; node = node->symbol.next)
908 {
909 if (symtab_function_p (node))
910 return cgraph (node);
911 }
912 return NULL;
913}
914
915/* Return next function. */
916static inline struct cgraph_node *
917cgraph_next_function (struct cgraph_node *node)
918{
919 symtab_node node1 = (symtab_node) node->symbol.next;
920 for (; node1; node1 = node1->symbol.next)
921 {
922 if (symtab_function_p (node1))
923 return cgraph (node1);
924 }
925 return NULL;
926}
65c70e6b
JH
927/* Walk all functions. */
928#define FOR_EACH_FUNCTION(node) \
2aae7680
JH
929 for ((node) = cgraph_first_function (); (node); \
930 (node) = cgraph_next_function ((node)))
c47d0034
JH
931
932/* Return true when NODE is a function with Gimple body defined
933 in current unit. Functions can also be define externally or they
934 can be thunks with no Gimple representation.
935
936 Note that at WPA stage, the function body may not be present in memory. */
937
938static inline bool
939cgraph_function_with_gimple_body_p (struct cgraph_node *node)
940{
39e2db00 941 return node->analyzed && !node->thunk.thunk_p && !node->alias;
c47d0034
JH
942}
943
944/* Return first function with body defined. */
945static inline struct cgraph_node *
946cgraph_first_function_with_gimple_body (void)
947{
2aae7680
JH
948 symtab_node node;
949 for (node = symtab_nodes; node; node = node->symbol.next)
c47d0034 950 {
2aae7680
JH
951 if (symtab_function_p (node)
952 && cgraph_function_with_gimple_body_p (cgraph (node)))
953 return cgraph (node);
c47d0034
JH
954 }
955 return NULL;
956}
957
958/* Return next reachable static variable with initializer after NODE. */
959static inline struct cgraph_node *
960cgraph_next_function_with_gimple_body (struct cgraph_node *node)
961{
2aae7680
JH
962 symtab_node node1 = node->symbol.next;
963 for (; node1; node1 = node1->symbol.next)
c47d0034 964 {
2aae7680
JH
965 if (symtab_function_p (node1)
966 && cgraph_function_with_gimple_body_p (cgraph (node1)))
967 return cgraph (node1);
c47d0034
JH
968 }
969 return NULL;
970}
971
972/* Walk all functions with body defined. */
973#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
974 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
975 (node) = cgraph_next_function_with_gimple_body (node))
976
43d861a5
RL
977/* Create a new static variable of type TYPE. */
978tree add_new_static_var (tree type);
979
fed5ae11
DK
980/* Return true if iterator CSI points to nothing. */
981static inline bool
982csi_end_p (cgraph_node_set_iterator csi)
983{
984 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
985}
986
987/* Advance iterator CSI. */
988static inline void
989csi_next (cgraph_node_set_iterator *csi)
990{
991 csi->index++;
992}
993
994/* Return the node pointed to by CSI. */
995static inline struct cgraph_node *
996csi_node (cgraph_node_set_iterator csi)
997{
998 return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
999}
1000
1001/* Return an iterator to the first node in SET. */
1002static inline cgraph_node_set_iterator
1003csi_start (cgraph_node_set set)
1004{
1005 cgraph_node_set_iterator csi;
1006
1007 csi.set = set;
1008 csi.index = 0;
1009 return csi;
1010}
1011
1012/* Return true if SET contains NODE. */
1013static inline bool
1014cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1015{
1016 cgraph_node_set_iterator csi;
1017 csi = cgraph_node_set_find (set, node);
1018 return !csi_end_p (csi);
1019}
1020
1021/* Return number of nodes in SET. */
1022static inline size_t
1023cgraph_node_set_size (cgraph_node_set set)
1024{
1cb1a99f 1025 return VEC_length (cgraph_node_ptr, set->nodes);
fed5ae11
DK
1026}
1027
2942c502
JH
1028/* Return true if iterator VSI points to nothing. */
1029static inline bool
1030vsi_end_p (varpool_node_set_iterator vsi)
1031{
1032 return vsi.index >= VEC_length (varpool_node_ptr, vsi.set->nodes);
1033}
1034
1035/* Advance iterator VSI. */
1036static inline void
1037vsi_next (varpool_node_set_iterator *vsi)
1038{
1039 vsi->index++;
1040}
1041
1042/* Return the node pointed to by VSI. */
1043static inline struct varpool_node *
1044vsi_node (varpool_node_set_iterator vsi)
1045{
1046 return VEC_index (varpool_node_ptr, vsi.set->nodes, vsi.index);
1047}
1048
1049/* Return an iterator to the first node in SET. */
1050static inline varpool_node_set_iterator
1051vsi_start (varpool_node_set set)
1052{
1053 varpool_node_set_iterator vsi;
1054
1055 vsi.set = set;
1056 vsi.index = 0;
1057 return vsi;
1058}
1059
1060/* Return true if SET contains NODE. */
1061static inline bool
1062varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
1063{
1064 varpool_node_set_iterator vsi;
1065 vsi = varpool_node_set_find (set, node);
1066 return !vsi_end_p (vsi);
1067}
1068
1069/* Return number of nodes in SET. */
1070static inline size_t
1071varpool_node_set_size (varpool_node_set set)
1072{
1cb1a99f 1073 return VEC_length (varpool_node_ptr, set->nodes);
2942c502
JH
1074}
1075
d48e9cea
OR
1076/* Uniquize all constants that appear in memory.
1077 Each constant in memory thus far output is recorded
1078 in `const_desc_table'. */
1079
1080struct GTY(()) constant_descriptor_tree {
1081 /* A MEM for the constant. */
1082 rtx rtl;
b8698a0f 1083
d48e9cea
OR
1084 /* The value of the constant. */
1085 tree value;
1086
1087 /* Hash of value. Computing the hash from value each time
1088 hashfn is called can't work properly, as that means recursive
1089 use of the hash table during hash table expansion. */
1090 hashval_t hash;
1091};
1092
ace72c88
JH
1093/* Return true if set is nonempty. */
1094static inline bool
1095cgraph_node_set_nonempty_p (cgraph_node_set set)
1096{
9eec9488 1097 return !VEC_empty (cgraph_node_ptr, set->nodes);
ace72c88
JH
1098}
1099
1100/* Return true if set is nonempty. */
1101static inline bool
1102varpool_node_set_nonempty_p (varpool_node_set set)
1103{
9eec9488 1104 return !VEC_empty (varpool_node_ptr, set->nodes);
ace72c88
JH
1105}
1106
be330ed4 1107/* Return true when function NODE is only called directly or it has alias.
b20996ff
JH
1108 i.e. it is not externally visible, address was not taken and
1109 it is not used in any other non-standard way. */
1110
1111static inline bool
be330ed4 1112cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
b20996ff 1113{
530f3a1b 1114 gcc_assert (!node->global.inlined_to);
ead84f73 1115 return (!node->symbol.force_output && !node->symbol.address_taken
960bfb69
JH
1116 && !node->symbol.used_from_other_partition
1117 && !DECL_STATIC_CONSTRUCTOR (node->symbol.decl)
1118 && !DECL_STATIC_DESTRUCTOR (node->symbol.decl)
1119 && !node->symbol.externally_visible);
b20996ff
JH
1120}
1121
df7705b1
JH
1122/* Return true when function NODE can be removed from callgraph
1123 if all direct calls are eliminated. */
1124
1125static inline bool
1126varpool_can_remove_if_no_refs (struct varpool_node *node)
1127{
ead84f73 1128 return (!node->symbol.force_output && !node->symbol.used_from_other_partition
960bfb69 1129 && (DECL_COMDAT (node->symbol.decl)
ead84f73
JH
1130 || !node->symbol.externally_visible
1131 || DECL_EXTERNAL (node->symbol.decl)));
df7705b1
JH
1132}
1133
4a444e58
JH
1134/* Return true when all references to VNODE must be visible in ipa_ref_list.
1135 i.e. if the variable is not externally visible or not used in some magic
1136 way (asm statement or such).
61502ca8 1137 The magic uses are all summarized in force_output flag. */
4a444e58
JH
1138
1139static inline bool
1140varpool_all_refs_explicit_p (struct varpool_node *vnode)
1141{
e8fdf1cd 1142 return (vnode->analyzed
960bfb69
JH
1143 && !vnode->symbol.externally_visible
1144 && !vnode->symbol.used_from_other_partition
ead84f73 1145 && !vnode->symbol.force_output);
4a444e58
JH
1146}
1147
d48e9cea
OR
1148/* Constant pool accessor function. */
1149htab_t constant_pool_htab (void);
fed5ae11 1150
be330ed4
JH
1151/* FIXME: inappropriate dependency of cgraph on IPA. */
1152#include "ipa-ref-inline.h"
1153
39e2db00
JH
1154/* Return node that alias N is aliasing. */
1155
1156static inline struct cgraph_node *
1157cgraph_alias_aliased_node (struct cgraph_node *n)
1158{
1159 struct ipa_ref *ref;
1160
960bfb69 1161 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
39e2db00 1162 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
5932a4d4 1163 if (symtab_function_p (ref->referred))
39e2db00
JH
1164 return ipa_ref_node (ref);
1165 return NULL;
1166}
1167
cd35bcf7
JH
1168/* Return node that alias N is aliasing. */
1169
1170static inline struct varpool_node *
1171varpool_alias_aliased_node (struct varpool_node *n)
1172{
1173 struct ipa_ref *ref;
1174
960bfb69 1175 ipa_ref_list_reference_iterate (&n->symbol.ref_list, 0, ref);
cd35bcf7 1176 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
5932a4d4 1177 if (symtab_variable_p (ref->referred))
cd35bcf7
JH
1178 return ipa_ref_varpool_node (ref);
1179 return NULL;
1180}
1181
be330ed4
JH
1182/* Given NODE, walk the alias chain to return the function NODE is alias of.
1183 Walk through thunk, too.
1184 When AVAILABILITY is non-NULL, get minimal availablity in the chain. */
1185
1186static inline struct cgraph_node *
1187cgraph_function_node (struct cgraph_node *node, enum availability *availability)
1188{
1189 if (availability)
1190 *availability = cgraph_function_body_availability (node);
1191 while (node)
1192 {
39e2db00
JH
1193 if (node->alias && node->analyzed)
1194 node = cgraph_alias_aliased_node (node);
1195 else if (node->thunk.thunk_p)
be330ed4
JH
1196 node = node->callees->callee;
1197 else
1198 return node;
39e2db00 1199 if (node && availability)
be330ed4
JH
1200 {
1201 enum availability a;
1202 a = cgraph_function_body_availability (node);
1203 if (a < *availability)
1204 *availability = a;
1205 }
1206 }
9c7c9f10 1207 if (availability)
39e2db00 1208 *availability = AVAIL_NOT_AVAILABLE;
be330ed4
JH
1209 return NULL;
1210}
1211
1212/* Given NODE, walk the alias chain to return the function NODE is alias of.
1213 Do not walk through thunks.
1214 When AVAILABILITY is non-NULL, get minimal availablity in the chain. */
1215
1216static inline struct cgraph_node *
1217cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability *availability)
1218{
1219 if (availability)
1220 *availability = cgraph_function_body_availability (node);
39e2db00
JH
1221 while (node)
1222 {
1223 if (node->alias && node->analyzed)
1224 node = cgraph_alias_aliased_node (node);
1225 else
1226 return node;
1227 if (node && availability)
1228 {
1229 enum availability a;
1230 a = cgraph_function_body_availability (node);
1231 if (a < *availability)
1232 *availability = a;
1233 }
1234 }
9c7c9f10 1235 if (availability)
39e2db00 1236 *availability = AVAIL_NOT_AVAILABLE;
be330ed4
JH
1237 return NULL;
1238}
1239
cd35bcf7
JH
1240/* Given NODE, walk the alias chain to return the function NODE is alias of.
1241 Do not walk through thunks.
1242 When AVAILABILITY is non-NULL, get minimal availablity in the chain. */
1243
1244static inline struct varpool_node *
1245varpool_variable_node (struct varpool_node *node, enum availability *availability)
1246{
1247 if (availability)
1248 *availability = cgraph_variable_initializer_availability (node);
1249 while (node)
1250 {
1251 if (node->alias && node->analyzed)
1252 node = varpool_alias_aliased_node (node);
1253 else
1254 return node;
1255 if (node && availability)
1256 {
1257 enum availability a;
1258 a = cgraph_variable_initializer_availability (node);
1259 if (a < *availability)
1260 *availability = a;
1261 }
1262 }
9c7c9f10 1263 if (availability)
cd35bcf7
JH
1264 *availability = AVAIL_NOT_AVAILABLE;
1265 return NULL;
1266}
1267
d7d1d041
RG
1268/* Return true when the edge E represents a direct recursion. */
1269static inline bool
1270cgraph_edge_recursive_p (struct cgraph_edge *e)
1271{
be330ed4 1272 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
d7d1d041 1273 if (e->caller->global.inlined_to)
960bfb69 1274 return e->caller->global.inlined_to->symbol.decl == callee->symbol.decl;
d7d1d041 1275 else
960bfb69 1276 return e->caller->symbol.decl == callee->symbol.decl;
d7d1d041 1277}
0a35513e
AH
1278
1279/* Return true if the TM_CLONE bit is set for a given FNDECL. */
1280static inline bool
1281decl_is_tm_clone (const_tree fndecl)
1282{
1283 struct cgraph_node *n = cgraph_get_node (fndecl);
1284 if (n)
1285 return n->tm_clone;
1286 return false;
1287}
1c4a429a 1288#endif /* GCC_CGRAPH_H */