comparison gcc/cgraph.h @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
1 /* Callgraph handling code. 1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Contributed by Jan Hubicka 4 Contributed by Jan Hubicka
5 5
6 This file is part of GCC. 6 This file is part of GCC.
7 7
19 along with GCC; see the file COPYING3. If not see 19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */ 20 <http://www.gnu.org/licenses/>. */
21 21
22 #ifndef GCC_CGRAPH_H 22 #ifndef GCC_CGRAPH_H
23 #define GCC_CGRAPH_H 23 #define GCC_CGRAPH_H
24
25 #include "vec.h"
24 #include "tree.h" 26 #include "tree.h"
25 #include "basic-block.h" 27 #include "basic-block.h"
28 #include "function.h"
29 #include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA. */
26 30
27 enum availability 31 enum availability
28 { 32 {
29 /* Not yet set by cgraph_function_body_availability. */ 33 /* Not yet set by cgraph_function_body_availability. */
30 AVAIL_UNSET, 34 AVAIL_UNSET,
85 /* Information about the function collected locally. 89 /* Information about the function collected locally.
86 Available after function is analyzed. */ 90 Available after function is analyzed. */
87 91
88 struct GTY(()) cgraph_local_info { 92 struct GTY(()) cgraph_local_info {
89 /* File stream where this node is being written to. */ 93 /* File stream where this node is being written to. */
90 struct lto_file_decl_data * GTY ((skip)) lto_file_data; 94 struct lto_file_decl_data * lto_file_data;
91 95
92 struct inline_summary inline_summary; 96 struct inline_summary inline_summary;
93 97
94 /* Set when function function is visible in current compilation unit only 98 /* Set when function function is visible in current compilation unit only
95 and its address is never taken. */ 99 and its address is never taken. */
102 unsigned finalized : 1; 106 unsigned finalized : 1;
103 107
104 /* False when there something makes inlining impossible (such as va_arg). */ 108 /* False when there something makes inlining impossible (such as va_arg). */
105 unsigned inlinable : 1; 109 unsigned inlinable : 1;
106 110
111 /* False when there something makes versioning impossible.
112 Currently computed and used only by ipa-cp. */
113 unsigned versionable : 1;
114
107 /* True when function should be inlined independently on its size. */ 115 /* True when function should be inlined independently on its size. */
108 unsigned disregard_inline_limits : 1; 116 unsigned disregard_inline_limits : 1;
109 117
110 /* True when the function has been originally extern inline, but it is 118 /* True when the function has been originally extern inline, but it is
111 redefined now. */ 119 redefined now. */
112 unsigned redefined_extern_inline : 1; 120 unsigned redefined_extern_inline : 1;
113
114 /* True if statics_read_for_function and
115 statics_written_for_function contain valid data. */
116 unsigned for_functions_valid : 1;
117 121
118 /* True if the function is going to be emitted in some other translation 122 /* True if the function is going to be emitted in some other translation
119 unit, referenced from vtable. */ 123 unit, referenced from vtable. */
120 unsigned vtable_method : 1; 124 unsigned vtable_method : 1;
121 }; 125 };
137 int time; 141 int time;
138 int size; 142 int size;
139 143
140 /* Estimated growth after inlining. INT_MIN if not computed. */ 144 /* Estimated growth after inlining. INT_MIN if not computed. */
141 int estimated_growth; 145 int estimated_growth;
142
143 /* Set iff the function has been inlined at least once. */
144 bool inlined;
145 }; 146 };
146 147
147 /* Information about the function that is propagated by the RTL backend. 148 /* Information about the function that is propagated by the RTL backend.
148 Available only for functions that has been already assembled. */ 149 Available only for functions that has been already assembled. */
149 150
157 { 158 {
158 /* The tree that will be replaced. */ 159 /* The tree that will be replaced. */
159 tree old_tree; 160 tree old_tree;
160 /* The new (replacing) tree. */ 161 /* The new (replacing) tree. */
161 tree new_tree; 162 tree new_tree;
163 /* Parameter number to replace, when old_tree is NULL. */
164 int parm_num;
162 /* True when a substitution should be done, false otherwise. */ 165 /* True when a substitution should be done, false otherwise. */
163 bool replace_p; 166 bool replace_p;
164 /* True when we replace a reference to old_tree. */ 167 /* True when we replace a reference to old_tree. */
165 bool ref_p; 168 bool ref_p;
166 }; 169 };
172 { 175 {
173 VEC(ipa_replace_map_p,gc)* tree_map; 176 VEC(ipa_replace_map_p,gc)* tree_map;
174 bitmap args_to_skip; 177 bitmap args_to_skip;
175 bitmap combined_args_to_skip; 178 bitmap combined_args_to_skip;
176 }; 179 };
180
181 enum node_frequency {
182 /* This function most likely won't be executed at all.
183 (set only when profile feedback is available or via function attribute). */
184 NODE_FREQUENCY_UNLIKELY_EXECUTED,
185 /* For functions that are known to be executed once (i.e. constructors, destructors
186 and main function. */
187 NODE_FREQUENCY_EXECUTED_ONCE,
188 /* The default value. */
189 NODE_FREQUENCY_NORMAL,
190 /* Optimize this function hard
191 (set only when profile feedback is available or via function attribute). */
192 NODE_FREQUENCY_HOT
193 };
194
177 195
178 /* The cgraph data structure. 196 /* The cgraph data structure.
179 Each function decl has assigned cgraph_node listing callees and callers. */ 197 Each function decl has assigned cgraph_node listing callees and callers. */
180 198
181 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node { 199 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
182 tree decl; 200 tree decl;
183 struct cgraph_edge *callees; 201 struct cgraph_edge *callees;
184 struct cgraph_edge *callers; 202 struct cgraph_edge *callers;
185 struct cgraph_node *next; 203 struct cgraph_node *next;
186 struct cgraph_node *previous; 204 struct cgraph_node *previous;
205 /* List of edges representing indirect calls with a yet undetermined
206 callee. */
207 struct cgraph_edge *indirect_calls;
187 /* For nested functions points to function the node is nested in. */ 208 /* For nested functions points to function the node is nested in. */
188 struct cgraph_node *origin; 209 struct cgraph_node *origin;
189 /* Points to first nested function, if any. */ 210 /* Points to first nested function, if any. */
190 struct cgraph_node *nested; 211 struct cgraph_node *nested;
191 /* Pointer to the next function with same origin, if any. */ 212 /* Pointer to the next function with same origin, if any. */
211 /* Interprocedural passes scheduled to have their transform functions 232 /* Interprocedural passes scheduled to have their transform functions
212 applied next time we execute local pass on them. We maintain it 233 applied next time we execute local pass on them. We maintain it
213 per-function in order to allow IPA passes to introduce new functions. */ 234 per-function in order to allow IPA passes to introduce new functions. */
214 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply; 235 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
215 236
237 struct ipa_ref_list ref_list;
216 struct cgraph_local_info local; 238 struct cgraph_local_info local;
217 struct cgraph_global_info global; 239 struct cgraph_global_info global;
218 struct cgraph_rtl_info rtl; 240 struct cgraph_rtl_info rtl;
219 struct cgraph_clone_info clone; 241 struct cgraph_clone_info clone;
220 struct cgraph_thunk_info thunk; 242 struct cgraph_thunk_info thunk;
247 This flag is computed at original cgraph construction and then 269 This flag is computed at original cgraph construction and then
248 updated in cgraph_remove_unreachable_nodes. Note that after 270 updated in cgraph_remove_unreachable_nodes. Note that after
249 cgraph_remove_unreachable_nodes cgraph still can contain unreachable 271 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
250 nodes when they are needed for virtual clone instantiation. */ 272 nodes when they are needed for virtual clone instantiation. */
251 unsigned reachable : 1; 273 unsigned reachable : 1;
274 /* Set when function is reachable by call from other LTRANS partition. */
275 unsigned reachable_from_other_partition : 1;
252 /* Set once the function is lowered (i.e. its CFG is built). */ 276 /* Set once the function is lowered (i.e. its CFG is built). */
253 unsigned lowered : 1; 277 unsigned lowered : 1;
254 /* Set once the function has been instantiated and its callee 278 /* Set once the function has been instantiated and its callee
255 lists created. */ 279 lists created. */
256 unsigned analyzed : 1; 280 unsigned analyzed : 1;
281 /* Set when function is available in the other LTRANS partition. */
282 unsigned in_other_partition : 1;
257 /* Set when function is scheduled to be processed by local passes. */ 283 /* Set when function is scheduled to be processed by local passes. */
258 unsigned process : 1; 284 unsigned process : 1;
259 /* Set for aliases once they got through assemble_alias. */ 285 /* Set for aliases once they got through assemble_alias. */
260 unsigned alias : 1; 286 unsigned alias : 1;
261 /* Set for nodes that was constructed and finalized by frontend. */ 287 /* Set for nodes that was constructed and finalized by frontend. */
262 unsigned finalized_by_frontend : 1; 288 unsigned finalized_by_frontend : 1;
263 /* Set for alias and thunk nodes, same_body points to the node they are alias 289 /* Set for alias and thunk nodes, same_body points to the node they are alias
264 of and they are linked through the next/previous pointers. */ 290 of and they are linked through the next/previous pointers. */
265 unsigned same_body_alias : 1; 291 unsigned same_body_alias : 1;
292 /* How commonly executed the node is. Initialized during branch
293 probabilities pass. */
294 ENUM_BITFIELD (node_frequency) frequency : 2;
266 }; 295 };
267 296
268 typedef struct cgraph_node *cgraph_node_ptr; 297 typedef struct cgraph_node *cgraph_node_ptr;
269 298
270 DEF_VEC_P(cgraph_node_ptr); 299 DEF_VEC_P(cgraph_node_ptr);
278 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab; 307 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
279 VEC(cgraph_node_ptr, gc) *nodes; 308 VEC(cgraph_node_ptr, gc) *nodes;
280 PTR GTY ((skip)) aux; 309 PTR GTY ((skip)) aux;
281 }; 310 };
282 311
312 typedef struct varpool_node *varpool_node_ptr;
313
314 DEF_VEC_P(varpool_node_ptr);
315 DEF_VEC_ALLOC_P(varpool_node_ptr,heap);
316 DEF_VEC_ALLOC_P(varpool_node_ptr,gc);
317
318 /* A varpool node set is a collection of varpool nodes. A varpool node
319 can appear in multiple sets. */
320 struct GTY(()) varpool_node_set_def
321 {
322 htab_t GTY((param_is (struct varpool_node_set_element_def))) hashtab;
323 VEC(varpool_node_ptr, gc) *nodes;
324 PTR GTY ((skip)) aux;
325 };
326
283 typedef struct cgraph_node_set_def *cgraph_node_set; 327 typedef struct cgraph_node_set_def *cgraph_node_set;
284 328
285 DEF_VEC_P(cgraph_node_set); 329 DEF_VEC_P(cgraph_node_set);
286 DEF_VEC_ALLOC_P(cgraph_node_set,gc); 330 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
287 DEF_VEC_ALLOC_P(cgraph_node_set,heap); 331 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
288 332
333 typedef struct varpool_node_set_def *varpool_node_set;
334
335 DEF_VEC_P(varpool_node_set);
336 DEF_VEC_ALLOC_P(varpool_node_set,gc);
337 DEF_VEC_ALLOC_P(varpool_node_set,heap);
338
289 /* A cgraph node set element contains an index in the vector of nodes in 339 /* A cgraph node set element contains an index in the vector of nodes in
290 the set. */ 340 the set. */
291 struct GTY(()) cgraph_node_set_element_def 341 struct GTY(()) cgraph_node_set_element_def
292 { 342 {
293 struct cgraph_node *node; 343 struct cgraph_node *node;
301 typedef struct 351 typedef struct
302 { 352 {
303 cgraph_node_set set; 353 cgraph_node_set set;
304 unsigned index; 354 unsigned index;
305 } cgraph_node_set_iterator; 355 } cgraph_node_set_iterator;
356
357 /* A varpool node set element contains an index in the vector of nodes in
358 the set. */
359 struct GTY(()) varpool_node_set_element_def
360 {
361 struct varpool_node *node;
362 HOST_WIDE_INT index;
363 };
364
365 typedef struct varpool_node_set_element_def *varpool_node_set_element;
366 typedef const struct varpool_node_set_element_def *const_varpool_node_set_element;
367
368 /* Iterator structure for varpool node sets. */
369 typedef struct
370 {
371 varpool_node_set set;
372 unsigned index;
373 } varpool_node_set_iterator;
306 374
307 #define DEFCIFCODE(code, string) CIF_ ## code, 375 #define DEFCIFCODE(code, string) CIF_ ## code,
308 /* Reasons for inlining failures. */ 376 /* Reasons for inlining failures. */
309 typedef enum { 377 typedef enum {
310 #include "cif-code.def" 378 #include "cif-code.def"
311 CIF_N_REASONS 379 CIF_N_REASONS
312 } cgraph_inline_failed_t; 380 } cgraph_inline_failed_t;
381
382 /* Structure containing additional information about an indirect call. */
383
384 struct GTY(()) cgraph_indirect_call_info
385 {
386 /* Offset accumulated from ancestor jump functions of inlined call graph
387 edges. */
388 HOST_WIDE_INT anc_offset;
389 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
390 HOST_WIDE_INT otr_token;
391 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
392 tree otr_type;
393 /* Index of the parameter that is called. */
394 int param_index;
395 /* ECF flags determined from the caller. */
396 int ecf_flags;
397
398 /* Set when the call is a virtual call with the parameter being the
399 associated object pointer rather than a simple direct call. */
400 unsigned polymorphic : 1;
401 };
313 402
314 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge { 403 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
315 /* Expected number of executions: calculated in profile.c. */ 404 /* Expected number of executions: calculated in profile.c. */
316 gcov_type count; 405 gcov_type count;
317 struct cgraph_node *caller; 406 struct cgraph_node *caller;
319 struct cgraph_edge *prev_caller; 408 struct cgraph_edge *prev_caller;
320 struct cgraph_edge *next_caller; 409 struct cgraph_edge *next_caller;
321 struct cgraph_edge *prev_callee; 410 struct cgraph_edge *prev_callee;
322 struct cgraph_edge *next_callee; 411 struct cgraph_edge *next_callee;
323 gimple call_stmt; 412 gimple call_stmt;
413 /* Additional information about an indirect call. Not cleared when an edge
414 becomes direct. */
415 struct cgraph_indirect_call_info *indirect_info;
324 PTR GTY ((skip (""))) aux; 416 PTR GTY ((skip (""))) aux;
325 /* When equal to CIF_OK, inline this call. Otherwise, points to the 417 /* When equal to CIF_OK, inline this call. Otherwise, points to the
326 explanation why function was not inlined. */ 418 explanation why function was not inlined. */
327 cgraph_inline_failed_t inline_failed; 419 cgraph_inline_failed_t inline_failed;
328 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt 420 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
334 int frequency; 426 int frequency;
335 /* Unique id of the edge. */ 427 /* Unique id of the edge. */
336 int uid; 428 int uid;
337 /* Depth of loop nest, 1 means no loop nest. */ 429 /* Depth of loop nest, 1 means no loop nest. */
338 unsigned short int loop_nest; 430 unsigned short int loop_nest;
339 /* Whether this edge describes a call that was originally indirect. */ 431 /* Whether this edge was made direct by indirect inlining. */
340 unsigned int indirect_call : 1; 432 unsigned int indirect_inlining_edge : 1;
433 /* Whether this edge describes an indirect call with an undetermined
434 callee. */
435 unsigned int indirect_unknown_callee : 1;
436 /* Whether this edge is still a dangling */
341 /* True if the corresponding CALL stmt cannot be inlined. */ 437 /* True if the corresponding CALL stmt cannot be inlined. */
342 unsigned int call_stmt_cannot_inline_p : 1; 438 unsigned int call_stmt_cannot_inline_p : 1;
343 /* Can this call throw externally? */ 439 /* Can this call throw externally? */
344 unsigned int can_throw_external : 1; 440 unsigned int can_throw_external : 1;
345 }; 441 };
353 DEF_VEC_ALLOC_P(cgraph_edge_p,heap); 449 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
354 450
355 /* The varpool data structure. 451 /* The varpool data structure.
356 Each static variable decl has assigned varpool_node. */ 452 Each static variable decl has assigned varpool_node. */
357 453
358 struct GTY((chain_next ("%h.next"))) varpool_node { 454 struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node {
359 tree decl; 455 tree decl;
360 /* Pointer to the next function in varpool_nodes. */ 456 /* Pointer to the next function in varpool_nodes. */
361 struct varpool_node *next; 457 struct varpool_node *next, *prev;
362 /* Pointer to the next function in varpool_nodes_queue. */ 458 /* Pointer to the next function in varpool_nodes_queue. */
363 struct varpool_node *next_needed; 459 struct varpool_node *next_needed, *prev_needed;
460 /* For normal nodes a pointer to the first extra name alias. For alias
461 nodes a pointer to the normal node. */
462 struct varpool_node *extra_name;
463 /* Circular list of nodes in the same comdat group if non-NULL. */
464 struct varpool_node *same_comdat_group;
465 struct ipa_ref_list ref_list;
466 PTR GTY ((skip)) aux;
364 /* Ordering of all cgraph nodes. */ 467 /* Ordering of all cgraph nodes. */
365 int order; 468 int order;
366 469
367 /* Set when function must be output - it is externally visible 470 /* Set when function must be output - it is externally visible
368 or its address is taken. */ 471 or its address is taken. */
377 unsigned finalized : 1; 480 unsigned finalized : 1;
378 /* Set when variable is scheduled to be assembled. */ 481 /* Set when variable is scheduled to be assembled. */
379 unsigned output : 1; 482 unsigned output : 1;
380 /* Set when function is visible by other units. */ 483 /* Set when function is visible by other units. */
381 unsigned externally_visible : 1; 484 unsigned externally_visible : 1;
382 /* Set for aliases once they got through assemble_alias. */ 485 /* Set for aliases once they got through assemble_alias. Also set for
486 extra name aliases in varpool_extra_name_alias. */
383 unsigned alias : 1; 487 unsigned alias : 1;
488 /* Set when variable is used from other LTRANS partition. */
489 unsigned used_from_other_partition : 1;
490 /* Set when variable is available in the other LTRANS partition. */
491 unsigned in_other_partition : 1;
384 }; 492 };
385 493
386 /* Every top level asm statement is put into a cgraph_asm_node. */ 494 /* Every top level asm statement is put into a cgraph_asm_node. */
387 495
388 struct GTY(()) cgraph_asm_node { 496 struct GTY(()) cgraph_asm_node {
433 void cgraph_release_function_body (struct cgraph_node *); 541 void cgraph_release_function_body (struct cgraph_node *);
434 void cgraph_node_remove_callees (struct cgraph_node *node); 542 void cgraph_node_remove_callees (struct cgraph_node *node);
435 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, 543 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
436 struct cgraph_node *, 544 struct cgraph_node *,
437 gimple, gcov_type, int, int); 545 gimple, gcov_type, int, int);
438 546 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple, int,
547 gcov_type, int, int);
439 struct cgraph_node * cgraph_get_node (tree); 548 struct cgraph_node * cgraph_get_node (tree);
440 struct cgraph_node *cgraph_node (tree); 549 struct cgraph_node *cgraph_node (tree);
441 bool cgraph_same_body_alias (tree, tree); 550 bool cgraph_same_body_alias (tree, tree);
442 void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree); 551 void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree);
443 void cgraph_remove_same_body_alias (struct cgraph_node *); 552 void cgraph_remove_same_body_alias (struct cgraph_node *);
455 struct cgraph_rtl_info *cgraph_rtl_info (tree); 564 struct cgraph_rtl_info *cgraph_rtl_info (tree);
456 const char * cgraph_node_name (struct cgraph_node *); 565 const char * cgraph_node_name (struct cgraph_node *);
457 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, 566 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
458 struct cgraph_node *, gimple, 567 struct cgraph_node *, gimple,
459 unsigned, gcov_type, int, int, bool); 568 unsigned, gcov_type, int, int, bool);
460 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int, 569 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int,
461 int, bool, VEC(cgraph_edge_p,heap) *); 570 int, bool, VEC(cgraph_edge_p,heap) *);
462 571
463 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *); 572 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
573 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *);
464 574
465 struct cgraph_asm_node *cgraph_add_asm_node (tree); 575 struct cgraph_asm_node *cgraph_add_asm_node (tree);
466 576
467 bool cgraph_function_possibly_inlined_p (tree); 577 bool cgraph_function_possibly_inlined_p (tree);
468 void cgraph_unnest_node (struct cgraph_node *); 578 void cgraph_unnest_node (struct cgraph_node *);
528 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *); 638 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
529 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *); 639 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
530 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *); 640 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
531 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *); 641 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
532 void cgraph_materialize_all_clones (void); 642 void cgraph_materialize_all_clones (void);
533 643 gimple cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *);
644 bool cgraph_propagate_frequency (struct cgraph_node *node);
534 /* In cgraphbuild.c */ 645 /* In cgraphbuild.c */
535 unsigned int rebuild_cgraph_edges (void); 646 unsigned int rebuild_cgraph_edges (void);
647 void cgraph_rebuild_references (void);
536 void reset_inline_failed (struct cgraph_node *); 648 void reset_inline_failed (struct cgraph_node *);
537 int compute_call_stmt_bb_frequency (tree, basic_block bb); 649 int compute_call_stmt_bb_frequency (tree, basic_block bb);
538 650
539 /* In ipa.c */ 651 /* In ipa.c */
540 bool cgraph_remove_unreachable_nodes (bool, FILE *); 652 bool cgraph_remove_unreachable_nodes (bool, FILE *);
545 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *); 657 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
546 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *); 658 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
547 void dump_cgraph_node_set (FILE *, cgraph_node_set); 659 void dump_cgraph_node_set (FILE *, cgraph_node_set);
548 void debug_cgraph_node_set (cgraph_node_set); 660 void debug_cgraph_node_set (cgraph_node_set);
549 661
662 varpool_node_set varpool_node_set_new (void);
663 varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
664 struct varpool_node *);
665 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
666 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
667 void dump_varpool_node_set (FILE *, varpool_node_set);
668 void debug_varpool_node_set (varpool_node_set);
669 void ipa_discover_readonly_nonaddressable_vars (void);
550 670
551 /* In predict.c */ 671 /* In predict.c */
552 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e); 672 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
553 673
554 /* In varpool.c */ 674 /* In varpool.c */
563 void dump_varpool_node (FILE *, struct varpool_node *); 683 void dump_varpool_node (FILE *, struct varpool_node *);
564 684
565 void varpool_finalize_decl (tree); 685 void varpool_finalize_decl (tree);
566 bool decide_is_variable_needed (struct varpool_node *, tree); 686 bool decide_is_variable_needed (struct varpool_node *, tree);
567 enum availability cgraph_variable_initializer_availability (struct varpool_node *); 687 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
688 void cgraph_make_decl_local (tree);
568 void cgraph_make_node_local (struct cgraph_node *); 689 void cgraph_make_node_local (struct cgraph_node *);
569 bool cgraph_node_can_be_local_p (struct cgraph_node *); 690 bool cgraph_node_can_be_local_p (struct cgraph_node *);
570 691
692
693 struct varpool_node * varpool_get_node (tree decl);
694 void varpool_remove_node (struct varpool_node *node);
571 bool varpool_assemble_pending_decls (void); 695 bool varpool_assemble_pending_decls (void);
572 bool varpool_assemble_decl (struct varpool_node *node); 696 bool varpool_assemble_decl (struct varpool_node *node);
573 bool varpool_analyze_pending_decls (void); 697 bool varpool_analyze_pending_decls (void);
574 void varpool_remove_unreferenced_decls (void); 698 void varpool_remove_unreferenced_decls (void);
575 void varpool_empty_needed_queue (void); 699 void varpool_empty_needed_queue (void);
700 bool varpool_extra_name_alias (tree, tree);
576 const char * varpool_node_name (struct varpool_node *node); 701 const char * varpool_node_name (struct varpool_node *node);
702 void varpool_reset_queue (void);
577 703
578 /* Walk all reachable static variables. */ 704 /* Walk all reachable static variables. */
579 #define FOR_EACH_STATIC_VARIABLE(node) \ 705 #define FOR_EACH_STATIC_VARIABLE(node) \
580 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed) 706 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
581 707
617 743
618 744
619 /* Create a new static variable of type TYPE. */ 745 /* Create a new static variable of type TYPE. */
620 tree add_new_static_var (tree type); 746 tree add_new_static_var (tree type);
621 747
622 /* lto-cgraph.c */
623
624 enum LTO_cgraph_tags
625 {
626 /* Must leave 0 for the stopper. */
627 LTO_cgraph_avail_node = 1,
628 LTO_cgraph_overwritable_node,
629 LTO_cgraph_unavail_node,
630 LTO_cgraph_edge,
631 LTO_cgraph_last_tag
632 };
633
634 extern const char * LTO_cgraph_tag_names[LTO_cgraph_last_tag];
635
636 #define LCC_NOT_FOUND (-1)
637
638
639 /* Return true if iterator CSI points to nothing. */ 748 /* Return true if iterator CSI points to nothing. */
640 static inline bool 749 static inline bool
641 csi_end_p (cgraph_node_set_iterator csi) 750 csi_end_p (cgraph_node_set_iterator csi)
642 { 751 {
643 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes); 752 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
678 } 787 }
679 788
680 /* Return number of nodes in SET. */ 789 /* Return number of nodes in SET. */
681 static inline size_t 790 static inline size_t
682 cgraph_node_set_size (cgraph_node_set set) 791 cgraph_node_set_size (cgraph_node_set set)
792 {
793 return htab_elements (set->hashtab);
794 }
795
796 /* Return true if iterator VSI points to nothing. */
797 static inline bool
798 vsi_end_p (varpool_node_set_iterator vsi)
799 {
800 return vsi.index >= VEC_length (varpool_node_ptr, vsi.set->nodes);
801 }
802
803 /* Advance iterator VSI. */
804 static inline void
805 vsi_next (varpool_node_set_iterator *vsi)
806 {
807 vsi->index++;
808 }
809
810 /* Return the node pointed to by VSI. */
811 static inline struct varpool_node *
812 vsi_node (varpool_node_set_iterator vsi)
813 {
814 return VEC_index (varpool_node_ptr, vsi.set->nodes, vsi.index);
815 }
816
817 /* Return an iterator to the first node in SET. */
818 static inline varpool_node_set_iterator
819 vsi_start (varpool_node_set set)
820 {
821 varpool_node_set_iterator vsi;
822
823 vsi.set = set;
824 vsi.index = 0;
825 return vsi;
826 }
827
828 /* Return true if SET contains NODE. */
829 static inline bool
830 varpool_node_in_set_p (struct varpool_node *node, varpool_node_set set)
831 {
832 varpool_node_set_iterator vsi;
833 vsi = varpool_node_set_find (set, node);
834 return !vsi_end_p (vsi);
835 }
836
837 /* Return number of nodes in SET. */
838 static inline size_t
839 varpool_node_set_size (varpool_node_set set)
683 { 840 {
684 return htab_elements (set->hashtab); 841 return htab_elements (set->hashtab);
685 } 842 }
686 843
687 /* Uniquize all constants that appear in memory. 844 /* Uniquize all constants that appear in memory.
699 hashfn is called can't work properly, as that means recursive 856 hashfn is called can't work properly, as that means recursive
700 use of the hash table during hash table expansion. */ 857 use of the hash table during hash table expansion. */
701 hashval_t hash; 858 hashval_t hash;
702 }; 859 };
703 860
861 /* Return true if set is nonempty. */
862 static inline bool
863 cgraph_node_set_nonempty_p (cgraph_node_set set)
864 {
865 return VEC_length (cgraph_node_ptr, set->nodes);
866 }
867
868 /* Return true if set is nonempty. */
869 static inline bool
870 varpool_node_set_nonempty_p (varpool_node_set set)
871 {
872 return VEC_length (varpool_node_ptr, set->nodes);
873 }
874
704 /* Return true when function NODE is only called directly. 875 /* Return true when function NODE is only called directly.
705 i.e. it is not externally visible, address was not taken and 876 i.e. it is not externally visible, address was not taken and
706 it is not used in any other non-standard way. */ 877 it is not used in any other non-standard way. */
707 878
708 static inline bool 879 static inline bool
709 cgraph_only_called_directly_p (struct cgraph_node *node) 880 cgraph_only_called_directly_p (struct cgraph_node *node)
710 { 881 {
711 return !node->needed && !node->local.externally_visible; 882 return !node->needed && !node->address_taken && !node->local.externally_visible;
712 } 883 }
713 884
714 /* Return true when function NODE can be removed from callgraph 885 /* Return true when function NODE can be removed from callgraph
715 if all direct calls are eliminated. */ 886 if all direct calls are eliminated. */
716 887
717 static inline bool 888 static inline bool
889 cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node)
890 {
891 return (!node->needed && !node->reachable_from_other_partition
892 && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
893 }
894
895 /* Return true when function NODE can be removed from callgraph
896 if all direct calls are eliminated. */
897
898 static inline bool
718 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node) 899 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
719 { 900 {
720 return (!node->needed 901 return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
721 && (DECL_COMDAT (node->decl) || !node->local.externally_visible)); 902 }
903
904 /* Return true when all references to VNODE must be visible in ipa_ref_list.
905 i.e. if the variable is not externally visible or not used in some magic
906 way (asm statement or such).
907 The magic uses are all sumarized in force_output flag. */
908
909 static inline bool
910 varpool_all_refs_explicit_p (struct varpool_node *vnode)
911 {
912 return (!vnode->externally_visible
913 && !vnode->used_from_other_partition
914 && !vnode->force_output);
722 } 915 }
723 916
724 /* Constant pool accessor function. */ 917 /* Constant pool accessor function. */
725 htab_t constant_pool_htab (void); 918 htab_t constant_pool_htab (void);
726 919
920 /* FIXME: inappropriate dependency of cgraph on IPA. */
921 #include "ipa-ref-inline.h"
922
727 #endif /* GCC_CGRAPH_H */ 923 #endif /* GCC_CGRAPH_H */