1 /* Callgraph handling code.
2 Copyright (C) 2003, 2004 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. */
33 /* Set when function function is visible in current compilation unit only
34 and it's address is never taken. */
36 /* Set once it has been finalized so we consider it to be output. */
39 /* False when there something makes inlining impossible (such as va_arg). */
41 /* True when function should be inlined independently on it's size. */
42 bool disregard_inline_limits
;
43 /* True when the function has been originally extern inline, but it is
45 bool redefined_extern_inline
;
48 /* Information about the function that needs to be computed globally
49 once compilation is finished. Available only with -funit-at-time. */
51 struct cgraph_global_info
GTY(())
53 /* For inline clones this points to the function they will be inlined into. */
54 struct cgraph_node
*inlined_to
;
56 /* Estimated size of the function after inlining. */
59 /* Set iff the function has been inlined at least once. */
63 /* Information about the function that is propagated by the RTL backend.
64 Available only for functions that has been already assembled. */
66 struct cgraph_rtl_info
GTY(())
68 int preferred_incoming_stack_boundary
;
74 /* The cgraph data structure.
75 Each function decl has assigned cgraph_node listing callees and callers. */
77 struct cgraph_node
GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
80 struct cgraph_edge
*callees
;
81 struct cgraph_edge
*callers
;
82 struct cgraph_node
*next
;
83 struct cgraph_node
*previous
;
84 /* For nested functions points to function the node is nested in. */
85 struct cgraph_node
*origin
;
86 /* Points to first nested function, if any. */
87 struct cgraph_node
*nested
;
88 /* Pointer to the next function with same origin, if any. */
89 struct cgraph_node
*next_nested
;
90 /* Pointer to the next function in cgraph_nodes_queue. */
91 struct cgraph_node
*next_needed
;
92 /* Pointer to the next clone. */
93 struct cgraph_node
*next_clone
;
96 struct cgraph_local_info local
;
97 struct cgraph_global_info global
;
98 struct cgraph_rtl_info rtl
;
99 /* Unique id of the node. */
101 /* Set when function must be output - it is externally visible
102 or it's address is taken. */
104 /* Set when function is reachable by call from other function
105 that is either reachable or needed. */
107 /* Set once the function has been instantiated and its callee
110 /* Set when function is scheduled to be assembled. */
114 struct cgraph_edge
GTY((chain_next ("%h.next_caller")))
116 struct cgraph_node
*caller
;
117 struct cgraph_node
*callee
;
118 struct cgraph_edge
*next_caller
;
119 struct cgraph_edge
*next_callee
;
121 PTR
GTY ((skip (""))) aux
;
122 /* When NULL, inline this call. When non-NULL, points to the explanation
123 why function was not inlined. */
124 const char *inline_failed
;
127 /* The cgraph_varpool data structure.
128 Each static variable decl has assigned cgraph_varpool_node. */
130 struct cgraph_varpool_node
GTY(())
133 /* Pointer to the next function in cgraph_varpool_nodes_queue. */
134 struct cgraph_varpool_node
*next_needed
;
136 /* Set when function must be output - it is externally visible
137 or it's address is taken. */
139 /* Set once it has been finalized so we consider it to be output. */
141 /* Set when function is scheduled to be assembled. */
145 extern GTY(()) struct cgraph_node
*cgraph_nodes
;
146 extern GTY(()) int cgraph_n_nodes
;
147 extern GTY(()) int cgraph_max_uid
;
148 extern bool cgraph_global_info_ready
;
149 extern GTY(()) struct cgraph_node
*cgraph_nodes_queue
;
150 extern FILE *cgraph_dump_file
;
152 extern GTY(()) int cgraph_varpool_n_nodes
;
153 extern GTY(()) struct cgraph_varpool_node
*cgraph_varpool_nodes_queue
;
156 void dump_cgraph (FILE *);
157 void dump_cgraph_node (FILE *, struct cgraph_node
*);
158 void cgraph_remove_edge (struct cgraph_edge
*);
159 void cgraph_remove_node (struct cgraph_node
*);
160 struct cgraph_edge
*cgraph_create_edge (struct cgraph_node
*,
161 struct cgraph_node
*,
163 struct cgraph_node
*cgraph_node (tree decl
);
164 struct cgraph_edge
*cgraph_edge (struct cgraph_node
*, tree call_expr
);
165 bool cgraph_calls_p (tree
, tree
);
166 struct cgraph_local_info
*cgraph_local_info (tree
);
167 struct cgraph_global_info
*cgraph_global_info (tree
);
168 struct cgraph_rtl_info
*cgraph_rtl_info (tree
);
169 const char * cgraph_node_name (struct cgraph_node
*);
170 struct cgraph_edge
* cgraph_clone_edge (struct cgraph_edge
*, struct cgraph_node
*, tree
);
171 struct cgraph_node
* cgraph_clone_node (struct cgraph_node
*);
173 struct cgraph_varpool_node
*cgraph_varpool_node (tree decl
);
174 void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node
*);
175 void cgraph_varpool_finalize_decl (tree
);
176 bool cgraph_varpool_assemble_pending_decls (void);
177 void cgraph_redirect_edge_callee (struct cgraph_edge
*, struct cgraph_node
*);
179 bool cgraph_function_possibly_inlined_p (tree
);
181 /* In cgraphunit.c */
182 bool cgraph_assemble_pending_functions (void);
183 void cgraph_finalize_function (tree
, bool);
184 void cgraph_finalize_compilation_unit (void);
185 void cgraph_create_edges (struct cgraph_node
*, tree
);
186 void cgraph_optimize (void);
187 void cgraph_mark_needed_node (struct cgraph_node
*);
188 void cgraph_mark_reachable_node (struct cgraph_node
*);
189 bool cgraph_inline_p (struct cgraph_edge
*, const char **reason
);
190 bool cgraph_preserve_function_body_p (tree
);
191 void verify_cgraph (void);
192 void verify_cgraph_node (struct cgraph_node
*);
193 void cgraph_mark_inline_edge (struct cgraph_edge
*e
);
194 void cgraph_clone_inlined_nodes (struct cgraph_edge
*e
, bool duplicate
);
196 #endif /* GCC_CGRAPH_H */