Add files that I missed when importing NaCl changes earlier
[gcc/nacl-gcc.git] / gcc / cgraph.h
blob695f2ab35e26bb6dd0b10650db03b51ba4317cb2
1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_CGRAPH_H
22 #define GCC_CGRAPH_H
23 #include "tree.h"
24 #include "basic-block.h"
26 enum availability
28 /* Not yet set by cgraph_function_body_availability. */
29 AVAIL_UNSET,
30 /* Function body/variable initializer is unknown. */
31 AVAIL_NOT_AVAILABLE,
32 /* Function body/variable initializer is known but might be replaced
33 by a different one from other compilation unit and thus needs to
34 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
35 arbitrary side effects on escaping variables and functions, while
36 like AVAILABLE it might access static variables. */
37 AVAIL_OVERWRITABLE,
38 /* Function body/variable initializer is known and will be used in final
39 program. */
40 AVAIL_AVAILABLE,
41 /* Function body/variable initializer is known and all it's uses are explicitly
42 visible within current unit (ie it's address is never taken and it is not
43 exported to other units).
44 Currently used only for functions. */
45 AVAIL_LOCAL
48 /* Information about the function collected locally.
49 Available after function is analyzed. */
51 struct cgraph_local_info GTY(())
53 /* Size of the function before inlining. */
54 int self_insns;
56 /* Set when function function is visible in current compilation unit only
57 and its address is never taken. */
58 unsigned local : 1;
60 /* Set when function is visible by other units. */
61 unsigned externally_visible : 1;
63 /* Set once it has been finalized so we consider it to be output. */
64 unsigned finalized : 1;
66 /* False when there something makes inlining impossible (such as va_arg). */
67 unsigned inlinable : 1;
69 /* True when function should be inlined independently on its size. */
70 unsigned disregard_inline_limits : 1;
72 /* True when the function has been originally extern inline, but it is
73 redefined now. */
74 unsigned redefined_extern_inline : 1;
76 /* True if statics_read_for_function and
77 statics_written_for_function contain valid data. */
78 unsigned for_functions_valid : 1;
80 /* True if the function is going to be emitted in some other translation
81 unit, referenced from vtable. */
82 unsigned vtable_method : 1;
85 /* Information about the function that needs to be computed globally
86 once compilation is finished. Available only with -funit-at-time. */
88 struct cgraph_global_info GTY(())
90 /* For inline clones this points to the function they will be inlined into. */
91 struct cgraph_node *inlined_to;
93 /* Estimated size of the function after inlining. */
94 int insns;
96 /* Estimated growth after inlining. INT_MIN if not computed. */
97 int estimated_growth;
99 /* Set iff the function has been inlined at least once. */
100 bool inlined;
103 /* Information about the function that is propagated by the RTL backend.
104 Available only for functions that has been already assembled. */
106 struct cgraph_rtl_info GTY(())
108 int preferred_incoming_stack_boundary;
111 /* The cgraph data structure.
112 Each function decl has assigned cgraph_node listing callees and callers. */
114 struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
116 tree decl;
117 struct cgraph_edge *callees;
118 struct cgraph_edge *callers;
119 struct cgraph_node *next;
120 struct cgraph_node *previous;
121 /* For nested functions points to function the node is nested in. */
122 struct cgraph_node *origin;
123 /* Points to first nested function, if any. */
124 struct cgraph_node *nested;
125 /* Pointer to the next function with same origin, if any. */
126 struct cgraph_node *next_nested;
127 /* Pointer to the next function in cgraph_nodes_queue. */
128 struct cgraph_node *next_needed;
129 /* Pointer to the next clone. */
130 struct cgraph_node *next_clone;
131 struct cgraph_node *prev_clone;
132 /* Pointer to a single unique cgraph node for this function. If the
133 function is to be output, this is the copy that will survive. */
134 struct cgraph_node *master_clone;
135 /* For functions with many calls sites it holds map from call expression
136 to the edge to speed up cgraph_edge function. */
137 htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
139 PTR GTY ((skip)) aux;
141 struct cgraph_local_info local;
142 struct cgraph_global_info global;
143 struct cgraph_rtl_info rtl;
145 /* Expected number of executions: calculated in profile.c. */
146 gcov_type count;
147 /* Unique id of the node. */
148 int uid;
149 /* Ordering of all cgraph nodes. */
150 int order;
152 /* Set when function must be output - it is externally visible
153 or its address is taken. */
154 unsigned needed : 1;
155 /* Set when function is reachable by call from other function
156 that is either reachable or needed. */
157 unsigned reachable : 1;
158 /* Set once the function is lowered (i.e. its CFG is built). */
159 unsigned lowered : 1;
160 /* Set once the function has been instantiated and its callee
161 lists created. */
162 unsigned analyzed : 1;
163 /* Set when function is scheduled to be assembled. */
164 unsigned output : 1;
165 /* Set for aliases once they got through assemble_alias. */
166 unsigned alias : 1;
168 /* In non-unit-at-a-time mode the function body of inline candidates is saved
169 into clone before compiling so the function in original form can be
170 inlined later. This pointer points to the clone. */
171 tree inline_decl;
174 struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
176 struct cgraph_node *caller;
177 struct cgraph_node *callee;
178 struct cgraph_edge *prev_caller;
179 struct cgraph_edge *next_caller;
180 struct cgraph_edge *prev_callee;
181 struct cgraph_edge *next_callee;
182 tree call_stmt;
183 PTR GTY ((skip (""))) aux;
184 /* When NULL, inline this call. When non-NULL, points to the explanation
185 why function was not inlined. */
186 const char *inline_failed;
187 /* Expected number of executions: calculated in profile.c. */
188 gcov_type count;
189 /* Depth of loop nest, 1 means no loop nest. */
190 int loop_nest;
193 typedef struct cgraph_edge *cgraph_edge_p;
195 DEF_VEC_P(cgraph_edge_p);
196 DEF_VEC_ALLOC_P(cgraph_edge_p,heap);
198 /* The cgraph_varpool data structure.
199 Each static variable decl has assigned cgraph_varpool_node. */
201 struct cgraph_varpool_node GTY(())
203 tree decl;
204 /* Pointer to the next function in cgraph_varpool_nodes. */
205 struct cgraph_varpool_node *next;
206 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
207 struct cgraph_varpool_node *next_needed;
208 /* Ordering of all cgraph nodes. */
209 int order;
211 /* Set when function must be output - it is externally visible
212 or its address is taken. */
213 unsigned needed : 1;
214 /* Needed variables might become dead by optimization. This flag
215 forces the variable to be output even if it appears dead otherwise. */
216 unsigned force_output : 1;
217 /* Set once the variable has been instantiated and its callee
218 lists created. */
219 unsigned analyzed : 1;
220 /* Set once it has been finalized so we consider it to be output. */
221 unsigned finalized : 1;
222 /* Set when variable is scheduled to be assembled. */
223 unsigned output : 1;
224 /* Set when function is visible by other units. */
225 unsigned externally_visible : 1;
226 /* Set for aliases once they got through assemble_alias. */
227 unsigned alias : 1;
230 /* Every top level asm statement is put into a cgraph_asm_node. */
232 struct cgraph_asm_node GTY(())
234 /* Next asm node. */
235 struct cgraph_asm_node *next;
236 /* String for this asm node. */
237 tree asm_str;
238 /* Ordering of all cgraph nodes. */
239 int order;
242 extern GTY(()) struct cgraph_node *cgraph_nodes;
243 extern GTY(()) int cgraph_n_nodes;
244 extern GTY(()) int cgraph_max_uid;
245 extern bool cgraph_global_info_ready;
246 extern bool cgraph_function_flags_ready;
247 extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
248 extern GTY(()) struct cgraph_node *cgraph_expand_queue;
250 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_first_unanalyzed_node;
251 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_last_needed_node;
252 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
253 extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes;
254 extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
255 extern GTY(()) int cgraph_order;
257 /* In cgraph.c */
258 void dump_cgraph (FILE *);
259 void dump_cgraph_node (FILE *, struct cgraph_node *);
260 void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
261 void dump_varpool (FILE *);
262 void dump_cgraph_varpool_node (FILE *, struct cgraph_varpool_node *);
263 void cgraph_remove_edge (struct cgraph_edge *);
264 void cgraph_remove_node (struct cgraph_node *);
265 void cgraph_node_remove_callees (struct cgraph_node *node);
266 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
267 struct cgraph_node *,
268 tree, gcov_type, int);
269 struct cgraph_node *cgraph_node (tree);
270 struct cgraph_node *cgraph_node_for_asm (tree asmname);
271 struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree);
272 void cgraph_set_call_stmt (struct cgraph_edge *, tree);
273 struct cgraph_local_info *cgraph_local_info (tree);
274 struct cgraph_global_info *cgraph_global_info (tree);
275 struct cgraph_rtl_info *cgraph_rtl_info (tree);
276 const char * cgraph_node_name (struct cgraph_node *);
277 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
278 struct cgraph_node *,
279 tree, gcov_type, int, bool);
280 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type,
281 int, bool);
283 struct cgraph_varpool_node *cgraph_varpool_node (tree);
284 struct cgraph_varpool_node *cgraph_varpool_node_for_asm (tree asmname);
285 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
286 void cgraph_varpool_finalize_decl (tree);
287 void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
289 struct cgraph_asm_node *cgraph_add_asm_node (tree);
291 bool cgraph_function_possibly_inlined_p (tree);
292 void cgraph_unnest_node (struct cgraph_node *);
293 void cgraph_varpool_enqueue_needed_node (struct cgraph_varpool_node *);
294 void cgraph_varpool_reset_queue (void);
295 bool decide_is_variable_needed (struct cgraph_varpool_node *, tree);
297 enum availability cgraph_function_body_availability (struct cgraph_node *);
298 enum availability cgraph_variable_initializer_availability (struct cgraph_varpool_node *);
299 bool cgraph_is_master_clone (struct cgraph_node *);
300 struct cgraph_node *cgraph_master_clone (struct cgraph_node *);
301 void cgraph_add_new_function (tree);
303 /* In cgraphunit.c */
304 bool cgraph_assemble_pending_functions (void);
305 bool cgraph_varpool_assemble_pending_decls (void);
306 void cgraph_finalize_function (tree, bool);
307 void cgraph_finalize_compilation_unit (void);
308 void cgraph_optimize (void);
309 void cgraph_mark_needed_node (struct cgraph_node *);
310 void cgraph_mark_reachable_node (struct cgraph_node *);
311 bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
312 bool cgraph_preserve_function_body_p (tree);
313 void verify_cgraph (void);
314 void verify_cgraph_node (struct cgraph_node *);
315 void cgraph_build_static_cdtor (char which, tree body, int priority);
316 void cgraph_reset_static_var_maps (void);
317 void init_cgraph (void);
318 struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
319 VEC(cgraph_edge_p,heap)*,
320 varray_type);
321 void cgraph_analyze_function (struct cgraph_node *);
322 struct cgraph_node *save_inline_function_body (struct cgraph_node *);
324 /* In ipa.c */
325 bool cgraph_remove_unreachable_nodes (bool, FILE *);
326 int cgraph_postorder (struct cgraph_node **);
328 /* In ipa-inline.c */
329 bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool);
330 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
331 void cgraph_mark_inline_edge (struct cgraph_edge *, bool);
332 bool cgraph_default_inline_p (struct cgraph_node *, const char **);
333 #endif /* GCC_CGRAPH_H */