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