1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004, 2005 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 2, or (at your option) any later
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
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 /* Information about the function collected locally.
27 Available after function is analyzed. */
29 struct cgraph_local_info
GTY(())
31 /* Size of the function before inlining. */
34 /* Set when function function is visible in current compilation unit only
35 and its address is never taken. */
38 /* Set once it has been finalized so we consider it to be output. */
41 /* False when there something makes inlining impossible (such as va_arg). */
44 /* True when function should be inlined independently on its size. */
45 bool disregard_inline_limits
;
47 /* True when the function has been originally extern inline, but it is
49 bool redefined_extern_inline
;
51 /* True if statics_read_for_function and
52 statics_written_for_function contain valid data. */
53 bool for_functions_valid
;
55 /* True if the function is going to be emitted in some other translation
56 unit, referenced from vtable. */
60 /* Information about the function that needs to be computed globally
61 once compilation is finished. Available only with -funit-at-time. */
63 struct cgraph_global_info
GTY(())
65 /* For inline clones this points to the function they will be inlined into. */
66 struct cgraph_node
*inlined_to
;
68 /* Estimated size of the function after inlining. */
71 /* Set iff the function has been inlined at least once. */
75 /* Information about the function that is propagated by the RTL backend.
76 Available only for functions that has been already assembled. */
78 struct cgraph_rtl_info
GTY(())
80 int preferred_incoming_stack_boundary
;
85 /* The cgraph data structure.
86 Each function decl has assigned cgraph_node listing callees and callers. */
88 struct cgraph_node
GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
91 struct cgraph_edge
*callees
;
92 struct cgraph_edge
*callers
;
93 struct cgraph_node
*next
;
94 struct cgraph_node
*previous
;
95 /* For nested functions points to function the node is nested in. */
96 struct cgraph_node
*origin
;
97 /* Points to first nested function, if any. */
98 struct cgraph_node
*nested
;
99 /* Pointer to the next function with same origin, if any. */
100 struct cgraph_node
*next_nested
;
101 /* Pointer to the next function in cgraph_nodes_queue. */
102 struct cgraph_node
*next_needed
;
103 /* Pointer to the next clone. */
104 struct cgraph_node
*next_clone
;
105 struct cgraph_node
*prev_clone
;
106 PTR
GTY ((skip
)) aux
;
108 struct cgraph_local_info local
;
109 struct cgraph_global_info global
;
110 struct cgraph_rtl_info rtl
;
112 /* Unique id of the node. */
114 /* Set when function must be output - it is externally visible
115 or its address is taken. */
117 /* Set when function is reachable by call from other function
118 that is either reachable or needed. */
120 /* Set once the function has been instantiated and its callee
123 /* Set when function is scheduled to be assembled. */
125 /* Set for aliases once they got through assemble_alias. */
129 struct cgraph_edge
GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller")))
131 struct cgraph_node
*caller
;
132 struct cgraph_node
*callee
;
133 struct cgraph_edge
*prev_caller
;
134 struct cgraph_edge
*next_caller
;
135 struct cgraph_edge
*prev_callee
;
136 struct cgraph_edge
*next_callee
;
138 PTR
GTY ((skip (""))) aux
;
139 /* When NULL, inline this call. When non-NULL, points to the explanation
140 why function was not inlined. */
141 const char *inline_failed
;
144 /* The cgraph_varpool data structure.
145 Each static variable decl has assigned cgraph_varpool_node. */
147 struct cgraph_varpool_node
GTY(())
150 /* Pointer to the next function in cgraph_varpool_nodes. */
151 struct cgraph_varpool_node
*next
;
152 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
153 struct cgraph_varpool_node
*next_needed
;
155 /* Set when function must be output - it is externally visible
156 or its address is taken. */
158 /* Needed variables might become dead by optimization. This flag
159 forces the variable to be output even if it appears dead otherwise. */
161 /* Set once the variable has been instantiated and its callee
164 /* Set once it has been finalized so we consider it to be output. */
166 /* Set when function is scheduled to be assembled. */
168 /* Set for aliases once they got through assemble_alias. */
172 extern GTY(()) struct cgraph_node
*cgraph_nodes
;
173 extern GTY(()) int cgraph_n_nodes
;
174 extern GTY(()) int cgraph_max_uid
;
175 extern bool cgraph_global_info_ready
;
176 extern GTY(()) struct cgraph_node
*cgraph_nodes_queue
;
178 extern GTY(()) struct cgraph_varpool_node
*cgraph_varpool_first_unanalyzed_node
;
179 extern GTY(()) struct cgraph_varpool_node
*cgraph_varpool_nodes_queue
;
182 void dump_cgraph (FILE *);
183 void dump_cgraph_node (FILE *, struct cgraph_node
*);
184 void dump_varpool (FILE *);
185 void dump_cgraph_varpool_node (FILE *, struct cgraph_varpool_node
*);
186 void cgraph_remove_edge (struct cgraph_edge
*);
187 void cgraph_remove_node (struct cgraph_node
*);
188 void cgraph_node_remove_callees (struct cgraph_node
*node
);
189 struct cgraph_edge
*cgraph_create_edge (struct cgraph_node
*,
190 struct cgraph_node
*,
192 struct cgraph_node
*cgraph_node (tree decl
);
193 struct cgraph_node
*cgraph_node_for_asm (tree asmname
);
194 struct cgraph_edge
*cgraph_edge (struct cgraph_node
*, tree call_expr
);
195 struct cgraph_local_info
*cgraph_local_info (tree
);
196 struct cgraph_global_info
*cgraph_global_info (tree
);
197 struct cgraph_rtl_info
*cgraph_rtl_info (tree
);
198 const char * cgraph_node_name (struct cgraph_node
*);
199 struct cgraph_edge
* cgraph_clone_edge (struct cgraph_edge
*, struct cgraph_node
*, tree
);
200 struct cgraph_node
* cgraph_clone_node (struct cgraph_node
*);
202 struct cgraph_varpool_node
*cgraph_varpool_node (tree decl
);
203 struct cgraph_varpool_node
*cgraph_varpool_node_for_asm (tree asmname
);
204 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node
*);
205 void cgraph_varpool_finalize_decl (tree
);
206 void cgraph_redirect_edge_callee (struct cgraph_edge
*, struct cgraph_node
*);
208 bool cgraph_function_possibly_inlined_p (tree
);
209 void cgraph_unnest_node (struct cgraph_node
*node
);
210 void cgraph_varpool_enqueue_needed_node (struct cgraph_varpool_node
*);
211 void cgraph_varpool_reset_queue (void);
212 bool decide_is_variable_needed (struct cgraph_varpool_node
*, tree
);
214 /* In cgraphunit.c */
215 bool cgraph_assemble_pending_functions (void);
216 bool cgraph_varpool_assemble_pending_decls (void);
217 void cgraph_finalize_function (tree
, bool);
218 void cgraph_finalize_compilation_unit (void);
219 void cgraph_create_edges (struct cgraph_node
*, tree
);
220 void cgraph_optimize (void);
221 void cgraph_mark_needed_node (struct cgraph_node
*);
222 void cgraph_mark_reachable_node (struct cgraph_node
*);
223 bool cgraph_inline_p (struct cgraph_edge
*, const char **reason
);
224 bool cgraph_preserve_function_body_p (tree
);
225 void verify_cgraph (void);
226 void verify_cgraph_node (struct cgraph_node
*);
227 void cgraph_mark_inline_edge (struct cgraph_edge
*e
);
228 void cgraph_clone_inlined_nodes (struct cgraph_edge
*e
, bool duplicate
);
229 void cgraph_build_static_cdtor (char which
, tree body
, int priority
);
230 void cgraph_reset_static_var_maps (void);
231 void init_cgraph (void);
234 bool cgraph_remove_unreachable_nodes (bool, FILE *);
235 int cgraph_postorder (struct cgraph_node
**);
237 /* In ipa-inline.c */
238 void cgraph_decide_inlining_incrementally (struct cgraph_node
*);
239 void cgraph_clone_inlined_nodes (struct cgraph_edge
*, bool);
240 void cgraph_mark_inline_edge (struct cgraph_edge
*);
241 bool cgraph_default_inline_p (struct cgraph_node
*);
242 #endif /* GCC_CGRAPH_H */