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