]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cgraph.h
* tree-pretty-print.c (dump_generic_node): Handle
[thirdparty/gcc.git] / gcc / cgraph.h
CommitLineData
ae01b312 1/* Callgraph handling code.
2b4876d2 2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
ae01b312 3 Contributed by Jan Hubicka
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING. If not, write to the Free
67ce556b 19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2002110-1301, USA. */
ae01b312 21
22#ifndef GCC_CGRAPH_H
23#define GCC_CGRAPH_H
acc70efa 24#include "tree.h"
edc6a4c0 25#include "basic-block.h"
ae01b312 26
e1be32b8 27enum availability
28{
29 /* Not yet set by cgraph_function_body_availability. */
30 AVAIL_UNSET,
31 /* Function body/variable initializer is unknown. */
32 AVAIL_NOT_AVAILABLE,
33 /* Function body/variable initializer is known but might be replaced
34 by a different one from other compilation unit and thus needs to
35 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
36 arbitrary side effects on escaping variables and functions, while
37 like AVAILABLE it might access static variables. */
38 AVAIL_OVERWRITABLE,
39 /* Function body/variable initializer is known and will be used in final
40 program. */
41 AVAIL_AVAILABLE,
42 /* Function body/variable initializer is known and all it's uses are explicitly
43 visible within current unit (ie it's address is never taken and it is not
44 exported to other units).
45 Currently used only for functions. */
46 AVAIL_LOCAL
47};
48
80a85d8a 49/* Information about the function collected locally.
ec1e35b2 50 Available after function is analyzed. */
80a85d8a 51
5d31fea4 52struct cgraph_local_info GTY(())
80a85d8a 53{
69435b7f 54 /* Size of the function before inlining. */
55 int self_insns;
acc70efa 56
d01481af 57 /* Set when function function is visible in current compilation unit only
9cd50731 58 and its address is never taken. */
80a85d8a 59 bool local;
acc70efa 60
3f82b628 61 /* Set when function is visible by other units. */
62 bool externally_visible;
63
79bb87b4 64 /* Set once it has been finalized so we consider it to be output. */
65 bool finalized;
d7c6d889 66
746149b7 67 /* False when there something makes inlining impossible (such as va_arg). */
d7c6d889 68 bool inlinable;
acc70efa 69
9cd50731 70 /* True when function should be inlined independently on its size. */
746149b7 71 bool disregard_inline_limits;
acc70efa 72
69435b7f 73 /* True when the function has been originally extern inline, but it is
74 redefined now. */
75 bool redefined_extern_inline;
acc70efa 76
77 /* True if statics_read_for_function and
78 statics_written_for_function contain valid data. */
79 bool for_functions_valid;
880afb80 80
81 /* True if the function is going to be emitted in some other translation
82 unit, referenced from vtable. */
83 bool vtable_method;
80a85d8a 84};
85
86/* Information about the function that needs to be computed globally
87 once compilation is finished. Available only with -funit-at-time. */
88
5d31fea4 89struct cgraph_global_info GTY(())
80a85d8a 90{
b0cdf642 91 /* For inline clones this points to the function they will be inlined into. */
92 struct cgraph_node *inlined_to;
93
d7c6d889 94 /* Estimated size of the function after inlining. */
95 int insns;
96
a49506c7 97 /* Estimated growth after inlining. INT_MIN if not computed. */
98 int estimated_growth;
99
b0cdf642 100 /* Set iff the function has been inlined at least once. */
5bd74231 101 bool inlined;
80a85d8a 102};
103
28992b23 104/* Information about the function that is propagated by the RTL backend.
105 Available only for functions that has been already assembled. */
106
5d31fea4 107struct cgraph_rtl_info GTY(())
28992b23 108{
4ee9c684 109 int preferred_incoming_stack_boundary;
28992b23 110};
111
c7bf1374 112/* The cgraph data structure.
d01481af 113 Each function decl has assigned cgraph_node listing callees and callers. */
ae01b312 114
40109983 115struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
ae01b312 116{
117 tree decl;
118 struct cgraph_edge *callees;
119 struct cgraph_edge *callers;
5d31fea4 120 struct cgraph_node *next;
121 struct cgraph_node *previous;
ae01b312 122 /* For nested functions points to function the node is nested in. */
123 struct cgraph_node *origin;
124 /* Points to first nested function, if any. */
125 struct cgraph_node *nested;
126 /* Pointer to the next function with same origin, if any. */
127 struct cgraph_node *next_nested;
d87976fb 128 /* Pointer to the next function in cgraph_nodes_queue. */
129 struct cgraph_node *next_needed;
b0cdf642 130 /* Pointer to the next clone. */
131 struct cgraph_node *next_clone;
113a8828 132 struct cgraph_node *prev_clone;
e1be32b8 133 /* Pointer to a single unique cgraph node for this function. If the
134 function is to be output, this is the copy that will survive. */
135 struct cgraph_node *master_clone;
136
7035b2ab 137 PTR GTY ((skip)) aux;
ae01b312 138
69435b7f 139 struct cgraph_local_info local;
140 struct cgraph_global_info global;
141 struct cgraph_rtl_info rtl;
acc70efa 142
edc6a4c0 143 /* Expected number of executions: calculated in profile.c. */
144 gcov_type count;
69435b7f 145 /* Unique id of the node. */
146 int uid;
56af936e 147 /* Ordering of all cgraph nodes. */
148 int order;
ae01b312 149 /* Set when function must be output - it is externally visible
9cd50731 150 or its address is taken. */
ae01b312 151 bool needed;
152 /* Set when function is reachable by call from other function
d01481af 153 that is either reachable or needed. */
ae01b312 154 bool reachable;
773c5ba7 155 /* Set once the function is lowered (i.e. its CFG is built). */
e27482aa 156 bool lowered;
ec1e35b2 157 /* Set once the function has been instantiated and its callee
158 lists created. */
159 bool analyzed;
ae01b312 160 /* Set when function is scheduled to be assembled. */
161 bool output;
62eec3b4 162 /* Set when function is visible by other units. */
163 bool externally_visible;
1d09f0e6 164 /* Set for aliases once they got through assemble_alias. */
165 bool alias;
469679ab 166
167 /* In non-unit-at-a-time mode the function body of inline candidates is saved
168 into clone before compiling so the function in original form can be
169 inlined later. This pointer points to the clone. */
170 tree inline_decl;
ae01b312 171};
172
bb4c7a44 173struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
ae01b312 174{
5d31fea4 175 struct cgraph_node *caller;
176 struct cgraph_node *callee;
bb4c7a44 177 struct cgraph_edge *prev_caller;
ae01b312 178 struct cgraph_edge *next_caller;
bb4c7a44 179 struct cgraph_edge *prev_callee;
ae01b312 180 struct cgraph_edge *next_callee;
9bfec7c2 181 tree call_stmt;
b0cdf642 182 PTR GTY ((skip (""))) aux;
611e5405 183 /* When NULL, inline this call. When non-NULL, points to the explanation
184 why function was not inlined. */
185 const char *inline_failed;
edc6a4c0 186 /* Expected number of executions: calculated in profile.c. */
187 gcov_type count;
188 /* Depth of loop nest, 1 means no loop nest. */
189 int loop_nest;
ae01b312 190};
191
c7bf1374 192/* The cgraph_varpool data structure.
229dcfae 193 Each static variable decl has assigned cgraph_varpool_node. */
194
5d31fea4 195struct cgraph_varpool_node GTY(())
229dcfae 196{
197 tree decl;
8bc09a74 198 /* Pointer to the next function in cgraph_varpool_nodes. */
199 struct cgraph_varpool_node *next;
d87976fb 200 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
201 struct cgraph_varpool_node *next_needed;
56af936e 202 /* Ordering of all cgraph nodes. */
203 int order;
229dcfae 204
205 /* Set when function must be output - it is externally visible
9cd50731 206 or its address is taken. */
229dcfae 207 bool needed;
c1dcd13c 208 /* Needed variables might become dead by optimization. This flag
209 forces the variable to be output even if it appears dead otherwise. */
210 bool force_output;
211 /* Set once the variable has been instantiated and its callee
212 lists created. */
213 bool analyzed;
229dcfae 214 /* Set once it has been finalized so we consider it to be output. */
215 bool finalized;
e1be32b8 216 /* Set when variable is scheduled to be assembled. */
229dcfae 217 bool output;
3f82b628 218 /* Set when function is visible by other units. */
219 bool externally_visible;
f1c94b55 220 /* Set for aliases once they got through assemble_alias. */
221 bool alias;
229dcfae 222};
223
56af936e 224/* Every top level asm statement is put into a cgraph_asm_node. */
225
226struct cgraph_asm_node GTY(())
227{
228 /* Next asm node. */
229 struct cgraph_asm_node *next;
230 /* String for this asm node. */
231 tree asm_str;
232 /* Ordering of all cgraph nodes. */
233 int order;
234};
235
5d31fea4 236extern GTY(()) struct cgraph_node *cgraph_nodes;
237extern GTY(()) int cgraph_n_nodes;
d7c6d889 238extern GTY(()) int cgraph_max_uid;
80a85d8a 239extern bool cgraph_global_info_ready;
3f82b628 240extern bool cgraph_function_flags_ready;
5d31fea4 241extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
773c5ba7 242extern GTY(()) struct cgraph_node *cgraph_expand_queue;
ae01b312 243
c1dcd13c 244extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_first_unanalyzed_node;
5d31fea4 245extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
56af936e 246extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
247extern GTY(()) int cgraph_order;
229dcfae 248
ae01b312 249/* In cgraph.c */
eeba438a 250void dump_cgraph (FILE *);
b0cdf642 251void dump_cgraph_node (FILE *, struct cgraph_node *);
469679ab 252void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
c1dcd13c 253void dump_varpool (FILE *);
254void dump_cgraph_varpool_node (FILE *, struct cgraph_varpool_node *);
b0cdf642 255void cgraph_remove_edge (struct cgraph_edge *);
eeba438a 256void cgraph_remove_node (struct cgraph_node *);
bb4c7a44 257void cgraph_node_remove_callees (struct cgraph_node *node);
b0cdf642 258struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
259 struct cgraph_node *,
edc6a4c0 260 tree, gcov_type, int);
261struct cgraph_node *cgraph_node (tree);
8bc09a74 262struct cgraph_node *cgraph_node_for_asm (tree asmname);
edc6a4c0 263struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree);
eeba438a 264struct cgraph_local_info *cgraph_local_info (tree);
265struct cgraph_global_info *cgraph_global_info (tree);
266struct cgraph_rtl_info *cgraph_rtl_info (tree);
267const char * cgraph_node_name (struct cgraph_node *);
0aca0eb6 268struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
269 struct cgraph_node *,
a2cb9b3b 270 tree, gcov_type, int, bool);
0aca0eb6 271struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type,
272 int, bool);
ae01b312 273
edc6a4c0 274struct cgraph_varpool_node *cgraph_varpool_node (tree);
8bc09a74 275struct cgraph_varpool_node *cgraph_varpool_node_for_asm (tree asmname);
229dcfae 276void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
277void cgraph_varpool_finalize_decl (tree);
b0cdf642 278void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
229dcfae 279
56af936e 280struct cgraph_asm_node *cgraph_add_asm_node (tree);
281
5bd74231 282bool cgraph_function_possibly_inlined_p (tree);
edc6a4c0 283void cgraph_unnest_node (struct cgraph_node *);
c1dcd13c 284void cgraph_varpool_enqueue_needed_node (struct cgraph_varpool_node *);
285void cgraph_varpool_reset_queue (void);
286bool decide_is_variable_needed (struct cgraph_varpool_node *, tree);
5bd74231 287
e1be32b8 288enum availability cgraph_function_body_availability (struct cgraph_node *);
289enum availability cgraph_variable_initializer_availability (struct cgraph_varpool_node *);
290bool cgraph_is_master_clone (struct cgraph_node *);
291struct cgraph_node *cgraph_master_clone (struct cgraph_node *);
1e8e9920 292void cgraph_add_new_function (tree);
e1be32b8 293
ae01b312 294/* In cgraphunit.c */
050e11c9 295bool cgraph_assemble_pending_functions (void);
c1dcd13c 296bool cgraph_varpool_assemble_pending_decls (void);
28df663b 297void cgraph_finalize_function (tree, bool);
eeba438a 298void cgraph_finalize_compilation_unit (void);
eeba438a 299void cgraph_optimize (void);
2c0b522d 300void cgraph_mark_needed_node (struct cgraph_node *);
301void cgraph_mark_reachable_node (struct cgraph_node *);
b0cdf642 302bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
303bool cgraph_preserve_function_body_p (tree);
304void verify_cgraph (void);
305void verify_cgraph_node (struct cgraph_node *);
c5344b58 306void cgraph_build_static_cdtor (char which, tree body, int priority);
acc70efa 307void cgraph_reset_static_var_maps (void);
121f3051 308void init_cgraph (void);
b5d36404 309struct cgraph_node *cgraph_function_versioning (struct cgraph_node *,
310 varray_type, varray_type);
1e8e9920 311void cgraph_analyze_function (struct cgraph_node *);
469679ab 312struct cgraph_node *save_inline_function_body (struct cgraph_node *);
ae01b312 313
65c1a668 314/* In ipa.c */
315bool cgraph_remove_unreachable_nodes (bool, FILE *);
316int cgraph_postorder (struct cgraph_node **);
317
318/* In ipa-inline.c */
9e0baf4d 319bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool);
a2cb9b3b 320void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
321void cgraph_mark_inline_edge (struct cgraph_edge *, bool);
b30512dd 322bool cgraph_default_inline_p (struct cgraph_node *, const char **);
ae01b312 323#endif /* GCC_CGRAPH_H */