]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cgraph.h
tree-ssa-math-opts.c (do_shift_rotate, [...]): Cast 0xff to uint64_t before shifting...
[thirdparty/gcc.git] / gcc / cgraph.h
CommitLineData
1c4a429a 1/* Callgraph handling code.
23a5b65a 2 Copyright (C) 2003-2014 Free Software Foundation, Inc.
1c4a429a
JH
3 Contributed by Jan Hubicka
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9dcd6f09 9Software Foundation; either version 3, or (at your option) any later
1c4a429a
JH
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
1c4a429a
JH
20
21#ifndef GCC_CGRAPH_H
22#define GCC_CGRAPH_H
7a8cba34 23
5d59b5e1 24#include "is-a.h"
051f8cc6 25#include "plugin-api.h"
7a8cba34 26#include "vec.h"
4d648807 27#include "basic-block.h"
7a8cba34 28#include "function.h"
1f00098b
JH
29#include "ipa-ref.h"
30
31/* Symbol table consists of functions and variables.
e70670cf 32 TODO: add labels and CONST_DECLs. */
1f00098b
JH
33enum symtab_type
34{
960bfb69 35 SYMTAB_SYMBOL,
1f00098b
JH
36 SYMTAB_FUNCTION,
37 SYMTAB_VARIABLE
38};
39
f961457f
JH
40/* Section names are stored as reference counted strings in GGC safe hashtable
41 (to make them survive through PCH). */
42
43struct GTY(()) section_hash_entry_d
44{
45 int ref_count;
46 char *name; /* As long as this datastructure stays in GGC, we can not put
47 string at the tail of structure of GGC dies in horrible
48 way */
49};
50
51typedef struct section_hash_entry_d section_hash_entry;
52
1f00098b
JH
53/* Base of all entries in the symbol table.
54 The symtab_node is inherited by cgraph and varpol nodes. */
a3bfa8b8
DM
55class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
56 chain_next ("%h.next"), chain_prev ("%h.previous")))
5e20cdc9 57 symtab_node
1f00098b 58{
a3bfa8b8 59public:
fec39fa6
TS
60 /* Return name. */
61 const char *name () const;
62
63 /* Return asm name. */
64 const char * asm_name () const;
65
1f00098b 66 /* Type of the symbol. */
b8dbdb12
RG
67 ENUM_BITFIELD (symtab_type) type : 8;
68
69 /* The symbols resolution. */
70 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
71
e70670cf
JH
72 /*** Flags representing the symbol type. ***/
73
74 /* True when symbol corresponds to a definition in current unit.
75 set via cgraph_finalize_function or varpool_finalize_decl */
76 unsigned definition : 1;
77 /* True when symbol is an alias.
78 Set by assemble_alias. */
79 unsigned alias : 1;
08346abd
JH
80 /* True when alias is a weakref. */
81 unsigned weakref : 1;
40a7fe1e 82 /* C++ frontend produce same body aliases and extra name aliases for
688010ba 83 virtual functions and vtables that are obviously equivalent.
40a7fe1e
JH
84 Those aliases are bit special, especially because C++ frontend
85 visibility code is so ugly it can not get them right at first time
86 and their visibility needs to be copied from their "masters" at
87 the end of parsing. */
88 unsigned cpp_implicit_alias : 1;
e70670cf
JH
89 /* Set once the definition was analyzed. The list of references and
90 other properties are built during analysis. */
91 unsigned analyzed : 1;
6de88c6a
JH
92 /* Set for write-only variables. */
93 unsigned writeonly : 1;
e70670cf
JH
94
95
96 /*** Visibility and linkage flags. ***/
97
b8dbdb12
RG
98 /* Set when function is visible by other units. */
99 unsigned externally_visible : 1;
4bcfd75c 100 /* The symbol will be assumed to be used in an invisible way (like
edb983b2 101 by an toplevel asm statement). */
b8dbdb12 102 unsigned force_output : 1;
edb983b2
JH
103 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
104 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
105 to static and it does not inhibit optimization. */
106 unsigned forced_by_abi : 1;
702d8703
JH
107 /* True when the name is known to be unique and thus it does not need mangling. */
108 unsigned unique_name : 1;
e257a17c
JH
109 /* Specify whether the section was set by user or by
110 compiler via -ffunction-sections. */
111 unsigned implicit_section : 1;
3d8d0043
MJ
112 /* True when body and other characteristics have been removed by
113 symtab_remove_unreachable_nodes. */
114 unsigned body_removed : 1;
b8dbdb12 115
e70670cf
JH
116 /*** WHOPR Partitioning flags.
117 These flags are used at ltrans stage when only part of the callgraph is
118 available. ***/
b8dbdb12 119
e70670cf
JH
120 /* Set when variable is used from other LTRANS partition. */
121 unsigned used_from_other_partition : 1;
122 /* Set when function is available in the other LTRANS partition.
123 During WPA output it is used to mark nodes that are present in
124 multiple partitions. */
125 unsigned in_other_partition : 1;
b8dbdb12 126
b8dbdb12 127
e70670cf
JH
128
129 /*** other flags. ***/
130
131 /* Set when symbol has address taken. */
132 unsigned address_taken : 1;
133
134
135 /* Ordering of all symtab entries. */
136 int order;
137
138 /* Declaration representing the symbol. */
139 tree decl;
960bfb69 140
2aae7680 141 /* Linked list of symbol table entries starting with symtab_nodes. */
5e20cdc9
DM
142 symtab_node *next;
143 symtab_node *previous;
e70670cf 144
1ab24192 145 /* Linked list of symbols with the same asm name. There may be multiple
e70670cf
JH
146 entries for single symbol name during LTO, because symbols are renamed
147 only after partitioning.
148
149 Because inline clones are kept in the assembler name has, they also produce
150 duplicate entries.
151
152 There are also several long standing bugs where frontends and builtin
153 code produce duplicated decls. */
5e20cdc9
DM
154 symtab_node *next_sharing_asm_name;
155 symtab_node *previous_sharing_asm_name;
2aae7680 156
e70670cf 157 /* Circular list of nodes in the same comdat group if non-NULL. */
5e20cdc9 158 symtab_node *same_comdat_group;
e70670cf 159
aede2c10
JH
160 /* Return comdat group. */
161 tree get_comdat_group ()
162 {
f961457f 163 return x_comdat_group;
aede2c10
JH
164 }
165
d67ff7b7
JM
166 tree get_comdat_group_id ()
167 {
f961457f
JH
168 if (x_comdat_group && TREE_CODE (x_comdat_group) != IDENTIFIER_NODE)
169 x_comdat_group = DECL_ASSEMBLER_NAME (x_comdat_group);
170 return x_comdat_group;
d67ff7b7
JM
171 }
172
aede2c10
JH
173 /* Set comdat group. */
174 void set_comdat_group (tree group)
175 {
24d047a3
JH
176 gcc_checking_assert (!group || TREE_CODE (group) == IDENTIFIER_NODE
177 || DECL_P (group));
f961457f 178 x_comdat_group = group;
24d047a3
JH
179 }
180
e257a17c
JH
181 /* Return section as string. */
182 const char * get_section ()
183 {
f961457f 184 if (!x_section)
e257a17c 185 return NULL;
f961457f 186 return x_section->name;
24d047a3
JH
187 }
188
e70670cf
JH
189 /* Vectors of referring and referenced entities. */
190 struct ipa_ref_list ref_list;
191
40a7fe1e
JH
192 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
193 depending to what was known to frontend on the creation time.
194 Once alias is resolved, this pointer become NULL. */
195 tree alias_target;
196
e70670cf
JH
197 /* File stream where this node is being written to. */
198 struct lto_file_decl_data * lto_file_data;
199
960bfb69 200 PTR GTY ((skip)) aux;
aede2c10
JH
201
202 /* Comdat group the symbol is in. Can be private if GGC allowed that. */
f961457f 203 tree x_comdat_group;
24d047a3
JH
204
205 /* Section name. Again can be private, if allowed. */
f961457f 206 section_hash_entry *x_section;
e257a17c
JH
207
208 /* Set section for symbol and its aliases. */
f961457f
JH
209 void set_section (const char *section);
210 void set_section_for_node (const char *section);
1f00098b 211};
1c4a429a 212
6b02a499
JH
213enum availability
214{
215 /* Not yet set by cgraph_function_body_availability. */
216 AVAIL_UNSET,
217 /* Function body/variable initializer is unknown. */
218 AVAIL_NOT_AVAILABLE,
219 /* Function body/variable initializer is known but might be replaced
220 by a different one from other compilation unit and thus needs to
221 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
222 arbitrary side effects on escaping variables and functions, while
223 like AVAILABLE it might access static variables. */
224 AVAIL_OVERWRITABLE,
225 /* Function body/variable initializer is known and will be used in final
226 program. */
227 AVAIL_AVAILABLE,
228 /* Function body/variable initializer is known and all it's uses are explicitly
229 visible within current unit (ie it's address is never taken and it is not
230 exported to other units).
231 Currently used only for functions. */
232 AVAIL_LOCAL
233};
234
d7f09764
DN
235/* This is the information that is put into the cgraph local structure
236 to recover a function. */
237struct lto_file_decl_data;
238
8a4a83ed 239extern const char * const cgraph_availability_names[];
430c6ceb 240extern const char * const ld_plugin_symbol_resolution_names[];
8a4a83ed 241
6744a6ab
JH
242/* Information about thunk, used only for same body aliases. */
243
244struct GTY(()) cgraph_thunk_info {
245 /* Information about the thunk. */
246 HOST_WIDE_INT fixed_offset;
247 HOST_WIDE_INT virtual_value;
248 tree alias;
249 bool this_adjusting;
250 bool virtual_offset_p;
251 /* Set to true when alias node is thunk. */
252 bool thunk_p;
253};
254
dafc5b82 255/* Information about the function collected locally.
25c84396 256 Available after function is analyzed. */
dafc5b82 257
d1b38208 258struct GTY(()) cgraph_local_info {
e0bb17a8 259 /* Set when function function is visible in current compilation unit only
e2209b03 260 and its address is never taken. */
b4e19405 261 unsigned local : 1;
6674a6ce 262
124f1be6
MJ
263 /* False when there is something makes versioning impossible. */
264 unsigned versionable : 1;
265
61e03ffc
JH
266 /* False when function calling convention and signature can not be changed.
267 This is the case when __builtin_apply_args is used. */
268 unsigned can_change_signature : 1;
269
95c755e9
JH
270 /* True when the function has been originally extern inline, but it is
271 redefined now. */
b4e19405 272 unsigned redefined_extern_inline : 1;
0a35513e
AH
273
274 /* True if the function may enter serial irrevocable mode. */
275 unsigned tm_may_enter_irr : 1;
dafc5b82
JH
276};
277
278/* Information about the function that needs to be computed globally
726a989a 279 once compilation is finished. Available only with -funit-at-a-time. */
dafc5b82 280
d1b38208 281struct GTY(()) cgraph_global_info {
726a989a
RB
282 /* For inline clones this points to the function they will be
283 inlined into. */
18c6ada9 284 struct cgraph_node *inlined_to;
dafc5b82
JH
285};
286
b255a036
JH
287/* Information about the function that is propagated by the RTL backend.
288 Available only for functions that has been already assembled. */
289
d1b38208 290struct GTY(()) cgraph_rtl_info {
17b29c0a 291 unsigned int preferred_incoming_stack_boundary;
27c07cc5
RO
292
293 /* Call unsaved hard registers really used by the corresponding
294 function (including ones used by functions called by the
295 function). */
296 HARD_REG_SET function_used_regs;
297 /* Set if function_used_regs is valid. */
298 unsigned function_used_regs_valid: 1;
b255a036
JH
299};
300
9187e02d
JH
301/* Represent which DECL tree (or reference to such tree)
302 will be replaced by another tree while versioning. */
303struct GTY(()) ipa_replace_map
304{
305 /* The tree that will be replaced. */
306 tree old_tree;
307 /* The new (replacing) tree. */
308 tree new_tree;
922f15c2
JH
309 /* Parameter number to replace, when old_tree is NULL. */
310 int parm_num;
9187e02d
JH
311 /* True when a substitution should be done, false otherwise. */
312 bool replace_p;
313 /* True when we replace a reference to old_tree. */
314 bool ref_p;
315};
316typedef struct ipa_replace_map *ipa_replace_map_p;
9187e02d
JH
317
318struct GTY(()) cgraph_clone_info
319{
9771b263 320 vec<ipa_replace_map_p, va_gc> *tree_map;
9187e02d 321 bitmap args_to_skip;
08ad1d6d 322 bitmap combined_args_to_skip;
9187e02d
JH
323};
324
0136f8f0
AH
325enum cgraph_simd_clone_arg_type
326{
327 SIMD_CLONE_ARG_TYPE_VECTOR,
328 SIMD_CLONE_ARG_TYPE_UNIFORM,
329 SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
330 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
331 SIMD_CLONE_ARG_TYPE_MASK
332};
333
334/* Function arguments in the original function of a SIMD clone.
335 Supplementary data for `struct simd_clone'. */
336
337struct GTY(()) cgraph_simd_clone_arg {
338 /* Original function argument as it originally existed in
339 DECL_ARGUMENTS. */
340 tree orig_arg;
341
342 /* orig_arg's function (or for extern functions type from
343 TYPE_ARG_TYPES). */
344 tree orig_type;
345
346 /* If argument is a vector, this holds the vector version of
347 orig_arg that after adjusting the argument types will live in
348 DECL_ARGUMENTS. Otherwise, this is NULL.
349
350 This basically holds:
351 vector(simdlen) __typeof__(orig_arg) new_arg. */
352 tree vector_arg;
353
354 /* vector_arg's type (or for extern functions new vector type. */
355 tree vector_type;
356
357 /* If argument is a vector, this holds the array where the simd
358 argument is held while executing the simd clone function. This
359 is a local variable in the cloned function. Its content is
360 copied from vector_arg upon entry to the clone.
361
362 This basically holds:
363 __typeof__(orig_arg) simd_array[simdlen]. */
364 tree simd_array;
365
366 /* A SIMD clone's argument can be either linear (constant or
367 variable), uniform, or vector. */
368 enum cgraph_simd_clone_arg_type arg_type;
369
370 /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP this is
371 the constant linear step, if arg_type is
372 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP, this is index of
373 the uniform argument holding the step, otherwise 0. */
374 HOST_WIDE_INT linear_step;
375
376 /* Variable alignment if available, otherwise 0. */
377 unsigned int alignment;
378};
379
380/* Specific data for a SIMD function clone. */
381
382struct GTY(()) cgraph_simd_clone {
383 /* Number of words in the SIMD lane associated with this clone. */
384 unsigned int simdlen;
385
386 /* Number of annotated function arguments in `args'. This is
387 usually the number of named arguments in FNDECL. */
388 unsigned int nargs;
389
390 /* Max hardware vector size in bits for integral vectors. */
391 unsigned int vecsize_int;
392
393 /* Max hardware vector size in bits for floating point vectors. */
394 unsigned int vecsize_float;
395
396 /* The mangling character for a given vector size. This is is used
397 to determine the ISA mangling bit as specified in the Intel
398 Vector ABI. */
399 unsigned char vecsize_mangle;
400
401 /* True if this is the masked, in-branch version of the clone,
402 otherwise false. */
403 unsigned int inbranch : 1;
404
405 /* True if this is a Cilk Plus variant. */
406 unsigned int cilk_elemental : 1;
407
408 /* Doubly linked list of SIMD clones. */
409 struct cgraph_node *prev_clone, *next_clone;
410
411 /* Original cgraph node the SIMD clones were created for. */
412 struct cgraph_node *origin;
413
414 /* Annotated function arguments for the original function. */
415 struct cgraph_simd_clone_arg GTY((length ("%h.nargs"))) args[1];
416};
417
5fefcf92 418
ba228239 419/* The cgraph data structure.
e0bb17a8 420 Each function decl has assigned cgraph_node listing callees and callers. */
1c4a429a 421
5e20cdc9 422struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node {
a3bfa8b8 423public:
1c4a429a
JH
424 struct cgraph_edge *callees;
425 struct cgraph_edge *callers;
e33c6cd6
MJ
426 /* List of edges representing indirect calls with a yet undetermined
427 callee. */
428 struct cgraph_edge *indirect_calls;
1c4a429a 429 /* For nested functions points to function the node is nested in. */
a3bfa8b8 430 struct cgraph_node *origin;
1c4a429a 431 /* Points to first nested function, if any. */
a3bfa8b8 432 struct cgraph_node *nested;
1c4a429a 433 /* Pointer to the next function with same origin, if any. */
a3bfa8b8 434 struct cgraph_node *next_nested;
18c6ada9 435 /* Pointer to the next clone. */
9187e02d
JH
436 struct cgraph_node *next_sibling_clone;
437 struct cgraph_node *prev_sibling_clone;
438 struct cgraph_node *clones;
439 struct cgraph_node *clone_of;
70d539ce
JH
440 /* For functions with many calls sites it holds map from call expression
441 to the edge to speed up cgraph_edge function. */
442 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
97ba0040
JH
443 /* Declaration node used to be clone of. */
444 tree former_clone_of;
c22cacf3 445
0136f8f0
AH
446 /* If this is a SIMD clone, this points to the SIMD specific
447 information for it. */
448 struct cgraph_simd_clone *simdclone;
449 /* If this function has SIMD clones, this points to the first clone. */
450 struct cgraph_node *simd_clones;
451
0e3776db
JH
452 /* Interprocedural passes scheduled to have their transform functions
453 applied next time we execute local pass on them. We maintain it
454 per-function in order to allow IPA passes to introduce new functions. */
9771b263 455 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
0e3776db 456
95c755e9
JH
457 struct cgraph_local_info local;
458 struct cgraph_global_info global;
459 struct cgraph_rtl_info rtl;
9187e02d 460 struct cgraph_clone_info clone;
6744a6ab 461 struct cgraph_thunk_info thunk;
c22cacf3 462
e42922b1
JH
463 /* Expected number of executions: calculated in profile.c. */
464 gcov_type count;
db0bf14f
JH
465 /* How to scale counts at materialization time; used to merge
466 LTO units with different number of profile runs. */
467 int count_materialization_scale;
95c755e9
JH
468 /* Unique id of the node. */
469 int uid;
2fa3d31b
JH
470 /* ID assigned by the profiling. */
471 unsigned int profile_id;
86ce5d2f
ML
472 /* Time profiler: first run of function. */
473 int tp_first_run;
3691626c 474
6b20f353
DS
475 /* Set when decl is an abstract function pointed to by the
476 ABSTRACT_DECL_ORIGIN of a reachable function. */
c0c123ef 477 unsigned used_as_abstract_origin : 1;
50674e96 478 /* Set once the function is lowered (i.e. its CFG is built). */
b4e19405 479 unsigned lowered : 1;
25c84396
RH
480 /* Set once the function has been instantiated and its callee
481 lists created. */
257eb6e3 482 unsigned process : 1;
5fefcf92
JH
483 /* How commonly executed the node is. Initialized during branch
484 probabilities pass. */
485 ENUM_BITFIELD (node_frequency) frequency : 2;
844db5d0
JH
486 /* True when function can only be called at startup (from static ctor). */
487 unsigned only_called_at_startup : 1;
488 /* True when function can only be called at startup (from static dtor). */
489 unsigned only_called_at_exit : 1;
0a35513e
AH
490 /* True when function is the transactional clone of a function which
491 is called only from inside transactions. */
492 /* ?? We should be able to remove this. We have enough bits in
493 cgraph to calculate it. */
494 unsigned tm_clone : 1;
3649b9b7
ST
495 /* True if this decl is a dispatcher for function versions. */
496 unsigned dispatcher_function : 1;
1f26ac87
JM
497 /* True if this decl calls a COMDAT-local function. This is set up in
498 compute_inline_parameters and inline_call. */
499 unsigned calls_comdat_local : 1;
1c4a429a
JH
500};
501
7380e6ef 502
fed5ae11
DK
503typedef struct cgraph_node *cgraph_node_ptr;
504
fed5ae11 505
3649b9b7
ST
506/* Function Multiversioning info. */
507struct GTY(()) cgraph_function_version_info {
508 /* The cgraph_node for which the function version info is stored. */
509 struct cgraph_node *this_node;
510 /* Chains all the semantically identical function versions. The
511 first function in this chain is the version_info node of the
512 default function. */
513 struct cgraph_function_version_info *prev;
514 /* If this version node corresponds to a dispatcher for function
515 versions, this points to the version info node of the default
516 function, the first node in the chain. */
517 struct cgraph_function_version_info *next;
518 /* If this node corresponds to a function version, this points
519 to the dispatcher function decl, which is the function that must
520 be called to execute the right function version at run-time.
521
522 If this cgraph node is a dispatcher (if dispatcher_function is
523 true, in the cgraph_node struct) for function versions, this
524 points to resolver function, which holds the function body of the
525 dispatcher. The dispatcher decl is an alias to the resolver
526 function decl. */
527 tree dispatcher_resolver;
528};
529
530/* Get the cgraph_function_version_info node corresponding to node. */
531struct cgraph_function_version_info *
532 get_cgraph_node_version (struct cgraph_node *node);
533
534/* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
535 corresponding to cgraph_node NODE. */
536struct cgraph_function_version_info *
537 insert_new_cgraph_node_version (struct cgraph_node *node);
538
539/* Record that DECL1 and DECL2 are semantically identical function
540 versions. */
541void record_function_versions (tree decl1, tree decl2);
542
543/* Remove the cgraph_function_version_info and cgraph_node for DECL. This
544 DECL is a duplicate declaration. */
545void delete_function_version (tree decl);
546
fed5ae11
DK
547/* A cgraph node set is a collection of cgraph nodes. A cgraph node
548 can appear in multiple sets. */
1cb1a99f 549struct cgraph_node_set_def
fed5ae11 550{
1cb1a99f 551 struct pointer_map_t *map;
9771b263 552 vec<cgraph_node_ptr> nodes;
fed5ae11
DK
553};
554
2c8326a5
OE
555class varpool_node;
556typedef varpool_node *varpool_node_ptr;
2942c502 557
2942c502
JH
558
559/* A varpool node set is a collection of varpool nodes. A varpool node
560 can appear in multiple sets. */
1cb1a99f 561struct varpool_node_set_def
2942c502 562{
1cb1a99f 563 struct pointer_map_t * map;
9771b263 564 vec<varpool_node_ptr> nodes;
2942c502
JH
565};
566
fed5ae11
DK
567typedef struct cgraph_node_set_def *cgraph_node_set;
568
fed5ae11 569
2942c502
JH
570typedef struct varpool_node_set_def *varpool_node_set;
571
2942c502 572
fed5ae11 573/* Iterator structure for cgraph node sets. */
84562394 574struct cgraph_node_set_iterator
fed5ae11
DK
575{
576 cgraph_node_set set;
577 unsigned index;
84562394 578};
fed5ae11 579
2942c502 580/* Iterator structure for varpool node sets. */
84562394 581struct varpool_node_set_iterator
2942c502
JH
582{
583 varpool_node_set set;
584 unsigned index;
84562394 585};
2942c502 586
1cf11770 587#define DEFCIFCODE(code, type, string) CIF_ ## code,
61a05df1 588/* Reasons for inlining failures. */
84562394 589enum cgraph_inline_failed_t {
61a05df1
JH
590#include "cif-code.def"
591 CIF_N_REASONS
84562394 592};
61a05df1 593
1cf11770
L
594enum cgraph_inline_failed_type_t
595{
596 CIF_FINAL_NORMAL = 0,
597 CIF_FINAL_ERROR
598};
599
e33c6cd6
MJ
600/* Structure containing additional information about an indirect call. */
601
602struct GTY(()) cgraph_indirect_call_info
603{
8b7773a4
MJ
604 /* When polymorphic is set, this field contains offset where the object which
605 was actually used in the polymorphic resides within a larger structure.
606 If agg_contents is set, the field contains the offset within the aggregate
607 from which the address to call was loaded. */
608 HOST_WIDE_INT offset;
b258210c
MJ
609 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
610 HOST_WIDE_INT otr_token;
611 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
68377e53 612 tree otr_type, outer_type;
e33c6cd6
MJ
613 /* Index of the parameter that is called. */
614 int param_index;
5f902d76
JH
615 /* ECF flags determined from the caller. */
616 int ecf_flags;
634ab819
JH
617 /* Profile_id of common target obtrained from profile. */
618 int common_target_id;
619 /* Probability that call will land in function with COMMON_TARGET_ID. */
620 int common_target_probability;
b258210c
MJ
621
622 /* Set when the call is a virtual call with the parameter being the
623 associated object pointer rather than a simple direct call. */
624 unsigned polymorphic : 1;
8b7773a4
MJ
625 /* Set when the call is a call of a pointer loaded from contents of an
626 aggregate at offset. */
627 unsigned agg_contents : 1;
c13bc3d9
MJ
628 /* Set when this is a call through a member pointer. */
629 unsigned member_ptr : 1;
8b7773a4
MJ
630 /* When the previous bit is set, this one determines whether the destination
631 is loaded from a parameter passed by reference. */
632 unsigned by_ref : 1;
68377e53
JH
633 unsigned int maybe_in_construction : 1;
634 unsigned int maybe_derived_type : 1;
e33c6cd6
MJ
635};
636
d1b38208 637struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
6009ee7b
MJ
638 /* Expected number of executions: calculated in profile.c. */
639 gcov_type count;
ed2df68b
JH
640 struct cgraph_node *caller;
641 struct cgraph_node *callee;
2563c224 642 struct cgraph_edge *prev_caller;
1c4a429a 643 struct cgraph_edge *next_caller;
2563c224 644 struct cgraph_edge *prev_callee;
1c4a429a 645 struct cgraph_edge *next_callee;
726a989a 646 gimple call_stmt;
e33c6cd6
MJ
647 /* Additional information about an indirect call. Not cleared when an edge
648 becomes direct. */
649 struct cgraph_indirect_call_info *indirect_info;
18c6ada9 650 PTR GTY ((skip (""))) aux;
61a05df1
JH
651 /* When equal to CIF_OK, inline this call. Otherwise, points to the
652 explanation why function was not inlined. */
84562394 653 enum cgraph_inline_failed_t inline_failed;
6009ee7b
MJ
654 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
655 when the function is serialized in. */
656 unsigned int lto_stmt_uid;
b8698a0f 657 /* Expected frequency of executions within the function.
45a80bb9
JH
658 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
659 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
660 int frequency;
6009ee7b
MJ
661 /* Unique id of the edge. */
662 int uid;
e33c6cd6
MJ
663 /* Whether this edge was made direct by indirect inlining. */
664 unsigned int indirect_inlining_edge : 1;
665 /* Whether this edge describes an indirect call with an undetermined
666 callee. */
667 unsigned int indirect_unknown_callee : 1;
668 /* Whether this edge is still a dangling */
d7f09764
DN
669 /* True if the corresponding CALL stmt cannot be inlined. */
670 unsigned int call_stmt_cannot_inline_p : 1;
2505c5ed
JH
671 /* Can this call throw externally? */
672 unsigned int can_throw_external : 1;
042ae7d2
JH
673 /* Edges with SPECULATIVE flag represents indirect calls that was
674 speculatively turned into direct (i.e. by profile feedback).
675 The final code sequence will have form:
676
677 if (call_target == expected_fn)
678 expected_fn ();
679 else
680 call_target ();
681
682 Every speculative call is represented by three components attached
683 to a same call statement:
684 1) a direct call (to expected_fn)
685 2) an indirect call (to call_target)
686 3) a IPA_REF_ADDR refrence to expected_fn.
687
688 Optimizers may later redirect direct call to clone, so 1) and 3)
689 do not need to necesarily agree with destination. */
690 unsigned int speculative : 1;
1c4a429a
JH
691};
692
45a80bb9
JH
693#define CGRAPH_FREQ_BASE 1000
694#define CGRAPH_FREQ_MAX 100000
695
b2c0ad40
KH
696typedef struct cgraph_edge *cgraph_edge_p;
697
b2c0ad40 698
8a4a83ed
JH
699/* The varpool data structure.
700 Each static variable decl has assigned varpool_node. */
e69529cd 701
5e20cdc9 702class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node {
a3bfa8b8 703public:
6b02a499 704 /* Set when variable is scheduled to be assembled. */
b4e19405 705 unsigned output : 1;
eb1d8159 706
59b36ecf
JJ
707 /* Set if the variable is dynamically initialized, except for
708 function local statics. */
709 unsigned dynamically_initialized : 1;
56363ffd
JH
710
711 ENUM_BITFIELD(tls_model) tls_model : 3;
e69529cd
JH
712};
713
65d630d4 714/* Every top level asm statement is put into a asm_node. */
474eccc6 715
65d630d4 716struct GTY(()) asm_node {
474eccc6 717 /* Next asm node. */
65d630d4 718 struct asm_node *next;
474eccc6
ILT
719 /* String for this asm node. */
720 tree asm_str;
721 /* Ordering of all cgraph nodes. */
722 int order;
723};
724
5d59b5e1
LC
725/* Report whether or not THIS symtab node is a function, aka cgraph_node. */
726
727template <>
728template <>
729inline bool
7de90a6c 730is_a_helper <cgraph_node *>::test (symtab_node *p)
5d59b5e1 731{
67348ccc 732 return p->type == SYMTAB_FUNCTION;
5d59b5e1
LC
733}
734
735/* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
736
737template <>
738template <>
739inline bool
7de90a6c 740is_a_helper <varpool_node *>::test (symtab_node *p)
5d59b5e1 741{
67348ccc 742 return p->type == SYMTAB_VARIABLE;
5d59b5e1
LC
743}
744
5e20cdc9 745extern GTY(()) symtab_node *symtab_nodes;
ed2df68b 746extern GTY(()) int cgraph_n_nodes;
b58b1157 747extern GTY(()) int cgraph_max_uid;
9088c1cc 748extern GTY(()) int cgraph_edge_max_uid;
dafc5b82 749extern bool cgraph_global_info_ready;
f45e0ad1
JH
750enum cgraph_state
751{
66058468
JH
752 /* Frontend is parsing and finalizing functions. */
753 CGRAPH_STATE_PARSING,
f45e0ad1
JH
754 /* Callgraph is being constructed. It is safe to add new functions. */
755 CGRAPH_STATE_CONSTRUCTION,
ca0f62a8
JH
756 /* Callgraph is being at LTO time. */
757 CGRAPH_LTO_STREAMING,
f45e0ad1
JH
758 /* Callgraph is built and IPA passes are being run. */
759 CGRAPH_STATE_IPA,
7a388ee4
JH
760 /* Callgraph is built and all functions are transformed to SSA form. */
761 CGRAPH_STATE_IPA_SSA,
f45e0ad1
JH
762 /* Functions are now ordered and being passed to RTL expanders. */
763 CGRAPH_STATE_EXPANSION,
764 /* All cgraph expansion is done. */
765 CGRAPH_STATE_FINISHED
766};
767extern enum cgraph_state cgraph_state;
e7d6beb0 768extern bool cgraph_function_flags_ready;
66058468 769extern cgraph_node_set cgraph_new_nodes;
1c4a429a 770
65d630d4 771extern GTY(()) struct asm_node *asm_nodes;
2aae7680 772extern GTY(()) int symtab_order;
40a7fe1e 773extern bool cpp_implicit_aliases_done;
e69529cd 774
96451279
JH
775/* Classifcation of symbols WRT partitioning. */
776enum symbol_partitioning_class
777{
778 /* External declarations are ignored by partitioning algorithms and they are
779 added into the boundary later via compute_ltrans_boundary. */
780 SYMBOL_EXTERNAL,
781 /* Partitioned symbols are pur into one of partitions. */
782 SYMBOL_PARTITION,
783 /* Duplicated symbols (such as comdat or constant pool references) are
784 copied into every node needing them via add_symbol_to_partition. */
785 SYMBOL_DUPLICATE
786};
787
788
2aae7680 789/* In symtab.c */
5e20cdc9
DM
790void symtab_register_node (symtab_node *);
791void symtab_unregister_node (symtab_node *);
7b3376a0 792void symtab_remove_from_same_comdat_group (symtab_node *);
5e20cdc9 793void symtab_remove_node (symtab_node *);
5e20cdc9 794symtab_node *symtab_node_for_asm (const_tree asmname);
5e20cdc9
DM
795void symtab_add_to_same_comdat_group (symtab_node *, symtab_node *);
796void symtab_dissolve_same_comdat_group_list (symtab_node *node);
8f940ee6
JH
797void dump_symtab (FILE *);
798void debug_symtab (void);
5e20cdc9
DM
799void dump_symtab_node (FILE *, symtab_node *);
800void debug_symtab_node (symtab_node *);
801void dump_symtab_base (FILE *, symtab_node *);
474ffc72 802void verify_symtab (void);
5e20cdc9
DM
803void verify_symtab_node (symtab_node *);
804bool verify_symtab_base (symtab_node *);
805bool symtab_used_from_object_file_p (symtab_node *);
65d630d4 806void symtab_make_decl_local (tree);
5e20cdc9 807symtab_node *symtab_alias_ultimate_target (symtab_node *,
40a7fe1e 808 enum availability *avail = NULL);
5e20cdc9
DM
809bool symtab_resolve_alias (symtab_node *node, symtab_node *target);
810void fixup_same_cpp_alias_visibility (symtab_node *node, symtab_node *target);
811bool symtab_for_node_and_aliases (symtab_node *,
812 bool (*) (symtab_node *, void *),
af15184a
JH
813 void *,
814 bool);
5e20cdc9
DM
815symtab_node *symtab_nonoverwritable_alias (symtab_node *);
816enum availability symtab_node_availability (symtab_node *);
817bool symtab_semantically_equivalent_p (symtab_node *, symtab_node *);
96451279 818enum symbol_partitioning_class symtab_get_symbol_partitioning_class (symtab_node *);
2aae7680 819
1c4a429a 820/* In cgraph.c */
439f7bc3 821void dump_cgraph (FILE *);
c4e622b6 822void debug_cgraph (void);
18c6ada9 823void dump_cgraph_node (FILE *, struct cgraph_node *);
c4e622b6 824void debug_cgraph_node (struct cgraph_node *);
18c6ada9 825void cgraph_remove_edge (struct cgraph_edge *);
439f7bc3 826void cgraph_remove_node (struct cgraph_node *);
3a40c18a 827void cgraph_release_function_body (struct cgraph_node *);
12123452 828void release_function_body (tree);
2563c224 829void cgraph_node_remove_callees (struct cgraph_node *node);
18c6ada9
JH
830struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
831 struct cgraph_node *,
898b8927 832 gimple, gcov_type, int);
ce47fda3 833struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
898b8927 834 int, gcov_type, int);
ce47fda3 835struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
a358e188 836struct cgraph_node * cgraph_create_node (tree);
66a20fc2 837struct cgraph_node * cgraph_create_empty_node (void);
a358e188 838struct cgraph_node * cgraph_get_create_node (tree);
87e7b310
JH
839struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
840struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
051f8cc6 841 HOST_WIDE_INT, tree, tree);
4537ec0c 842struct cgraph_node *cgraph_node_for_asm (tree);
726a989a 843struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
042ae7d2 844void cgraph_set_call_stmt (struct cgraph_edge *, gimple, bool update_speculative = true);
4b685e14 845void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
439f7bc3
AJ
846struct cgraph_local_info *cgraph_local_info (tree);
847struct cgraph_global_info *cgraph_global_info (tree);
848struct cgraph_rtl_info *cgraph_rtl_info (tree);
39e2db00 849struct cgraph_node *cgraph_create_function_alias (tree, tree);
66a20fc2
JH
850void cgraph_call_node_duplication_hooks (struct cgraph_node *,
851 struct cgraph_node *);
852void cgraph_call_edge_duplication_hooks (struct cgraph_edge *,
853 struct cgraph_edge *);
1c4a429a 854
18c6ada9 855void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
042ae7d2 856struct cgraph_edge *cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
be330ed4 857bool cgraph_only_called_directly_p (struct cgraph_node *);
e69529cd 858
1bb17c21 859bool cgraph_function_possibly_inlined_p (tree);
e42922b1 860void cgraph_unnest_node (struct cgraph_node *);
1bb17c21 861
6b02a499 862enum availability cgraph_function_body_availability (struct cgraph_node *);
f45e0ad1 863void cgraph_add_new_function (tree, bool);
61a05df1 864const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
1cf11770 865cgraph_inline_failed_type_t cgraph_inline_failed_type (cgraph_inline_failed_t);
6b02a499 866
20cdc2be 867void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
530f3a1b
JH
868void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
869void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
d56026c2
JH
870bool cgraph_node_cannot_return (struct cgraph_node *);
871bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
508e4757
JH
872bool cgraph_will_be_removed_from_program_if_no_direct_calls
873 (struct cgraph_node *node);
874bool cgraph_can_remove_if_no_direct_calls_and_refs_p
875 (struct cgraph_node *node);
9aa3f5c5 876bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node);
be330ed4 877bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution);
be330ed4
JH
878bool cgraph_for_node_thunks_and_aliases (struct cgraph_node *,
879 bool (*) (struct cgraph_node *, void *),
880 void *,
881 bool);
882bool cgraph_for_node_and_aliases (struct cgraph_node *,
883 bool (*) (struct cgraph_node *, void *),
884 void *, bool);
9771b263 885vec<cgraph_edge_p> collect_callers_of_node (struct cgraph_node *node);
18c6ada9
JH
886void verify_cgraph (void);
887void verify_cgraph_node (struct cgraph_node *);
9c8305f8 888void cgraph_mark_address_taken_node (struct cgraph_node *);
d7f09764 889
9088c1cc
MJ
890typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
891typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
2c8326a5 892typedef void (*varpool_node_hook)(varpool_node *, void *);
9088c1cc
MJ
893typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
894 void *);
895typedef void (*cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *,
896 void *);
897struct cgraph_edge_hook_list;
898struct cgraph_node_hook_list;
26e5b0fd 899struct varpool_node_hook_list;
9088c1cc
MJ
900struct cgraph_2edge_hook_list;
901struct cgraph_2node_hook_list;
902struct cgraph_edge_hook_list *cgraph_add_edge_removal_hook (cgraph_edge_hook, void *);
903void cgraph_remove_edge_removal_hook (struct cgraph_edge_hook_list *);
904struct cgraph_node_hook_list *cgraph_add_node_removal_hook (cgraph_node_hook,
905 void *);
906void cgraph_remove_node_removal_hook (struct cgraph_node_hook_list *);
26e5b0fd
JH
907struct varpool_node_hook_list *varpool_add_node_removal_hook (varpool_node_hook,
908 void *);
909void varpool_remove_node_removal_hook (struct varpool_node_hook_list *);
129a37fc
JH
910struct cgraph_node_hook_list *cgraph_add_function_insertion_hook (cgraph_node_hook,
911 void *);
912void cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *);
26e5b0fd
JH
913struct varpool_node_hook_list *varpool_add_variable_insertion_hook (varpool_node_hook,
914 void *);
915void varpool_remove_variable_insertion_hook (struct varpool_node_hook_list *);
129a37fc 916void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
9088c1cc
MJ
917struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
918void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
919struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
920void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
8132a837 921gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
40a7fe1e
JH
922struct cgraph_node * cgraph_function_node (struct cgraph_node *,
923 enum availability *avail = NULL);
a2e2a668 924bool cgraph_get_body (struct cgraph_node *node);
09ce3660 925struct cgraph_edge *
042ae7d2
JH
926cgraph_turn_edge_to_speculative (struct cgraph_edge *,
927 struct cgraph_node *,
928 gcov_type, int);
929void cgraph_speculative_call_info (struct cgraph_edge *,
930 struct cgraph_edge *&,
931 struct cgraph_edge *&,
932 struct ipa_ref *&);
4484a35a 933extern bool gimple_check_call_matching_types (gimple, tree, bool);
9c8305f8
JH
934
935/* In cgraphunit.c */
65d630d4 936struct asm_node *add_asm_node (tree);
9c8305f8
JH
937extern FILE *cgraph_dump_file;
938void cgraph_finalize_function (tree, bool);
65d630d4
JH
939void finalize_compilation_unit (void);
940void compile (void);
9c8305f8 941void init_cgraph (void);
b4d05578 942void cgraph_process_new_functions (void);
66a20fc2 943void cgraph_process_same_body_aliases (void);
5e20cdc9 944void fixup_same_cpp_alias_visibility (symtab_node *, symtab_node *target, tree);
3649b9b7
ST
945/* Initialize datastructures so DECL is a function in lowered gimple form.
946 IN_SSA is true if the gimple is in SSA. */
e70670cf
JH
947basic_block init_lowered_empty_function (tree, bool);
948void cgraph_reset_node (struct cgraph_node *);
d211e471 949bool expand_thunk (struct cgraph_node *, bool, bool);
8be2dc8c
ML
950void cgraph_make_wrapper (struct cgraph_node *source,
951 struct cgraph_node *target);
66a20fc2
JH
952
953/* In cgraphclones.c */
954
955struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
956 struct cgraph_node *, gimple,
957 unsigned, gcov_type, int, bool);
958struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
9771b263 959 int, bool, vec<cgraph_edge_p>,
610c8ef0 960 bool, struct cgraph_node *, bitmap);
66a20fc2
JH
961tree clone_function_name (tree decl, const char *);
962struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
9771b263
DN
963 vec<cgraph_edge_p>,
964 vec<ipa_replace_map_p, va_gc> *tree_map,
66a20fc2
JH
965 bitmap args_to_skip,
966 const char *clone_name);
967struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
968bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
042ae7d2
JH
969void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple,
970 bool update_speculative = true);
66a20fc2
JH
971void cgraph_create_edge_including_clones (struct cgraph_node *,
972 struct cgraph_node *,
973 gimple, gimple, gcov_type, int,
974 cgraph_inline_failed_t);
975void cgraph_materialize_all_clones (void);
9c8305f8 976struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
9771b263 977 tree, vec<cgraph_edge_p>, bitmap);
9c8305f8 978struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
9771b263
DN
979 vec<cgraph_edge_p>,
980 vec<ipa_replace_map_p, va_gc> *,
9c8305f8
JH
981 bitmap, bool, bitmap,
982 basic_block, const char *);
9771b263 983void tree_function_versioning (tree, tree, vec<ipa_replace_map_p, va_gc> *,
9c8305f8 984 bool, bitmap, bool, bitmap, basic_block);
09ce3660 985struct cgraph_edge *cgraph_resolve_speculation (struct cgraph_edge *, tree);
9c8305f8 986
917948d3
ZD
987/* In cgraphbuild.c */
988unsigned int rebuild_cgraph_edges (void);
99b766fc 989void cgraph_rebuild_references (void);
9187e02d 990int compute_call_stmt_bb_frequency (tree, basic_block bb);
9c8305f8 991void record_references_in_initializer (tree, bool);
82338059 992void ipa_record_stmt_references (struct cgraph_node *, gimple);
917948d3 993
ca31b95f 994/* In ipa.c */
04142cc3 995bool symtab_remove_unreachable_nodes (bool, FILE *);
fed5ae11
DK
996cgraph_node_set cgraph_node_set_new (void);
997cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
998 struct cgraph_node *);
999void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
1000void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
1001void dump_cgraph_node_set (FILE *, cgraph_node_set);
1002void debug_cgraph_node_set (cgraph_node_set);
1cb1a99f 1003void free_cgraph_node_set (cgraph_node_set);
9c8305f8 1004void cgraph_build_static_cdtor (char which, tree body, int priority);
fed5ae11 1005
2942c502
JH
1006varpool_node_set varpool_node_set_new (void);
1007varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
2c8326a5
OE
1008 varpool_node *);
1009void varpool_node_set_add (varpool_node_set, varpool_node *);
1010void varpool_node_set_remove (varpool_node_set, varpool_node *);
2942c502
JH
1011void dump_varpool_node_set (FILE *, varpool_node_set);
1012void debug_varpool_node_set (varpool_node_set);
1cb1a99f 1013void free_varpool_node_set (varpool_node_set);
4a444e58 1014void ipa_discover_readonly_nonaddressable_vars (void);
2c8326a5 1015bool varpool_externally_visible_p (varpool_node *);
ca31b95f 1016
7f7beb3f
JH
1017/* In ipa-visibility.c */
1018bool cgraph_local_node_p (struct cgraph_node *);
d211e471 1019bool address_taken_from_non_vtable_p (symtab_node *node);
7f7beb3f
JH
1020
1021
fed5ae11 1022/* In predict.c */
ca30a539 1023bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
e6416b30 1024bool cgraph_optimize_for_size_p (struct cgraph_node *);
ca30a539 1025
8a4a83ed 1026/* In varpool.c */
2c8326a5
OE
1027varpool_node *varpool_create_empty_node (void);
1028varpool_node *varpool_node_for_decl (tree);
1029varpool_node *varpool_node_for_asm (tree asmname);
1030void varpool_mark_needed_node (varpool_node *);
d85478c2 1031void debug_varpool (void);
8a4a83ed 1032void dump_varpool (FILE *);
2c8326a5 1033void dump_varpool_node (FILE *, varpool_node *);
8a4a83ed
JH
1034
1035void varpool_finalize_decl (tree);
2c8326a5 1036enum availability cgraph_variable_initializer_availability (varpool_node *);
a550d677
MJ
1037void cgraph_make_node_local (struct cgraph_node *);
1038bool cgraph_node_can_be_local_p (struct cgraph_node *);
8a4a83ed 1039
2942c502 1040
2c8326a5
OE
1041void varpool_remove_node (varpool_node *node);
1042void varpool_finalize_named_section_flags (varpool_node *node);
65d630d4 1043bool varpool_output_variables (void);
2c8326a5
OE
1044bool varpool_assemble_decl (varpool_node *node);
1045void varpool_analyze_node (varpool_node *);
1046varpool_node * varpool_extra_name_alias (tree, tree);
1047varpool_node * varpool_create_variable_alias (tree, tree);
b34fd25c 1048void varpool_reset_queue (void);
6a6dac52 1049tree ctor_for_folding (tree);
2c8326a5
OE
1050bool varpool_for_node_and_aliases (varpool_node *,
1051 bool (*) (varpool_node *, void *),
cd35bcf7 1052 void *, bool);
38877e98 1053void varpool_add_new_variable (tree);
b5493fb2 1054void symtab_initialize_asm_name_hash (void);
5e20cdc9 1055void symtab_prevail_in_asm_name_hash (symtab_node *node);
2c8326a5 1056void varpool_remove_initializer (varpool_node *);
8a4a83ed 1057
d8a2d370
DN
1058/* In cgraph.c */
1059extern void change_decl_assembler_name (tree, tree);
68e56cc4 1060
aede2c10
JH
1061/* Return symbol table node associated with DECL, if any,
1062 and NULL otherwise. */
1063
1064static inline symtab_node *
1065symtab_get_node (const_tree decl)
1066{
1067#ifdef ENABLE_CHECKING
1068 /* Check that we are called for sane type of object - functions
1069 and static or external variables. */
1070 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
1071 || (TREE_CODE (decl) == VAR_DECL
1072 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
1073 || in_lto_p)));
1074 /* Check that the mapping is sane - perhaps this check can go away,
1075 but at the moment frontends tends to corrupt the mapping by calling
1076 memcpy/memset on the tree nodes. */
1077 gcc_checking_assert (!decl->decl_with_vis.symtab_node
1078 || decl->decl_with_vis.symtab_node->decl == decl);
1079#endif
1080 return decl->decl_with_vis.symtab_node;
1081}
1082
1f00098b
JH
1083/* Return callgraph node for given symbol and check it is a function. */
1084static inline struct cgraph_node *
5e20cdc9 1085cgraph (symtab_node *node)
1f00098b 1086{
67348ccc 1087 gcc_checking_assert (!node || node->type == SYMTAB_FUNCTION);
1ab24192 1088 return (struct cgraph_node *)node;
1f00098b
JH
1089}
1090
1091/* Return varpool node for given symbol and check it is a variable. */
2c8326a5 1092static inline varpool_node *
5e20cdc9 1093varpool (symtab_node *node)
1f00098b 1094{
67348ccc 1095 gcc_checking_assert (!node || node->type == SYMTAB_VARIABLE);
2c8326a5 1096 return (varpool_node *)node;
1f00098b
JH
1097}
1098
1ab24192
JH
1099/* Return callgraph node for given symbol and check it is a function. */
1100static inline struct cgraph_node *
1101cgraph_get_node (const_tree decl)
1102{
1103 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
1104 return cgraph (symtab_get_node (decl));
1105}
1106
1107/* Return varpool node for given symbol and check it is a function. */
2c8326a5 1108static inline varpool_node *
1ab24192
JH
1109varpool_get_node (const_tree decl)
1110{
1111 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
1112 return varpool (symtab_get_node (decl));
1113}
1114
1115/* Walk all symbols. */
1116#define FOR_EACH_SYMBOL(node) \
67348ccc 1117 for ((node) = symtab_nodes; (node); (node) = (node)->next)
1f00098b 1118
d6d229c6
JH
1119/* Return first static symbol with definition. */
1120static inline symtab_node *
1121symtab_first_defined_symbol (void)
1122{
1123 symtab_node *node;
1124
1125 for (node = symtab_nodes; node; node = node->next)
1126 if (node->definition)
1127 return node;
1128
1129 return NULL;
1130}
1131
1132/* Return next reachable static symbol with initializer after NODE. */
1133static inline symtab_node *
1134symtab_next_defined_symbol (symtab_node *node)
1135{
1136 symtab_node *node1 = node->next;
1137
1138 for (; node1; node1 = node1->next)
1139 if (node1->definition)
1140 return node1;
1141
1142 return NULL;
1143}
1144/* Walk all symbols with definitions in current unit. */
1145#define FOR_EACH_DEFINED_SYMBOL(node) \
1146 for ((node) = symtab_first_defined_symbol (); (node); \
1147 (node) = symtab_next_defined_symbol (node))
66058468
JH
1148
1149/* Return first variable. */
2c8326a5 1150static inline varpool_node *
66058468
JH
1151varpool_first_variable (void)
1152{
5e20cdc9 1153 symtab_node *node;
67348ccc 1154 for (node = symtab_nodes; node; node = node->next)
7de90a6c 1155 if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
5d59b5e1 1156 return vnode;
66058468
JH
1157 return NULL;
1158}
1159
1160/* Return next variable after NODE. */
2c8326a5
OE
1161static inline varpool_node *
1162varpool_next_variable (varpool_node *node)
66058468 1163{
5e20cdc9 1164 symtab_node *node1 = node->next;
67348ccc 1165 for (; node1; node1 = node1->next)
7de90a6c 1166 if (varpool_node *vnode1 = dyn_cast <varpool_node *> (node1))
5d59b5e1 1167 return vnode1;
66058468
JH
1168 return NULL;
1169}
1170/* Walk all variables. */
1171#define FOR_EACH_VARIABLE(node) \
1172 for ((node) = varpool_first_variable (); \
1173 (node); \
1174 (node) = varpool_next_variable ((node)))
1175
d6d229c6 1176/* Return first static variable with initializer. */
2c8326a5 1177static inline varpool_node *
68e56cc4
JH
1178varpool_first_static_initializer (void)
1179{
5e20cdc9 1180 symtab_node *node;
67348ccc 1181 for (node = symtab_nodes; node; node = node->next)
68e56cc4 1182 {
7de90a6c 1183 varpool_node *vnode = dyn_cast <varpool_node *> (node);
67348ccc 1184 if (vnode && DECL_INITIAL (node->decl))
5d59b5e1 1185 return vnode;
68e56cc4
JH
1186 }
1187 return NULL;
1188}
1189
d6d229c6 1190/* Return next static variable with initializer after NODE. */
2c8326a5
OE
1191static inline varpool_node *
1192varpool_next_static_initializer (varpool_node *node)
68e56cc4 1193{
5e20cdc9 1194 symtab_node *node1 = node->next;
67348ccc 1195 for (; node1; node1 = node1->next)
68e56cc4 1196 {
7de90a6c 1197 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
67348ccc 1198 if (vnode1 && DECL_INITIAL (node1->decl))
5d59b5e1 1199 return vnode1;
68e56cc4
JH
1200 }
1201 return NULL;
1202}
1203
1204/* Walk all static variables with initializer set. */
1205#define FOR_EACH_STATIC_INITIALIZER(node) \
1206 for ((node) = varpool_first_static_initializer (); (node); \
1207 (node) = varpool_next_static_initializer (node))
2aae7680 1208
d6d229c6 1209/* Return first static variable with definition. */
2c8326a5 1210static inline varpool_node *
66058468 1211varpool_first_defined_variable (void)
2aae7680 1212{
5e20cdc9 1213 symtab_node *node;
67348ccc 1214 for (node = symtab_nodes; node; node = node->next)
2aae7680 1215 {
7de90a6c 1216 varpool_node *vnode = dyn_cast <varpool_node *> (node);
67348ccc 1217 if (vnode && vnode->definition)
5d59b5e1 1218 return vnode;
2aae7680
JH
1219 }
1220 return NULL;
1221}
1222
d6d229c6 1223/* Return next static variable with definition after NODE. */
2c8326a5
OE
1224static inline varpool_node *
1225varpool_next_defined_variable (varpool_node *node)
2aae7680 1226{
5e20cdc9 1227 symtab_node *node1 = node->next;
67348ccc 1228 for (; node1; node1 = node1->next)
2aae7680 1229 {
7de90a6c 1230 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
67348ccc 1231 if (vnode1 && vnode1->definition)
5d59b5e1 1232 return vnode1;
2aae7680
JH
1233 }
1234 return NULL;
1235}
65c70e6b
JH
1236/* Walk all variables with definitions in current unit. */
1237#define FOR_EACH_DEFINED_VARIABLE(node) \
66058468
JH
1238 for ((node) = varpool_first_defined_variable (); (node); \
1239 (node) = varpool_next_defined_variable (node))
68e56cc4 1240
c47d0034
JH
1241/* Return first function with body defined. */
1242static inline struct cgraph_node *
1243cgraph_first_defined_function (void)
1244{
5e20cdc9 1245 symtab_node *node;
67348ccc 1246 for (node = symtab_nodes; node; node = node->next)
c47d0034 1247 {
7de90a6c 1248 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
67348ccc 1249 if (cn && cn->definition)
5d59b5e1 1250 return cn;
c47d0034
JH
1251 }
1252 return NULL;
1253}
1254
45896127 1255/* Return next function with body defined after NODE. */
c47d0034
JH
1256static inline struct cgraph_node *
1257cgraph_next_defined_function (struct cgraph_node *node)
1258{
5e20cdc9 1259 symtab_node *node1 = node->next;
67348ccc 1260 for (; node1; node1 = node1->next)
c47d0034 1261 {
7de90a6c 1262 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
67348ccc 1263 if (cn1 && cn1->definition)
5d59b5e1 1264 return cn1;
c47d0034
JH
1265 }
1266 return NULL;
1267}
1268
1269/* Walk all functions with body defined. */
1270#define FOR_EACH_DEFINED_FUNCTION(node) \
1271 for ((node) = cgraph_first_defined_function (); (node); \
2aae7680
JH
1272 (node) = cgraph_next_defined_function ((node)))
1273
1274/* Return first function. */
1275static inline struct cgraph_node *
1276cgraph_first_function (void)
1277{
5e20cdc9 1278 symtab_node *node;
67348ccc 1279 for (node = symtab_nodes; node; node = node->next)
7de90a6c 1280 if (cgraph_node *cn = dyn_cast <cgraph_node *> (node))
5d59b5e1 1281 return cn;
2aae7680
JH
1282 return NULL;
1283}
1284
1285/* Return next function. */
1286static inline struct cgraph_node *
1287cgraph_next_function (struct cgraph_node *node)
1288{
5e20cdc9 1289 symtab_node *node1 = node->next;
67348ccc 1290 for (; node1; node1 = node1->next)
7de90a6c 1291 if (cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1))
5d59b5e1 1292 return cn1;
2aae7680
JH
1293 return NULL;
1294}
65c70e6b
JH
1295/* Walk all functions. */
1296#define FOR_EACH_FUNCTION(node) \
2aae7680
JH
1297 for ((node) = cgraph_first_function (); (node); \
1298 (node) = cgraph_next_function ((node)))
c47d0034
JH
1299
1300/* Return true when NODE is a function with Gimple body defined
1301 in current unit. Functions can also be define externally or they
1302 can be thunks with no Gimple representation.
1303
1304 Note that at WPA stage, the function body may not be present in memory. */
1305
1306static inline bool
1307cgraph_function_with_gimple_body_p (struct cgraph_node *node)
1308{
67348ccc 1309 return node->definition && !node->thunk.thunk_p && !node->alias;
c47d0034
JH
1310}
1311
1312/* Return first function with body defined. */
1313static inline struct cgraph_node *
1314cgraph_first_function_with_gimple_body (void)
1315{
5e20cdc9 1316 symtab_node *node;
67348ccc 1317 for (node = symtab_nodes; node; node = node->next)
c47d0034 1318 {
7de90a6c 1319 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
5d59b5e1
LC
1320 if (cn && cgraph_function_with_gimple_body_p (cn))
1321 return cn;
c47d0034
JH
1322 }
1323 return NULL;
1324}
1325
1326/* Return next reachable static variable with initializer after NODE. */
1327static inline struct cgraph_node *
1328cgraph_next_function_with_gimple_body (struct cgraph_node *node)
1329{
5e20cdc9 1330 symtab_node *node1 = node->next;
67348ccc 1331 for (; node1; node1 = node1->next)
c47d0034 1332 {
7de90a6c 1333 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
5d59b5e1
LC
1334 if (cn1 && cgraph_function_with_gimple_body_p (cn1))
1335 return cn1;
c47d0034
JH
1336 }
1337 return NULL;
1338}
1339
1340/* Walk all functions with body defined. */
1341#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
1342 for ((node) = cgraph_first_function_with_gimple_body (); (node); \
1343 (node) = cgraph_next_function_with_gimple_body (node))
1344
43d861a5
RL
1345/* Create a new static variable of type TYPE. */
1346tree add_new_static_var (tree type);
1347
fed5ae11
DK
1348/* Return true if iterator CSI points to nothing. */
1349static inline bool
1350csi_end_p (cgraph_node_set_iterator csi)
1351{
9771b263 1352 return csi.index >= csi.set->nodes.length ();
fed5ae11
DK
1353}
1354
1355/* Advance iterator CSI. */
1356static inline void
1357csi_next (cgraph_node_set_iterator *csi)
1358{
1359 csi->index++;
1360}
1361
1362/* Return the node pointed to by CSI. */
1363static inline struct cgraph_node *
1364csi_node (cgraph_node_set_iterator csi)
1365{
9771b263 1366 return csi.set->nodes[csi.index];
fed5ae11
DK
1367}
1368
1369/* Return an iterator to the first node in SET. */
1370static inline cgraph_node_set_iterator
1371csi_start (cgraph_node_set set)
1372{
1373 cgraph_node_set_iterator csi;
1374
1375 csi.set = set;
1376 csi.index = 0;
1377 return csi;
1378}
1379
1380/* Return true if SET contains NODE. */
1381static inline bool
1382cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
1383{
1384 cgraph_node_set_iterator csi;
1385 csi = cgraph_node_set_find (set, node);
1386 return !csi_end_p (csi);
1387}
1388
1389/* Return number of nodes in SET. */
1390static inline size_t
1391cgraph_node_set_size (cgraph_node_set set)
1392{
9771b263 1393 return set->nodes.length ();
fed5ae11
DK
1394}
1395
2942c502
JH
1396/* Return true if iterator VSI points to nothing. */
1397static inline bool
1398vsi_end_p (varpool_node_set_iterator vsi)
1399{
9771b263 1400 return vsi.index >= vsi.set->nodes.length ();
2942c502
JH
1401}
1402
1403/* Advance iterator VSI. */
1404static inline void
1405vsi_next (varpool_node_set_iterator *vsi)
1406{
1407 vsi->index++;
1408}
1409
1410/* Return the node pointed to by VSI. */
2c8326a5 1411static inline varpool_node *
2942c502
JH
1412vsi_node (varpool_node_set_iterator vsi)
1413{
9771b263 1414 return vsi.set->nodes[vsi.index];
2942c502
JH
1415}
1416
1417/* Return an iterator to the first node in SET. */
1418static inline varpool_node_set_iterator
1419vsi_start (varpool_node_set set)
1420{
1421 varpool_node_set_iterator vsi;
1422
1423 vsi.set = set;
1424 vsi.index = 0;
1425 return vsi;
1426}
1427
1428/* Return true if SET contains NODE. */
1429static inline bool
2c8326a5 1430varpool_node_in_set_p (varpool_node *node, varpool_node_set set)
2942c502
JH
1431{
1432 varpool_node_set_iterator vsi;
1433 vsi = varpool_node_set_find (set, node);
1434 return !vsi_end_p (vsi);
1435}
1436
1437/* Return number of nodes in SET. */
1438static inline size_t
1439varpool_node_set_size (varpool_node_set set)
1440{
9771b263 1441 return set->nodes.length ();
2942c502
JH
1442}
1443
d48e9cea
OR
1444/* Uniquize all constants that appear in memory.
1445 Each constant in memory thus far output is recorded
1446 in `const_desc_table'. */
1447
1448struct GTY(()) constant_descriptor_tree {
1449 /* A MEM for the constant. */
1450 rtx rtl;
b8698a0f 1451
d48e9cea
OR
1452 /* The value of the constant. */
1453 tree value;
1454
1455 /* Hash of value. Computing the hash from value each time
1456 hashfn is called can't work properly, as that means recursive
1457 use of the hash table during hash table expansion. */
1458 hashval_t hash;
1459};
1460
ace72c88
JH
1461/* Return true if set is nonempty. */
1462static inline bool
1463cgraph_node_set_nonempty_p (cgraph_node_set set)
1464{
9771b263 1465 return !set->nodes.is_empty ();
ace72c88
JH
1466}
1467
1468/* Return true if set is nonempty. */
1469static inline bool
1470varpool_node_set_nonempty_p (varpool_node_set set)
1471{
9771b263 1472 return !set->nodes.is_empty ();
ace72c88
JH
1473}
1474
be330ed4 1475/* Return true when function NODE is only called directly or it has alias.
b20996ff
JH
1476 i.e. it is not externally visible, address was not taken and
1477 it is not used in any other non-standard way. */
1478
1479static inline bool
be330ed4 1480cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node)
b20996ff 1481{
530f3a1b 1482 gcc_assert (!node->global.inlined_to);
67348ccc
DM
1483 return (!node->force_output && !node->address_taken
1484 && !node->used_from_other_partition
1485 && !DECL_VIRTUAL_P (node->decl)
1486 && !DECL_STATIC_CONSTRUCTOR (node->decl)
1487 && !DECL_STATIC_DESTRUCTOR (node->decl)
1488 && !node->externally_visible);
b20996ff
JH
1489}
1490
df7705b1
JH
1491/* Return true when function NODE can be removed from callgraph
1492 if all direct calls are eliminated. */
1493
1494static inline bool
2c8326a5 1495varpool_can_remove_if_no_refs (varpool_node *node)
df7705b1 1496{
67348ccc 1497 if (DECL_EXTERNAL (node->decl))
6649df51 1498 return true;
67348ccc
DM
1499 return (!node->force_output && !node->used_from_other_partition
1500 && ((DECL_COMDAT (node->decl)
1501 && !node->forced_by_abi
1502 && !symtab_used_from_object_file_p (node))
1503 || !node->externally_visible
1504 || DECL_HAS_VALUE_EXPR_P (node->decl)));
df7705b1
JH
1505}
1506
4a444e58
JH
1507/* Return true when all references to VNODE must be visible in ipa_ref_list.
1508 i.e. if the variable is not externally visible or not used in some magic
1509 way (asm statement or such).
61502ca8 1510 The magic uses are all summarized in force_output flag. */
4a444e58
JH
1511
1512static inline bool
2c8326a5 1513varpool_all_refs_explicit_p (varpool_node *vnode)
4a444e58 1514{
67348ccc
DM
1515 return (vnode->definition
1516 && !vnode->externally_visible
1517 && !vnode->used_from_other_partition
1518 && !vnode->force_output);
4a444e58
JH
1519}
1520
d48e9cea
OR
1521/* Constant pool accessor function. */
1522htab_t constant_pool_htab (void);
fed5ae11 1523
be330ed4
JH
1524/* FIXME: inappropriate dependency of cgraph on IPA. */
1525#include "ipa-ref-inline.h"
1526
39e2db00
JH
1527/* Return node that alias N is aliasing. */
1528
5e20cdc9
DM
1529static inline symtab_node *
1530symtab_alias_target (symtab_node *n)
39e2db00
JH
1531{
1532 struct ipa_ref *ref;
67348ccc 1533 ipa_ref_list_reference_iterate (&n->ref_list, 0, ref);
39e2db00 1534 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
e70670cf 1535 return ref->referred;
39e2db00
JH
1536}
1537
e70670cf
JH
1538static inline struct cgraph_node *
1539cgraph_alias_target (struct cgraph_node *n)
cd35bcf7 1540{
7de90a6c 1541 return dyn_cast <cgraph_node *> (symtab_alias_target (n));
cd35bcf7
JH
1542}
1543
2c8326a5
OE
1544static inline varpool_node *
1545varpool_alias_target (varpool_node *n)
be330ed4 1546{
7de90a6c 1547 return dyn_cast <varpool_node *> (symtab_alias_target (n));
be330ed4
JH
1548}
1549
1550/* Given NODE, walk the alias chain to return the function NODE is alias of.
1551 Do not walk through thunks.
073a8998 1552 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
be330ed4
JH
1553
1554static inline struct cgraph_node *
40a7fe1e
JH
1555cgraph_function_or_thunk_node (struct cgraph_node *node,
1556 enum availability *availability = NULL)
be330ed4 1557{
e70670cf
JH
1558 struct cgraph_node *n;
1559
7de90a6c
DM
1560 n = dyn_cast <cgraph_node *> (symtab_alias_ultimate_target (node,
1561 availability));
40a7fe1e 1562 if (!n && availability)
39e2db00 1563 *availability = AVAIL_NOT_AVAILABLE;
e70670cf 1564 return n;
be330ed4 1565}
cd35bcf7
JH
1566/* Given NODE, walk the alias chain to return the function NODE is alias of.
1567 Do not walk through thunks.
073a8998 1568 When AVAILABILITY is non-NULL, get minimal availability in the chain. */
cd35bcf7 1569
2c8326a5
OE
1570static inline varpool_node *
1571varpool_variable_node (varpool_node *node,
40a7fe1e 1572 enum availability *availability = NULL)
cd35bcf7 1573{
2c8326a5 1574 varpool_node *n;
e70670cf 1575
ff36fcbe 1576 if (node)
7de90a6c
DM
1577 n = dyn_cast <varpool_node *> (symtab_alias_ultimate_target (node,
1578 availability));
ff36fcbe
EB
1579 else
1580 n = NULL;
1581
40a7fe1e 1582 if (!n && availability)
cd35bcf7 1583 *availability = AVAIL_NOT_AVAILABLE;
e70670cf 1584 return n;
cd35bcf7
JH
1585}
1586
d7d1d041
RG
1587/* Return true when the edge E represents a direct recursion. */
1588static inline bool
1589cgraph_edge_recursive_p (struct cgraph_edge *e)
1590{
be330ed4 1591 struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
d7d1d041 1592 if (e->caller->global.inlined_to)
67348ccc 1593 return e->caller->global.inlined_to->decl == callee->decl;
d7d1d041 1594 else
67348ccc 1595 return e->caller->decl == callee->decl;
d7d1d041 1596}
0a35513e
AH
1597
1598/* Return true if the TM_CLONE bit is set for a given FNDECL. */
1599static inline bool
1600decl_is_tm_clone (const_tree fndecl)
1601{
1602 struct cgraph_node *n = cgraph_get_node (fndecl);
1603 if (n)
1604 return n->tm_clone;
1605 return false;
1606}
9c8305f8
JH
1607
1608/* Likewise indicate that a node is needed, i.e. reachable via some
1609 external means. */
1610
1611static inline void
1612cgraph_mark_force_output_node (struct cgraph_node *node)
1613{
67348ccc 1614 node->force_output = 1;
9c8305f8
JH
1615 gcc_checking_assert (!node->global.inlined_to);
1616}
65d630d4 1617
b5493fb2 1618/* Return true when the symbol is real symbol, i.e. it is not inline clone
e70670cf 1619 or abstract function kept for debug info purposes only. */
b5493fb2
JH
1620
1621static inline bool
5e20cdc9 1622symtab_real_symbol_p (symtab_node *node)
b5493fb2
JH
1623{
1624 struct cgraph_node *cnode;
b5493fb2 1625
67348ccc 1626 if (DECL_ABSTRACT (node->decl))
c0c123ef 1627 return false;
7de90a6c 1628 if (!is_a <cgraph_node *> (node))
b5493fb2
JH
1629 return true;
1630 cnode = cgraph (node);
1631 if (cnode->global.inlined_to)
1632 return false;
b5493fb2
JH
1633 return true;
1634}
09ce3660
JH
1635
1636/* Return true if NODE can be discarded by linker from the binary. */
1637
1638static inline bool
5e20cdc9 1639symtab_can_be_discarded (symtab_node *node)
09ce3660 1640{
67348ccc 1641 return (DECL_EXTERNAL (node->decl)
aede2c10 1642 || (node->get_comdat_group ()
67348ccc
DM
1643 && node->resolution != LDPR_PREVAILING_DEF
1644 && node->resolution != LDPR_PREVAILING_DEF_IRONLY
1645 && node->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP));
09ce3660 1646}
1f26ac87
JM
1647
1648/* Return true if NODE is local to a particular COMDAT group, and must not
1649 be named from outside the COMDAT. This is used for C++ decloned
1650 constructors. */
1651
1652static inline bool
1653symtab_comdat_local_p (symtab_node *node)
1654{
1655 return (node->same_comdat_group && !TREE_PUBLIC (node->decl));
1656}
1657
1658/* Return true if ONE and TWO are part of the same COMDAT group. */
1659
1660static inline bool
1661symtab_in_same_comdat_p (symtab_node *one, symtab_node *two)
1662{
d6d229c6
JH
1663 if (cgraph_node *cn = dyn_cast <cgraph_node *> (one))
1664 {
1665 if (cn->global.inlined_to)
1666 one = cn->global.inlined_to;
1667 }
1668 if (cgraph_node *cn = dyn_cast <cgraph_node *> (two))
1669 {
1670 if (cn->global.inlined_to)
1671 two = cn->global.inlined_to;
1672 }
1673
aede2c10
JH
1674 return one->get_comdat_group () == two->get_comdat_group ();
1675}
1c4a429a 1676#endif /* GCC_CGRAPH_H */