comparison gcc/cgraph.h @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 /* Callgraph handling code. 1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
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
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 24
25 #include "plugin-api.h"
25 #include "vec.h" 26 #include "vec.h"
26 #include "tree.h" 27 #include "tree.h"
27 #include "basic-block.h" 28 #include "basic-block.h"
28 #include "function.h" 29 #include "function.h"
29 #include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA. */ 30 #include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IPA. */
53 /* This is the information that is put into the cgraph local structure 54 /* This is the information that is put into the cgraph local structure
54 to recover a function. */ 55 to recover a function. */
55 struct lto_file_decl_data; 56 struct lto_file_decl_data;
56 57
57 extern const char * const cgraph_availability_names[]; 58 extern const char * const cgraph_availability_names[];
59 extern const char * const ld_plugin_symbol_resolution_names[];
58 60
59 /* Function inlining information. */ 61 /* Function inlining information. */
60 62
61 struct GTY(()) inline_summary 63 struct GTY(()) inline_summary
62 { 64 {
99 and its address is never taken. */ 101 and its address is never taken. */
100 unsigned local : 1; 102 unsigned local : 1;
101 103
102 /* Set when function is visible by other units. */ 104 /* Set when function is visible by other units. */
103 unsigned externally_visible : 1; 105 unsigned externally_visible : 1;
104 106
105 /* Set once it has been finalized so we consider it to be output. */ 107 /* Set once it has been finalized so we consider it to be output. */
106 unsigned finalized : 1; 108 unsigned finalized : 1;
107 109
108 /* False when there something makes inlining impossible (such as va_arg). */ 110 /* False when there something makes inlining impossible (such as va_arg). */
109 unsigned inlinable : 1; 111 unsigned inlinable : 1;
110 112
111 /* False when there something makes versioning impossible. 113 /* False when there something makes versioning impossible.
112 Currently computed and used only by ipa-cp. */ 114 Currently computed and used only by ipa-cp. */
113 unsigned versionable : 1; 115 unsigned versionable : 1;
116
117 /* False when function calling convention and signature can not be changed.
118 This is the case when __builtin_apply_args is used. */
119 unsigned can_change_signature : 1;
114 120
115 /* True when function should be inlined independently on its size. */ 121 /* True when function should be inlined independently on its size. */
116 unsigned disregard_inline_limits : 1; 122 unsigned disregard_inline_limits : 1;
117 123
118 /* True when the function has been originally extern inline, but it is 124 /* True when the function has been originally extern inline, but it is
174 struct GTY(()) cgraph_clone_info 180 struct GTY(()) cgraph_clone_info
175 { 181 {
176 VEC(ipa_replace_map_p,gc)* tree_map; 182 VEC(ipa_replace_map_p,gc)* tree_map;
177 bitmap args_to_skip; 183 bitmap args_to_skip;
178 bitmap combined_args_to_skip; 184 bitmap combined_args_to_skip;
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 }; 185 };
194 186
195 187
196 /* The cgraph data structure. 188 /* The cgraph data structure.
197 Each function decl has assigned cgraph_node listing callees and callers. */ 189 Each function decl has assigned cgraph_node listing callees and callers. */
224 /* Circular list of nodes in the same comdat group if non-NULL. */ 216 /* Circular list of nodes in the same comdat group if non-NULL. */
225 struct cgraph_node *same_comdat_group; 217 struct cgraph_node *same_comdat_group;
226 /* For functions with many calls sites it holds map from call expression 218 /* For functions with many calls sites it holds map from call expression
227 to the edge to speed up cgraph_edge function. */ 219 to the edge to speed up cgraph_edge function. */
228 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash; 220 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
221 /* Declaration node used to be clone of. */
222 tree former_clone_of;
229 223
230 PTR GTY ((skip)) aux; 224 PTR GTY ((skip)) aux;
231 225
232 /* Interprocedural passes scheduled to have their transform functions 226 /* Interprocedural passes scheduled to have their transform functions
233 applied next time we execute local pass on them. We maintain it 227 applied next time we execute local pass on them. We maintain it
241 struct cgraph_clone_info clone; 235 struct cgraph_clone_info clone;
242 struct cgraph_thunk_info thunk; 236 struct cgraph_thunk_info thunk;
243 237
244 /* Expected number of executions: calculated in profile.c. */ 238 /* Expected number of executions: calculated in profile.c. */
245 gcov_type count; 239 gcov_type count;
240 /* How to scale counts at materialization time; used to merge
241 LTO units with different number of profile runs. */
242 int count_materialization_scale;
246 /* Unique id of the node. */ 243 /* Unique id of the node. */
247 int uid; 244 int uid;
248 /* Ordering of all cgraph nodes. */ 245 /* Ordering of all cgraph nodes. */
249 int order; 246 int order;
250 247
251 /* unique id for profiling. pid is not suitable because of different 248 /* unique id for profiling. pid is not suitable because of different
252 number of cfg nodes with -fprofile-generate and -fprofile-use */ 249 number of cfg nodes with -fprofile-generate and -fprofile-use */
253 int pid; 250 int pid;
251 enum ld_plugin_symbol_resolution resolution;
254 252
255 /* Set when function must be output for some reason. The primary 253 /* Set when function must be output for some reason. The primary
256 use of this flag is to mark functions needed to be output for 254 use of this flag is to mark functions needed to be output for
257 non-standard reason. Functions that are externally visible 255 non-standard reason. Functions that are externally visible
258 or reachable from functions needed to be output are marked 256 or reachable from functions needed to be output are marked
276 /* Set once the function is lowered (i.e. its CFG is built). */ 274 /* Set once the function is lowered (i.e. its CFG is built). */
277 unsigned lowered : 1; 275 unsigned lowered : 1;
278 /* Set once the function has been instantiated and its callee 276 /* Set once the function has been instantiated and its callee
279 lists created. */ 277 lists created. */
280 unsigned analyzed : 1; 278 unsigned analyzed : 1;
281 /* Set when function is available in the other LTRANS partition. */ 279 /* Set when function is available in the other LTRANS partition.
280 During WPA output it is used to mark nodes that are present in
281 multiple partitions. */
282 unsigned in_other_partition : 1; 282 unsigned in_other_partition : 1;
283 /* Set when function is scheduled to be processed by local passes. */ 283 /* Set when function is scheduled to be processed by local passes. */
284 unsigned process : 1; 284 unsigned process : 1;
285 /* Set for aliases once they got through assemble_alias. */ 285 /* Set for aliases once they got through assemble_alias. */
286 unsigned alias : 1; 286 unsigned alias : 1;
290 of and they are linked through the next/previous pointers. */ 290 of and they are linked through the next/previous pointers. */
291 unsigned same_body_alias : 1; 291 unsigned same_body_alias : 1;
292 /* How commonly executed the node is. Initialized during branch 292 /* How commonly executed the node is. Initialized during branch
293 probabilities pass. */ 293 probabilities pass. */
294 ENUM_BITFIELD (node_frequency) frequency : 2; 294 ENUM_BITFIELD (node_frequency) frequency : 2;
295 /* True when function can only be called at startup (from static ctor). */
296 unsigned only_called_at_startup : 1;
297 /* True when function can only be called at startup (from static dtor). */
298 unsigned only_called_at_exit : 1;
295 }; 299 };
296 300
297 typedef struct cgraph_node *cgraph_node_ptr; 301 typedef struct cgraph_node *cgraph_node_ptr;
298 302
299 DEF_VEC_P(cgraph_node_ptr); 303 DEF_VEC_P(cgraph_node_ptr);
304 can appear in multiple sets. */ 308 can appear in multiple sets. */
305 struct GTY(()) cgraph_node_set_def 309 struct GTY(()) cgraph_node_set_def
306 { 310 {
307 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab; 311 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
308 VEC(cgraph_node_ptr, gc) *nodes; 312 VEC(cgraph_node_ptr, gc) *nodes;
309 PTR GTY ((skip)) aux;
310 }; 313 };
311 314
312 typedef struct varpool_node *varpool_node_ptr; 315 typedef struct varpool_node *varpool_node_ptr;
313 316
314 DEF_VEC_P(varpool_node_ptr); 317 DEF_VEC_P(varpool_node_ptr);
319 can appear in multiple sets. */ 322 can appear in multiple sets. */
320 struct GTY(()) varpool_node_set_def 323 struct GTY(()) varpool_node_set_def
321 { 324 {
322 htab_t GTY((param_is (struct varpool_node_set_element_def))) hashtab; 325 htab_t GTY((param_is (struct varpool_node_set_element_def))) hashtab;
323 VEC(varpool_node_ptr, gc) *nodes; 326 VEC(varpool_node_ptr, gc) *nodes;
324 PTR GTY ((skip)) aux;
325 }; 327 };
326 328
327 typedef struct cgraph_node_set_def *cgraph_node_set; 329 typedef struct cgraph_node_set_def *cgraph_node_set;
328 330
329 DEF_VEC_P(cgraph_node_set); 331 DEF_VEC_P(cgraph_node_set);
386 /* Offset accumulated from ancestor jump functions of inlined call graph 388 /* Offset accumulated from ancestor jump functions of inlined call graph
387 edges. */ 389 edges. */
388 HOST_WIDE_INT anc_offset; 390 HOST_WIDE_INT anc_offset;
389 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */ 391 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
390 HOST_WIDE_INT otr_token; 392 HOST_WIDE_INT otr_token;
393 /* Delta by which must be added to this parameter to compensate for a skipped
394 this adjusting thunk. */
395 HOST_WIDE_INT thunk_delta;
391 /* Type of the object from OBJ_TYPE_REF_OBJECT. */ 396 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
392 tree otr_type; 397 tree otr_type;
393 /* Index of the parameter that is called. */ 398 /* Index of the parameter that is called. */
394 int param_index; 399 int param_index;
395 /* ECF flags determined from the caller. */ 400 /* ECF flags determined from the caller. */
461 nodes a pointer to the normal node. */ 466 nodes a pointer to the normal node. */
462 struct varpool_node *extra_name; 467 struct varpool_node *extra_name;
463 /* Circular list of nodes in the same comdat group if non-NULL. */ 468 /* Circular list of nodes in the same comdat group if non-NULL. */
464 struct varpool_node *same_comdat_group; 469 struct varpool_node *same_comdat_group;
465 struct ipa_ref_list ref_list; 470 struct ipa_ref_list ref_list;
471 /* File stream where this node is being written to. */
472 struct lto_file_decl_data * lto_file_data;
466 PTR GTY ((skip)) aux; 473 PTR GTY ((skip)) aux;
467 /* Ordering of all cgraph nodes. */ 474 /* Ordering of all cgraph nodes. */
468 int order; 475 int order;
476 enum ld_plugin_symbol_resolution resolution;
469 477
470 /* Set when function must be output - it is externally visible 478 /* Set when function must be output - it is externally visible
471 or its address is taken. */ 479 or its address is taken. */
472 unsigned needed : 1; 480 unsigned needed : 1;
473 /* Needed variables might become dead by optimization. This flag 481 /* Needed variables might become dead by optimization. This flag
485 /* Set for aliases once they got through assemble_alias. Also set for 493 /* Set for aliases once they got through assemble_alias. Also set for
486 extra name aliases in varpool_extra_name_alias. */ 494 extra name aliases in varpool_extra_name_alias. */
487 unsigned alias : 1; 495 unsigned alias : 1;
488 /* Set when variable is used from other LTRANS partition. */ 496 /* Set when variable is used from other LTRANS partition. */
489 unsigned used_from_other_partition : 1; 497 unsigned used_from_other_partition : 1;
490 /* Set when variable is available in the other LTRANS partition. */ 498 /* Set when variable is available in the other LTRANS partition.
499 During WPA output it is used to mark nodes that are present in
500 multiple partitions. */
491 unsigned in_other_partition : 1; 501 unsigned in_other_partition : 1;
492 }; 502 };
493 503
494 /* Every top level asm statement is put into a cgraph_asm_node. */ 504 /* Every top level asm statement is put into a cgraph_asm_node. */
495 505
541 void cgraph_release_function_body (struct cgraph_node *); 551 void cgraph_release_function_body (struct cgraph_node *);
542 void cgraph_node_remove_callees (struct cgraph_node *node); 552 void cgraph_node_remove_callees (struct cgraph_node *node);
543 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, 553 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
544 struct cgraph_node *, 554 struct cgraph_node *,
545 gimple, gcov_type, int, int); 555 gimple, gcov_type, int, int);
546 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple, int, 556 struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
547 gcov_type, int, int); 557 int, gcov_type, int, int);
548 struct cgraph_node * cgraph_get_node (tree); 558 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
549 struct cgraph_node *cgraph_node (tree); 559 struct cgraph_node * cgraph_get_node (const_tree);
550 bool cgraph_same_body_alias (tree, tree); 560 struct cgraph_node * cgraph_get_node_or_alias (const_tree);
551 void cgraph_add_thunk (tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree); 561 struct cgraph_node * cgraph_node (tree);
562 struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree);
563 struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT,
564 HOST_WIDE_INT, tree, tree);
552 void cgraph_remove_same_body_alias (struct cgraph_node *); 565 void cgraph_remove_same_body_alias (struct cgraph_node *);
553 struct cgraph_node *cgraph_node_for_asm (tree); 566 struct cgraph_node *cgraph_node_for_asm (tree);
554 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple); 567 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
555 void cgraph_set_call_stmt (struct cgraph_edge *, gimple); 568 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
556 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple); 569 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
568 unsigned, gcov_type, int, int, bool); 581 unsigned, gcov_type, int, int, bool);
569 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int, 582 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int,
570 int, bool, VEC(cgraph_edge_p,heap) *); 583 int, bool, VEC(cgraph_edge_p,heap) *);
571 584
572 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *); 585 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
573 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *); 586 void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *,
587 HOST_WIDE_INT);
574 588
575 struct cgraph_asm_node *cgraph_add_asm_node (tree); 589 struct cgraph_asm_node *cgraph_add_asm_node (tree);
576 590
577 bool cgraph_function_possibly_inlined_p (tree); 591 bool cgraph_function_possibly_inlined_p (tree);
578 void cgraph_unnest_node (struct cgraph_node *); 592 void cgraph_unnest_node (struct cgraph_node *);
581 void cgraph_add_new_function (tree, bool); 595 void cgraph_add_new_function (tree, bool);
582 const char* cgraph_inline_failed_string (cgraph_inline_failed_t); 596 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
583 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node, 597 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
584 VEC(cgraph_edge_p,heap)*, 598 VEC(cgraph_edge_p,heap)*,
585 VEC(ipa_replace_map_p,gc)* tree_map, 599 VEC(ipa_replace_map_p,gc)* tree_map,
586 bitmap args_to_skip); 600 bitmap args_to_skip,
601 const char *clone_name);
587 602
588 void cgraph_set_nothrow_flag (struct cgraph_node *, bool); 603 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
589 void cgraph_set_readonly_flag (struct cgraph_node *, bool); 604 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
590 void cgraph_set_pure_flag (struct cgraph_node *, bool); 605 void cgraph_set_pure_flag (struct cgraph_node *, bool, bool);
591 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool); 606 tree clone_function_name (tree decl, const char *);
607 bool cgraph_node_cannot_return (struct cgraph_node *);
608 bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *);
609 bool cgraph_will_be_removed_from_program_if_no_direct_calls
610 (struct cgraph_node *node);
611 bool cgraph_can_remove_if_no_direct_calls_and_refs_p
612 (struct cgraph_node *node);
613 bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution);
614 bool cgraph_used_from_object_file_p (struct cgraph_node *node);
615 bool varpool_used_from_object_file_p (struct varpool_node *node);
592 616
593 /* In cgraphunit.c */ 617 /* In cgraphunit.c */
618 extern FILE *cgraph_dump_file;
594 void cgraph_finalize_function (tree, bool); 619 void cgraph_finalize_function (tree, bool);
595 void cgraph_mark_if_needed (tree); 620 void cgraph_mark_if_needed (tree);
596 void cgraph_finalize_compilation_unit (void); 621 void cgraph_finalize_compilation_unit (void);
597 void cgraph_optimize (void); 622 void cgraph_optimize (void);
598 void cgraph_mark_needed_node (struct cgraph_node *); 623 void cgraph_mark_needed_node (struct cgraph_node *);
606 void cgraph_reset_static_var_maps (void); 631 void cgraph_reset_static_var_maps (void);
607 void init_cgraph (void); 632 void init_cgraph (void);
608 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *, 633 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
609 VEC(cgraph_edge_p,heap)*, 634 VEC(cgraph_edge_p,heap)*,
610 VEC(ipa_replace_map_p,gc)*, 635 VEC(ipa_replace_map_p,gc)*,
611 bitmap); 636 bitmap, bitmap, basic_block,
612 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap); 637 const char *);
638 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap,
639 bitmap, basic_block);
613 struct cgraph_node *save_inline_function_body (struct cgraph_node *); 640 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
614 void record_references_in_initializer (tree, bool); 641 void record_references_in_initializer (tree, bool);
615 bool cgraph_process_new_functions (void); 642 bool cgraph_process_new_functions (void);
616 643
617 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree); 644 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
665 void varpool_node_set_add (varpool_node_set, struct varpool_node *); 692 void varpool_node_set_add (varpool_node_set, struct varpool_node *);
666 void varpool_node_set_remove (varpool_node_set, struct varpool_node *); 693 void varpool_node_set_remove (varpool_node_set, struct varpool_node *);
667 void dump_varpool_node_set (FILE *, varpool_node_set); 694 void dump_varpool_node_set (FILE *, varpool_node_set);
668 void debug_varpool_node_set (varpool_node_set); 695 void debug_varpool_node_set (varpool_node_set);
669 void ipa_discover_readonly_nonaddressable_vars (void); 696 void ipa_discover_readonly_nonaddressable_vars (void);
697 bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *);
670 698
671 /* In predict.c */ 699 /* In predict.c */
672 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e); 700 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
673 701
674 /* In varpool.c */ 702 /* In varpool.c */
688 void cgraph_make_decl_local (tree); 716 void cgraph_make_decl_local (tree);
689 void cgraph_make_node_local (struct cgraph_node *); 717 void cgraph_make_node_local (struct cgraph_node *);
690 bool cgraph_node_can_be_local_p (struct cgraph_node *); 718 bool cgraph_node_can_be_local_p (struct cgraph_node *);
691 719
692 720
693 struct varpool_node * varpool_get_node (tree decl); 721 struct varpool_node * varpool_get_node (const_tree decl);
694 void varpool_remove_node (struct varpool_node *node); 722 void varpool_remove_node (struct varpool_node *node);
723 void varpool_finalize_named_section_flags (struct varpool_node *node);
695 bool varpool_assemble_pending_decls (void); 724 bool varpool_assemble_pending_decls (void);
696 bool varpool_assemble_decl (struct varpool_node *node); 725 bool varpool_assemble_decl (struct varpool_node *node);
697 bool varpool_analyze_pending_decls (void); 726 bool varpool_analyze_pending_decls (void);
698 void varpool_remove_unreferenced_decls (void); 727 void varpool_remove_unreferenced_decls (void);
699 void varpool_empty_needed_queue (void); 728 void varpool_empty_needed_queue (void);
700 bool varpool_extra_name_alias (tree, tree); 729 struct varpool_node * varpool_extra_name_alias (tree, tree);
701 const char * varpool_node_name (struct varpool_node *node); 730 const char * varpool_node_name (struct varpool_node *node);
702 void varpool_reset_queue (void); 731 void varpool_reset_queue (void);
732 bool const_value_known_p (tree);
703 733
704 /* Walk all reachable static variables. */ 734 /* Walk all reachable static variables. */
705 #define FOR_EACH_STATIC_VARIABLE(node) \ 735 #define FOR_EACH_STATIC_VARIABLE(node) \
706 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed) 736 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
707 737
710 varpool_first_static_initializer (void) 740 varpool_first_static_initializer (void)
711 { 741 {
712 struct varpool_node *node; 742 struct varpool_node *node;
713 for (node = varpool_nodes_queue; node; node = node->next_needed) 743 for (node = varpool_nodes_queue; node; node = node->next_needed)
714 { 744 {
715 gcc_assert (TREE_CODE (node->decl) == VAR_DECL); 745 gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
716 if (DECL_INITIAL (node->decl)) 746 if (DECL_INITIAL (node->decl))
717 return node; 747 return node;
718 } 748 }
719 return NULL; 749 return NULL;
720 } 750 }
723 static inline struct varpool_node * 753 static inline struct varpool_node *
724 varpool_next_static_initializer (struct varpool_node *node) 754 varpool_next_static_initializer (struct varpool_node *node)
725 { 755 {
726 for (node = node->next_needed; node; node = node->next_needed) 756 for (node = node->next_needed; node; node = node->next_needed)
727 { 757 {
728 gcc_assert (TREE_CODE (node->decl) == VAR_DECL); 758 gcc_checking_assert (TREE_CODE (node->decl) == VAR_DECL);
729 if (DECL_INITIAL (node->decl)) 759 if (DECL_INITIAL (node->decl))
730 return node; 760 return node;
731 } 761 }
732 return NULL; 762 return NULL;
733 } 763 }
737 for ((node) = varpool_first_static_initializer (); (node); \ 767 for ((node) = varpool_first_static_initializer (); (node); \
738 (node) = varpool_next_static_initializer (node)) 768 (node) = varpool_next_static_initializer (node))
739 769
740 /* In ipa-inline.c */ 770 /* In ipa-inline.c */
741 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool); 771 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
742 unsigned int compute_inline_parameters (struct cgraph_node *); 772 void compute_inline_parameters (struct cgraph_node *);
743 773
744 774
745 /* Create a new static variable of type TYPE. */ 775 /* Create a new static variable of type TYPE. */
746 tree add_new_static_var (tree type); 776 tree add_new_static_var (tree type);
747 777
860 890
861 /* Return true if set is nonempty. */ 891 /* Return true if set is nonempty. */
862 static inline bool 892 static inline bool
863 cgraph_node_set_nonempty_p (cgraph_node_set set) 893 cgraph_node_set_nonempty_p (cgraph_node_set set)
864 { 894 {
865 return VEC_length (cgraph_node_ptr, set->nodes); 895 return !VEC_empty (cgraph_node_ptr, set->nodes);
866 } 896 }
867 897
868 /* Return true if set is nonempty. */ 898 /* Return true if set is nonempty. */
869 static inline bool 899 static inline bool
870 varpool_node_set_nonempty_p (varpool_node_set set) 900 varpool_node_set_nonempty_p (varpool_node_set set)
871 { 901 {
872 return VEC_length (varpool_node_ptr, set->nodes); 902 return !VEC_empty (varpool_node_ptr, set->nodes);
873 } 903 }
874 904
875 /* Return true when function NODE is only called directly. 905 /* Return true when function NODE is only called directly.
876 i.e. it is not externally visible, address was not taken and 906 i.e. it is not externally visible, address was not taken and
877 it is not used in any other non-standard way. */ 907 it is not used in any other non-standard way. */
878 908
879 static inline bool 909 static inline bool
880 cgraph_only_called_directly_p (struct cgraph_node *node) 910 cgraph_only_called_directly_p (struct cgraph_node *node)
881 { 911 {
882 return !node->needed && !node->address_taken && !node->local.externally_visible; 912 gcc_assert (!node->global.inlined_to);
913 return (!node->needed && !node->address_taken
914 && !node->reachable_from_other_partition
915 && !DECL_STATIC_CONSTRUCTOR (node->decl)
916 && !DECL_STATIC_DESTRUCTOR (node->decl)
917 && !node->local.externally_visible);
883 } 918 }
884 919
885 /* Return true when function NODE can be removed from callgraph 920 /* Return true when function NODE can be removed from callgraph
886 if all direct calls are eliminated. */ 921 if all direct calls are eliminated. */
887 922
888 static inline bool 923 static inline bool
889 cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node) 924 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
890 { 925 {
891 return (!node->needed && !node->reachable_from_other_partition 926 /* Extern inlines can always go, we will use the external definition. */
892 && (DECL_COMDAT (node->decl) || !node->local.externally_visible)); 927 if (DECL_EXTERNAL (node->decl))
928 return true;
929 return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
893 } 930 }
894 931
895 /* Return true when function NODE can be removed from callgraph 932 /* Return true when function NODE can be removed from callgraph
896 if all direct calls are eliminated. */ 933 if all direct calls are eliminated. */
897 934
898 static inline bool 935 static inline bool
899 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node) 936 varpool_can_remove_if_no_refs (struct varpool_node *node)
900 { 937 {
901 return !node->address_taken && cgraph_can_remove_if_no_direct_calls_and_refs_p (node); 938 return (!node->force_output && !node->used_from_other_partition
939 && (flag_toplevel_reorder || DECL_COMDAT (node->decl)
940 || DECL_ARTIFICIAL (node->decl))
941 && (DECL_COMDAT (node->decl) || !node->externally_visible));
902 } 942 }
903 943
904 /* Return true when all references to VNODE must be visible in ipa_ref_list. 944 /* 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 945 i.e. if the variable is not externally visible or not used in some magic
906 way (asm statement or such). 946 way (asm statement or such).
907 The magic uses are all sumarized in force_output flag. */ 947 The magic uses are all summarized in force_output flag. */
908 948
909 static inline bool 949 static inline bool
910 varpool_all_refs_explicit_p (struct varpool_node *vnode) 950 varpool_all_refs_explicit_p (struct varpool_node *vnode)
911 { 951 {
912 return (!vnode->externally_visible 952 return (!vnode->externally_visible