]> gcc.gnu.org Git - gcc.git/blame - gcc/cgraph.h
objc-act.c (objc_build_struct): Save the TYPE_OBJC_INFO portion of TYPE_LANG_SPECIFIC...
[gcc.git] / gcc / cgraph.h
CommitLineData
1c4a429a 1/* Callgraph handling code.
ad616de1 2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
1c4a429a
JH
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
366ccddb
KC
19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2002110-1301, USA. */
1c4a429a
JH
21
22#ifndef GCC_CGRAPH_H
23#define GCC_CGRAPH_H
6674a6ce 24#include "tree.h"
e42922b1 25#include "basic-block.h"
1c4a429a 26
6b02a499
JH
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
dafc5b82 49/* Information about the function collected locally.
25c84396 50 Available after function is analyzed. */
dafc5b82 51
ed2df68b 52struct cgraph_local_info GTY(())
dafc5b82 53{
95c755e9
JH
54 /* Size of the function before inlining. */
55 int self_insns;
6674a6ce 56
e0bb17a8 57 /* Set when function function is visible in current compilation unit only
e2209b03 58 and its address is never taken. */
dafc5b82 59 bool local;
6674a6ce 60
e7d6beb0
JH
61 /* Set when function is visible by other units. */
62 bool externally_visible;
63
f6981e16
JH
64 /* Set once it has been finalized so we consider it to be output. */
65 bool finalized;
b58b1157 66
b3c3af2f 67 /* False when there something makes inlining impossible (such as va_arg). */
b58b1157 68 bool inlinable;
6674a6ce 69
e2209b03 70 /* True when function should be inlined independently on its size. */
b3c3af2f 71 bool disregard_inline_limits;
6674a6ce 72
95c755e9
JH
73 /* True when the function has been originally extern inline, but it is
74 redefined now. */
75 bool redefined_extern_inline;
6674a6ce
KZ
76
77 /* True if statics_read_for_function and
78 statics_written_for_function contain valid data. */
79 bool for_functions_valid;
8634c649
JJ
80
81 /* True if the function is going to be emitted in some other translation
82 unit, referenced from vtable. */
83 bool vtable_method;
dafc5b82
JH
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
ed2df68b 89struct cgraph_global_info GTY(())
dafc5b82 90{
18c6ada9
JH
91 /* For inline clones this points to the function they will be inlined into. */
92 struct cgraph_node *inlined_to;
93
b58b1157
JH
94 /* Estimated size of the function after inlining. */
95 int insns;
96
670cd5c5
JH
97 /* Estimated growth after inlining. INT_MIN if not computed. */
98 int estimated_growth;
99
18c6ada9 100 /* Set iff the function has been inlined at least once. */
1bb17c21 101 bool inlined;
dafc5b82
JH
102};
103
b255a036
JH
104/* Information about the function that is propagated by the RTL backend.
105 Available only for functions that has been already assembled. */
106
ed2df68b 107struct cgraph_rtl_info GTY(())
b255a036 108{
6de9cd9a 109 int preferred_incoming_stack_boundary;
ed2df68b
JH
110 bool const_function;
111 bool pure_function;
b255a036
JH
112};
113
ba228239 114/* The cgraph data structure.
e0bb17a8 115 Each function decl has assigned cgraph_node listing callees and callers. */
1c4a429a 116
d1bd0ded 117struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
1c4a429a
JH
118{
119 tree decl;
120 struct cgraph_edge *callees;
121 struct cgraph_edge *callers;
ed2df68b
JH
122 struct cgraph_node *next;
123 struct cgraph_node *previous;
1c4a429a
JH
124 /* For nested functions points to function the node is nested in. */
125 struct cgraph_node *origin;
126 /* Points to first nested function, if any. */
127 struct cgraph_node *nested;
128 /* Pointer to the next function with same origin, if any. */
129 struct cgraph_node *next_nested;
8bd87c4e
JH
130 /* Pointer to the next function in cgraph_nodes_queue. */
131 struct cgraph_node *next_needed;
18c6ada9
JH
132 /* Pointer to the next clone. */
133 struct cgraph_node *next_clone;
1655dc9d 134 struct cgraph_node *prev_clone;
6b02a499
JH
135 /* Pointer to a single unique cgraph node for this function. If the
136 function is to be output, this is the copy that will survive. */
137 struct cgraph_node *master_clone;
138
1431042e 139 PTR GTY ((skip)) aux;
1c4a429a 140
95c755e9
JH
141 struct cgraph_local_info local;
142 struct cgraph_global_info global;
143 struct cgraph_rtl_info rtl;
6674a6ce 144
e42922b1
JH
145 /* Expected number of executions: calculated in profile.c. */
146 gcov_type count;
95c755e9
JH
147 /* Unique id of the node. */
148 int uid;
1c4a429a 149 /* Set when function must be output - it is externally visible
e2209b03 150 or its address is taken. */
1c4a429a
JH
151 bool needed;
152 /* Set when function is reachable by call from other function
e0bb17a8 153 that is either reachable or needed. */
1c4a429a 154 bool reachable;
e21aff8a
SB
155 /* Set once the function is lowered (ie it's CFG is built). */
156 bool lowered;
25c84396
RH
157 /* Set once the function has been instantiated and its callee
158 lists created. */
159 bool analyzed;
1c4a429a
JH
160 /* Set when function is scheduled to be assembled. */
161 bool output;
ce91e74c
JH
162 /* Set when function is visible by other units. */
163 bool externally_visible;
12527dce
RH
164 /* Set for aliases once they got through assemble_alias. */
165 bool alias;
1c4a429a
JH
166};
167
2563c224 168struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
1c4a429a 169{
ed2df68b
JH
170 struct cgraph_node *caller;
171 struct cgraph_node *callee;
2563c224 172 struct cgraph_edge *prev_caller;
1c4a429a 173 struct cgraph_edge *next_caller;
2563c224 174 struct cgraph_edge *prev_callee;
1c4a429a 175 struct cgraph_edge *next_callee;
e0704a46 176 tree call_stmt;
18c6ada9 177 PTR GTY ((skip (""))) aux;
dc0bfe6a
JH
178 /* When NULL, inline this call. When non-NULL, points to the explanation
179 why function was not inlined. */
180 const char *inline_failed;
e42922b1
JH
181 /* Expected number of executions: calculated in profile.c. */
182 gcov_type count;
183 /* Depth of loop nest, 1 means no loop nest. */
184 int loop_nest;
1c4a429a
JH
185};
186
ba228239 187/* The cgraph_varpool data structure.
e69529cd
JH
188 Each static variable decl has assigned cgraph_varpool_node. */
189
ed2df68b 190struct cgraph_varpool_node GTY(())
e69529cd
JH
191{
192 tree decl;
bedb9fc0
RH
193 /* Pointer to the next function in cgraph_varpool_nodes. */
194 struct cgraph_varpool_node *next;
8bd87c4e
JH
195 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
196 struct cgraph_varpool_node *next_needed;
e69529cd
JH
197
198 /* Set when function must be output - it is externally visible
e2209b03 199 or its address is taken. */
e69529cd 200 bool needed;
cd9c7bd2
JH
201 /* Needed variables might become dead by optimization. This flag
202 forces the variable to be output even if it appears dead otherwise. */
203 bool force_output;
204 /* Set once the variable has been instantiated and its callee
205 lists created. */
206 bool analyzed;
e69529cd
JH
207 /* Set once it has been finalized so we consider it to be output. */
208 bool finalized;
6b02a499 209 /* Set when variable is scheduled to be assembled. */
e69529cd 210 bool output;
e7d6beb0
JH
211 /* Set when function is visible by other units. */
212 bool externally_visible;
1a612e0a
JJ
213 /* Set for aliases once they got through assemble_alias. */
214 bool alias;
e69529cd
JH
215};
216
ed2df68b
JH
217extern GTY(()) struct cgraph_node *cgraph_nodes;
218extern GTY(()) int cgraph_n_nodes;
b58b1157 219extern GTY(()) int cgraph_max_uid;
dafc5b82 220extern bool cgraph_global_info_ready;
e7d6beb0 221extern bool cgraph_function_flags_ready;
ed2df68b 222extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
1c4a429a 223
cd9c7bd2 224extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_first_unanalyzed_node;
ed2df68b 225extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
e69529cd 226
1c4a429a 227/* In cgraph.c */
439f7bc3 228void dump_cgraph (FILE *);
18c6ada9 229void dump_cgraph_node (FILE *, struct cgraph_node *);
cd9c7bd2
JH
230void dump_varpool (FILE *);
231void dump_cgraph_varpool_node (FILE *, struct cgraph_varpool_node *);
18c6ada9 232void cgraph_remove_edge (struct cgraph_edge *);
439f7bc3 233void cgraph_remove_node (struct cgraph_node *);
2563c224 234void cgraph_node_remove_callees (struct cgraph_node *node);
18c6ada9
JH
235struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
236 struct cgraph_node *,
e42922b1
JH
237 tree, gcov_type, int);
238struct cgraph_node *cgraph_node (tree);
bedb9fc0 239struct cgraph_node *cgraph_node_for_asm (tree asmname);
e42922b1 240struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree);
439f7bc3
AJ
241struct cgraph_local_info *cgraph_local_info (tree);
242struct cgraph_global_info *cgraph_global_info (tree);
243struct cgraph_rtl_info *cgraph_rtl_info (tree);
244const char * cgraph_node_name (struct cgraph_node *);
e42922b1
JH
245struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, struct cgraph_node *, tree, int, int);
246struct cgraph_node * cgraph_clone_node (struct cgraph_node *, gcov_type, int);
1c4a429a 247
e42922b1 248struct cgraph_varpool_node *cgraph_varpool_node (tree);
bedb9fc0 249struct cgraph_varpool_node *cgraph_varpool_node_for_asm (tree asmname);
e69529cd
JH
250void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
251void cgraph_varpool_finalize_decl (tree);
18c6ada9 252void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *);
e69529cd 253
1bb17c21 254bool cgraph_function_possibly_inlined_p (tree);
e42922b1 255void cgraph_unnest_node (struct cgraph_node *);
cd9c7bd2
JH
256void cgraph_varpool_enqueue_needed_node (struct cgraph_varpool_node *);
257void cgraph_varpool_reset_queue (void);
258bool decide_is_variable_needed (struct cgraph_varpool_node *, tree);
1bb17c21 259
6b02a499
JH
260enum availability cgraph_function_body_availability (struct cgraph_node *);
261enum availability cgraph_variable_initializer_availability (struct cgraph_varpool_node *);
262bool cgraph_is_master_clone (struct cgraph_node *);
263struct cgraph_node *cgraph_master_clone (struct cgraph_node *);
264
1c4a429a 265/* In cgraphunit.c */
f6d1b84a 266bool cgraph_assemble_pending_functions (void);
cd9c7bd2 267bool cgraph_varpool_assemble_pending_decls (void);
6b00c969 268void cgraph_finalize_function (tree, bool);
e21aff8a 269void cgraph_lower_function (struct cgraph_node *);
439f7bc3 270void cgraph_finalize_compilation_unit (void);
439f7bc3 271void cgraph_optimize (void);
8dafba3c
RH
272void cgraph_mark_needed_node (struct cgraph_node *);
273void cgraph_mark_reachable_node (struct cgraph_node *);
18c6ada9
JH
274bool cgraph_inline_p (struct cgraph_edge *, const char **reason);
275bool cgraph_preserve_function_body_p (tree);
276void verify_cgraph (void);
277void verify_cgraph_node (struct cgraph_node *);
278void cgraph_mark_inline_edge (struct cgraph_edge *e);
279void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate);
35b6fdcf 280void cgraph_build_static_cdtor (char which, tree body, int priority);
6674a6ce 281void cgraph_reset_static_var_maps (void);
9b3e897d 282void init_cgraph (void);
1c4a429a 283
ca31b95f
JH
284/* In ipa.c */
285bool cgraph_remove_unreachable_nodes (bool, FILE *);
286int cgraph_postorder (struct cgraph_node **);
287
288/* In ipa-inline.c */
289void cgraph_decide_inlining_incrementally (struct cgraph_node *);
290void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool);
291void cgraph_mark_inline_edge (struct cgraph_edge *);
292bool cgraph_default_inline_p (struct cgraph_node *);
1c4a429a 293#endif /* GCC_CGRAPH_H */
This page took 0.660443 seconds and 5 git commands to generate.