]>
Commit | Line | Data |
---|---|---|
1c4a429a | 1 | /* Callgraph handling code. |
ad616de1 | 2 | Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
1c4a429a JH |
3 | Contributed by Jan Hubicka |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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 | |
10 | version. | |
11 | ||
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. | |
16 | ||
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 | |
20 | 02111-1307, USA. */ | |
21 | ||
22 | #ifndef GCC_CGRAPH_H | |
23 | #define GCC_CGRAPH_H | |
6674a6ce | 24 | #include "tree.h" |
1c4a429a | 25 | |
dafc5b82 | 26 | /* Information about the function collected locally. |
25c84396 | 27 | Available after function is analyzed. */ |
dafc5b82 | 28 | |
ed2df68b | 29 | struct cgraph_local_info GTY(()) |
dafc5b82 | 30 | { |
95c755e9 JH |
31 | /* Size of the function before inlining. */ |
32 | int self_insns; | |
6674a6ce | 33 | |
e0bb17a8 | 34 | /* Set when function function is visible in current compilation unit only |
e2209b03 | 35 | and its address is never taken. */ |
dafc5b82 | 36 | bool local; |
6674a6ce | 37 | |
f6981e16 JH |
38 | /* Set once it has been finalized so we consider it to be output. */ |
39 | bool finalized; | |
b58b1157 | 40 | |
b3c3af2f | 41 | /* False when there something makes inlining impossible (such as va_arg). */ |
b58b1157 | 42 | bool inlinable; |
6674a6ce | 43 | |
e2209b03 | 44 | /* True when function should be inlined independently on its size. */ |
b3c3af2f | 45 | bool disregard_inline_limits; |
6674a6ce | 46 | |
95c755e9 JH |
47 | /* True when the function has been originally extern inline, but it is |
48 | redefined now. */ | |
49 | bool redefined_extern_inline; | |
6674a6ce KZ |
50 | |
51 | /* True if statics_read_for_function and | |
52 | statics_written_for_function contain valid data. */ | |
53 | bool for_functions_valid; | |
dafc5b82 JH |
54 | }; |
55 | ||
56 | /* Information about the function that needs to be computed globally | |
57 | once compilation is finished. Available only with -funit-at-time. */ | |
58 | ||
ed2df68b | 59 | struct cgraph_global_info GTY(()) |
dafc5b82 | 60 | { |
18c6ada9 JH |
61 | /* For inline clones this points to the function they will be inlined into. */ |
62 | struct cgraph_node *inlined_to; | |
63 | ||
b58b1157 JH |
64 | /* Estimated size of the function after inlining. */ |
65 | int insns; | |
66 | ||
18c6ada9 | 67 | /* Set iff the function has been inlined at least once. */ |
1bb17c21 | 68 | bool inlined; |
dafc5b82 JH |
69 | }; |
70 | ||
b255a036 JH |
71 | /* Information about the function that is propagated by the RTL backend. |
72 | Available only for functions that has been already assembled. */ | |
73 | ||
ed2df68b | 74 | struct cgraph_rtl_info GTY(()) |
b255a036 | 75 | { |
6de9cd9a | 76 | int preferred_incoming_stack_boundary; |
ed2df68b JH |
77 | bool const_function; |
78 | bool pure_function; | |
b255a036 JH |
79 | }; |
80 | ||
ba228239 | 81 | /* The cgraph data structure. |
e0bb17a8 | 82 | Each function decl has assigned cgraph_node listing callees and callers. */ |
1c4a429a | 83 | |
d1bd0ded | 84 | struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) |
1c4a429a JH |
85 | { |
86 | tree decl; | |
87 | struct cgraph_edge *callees; | |
88 | struct cgraph_edge *callers; | |
ed2df68b JH |
89 | struct cgraph_node *next; |
90 | struct cgraph_node *previous; | |
1c4a429a JH |
91 | /* For nested functions points to function the node is nested in. */ |
92 | struct cgraph_node *origin; | |
93 | /* Points to first nested function, if any. */ | |
94 | struct cgraph_node *nested; | |
95 | /* Pointer to the next function with same origin, if any. */ | |
96 | struct cgraph_node *next_nested; | |
8bd87c4e JH |
97 | /* Pointer to the next function in cgraph_nodes_queue. */ |
98 | struct cgraph_node *next_needed; | |
18c6ada9 JH |
99 | /* Pointer to the next clone. */ |
100 | struct cgraph_node *next_clone; | |
1655dc9d | 101 | struct cgraph_node *prev_clone; |
1431042e | 102 | PTR GTY ((skip)) aux; |
1c4a429a | 103 | |
95c755e9 JH |
104 | struct cgraph_local_info local; |
105 | struct cgraph_global_info global; | |
106 | struct cgraph_rtl_info rtl; | |
6674a6ce | 107 | |
95c755e9 JH |
108 | /* Unique id of the node. */ |
109 | int uid; | |
1c4a429a | 110 | /* Set when function must be output - it is externally visible |
e2209b03 | 111 | or its address is taken. */ |
1c4a429a JH |
112 | bool needed; |
113 | /* Set when function is reachable by call from other function | |
e0bb17a8 | 114 | that is either reachable or needed. */ |
1c4a429a | 115 | bool reachable; |
25c84396 RH |
116 | /* Set once the function has been instantiated and its callee |
117 | lists created. */ | |
118 | bool analyzed; | |
1c4a429a JH |
119 | /* Set when function is scheduled to be assembled. */ |
120 | bool output; | |
121 | }; | |
122 | ||
2563c224 | 123 | struct cgraph_edge GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) |
1c4a429a | 124 | { |
ed2df68b JH |
125 | struct cgraph_node *caller; |
126 | struct cgraph_node *callee; | |
2563c224 | 127 | struct cgraph_edge *prev_caller; |
1c4a429a | 128 | struct cgraph_edge *next_caller; |
2563c224 | 129 | struct cgraph_edge *prev_callee; |
1c4a429a | 130 | struct cgraph_edge *next_callee; |
18c6ada9 JH |
131 | tree call_expr; |
132 | PTR GTY ((skip (""))) aux; | |
dc0bfe6a JH |
133 | /* When NULL, inline this call. When non-NULL, points to the explanation |
134 | why function was not inlined. */ | |
135 | const char *inline_failed; | |
1c4a429a JH |
136 | }; |
137 | ||
ba228239 | 138 | /* The cgraph_varpool data structure. |
e69529cd JH |
139 | Each static variable decl has assigned cgraph_varpool_node. */ |
140 | ||
ed2df68b | 141 | struct cgraph_varpool_node GTY(()) |
e69529cd JH |
142 | { |
143 | tree decl; | |
bedb9fc0 RH |
144 | /* Pointer to the next function in cgraph_varpool_nodes. */ |
145 | struct cgraph_varpool_node *next; | |
8bd87c4e JH |
146 | /* Pointer to the next function in cgraph_varpool_nodes_queue. */ |
147 | struct cgraph_varpool_node *next_needed; | |
e69529cd JH |
148 | |
149 | /* Set when function must be output - it is externally visible | |
e2209b03 | 150 | or its address is taken. */ |
e69529cd JH |
151 | bool needed; |
152 | /* Set once it has been finalized so we consider it to be output. */ | |
153 | bool finalized; | |
154 | /* Set when function is scheduled to be assembled. */ | |
155 | bool output; | |
156 | }; | |
157 | ||
ed2df68b JH |
158 | extern GTY(()) struct cgraph_node *cgraph_nodes; |
159 | extern GTY(()) int cgraph_n_nodes; | |
b58b1157 | 160 | extern GTY(()) int cgraph_max_uid; |
dafc5b82 | 161 | extern bool cgraph_global_info_ready; |
ed2df68b | 162 | extern GTY(()) struct cgraph_node *cgraph_nodes_queue; |
1c4a429a | 163 | |
ed2df68b | 164 | extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue; |
e69529cd | 165 | |
1c4a429a | 166 | /* In cgraph.c */ |
439f7bc3 | 167 | void dump_cgraph (FILE *); |
18c6ada9 JH |
168 | void dump_cgraph_node (FILE *, struct cgraph_node *); |
169 | void cgraph_remove_edge (struct cgraph_edge *); | |
439f7bc3 | 170 | void cgraph_remove_node (struct cgraph_node *); |
2563c224 | 171 | void cgraph_node_remove_callees (struct cgraph_node *node); |
18c6ada9 JH |
172 | struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, |
173 | struct cgraph_node *, | |
174 | tree); | |
439f7bc3 | 175 | struct cgraph_node *cgraph_node (tree decl); |
bedb9fc0 | 176 | struct cgraph_node *cgraph_node_for_asm (tree asmname); |
18c6ada9 | 177 | struct cgraph_edge *cgraph_edge (struct cgraph_node *, tree call_expr); |
439f7bc3 AJ |
178 | struct cgraph_local_info *cgraph_local_info (tree); |
179 | struct cgraph_global_info *cgraph_global_info (tree); | |
180 | struct cgraph_rtl_info *cgraph_rtl_info (tree); | |
181 | const char * cgraph_node_name (struct cgraph_node *); | |
18c6ada9 JH |
182 | struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, struct cgraph_node *, tree); |
183 | struct cgraph_node * cgraph_clone_node (struct cgraph_node *); | |
1c4a429a | 184 | |
e69529cd | 185 | struct cgraph_varpool_node *cgraph_varpool_node (tree decl); |
bedb9fc0 | 186 | struct cgraph_varpool_node *cgraph_varpool_node_for_asm (tree asmname); |
e69529cd JH |
187 | void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *); |
188 | void cgraph_varpool_finalize_decl (tree); | |
189 | bool cgraph_varpool_assemble_pending_decls (void); | |
18c6ada9 | 190 | void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *); |
e69529cd | 191 | |
1bb17c21 | 192 | bool cgraph_function_possibly_inlined_p (tree); |
8f235343 | 193 | void cgraph_unnest_node (struct cgraph_node *node); |
1bb17c21 | 194 | |
1c4a429a | 195 | /* In cgraphunit.c */ |
f6d1b84a | 196 | bool cgraph_assemble_pending_functions (void); |
6b00c969 | 197 | void cgraph_finalize_function (tree, bool); |
439f7bc3 | 198 | void cgraph_finalize_compilation_unit (void); |
18c6ada9 | 199 | void cgraph_create_edges (struct cgraph_node *, tree); |
439f7bc3 | 200 | void cgraph_optimize (void); |
8dafba3c RH |
201 | void cgraph_mark_needed_node (struct cgraph_node *); |
202 | void cgraph_mark_reachable_node (struct cgraph_node *); | |
18c6ada9 JH |
203 | bool cgraph_inline_p (struct cgraph_edge *, const char **reason); |
204 | bool cgraph_preserve_function_body_p (tree); | |
205 | void verify_cgraph (void); | |
206 | void verify_cgraph_node (struct cgraph_node *); | |
207 | void cgraph_mark_inline_edge (struct cgraph_edge *e); | |
208 | void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate); | |
35b6fdcf | 209 | void cgraph_build_static_cdtor (char which, tree body, int priority); |
6674a6ce | 210 | void cgraph_reset_static_var_maps (void); |
9b3e897d | 211 | void init_cgraph (void); |
1c4a429a JH |
212 | |
213 | #endif /* GCC_CGRAPH_H */ |