comparison gcc/cgraph.h @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents a06113de4d67
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
1 /* Callgraph handling code. 1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
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
44 exported to other units). 44 exported to other units).
45 Currently used only for functions. */ 45 Currently used only for functions. */
46 AVAIL_LOCAL 46 AVAIL_LOCAL
47 }; 47 };
48 48
49 /* This is the information that is put into the cgraph local structure
50 to recover a function. */
51 struct lto_file_decl_data;
52
49 extern const char * const cgraph_availability_names[]; 53 extern const char * const cgraph_availability_names[];
54
55 /* Function inlining information. */
56
57 struct GTY(()) inline_summary
58 {
59 /* Estimated stack frame consumption by the function. */
60 HOST_WIDE_INT estimated_self_stack_size;
61
62 /* Size of the function body. */
63 int self_size;
64 /* How many instructions are likely going to disappear after inlining. */
65 int size_inlining_benefit;
66 /* Estimated time spent executing the function body. */
67 int self_time;
68 /* How much time is going to be saved by inlining. */
69 int time_inlining_benefit;
70 };
71
72 /* Information about thunk, used only for same body aliases. */
73
74 struct GTY(()) cgraph_thunk_info {
75 /* Information about the thunk. */
76 HOST_WIDE_INT fixed_offset;
77 HOST_WIDE_INT virtual_value;
78 tree alias;
79 bool this_adjusting;
80 bool virtual_offset_p;
81 /* Set to true when alias node is thunk. */
82 bool thunk_p;
83 };
50 84
51 /* Information about the function collected locally. 85 /* Information about the function collected locally.
52 Available after function is analyzed. */ 86 Available after function is analyzed. */
53 87
54 struct cgraph_local_info GTY(()) 88 struct GTY(()) cgraph_local_info {
55 { 89 /* File stream where this node is being written to. */
56 struct inline_summary { 90 struct lto_file_decl_data * GTY ((skip)) lto_file_data;
57 /* Estimated stack frame consumption by the function. */ 91
58 HOST_WIDE_INT estimated_self_stack_size; 92 struct inline_summary inline_summary;
59
60 /* Size of the function before inlining. */
61 int self_insns;
62 } inline_summary;
63 93
64 /* Set when function function is visible in current compilation unit only 94 /* Set when function function is visible in current compilation unit only
65 and its address is never taken. */ 95 and its address is never taken. */
66 unsigned local : 1; 96 unsigned local : 1;
67 97
91 }; 121 };
92 122
93 /* Information about the function that needs to be computed globally 123 /* Information about the function that needs to be computed globally
94 once compilation is finished. Available only with -funit-at-a-time. */ 124 once compilation is finished. Available only with -funit-at-a-time. */
95 125
96 struct cgraph_global_info GTY(()) 126 struct GTY(()) cgraph_global_info {
97 {
98 /* Estimated stack frame consumption by the function. */ 127 /* Estimated stack frame consumption by the function. */
99 HOST_WIDE_INT estimated_stack_size; 128 HOST_WIDE_INT estimated_stack_size;
100 /* Expected offset of the stack frame of inlined function. */ 129 /* Expected offset of the stack frame of inlined function. */
101 HOST_WIDE_INT stack_frame_offset; 130 HOST_WIDE_INT stack_frame_offset;
102 131
103 /* For inline clones this points to the function they will be 132 /* For inline clones this points to the function they will be
104 inlined into. */ 133 inlined into. */
105 struct cgraph_node *inlined_to; 134 struct cgraph_node *inlined_to;
106 135
107 /* Estimated size of the function after inlining. */ 136 /* Estimated size of the function after inlining. */
108 int insns; 137 int time;
138 int size;
109 139
110 /* Estimated growth after inlining. INT_MIN if not computed. */ 140 /* Estimated growth after inlining. INT_MIN if not computed. */
111 int estimated_growth; 141 int estimated_growth;
112 142
113 /* Set iff the function has been inlined at least once. */ 143 /* Set iff the function has been inlined at least once. */
115 }; 145 };
116 146
117 /* Information about the function that is propagated by the RTL backend. 147 /* Information about the function that is propagated by the RTL backend.
118 Available only for functions that has been already assembled. */ 148 Available only for functions that has been already assembled. */
119 149
120 struct cgraph_rtl_info GTY(()) 150 struct GTY(()) cgraph_rtl_info {
121 {
122 unsigned int preferred_incoming_stack_boundary; 151 unsigned int preferred_incoming_stack_boundary;
152 };
153
154 /* Represent which DECL tree (or reference to such tree)
155 will be replaced by another tree while versioning. */
156 struct GTY(()) ipa_replace_map
157 {
158 /* The tree that will be replaced. */
159 tree old_tree;
160 /* The new (replacing) tree. */
161 tree new_tree;
162 /* True when a substitution should be done, false otherwise. */
163 bool replace_p;
164 /* True when we replace a reference to old_tree. */
165 bool ref_p;
166 };
167 typedef struct ipa_replace_map *ipa_replace_map_p;
168 DEF_VEC_P(ipa_replace_map_p);
169 DEF_VEC_ALLOC_P(ipa_replace_map_p,gc);
170
171 struct GTY(()) cgraph_clone_info
172 {
173 VEC(ipa_replace_map_p,gc)* tree_map;
174 bitmap args_to_skip;
175 bitmap combined_args_to_skip;
123 }; 176 };
124 177
125 /* The cgraph data structure. 178 /* The cgraph data structure.
126 Each function decl has assigned cgraph_node listing callees and callers. */ 179 Each function decl has assigned cgraph_node listing callees and callers. */
127 180
128 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) 181 struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node {
129 {
130 tree decl; 182 tree decl;
131 struct cgraph_edge *callees; 183 struct cgraph_edge *callees;
132 struct cgraph_edge *callers; 184 struct cgraph_edge *callers;
133 struct cgraph_node *next; 185 struct cgraph_node *next;
134 struct cgraph_node *previous; 186 struct cgraph_node *previous;
139 /* Pointer to the next function with same origin, if any. */ 191 /* Pointer to the next function with same origin, if any. */
140 struct cgraph_node *next_nested; 192 struct cgraph_node *next_nested;
141 /* Pointer to the next function in cgraph_nodes_queue. */ 193 /* Pointer to the next function in cgraph_nodes_queue. */
142 struct cgraph_node *next_needed; 194 struct cgraph_node *next_needed;
143 /* Pointer to the next clone. */ 195 /* Pointer to the next clone. */
144 struct cgraph_node *next_clone; 196 struct cgraph_node *next_sibling_clone;
145 struct cgraph_node *prev_clone; 197 struct cgraph_node *prev_sibling_clone;
146 /* Pointer to a single unique cgraph node for this function. If the 198 struct cgraph_node *clones;
147 function is to be output, this is the copy that will survive. */ 199 struct cgraph_node *clone_of;
148 struct cgraph_node *master_clone; 200 /* For normal nodes pointer to the list of alias and thunk nodes,
201 in alias/thunk nodes pointer to the normal node. */
202 struct cgraph_node *same_body;
203 /* Circular list of nodes in the same comdat group if non-NULL. */
204 struct cgraph_node *same_comdat_group;
149 /* For functions with many calls sites it holds map from call expression 205 /* For functions with many calls sites it holds map from call expression
150 to the edge to speed up cgraph_edge function. */ 206 to the edge to speed up cgraph_edge function. */
151 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash; 207 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
152 208
153 PTR GTY ((skip)) aux; 209 PTR GTY ((skip)) aux;
154 210
211 /* Interprocedural passes scheduled to have their transform functions
212 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. */
214 VEC(ipa_opt_pass,heap) * GTY((skip)) ipa_transforms_to_apply;
215
155 struct cgraph_local_info local; 216 struct cgraph_local_info local;
156 struct cgraph_global_info global; 217 struct cgraph_global_info global;
157 struct cgraph_rtl_info rtl; 218 struct cgraph_rtl_info rtl;
219 struct cgraph_clone_info clone;
220 struct cgraph_thunk_info thunk;
158 221
159 /* Expected number of executions: calculated in profile.c. */ 222 /* Expected number of executions: calculated in profile.c. */
160 gcov_type count; 223 gcov_type count;
161 /* Unique id of the node. */ 224 /* Unique id of the node. */
162 int uid; 225 int uid;
165 228
166 /* unique id for profiling. pid is not suitable because of different 229 /* unique id for profiling. pid is not suitable because of different
167 number of cfg nodes with -fprofile-generate and -fprofile-use */ 230 number of cfg nodes with -fprofile-generate and -fprofile-use */
168 int pid; 231 int pid;
169 232
170 /* Set when function must be output - it is externally visible 233 /* Set when function must be output for some reason. The primary
171 or its address is taken. */ 234 use of this flag is to mark functions needed to be output for
235 non-standard reason. Functions that are externally visible
236 or reachable from functions needed to be output are marked
237 by specialized flags. */
172 unsigned needed : 1; 238 unsigned needed : 1;
239 /* Set when function has address taken.
240 In current implementation it imply needed flag. */
241 unsigned address_taken : 1;
173 /* Set when decl is an abstract function pointed to by the 242 /* Set when decl is an abstract function pointed to by the
174 ABSTRACT_DECL_ORIGIN of a reachable function. */ 243 ABSTRACT_DECL_ORIGIN of a reachable function. */
175 unsigned abstract_and_needed : 1; 244 unsigned abstract_and_needed : 1;
176 /* Set when function is reachable by call from other function 245 /* Set when function is reachable by call from other function
177 that is either reachable or needed. */ 246 that is either reachable or needed.
247 This flag is computed at original cgraph construction and then
248 updated in cgraph_remove_unreachable_nodes. Note that after
249 cgraph_remove_unreachable_nodes cgraph still can contain unreachable
250 nodes when they are needed for virtual clone instantiation. */
178 unsigned reachable : 1; 251 unsigned reachable : 1;
179 /* Set once the function is lowered (i.e. its CFG is built). */ 252 /* Set once the function is lowered (i.e. its CFG is built). */
180 unsigned lowered : 1; 253 unsigned lowered : 1;
181 /* Set once the function has been instantiated and its callee 254 /* Set once the function has been instantiated and its callee
182 lists created. */ 255 lists created. */
183 unsigned analyzed : 1; 256 unsigned analyzed : 1;
184 /* Set when function is scheduled to be assembled. */ 257 /* Set when function is scheduled to be processed by local passes. */
185 unsigned output : 1; 258 unsigned process : 1;
186 /* Set for aliases once they got through assemble_alias. */ 259 /* Set for aliases once they got through assemble_alias. */
187 unsigned alias : 1; 260 unsigned alias : 1;
188 261 /* Set for nodes that was constructed and finalized by frontend. */
189 /* In non-unit-at-a-time mode the function body of inline candidates is saved 262 unsigned finalized_by_frontend : 1;
190 into clone before compiling so the function in original form can be 263 /* Set for alias and thunk nodes, same_body points to the node they are alias
191 inlined later. This pointer points to the clone. */ 264 of and they are linked through the next/previous pointers. */
192 tree inline_decl; 265 unsigned same_body_alias : 1;
193 }; 266 };
194 267
195 struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) 268 typedef struct cgraph_node *cgraph_node_ptr;
196 { 269
270 DEF_VEC_P(cgraph_node_ptr);
271 DEF_VEC_ALLOC_P(cgraph_node_ptr,heap);
272 DEF_VEC_ALLOC_P(cgraph_node_ptr,gc);
273
274 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
275 can appear in multiple sets. */
276 struct GTY(()) cgraph_node_set_def
277 {
278 htab_t GTY((param_is (struct cgraph_node_set_element_def))) hashtab;
279 VEC(cgraph_node_ptr, gc) *nodes;
280 PTR GTY ((skip)) aux;
281 };
282
283 typedef struct cgraph_node_set_def *cgraph_node_set;
284
285 DEF_VEC_P(cgraph_node_set);
286 DEF_VEC_ALLOC_P(cgraph_node_set,gc);
287 DEF_VEC_ALLOC_P(cgraph_node_set,heap);
288
289 /* A cgraph node set element contains an index in the vector of nodes in
290 the set. */
291 struct GTY(()) cgraph_node_set_element_def
292 {
293 struct cgraph_node *node;
294 HOST_WIDE_INT index;
295 };
296
297 typedef struct cgraph_node_set_element_def *cgraph_node_set_element;
298 typedef const struct cgraph_node_set_element_def *const_cgraph_node_set_element;
299
300 /* Iterator structure for cgraph node sets. */
301 typedef struct
302 {
303 cgraph_node_set set;
304 unsigned index;
305 } cgraph_node_set_iterator;
306
307 #define DEFCIFCODE(code, string) CIF_ ## code,
308 /* Reasons for inlining failures. */
309 typedef enum {
310 #include "cif-code.def"
311 CIF_N_REASONS
312 } cgraph_inline_failed_t;
313
314 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgraph_edge {
315 /* Expected number of executions: calculated in profile.c. */
316 gcov_type count;
197 struct cgraph_node *caller; 317 struct cgraph_node *caller;
198 struct cgraph_node *callee; 318 struct cgraph_node *callee;
199 struct cgraph_edge *prev_caller; 319 struct cgraph_edge *prev_caller;
200 struct cgraph_edge *next_caller; 320 struct cgraph_edge *next_caller;
201 struct cgraph_edge *prev_callee; 321 struct cgraph_edge *prev_callee;
202 struct cgraph_edge *next_callee; 322 struct cgraph_edge *next_callee;
203 gimple call_stmt; 323 gimple call_stmt;
204 PTR GTY ((skip (""))) aux; 324 PTR GTY ((skip (""))) aux;
205 /* When NULL, inline this call. When non-NULL, points to the explanation 325 /* When equal to CIF_OK, inline this call. Otherwise, points to the
206 why function was not inlined. */ 326 explanation why function was not inlined. */
207 const char *inline_failed; 327 cgraph_inline_failed_t inline_failed;
208 /* Expected number of executions: calculated in profile.c. */ 328 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
209 gcov_type count; 329 when the function is serialized in. */
210 /* Expected frequency of executions within the function. 330 unsigned int lto_stmt_uid;
331 /* Expected frequency of executions within the function.
211 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once 332 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
212 per function call. The range is 0 to CGRAPH_FREQ_MAX. */ 333 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
213 int frequency; 334 int frequency;
335 /* Unique id of the edge. */
336 int uid;
214 /* Depth of loop nest, 1 means no loop nest. */ 337 /* Depth of loop nest, 1 means no loop nest. */
215 unsigned int loop_nest : 31; 338 unsigned short int loop_nest;
216 /* Whether this edge describes a call that was originally indirect. */ 339 /* Whether this edge describes a call that was originally indirect. */
217 unsigned int indirect_call : 1; 340 unsigned int indirect_call : 1;
218 /* Unique id of the edge. */ 341 /* True if the corresponding CALL stmt cannot be inlined. */
219 int uid; 342 unsigned int call_stmt_cannot_inline_p : 1;
343 /* Can this call throw externally? */
344 unsigned int can_throw_external : 1;
220 }; 345 };
221 346
222 #define CGRAPH_FREQ_BASE 1000 347 #define CGRAPH_FREQ_BASE 1000
223 #define CGRAPH_FREQ_MAX 100000 348 #define CGRAPH_FREQ_MAX 100000
224 349
228 DEF_VEC_ALLOC_P(cgraph_edge_p,heap); 353 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
229 354
230 /* The varpool data structure. 355 /* The varpool data structure.
231 Each static variable decl has assigned varpool_node. */ 356 Each static variable decl has assigned varpool_node. */
232 357
233 struct varpool_node GTY((chain_next ("%h.next"))) 358 struct GTY((chain_next ("%h.next"))) varpool_node {
234 {
235 tree decl; 359 tree decl;
236 /* Pointer to the next function in varpool_nodes. */ 360 /* Pointer to the next function in varpool_nodes. */
237 struct varpool_node *next; 361 struct varpool_node *next;
238 /* Pointer to the next function in varpool_nodes_queue. */ 362 /* Pointer to the next function in varpool_nodes_queue. */
239 struct varpool_node *next_needed; 363 struct varpool_node *next_needed;
259 unsigned alias : 1; 383 unsigned alias : 1;
260 }; 384 };
261 385
262 /* Every top level asm statement is put into a cgraph_asm_node. */ 386 /* Every top level asm statement is put into a cgraph_asm_node. */
263 387
264 struct cgraph_asm_node GTY(()) 388 struct GTY(()) cgraph_asm_node {
265 {
266 /* Next asm node. */ 389 /* Next asm node. */
267 struct cgraph_asm_node *next; 390 struct cgraph_asm_node *next;
268 /* String for this asm node. */ 391 /* String for this asm node. */
269 tree asm_str; 392 tree asm_str;
270 /* Ordering of all cgraph nodes. */ 393 /* Ordering of all cgraph nodes. */
304 void dump_cgraph_node (FILE *, struct cgraph_node *); 427 void dump_cgraph_node (FILE *, struct cgraph_node *);
305 void debug_cgraph_node (struct cgraph_node *); 428 void debug_cgraph_node (struct cgraph_node *);
306 void cgraph_insert_node_to_hashtable (struct cgraph_node *node); 429 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
307 void cgraph_remove_edge (struct cgraph_edge *); 430 void cgraph_remove_edge (struct cgraph_edge *);
308 void cgraph_remove_node (struct cgraph_node *); 431 void cgraph_remove_node (struct cgraph_node *);
432 void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
309 void cgraph_release_function_body (struct cgraph_node *); 433 void cgraph_release_function_body (struct cgraph_node *);
310 void cgraph_node_remove_callees (struct cgraph_node *node); 434 void cgraph_node_remove_callees (struct cgraph_node *node);
311 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, 435 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
312 struct cgraph_node *, 436 struct cgraph_node *,
313 gimple, gcov_type, int, int); 437 gimple, gcov_type, int, int);
438
439 struct cgraph_node * cgraph_get_node (tree);
314 struct cgraph_node *cgraph_node (tree); 440 struct cgraph_node *cgraph_node (tree);
315 struct cgraph_node *cgraph_node_for_asm (tree asmname); 441 bool cgraph_same_body_alias (tree, tree);
442 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 *);
444 struct cgraph_node *cgraph_node_for_asm (tree);
316 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple); 445 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
317 void cgraph_set_call_stmt (struct cgraph_edge *, gimple); 446 void cgraph_set_call_stmt (struct cgraph_edge *, gimple);
318 void cgraph_update_edges_for_call_stmt (gimple, gimple); 447 void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple);
448 void cgraph_create_edge_including_clones (struct cgraph_node *,
449 struct cgraph_node *,
450 gimple, gimple, gcov_type, int, int,
451 cgraph_inline_failed_t);
452 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
319 struct cgraph_local_info *cgraph_local_info (tree); 453 struct cgraph_local_info *cgraph_local_info (tree);
320 struct cgraph_global_info *cgraph_global_info (tree); 454 struct cgraph_global_info *cgraph_global_info (tree);
321 struct cgraph_rtl_info *cgraph_rtl_info (tree); 455 struct cgraph_rtl_info *cgraph_rtl_info (tree);
322 const char * cgraph_node_name (struct cgraph_node *); 456 const char * cgraph_node_name (struct cgraph_node *);
323 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, 457 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
324 struct cgraph_node *, 458 struct cgraph_node *, gimple,
325 gimple, gcov_type, int, int, bool); 459 unsigned, gcov_type, int, int, bool);
326 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int, 460 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int,
327 int, bool); 461 int, bool, VEC(cgraph_edge_p,heap) *);
328 462
329 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *); 463 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
330 464
331 struct cgraph_asm_node *cgraph_add_asm_node (tree); 465 struct cgraph_asm_node *cgraph_add_asm_node (tree);
332 466
333 bool cgraph_function_possibly_inlined_p (tree); 467 bool cgraph_function_possibly_inlined_p (tree);
334 void cgraph_unnest_node (struct cgraph_node *); 468 void cgraph_unnest_node (struct cgraph_node *);
335 469
336 enum availability cgraph_function_body_availability (struct cgraph_node *); 470 enum availability cgraph_function_body_availability (struct cgraph_node *);
337 bool cgraph_is_master_clone (struct cgraph_node *);
338 struct cgraph_node *cgraph_master_clone (struct cgraph_node *);
339 void cgraph_add_new_function (tree, bool); 471 void cgraph_add_new_function (tree, bool);
472 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
473 struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
474 VEC(cgraph_edge_p,heap)*,
475 VEC(ipa_replace_map_p,gc)* tree_map,
476 bitmap args_to_skip);
477
478 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
479 void cgraph_set_readonly_flag (struct cgraph_node *, bool);
480 void cgraph_set_pure_flag (struct cgraph_node *, bool);
481 void cgraph_set_looping_const_or_pure_flag (struct cgraph_node *, bool);
340 482
341 /* In cgraphunit.c */ 483 /* In cgraphunit.c */
342 void cgraph_finalize_function (tree, bool); 484 void cgraph_finalize_function (tree, bool);
343 void cgraph_mark_if_needed (tree); 485 void cgraph_mark_if_needed (tree);
344 void cgraph_finalize_compilation_unit (void); 486 void cgraph_finalize_compilation_unit (void);
345 void cgraph_optimize (void); 487 void cgraph_optimize (void);
346 void cgraph_mark_needed_node (struct cgraph_node *); 488 void cgraph_mark_needed_node (struct cgraph_node *);
489 void cgraph_mark_address_taken_node (struct cgraph_node *);
347 void cgraph_mark_reachable_node (struct cgraph_node *); 490 void cgraph_mark_reachable_node (struct cgraph_node *);
348 bool cgraph_inline_p (struct cgraph_edge *, const char **reason); 491 bool cgraph_inline_p (struct cgraph_edge *, cgraph_inline_failed_t *reason);
349 bool cgraph_preserve_function_body_p (tree); 492 bool cgraph_preserve_function_body_p (tree);
350 void verify_cgraph (void); 493 void verify_cgraph (void);
351 void verify_cgraph_node (struct cgraph_node *); 494 void verify_cgraph_node (struct cgraph_node *);
352 void cgraph_build_static_cdtor (char which, tree body, int priority); 495 void cgraph_build_static_cdtor (char which, tree body, int priority);
353 void cgraph_reset_static_var_maps (void); 496 void cgraph_reset_static_var_maps (void);
354 void init_cgraph (void); 497 void init_cgraph (void);
355 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *, 498 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
356 VEC(cgraph_edge_p,heap)*, 499 VEC(cgraph_edge_p,heap)*,
357 varray_type, 500 VEC(ipa_replace_map_p,gc)*,
358 bitmap); 501 bitmap);
359 void cgraph_analyze_function (struct cgraph_node *); 502 void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap);
360 struct cgraph_node *save_inline_function_body (struct cgraph_node *); 503 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
361 void record_references_in_initializer (tree); 504 void record_references_in_initializer (tree, bool);
362 bool cgraph_process_new_functions (void); 505 bool cgraph_process_new_functions (void);
506
507 bool cgraph_decide_is_function_needed (struct cgraph_node *, tree);
363 508
364 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *); 509 typedef void (*cgraph_edge_hook)(struct cgraph_edge *, void *);
365 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *); 510 typedef void (*cgraph_node_hook)(struct cgraph_node *, void *);
366 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *, 511 typedef void (*cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *,
367 void *); 512 void *);
382 void cgraph_call_function_insertion_hooks (struct cgraph_node *node); 527 void cgraph_call_function_insertion_hooks (struct cgraph_node *node);
383 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *); 528 struct cgraph_2edge_hook_list *cgraph_add_edge_duplication_hook (cgraph_2edge_hook, void *);
384 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *); 529 void cgraph_remove_edge_duplication_hook (struct cgraph_2edge_hook_list *);
385 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *); 530 struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook (cgraph_2node_hook, void *);
386 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *); 531 void cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *);
532 void cgraph_materialize_all_clones (void);
387 533
388 /* In cgraphbuild.c */ 534 /* In cgraphbuild.c */
389 unsigned int rebuild_cgraph_edges (void); 535 unsigned int rebuild_cgraph_edges (void);
390 int compute_call_stmt_bb_frequency (basic_block bb); 536 void reset_inline_failed (struct cgraph_node *);
537 int compute_call_stmt_bb_frequency (tree, basic_block bb);
391 538
392 /* In ipa.c */ 539 /* In ipa.c */
393 bool cgraph_remove_unreachable_nodes (bool, FILE *); 540 bool cgraph_remove_unreachable_nodes (bool, FILE *);
394 int cgraph_postorder (struct cgraph_node **); 541 int cgraph_postorder (struct cgraph_node **);
395 542 cgraph_node_set cgraph_node_set_new (void);
543 cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
544 struct cgraph_node *);
545 void cgraph_node_set_add (cgraph_node_set, struct cgraph_node *);
546 void cgraph_node_set_remove (cgraph_node_set, struct cgraph_node *);
547 void dump_cgraph_node_set (FILE *, cgraph_node_set);
548 void debug_cgraph_node_set (cgraph_node_set);
549
550
551 /* In predict.c */
396 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e); 552 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
397 553
398 /* In varpool.c */ 554 /* In varpool.c */
399
400 extern GTY(()) struct varpool_node *varpool_nodes_queue; 555 extern GTY(()) struct varpool_node *varpool_nodes_queue;
401 extern GTY(()) struct varpool_node *varpool_nodes; 556 extern GTY(()) struct varpool_node *varpool_nodes;
402 557
403 struct varpool_node *varpool_node (tree); 558 struct varpool_node *varpool_node (tree);
404 struct varpool_node *varpool_node_for_asm (tree asmname); 559 struct varpool_node *varpool_node_for_asm (tree asmname);
405 void varpool_mark_needed_node (struct varpool_node *); 560 void varpool_mark_needed_node (struct varpool_node *);
561 void debug_varpool (void);
406 void dump_varpool (FILE *); 562 void dump_varpool (FILE *);
407 void dump_varpool_node (FILE *, struct varpool_node *); 563 void dump_varpool_node (FILE *, struct varpool_node *);
408 564
409 void varpool_finalize_decl (tree); 565 void varpool_finalize_decl (tree);
410 bool decide_is_variable_needed (struct varpool_node *, tree); 566 bool decide_is_variable_needed (struct varpool_node *, tree);
411 enum availability cgraph_variable_initializer_availability (struct varpool_node *); 567 enum availability cgraph_variable_initializer_availability (struct varpool_node *);
568 void cgraph_make_node_local (struct cgraph_node *);
569 bool cgraph_node_can_be_local_p (struct cgraph_node *);
412 570
413 bool varpool_assemble_pending_decls (void); 571 bool varpool_assemble_pending_decls (void);
414 bool varpool_assemble_decl (struct varpool_node *node); 572 bool varpool_assemble_decl (struct varpool_node *node);
415 bool varpool_analyze_pending_decls (void); 573 bool varpool_analyze_pending_decls (void);
416 void varpool_remove_unreferenced_decls (void); 574 void varpool_remove_unreferenced_decls (void);
417 void varpool_empty_needed_queue (void); 575 void varpool_empty_needed_queue (void);
576 const char * varpool_node_name (struct varpool_node *node);
418 577
419 /* Walk all reachable static variables. */ 578 /* Walk all reachable static variables. */
420 #define FOR_EACH_STATIC_VARIABLE(node) \ 579 #define FOR_EACH_STATIC_VARIABLE(node) \
421 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed) 580 for ((node) = varpool_nodes_queue; (node); (node) = (node)->next_needed)
422 581
452 for ((node) = varpool_first_static_initializer (); (node); \ 611 for ((node) = varpool_first_static_initializer (); (node); \
453 (node) = varpool_next_static_initializer (node)) 612 (node) = varpool_next_static_initializer (node))
454 613
455 /* In ipa-inline.c */ 614 /* In ipa-inline.c */
456 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool); 615 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
457 bool cgraph_default_inline_p (struct cgraph_node *, const char **);
458 unsigned int compute_inline_parameters (struct cgraph_node *); 616 unsigned int compute_inline_parameters (struct cgraph_node *);
459 617
460 618
461 /* Create a new static variable of type TYPE. */ 619 /* Create a new static variable of type TYPE. */
462 tree add_new_static_var (tree type); 620 tree add_new_static_var (tree type);
463 621
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. */
640 static inline bool
641 csi_end_p (cgraph_node_set_iterator csi)
642 {
643 return csi.index >= VEC_length (cgraph_node_ptr, csi.set->nodes);
644 }
645
646 /* Advance iterator CSI. */
647 static inline void
648 csi_next (cgraph_node_set_iterator *csi)
649 {
650 csi->index++;
651 }
652
653 /* Return the node pointed to by CSI. */
654 static inline struct cgraph_node *
655 csi_node (cgraph_node_set_iterator csi)
656 {
657 return VEC_index (cgraph_node_ptr, csi.set->nodes, csi.index);
658 }
659
660 /* Return an iterator to the first node in SET. */
661 static inline cgraph_node_set_iterator
662 csi_start (cgraph_node_set set)
663 {
664 cgraph_node_set_iterator csi;
665
666 csi.set = set;
667 csi.index = 0;
668 return csi;
669 }
670
671 /* Return true if SET contains NODE. */
672 static inline bool
673 cgraph_node_in_set_p (struct cgraph_node *node, cgraph_node_set set)
674 {
675 cgraph_node_set_iterator csi;
676 csi = cgraph_node_set_find (set, node);
677 return !csi_end_p (csi);
678 }
679
680 /* Return number of nodes in SET. */
681 static inline size_t
682 cgraph_node_set_size (cgraph_node_set set)
683 {
684 return htab_elements (set->hashtab);
685 }
686
687 /* Uniquize all constants that appear in memory.
688 Each constant in memory thus far output is recorded
689 in `const_desc_table'. */
690
691 struct GTY(()) constant_descriptor_tree {
692 /* A MEM for the constant. */
693 rtx rtl;
694
695 /* The value of the constant. */
696 tree value;
697
698 /* Hash of value. Computing the hash from value each time
699 hashfn is called can't work properly, as that means recursive
700 use of the hash table during hash table expansion. */
701 hashval_t hash;
702 };
703
704 /* Return true when function NODE is only called directly.
705 i.e. it is not externally visible, address was not taken and
706 it is not used in any other non-standard way. */
707
708 static inline bool
709 cgraph_only_called_directly_p (struct cgraph_node *node)
710 {
711 return !node->needed && !node->local.externally_visible;
712 }
713
714 /* Return true when function NODE can be removed from callgraph
715 if all direct calls are eliminated. */
716
717 static inline bool
718 cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
719 {
720 return (!node->needed
721 && (DECL_COMDAT (node->decl) || !node->local.externally_visible));
722 }
723
724 /* Constant pool accessor function. */
725 htab_t constant_pool_htab (void);
726
464 #endif /* GCC_CGRAPH_H */ 727 #endif /* GCC_CGRAPH_H */