annotate gcc/cgraph.h @ 120:f93fa5091070

fix conv1.c
author mir3636
date Thu, 08 Mar 2018 14:53:42 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Callgraph handling code.
111
kono
parents: 67
diff changeset
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Jan Hubicka
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #ifndef GCC_CGRAPH_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define GCC_CGRAPH_H
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
23
111
kono
parents: 67
diff changeset
24 #include "profile-count.h"
kono
parents: 67
diff changeset
25 #include "ipa-ref.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
26 #include "plugin-api.h"
111
kono
parents: 67
diff changeset
27
kono
parents: 67
diff changeset
28 class ipa_opt_pass_d;
kono
parents: 67
diff changeset
29 typedef ipa_opt_pass_d *ipa_opt_pass;
kono
parents: 67
diff changeset
30
kono
parents: 67
diff changeset
31 /* Symbol table consists of functions and variables.
kono
parents: 67
diff changeset
32 TODO: add labels and CONST_DECLs. */
kono
parents: 67
diff changeset
33 enum symtab_type
kono
parents: 67
diff changeset
34 {
kono
parents: 67
diff changeset
35 SYMTAB_SYMBOL,
kono
parents: 67
diff changeset
36 SYMTAB_FUNCTION,
kono
parents: 67
diff changeset
37 SYMTAB_VARIABLE
kono
parents: 67
diff changeset
38 };
kono
parents: 67
diff changeset
39
kono
parents: 67
diff changeset
40 /* Section names are stored as reference counted strings in GGC safe hashtable
kono
parents: 67
diff changeset
41 (to make them survive through PCH). */
kono
parents: 67
diff changeset
42
kono
parents: 67
diff changeset
43 struct GTY((for_user)) section_hash_entry
kono
parents: 67
diff changeset
44 {
kono
parents: 67
diff changeset
45 int ref_count;
kono
parents: 67
diff changeset
46 char *name; /* As long as this datastructure stays in GGC, we can not put
kono
parents: 67
diff changeset
47 string at the tail of structure of GGC dies in horrible
kono
parents: 67
diff changeset
48 way */
kono
parents: 67
diff changeset
49 };
kono
parents: 67
diff changeset
50
kono
parents: 67
diff changeset
51 struct section_name_hasher : ggc_ptr_hash<section_hash_entry>
kono
parents: 67
diff changeset
52 {
kono
parents: 67
diff changeset
53 typedef const char *compare_type;
kono
parents: 67
diff changeset
54
kono
parents: 67
diff changeset
55 static hashval_t hash (section_hash_entry *);
kono
parents: 67
diff changeset
56 static bool equal (section_hash_entry *, const char *);
kono
parents: 67
diff changeset
57 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 enum availability
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 /* Not yet set by cgraph_function_body_availability. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 AVAIL_UNSET,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 /* Function body/variable initializer is unknown. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 AVAIL_NOT_AVAILABLE,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 /* Function body/variable initializer is known but might be replaced
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 by a different one from other compilation unit and thus needs to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 arbitrary side effects on escaping variables and functions, while
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 like AVAILABLE it might access static variables. */
111
kono
parents: 67
diff changeset
70 AVAIL_INTERPOSABLE,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 /* Function body/variable initializer is known and will be used in final
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 program. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 AVAIL_AVAILABLE,
111
kono
parents: 67
diff changeset
74 /* Function body/variable initializer is known and all it's uses are
kono
parents: 67
diff changeset
75 explicitly visible within current unit (ie it's address is never taken and
kono
parents: 67
diff changeset
76 it is not exported to other units). Currently used only for functions. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 AVAIL_LOCAL
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
111
kono
parents: 67
diff changeset
80 /* Classification of symbols WRT partitioning. */
kono
parents: 67
diff changeset
81 enum symbol_partitioning_class
kono
parents: 67
diff changeset
82 {
kono
parents: 67
diff changeset
83 /* External declarations are ignored by partitioning algorithms and they are
kono
parents: 67
diff changeset
84 added into the boundary later via compute_ltrans_boundary. */
kono
parents: 67
diff changeset
85 SYMBOL_EXTERNAL,
kono
parents: 67
diff changeset
86 /* Partitioned symbols are pur into one of partitions. */
kono
parents: 67
diff changeset
87 SYMBOL_PARTITION,
kono
parents: 67
diff changeset
88 /* Duplicated symbols (such as comdat or constant pool references) are
kono
parents: 67
diff changeset
89 copied into every node needing them via add_symbol_to_partition. */
kono
parents: 67
diff changeset
90 SYMBOL_DUPLICATE
kono
parents: 67
diff changeset
91 };
kono
parents: 67
diff changeset
92
kono
parents: 67
diff changeset
93 /* Base of all entries in the symbol table.
kono
parents: 67
diff changeset
94 The symtab_node is inherited by cgraph and varpol nodes. */
kono
parents: 67
diff changeset
95 class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
kono
parents: 67
diff changeset
96 chain_next ("%h.next"), chain_prev ("%h.previous")))
kono
parents: 67
diff changeset
97 symtab_node
kono
parents: 67
diff changeset
98 {
kono
parents: 67
diff changeset
99 public:
kono
parents: 67
diff changeset
100 /* Return name. */
kono
parents: 67
diff changeset
101 const char *name () const;
kono
parents: 67
diff changeset
102
kono
parents: 67
diff changeset
103 /* Return dump name. */
kono
parents: 67
diff changeset
104 const char *dump_name () const;
kono
parents: 67
diff changeset
105
kono
parents: 67
diff changeset
106 /* Return asm name. */
kono
parents: 67
diff changeset
107 const char *asm_name () const;
kono
parents: 67
diff changeset
108
kono
parents: 67
diff changeset
109 /* Return dump name with assembler name. */
kono
parents: 67
diff changeset
110 const char *dump_asm_name () const;
kono
parents: 67
diff changeset
111
kono
parents: 67
diff changeset
112 /* Add node into symbol table. This function is not used directly, but via
kono
parents: 67
diff changeset
113 cgraph/varpool node creation routines. */
kono
parents: 67
diff changeset
114 void register_symbol (void);
kono
parents: 67
diff changeset
115
kono
parents: 67
diff changeset
116 /* Remove symbol from symbol table. */
kono
parents: 67
diff changeset
117 void remove (void);
kono
parents: 67
diff changeset
118
kono
parents: 67
diff changeset
119 /* Dump symtab node to F. */
kono
parents: 67
diff changeset
120 void dump (FILE *f);
kono
parents: 67
diff changeset
121
kono
parents: 67
diff changeset
122 /* Dump symtab node to stderr. */
kono
parents: 67
diff changeset
123 void DEBUG_FUNCTION debug (void);
kono
parents: 67
diff changeset
124
kono
parents: 67
diff changeset
125 /* Verify consistency of node. */
kono
parents: 67
diff changeset
126 void DEBUG_FUNCTION verify (void);
kono
parents: 67
diff changeset
127
kono
parents: 67
diff changeset
128 /* Return ipa reference from this symtab_node to
kono
parents: 67
diff changeset
129 REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
kono
parents: 67
diff changeset
130 of the use and STMT the statement (if it exists). */
kono
parents: 67
diff changeset
131 ipa_ref *create_reference (symtab_node *referred_node,
kono
parents: 67
diff changeset
132 enum ipa_ref_use use_type);
kono
parents: 67
diff changeset
133
kono
parents: 67
diff changeset
134 /* Return ipa reference from this symtab_node to
kono
parents: 67
diff changeset
135 REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
kono
parents: 67
diff changeset
136 of the use and STMT the statement (if it exists). */
kono
parents: 67
diff changeset
137 ipa_ref *create_reference (symtab_node *referred_node,
kono
parents: 67
diff changeset
138 enum ipa_ref_use use_type, gimple *stmt);
kono
parents: 67
diff changeset
139
kono
parents: 67
diff changeset
140 /* If VAL is a reference to a function or a variable, add a reference from
kono
parents: 67
diff changeset
141 this symtab_node to the corresponding symbol table node. Return the new
kono
parents: 67
diff changeset
142 reference or NULL if none was created. */
kono
parents: 67
diff changeset
143 ipa_ref *maybe_create_reference (tree val, gimple *stmt);
kono
parents: 67
diff changeset
144
kono
parents: 67
diff changeset
145 /* Clone all references from symtab NODE to this symtab_node. */
kono
parents: 67
diff changeset
146 void clone_references (symtab_node *node);
kono
parents: 67
diff changeset
147
kono
parents: 67
diff changeset
148 /* Remove all stmt references in non-speculative references.
kono
parents: 67
diff changeset
149 Those are not maintained during inlining & clonning.
kono
parents: 67
diff changeset
150 The exception are speculative references that are updated along
kono
parents: 67
diff changeset
151 with callgraph edges associated with them. */
kono
parents: 67
diff changeset
152 void clone_referring (symtab_node *node);
kono
parents: 67
diff changeset
153
kono
parents: 67
diff changeset
154 /* Clone reference REF to this symtab_node and set its stmt to STMT. */
kono
parents: 67
diff changeset
155 ipa_ref *clone_reference (ipa_ref *ref, gimple *stmt);
kono
parents: 67
diff changeset
156
kono
parents: 67
diff changeset
157 /* Find the structure describing a reference to REFERRED_NODE
kono
parents: 67
diff changeset
158 and associated with statement STMT. */
kono
parents: 67
diff changeset
159 ipa_ref *find_reference (symtab_node *referred_node, gimple *stmt,
kono
parents: 67
diff changeset
160 unsigned int lto_stmt_uid);
kono
parents: 67
diff changeset
161
kono
parents: 67
diff changeset
162 /* Remove all references that are associated with statement STMT. */
kono
parents: 67
diff changeset
163 void remove_stmt_references (gimple *stmt);
kono
parents: 67
diff changeset
164
kono
parents: 67
diff changeset
165 /* Remove all stmt references in non-speculative references.
kono
parents: 67
diff changeset
166 Those are not maintained during inlining & clonning.
kono
parents: 67
diff changeset
167 The exception are speculative references that are updated along
kono
parents: 67
diff changeset
168 with callgraph edges associated with them. */
kono
parents: 67
diff changeset
169 void clear_stmts_in_references (void);
kono
parents: 67
diff changeset
170
kono
parents: 67
diff changeset
171 /* Remove all references in ref list. */
kono
parents: 67
diff changeset
172 void remove_all_references (void);
kono
parents: 67
diff changeset
173
kono
parents: 67
diff changeset
174 /* Remove all referring items in ref list. */
kono
parents: 67
diff changeset
175 void remove_all_referring (void);
kono
parents: 67
diff changeset
176
kono
parents: 67
diff changeset
177 /* Dump references in ref list to FILE. */
kono
parents: 67
diff changeset
178 void dump_references (FILE *file);
kono
parents: 67
diff changeset
179
kono
parents: 67
diff changeset
180 /* Dump referring in list to FILE. */
kono
parents: 67
diff changeset
181 void dump_referring (FILE *);
kono
parents: 67
diff changeset
182
kono
parents: 67
diff changeset
183 /* Get number of references for this node. */
kono
parents: 67
diff changeset
184 inline unsigned num_references (void)
kono
parents: 67
diff changeset
185 {
kono
parents: 67
diff changeset
186 return ref_list.references ? ref_list.references->length () : 0;
kono
parents: 67
diff changeset
187 }
kono
parents: 67
diff changeset
188
kono
parents: 67
diff changeset
189 /* Iterates I-th reference in the list, REF is also set. */
kono
parents: 67
diff changeset
190 ipa_ref *iterate_reference (unsigned i, ipa_ref *&ref);
kono
parents: 67
diff changeset
191
kono
parents: 67
diff changeset
192 /* Iterates I-th referring item in the list, REF is also set. */
kono
parents: 67
diff changeset
193 ipa_ref *iterate_referring (unsigned i, ipa_ref *&ref);
kono
parents: 67
diff changeset
194
kono
parents: 67
diff changeset
195 /* Iterates I-th referring alias item in the list, REF is also set. */
kono
parents: 67
diff changeset
196 ipa_ref *iterate_direct_aliases (unsigned i, ipa_ref *&ref);
kono
parents: 67
diff changeset
197
kono
parents: 67
diff changeset
198 /* Return true if symtab node and TARGET represents
kono
parents: 67
diff changeset
199 semantically equivalent symbols. */
kono
parents: 67
diff changeset
200 bool semantically_equivalent_p (symtab_node *target);
kono
parents: 67
diff changeset
201
kono
parents: 67
diff changeset
202 /* Classify symbol symtab node for partitioning. */
kono
parents: 67
diff changeset
203 enum symbol_partitioning_class get_partitioning_class (void);
kono
parents: 67
diff changeset
204
kono
parents: 67
diff changeset
205 /* Return comdat group. */
kono
parents: 67
diff changeset
206 tree get_comdat_group ()
kono
parents: 67
diff changeset
207 {
kono
parents: 67
diff changeset
208 return x_comdat_group;
kono
parents: 67
diff changeset
209 }
kono
parents: 67
diff changeset
210
kono
parents: 67
diff changeset
211 /* Return comdat group as identifier_node. */
kono
parents: 67
diff changeset
212 tree get_comdat_group_id ()
kono
parents: 67
diff changeset
213 {
kono
parents: 67
diff changeset
214 if (x_comdat_group && TREE_CODE (x_comdat_group) != IDENTIFIER_NODE)
kono
parents: 67
diff changeset
215 x_comdat_group = DECL_ASSEMBLER_NAME (x_comdat_group);
kono
parents: 67
diff changeset
216 return x_comdat_group;
kono
parents: 67
diff changeset
217 }
kono
parents: 67
diff changeset
218
kono
parents: 67
diff changeset
219 /* Set comdat group. */
kono
parents: 67
diff changeset
220 void set_comdat_group (tree group)
kono
parents: 67
diff changeset
221 {
kono
parents: 67
diff changeset
222 gcc_checking_assert (!group || TREE_CODE (group) == IDENTIFIER_NODE
kono
parents: 67
diff changeset
223 || DECL_P (group));
kono
parents: 67
diff changeset
224 x_comdat_group = group;
kono
parents: 67
diff changeset
225 }
kono
parents: 67
diff changeset
226
kono
parents: 67
diff changeset
227 /* Return section as string. */
kono
parents: 67
diff changeset
228 const char * get_section ()
kono
parents: 67
diff changeset
229 {
kono
parents: 67
diff changeset
230 if (!x_section)
kono
parents: 67
diff changeset
231 return NULL;
kono
parents: 67
diff changeset
232 return x_section->name;
kono
parents: 67
diff changeset
233 }
kono
parents: 67
diff changeset
234
kono
parents: 67
diff changeset
235 /* Remove node from same comdat group. */
kono
parents: 67
diff changeset
236 void remove_from_same_comdat_group (void);
kono
parents: 67
diff changeset
237
kono
parents: 67
diff changeset
238 /* Add this symtab_node to the same comdat group that OLD is in. */
kono
parents: 67
diff changeset
239 void add_to_same_comdat_group (symtab_node *old_node);
kono
parents: 67
diff changeset
240
kono
parents: 67
diff changeset
241 /* Dissolve the same_comdat_group list in which NODE resides. */
kono
parents: 67
diff changeset
242 void dissolve_same_comdat_group_list (void);
kono
parents: 67
diff changeset
243
kono
parents: 67
diff changeset
244 /* Return true when symtab_node is known to be used from other (non-LTO)
kono
parents: 67
diff changeset
245 object file. Known only when doing LTO via linker plugin. */
kono
parents: 67
diff changeset
246 bool used_from_object_file_p (void);
kono
parents: 67
diff changeset
247
kono
parents: 67
diff changeset
248 /* Walk the alias chain to return the symbol NODE is alias of.
kono
parents: 67
diff changeset
249 If NODE is not an alias, return NODE.
kono
parents: 67
diff changeset
250 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
251 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
252 when determining the availability. */
kono
parents: 67
diff changeset
253 symtab_node *ultimate_alias_target (enum availability *avail = NULL,
kono
parents: 67
diff changeset
254 struct symtab_node *ref = NULL);
kono
parents: 67
diff changeset
255
kono
parents: 67
diff changeset
256 /* Return next reachable static symbol with initializer after NODE. */
kono
parents: 67
diff changeset
257 inline symtab_node *next_defined_symbol (void);
kono
parents: 67
diff changeset
258
kono
parents: 67
diff changeset
259 /* Add reference recording that symtab node is alias of TARGET.
kono
parents: 67
diff changeset
260 If TRANSPARENT is true make the alias to be transparent alias.
kono
parents: 67
diff changeset
261 The function can fail in the case of aliasing cycles; in this case
kono
parents: 67
diff changeset
262 it returns false. */
kono
parents: 67
diff changeset
263 bool resolve_alias (symtab_node *target, bool transparent = false);
kono
parents: 67
diff changeset
264
kono
parents: 67
diff changeset
265 /* C++ FE sometimes change linkage flags after producing same
kono
parents: 67
diff changeset
266 body aliases. */
kono
parents: 67
diff changeset
267 void fixup_same_cpp_alias_visibility (symtab_node *target);
kono
parents: 67
diff changeset
268
kono
parents: 67
diff changeset
269 /* Call callback on symtab node and aliases associated to this node.
kono
parents: 67
diff changeset
270 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
kono
parents: 67
diff changeset
271 skipped. */
kono
parents: 67
diff changeset
272 bool call_for_symbol_and_aliases (bool (*callback) (symtab_node *, void *),
kono
parents: 67
diff changeset
273 void *data,
kono
parents: 67
diff changeset
274 bool include_overwrite);
kono
parents: 67
diff changeset
275
kono
parents: 67
diff changeset
276 /* If node can not be interposable by static or dynamic linker to point to
kono
parents: 67
diff changeset
277 different definition, return this symbol. Otherwise look for alias with
kono
parents: 67
diff changeset
278 such property and if none exists, introduce new one. */
kono
parents: 67
diff changeset
279 symtab_node *noninterposable_alias (void);
kono
parents: 67
diff changeset
280
kono
parents: 67
diff changeset
281 /* Return node that alias is aliasing. */
kono
parents: 67
diff changeset
282 inline symtab_node *get_alias_target (void);
kono
parents: 67
diff changeset
283
kono
parents: 67
diff changeset
284 /* Set section for symbol and its aliases. */
kono
parents: 67
diff changeset
285 void set_section (const char *section);
kono
parents: 67
diff changeset
286
kono
parents: 67
diff changeset
287 /* Set section, do not recurse into aliases.
kono
parents: 67
diff changeset
288 When one wants to change section of symbol and its aliases,
kono
parents: 67
diff changeset
289 use set_section. */
kono
parents: 67
diff changeset
290 void set_section_for_node (const char *section);
kono
parents: 67
diff changeset
291
kono
parents: 67
diff changeset
292 /* Set initialization priority to PRIORITY. */
kono
parents: 67
diff changeset
293 void set_init_priority (priority_type priority);
kono
parents: 67
diff changeset
294
kono
parents: 67
diff changeset
295 /* Return the initialization priority. */
kono
parents: 67
diff changeset
296 priority_type get_init_priority ();
kono
parents: 67
diff changeset
297
kono
parents: 67
diff changeset
298 /* Return availability of NODE when referenced from REF. */
kono
parents: 67
diff changeset
299 enum availability get_availability (symtab_node *ref = NULL);
kono
parents: 67
diff changeset
300
kono
parents: 67
diff changeset
301 /* Return true if NODE binds to current definition in final executable
kono
parents: 67
diff changeset
302 when referenced from REF. If REF is NULL return conservative value
kono
parents: 67
diff changeset
303 for any reference. */
kono
parents: 67
diff changeset
304 bool binds_to_current_def_p (symtab_node *ref = NULL);
kono
parents: 67
diff changeset
305
kono
parents: 67
diff changeset
306 /* Make DECL local. */
kono
parents: 67
diff changeset
307 void make_decl_local (void);
kono
parents: 67
diff changeset
308
kono
parents: 67
diff changeset
309 /* Copy visibility from N. */
kono
parents: 67
diff changeset
310 void copy_visibility_from (symtab_node *n);
kono
parents: 67
diff changeset
311
kono
parents: 67
diff changeset
312 /* Return desired alignment of the definition. This is NOT alignment useful
kono
parents: 67
diff changeset
313 to access THIS, because THIS may be interposable and DECL_ALIGN should
kono
parents: 67
diff changeset
314 be used instead. It however must be guaranteed when output definition
kono
parents: 67
diff changeset
315 of THIS. */
kono
parents: 67
diff changeset
316 unsigned int definition_alignment ();
kono
parents: 67
diff changeset
317
kono
parents: 67
diff changeset
318 /* Return true if alignment can be increased. */
kono
parents: 67
diff changeset
319 bool can_increase_alignment_p ();
kono
parents: 67
diff changeset
320
kono
parents: 67
diff changeset
321 /* Increase alignment of symbol to ALIGN. */
kono
parents: 67
diff changeset
322 void increase_alignment (unsigned int align);
kono
parents: 67
diff changeset
323
kono
parents: 67
diff changeset
324 /* Return true if list contains an alias. */
kono
parents: 67
diff changeset
325 bool has_aliases_p (void);
kono
parents: 67
diff changeset
326
kono
parents: 67
diff changeset
327 /* Return true when the symbol is real symbol, i.e. it is not inline clone
kono
parents: 67
diff changeset
328 or abstract function kept for debug info purposes only. */
kono
parents: 67
diff changeset
329 bool real_symbol_p (void);
kono
parents: 67
diff changeset
330
kono
parents: 67
diff changeset
331 /* Determine if symbol declaration is needed. That is, visible to something
kono
parents: 67
diff changeset
332 either outside this translation unit, something magic in the system
kono
parents: 67
diff changeset
333 configury. This function is used just during symbol creation. */
kono
parents: 67
diff changeset
334 bool needed_p (void);
kono
parents: 67
diff changeset
335
kono
parents: 67
diff changeset
336 /* Return true if this symbol is a function from the C frontend specified
kono
parents: 67
diff changeset
337 directly in RTL form (with "__RTL"). */
kono
parents: 67
diff changeset
338 bool native_rtl_p () const;
kono
parents: 67
diff changeset
339
kono
parents: 67
diff changeset
340 /* Return true when there are references to the node. */
kono
parents: 67
diff changeset
341 bool referred_to_p (bool include_self = true);
kono
parents: 67
diff changeset
342
kono
parents: 67
diff changeset
343 /* Return true if symbol can be discarded by linker from the binary.
kono
parents: 67
diff changeset
344 Assume that symbol is used (so there is no need to take into account
kono
parents: 67
diff changeset
345 garbage collecting linkers)
kono
parents: 67
diff changeset
346
kono
parents: 67
diff changeset
347 This can happen for comdats, commons and weaks when they are previaled
kono
parents: 67
diff changeset
348 by other definition at static linking time. */
kono
parents: 67
diff changeset
349 inline bool
kono
parents: 67
diff changeset
350 can_be_discarded_p (void)
kono
parents: 67
diff changeset
351 {
kono
parents: 67
diff changeset
352 return (DECL_EXTERNAL (decl)
kono
parents: 67
diff changeset
353 || ((get_comdat_group ()
kono
parents: 67
diff changeset
354 || DECL_COMMON (decl)
kono
parents: 67
diff changeset
355 || (DECL_SECTION_NAME (decl) && DECL_WEAK (decl)))
kono
parents: 67
diff changeset
356 && ((resolution != LDPR_PREVAILING_DEF
kono
parents: 67
diff changeset
357 && resolution != LDPR_PREVAILING_DEF_IRONLY_EXP)
kono
parents: 67
diff changeset
358 || flag_incremental_link)
kono
parents: 67
diff changeset
359 && resolution != LDPR_PREVAILING_DEF_IRONLY));
kono
parents: 67
diff changeset
360 }
kono
parents: 67
diff changeset
361
kono
parents: 67
diff changeset
362 /* Return true if NODE is local to a particular COMDAT group, and must not
kono
parents: 67
diff changeset
363 be named from outside the COMDAT. This is used for C++ decloned
kono
parents: 67
diff changeset
364 constructors. */
kono
parents: 67
diff changeset
365 inline bool comdat_local_p (void)
kono
parents: 67
diff changeset
366 {
kono
parents: 67
diff changeset
367 return (same_comdat_group && !TREE_PUBLIC (decl));
kono
parents: 67
diff changeset
368 }
kono
parents: 67
diff changeset
369
kono
parents: 67
diff changeset
370 /* Return true if ONE and TWO are part of the same COMDAT group. */
kono
parents: 67
diff changeset
371 inline bool in_same_comdat_group_p (symtab_node *target);
kono
parents: 67
diff changeset
372
kono
parents: 67
diff changeset
373 /* Return true if symbol is known to be nonzero. */
kono
parents: 67
diff changeset
374 bool nonzero_address ();
kono
parents: 67
diff changeset
375
kono
parents: 67
diff changeset
376 /* Return 0 if symbol is known to have different address than S2,
kono
parents: 67
diff changeset
377 Return 1 if symbol is known to have same address as S2,
kono
parents: 67
diff changeset
378 return 2 otherwise.
kono
parents: 67
diff changeset
379
kono
parents: 67
diff changeset
380 If MEMORY_ACCESSED is true, assume that both memory pointer to THIS
kono
parents: 67
diff changeset
381 and S2 is going to be accessed. This eliminates the situations when
kono
parents: 67
diff changeset
382 either THIS or S2 is NULL and is seful for comparing bases when deciding
kono
parents: 67
diff changeset
383 about memory aliasing. */
kono
parents: 67
diff changeset
384 int equal_address_to (symtab_node *s2, bool memory_accessed = false);
kono
parents: 67
diff changeset
385
kono
parents: 67
diff changeset
386 /* Return true if symbol's address may possibly be compared to other
kono
parents: 67
diff changeset
387 symbol's address. */
kono
parents: 67
diff changeset
388 bool address_matters_p ();
kono
parents: 67
diff changeset
389
kono
parents: 67
diff changeset
390 /* Return true if NODE's address can be compared. This use properties
kono
parents: 67
diff changeset
391 of NODE only and does not look if the address is actually taken in
kono
parents: 67
diff changeset
392 interesting way. For that use ADDRESS_MATTERS_P instead. */
kono
parents: 67
diff changeset
393 bool address_can_be_compared_p (void);
kono
parents: 67
diff changeset
394
kono
parents: 67
diff changeset
395 /* Return symbol table node associated with DECL, if any,
kono
parents: 67
diff changeset
396 and NULL otherwise. */
kono
parents: 67
diff changeset
397 static inline symtab_node *get (const_tree decl)
kono
parents: 67
diff changeset
398 {
kono
parents: 67
diff changeset
399 /* Check that we are called for sane type of object - functions
kono
parents: 67
diff changeset
400 and static or external variables. */
kono
parents: 67
diff changeset
401 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
kono
parents: 67
diff changeset
402 || (TREE_CODE (decl) == VAR_DECL
kono
parents: 67
diff changeset
403 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
kono
parents: 67
diff changeset
404 || in_lto_p)));
kono
parents: 67
diff changeset
405 /* Check that the mapping is sane - perhaps this check can go away,
kono
parents: 67
diff changeset
406 but at the moment frontends tends to corrupt the mapping by calling
kono
parents: 67
diff changeset
407 memcpy/memset on the tree nodes. */
kono
parents: 67
diff changeset
408 gcc_checking_assert (!decl->decl_with_vis.symtab_node
kono
parents: 67
diff changeset
409 || decl->decl_with_vis.symtab_node->decl == decl);
kono
parents: 67
diff changeset
410 return decl->decl_with_vis.symtab_node;
kono
parents: 67
diff changeset
411 }
kono
parents: 67
diff changeset
412
kono
parents: 67
diff changeset
413 /* Try to find a symtab node for declaration DECL and if it does not
kono
parents: 67
diff changeset
414 exist or if it corresponds to an inline clone, create a new one. */
kono
parents: 67
diff changeset
415 static inline symtab_node * get_create (tree node);
kono
parents: 67
diff changeset
416
kono
parents: 67
diff changeset
417 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
kono
parents: 67
diff changeset
418 Return NULL if there's no such node. */
kono
parents: 67
diff changeset
419 static symtab_node *get_for_asmname (const_tree asmname);
kono
parents: 67
diff changeset
420
kono
parents: 67
diff changeset
421 /* Verify symbol table for internal consistency. */
kono
parents: 67
diff changeset
422 static DEBUG_FUNCTION void verify_symtab_nodes (void);
kono
parents: 67
diff changeset
423
kono
parents: 67
diff changeset
424 /* Perform internal consistency checks, if they are enabled. */
kono
parents: 67
diff changeset
425 static inline void checking_verify_symtab_nodes (void);
kono
parents: 67
diff changeset
426
kono
parents: 67
diff changeset
427 /* Type of the symbol. */
kono
parents: 67
diff changeset
428 ENUM_BITFIELD (symtab_type) type : 8;
kono
parents: 67
diff changeset
429
kono
parents: 67
diff changeset
430 /* The symbols resolution. */
kono
parents: 67
diff changeset
431 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
kono
parents: 67
diff changeset
432
kono
parents: 67
diff changeset
433 /*** Flags representing the symbol type. ***/
kono
parents: 67
diff changeset
434
kono
parents: 67
diff changeset
435 /* True when symbol corresponds to a definition in current unit.
kono
parents: 67
diff changeset
436 set via finalize_function or finalize_decl */
kono
parents: 67
diff changeset
437 unsigned definition : 1;
kono
parents: 67
diff changeset
438 /* True when symbol is an alias.
kono
parents: 67
diff changeset
439 Set by ssemble_alias. */
kono
parents: 67
diff changeset
440 unsigned alias : 1;
kono
parents: 67
diff changeset
441 /* When true the alias is translated into its target symbol either by GCC
kono
parents: 67
diff changeset
442 or assembler (it also may just be a duplicate declaration of the same
kono
parents: 67
diff changeset
443 linker name).
kono
parents: 67
diff changeset
444
kono
parents: 67
diff changeset
445 Currently transparent aliases come in three different flavors
kono
parents: 67
diff changeset
446 - aliases having the same assembler name as their target (aka duplicated
kono
parents: 67
diff changeset
447 declarations). In this case the assembler names compare via
kono
parents: 67
diff changeset
448 assembler_names_equal_p and weakref is false
kono
parents: 67
diff changeset
449 - aliases that are renamed at a time being output to final file
kono
parents: 67
diff changeset
450 by varasm.c. For those DECL_ASSEMBLER_NAME have
kono
parents: 67
diff changeset
451 IDENTIFIER_TRANSPARENT_ALIAS set and thus also their assembler
kono
parents: 67
diff changeset
452 name must be unique.
kono
parents: 67
diff changeset
453 Weakrefs belong to this cateogry when we target assembler without
kono
parents: 67
diff changeset
454 .weakref directive.
kono
parents: 67
diff changeset
455 - weakrefs that are renamed by assembler via .weakref directive.
kono
parents: 67
diff changeset
456 In this case the alias may or may not be definition (depending if
kono
parents: 67
diff changeset
457 target declaration was seen by the compiler), weakref is set.
kono
parents: 67
diff changeset
458 Unless we are before renaming statics, assembler names are different.
kono
parents: 67
diff changeset
459
kono
parents: 67
diff changeset
460 Given that we now support duplicate declarations, the second option is
kono
parents: 67
diff changeset
461 redundant and will be removed. */
kono
parents: 67
diff changeset
462 unsigned transparent_alias : 1;
kono
parents: 67
diff changeset
463 /* True when alias is a weakref. */
kono
parents: 67
diff changeset
464 unsigned weakref : 1;
kono
parents: 67
diff changeset
465 /* C++ frontend produce same body aliases and extra name aliases for
kono
parents: 67
diff changeset
466 virtual functions and vtables that are obviously equivalent.
kono
parents: 67
diff changeset
467 Those aliases are bit special, especially because C++ frontend
kono
parents: 67
diff changeset
468 visibility code is so ugly it can not get them right at first time
kono
parents: 67
diff changeset
469 and their visibility needs to be copied from their "masters" at
kono
parents: 67
diff changeset
470 the end of parsing. */
kono
parents: 67
diff changeset
471 unsigned cpp_implicit_alias : 1;
kono
parents: 67
diff changeset
472 /* Set once the definition was analyzed. The list of references and
kono
parents: 67
diff changeset
473 other properties are built during analysis. */
kono
parents: 67
diff changeset
474 unsigned analyzed : 1;
kono
parents: 67
diff changeset
475 /* Set for write-only variables. */
kono
parents: 67
diff changeset
476 unsigned writeonly : 1;
kono
parents: 67
diff changeset
477 /* Visibility of symbol was used for further optimization; do not
kono
parents: 67
diff changeset
478 permit further changes. */
kono
parents: 67
diff changeset
479 unsigned refuse_visibility_changes : 1;
kono
parents: 67
diff changeset
480
kono
parents: 67
diff changeset
481 /*** Visibility and linkage flags. ***/
kono
parents: 67
diff changeset
482
kono
parents: 67
diff changeset
483 /* Set when function is visible by other units. */
kono
parents: 67
diff changeset
484 unsigned externally_visible : 1;
kono
parents: 67
diff changeset
485 /* Don't reorder to other symbols having this set. */
kono
parents: 67
diff changeset
486 unsigned no_reorder : 1;
kono
parents: 67
diff changeset
487 /* The symbol will be assumed to be used in an invisible way (like
kono
parents: 67
diff changeset
488 by an toplevel asm statement). */
kono
parents: 67
diff changeset
489 unsigned force_output : 1;
kono
parents: 67
diff changeset
490 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
kono
parents: 67
diff changeset
491 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
kono
parents: 67
diff changeset
492 to static and it does not inhibit optimization. */
kono
parents: 67
diff changeset
493 unsigned forced_by_abi : 1;
kono
parents: 67
diff changeset
494 /* True when the name is known to be unique and thus it does not need mangling. */
kono
parents: 67
diff changeset
495 unsigned unique_name : 1;
kono
parents: 67
diff changeset
496 /* Specify whether the section was set by user or by
kono
parents: 67
diff changeset
497 compiler via -ffunction-sections. */
kono
parents: 67
diff changeset
498 unsigned implicit_section : 1;
kono
parents: 67
diff changeset
499 /* True when body and other characteristics have been removed by
kono
parents: 67
diff changeset
500 symtab_remove_unreachable_nodes. */
kono
parents: 67
diff changeset
501 unsigned body_removed : 1;
kono
parents: 67
diff changeset
502
kono
parents: 67
diff changeset
503 /*** WHOPR Partitioning flags.
kono
parents: 67
diff changeset
504 These flags are used at ltrans stage when only part of the callgraph is
kono
parents: 67
diff changeset
505 available. ***/
kono
parents: 67
diff changeset
506
kono
parents: 67
diff changeset
507 /* Set when variable is used from other LTRANS partition. */
kono
parents: 67
diff changeset
508 unsigned used_from_other_partition : 1;
kono
parents: 67
diff changeset
509 /* Set when function is available in the other LTRANS partition.
kono
parents: 67
diff changeset
510 During WPA output it is used to mark nodes that are present in
kono
parents: 67
diff changeset
511 multiple partitions. */
kono
parents: 67
diff changeset
512 unsigned in_other_partition : 1;
kono
parents: 67
diff changeset
513
kono
parents: 67
diff changeset
514
kono
parents: 67
diff changeset
515
kono
parents: 67
diff changeset
516 /*** other flags. ***/
kono
parents: 67
diff changeset
517
kono
parents: 67
diff changeset
518 /* Set when symbol has address taken. */
kono
parents: 67
diff changeset
519 unsigned address_taken : 1;
kono
parents: 67
diff changeset
520 /* Set when init priority is set. */
kono
parents: 67
diff changeset
521 unsigned in_init_priority_hash : 1;
kono
parents: 67
diff changeset
522
kono
parents: 67
diff changeset
523 /* Set when symbol needs to be streamed into LTO bytecode for LTO, or in case
kono
parents: 67
diff changeset
524 of offloading, for separate compilation for a different target. */
kono
parents: 67
diff changeset
525 unsigned need_lto_streaming : 1;
kono
parents: 67
diff changeset
526
kono
parents: 67
diff changeset
527 /* Set when symbol can be streamed into bytecode for offloading. */
kono
parents: 67
diff changeset
528 unsigned offloadable : 1;
kono
parents: 67
diff changeset
529
kono
parents: 67
diff changeset
530
kono
parents: 67
diff changeset
531 /* Ordering of all symtab entries. */
kono
parents: 67
diff changeset
532 int order;
kono
parents: 67
diff changeset
533
kono
parents: 67
diff changeset
534 /* Declaration representing the symbol. */
kono
parents: 67
diff changeset
535 tree decl;
kono
parents: 67
diff changeset
536
kono
parents: 67
diff changeset
537 /* Linked list of symbol table entries starting with symtab_nodes. */
kono
parents: 67
diff changeset
538 symtab_node *next;
kono
parents: 67
diff changeset
539 symtab_node *previous;
kono
parents: 67
diff changeset
540
kono
parents: 67
diff changeset
541 /* Linked list of symbols with the same asm name. There may be multiple
kono
parents: 67
diff changeset
542 entries for single symbol name during LTO, because symbols are renamed
kono
parents: 67
diff changeset
543 only after partitioning.
kono
parents: 67
diff changeset
544
kono
parents: 67
diff changeset
545 Because inline clones are kept in the assembler name has, they also produce
kono
parents: 67
diff changeset
546 duplicate entries.
kono
parents: 67
diff changeset
547
kono
parents: 67
diff changeset
548 There are also several long standing bugs where frontends and builtin
kono
parents: 67
diff changeset
549 code produce duplicated decls. */
kono
parents: 67
diff changeset
550 symtab_node *next_sharing_asm_name;
kono
parents: 67
diff changeset
551 symtab_node *previous_sharing_asm_name;
kono
parents: 67
diff changeset
552
kono
parents: 67
diff changeset
553 /* Circular list of nodes in the same comdat group if non-NULL. */
kono
parents: 67
diff changeset
554 symtab_node *same_comdat_group;
kono
parents: 67
diff changeset
555
kono
parents: 67
diff changeset
556 /* Vectors of referring and referenced entities. */
kono
parents: 67
diff changeset
557 ipa_ref_list ref_list;
kono
parents: 67
diff changeset
558
kono
parents: 67
diff changeset
559 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
kono
parents: 67
diff changeset
560 depending to what was known to frontend on the creation time.
kono
parents: 67
diff changeset
561 Once alias is resolved, this pointer become NULL. */
kono
parents: 67
diff changeset
562 tree alias_target;
kono
parents: 67
diff changeset
563
kono
parents: 67
diff changeset
564 /* File stream where this node is being written to. */
kono
parents: 67
diff changeset
565 struct lto_file_decl_data * lto_file_data;
kono
parents: 67
diff changeset
566
kono
parents: 67
diff changeset
567 PTR GTY ((skip)) aux;
kono
parents: 67
diff changeset
568
kono
parents: 67
diff changeset
569 /* Comdat group the symbol is in. Can be private if GGC allowed that. */
kono
parents: 67
diff changeset
570 tree x_comdat_group;
kono
parents: 67
diff changeset
571
kono
parents: 67
diff changeset
572 /* Section name. Again can be private, if allowed. */
kono
parents: 67
diff changeset
573 section_hash_entry *x_section;
kono
parents: 67
diff changeset
574
kono
parents: 67
diff changeset
575 protected:
kono
parents: 67
diff changeset
576 /* Dump base fields of symtab nodes to F. Not to be used directly. */
kono
parents: 67
diff changeset
577 void dump_base (FILE *);
kono
parents: 67
diff changeset
578
kono
parents: 67
diff changeset
579 /* Verify common part of symtab node. */
kono
parents: 67
diff changeset
580 bool DEBUG_FUNCTION verify_base (void);
kono
parents: 67
diff changeset
581
kono
parents: 67
diff changeset
582 /* Remove node from symbol table. This function is not used directly, but via
kono
parents: 67
diff changeset
583 cgraph/varpool node removal routines. */
kono
parents: 67
diff changeset
584 void unregister (void);
kono
parents: 67
diff changeset
585
kono
parents: 67
diff changeset
586 /* Return the initialization and finalization priority information for
kono
parents: 67
diff changeset
587 DECL. If there is no previous priority information, a freshly
kono
parents: 67
diff changeset
588 allocated structure is returned. */
kono
parents: 67
diff changeset
589 struct symbol_priority_map *priority_info (void);
kono
parents: 67
diff changeset
590
kono
parents: 67
diff changeset
591 /* Worker for call_for_symbol_and_aliases_1. */
kono
parents: 67
diff changeset
592 bool call_for_symbol_and_aliases_1 (bool (*callback) (symtab_node *, void *),
kono
parents: 67
diff changeset
593 void *data,
kono
parents: 67
diff changeset
594 bool include_overwrite);
kono
parents: 67
diff changeset
595 private:
kono
parents: 67
diff changeset
596 /* Worker for set_section. */
kono
parents: 67
diff changeset
597 static bool set_section (symtab_node *n, void *s);
kono
parents: 67
diff changeset
598
kono
parents: 67
diff changeset
599 /* Worker for symtab_resolve_alias. */
kono
parents: 67
diff changeset
600 static bool set_implicit_section (symtab_node *n, void *);
kono
parents: 67
diff changeset
601
kono
parents: 67
diff changeset
602 /* Worker searching noninterposable alias. */
kono
parents: 67
diff changeset
603 static bool noninterposable_alias (symtab_node *node, void *data);
kono
parents: 67
diff changeset
604
kono
parents: 67
diff changeset
605 /* Worker for ultimate_alias_target. */
kono
parents: 67
diff changeset
606 symtab_node *ultimate_alias_target_1 (enum availability *avail = NULL,
kono
parents: 67
diff changeset
607 symtab_node *ref = NULL);
kono
parents: 67
diff changeset
608
kono
parents: 67
diff changeset
609 /* Get dump name with normal or assembly name. */
kono
parents: 67
diff changeset
610 const char *get_dump_name (bool asm_name_p) const;
kono
parents: 67
diff changeset
611 };
kono
parents: 67
diff changeset
612
kono
parents: 67
diff changeset
613 inline void
kono
parents: 67
diff changeset
614 symtab_node::checking_verify_symtab_nodes (void)
kono
parents: 67
diff changeset
615 {
kono
parents: 67
diff changeset
616 if (flag_checking)
kono
parents: 67
diff changeset
617 symtab_node::verify_symtab_nodes ();
kono
parents: 67
diff changeset
618 }
kono
parents: 67
diff changeset
619
kono
parents: 67
diff changeset
620 /* Walk all aliases for NODE. */
kono
parents: 67
diff changeset
621 #define FOR_EACH_ALIAS(node, alias) \
kono
parents: 67
diff changeset
622 for (unsigned x_i = 0; node->iterate_direct_aliases (x_i, alias); x_i++)
kono
parents: 67
diff changeset
623
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
624 /* This is the information that is put into the cgraph local structure
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
625 to recover a function. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
626 struct lto_file_decl_data;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
627
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 extern const char * const cgraph_availability_names[];
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
629 extern const char * const ld_plugin_symbol_resolution_names[];
111
kono
parents: 67
diff changeset
630 extern const char * const tls_model_names[];
kono
parents: 67
diff changeset
631
kono
parents: 67
diff changeset
632 /* Sub-structure of cgraph_node. Holds information about thunk, used only for
kono
parents: 67
diff changeset
633 same body aliases.
kono
parents: 67
diff changeset
634
kono
parents: 67
diff changeset
635 Thunks are basically wrappers around methods which are introduced in case
kono
parents: 67
diff changeset
636 of multiple inheritance in order to adjust the value of the "this" pointer
kono
parents: 67
diff changeset
637 or of the returned value.
kono
parents: 67
diff changeset
638
kono
parents: 67
diff changeset
639 In the case of this-adjusting thunks, each back-end can override the
kono
parents: 67
diff changeset
640 can_output_mi_thunk/output_mi_thunk target hooks to generate a minimal thunk
kono
parents: 67
diff changeset
641 (with a tail call for instance) directly as assembly. For the default hook
kono
parents: 67
diff changeset
642 or for the case where the can_output_mi_thunk hooks return false, the thunk
kono
parents: 67
diff changeset
643 is gimplified and lowered using the regular machinery. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
644
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
645 struct GTY(()) cgraph_thunk_info {
111
kono
parents: 67
diff changeset
646 /* Offset used to adjust "this". */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
647 HOST_WIDE_INT fixed_offset;
111
kono
parents: 67
diff changeset
648
kono
parents: 67
diff changeset
649 /* Offset in the virtual table to get the offset to adjust "this". Valid iff
kono
parents: 67
diff changeset
650 VIRTUAL_OFFSET_P is true. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
651 HOST_WIDE_INT virtual_value;
111
kono
parents: 67
diff changeset
652
kono
parents: 67
diff changeset
653 /* Thunk target, i.e. the method that this thunk wraps. Depending on the
kono
parents: 67
diff changeset
654 TARGET_USE_LOCAL_THUNK_ALIAS_P macro, this may have to be a new alias. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
655 tree alias;
111
kono
parents: 67
diff changeset
656
kono
parents: 67
diff changeset
657 /* Nonzero for a "this" adjusting thunk and zero for a result adjusting
kono
parents: 67
diff changeset
658 thunk. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
659 bool this_adjusting;
111
kono
parents: 67
diff changeset
660
kono
parents: 67
diff changeset
661 /* If true, this thunk is what we call a virtual thunk. In this case:
kono
parents: 67
diff changeset
662 * for this-adjusting thunks, after the FIXED_OFFSET based adjustment is
kono
parents: 67
diff changeset
663 done, add to the result the offset found in the vtable at:
kono
parents: 67
diff changeset
664 vptr + VIRTUAL_VALUE
kono
parents: 67
diff changeset
665 * for result-adjusting thunks, the FIXED_OFFSET adjustment is done after
kono
parents: 67
diff changeset
666 the virtual one. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
667 bool virtual_offset_p;
111
kono
parents: 67
diff changeset
668
kono
parents: 67
diff changeset
669 /* ??? True for special kind of thunks, seems related to instrumentation. */
kono
parents: 67
diff changeset
670 bool add_pointer_bounds_args;
kono
parents: 67
diff changeset
671
kono
parents: 67
diff changeset
672 /* Set to true when alias node (the cgraph_node to which this struct belong)
kono
parents: 67
diff changeset
673 is a thunk. Access to any other fields is invalid if this is false. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
674 bool thunk_p;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
675 };
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
676
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 /* Information about the function collected locally.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 Available after function is analyzed. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
680 struct GTY(()) cgraph_local_info {
111
kono
parents: 67
diff changeset
681 /* Set when function is visible in current compilation unit only and
kono
parents: 67
diff changeset
682 its address is never taken. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 unsigned local : 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684
111
kono
parents: 67
diff changeset
685 /* False when there is something makes versioning impossible. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
686 unsigned versionable : 1;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
687
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
688 /* False when function calling convention and signature can not be changed.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
689 This is the case when __builtin_apply_args is used. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
690 unsigned can_change_signature : 1;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
691
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 /* True when the function has been originally extern inline, but it is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 redefined now. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 unsigned redefined_extern_inline : 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695
111
kono
parents: 67
diff changeset
696 /* True if the function may enter serial irrevocable mode. */
kono
parents: 67
diff changeset
697 unsigned tm_may_enter_irr : 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 /* Information about the function that needs to be computed globally
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 once compilation is finished. Available only with -funit-at-a-time. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
703 struct GTY(()) cgraph_global_info {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 /* For inline clones this points to the function they will be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 inlined into. */
111
kono
parents: 67
diff changeset
706 cgraph_node *inlined_to;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
707 };
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
708
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
709 /* Represent which DECL tree (or reference to such tree)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
710 will be replaced by another tree while versioning. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
711 struct GTY(()) ipa_replace_map
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
713 /* The tree that will be replaced. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
714 tree old_tree;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
715 /* The new (replacing) tree. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
716 tree new_tree;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
717 /* Parameter number to replace, when old_tree is NULL. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
718 int parm_num;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
719 /* True when a substitution should be done, false otherwise. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
720 bool replace_p;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
721 /* True when we replace a reference to old_tree. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
722 bool ref_p;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
723 };
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
724
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
725 struct GTY(()) cgraph_clone_info
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
726 {
111
kono
parents: 67
diff changeset
727 vec<ipa_replace_map *, va_gc> *tree_map;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
728 bitmap args_to_skip;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
729 bitmap combined_args_to_skip;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731
111
kono
parents: 67
diff changeset
732 enum cgraph_simd_clone_arg_type
kono
parents: 67
diff changeset
733 {
kono
parents: 67
diff changeset
734 SIMD_CLONE_ARG_TYPE_VECTOR,
kono
parents: 67
diff changeset
735 SIMD_CLONE_ARG_TYPE_UNIFORM,
kono
parents: 67
diff changeset
736 /* These are only for integer/pointer arguments passed by value. */
kono
parents: 67
diff changeset
737 SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
kono
parents: 67
diff changeset
738 SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
kono
parents: 67
diff changeset
739 /* These 6 are only for reference type arguments or arguments passed
kono
parents: 67
diff changeset
740 by reference. */
kono
parents: 67
diff changeset
741 SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP,
kono
parents: 67
diff changeset
742 SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP,
kono
parents: 67
diff changeset
743 SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP,
kono
parents: 67
diff changeset
744 SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP,
kono
parents: 67
diff changeset
745 SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP,
kono
parents: 67
diff changeset
746 SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP,
kono
parents: 67
diff changeset
747 SIMD_CLONE_ARG_TYPE_MASK
kono
parents: 67
diff changeset
748 };
kono
parents: 67
diff changeset
749
kono
parents: 67
diff changeset
750 /* Function arguments in the original function of a SIMD clone.
kono
parents: 67
diff changeset
751 Supplementary data for `struct simd_clone'. */
kono
parents: 67
diff changeset
752
kono
parents: 67
diff changeset
753 struct GTY(()) cgraph_simd_clone_arg {
kono
parents: 67
diff changeset
754 /* Original function argument as it originally existed in
kono
parents: 67
diff changeset
755 DECL_ARGUMENTS. */
kono
parents: 67
diff changeset
756 tree orig_arg;
kono
parents: 67
diff changeset
757
kono
parents: 67
diff changeset
758 /* orig_arg's function (or for extern functions type from
kono
parents: 67
diff changeset
759 TYPE_ARG_TYPES). */
kono
parents: 67
diff changeset
760 tree orig_type;
kono
parents: 67
diff changeset
761
kono
parents: 67
diff changeset
762 /* If argument is a vector, this holds the vector version of
kono
parents: 67
diff changeset
763 orig_arg that after adjusting the argument types will live in
kono
parents: 67
diff changeset
764 DECL_ARGUMENTS. Otherwise, this is NULL.
kono
parents: 67
diff changeset
765
kono
parents: 67
diff changeset
766 This basically holds:
kono
parents: 67
diff changeset
767 vector(simdlen) __typeof__(orig_arg) new_arg. */
kono
parents: 67
diff changeset
768 tree vector_arg;
kono
parents: 67
diff changeset
769
kono
parents: 67
diff changeset
770 /* vector_arg's type (or for extern functions new vector type. */
kono
parents: 67
diff changeset
771 tree vector_type;
kono
parents: 67
diff changeset
772
kono
parents: 67
diff changeset
773 /* If argument is a vector, this holds the array where the simd
kono
parents: 67
diff changeset
774 argument is held while executing the simd clone function. This
kono
parents: 67
diff changeset
775 is a local variable in the cloned function. Its content is
kono
parents: 67
diff changeset
776 copied from vector_arg upon entry to the clone.
kono
parents: 67
diff changeset
777
kono
parents: 67
diff changeset
778 This basically holds:
kono
parents: 67
diff changeset
779 __typeof__(orig_arg) simd_array[simdlen]. */
kono
parents: 67
diff changeset
780 tree simd_array;
kono
parents: 67
diff changeset
781
kono
parents: 67
diff changeset
782 /* A SIMD clone's argument can be either linear (constant or
kono
parents: 67
diff changeset
783 variable), uniform, or vector. */
kono
parents: 67
diff changeset
784 enum cgraph_simd_clone_arg_type arg_type;
kono
parents: 67
diff changeset
785
kono
parents: 67
diff changeset
786 /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_*CONSTANT_STEP this is
kono
parents: 67
diff changeset
787 the constant linear step, if arg_type is
kono
parents: 67
diff changeset
788 SIMD_CLONE_ARG_TYPE_LINEAR_*VARIABLE_STEP, this is index of
kono
parents: 67
diff changeset
789 the uniform argument holding the step, otherwise 0. */
kono
parents: 67
diff changeset
790 HOST_WIDE_INT linear_step;
kono
parents: 67
diff changeset
791
kono
parents: 67
diff changeset
792 /* Variable alignment if available, otherwise 0. */
kono
parents: 67
diff changeset
793 unsigned int alignment;
kono
parents: 67
diff changeset
794 };
kono
parents: 67
diff changeset
795
kono
parents: 67
diff changeset
796 /* Specific data for a SIMD function clone. */
kono
parents: 67
diff changeset
797
kono
parents: 67
diff changeset
798 struct GTY(()) cgraph_simd_clone {
kono
parents: 67
diff changeset
799 /* Number of words in the SIMD lane associated with this clone. */
kono
parents: 67
diff changeset
800 unsigned int simdlen;
kono
parents: 67
diff changeset
801
kono
parents: 67
diff changeset
802 /* Number of annotated function arguments in `args'. This is
kono
parents: 67
diff changeset
803 usually the number of named arguments in FNDECL. */
kono
parents: 67
diff changeset
804 unsigned int nargs;
kono
parents: 67
diff changeset
805
kono
parents: 67
diff changeset
806 /* Max hardware vector size in bits for integral vectors. */
kono
parents: 67
diff changeset
807 unsigned int vecsize_int;
kono
parents: 67
diff changeset
808
kono
parents: 67
diff changeset
809 /* Max hardware vector size in bits for floating point vectors. */
kono
parents: 67
diff changeset
810 unsigned int vecsize_float;
kono
parents: 67
diff changeset
811
kono
parents: 67
diff changeset
812 /* Machine mode of the mask argument(s), if they are to be passed
kono
parents: 67
diff changeset
813 as bitmasks in integer argument(s). VOIDmode if masks are passed
kono
parents: 67
diff changeset
814 as vectors of characteristic type. */
kono
parents: 67
diff changeset
815 machine_mode mask_mode;
kono
parents: 67
diff changeset
816
kono
parents: 67
diff changeset
817 /* The mangling character for a given vector size. This is used
kono
parents: 67
diff changeset
818 to determine the ISA mangling bit as specified in the Intel
kono
parents: 67
diff changeset
819 Vector ABI. */
kono
parents: 67
diff changeset
820 unsigned char vecsize_mangle;
kono
parents: 67
diff changeset
821
kono
parents: 67
diff changeset
822 /* True if this is the masked, in-branch version of the clone,
kono
parents: 67
diff changeset
823 otherwise false. */
kono
parents: 67
diff changeset
824 unsigned int inbranch : 1;
kono
parents: 67
diff changeset
825
kono
parents: 67
diff changeset
826 /* True if this is a Cilk Plus variant. */
kono
parents: 67
diff changeset
827 unsigned int cilk_elemental : 1;
kono
parents: 67
diff changeset
828
kono
parents: 67
diff changeset
829 /* Doubly linked list of SIMD clones. */
kono
parents: 67
diff changeset
830 cgraph_node *prev_clone, *next_clone;
kono
parents: 67
diff changeset
831
kono
parents: 67
diff changeset
832 /* Original cgraph node the SIMD clones were created for. */
kono
parents: 67
diff changeset
833 cgraph_node *origin;
kono
parents: 67
diff changeset
834
kono
parents: 67
diff changeset
835 /* Annotated function arguments for the original function. */
kono
parents: 67
diff changeset
836 cgraph_simd_clone_arg GTY((length ("%h.nargs"))) args[1];
kono
parents: 67
diff changeset
837 };
kono
parents: 67
diff changeset
838
kono
parents: 67
diff changeset
839 /* Function Multiversioning info. */
kono
parents: 67
diff changeset
840 struct GTY((for_user)) cgraph_function_version_info {
kono
parents: 67
diff changeset
841 /* The cgraph_node for which the function version info is stored. */
kono
parents: 67
diff changeset
842 cgraph_node *this_node;
kono
parents: 67
diff changeset
843 /* Chains all the semantically identical function versions. The
kono
parents: 67
diff changeset
844 first function in this chain is the version_info node of the
kono
parents: 67
diff changeset
845 default function. */
kono
parents: 67
diff changeset
846 cgraph_function_version_info *prev;
kono
parents: 67
diff changeset
847 /* If this version node corresponds to a dispatcher for function
kono
parents: 67
diff changeset
848 versions, this points to the version info node of the default
kono
parents: 67
diff changeset
849 function, the first node in the chain. */
kono
parents: 67
diff changeset
850 cgraph_function_version_info *next;
kono
parents: 67
diff changeset
851 /* If this node corresponds to a function version, this points
kono
parents: 67
diff changeset
852 to the dispatcher function decl, which is the function that must
kono
parents: 67
diff changeset
853 be called to execute the right function version at run-time.
kono
parents: 67
diff changeset
854
kono
parents: 67
diff changeset
855 If this cgraph node is a dispatcher (if dispatcher_function is
kono
parents: 67
diff changeset
856 true, in the cgraph_node struct) for function versions, this
kono
parents: 67
diff changeset
857 points to resolver function, which holds the function body of the
kono
parents: 67
diff changeset
858 dispatcher. The dispatcher decl is an alias to the resolver
kono
parents: 67
diff changeset
859 function decl. */
kono
parents: 67
diff changeset
860 tree dispatcher_resolver;
kono
parents: 67
diff changeset
861 };
kono
parents: 67
diff changeset
862
kono
parents: 67
diff changeset
863 #define DEFCIFCODE(code, type, string) CIF_ ## code,
kono
parents: 67
diff changeset
864 /* Reasons for inlining failures. */
kono
parents: 67
diff changeset
865
kono
parents: 67
diff changeset
866 enum cgraph_inline_failed_t {
kono
parents: 67
diff changeset
867 #include "cif-code.def"
kono
parents: 67
diff changeset
868 CIF_N_REASONS
kono
parents: 67
diff changeset
869 };
kono
parents: 67
diff changeset
870
kono
parents: 67
diff changeset
871 enum cgraph_inline_failed_type_t
kono
parents: 67
diff changeset
872 {
kono
parents: 67
diff changeset
873 CIF_FINAL_NORMAL = 0,
kono
parents: 67
diff changeset
874 CIF_FINAL_ERROR
kono
parents: 67
diff changeset
875 };
kono
parents: 67
diff changeset
876
kono
parents: 67
diff changeset
877 struct cgraph_edge;
kono
parents: 67
diff changeset
878
kono
parents: 67
diff changeset
879 struct cgraph_edge_hasher : ggc_ptr_hash<cgraph_edge>
kono
parents: 67
diff changeset
880 {
kono
parents: 67
diff changeset
881 typedef gimple *compare_type;
kono
parents: 67
diff changeset
882
kono
parents: 67
diff changeset
883 static hashval_t hash (cgraph_edge *);
kono
parents: 67
diff changeset
884 static hashval_t hash (gimple *);
kono
parents: 67
diff changeset
885 static bool equal (cgraph_edge *, gimple *);
kono
parents: 67
diff changeset
886 };
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
887
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 /* The cgraph data structure.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 Each function decl has assigned cgraph_node listing callees and callers. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890
111
kono
parents: 67
diff changeset
891 struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node {
kono
parents: 67
diff changeset
892 public:
kono
parents: 67
diff changeset
893 /* Remove the node from cgraph and all inline clones inlined into it.
kono
parents: 67
diff changeset
894 Skip however removal of FORBIDDEN_NODE and return true if it needs to be
kono
parents: 67
diff changeset
895 removed. This allows to call the function from outer loop walking clone
kono
parents: 67
diff changeset
896 tree. */
kono
parents: 67
diff changeset
897 bool remove_symbol_and_inline_clones (cgraph_node *forbidden_node = NULL);
kono
parents: 67
diff changeset
898
kono
parents: 67
diff changeset
899 /* Record all references from cgraph_node that are taken
kono
parents: 67
diff changeset
900 in statement STMT. */
kono
parents: 67
diff changeset
901 void record_stmt_references (gimple *stmt);
kono
parents: 67
diff changeset
902
kono
parents: 67
diff changeset
903 /* Like cgraph_set_call_stmt but walk the clone tree and update all
kono
parents: 67
diff changeset
904 clones sharing the same function body.
kono
parents: 67
diff changeset
905 When WHOLE_SPECULATIVE_EDGES is true, all three components of
kono
parents: 67
diff changeset
906 speculative edge gets updated. Otherwise we update only direct
kono
parents: 67
diff changeset
907 call. */
kono
parents: 67
diff changeset
908 void set_call_stmt_including_clones (gimple *old_stmt, gcall *new_stmt,
kono
parents: 67
diff changeset
909 bool update_speculative = true);
kono
parents: 67
diff changeset
910
kono
parents: 67
diff changeset
911 /* Walk the alias chain to return the function cgraph_node is alias of.
kono
parents: 67
diff changeset
912 Walk through thunk, too.
kono
parents: 67
diff changeset
913 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
914 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
915 when determining the availability. */
kono
parents: 67
diff changeset
916 cgraph_node *function_symbol (enum availability *avail = NULL,
kono
parents: 67
diff changeset
917 struct symtab_node *ref = NULL);
kono
parents: 67
diff changeset
918
kono
parents: 67
diff changeset
919 /* Walk the alias chain to return the function cgraph_node is alias of.
kono
parents: 67
diff changeset
920 Walk through non virtual thunks, too. Thus we return either a function
kono
parents: 67
diff changeset
921 or a virtual thunk node.
kono
parents: 67
diff changeset
922 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
923 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
924 when determining the availability. */
kono
parents: 67
diff changeset
925 cgraph_node *function_or_virtual_thunk_symbol
kono
parents: 67
diff changeset
926 (enum availability *avail = NULL,
kono
parents: 67
diff changeset
927 struct symtab_node *ref = NULL);
kono
parents: 67
diff changeset
928
kono
parents: 67
diff changeset
929 /* Create node representing clone of N executed COUNT times. Decrease
kono
parents: 67
diff changeset
930 the execution counts from original node too.
kono
parents: 67
diff changeset
931 The new clone will have decl set to DECL that may or may not be the same
kono
parents: 67
diff changeset
932 as decl of N.
kono
parents: 67
diff changeset
933
kono
parents: 67
diff changeset
934 When UPDATE_ORIGINAL is true, the counts are subtracted from the original
kono
parents: 67
diff changeset
935 function's profile to reflect the fact that part of execution is handled
kono
parents: 67
diff changeset
936 by node.
kono
parents: 67
diff changeset
937 When CALL_DUPLICATOIN_HOOK is true, the ipa passes are acknowledged about
kono
parents: 67
diff changeset
938 the new clone. Otherwise the caller is responsible for doing so later.
kono
parents: 67
diff changeset
939
kono
parents: 67
diff changeset
940 If the new node is being inlined into another one, NEW_INLINED_TO should be
kono
parents: 67
diff changeset
941 the outline function the new one is (even indirectly) inlined to.
kono
parents: 67
diff changeset
942 All hooks will see this in node's global.inlined_to, when invoked.
kono
parents: 67
diff changeset
943 Can be NULL if the node is not inlined. SUFFIX is string that is appended
kono
parents: 67
diff changeset
944 to the original name. */
kono
parents: 67
diff changeset
945 cgraph_node *create_clone (tree decl, profile_count count, int freq,
kono
parents: 67
diff changeset
946 bool update_original,
kono
parents: 67
diff changeset
947 vec<cgraph_edge *> redirect_callers,
kono
parents: 67
diff changeset
948 bool call_duplication_hook,
kono
parents: 67
diff changeset
949 cgraph_node *new_inlined_to,
kono
parents: 67
diff changeset
950 bitmap args_to_skip, const char *suffix = NULL);
kono
parents: 67
diff changeset
951
kono
parents: 67
diff changeset
952 /* Create callgraph node clone with new declaration. The actual body will
kono
parents: 67
diff changeset
953 be copied later at compilation stage. */
kono
parents: 67
diff changeset
954 cgraph_node *create_virtual_clone (vec<cgraph_edge *> redirect_callers,
kono
parents: 67
diff changeset
955 vec<ipa_replace_map *, va_gc> *tree_map,
kono
parents: 67
diff changeset
956 bitmap args_to_skip, const char * suffix);
kono
parents: 67
diff changeset
957
kono
parents: 67
diff changeset
958 /* cgraph node being removed from symbol table; see if its entry can be
kono
parents: 67
diff changeset
959 replaced by other inline clone. */
kono
parents: 67
diff changeset
960 cgraph_node *find_replacement (void);
kono
parents: 67
diff changeset
961
kono
parents: 67
diff changeset
962 /* Create a new cgraph node which is the new version of
kono
parents: 67
diff changeset
963 callgraph node. REDIRECT_CALLERS holds the callers
kono
parents: 67
diff changeset
964 edges which should be redirected to point to
kono
parents: 67
diff changeset
965 NEW_VERSION. ALL the callees edges of the node
kono
parents: 67
diff changeset
966 are cloned to the new version node. Return the new
kono
parents: 67
diff changeset
967 version node.
kono
parents: 67
diff changeset
968
kono
parents: 67
diff changeset
969 If non-NULL BLOCK_TO_COPY determine what basic blocks
kono
parents: 67
diff changeset
970 was copied to prevent duplications of calls that are dead
kono
parents: 67
diff changeset
971 in the clone.
kono
parents: 67
diff changeset
972
kono
parents: 67
diff changeset
973 SUFFIX is string that is appended to the original name. */
kono
parents: 67
diff changeset
974
kono
parents: 67
diff changeset
975 cgraph_node *create_version_clone (tree new_decl,
kono
parents: 67
diff changeset
976 vec<cgraph_edge *> redirect_callers,
kono
parents: 67
diff changeset
977 bitmap bbs_to_copy,
kono
parents: 67
diff changeset
978 const char *suffix = NULL);
kono
parents: 67
diff changeset
979
kono
parents: 67
diff changeset
980 /* Perform function versioning.
kono
parents: 67
diff changeset
981 Function versioning includes copying of the tree and
kono
parents: 67
diff changeset
982 a callgraph update (creating a new cgraph node and updating
kono
parents: 67
diff changeset
983 its callees and callers).
kono
parents: 67
diff changeset
984
kono
parents: 67
diff changeset
985 REDIRECT_CALLERS varray includes the edges to be redirected
kono
parents: 67
diff changeset
986 to the new version.
kono
parents: 67
diff changeset
987
kono
parents: 67
diff changeset
988 TREE_MAP is a mapping of tree nodes we want to replace with
kono
parents: 67
diff changeset
989 new ones (according to results of prior analysis).
kono
parents: 67
diff changeset
990
kono
parents: 67
diff changeset
991 If non-NULL ARGS_TO_SKIP determine function parameters to remove
kono
parents: 67
diff changeset
992 from new version.
kono
parents: 67
diff changeset
993 If SKIP_RETURN is true, the new version will return void.
kono
parents: 67
diff changeset
994 If non-NULL BLOCK_TO_COPY determine what basic blocks to copy.
kono
parents: 67
diff changeset
995 If non_NULL NEW_ENTRY determine new entry BB of the clone.
kono
parents: 67
diff changeset
996
kono
parents: 67
diff changeset
997 Return the new version's cgraph node. */
kono
parents: 67
diff changeset
998 cgraph_node *create_version_clone_with_body
kono
parents: 67
diff changeset
999 (vec<cgraph_edge *> redirect_callers,
kono
parents: 67
diff changeset
1000 vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip,
kono
parents: 67
diff changeset
1001 bool skip_return, bitmap bbs_to_copy, basic_block new_entry_block,
kono
parents: 67
diff changeset
1002 const char *clone_name);
kono
parents: 67
diff changeset
1003
kono
parents: 67
diff changeset
1004 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
kono
parents: 67
diff changeset
1005 corresponding to cgraph_node. */
kono
parents: 67
diff changeset
1006 cgraph_function_version_info *insert_new_function_version (void);
kono
parents: 67
diff changeset
1007
kono
parents: 67
diff changeset
1008 /* Get the cgraph_function_version_info node corresponding to node. */
kono
parents: 67
diff changeset
1009 cgraph_function_version_info *function_version (void);
kono
parents: 67
diff changeset
1010
kono
parents: 67
diff changeset
1011 /* Discover all functions and variables that are trivially needed, analyze
kono
parents: 67
diff changeset
1012 them as well as all functions and variables referred by them */
kono
parents: 67
diff changeset
1013 void analyze (void);
kono
parents: 67
diff changeset
1014
kono
parents: 67
diff changeset
1015 /* Add thunk alias into callgraph. The alias declaration is ALIAS and it
kono
parents: 67
diff changeset
1016 aliases DECL with an adjustments made into the first parameter.
kono
parents: 67
diff changeset
1017 See comments in struct cgraph_thunk_info for detail on the parameters. */
kono
parents: 67
diff changeset
1018 cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
kono
parents: 67
diff changeset
1019 HOST_WIDE_INT fixed_offset,
kono
parents: 67
diff changeset
1020 HOST_WIDE_INT virtual_value,
kono
parents: 67
diff changeset
1021 tree virtual_offset,
kono
parents: 67
diff changeset
1022 tree real_alias);
kono
parents: 67
diff changeset
1023
kono
parents: 67
diff changeset
1024
kono
parents: 67
diff changeset
1025 /* Return node that alias is aliasing. */
kono
parents: 67
diff changeset
1026 inline cgraph_node *get_alias_target (void);
kono
parents: 67
diff changeset
1027
kono
parents: 67
diff changeset
1028 /* Given function symbol, walk the alias chain to return the function node
kono
parents: 67
diff changeset
1029 is alias of. Do not walk through thunks.
kono
parents: 67
diff changeset
1030 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
1031 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
1032 when determining the availability. */
kono
parents: 67
diff changeset
1033
kono
parents: 67
diff changeset
1034 cgraph_node *ultimate_alias_target (availability *availability = NULL,
kono
parents: 67
diff changeset
1035 symtab_node *ref = NULL);
kono
parents: 67
diff changeset
1036
kono
parents: 67
diff changeset
1037 /* Expand thunk NODE to gimple if possible.
kono
parents: 67
diff changeset
1038 When FORCE_GIMPLE_THUNK is true, gimple thunk is created and
kono
parents: 67
diff changeset
1039 no assembler is produced.
kono
parents: 67
diff changeset
1040 When OUTPUT_ASM_THUNK is true, also produce assembler for
kono
parents: 67
diff changeset
1041 thunks that are not lowered. */
kono
parents: 67
diff changeset
1042 bool expand_thunk (bool output_asm_thunks, bool force_gimple_thunk);
kono
parents: 67
diff changeset
1043
kono
parents: 67
diff changeset
1044 /* Call expand_thunk on all callers that are thunks and analyze those
kono
parents: 67
diff changeset
1045 nodes that were expanded. */
kono
parents: 67
diff changeset
1046 void expand_all_artificial_thunks ();
kono
parents: 67
diff changeset
1047
kono
parents: 67
diff changeset
1048 /* Assemble thunks and aliases associated to node. */
kono
parents: 67
diff changeset
1049 void assemble_thunks_and_aliases (void);
kono
parents: 67
diff changeset
1050
kono
parents: 67
diff changeset
1051 /* Expand function specified by node. */
kono
parents: 67
diff changeset
1052 void expand (void);
kono
parents: 67
diff changeset
1053
kono
parents: 67
diff changeset
1054 /* As an GCC extension we allow redefinition of the function. The
kono
parents: 67
diff changeset
1055 semantics when both copies of bodies differ is not well defined.
kono
parents: 67
diff changeset
1056 We replace the old body with new body so in unit at a time mode
kono
parents: 67
diff changeset
1057 we always use new body, while in normal mode we may end up with
kono
parents: 67
diff changeset
1058 old body inlined into some functions and new body expanded and
kono
parents: 67
diff changeset
1059 inlined in others. */
kono
parents: 67
diff changeset
1060 void reset (void);
kono
parents: 67
diff changeset
1061
kono
parents: 67
diff changeset
1062 /* Creates a wrapper from cgraph_node to TARGET node. Thunk is used for this
kono
parents: 67
diff changeset
1063 kind of wrapper method. */
kono
parents: 67
diff changeset
1064 void create_wrapper (cgraph_node *target);
kono
parents: 67
diff changeset
1065
kono
parents: 67
diff changeset
1066 /* Verify cgraph nodes of the cgraph node. */
kono
parents: 67
diff changeset
1067 void DEBUG_FUNCTION verify_node (void);
kono
parents: 67
diff changeset
1068
kono
parents: 67
diff changeset
1069 /* Remove function from symbol table. */
kono
parents: 67
diff changeset
1070 void remove (void);
kono
parents: 67
diff changeset
1071
kono
parents: 67
diff changeset
1072 /* Dump call graph node to file F. */
kono
parents: 67
diff changeset
1073 void dump (FILE *f);
kono
parents: 67
diff changeset
1074
kono
parents: 67
diff changeset
1075 /* Dump call graph node to stderr. */
kono
parents: 67
diff changeset
1076 void DEBUG_FUNCTION debug (void);
kono
parents: 67
diff changeset
1077
kono
parents: 67
diff changeset
1078 /* When doing LTO, read cgraph_node's body from disk if it is not already
kono
parents: 67
diff changeset
1079 present. */
kono
parents: 67
diff changeset
1080 bool get_untransformed_body (void);
kono
parents: 67
diff changeset
1081
kono
parents: 67
diff changeset
1082 /* Prepare function body. When doing LTO, read cgraph_node's body from disk
kono
parents: 67
diff changeset
1083 if it is not already present. When some IPA transformations are scheduled,
kono
parents: 67
diff changeset
1084 apply them. */
kono
parents: 67
diff changeset
1085 bool get_body (void);
kono
parents: 67
diff changeset
1086
kono
parents: 67
diff changeset
1087 /* Release memory used to represent body of function.
kono
parents: 67
diff changeset
1088 Use this only for functions that are released before being translated to
kono
parents: 67
diff changeset
1089 target code (i.e. RTL). Functions that are compiled to RTL and beyond
kono
parents: 67
diff changeset
1090 are free'd in final.c via free_after_compilation(). */
kono
parents: 67
diff changeset
1091 void release_body (bool keep_arguments = false);
kono
parents: 67
diff changeset
1092
kono
parents: 67
diff changeset
1093 /* Return the DECL_STRUCT_FUNCTION of the function. */
kono
parents: 67
diff changeset
1094 struct function *get_fun (void);
kono
parents: 67
diff changeset
1095
kono
parents: 67
diff changeset
1096 /* cgraph_node is no longer nested function; update cgraph accordingly. */
kono
parents: 67
diff changeset
1097 void unnest (void);
kono
parents: 67
diff changeset
1098
kono
parents: 67
diff changeset
1099 /* Bring cgraph node local. */
kono
parents: 67
diff changeset
1100 void make_local (void);
kono
parents: 67
diff changeset
1101
kono
parents: 67
diff changeset
1102 /* Likewise indicate that a node is having address taken. */
kono
parents: 67
diff changeset
1103 void mark_address_taken (void);
kono
parents: 67
diff changeset
1104
kono
parents: 67
diff changeset
1105 /* Set fialization priority to PRIORITY. */
kono
parents: 67
diff changeset
1106 void set_fini_priority (priority_type priority);
kono
parents: 67
diff changeset
1107
kono
parents: 67
diff changeset
1108 /* Return the finalization priority. */
kono
parents: 67
diff changeset
1109 priority_type get_fini_priority (void);
kono
parents: 67
diff changeset
1110
kono
parents: 67
diff changeset
1111 /* Create edge from a given function to CALLEE in the cgraph. */
kono
parents: 67
diff changeset
1112 cgraph_edge *create_edge (cgraph_node *callee,
kono
parents: 67
diff changeset
1113 gcall *call_stmt, profile_count count,
kono
parents: 67
diff changeset
1114 int freq);
kono
parents: 67
diff changeset
1115
kono
parents: 67
diff changeset
1116 /* Create an indirect edge with a yet-undetermined callee where the call
kono
parents: 67
diff changeset
1117 statement destination is a formal parameter of the caller with index
kono
parents: 67
diff changeset
1118 PARAM_INDEX. */
kono
parents: 67
diff changeset
1119 cgraph_edge *create_indirect_edge (gcall *call_stmt, int ecf_flags,
kono
parents: 67
diff changeset
1120 profile_count count, int freq,
kono
parents: 67
diff changeset
1121 bool compute_indirect_info = true);
kono
parents: 67
diff changeset
1122
kono
parents: 67
diff changeset
1123 /* Like cgraph_create_edge walk the clone tree and update all clones sharing
kono
parents: 67
diff changeset
1124 same function body. If clones already have edge for OLD_STMT; only
kono
parents: 67
diff changeset
1125 update the edge same way as cgraph_set_call_stmt_including_clones does. */
kono
parents: 67
diff changeset
1126 void create_edge_including_clones (cgraph_node *callee,
kono
parents: 67
diff changeset
1127 gimple *old_stmt, gcall *stmt,
kono
parents: 67
diff changeset
1128 profile_count count,
kono
parents: 67
diff changeset
1129 int freq,
kono
parents: 67
diff changeset
1130 cgraph_inline_failed_t reason);
kono
parents: 67
diff changeset
1131
kono
parents: 67
diff changeset
1132 /* Return the callgraph edge representing the GIMPLE_CALL statement
kono
parents: 67
diff changeset
1133 CALL_STMT. */
kono
parents: 67
diff changeset
1134 cgraph_edge *get_edge (gimple *call_stmt);
kono
parents: 67
diff changeset
1135
kono
parents: 67
diff changeset
1136 /* Collect all callers of cgraph_node and its aliases that are known to lead
kono
parents: 67
diff changeset
1137 to NODE (i.e. are not overwritable) and that are not thunks. */
kono
parents: 67
diff changeset
1138 vec<cgraph_edge *> collect_callers (void);
kono
parents: 67
diff changeset
1139
kono
parents: 67
diff changeset
1140 /* Remove all callers from the node. */
kono
parents: 67
diff changeset
1141 void remove_callers (void);
kono
parents: 67
diff changeset
1142
kono
parents: 67
diff changeset
1143 /* Remove all callees from the node. */
kono
parents: 67
diff changeset
1144 void remove_callees (void);
kono
parents: 67
diff changeset
1145
kono
parents: 67
diff changeset
1146 /* Return function availability. See cgraph.h for description of individual
kono
parents: 67
diff changeset
1147 return values. */
kono
parents: 67
diff changeset
1148 enum availability get_availability (symtab_node *ref = NULL);
kono
parents: 67
diff changeset
1149
kono
parents: 67
diff changeset
1150 /* Set TREE_NOTHROW on cgraph_node's decl and on aliases of the node
kono
parents: 67
diff changeset
1151 if any to NOTHROW. */
kono
parents: 67
diff changeset
1152 bool set_nothrow_flag (bool nothrow);
kono
parents: 67
diff changeset
1153
kono
parents: 67
diff changeset
1154 /* If SET_CONST is true, mark function, aliases and thunks to be ECF_CONST.
kono
parents: 67
diff changeset
1155 If SET_CONST if false, clear the flag.
kono
parents: 67
diff changeset
1156
kono
parents: 67
diff changeset
1157 When setting the flag be careful about possible interposition and
kono
parents: 67
diff changeset
1158 do not set the flag for functions that can be interposet and set pure
kono
parents: 67
diff changeset
1159 flag for functions that can bind to other definition.
kono
parents: 67
diff changeset
1160
kono
parents: 67
diff changeset
1161 Return true if any change was done. */
kono
parents: 67
diff changeset
1162
kono
parents: 67
diff changeset
1163 bool set_const_flag (bool set_const, bool looping);
kono
parents: 67
diff changeset
1164
kono
parents: 67
diff changeset
1165 /* Set DECL_PURE_P on cgraph_node's decl and on aliases of the node
kono
parents: 67
diff changeset
1166 if any to PURE.
kono
parents: 67
diff changeset
1167
kono
parents: 67
diff changeset
1168 When setting the flag, be careful about possible interposition.
kono
parents: 67
diff changeset
1169 Return true if any change was done. */
kono
parents: 67
diff changeset
1170
kono
parents: 67
diff changeset
1171 bool set_pure_flag (bool pure, bool looping);
kono
parents: 67
diff changeset
1172
kono
parents: 67
diff changeset
1173 /* Call callback on function and aliases associated to the function.
kono
parents: 67
diff changeset
1174 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
kono
parents: 67
diff changeset
1175 skipped. */
kono
parents: 67
diff changeset
1176
kono
parents: 67
diff changeset
1177 bool call_for_symbol_and_aliases (bool (*callback) (cgraph_node *,
kono
parents: 67
diff changeset
1178 void *),
kono
parents: 67
diff changeset
1179 void *data, bool include_overwritable);
kono
parents: 67
diff changeset
1180
kono
parents: 67
diff changeset
1181 /* Call callback on cgraph_node, thunks and aliases associated to NODE.
kono
parents: 67
diff changeset
1182 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
kono
parents: 67
diff changeset
1183 skipped. When EXCLUDE_VIRTUAL_THUNKS is true, virtual thunks are
kono
parents: 67
diff changeset
1184 skipped. */
kono
parents: 67
diff changeset
1185 bool call_for_symbol_thunks_and_aliases (bool (*callback) (cgraph_node *node,
kono
parents: 67
diff changeset
1186 void *data),
kono
parents: 67
diff changeset
1187 void *data,
kono
parents: 67
diff changeset
1188 bool include_overwritable,
kono
parents: 67
diff changeset
1189 bool exclude_virtual_thunks = false);
kono
parents: 67
diff changeset
1190
kono
parents: 67
diff changeset
1191 /* Likewise indicate that a node is needed, i.e. reachable via some
kono
parents: 67
diff changeset
1192 external means. */
kono
parents: 67
diff changeset
1193 inline void mark_force_output (void);
kono
parents: 67
diff changeset
1194
kono
parents: 67
diff changeset
1195 /* Return true when function can be marked local. */
kono
parents: 67
diff changeset
1196 bool local_p (void);
kono
parents: 67
diff changeset
1197
kono
parents: 67
diff changeset
1198 /* Return true if cgraph_node can be made local for API change.
kono
parents: 67
diff changeset
1199 Extern inline functions and C++ COMDAT functions can be made local
kono
parents: 67
diff changeset
1200 at the expense of possible code size growth if function is used in multiple
kono
parents: 67
diff changeset
1201 compilation units. */
kono
parents: 67
diff changeset
1202 bool can_be_local_p (void);
kono
parents: 67
diff changeset
1203
kono
parents: 67
diff changeset
1204 /* Return true when cgraph_node can not return or throw and thus
kono
parents: 67
diff changeset
1205 it is safe to ignore its side effects for IPA analysis. */
kono
parents: 67
diff changeset
1206 bool cannot_return_p (void);
kono
parents: 67
diff changeset
1207
kono
parents: 67
diff changeset
1208 /* Return true when function cgraph_node and all its aliases are only called
kono
parents: 67
diff changeset
1209 directly.
kono
parents: 67
diff changeset
1210 i.e. it is not externally visible, address was not taken and
kono
parents: 67
diff changeset
1211 it is not used in any other non-standard way. */
kono
parents: 67
diff changeset
1212 bool only_called_directly_p (void);
kono
parents: 67
diff changeset
1213
kono
parents: 67
diff changeset
1214 /* Return true when function is only called directly or it has alias.
kono
parents: 67
diff changeset
1215 i.e. it is not externally visible, address was not taken and
kono
parents: 67
diff changeset
1216 it is not used in any other non-standard way. */
kono
parents: 67
diff changeset
1217 inline bool only_called_directly_or_aliased_p (void);
kono
parents: 67
diff changeset
1218
kono
parents: 67
diff changeset
1219 /* Return true when function cgraph_node can be expected to be removed
kono
parents: 67
diff changeset
1220 from program when direct calls in this compilation unit are removed.
kono
parents: 67
diff changeset
1221
kono
parents: 67
diff changeset
1222 As a special case COMDAT functions are
kono
parents: 67
diff changeset
1223 cgraph_can_remove_if_no_direct_calls_p while the are not
kono
parents: 67
diff changeset
1224 cgraph_only_called_directly_p (it is possible they are called from other
kono
parents: 67
diff changeset
1225 unit)
kono
parents: 67
diff changeset
1226
kono
parents: 67
diff changeset
1227 This function behaves as cgraph_only_called_directly_p because eliminating
kono
parents: 67
diff changeset
1228 all uses of COMDAT function does not make it necessarily disappear from
kono
parents: 67
diff changeset
1229 the program unless we are compiling whole program or we do LTO. In this
kono
parents: 67
diff changeset
1230 case we know we win since dynamic linking will not really discard the
kono
parents: 67
diff changeset
1231 linkonce section.
kono
parents: 67
diff changeset
1232
kono
parents: 67
diff changeset
1233 If WILL_INLINE is true, assume that function will be inlined into all the
kono
parents: 67
diff changeset
1234 direct calls. */
kono
parents: 67
diff changeset
1235 bool will_be_removed_from_program_if_no_direct_calls_p
kono
parents: 67
diff changeset
1236 (bool will_inline = false);
kono
parents: 67
diff changeset
1237
kono
parents: 67
diff changeset
1238 /* Return true when function can be removed from callgraph
kono
parents: 67
diff changeset
1239 if all direct calls and references are eliminated. The function does
kono
parents: 67
diff changeset
1240 not take into account comdat groups. */
kono
parents: 67
diff changeset
1241 bool can_remove_if_no_direct_calls_and_refs_p (void);
kono
parents: 67
diff changeset
1242
kono
parents: 67
diff changeset
1243 /* Return true when function cgraph_node and its aliases can be removed from
kono
parents: 67
diff changeset
1244 callgraph if all direct calls are eliminated.
kono
parents: 67
diff changeset
1245 If WILL_INLINE is true, assume that function will be inlined into all the
kono
parents: 67
diff changeset
1246 direct calls. */
kono
parents: 67
diff changeset
1247 bool can_remove_if_no_direct_calls_p (bool will_inline = false);
kono
parents: 67
diff changeset
1248
kono
parents: 67
diff changeset
1249 /* Return true when callgraph node is a function with Gimple body defined
kono
parents: 67
diff changeset
1250 in current unit. Functions can also be define externally or they
kono
parents: 67
diff changeset
1251 can be thunks with no Gimple representation.
kono
parents: 67
diff changeset
1252
kono
parents: 67
diff changeset
1253 Note that at WPA stage, the function body may not be present in memory. */
kono
parents: 67
diff changeset
1254 inline bool has_gimple_body_p (void);
kono
parents: 67
diff changeset
1255
kono
parents: 67
diff changeset
1256 /* Return true if function should be optimized for size. */
kono
parents: 67
diff changeset
1257 bool optimize_for_size_p (void);
kono
parents: 67
diff changeset
1258
kono
parents: 67
diff changeset
1259 /* Dump the callgraph to file F. */
kono
parents: 67
diff changeset
1260 static void dump_cgraph (FILE *f);
kono
parents: 67
diff changeset
1261
kono
parents: 67
diff changeset
1262 /* Dump the call graph to stderr. */
kono
parents: 67
diff changeset
1263 static inline
kono
parents: 67
diff changeset
1264 void debug_cgraph (void)
kono
parents: 67
diff changeset
1265 {
kono
parents: 67
diff changeset
1266 dump_cgraph (stderr);
kono
parents: 67
diff changeset
1267 }
kono
parents: 67
diff changeset
1268
kono
parents: 67
diff changeset
1269 /* Record that DECL1 and DECL2 are semantically identical function
kono
parents: 67
diff changeset
1270 versions. */
kono
parents: 67
diff changeset
1271 static void record_function_versions (tree decl1, tree decl2);
kono
parents: 67
diff changeset
1272
kono
parents: 67
diff changeset
1273 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
kono
parents: 67
diff changeset
1274 DECL is a duplicate declaration. */
kono
parents: 67
diff changeset
1275 static void delete_function_version_by_decl (tree decl);
kono
parents: 67
diff changeset
1276
kono
parents: 67
diff changeset
1277 /* Add the function FNDECL to the call graph.
kono
parents: 67
diff changeset
1278 Unlike finalize_function, this function is intended to be used
kono
parents: 67
diff changeset
1279 by middle end and allows insertion of new function at arbitrary point
kono
parents: 67
diff changeset
1280 of compilation. The function can be either in high, low or SSA form
kono
parents: 67
diff changeset
1281 GIMPLE.
kono
parents: 67
diff changeset
1282
kono
parents: 67
diff changeset
1283 The function is assumed to be reachable and have address taken (so no
kono
parents: 67
diff changeset
1284 API breaking optimizations are performed on it).
kono
parents: 67
diff changeset
1285
kono
parents: 67
diff changeset
1286 Main work done by this function is to enqueue the function for later
kono
parents: 67
diff changeset
1287 processing to avoid need the passes to be re-entrant. */
kono
parents: 67
diff changeset
1288 static void add_new_function (tree fndecl, bool lowered);
kono
parents: 67
diff changeset
1289
kono
parents: 67
diff changeset
1290 /* Return callgraph node for given symbol and check it is a function. */
kono
parents: 67
diff changeset
1291 static inline cgraph_node *get (const_tree decl)
kono
parents: 67
diff changeset
1292 {
kono
parents: 67
diff changeset
1293 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
kono
parents: 67
diff changeset
1294 return dyn_cast <cgraph_node *> (symtab_node::get (decl));
kono
parents: 67
diff changeset
1295 }
kono
parents: 67
diff changeset
1296
kono
parents: 67
diff changeset
1297 /* DECL has been parsed. Take it, queue it, compile it at the whim of the
kono
parents: 67
diff changeset
1298 logic in effect. If NO_COLLECT is true, then our caller cannot stand to
kono
parents: 67
diff changeset
1299 have the garbage collector run at the moment. We would need to either
kono
parents: 67
diff changeset
1300 create a new GC context, or just not compile right now. */
kono
parents: 67
diff changeset
1301 static void finalize_function (tree, bool);
kono
parents: 67
diff changeset
1302
kono
parents: 67
diff changeset
1303 /* Return cgraph node assigned to DECL. Create new one when needed. */
kono
parents: 67
diff changeset
1304 static cgraph_node * create (tree decl);
kono
parents: 67
diff changeset
1305
kono
parents: 67
diff changeset
1306 /* Try to find a call graph node for declaration DECL and if it does not
kono
parents: 67
diff changeset
1307 exist or if it corresponds to an inline clone, create a new one. */
kono
parents: 67
diff changeset
1308 static cgraph_node * get_create (tree);
kono
parents: 67
diff changeset
1309
kono
parents: 67
diff changeset
1310 /* Return local info for the compiled function. */
kono
parents: 67
diff changeset
1311 static cgraph_local_info *local_info (tree decl);
kono
parents: 67
diff changeset
1312
kono
parents: 67
diff changeset
1313 /* Return local info for the compiled function. */
kono
parents: 67
diff changeset
1314 static struct cgraph_rtl_info *rtl_info (tree);
kono
parents: 67
diff changeset
1315
kono
parents: 67
diff changeset
1316 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
kono
parents: 67
diff changeset
1317 Return NULL if there's no such node. */
kono
parents: 67
diff changeset
1318 static cgraph_node *get_for_asmname (tree asmname);
kono
parents: 67
diff changeset
1319
kono
parents: 67
diff changeset
1320 /* Attempt to mark ALIAS as an alias to DECL. Return alias node if
kono
parents: 67
diff changeset
1321 successful and NULL otherwise.
kono
parents: 67
diff changeset
1322 Same body aliases are output whenever the body of DECL is output,
kono
parents: 67
diff changeset
1323 and cgraph_node::get (ALIAS) transparently
kono
parents: 67
diff changeset
1324 returns cgraph_node::get (DECL). */
kono
parents: 67
diff changeset
1325 static cgraph_node * create_same_body_alias (tree alias, tree decl);
kono
parents: 67
diff changeset
1326
kono
parents: 67
diff changeset
1327 /* Verify whole cgraph structure. */
kono
parents: 67
diff changeset
1328 static void DEBUG_FUNCTION verify_cgraph_nodes (void);
kono
parents: 67
diff changeset
1329
kono
parents: 67
diff changeset
1330 /* Verify cgraph, if consistency checking is enabled. */
kono
parents: 67
diff changeset
1331 static inline void checking_verify_cgraph_nodes (void);
kono
parents: 67
diff changeset
1332
kono
parents: 67
diff changeset
1333 /* Worker to bring NODE local. */
kono
parents: 67
diff changeset
1334 static bool make_local (cgraph_node *node, void *);
kono
parents: 67
diff changeset
1335
kono
parents: 67
diff changeset
1336 /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing
kono
parents: 67
diff changeset
1337 the function body is associated
kono
parents: 67
diff changeset
1338 with (not necessarily cgraph_node (DECL). */
kono
parents: 67
diff changeset
1339 static cgraph_node *create_alias (tree alias, tree target);
kono
parents: 67
diff changeset
1340
kono
parents: 67
diff changeset
1341 /* Return true if NODE has thunk. */
kono
parents: 67
diff changeset
1342 static bool has_thunk_p (cgraph_node *node, void *);
kono
parents: 67
diff changeset
1343
kono
parents: 67
diff changeset
1344 cgraph_edge *callees;
kono
parents: 67
diff changeset
1345 cgraph_edge *callers;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1346 /* List of edges representing indirect calls with a yet undetermined
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1347 callee. */
111
kono
parents: 67
diff changeset
1348 cgraph_edge *indirect_calls;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1349 /* For nested functions points to function the node is nested in. */
111
kono
parents: 67
diff changeset
1350 cgraph_node *origin;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351 /* Points to first nested function, if any. */
111
kono
parents: 67
diff changeset
1352 cgraph_node *nested;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1353 /* Pointer to the next function with same origin, if any. */
111
kono
parents: 67
diff changeset
1354 cgraph_node *next_nested;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1355 /* Pointer to the next clone. */
111
kono
parents: 67
diff changeset
1356 cgraph_node *next_sibling_clone;
kono
parents: 67
diff changeset
1357 cgraph_node *prev_sibling_clone;
kono
parents: 67
diff changeset
1358 cgraph_node *clones;
kono
parents: 67
diff changeset
1359 cgraph_node *clone_of;
kono
parents: 67
diff changeset
1360 /* If instrumentation_clone is 1 then instrumented_version points
kono
parents: 67
diff changeset
1361 to the original function used to make instrumented version.
kono
parents: 67
diff changeset
1362 Otherwise points to instrumented version of the function. */
kono
parents: 67
diff changeset
1363 cgraph_node *instrumented_version;
kono
parents: 67
diff changeset
1364 /* If instrumentation_clone is 1 then orig_decl is the original
kono
parents: 67
diff changeset
1365 function declaration. */
kono
parents: 67
diff changeset
1366 tree orig_decl;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1367 /* For functions with many calls sites it holds map from call expression
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1368 to the edge to speed up cgraph_edge function. */
111
kono
parents: 67
diff changeset
1369 hash_table<cgraph_edge_hasher> *GTY(()) call_site_hash;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1370 /* Declaration node used to be clone of. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1371 tree former_clone_of;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1372
111
kono
parents: 67
diff changeset
1373 /* If this is a SIMD clone, this points to the SIMD specific
kono
parents: 67
diff changeset
1374 information for it. */
kono
parents: 67
diff changeset
1375 cgraph_simd_clone *simdclone;
kono
parents: 67
diff changeset
1376 /* If this function has SIMD clones, this points to the first clone. */
kono
parents: 67
diff changeset
1377 cgraph_node *simd_clones;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1378
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1379 /* Interprocedural passes scheduled to have their transform functions
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1380 applied next time we execute local pass on them. We maintain it
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1381 per-function in order to allow IPA passes to introduce new functions. */
111
kono
parents: 67
diff changeset
1382 vec<ipa_opt_pass> GTY((skip)) ipa_transforms_to_apply;
kono
parents: 67
diff changeset
1383
kono
parents: 67
diff changeset
1384 cgraph_local_info local;
kono
parents: 67
diff changeset
1385 cgraph_global_info global;
kono
parents: 67
diff changeset
1386 struct cgraph_rtl_info *rtl;
kono
parents: 67
diff changeset
1387 cgraph_clone_info clone;
kono
parents: 67
diff changeset
1388 cgraph_thunk_info thunk;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1390 /* Expected number of executions: calculated in profile.c. */
111
kono
parents: 67
diff changeset
1391 profile_count count;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1392 /* How to scale counts at materialization time; used to merge
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1393 LTO units with different number of profile runs. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1394 int count_materialization_scale;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1395 /* Unique id of the node. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1396 int uid;
111
kono
parents: 67
diff changeset
1397 /* Summary unique id of the node. */
kono
parents: 67
diff changeset
1398 int summary_uid;
kono
parents: 67
diff changeset
1399 /* ID assigned by the profiling. */
kono
parents: 67
diff changeset
1400 unsigned int profile_id;
kono
parents: 67
diff changeset
1401 /* Time profiler: first run of function. */
kono
parents: 67
diff changeset
1402 int tp_first_run;
kono
parents: 67
diff changeset
1403
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1404 /* Set when decl is an abstract function pointed to by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405 ABSTRACT_DECL_ORIGIN of a reachable function. */
111
kono
parents: 67
diff changeset
1406 unsigned used_as_abstract_origin : 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1407 /* Set once the function is lowered (i.e. its CFG is built). */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1408 unsigned lowered : 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1409 /* Set once the function has been instantiated and its callee
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1410 lists created. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1411 unsigned process : 1;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1412 /* How commonly executed the node is. Initialized during branch
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1413 probabilities pass. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1414 ENUM_BITFIELD (node_frequency) frequency : 2;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1415 /* True when function can only be called at startup (from static ctor). */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1416 unsigned only_called_at_startup : 1;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1417 /* True when function can only be called at startup (from static dtor). */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1418 unsigned only_called_at_exit : 1;
111
kono
parents: 67
diff changeset
1419 /* True when function is the transactional clone of a function which
kono
parents: 67
diff changeset
1420 is called only from inside transactions. */
kono
parents: 67
diff changeset
1421 /* ?? We should be able to remove this. We have enough bits in
kono
parents: 67
diff changeset
1422 cgraph to calculate it. */
kono
parents: 67
diff changeset
1423 unsigned tm_clone : 1;
kono
parents: 67
diff changeset
1424 /* True if this decl is a dispatcher for function versions. */
kono
parents: 67
diff changeset
1425 unsigned dispatcher_function : 1;
kono
parents: 67
diff changeset
1426 /* True if this decl calls a COMDAT-local function. This is set up in
kono
parents: 67
diff changeset
1427 compute_fn_summary and inline_call. */
kono
parents: 67
diff changeset
1428 unsigned calls_comdat_local : 1;
kono
parents: 67
diff changeset
1429 /* True if node has been created by merge operation in IPA-ICF. */
kono
parents: 67
diff changeset
1430 unsigned icf_merged: 1;
kono
parents: 67
diff changeset
1431 /* True when function is clone created for Pointer Bounds Checker
kono
parents: 67
diff changeset
1432 instrumentation. */
kono
parents: 67
diff changeset
1433 unsigned instrumentation_clone : 1;
kono
parents: 67
diff changeset
1434 /* True if call to node can't result in a call to free, munmap or
kono
parents: 67
diff changeset
1435 other operation that could make previously non-trapping memory
kono
parents: 67
diff changeset
1436 accesses trapping. */
kono
parents: 67
diff changeset
1437 unsigned nonfreeing_fn : 1;
kono
parents: 67
diff changeset
1438 /* True if there was multiple COMDAT bodies merged by lto-symtab. */
kono
parents: 67
diff changeset
1439 unsigned merged_comdat : 1;
kono
parents: 67
diff changeset
1440 /* True if function was created to be executed in parallel. */
kono
parents: 67
diff changeset
1441 unsigned parallelized_function : 1;
kono
parents: 67
diff changeset
1442 /* True if function is part split out by ipa-split. */
kono
parents: 67
diff changeset
1443 unsigned split_part : 1;
kono
parents: 67
diff changeset
1444 /* True if the function appears as possible target of indirect call. */
kono
parents: 67
diff changeset
1445 unsigned indirect_call_target : 1;
kono
parents: 67
diff changeset
1446
kono
parents: 67
diff changeset
1447 private:
kono
parents: 67
diff changeset
1448 /* Worker for call_for_symbol_and_aliases. */
kono
parents: 67
diff changeset
1449 bool call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *,
kono
parents: 67
diff changeset
1450 void *),
kono
parents: 67
diff changeset
1451 void *data, bool include_overwritable);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1452 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1453
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1454 /* A cgraph node set is a collection of cgraph nodes. A cgraph node
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1455 can appear in multiple sets. */
111
kono
parents: 67
diff changeset
1456 struct cgraph_node_set_def
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1457 {
111
kono
parents: 67
diff changeset
1458 hash_map<cgraph_node *, size_t> *map;
kono
parents: 67
diff changeset
1459 vec<cgraph_node *> nodes;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1460 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1461
111
kono
parents: 67
diff changeset
1462 typedef cgraph_node_set_def *cgraph_node_set;
kono
parents: 67
diff changeset
1463 typedef struct varpool_node_set_def *varpool_node_set;
kono
parents: 67
diff changeset
1464
kono
parents: 67
diff changeset
1465 class varpool_node;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1466
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1467 /* A varpool node set is a collection of varpool nodes. A varpool node
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1468 can appear in multiple sets. */
111
kono
parents: 67
diff changeset
1469 struct varpool_node_set_def
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1470 {
111
kono
parents: 67
diff changeset
1471 hash_map<varpool_node *, size_t> * map;
kono
parents: 67
diff changeset
1472 vec<varpool_node *> nodes;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1473 };
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1474
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1475 /* Iterator structure for cgraph node sets. */
111
kono
parents: 67
diff changeset
1476 struct cgraph_node_set_iterator
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1477 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1478 cgraph_node_set set;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1479 unsigned index;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1480 };
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1481
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1482 /* Iterator structure for varpool node sets. */
111
kono
parents: 67
diff changeset
1483 struct varpool_node_set_iterator
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1484 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1485 varpool_node_set set;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1486 unsigned index;
111
kono
parents: 67
diff changeset
1487 };
kono
parents: 67
diff changeset
1488
kono
parents: 67
diff changeset
1489 /* Context of polymorphic call. It represent information about the type of
kono
parents: 67
diff changeset
1490 instance that may reach the call. This is used by ipa-devirt walkers of the
kono
parents: 67
diff changeset
1491 type inheritance graph. */
kono
parents: 67
diff changeset
1492
kono
parents: 67
diff changeset
1493 class GTY(()) ipa_polymorphic_call_context {
kono
parents: 67
diff changeset
1494 public:
kono
parents: 67
diff changeset
1495 /* The called object appears in an object of type OUTER_TYPE
kono
parents: 67
diff changeset
1496 at offset OFFSET. When information is not 100% reliable, we
kono
parents: 67
diff changeset
1497 use SPECULATIVE_OUTER_TYPE and SPECULATIVE_OFFSET. */
kono
parents: 67
diff changeset
1498 HOST_WIDE_INT offset;
kono
parents: 67
diff changeset
1499 HOST_WIDE_INT speculative_offset;
kono
parents: 67
diff changeset
1500 tree outer_type;
kono
parents: 67
diff changeset
1501 tree speculative_outer_type;
kono
parents: 67
diff changeset
1502 /* True if outer object may be in construction or destruction. */
kono
parents: 67
diff changeset
1503 unsigned maybe_in_construction : 1;
kono
parents: 67
diff changeset
1504 /* True if outer object may be of derived type. */
kono
parents: 67
diff changeset
1505 unsigned maybe_derived_type : 1;
kono
parents: 67
diff changeset
1506 /* True if speculative outer object may be of derived type. We always
kono
parents: 67
diff changeset
1507 speculate that construction does not happen. */
kono
parents: 67
diff changeset
1508 unsigned speculative_maybe_derived_type : 1;
kono
parents: 67
diff changeset
1509 /* True if the context is invalid and all calls should be redirected
kono
parents: 67
diff changeset
1510 to BUILTIN_UNREACHABLE. */
kono
parents: 67
diff changeset
1511 unsigned invalid : 1;
kono
parents: 67
diff changeset
1512 /* True if the outer type is dynamic. */
kono
parents: 67
diff changeset
1513 unsigned dynamic : 1;
kono
parents: 67
diff changeset
1514
kono
parents: 67
diff changeset
1515 /* Build empty "I know nothing" context. */
kono
parents: 67
diff changeset
1516 ipa_polymorphic_call_context ();
kono
parents: 67
diff changeset
1517 /* Build polymorphic call context for indirect call E. */
kono
parents: 67
diff changeset
1518 ipa_polymorphic_call_context (cgraph_edge *e);
kono
parents: 67
diff changeset
1519 /* Build polymorphic call context for IP invariant CST.
kono
parents: 67
diff changeset
1520 If specified, OTR_TYPE specify the type of polymorphic call
kono
parents: 67
diff changeset
1521 that takes CST+OFFSET as a prameter. */
kono
parents: 67
diff changeset
1522 ipa_polymorphic_call_context (tree cst, tree otr_type = NULL,
kono
parents: 67
diff changeset
1523 HOST_WIDE_INT offset = 0);
kono
parents: 67
diff changeset
1524 /* Build context for pointer REF contained in FNDECL at statement STMT.
kono
parents: 67
diff changeset
1525 if INSTANCE is non-NULL, return pointer to the object described by
kono
parents: 67
diff changeset
1526 the context. */
kono
parents: 67
diff changeset
1527 ipa_polymorphic_call_context (tree fndecl, tree ref, gimple *stmt,
kono
parents: 67
diff changeset
1528 tree *instance = NULL);
kono
parents: 67
diff changeset
1529
kono
parents: 67
diff changeset
1530 /* Look for vtable stores or constructor calls to work out dynamic type
kono
parents: 67
diff changeset
1531 of memory location. */
kono
parents: 67
diff changeset
1532 bool get_dynamic_type (tree, tree, tree, gimple *);
kono
parents: 67
diff changeset
1533
kono
parents: 67
diff changeset
1534 /* Make context non-speculative. */
kono
parents: 67
diff changeset
1535 void clear_speculation ();
kono
parents: 67
diff changeset
1536
kono
parents: 67
diff changeset
1537 /* Produce context specifying all derrived types of OTR_TYPE. If OTR_TYPE is
kono
parents: 67
diff changeset
1538 NULL, the context is set to dummy "I know nothing" setting. */
kono
parents: 67
diff changeset
1539 void clear_outer_type (tree otr_type = NULL);
kono
parents: 67
diff changeset
1540
kono
parents: 67
diff changeset
1541 /* Walk container types and modify context to point to actual class
kono
parents: 67
diff changeset
1542 containing OTR_TYPE (if non-NULL) as base class.
kono
parents: 67
diff changeset
1543 Return true if resulting context is valid.
kono
parents: 67
diff changeset
1544
kono
parents: 67
diff changeset
1545 When CONSIDER_PLACEMENT_NEW is false, reject contexts that may be made
kono
parents: 67
diff changeset
1546 valid only via allocation of new polymorphic type inside by means
kono
parents: 67
diff changeset
1547 of placement new.
kono
parents: 67
diff changeset
1548
kono
parents: 67
diff changeset
1549 When CONSIDER_BASES is false, only look for actual fields, not base types
kono
parents: 67
diff changeset
1550 of TYPE. */
kono
parents: 67
diff changeset
1551 bool restrict_to_inner_class (tree otr_type,
kono
parents: 67
diff changeset
1552 bool consider_placement_new = true,
kono
parents: 67
diff changeset
1553 bool consider_bases = true);
kono
parents: 67
diff changeset
1554
kono
parents: 67
diff changeset
1555 /* Adjust all offsets in contexts by given number of bits. */
kono
parents: 67
diff changeset
1556 void offset_by (HOST_WIDE_INT);
kono
parents: 67
diff changeset
1557 /* Use when we can not track dynamic type change. This speculatively assume
kono
parents: 67
diff changeset
1558 type change is not happening. */
kono
parents: 67
diff changeset
1559 void possible_dynamic_type_change (bool, tree otr_type = NULL);
kono
parents: 67
diff changeset
1560 /* Assume that both THIS and a given context is valid and strenghten THIS
kono
parents: 67
diff changeset
1561 if possible. Return true if any strenghtening was made.
kono
parents: 67
diff changeset
1562 If actual type the context is being used in is known, OTR_TYPE should be
kono
parents: 67
diff changeset
1563 set accordingly. This improves quality of combined result. */
kono
parents: 67
diff changeset
1564 bool combine_with (ipa_polymorphic_call_context, tree otr_type = NULL);
kono
parents: 67
diff changeset
1565 bool meet_with (ipa_polymorphic_call_context, tree otr_type = NULL);
kono
parents: 67
diff changeset
1566
kono
parents: 67
diff changeset
1567 /* Return TRUE if context is fully useless. */
kono
parents: 67
diff changeset
1568 bool useless_p () const;
kono
parents: 67
diff changeset
1569 /* Return TRUE if this context conveys the same information as X. */
kono
parents: 67
diff changeset
1570 bool equal_to (const ipa_polymorphic_call_context &x) const;
kono
parents: 67
diff changeset
1571
kono
parents: 67
diff changeset
1572 /* Dump human readable context to F. If NEWLINE is true, it will be
kono
parents: 67
diff changeset
1573 terminated by a newline. */
kono
parents: 67
diff changeset
1574 void dump (FILE *f, bool newline = true) const;
kono
parents: 67
diff changeset
1575 void DEBUG_FUNCTION debug () const;
kono
parents: 67
diff changeset
1576
kono
parents: 67
diff changeset
1577 /* LTO streaming. */
kono
parents: 67
diff changeset
1578 void stream_out (struct output_block *) const;
kono
parents: 67
diff changeset
1579 void stream_in (struct lto_input_block *, struct data_in *data_in);
kono
parents: 67
diff changeset
1580
kono
parents: 67
diff changeset
1581 private:
kono
parents: 67
diff changeset
1582 bool combine_speculation_with (tree, HOST_WIDE_INT, bool, tree);
kono
parents: 67
diff changeset
1583 bool meet_speculation_with (tree, HOST_WIDE_INT, bool, tree);
kono
parents: 67
diff changeset
1584 void set_by_decl (tree, HOST_WIDE_INT);
kono
parents: 67
diff changeset
1585 bool set_by_invariant (tree, tree, HOST_WIDE_INT);
kono
parents: 67
diff changeset
1586 bool speculation_consistent_p (tree, HOST_WIDE_INT, bool, tree) const;
kono
parents: 67
diff changeset
1587 void make_speculative (tree otr_type = NULL);
kono
parents: 67
diff changeset
1588 };
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1589
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1590 /* Structure containing additional information about an indirect call. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1591
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1592 struct GTY(()) cgraph_indirect_call_info
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1593 {
111
kono
parents: 67
diff changeset
1594 /* When agg_content is set, an offset where the call pointer is located
kono
parents: 67
diff changeset
1595 within the aggregate. */
kono
parents: 67
diff changeset
1596 HOST_WIDE_INT offset;
kono
parents: 67
diff changeset
1597 /* Context of the polymorphic call; use only when POLYMORPHIC flag is set. */
kono
parents: 67
diff changeset
1598 ipa_polymorphic_call_context context;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1599 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1600 HOST_WIDE_INT otr_token;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1601 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1602 tree otr_type;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1603 /* Index of the parameter that is called. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1604 int param_index;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1605 /* ECF flags determined from the caller. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1606 int ecf_flags;
111
kono
parents: 67
diff changeset
1607 /* Profile_id of common target obtrained from profile. */
kono
parents: 67
diff changeset
1608 int common_target_id;
kono
parents: 67
diff changeset
1609 /* Probability that call will land in function with COMMON_TARGET_ID. */
kono
parents: 67
diff changeset
1610 int common_target_probability;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1611
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1612 /* Set when the call is a virtual call with the parameter being the
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1613 associated object pointer rather than a simple direct call. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1614 unsigned polymorphic : 1;
111
kono
parents: 67
diff changeset
1615 /* Set when the call is a call of a pointer loaded from contents of an
kono
parents: 67
diff changeset
1616 aggregate at offset. */
kono
parents: 67
diff changeset
1617 unsigned agg_contents : 1;
kono
parents: 67
diff changeset
1618 /* Set when this is a call through a member pointer. */
kono
parents: 67
diff changeset
1619 unsigned member_ptr : 1;
kono
parents: 67
diff changeset
1620 /* When the agg_contents bit is set, this one determines whether the
kono
parents: 67
diff changeset
1621 destination is loaded from a parameter passed by reference. */
kono
parents: 67
diff changeset
1622 unsigned by_ref : 1;
kono
parents: 67
diff changeset
1623 /* When the agg_contents bit is set, this one determines whether we can
kono
parents: 67
diff changeset
1624 deduce from the function body that the loaded value from the reference is
kono
parents: 67
diff changeset
1625 never modified between the invocation of the function and the load
kono
parents: 67
diff changeset
1626 point. */
kono
parents: 67
diff changeset
1627 unsigned guaranteed_unmodified : 1;
kono
parents: 67
diff changeset
1628 /* For polymorphic calls this specify whether the virtual table pointer
kono
parents: 67
diff changeset
1629 may have changed in between function entry and the call. */
kono
parents: 67
diff changeset
1630 unsigned vptr_changed : 1;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1631 };
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1632
111
kono
parents: 67
diff changeset
1633 struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
kono
parents: 67
diff changeset
1634 for_user)) cgraph_edge {
kono
parents: 67
diff changeset
1635 friend class cgraph_node;
kono
parents: 67
diff changeset
1636
kono
parents: 67
diff changeset
1637 /* Remove the edge in the cgraph. */
kono
parents: 67
diff changeset
1638 void remove (void);
kono
parents: 67
diff changeset
1639
kono
parents: 67
diff changeset
1640 /* Change field call_stmt of edge to NEW_STMT.
kono
parents: 67
diff changeset
1641 If UPDATE_SPECULATIVE and E is any component of speculative
kono
parents: 67
diff changeset
1642 edge, then update all components. */
kono
parents: 67
diff changeset
1643 void set_call_stmt (gcall *new_stmt, bool update_speculative = true);
kono
parents: 67
diff changeset
1644
kono
parents: 67
diff changeset
1645 /* Redirect callee of the edge to N. The function does not update underlying
kono
parents: 67
diff changeset
1646 call expression. */
kono
parents: 67
diff changeset
1647 void redirect_callee (cgraph_node *n);
kono
parents: 67
diff changeset
1648
kono
parents: 67
diff changeset
1649 /* If the edge does not lead to a thunk, simply redirect it to N. Otherwise
kono
parents: 67
diff changeset
1650 create one or more equivalent thunks for N and redirect E to the first in
kono
parents: 67
diff changeset
1651 the chain. Note that it is then necessary to call
kono
parents: 67
diff changeset
1652 n->expand_all_artificial_thunks once all callers are redirected. */
kono
parents: 67
diff changeset
1653 void redirect_callee_duplicating_thunks (cgraph_node *n);
kono
parents: 67
diff changeset
1654
kono
parents: 67
diff changeset
1655 /* Make an indirect edge with an unknown callee an ordinary edge leading to
kono
parents: 67
diff changeset
1656 CALLEE. DELTA is an integer constant that is to be added to the this
kono
parents: 67
diff changeset
1657 pointer (first parameter) to compensate for skipping
kono
parents: 67
diff changeset
1658 a thunk adjustment. */
kono
parents: 67
diff changeset
1659 cgraph_edge *make_direct (cgraph_node *callee);
kono
parents: 67
diff changeset
1660
kono
parents: 67
diff changeset
1661 /* Turn edge into speculative call calling N2. Update
kono
parents: 67
diff changeset
1662 the profile so the direct call is taken COUNT times
kono
parents: 67
diff changeset
1663 with FREQUENCY. */
kono
parents: 67
diff changeset
1664 cgraph_edge *make_speculative (cgraph_node *n2, profile_count direct_count,
kono
parents: 67
diff changeset
1665 int direct_frequency);
kono
parents: 67
diff changeset
1666
kono
parents: 67
diff changeset
1667 /* Given speculative call edge, return all three components. */
kono
parents: 67
diff changeset
1668 void speculative_call_info (cgraph_edge *&direct, cgraph_edge *&indirect,
kono
parents: 67
diff changeset
1669 ipa_ref *&reference);
kono
parents: 67
diff changeset
1670
kono
parents: 67
diff changeset
1671 /* Speculative call edge turned out to be direct call to CALLE_DECL.
kono
parents: 67
diff changeset
1672 Remove the speculative call sequence and return edge representing the call.
kono
parents: 67
diff changeset
1673 It is up to caller to redirect the call as appropriate. */
kono
parents: 67
diff changeset
1674 cgraph_edge *resolve_speculation (tree callee_decl = NULL);
kono
parents: 67
diff changeset
1675
kono
parents: 67
diff changeset
1676 /* If necessary, change the function declaration in the call statement
kono
parents: 67
diff changeset
1677 associated with the edge so that it corresponds to the edge callee. */
kono
parents: 67
diff changeset
1678 gimple *redirect_call_stmt_to_callee (void);
kono
parents: 67
diff changeset
1679
kono
parents: 67
diff changeset
1680 /* Create clone of edge in the node N represented
kono
parents: 67
diff changeset
1681 by CALL_EXPR the callgraph. */
kono
parents: 67
diff changeset
1682 cgraph_edge * clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
kono
parents: 67
diff changeset
1683 profile_count num, profile_count den, int freq_scale,
kono
parents: 67
diff changeset
1684 bool update_original);
kono
parents: 67
diff changeset
1685
kono
parents: 67
diff changeset
1686 /* Verify edge count and frequency. */
kono
parents: 67
diff changeset
1687 bool verify_count_and_frequency ();
kono
parents: 67
diff changeset
1688
kono
parents: 67
diff changeset
1689 /* Return true when call of edge can not lead to return from caller
kono
parents: 67
diff changeset
1690 and thus it is safe to ignore its side effects for IPA analysis
kono
parents: 67
diff changeset
1691 when computing side effects of the caller. */
kono
parents: 67
diff changeset
1692 bool cannot_lead_to_return_p (void);
kono
parents: 67
diff changeset
1693
kono
parents: 67
diff changeset
1694 /* Return true when the edge represents a direct recursion. */
kono
parents: 67
diff changeset
1695 bool recursive_p (void);
kono
parents: 67
diff changeset
1696
kono
parents: 67
diff changeset
1697 /* Return true if the call can be hot. */
kono
parents: 67
diff changeset
1698 bool maybe_hot_p (void);
kono
parents: 67
diff changeset
1699
kono
parents: 67
diff changeset
1700 /* Rebuild cgraph edges for current function node. This needs to be run after
kono
parents: 67
diff changeset
1701 passes that don't update the cgraph. */
kono
parents: 67
diff changeset
1702 static unsigned int rebuild_edges (void);
kono
parents: 67
diff changeset
1703
kono
parents: 67
diff changeset
1704 /* Rebuild cgraph references for current function node. This needs to be run
kono
parents: 67
diff changeset
1705 after passes that don't update the cgraph. */
kono
parents: 67
diff changeset
1706 static void rebuild_references (void);
kono
parents: 67
diff changeset
1707
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1708 /* Expected number of executions: calculated in profile.c. */
111
kono
parents: 67
diff changeset
1709 profile_count count;
kono
parents: 67
diff changeset
1710 cgraph_node *caller;
kono
parents: 67
diff changeset
1711 cgraph_node *callee;
kono
parents: 67
diff changeset
1712 cgraph_edge *prev_caller;
kono
parents: 67
diff changeset
1713 cgraph_edge *next_caller;
kono
parents: 67
diff changeset
1714 cgraph_edge *prev_callee;
kono
parents: 67
diff changeset
1715 cgraph_edge *next_callee;
kono
parents: 67
diff changeset
1716 gcall *call_stmt;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1717 /* Additional information about an indirect call. Not cleared when an edge
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1718 becomes direct. */
111
kono
parents: 67
diff changeset
1719 cgraph_indirect_call_info *indirect_info;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1720 PTR GTY ((skip (""))) aux;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1721 /* When equal to CIF_OK, inline this call. Otherwise, points to the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1722 explanation why function was not inlined. */
111
kono
parents: 67
diff changeset
1723 enum cgraph_inline_failed_t inline_failed;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1724 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1725 when the function is serialized in. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1726 unsigned int lto_stmt_uid;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1727 /* Expected frequency of executions within the function.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1728 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1729 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1730 int frequency;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1731 /* Unique id of the edge. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1732 int uid;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1733 /* Whether this edge was made direct by indirect inlining. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1734 unsigned int indirect_inlining_edge : 1;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1735 /* Whether this edge describes an indirect call with an undetermined
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1736 callee. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1737 unsigned int indirect_unknown_callee : 1;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1738 /* Whether this edge is still a dangling */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1739 /* True if the corresponding CALL stmt cannot be inlined. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1740 unsigned int call_stmt_cannot_inline_p : 1;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1741 /* Can this call throw externally? */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1742 unsigned int can_throw_external : 1;
111
kono
parents: 67
diff changeset
1743 /* Edges with SPECULATIVE flag represents indirect calls that was
kono
parents: 67
diff changeset
1744 speculatively turned into direct (i.e. by profile feedback).
kono
parents: 67
diff changeset
1745 The final code sequence will have form:
kono
parents: 67
diff changeset
1746
kono
parents: 67
diff changeset
1747 if (call_target == expected_fn)
kono
parents: 67
diff changeset
1748 expected_fn ();
kono
parents: 67
diff changeset
1749 else
kono
parents: 67
diff changeset
1750 call_target ();
kono
parents: 67
diff changeset
1751
kono
parents: 67
diff changeset
1752 Every speculative call is represented by three components attached
kono
parents: 67
diff changeset
1753 to a same call statement:
kono
parents: 67
diff changeset
1754 1) a direct call (to expected_fn)
kono
parents: 67
diff changeset
1755 2) an indirect call (to call_target)
kono
parents: 67
diff changeset
1756 3) a IPA_REF_ADDR refrence to expected_fn.
kono
parents: 67
diff changeset
1757
kono
parents: 67
diff changeset
1758 Optimizers may later redirect direct call to clone, so 1) and 3)
kono
parents: 67
diff changeset
1759 do not need to necesarily agree with destination. */
kono
parents: 67
diff changeset
1760 unsigned int speculative : 1;
kono
parents: 67
diff changeset
1761 /* Set to true when caller is a constructor or destructor of polymorphic
kono
parents: 67
diff changeset
1762 type. */
kono
parents: 67
diff changeset
1763 unsigned in_polymorphic_cdtor : 1;
kono
parents: 67
diff changeset
1764
kono
parents: 67
diff changeset
1765 /* Return true if call must bind to current definition. */
kono
parents: 67
diff changeset
1766 bool binds_to_current_def_p ();
kono
parents: 67
diff changeset
1767
kono
parents: 67
diff changeset
1768 private:
kono
parents: 67
diff changeset
1769 /* Remove the edge from the list of the callers of the callee. */
kono
parents: 67
diff changeset
1770 void remove_caller (void);
kono
parents: 67
diff changeset
1771
kono
parents: 67
diff changeset
1772 /* Remove the edge from the list of the callees of the caller. */
kono
parents: 67
diff changeset
1773 void remove_callee (void);
kono
parents: 67
diff changeset
1774
kono
parents: 67
diff changeset
1775 /* Set callee N of call graph edge and add it to the corresponding set of
kono
parents: 67
diff changeset
1776 callers. */
kono
parents: 67
diff changeset
1777 void set_callee (cgraph_node *n);
kono
parents: 67
diff changeset
1778
kono
parents: 67
diff changeset
1779 /* Output flags of edge to a file F. */
kono
parents: 67
diff changeset
1780 void dump_edge_flags (FILE *f);
kono
parents: 67
diff changeset
1781
kono
parents: 67
diff changeset
1782 /* Verify that call graph edge corresponds to DECL from the associated
kono
parents: 67
diff changeset
1783 statement. Return true if the verification should fail. */
kono
parents: 67
diff changeset
1784 bool verify_corresponds_to_fndecl (tree decl);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1785 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1786
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1787 #define CGRAPH_FREQ_BASE 1000
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1788 #define CGRAPH_FREQ_MAX 100000
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1789
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1790 /* The varpool data structure.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1791 Each static variable decl has assigned varpool_node. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1792
111
kono
parents: 67
diff changeset
1793 class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node {
kono
parents: 67
diff changeset
1794 public:
kono
parents: 67
diff changeset
1795 /* Dump given varpool node to F. */
kono
parents: 67
diff changeset
1796 void dump (FILE *f);
kono
parents: 67
diff changeset
1797
kono
parents: 67
diff changeset
1798 /* Dump given varpool node to stderr. */
kono
parents: 67
diff changeset
1799 void DEBUG_FUNCTION debug (void);
kono
parents: 67
diff changeset
1800
kono
parents: 67
diff changeset
1801 /* Remove variable from symbol table. */
kono
parents: 67
diff changeset
1802 void remove (void);
kono
parents: 67
diff changeset
1803
kono
parents: 67
diff changeset
1804 /* Remove node initializer when it is no longer needed. */
kono
parents: 67
diff changeset
1805 void remove_initializer (void);
kono
parents: 67
diff changeset
1806
kono
parents: 67
diff changeset
1807 void analyze (void);
kono
parents: 67
diff changeset
1808
kono
parents: 67
diff changeset
1809 /* Return variable availability. */
kono
parents: 67
diff changeset
1810 availability get_availability (symtab_node *ref = NULL);
kono
parents: 67
diff changeset
1811
kono
parents: 67
diff changeset
1812 /* When doing LTO, read variable's constructor from disk if
kono
parents: 67
diff changeset
1813 it is not already present. */
kono
parents: 67
diff changeset
1814 tree get_constructor (void);
kono
parents: 67
diff changeset
1815
kono
parents: 67
diff changeset
1816 /* Return true if variable has constructor that can be used for folding. */
kono
parents: 67
diff changeset
1817 bool ctor_useable_for_folding_p (void);
kono
parents: 67
diff changeset
1818
kono
parents: 67
diff changeset
1819 /* For given variable pool node, walk the alias chain to return the function
kono
parents: 67
diff changeset
1820 the variable is alias of. Do not walk through thunks.
kono
parents: 67
diff changeset
1821 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
1822 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
1823 when determining the availability. */
kono
parents: 67
diff changeset
1824 inline varpool_node *ultimate_alias_target
kono
parents: 67
diff changeset
1825 (availability *availability = NULL, symtab_node *ref = NULL);
kono
parents: 67
diff changeset
1826
kono
parents: 67
diff changeset
1827 /* Return node that alias is aliasing. */
kono
parents: 67
diff changeset
1828 inline varpool_node *get_alias_target (void);
kono
parents: 67
diff changeset
1829
kono
parents: 67
diff changeset
1830 /* Output one variable, if necessary. Return whether we output it. */
kono
parents: 67
diff changeset
1831 bool assemble_decl (void);
kono
parents: 67
diff changeset
1832
kono
parents: 67
diff changeset
1833 /* For variables in named sections make sure get_variable_section
kono
parents: 67
diff changeset
1834 is called before we switch to those sections. Then section
kono
parents: 67
diff changeset
1835 conflicts between read-only and read-only requiring relocations
kono
parents: 67
diff changeset
1836 sections can be resolved. */
kono
parents: 67
diff changeset
1837 void finalize_named_section_flags (void);
kono
parents: 67
diff changeset
1838
kono
parents: 67
diff changeset
1839 /* Call calback on varpool symbol and aliases associated to varpool symbol.
kono
parents: 67
diff changeset
1840 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
kono
parents: 67
diff changeset
1841 skipped. */
kono
parents: 67
diff changeset
1842 bool call_for_symbol_and_aliases (bool (*callback) (varpool_node *, void *),
kono
parents: 67
diff changeset
1843 void *data,
kono
parents: 67
diff changeset
1844 bool include_overwritable);
kono
parents: 67
diff changeset
1845
kono
parents: 67
diff changeset
1846 /* Return true when variable should be considered externally visible. */
kono
parents: 67
diff changeset
1847 bool externally_visible_p (void);
kono
parents: 67
diff changeset
1848
kono
parents: 67
diff changeset
1849 /* Return true when all references to variable must be visible
kono
parents: 67
diff changeset
1850 in ipa_ref_list.
kono
parents: 67
diff changeset
1851 i.e. if the variable is not externally visible or not used in some magic
kono
parents: 67
diff changeset
1852 way (asm statement or such).
kono
parents: 67
diff changeset
1853 The magic uses are all summarized in force_output flag. */
kono
parents: 67
diff changeset
1854 inline bool all_refs_explicit_p ();
kono
parents: 67
diff changeset
1855
kono
parents: 67
diff changeset
1856 /* Return true when variable can be removed from variable pool
kono
parents: 67
diff changeset
1857 if all direct calls are eliminated. */
kono
parents: 67
diff changeset
1858 inline bool can_remove_if_no_refs_p (void);
kono
parents: 67
diff changeset
1859
kono
parents: 67
diff changeset
1860 /* Add the variable DECL to the varpool.
kono
parents: 67
diff changeset
1861 Unlike finalize_decl function is intended to be used
kono
parents: 67
diff changeset
1862 by middle end and allows insertion of new variable at arbitrary point
kono
parents: 67
diff changeset
1863 of compilation. */
kono
parents: 67
diff changeset
1864 static void add (tree decl);
kono
parents: 67
diff changeset
1865
kono
parents: 67
diff changeset
1866 /* Return varpool node for given symbol and check it is a function. */
kono
parents: 67
diff changeset
1867 static inline varpool_node *get (const_tree decl);
kono
parents: 67
diff changeset
1868
kono
parents: 67
diff changeset
1869 /* Mark DECL as finalized. By finalizing the declaration, frontend instruct
kono
parents: 67
diff changeset
1870 the middle end to output the variable to asm file, if needed or externally
kono
parents: 67
diff changeset
1871 visible. */
kono
parents: 67
diff changeset
1872 static void finalize_decl (tree decl);
kono
parents: 67
diff changeset
1873
kono
parents: 67
diff changeset
1874 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
kono
parents: 67
diff changeset
1875 Extra name aliases are output whenever DECL is output. */
kono
parents: 67
diff changeset
1876 static varpool_node * create_extra_name_alias (tree alias, tree decl);
kono
parents: 67
diff changeset
1877
kono
parents: 67
diff changeset
1878 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
kono
parents: 67
diff changeset
1879 Extra name aliases are output whenever DECL is output. */
kono
parents: 67
diff changeset
1880 static varpool_node * create_alias (tree, tree);
kono
parents: 67
diff changeset
1881
kono
parents: 67
diff changeset
1882 /* Dump the variable pool to F. */
kono
parents: 67
diff changeset
1883 static void dump_varpool (FILE *f);
kono
parents: 67
diff changeset
1884
kono
parents: 67
diff changeset
1885 /* Dump the variable pool to stderr. */
kono
parents: 67
diff changeset
1886 static void DEBUG_FUNCTION debug_varpool (void);
kono
parents: 67
diff changeset
1887
kono
parents: 67
diff changeset
1888 /* Allocate new callgraph node and insert it into basic data structures. */
kono
parents: 67
diff changeset
1889 static varpool_node *create_empty (void);
kono
parents: 67
diff changeset
1890
kono
parents: 67
diff changeset
1891 /* Return varpool node assigned to DECL. Create new one when needed. */
kono
parents: 67
diff changeset
1892 static varpool_node *get_create (tree decl);
kono
parents: 67
diff changeset
1893
kono
parents: 67
diff changeset
1894 /* Given an assembler name, lookup node. */
kono
parents: 67
diff changeset
1895 static varpool_node *get_for_asmname (tree asmname);
kono
parents: 67
diff changeset
1896
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1897 /* Set when variable is scheduled to be assembled. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1898 unsigned output : 1;
111
kono
parents: 67
diff changeset
1899
kono
parents: 67
diff changeset
1900 /* Set when variable has statically initialized pointer
kono
parents: 67
diff changeset
1901 or is a static bounds variable and needs initalization. */
kono
parents: 67
diff changeset
1902 unsigned need_bounds_init : 1;
kono
parents: 67
diff changeset
1903
kono
parents: 67
diff changeset
1904 /* Set if the variable is dynamically initialized, except for
kono
parents: 67
diff changeset
1905 function local statics. */
kono
parents: 67
diff changeset
1906 unsigned dynamically_initialized : 1;
kono
parents: 67
diff changeset
1907
kono
parents: 67
diff changeset
1908 ENUM_BITFIELD(tls_model) tls_model : 3;
kono
parents: 67
diff changeset
1909
kono
parents: 67
diff changeset
1910 /* Set if the variable is known to be used by single function only.
kono
parents: 67
diff changeset
1911 This is computed by ipa_signle_use pass and used by late optimizations
kono
parents: 67
diff changeset
1912 in places where optimization would be valid for local static variable
kono
parents: 67
diff changeset
1913 if we did not do any inter-procedural code movement. */
kono
parents: 67
diff changeset
1914 unsigned used_by_single_function : 1;
kono
parents: 67
diff changeset
1915
kono
parents: 67
diff changeset
1916 private:
kono
parents: 67
diff changeset
1917 /* Assemble thunks and aliases associated to varpool node. */
kono
parents: 67
diff changeset
1918 void assemble_aliases (void);
kono
parents: 67
diff changeset
1919
kono
parents: 67
diff changeset
1920 /* Worker for call_for_node_and_aliases. */
kono
parents: 67
diff changeset
1921 bool call_for_symbol_and_aliases_1 (bool (*callback) (varpool_node *, void *),
kono
parents: 67
diff changeset
1922 void *data,
kono
parents: 67
diff changeset
1923 bool include_overwritable);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1924 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1925
111
kono
parents: 67
diff changeset
1926 /* Every top level asm statement is put into a asm_node. */
kono
parents: 67
diff changeset
1927
kono
parents: 67
diff changeset
1928 struct GTY(()) asm_node {
kono
parents: 67
diff changeset
1929
kono
parents: 67
diff changeset
1930
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1931 /* Next asm node. */
111
kono
parents: 67
diff changeset
1932 asm_node *next;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1933 /* String for this asm node. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1934 tree asm_str;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1935 /* Ordering of all cgraph nodes. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1936 int order;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1937 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1938
111
kono
parents: 67
diff changeset
1939 /* Report whether or not THIS symtab node is a function, aka cgraph_node. */
kono
parents: 67
diff changeset
1940
kono
parents: 67
diff changeset
1941 template <>
kono
parents: 67
diff changeset
1942 template <>
kono
parents: 67
diff changeset
1943 inline bool
kono
parents: 67
diff changeset
1944 is_a_helper <cgraph_node *>::test (symtab_node *p)
kono
parents: 67
diff changeset
1945 {
kono
parents: 67
diff changeset
1946 return p && p->type == SYMTAB_FUNCTION;
kono
parents: 67
diff changeset
1947 }
kono
parents: 67
diff changeset
1948
kono
parents: 67
diff changeset
1949 /* Report whether or not THIS symtab node is a vriable, aka varpool_node. */
kono
parents: 67
diff changeset
1950
kono
parents: 67
diff changeset
1951 template <>
kono
parents: 67
diff changeset
1952 template <>
kono
parents: 67
diff changeset
1953 inline bool
kono
parents: 67
diff changeset
1954 is_a_helper <varpool_node *>::test (symtab_node *p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1955 {
111
kono
parents: 67
diff changeset
1956 return p && p->type == SYMTAB_VARIABLE;
kono
parents: 67
diff changeset
1957 }
kono
parents: 67
diff changeset
1958
kono
parents: 67
diff changeset
1959 /* Macros to access the next item in the list of free cgraph nodes and
kono
parents: 67
diff changeset
1960 edges. */
kono
parents: 67
diff changeset
1961 #define NEXT_FREE_NODE(NODE) dyn_cast<cgraph_node *> ((NODE)->next)
kono
parents: 67
diff changeset
1962 #define SET_NEXT_FREE_NODE(NODE,NODE2) ((NODE))->next = NODE2
kono
parents: 67
diff changeset
1963 #define NEXT_FREE_EDGE(EDGE) (EDGE)->prev_caller
kono
parents: 67
diff changeset
1964
kono
parents: 67
diff changeset
1965 typedef void (*cgraph_edge_hook)(cgraph_edge *, void *);
kono
parents: 67
diff changeset
1966 typedef void (*cgraph_node_hook)(cgraph_node *, void *);
kono
parents: 67
diff changeset
1967 typedef void (*varpool_node_hook)(varpool_node *, void *);
kono
parents: 67
diff changeset
1968 typedef void (*cgraph_2edge_hook)(cgraph_edge *, cgraph_edge *, void *);
kono
parents: 67
diff changeset
1969 typedef void (*cgraph_2node_hook)(cgraph_node *, cgraph_node *, void *);
kono
parents: 67
diff changeset
1970
kono
parents: 67
diff changeset
1971 struct cgraph_edge_hook_list;
kono
parents: 67
diff changeset
1972 struct cgraph_node_hook_list;
kono
parents: 67
diff changeset
1973 struct varpool_node_hook_list;
kono
parents: 67
diff changeset
1974 struct cgraph_2edge_hook_list;
kono
parents: 67
diff changeset
1975 struct cgraph_2node_hook_list;
kono
parents: 67
diff changeset
1976
kono
parents: 67
diff changeset
1977 /* Map from a symbol to initialization/finalization priorities. */
kono
parents: 67
diff changeset
1978 struct GTY(()) symbol_priority_map {
kono
parents: 67
diff changeset
1979 priority_type init;
kono
parents: 67
diff changeset
1980 priority_type fini;
kono
parents: 67
diff changeset
1981 };
kono
parents: 67
diff changeset
1982
kono
parents: 67
diff changeset
1983 enum symtab_state
kono
parents: 67
diff changeset
1984 {
kono
parents: 67
diff changeset
1985 /* Frontend is parsing and finalizing functions. */
kono
parents: 67
diff changeset
1986 PARSING,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1987 /* Callgraph is being constructed. It is safe to add new functions. */
111
kono
parents: 67
diff changeset
1988 CONSTRUCTION,
kono
parents: 67
diff changeset
1989 /* Callgraph is being streamed-in at LTO time. */
kono
parents: 67
diff changeset
1990 LTO_STREAMING,
kono
parents: 67
diff changeset
1991 /* Callgraph is built and early IPA passes are being run. */
kono
parents: 67
diff changeset
1992 IPA,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1993 /* Callgraph is built and all functions are transformed to SSA form. */
111
kono
parents: 67
diff changeset
1994 IPA_SSA,
kono
parents: 67
diff changeset
1995 /* All inline decisions are done; it is now possible to remove extern inline
kono
parents: 67
diff changeset
1996 functions and virtual call targets. */
kono
parents: 67
diff changeset
1997 IPA_SSA_AFTER_INLINING,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1998 /* Functions are now ordered and being passed to RTL expanders. */
111
kono
parents: 67
diff changeset
1999 EXPANSION,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2000 /* All cgraph expansion is done. */
111
kono
parents: 67
diff changeset
2001 FINISHED
kono
parents: 67
diff changeset
2002 };
kono
parents: 67
diff changeset
2003
kono
parents: 67
diff changeset
2004 struct asmname_hasher : ggc_ptr_hash <symtab_node>
kono
parents: 67
diff changeset
2005 {
kono
parents: 67
diff changeset
2006 typedef const_tree compare_type;
kono
parents: 67
diff changeset
2007
kono
parents: 67
diff changeset
2008 static hashval_t hash (symtab_node *n);
kono
parents: 67
diff changeset
2009 static bool equal (symtab_node *n, const_tree t);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2010 };
111
kono
parents: 67
diff changeset
2011
kono
parents: 67
diff changeset
2012 class GTY((tag ("SYMTAB"))) symbol_table
kono
parents: 67
diff changeset
2013 {
kono
parents: 67
diff changeset
2014 public:
kono
parents: 67
diff changeset
2015 friend class symtab_node;
kono
parents: 67
diff changeset
2016 friend class cgraph_node;
kono
parents: 67
diff changeset
2017 friend class cgraph_edge;
kono
parents: 67
diff changeset
2018
kono
parents: 67
diff changeset
2019 symbol_table (): cgraph_max_summary_uid (1)
kono
parents: 67
diff changeset
2020 {
kono
parents: 67
diff changeset
2021 }
kono
parents: 67
diff changeset
2022
kono
parents: 67
diff changeset
2023 /* Initialize callgraph dump file. */
kono
parents: 67
diff changeset
2024 void initialize (void);
kono
parents: 67
diff changeset
2025
kono
parents: 67
diff changeset
2026 /* Register a top-level asm statement ASM_STR. */
kono
parents: 67
diff changeset
2027 inline asm_node *finalize_toplevel_asm (tree asm_str);
kono
parents: 67
diff changeset
2028
kono
parents: 67
diff changeset
2029 /* Analyze the whole compilation unit once it is parsed completely. */
kono
parents: 67
diff changeset
2030 void finalize_compilation_unit (void);
kono
parents: 67
diff changeset
2031
kono
parents: 67
diff changeset
2032 /* C++ frontend produce same body aliases all over the place, even before PCH
kono
parents: 67
diff changeset
2033 gets streamed out. It relies on us linking the aliases with their function
kono
parents: 67
diff changeset
2034 in order to do the fixups, but ipa-ref is not PCH safe. Consequentely we
kono
parents: 67
diff changeset
2035 first produce aliases without links, but once C++ FE is sure he won't sream
kono
parents: 67
diff changeset
2036 PCH we build the links via this function. */
kono
parents: 67
diff changeset
2037 void process_same_body_aliases (void);
kono
parents: 67
diff changeset
2038
kono
parents: 67
diff changeset
2039 /* Perform simple optimizations based on callgraph. */
kono
parents: 67
diff changeset
2040 void compile (void);
kono
parents: 67
diff changeset
2041
kono
parents: 67
diff changeset
2042 /* Process CGRAPH_NEW_FUNCTIONS and perform actions necessary to add these
kono
parents: 67
diff changeset
2043 functions into callgraph in a way so they look like ordinary reachable
kono
parents: 67
diff changeset
2044 functions inserted into callgraph already at construction time. */
kono
parents: 67
diff changeset
2045 void process_new_functions (void);
kono
parents: 67
diff changeset
2046
kono
parents: 67
diff changeset
2047 /* Once all functions from compilation unit are in memory, produce all clones
kono
parents: 67
diff changeset
2048 and update all calls. We might also do this on demand if we don't want to
kono
parents: 67
diff changeset
2049 bring all functions to memory prior compilation, but current WHOPR
kono
parents: 67
diff changeset
2050 implementation does that and it is bit easier to keep everything right
kono
parents: 67
diff changeset
2051 in this order. */
kono
parents: 67
diff changeset
2052 void materialize_all_clones (void);
kono
parents: 67
diff changeset
2053
kono
parents: 67
diff changeset
2054 /* Register a symbol NODE. */
kono
parents: 67
diff changeset
2055 inline void register_symbol (symtab_node *node);
kono
parents: 67
diff changeset
2056
kono
parents: 67
diff changeset
2057 inline void
kono
parents: 67
diff changeset
2058 clear_asm_symbols (void)
kono
parents: 67
diff changeset
2059 {
kono
parents: 67
diff changeset
2060 asmnodes = NULL;
kono
parents: 67
diff changeset
2061 asm_last_node = NULL;
kono
parents: 67
diff changeset
2062 }
kono
parents: 67
diff changeset
2063
kono
parents: 67
diff changeset
2064 /* Perform reachability analysis and reclaim all unreachable nodes. */
kono
parents: 67
diff changeset
2065 bool remove_unreachable_nodes (FILE *file);
kono
parents: 67
diff changeset
2066
kono
parents: 67
diff changeset
2067 /* Optimization of function bodies might've rendered some variables as
kono
parents: 67
diff changeset
2068 unnecessary so we want to avoid these from being compiled. Re-do
kono
parents: 67
diff changeset
2069 reachability starting from variables that are either externally visible
kono
parents: 67
diff changeset
2070 or was referred from the asm output routines. */
kono
parents: 67
diff changeset
2071 void remove_unreferenced_decls (void);
kono
parents: 67
diff changeset
2072
kono
parents: 67
diff changeset
2073 /* Unregister a symbol NODE. */
kono
parents: 67
diff changeset
2074 inline void unregister (symtab_node *node);
kono
parents: 67
diff changeset
2075
kono
parents: 67
diff changeset
2076 /* Allocate new callgraph node and insert it into basic data structures. */
kono
parents: 67
diff changeset
2077 cgraph_node *create_empty (void);
kono
parents: 67
diff changeset
2078
kono
parents: 67
diff changeset
2079 /* Release a callgraph NODE with UID and put in to the list
kono
parents: 67
diff changeset
2080 of free nodes. */
kono
parents: 67
diff changeset
2081 void release_symbol (cgraph_node *node, int uid);
kono
parents: 67
diff changeset
2082
kono
parents: 67
diff changeset
2083 /* Output all variables enqueued to be assembled. */
kono
parents: 67
diff changeset
2084 bool output_variables (void);
kono
parents: 67
diff changeset
2085
kono
parents: 67
diff changeset
2086 /* Weakrefs may be associated to external decls and thus not output
kono
parents: 67
diff changeset
2087 at expansion time. Emit all necessary aliases. */
kono
parents: 67
diff changeset
2088 void output_weakrefs (void);
kono
parents: 67
diff changeset
2089
kono
parents: 67
diff changeset
2090 /* Return first static symbol with definition. */
kono
parents: 67
diff changeset
2091 inline symtab_node *first_symbol (void);
kono
parents: 67
diff changeset
2092
kono
parents: 67
diff changeset
2093 /* Return first assembler symbol. */
kono
parents: 67
diff changeset
2094 inline asm_node *
kono
parents: 67
diff changeset
2095 first_asm_symbol (void)
kono
parents: 67
diff changeset
2096 {
kono
parents: 67
diff changeset
2097 return asmnodes;
kono
parents: 67
diff changeset
2098 }
kono
parents: 67
diff changeset
2099
kono
parents: 67
diff changeset
2100 /* Return first static symbol with definition. */
kono
parents: 67
diff changeset
2101 inline symtab_node *first_defined_symbol (void);
kono
parents: 67
diff changeset
2102
kono
parents: 67
diff changeset
2103 /* Return first variable. */
kono
parents: 67
diff changeset
2104 inline varpool_node *first_variable (void);
kono
parents: 67
diff changeset
2105
kono
parents: 67
diff changeset
2106 /* Return next variable after NODE. */
kono
parents: 67
diff changeset
2107 inline varpool_node *next_variable (varpool_node *node);
kono
parents: 67
diff changeset
2108
kono
parents: 67
diff changeset
2109 /* Return first static variable with initializer. */
kono
parents: 67
diff changeset
2110 inline varpool_node *first_static_initializer (void);
kono
parents: 67
diff changeset
2111
kono
parents: 67
diff changeset
2112 /* Return next static variable with initializer after NODE. */
kono
parents: 67
diff changeset
2113 inline varpool_node *next_static_initializer (varpool_node *node);
kono
parents: 67
diff changeset
2114
kono
parents: 67
diff changeset
2115 /* Return first static variable with definition. */
kono
parents: 67
diff changeset
2116 inline varpool_node *first_defined_variable (void);
kono
parents: 67
diff changeset
2117
kono
parents: 67
diff changeset
2118 /* Return next static variable with definition after NODE. */
kono
parents: 67
diff changeset
2119 inline varpool_node *next_defined_variable (varpool_node *node);
kono
parents: 67
diff changeset
2120
kono
parents: 67
diff changeset
2121 /* Return first function with body defined. */
kono
parents: 67
diff changeset
2122 inline cgraph_node *first_defined_function (void);
kono
parents: 67
diff changeset
2123
kono
parents: 67
diff changeset
2124 /* Return next function with body defined after NODE. */
kono
parents: 67
diff changeset
2125 inline cgraph_node *next_defined_function (cgraph_node *node);
kono
parents: 67
diff changeset
2126
kono
parents: 67
diff changeset
2127 /* Return first function. */
kono
parents: 67
diff changeset
2128 inline cgraph_node *first_function (void);
kono
parents: 67
diff changeset
2129
kono
parents: 67
diff changeset
2130 /* Return next function. */
kono
parents: 67
diff changeset
2131 inline cgraph_node *next_function (cgraph_node *node);
kono
parents: 67
diff changeset
2132
kono
parents: 67
diff changeset
2133 /* Return first function with body defined. */
kono
parents: 67
diff changeset
2134 cgraph_node *first_function_with_gimple_body (void);
kono
parents: 67
diff changeset
2135
kono
parents: 67
diff changeset
2136 /* Return next reachable static variable with initializer after NODE. */
kono
parents: 67
diff changeset
2137 inline cgraph_node *next_function_with_gimple_body (cgraph_node *node);
kono
parents: 67
diff changeset
2138
kono
parents: 67
diff changeset
2139 /* Register HOOK to be called with DATA on each removed edge. */
kono
parents: 67
diff changeset
2140 cgraph_edge_hook_list *add_edge_removal_hook (cgraph_edge_hook hook,
kono
parents: 67
diff changeset
2141 void *data);
kono
parents: 67
diff changeset
2142
kono
parents: 67
diff changeset
2143 /* Remove ENTRY from the list of hooks called on removing edges. */
kono
parents: 67
diff changeset
2144 void remove_edge_removal_hook (cgraph_edge_hook_list *entry);
kono
parents: 67
diff changeset
2145
kono
parents: 67
diff changeset
2146 /* Register HOOK to be called with DATA on each removed node. */
kono
parents: 67
diff changeset
2147 cgraph_node_hook_list *add_cgraph_removal_hook (cgraph_node_hook hook,
kono
parents: 67
diff changeset
2148 void *data);
kono
parents: 67
diff changeset
2149
kono
parents: 67
diff changeset
2150 /* Remove ENTRY from the list of hooks called on removing nodes. */
kono
parents: 67
diff changeset
2151 void remove_cgraph_removal_hook (cgraph_node_hook_list *entry);
kono
parents: 67
diff changeset
2152
kono
parents: 67
diff changeset
2153 /* Register HOOK to be called with DATA on each removed node. */
kono
parents: 67
diff changeset
2154 varpool_node_hook_list *add_varpool_removal_hook (varpool_node_hook hook,
kono
parents: 67
diff changeset
2155 void *data);
kono
parents: 67
diff changeset
2156
kono
parents: 67
diff changeset
2157 /* Remove ENTRY from the list of hooks called on removing nodes. */
kono
parents: 67
diff changeset
2158 void remove_varpool_removal_hook (varpool_node_hook_list *entry);
kono
parents: 67
diff changeset
2159
kono
parents: 67
diff changeset
2160 /* Register HOOK to be called with DATA on each inserted node. */
kono
parents: 67
diff changeset
2161 cgraph_node_hook_list *add_cgraph_insertion_hook (cgraph_node_hook hook,
kono
parents: 67
diff changeset
2162 void *data);
kono
parents: 67
diff changeset
2163
kono
parents: 67
diff changeset
2164 /* Remove ENTRY from the list of hooks called on inserted nodes. */
kono
parents: 67
diff changeset
2165 void remove_cgraph_insertion_hook (cgraph_node_hook_list *entry);
kono
parents: 67
diff changeset
2166
kono
parents: 67
diff changeset
2167 /* Register HOOK to be called with DATA on each inserted node. */
kono
parents: 67
diff changeset
2168 varpool_node_hook_list *add_varpool_insertion_hook (varpool_node_hook hook,
kono
parents: 67
diff changeset
2169 void *data);
kono
parents: 67
diff changeset
2170
kono
parents: 67
diff changeset
2171 /* Remove ENTRY from the list of hooks called on inserted nodes. */
kono
parents: 67
diff changeset
2172 void remove_varpool_insertion_hook (varpool_node_hook_list *entry);
kono
parents: 67
diff changeset
2173
kono
parents: 67
diff changeset
2174 /* Register HOOK to be called with DATA on each duplicated edge. */
kono
parents: 67
diff changeset
2175 cgraph_2edge_hook_list *add_edge_duplication_hook (cgraph_2edge_hook hook,
kono
parents: 67
diff changeset
2176 void *data);
kono
parents: 67
diff changeset
2177 /* Remove ENTRY from the list of hooks called on duplicating edges. */
kono
parents: 67
diff changeset
2178 void remove_edge_duplication_hook (cgraph_2edge_hook_list *entry);
kono
parents: 67
diff changeset
2179
kono
parents: 67
diff changeset
2180 /* Register HOOK to be called with DATA on each duplicated node. */
kono
parents: 67
diff changeset
2181 cgraph_2node_hook_list *add_cgraph_duplication_hook (cgraph_2node_hook hook,
kono
parents: 67
diff changeset
2182 void *data);
kono
parents: 67
diff changeset
2183
kono
parents: 67
diff changeset
2184 /* Remove ENTRY from the list of hooks called on duplicating nodes. */
kono
parents: 67
diff changeset
2185 void remove_cgraph_duplication_hook (cgraph_2node_hook_list *entry);
kono
parents: 67
diff changeset
2186
kono
parents: 67
diff changeset
2187 /* Call all edge removal hooks. */
kono
parents: 67
diff changeset
2188 void call_edge_removal_hooks (cgraph_edge *e);
kono
parents: 67
diff changeset
2189
kono
parents: 67
diff changeset
2190 /* Call all node insertion hooks. */
kono
parents: 67
diff changeset
2191 void call_cgraph_insertion_hooks (cgraph_node *node);
kono
parents: 67
diff changeset
2192
kono
parents: 67
diff changeset
2193 /* Call all node removal hooks. */
kono
parents: 67
diff changeset
2194 void call_cgraph_removal_hooks (cgraph_node *node);
kono
parents: 67
diff changeset
2195
kono
parents: 67
diff changeset
2196 /* Call all node duplication hooks. */
kono
parents: 67
diff changeset
2197 void call_cgraph_duplication_hooks (cgraph_node *node, cgraph_node *node2);
kono
parents: 67
diff changeset
2198
kono
parents: 67
diff changeset
2199 /* Call all edge duplication hooks. */
kono
parents: 67
diff changeset
2200 void call_edge_duplication_hooks (cgraph_edge *cs1, cgraph_edge *cs2);
kono
parents: 67
diff changeset
2201
kono
parents: 67
diff changeset
2202 /* Call all node removal hooks. */
kono
parents: 67
diff changeset
2203 void call_varpool_removal_hooks (varpool_node *node);
kono
parents: 67
diff changeset
2204
kono
parents: 67
diff changeset
2205 /* Call all node insertion hooks. */
kono
parents: 67
diff changeset
2206 void call_varpool_insertion_hooks (varpool_node *node);
kono
parents: 67
diff changeset
2207
kono
parents: 67
diff changeset
2208 /* Arrange node to be first in its entry of assembler_name_hash. */
kono
parents: 67
diff changeset
2209 void symtab_prevail_in_asm_name_hash (symtab_node *node);
kono
parents: 67
diff changeset
2210
kono
parents: 67
diff changeset
2211 /* Initalize asm name hash unless. */
kono
parents: 67
diff changeset
2212 void symtab_initialize_asm_name_hash (void);
kono
parents: 67
diff changeset
2213
kono
parents: 67
diff changeset
2214 /* Set the DECL_ASSEMBLER_NAME and update symtab hashtables. */
kono
parents: 67
diff changeset
2215 void change_decl_assembler_name (tree decl, tree name);
kono
parents: 67
diff changeset
2216
kono
parents: 67
diff changeset
2217 /* Dump symbol table to F. */
kono
parents: 67
diff changeset
2218 void dump (FILE *f);
kono
parents: 67
diff changeset
2219
kono
parents: 67
diff changeset
2220 /* Dump symbol table to stderr. */
kono
parents: 67
diff changeset
2221 inline DEBUG_FUNCTION void debug (void)
kono
parents: 67
diff changeset
2222 {
kono
parents: 67
diff changeset
2223 dump (stderr);
kono
parents: 67
diff changeset
2224 }
kono
parents: 67
diff changeset
2225
kono
parents: 67
diff changeset
2226 /* Return true if assembler names NAME1 and NAME2 leads to the same symbol
kono
parents: 67
diff changeset
2227 name. */
kono
parents: 67
diff changeset
2228 static bool assembler_names_equal_p (const char *name1, const char *name2);
kono
parents: 67
diff changeset
2229
kono
parents: 67
diff changeset
2230 int cgraph_count;
kono
parents: 67
diff changeset
2231 int cgraph_max_uid;
kono
parents: 67
diff changeset
2232 int cgraph_max_summary_uid;
kono
parents: 67
diff changeset
2233
kono
parents: 67
diff changeset
2234 int edges_count;
kono
parents: 67
diff changeset
2235 int edges_max_uid;
kono
parents: 67
diff changeset
2236
kono
parents: 67
diff changeset
2237 symtab_node* GTY(()) nodes;
kono
parents: 67
diff changeset
2238 asm_node* GTY(()) asmnodes;
kono
parents: 67
diff changeset
2239 asm_node* GTY(()) asm_last_node;
kono
parents: 67
diff changeset
2240 cgraph_node* GTY(()) free_nodes;
kono
parents: 67
diff changeset
2241
kono
parents: 67
diff changeset
2242 /* Head of a linked list of unused (freed) call graph edges.
kono
parents: 67
diff changeset
2243 Do not GTY((delete)) this list so UIDs gets reliably recycled. */
kono
parents: 67
diff changeset
2244 cgraph_edge * GTY(()) free_edges;
kono
parents: 67
diff changeset
2245
kono
parents: 67
diff changeset
2246 /* The order index of the next symtab node to be created. This is
kono
parents: 67
diff changeset
2247 used so that we can sort the cgraph nodes in order by when we saw
kono
parents: 67
diff changeset
2248 them, to support -fno-toplevel-reorder. */
kono
parents: 67
diff changeset
2249 int order;
kono
parents: 67
diff changeset
2250
kono
parents: 67
diff changeset
2251 /* Set when whole unit has been analyzed so we can access global info. */
kono
parents: 67
diff changeset
2252 bool global_info_ready;
kono
parents: 67
diff changeset
2253 /* What state callgraph is in right now. */
kono
parents: 67
diff changeset
2254 enum symtab_state state;
kono
parents: 67
diff changeset
2255 /* Set when the cgraph is fully build and the basic flags are computed. */
kono
parents: 67
diff changeset
2256 bool function_flags_ready;
kono
parents: 67
diff changeset
2257
kono
parents: 67
diff changeset
2258 bool cpp_implicit_aliases_done;
kono
parents: 67
diff changeset
2259
kono
parents: 67
diff changeset
2260 /* Hash table used to hold sectoons. */
kono
parents: 67
diff changeset
2261 hash_table<section_name_hasher> *GTY(()) section_hash;
kono
parents: 67
diff changeset
2262
kono
parents: 67
diff changeset
2263 /* Hash table used to convert assembler names into nodes. */
kono
parents: 67
diff changeset
2264 hash_table<asmname_hasher> *assembler_name_hash;
kono
parents: 67
diff changeset
2265
kono
parents: 67
diff changeset
2266 /* Hash table used to hold init priorities. */
kono
parents: 67
diff changeset
2267 hash_map<symtab_node *, symbol_priority_map> *init_priority_hash;
kono
parents: 67
diff changeset
2268
kono
parents: 67
diff changeset
2269 FILE* GTY ((skip)) dump_file;
kono
parents: 67
diff changeset
2270
kono
parents: 67
diff changeset
2271 /* Return symbol used to separate symbol name from suffix. */
kono
parents: 67
diff changeset
2272 static char symbol_suffix_separator ();
kono
parents: 67
diff changeset
2273
kono
parents: 67
diff changeset
2274 FILE* GTY ((skip)) ipa_clones_dump_file;
kono
parents: 67
diff changeset
2275
kono
parents: 67
diff changeset
2276 hash_set <const cgraph_node *> GTY ((skip)) cloned_nodes;
kono
parents: 67
diff changeset
2277
kono
parents: 67
diff changeset
2278 private:
kono
parents: 67
diff changeset
2279 /* Allocate new callgraph node. */
kono
parents: 67
diff changeset
2280 inline cgraph_node * allocate_cgraph_symbol (void);
kono
parents: 67
diff changeset
2281
kono
parents: 67
diff changeset
2282 /* Allocate a cgraph_edge structure and fill it with data according to the
kono
parents: 67
diff changeset
2283 parameters of which only CALLEE can be NULL (when creating an indirect call
kono
parents: 67
diff changeset
2284 edge). */
kono
parents: 67
diff changeset
2285 cgraph_edge *create_edge (cgraph_node *caller, cgraph_node *callee,
kono
parents: 67
diff changeset
2286 gcall *call_stmt, profile_count count, int freq,
kono
parents: 67
diff changeset
2287 bool indir_unknown_callee);
kono
parents: 67
diff changeset
2288
kono
parents: 67
diff changeset
2289 /* Put the edge onto the free list. */
kono
parents: 67
diff changeset
2290 void free_edge (cgraph_edge *e);
kono
parents: 67
diff changeset
2291
kono
parents: 67
diff changeset
2292 /* Insert NODE to assembler name hash. */
kono
parents: 67
diff changeset
2293 void insert_to_assembler_name_hash (symtab_node *node, bool with_clones);
kono
parents: 67
diff changeset
2294
kono
parents: 67
diff changeset
2295 /* Remove NODE from assembler name hash. */
kono
parents: 67
diff changeset
2296 void unlink_from_assembler_name_hash (symtab_node *node, bool with_clones);
kono
parents: 67
diff changeset
2297
kono
parents: 67
diff changeset
2298 /* Hash asmnames ignoring the user specified marks. */
kono
parents: 67
diff changeset
2299 static hashval_t decl_assembler_name_hash (const_tree asmname);
kono
parents: 67
diff changeset
2300
kono
parents: 67
diff changeset
2301 /* Compare ASMNAME with the DECL_ASSEMBLER_NAME of DECL. */
kono
parents: 67
diff changeset
2302 static bool decl_assembler_name_equal (tree decl, const_tree asmname);
kono
parents: 67
diff changeset
2303
kono
parents: 67
diff changeset
2304 friend struct asmname_hasher;
kono
parents: 67
diff changeset
2305
kono
parents: 67
diff changeset
2306 /* List of hooks triggered when an edge is removed. */
kono
parents: 67
diff changeset
2307 cgraph_edge_hook_list * GTY((skip)) m_first_edge_removal_hook;
kono
parents: 67
diff changeset
2308 /* List of hooks triggem_red when a cgraph node is removed. */
kono
parents: 67
diff changeset
2309 cgraph_node_hook_list * GTY((skip)) m_first_cgraph_removal_hook;
kono
parents: 67
diff changeset
2310 /* List of hooks triggered when an edge is duplicated. */
kono
parents: 67
diff changeset
2311 cgraph_2edge_hook_list * GTY((skip)) m_first_edge_duplicated_hook;
kono
parents: 67
diff changeset
2312 /* List of hooks triggered when a node is duplicated. */
kono
parents: 67
diff changeset
2313 cgraph_2node_hook_list * GTY((skip)) m_first_cgraph_duplicated_hook;
kono
parents: 67
diff changeset
2314 /* List of hooks triggered when an function is inserted. */
kono
parents: 67
diff changeset
2315 cgraph_node_hook_list * GTY((skip)) m_first_cgraph_insertion_hook;
kono
parents: 67
diff changeset
2316 /* List of hooks triggered when an variable is inserted. */
kono
parents: 67
diff changeset
2317 varpool_node_hook_list * GTY((skip)) m_first_varpool_insertion_hook;
kono
parents: 67
diff changeset
2318 /* List of hooks triggered when a node is removed. */
kono
parents: 67
diff changeset
2319 varpool_node_hook_list * GTY((skip)) m_first_varpool_removal_hook;
kono
parents: 67
diff changeset
2320 };
kono
parents: 67
diff changeset
2321
kono
parents: 67
diff changeset
2322 extern GTY(()) symbol_table *symtab;
kono
parents: 67
diff changeset
2323
kono
parents: 67
diff changeset
2324 extern vec<cgraph_node *> cgraph_new_nodes;
kono
parents: 67
diff changeset
2325
kono
parents: 67
diff changeset
2326 inline hashval_t
kono
parents: 67
diff changeset
2327 asmname_hasher::hash (symtab_node *n)
kono
parents: 67
diff changeset
2328 {
kono
parents: 67
diff changeset
2329 return symbol_table::decl_assembler_name_hash
kono
parents: 67
diff changeset
2330 (DECL_ASSEMBLER_NAME (n->decl));
kono
parents: 67
diff changeset
2331 }
kono
parents: 67
diff changeset
2332
kono
parents: 67
diff changeset
2333 inline bool
kono
parents: 67
diff changeset
2334 asmname_hasher::equal (symtab_node *n, const_tree t)
kono
parents: 67
diff changeset
2335 {
kono
parents: 67
diff changeset
2336 return symbol_table::decl_assembler_name_equal (n->decl, t);
kono
parents: 67
diff changeset
2337 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2338
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2339 /* In cgraph.c */
111
kono
parents: 67
diff changeset
2340 void cgraph_c_finalize (void);
kono
parents: 67
diff changeset
2341 void release_function_body (tree);
kono
parents: 67
diff changeset
2342 cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
kono
parents: 67
diff changeset
2343
kono
parents: 67
diff changeset
2344 void cgraph_update_edges_for_call_stmt (gimple *, tree, gimple *);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2345 bool cgraph_function_possibly_inlined_p (tree);
111
kono
parents: 67
diff changeset
2346
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2347 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
111
kono
parents: 67
diff changeset
2348 cgraph_inline_failed_type_t cgraph_inline_failed_type (cgraph_inline_failed_t);
kono
parents: 67
diff changeset
2349
kono
parents: 67
diff changeset
2350 extern bool gimple_check_call_matching_types (gimple *, tree, bool);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2351
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2352 /* In cgraphunit.c */
111
kono
parents: 67
diff changeset
2353 void cgraphunit_c_finalize (void);
kono
parents: 67
diff changeset
2354
kono
parents: 67
diff changeset
2355 /* Initialize datastructures so DECL is a function in lowered gimple form.
kono
parents: 67
diff changeset
2356 IN_SSA is true if the gimple is in SSA. */
kono
parents: 67
diff changeset
2357 basic_block init_lowered_empty_function (tree, bool, profile_count);
kono
parents: 67
diff changeset
2358
kono
parents: 67
diff changeset
2359 tree thunk_adjust (gimple_stmt_iterator *, tree, bool, HOST_WIDE_INT, tree);
kono
parents: 67
diff changeset
2360 /* In cgraphclones.c */
kono
parents: 67
diff changeset
2361
kono
parents: 67
diff changeset
2362 tree clone_function_name_1 (const char *, const char *);
kono
parents: 67
diff changeset
2363 tree clone_function_name (tree decl, const char *);
kono
parents: 67
diff changeset
2364
kono
parents: 67
diff changeset
2365 void tree_function_versioning (tree, tree, vec<ipa_replace_map *, va_gc> *,
kono
parents: 67
diff changeset
2366 bool, bitmap, bool, bitmap, basic_block);
kono
parents: 67
diff changeset
2367
kono
parents: 67
diff changeset
2368 void dump_callgraph_transformation (const cgraph_node *original,
kono
parents: 67
diff changeset
2369 const cgraph_node *clone,
kono
parents: 67
diff changeset
2370 const char *suffix);
kono
parents: 67
diff changeset
2371 tree cgraph_build_function_type_skip_args (tree orig_type, bitmap args_to_skip,
kono
parents: 67
diff changeset
2372 bool skip_return);
kono
parents: 67
diff changeset
2373
kono
parents: 67
diff changeset
2374 /* In cgraphbuild.c */
kono
parents: 67
diff changeset
2375 int compute_call_stmt_bb_frequency (tree, basic_block bb);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2376 void record_references_in_initializer (tree, bool);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2377
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2378 /* In ipa.c */
111
kono
parents: 67
diff changeset
2379 void cgraph_build_static_cdtor (char which, tree body, int priority);
kono
parents: 67
diff changeset
2380 bool ipa_discover_readonly_nonaddressable_vars (void);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2381
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2382 /* In varpool.c */
111
kono
parents: 67
diff changeset
2383 tree ctor_for_folding (tree);
kono
parents: 67
diff changeset
2384
kono
parents: 67
diff changeset
2385 /* In tree-chkp.c */
kono
parents: 67
diff changeset
2386 extern bool chkp_function_instrumented_p (tree fndecl);
kono
parents: 67
diff changeset
2387
kono
parents: 67
diff changeset
2388 /* In ipa-inline-analysis.c */
kono
parents: 67
diff changeset
2389 void initialize_inline_failed (struct cgraph_edge *);
kono
parents: 67
diff changeset
2390 bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining);
kono
parents: 67
diff changeset
2391
kono
parents: 67
diff changeset
2392 /* Return true when the symbol is real symbol, i.e. it is not inline clone
kono
parents: 67
diff changeset
2393 or abstract function kept for debug info purposes only. */
kono
parents: 67
diff changeset
2394 inline bool
kono
parents: 67
diff changeset
2395 symtab_node::real_symbol_p (void)
kono
parents: 67
diff changeset
2396 {
kono
parents: 67
diff changeset
2397 cgraph_node *cnode;
kono
parents: 67
diff changeset
2398
kono
parents: 67
diff changeset
2399 if (DECL_ABSTRACT_P (decl))
kono
parents: 67
diff changeset
2400 return false;
kono
parents: 67
diff changeset
2401 if (transparent_alias && definition)
kono
parents: 67
diff changeset
2402 return false;
kono
parents: 67
diff changeset
2403 if (!is_a <cgraph_node *> (this))
kono
parents: 67
diff changeset
2404 return true;
kono
parents: 67
diff changeset
2405 cnode = dyn_cast <cgraph_node *> (this);
kono
parents: 67
diff changeset
2406 if (cnode->global.inlined_to)
kono
parents: 67
diff changeset
2407 return false;
kono
parents: 67
diff changeset
2408 return true;
kono
parents: 67
diff changeset
2409 }
kono
parents: 67
diff changeset
2410
kono
parents: 67
diff changeset
2411 /* Return true if DECL should have entry in symbol table if used.
kono
parents: 67
diff changeset
2412 Those are functions and static & external veriables*/
kono
parents: 67
diff changeset
2413
kono
parents: 67
diff changeset
2414 static inline bool
kono
parents: 67
diff changeset
2415 decl_in_symtab_p (const_tree decl)
kono
parents: 67
diff changeset
2416 {
kono
parents: 67
diff changeset
2417 return (TREE_CODE (decl) == FUNCTION_DECL
kono
parents: 67
diff changeset
2418 || (TREE_CODE (decl) == VAR_DECL
kono
parents: 67
diff changeset
2419 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))));
kono
parents: 67
diff changeset
2420 }
kono
parents: 67
diff changeset
2421
kono
parents: 67
diff changeset
2422 inline bool
kono
parents: 67
diff changeset
2423 symtab_node::in_same_comdat_group_p (symtab_node *target)
kono
parents: 67
diff changeset
2424 {
kono
parents: 67
diff changeset
2425 symtab_node *source = this;
kono
parents: 67
diff changeset
2426
kono
parents: 67
diff changeset
2427 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
kono
parents: 67
diff changeset
2428 {
kono
parents: 67
diff changeset
2429 if (cn->global.inlined_to)
kono
parents: 67
diff changeset
2430 source = cn->global.inlined_to;
kono
parents: 67
diff changeset
2431 }
kono
parents: 67
diff changeset
2432 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
kono
parents: 67
diff changeset
2433 {
kono
parents: 67
diff changeset
2434 if (cn->global.inlined_to)
kono
parents: 67
diff changeset
2435 target = cn->global.inlined_to;
kono
parents: 67
diff changeset
2436 }
kono
parents: 67
diff changeset
2437
kono
parents: 67
diff changeset
2438 return source->get_comdat_group () == target->get_comdat_group ();
kono
parents: 67
diff changeset
2439 }
kono
parents: 67
diff changeset
2440
kono
parents: 67
diff changeset
2441 /* Return node that alias is aliasing. */
kono
parents: 67
diff changeset
2442
kono
parents: 67
diff changeset
2443 inline symtab_node *
kono
parents: 67
diff changeset
2444 symtab_node::get_alias_target (void)
kono
parents: 67
diff changeset
2445 {
kono
parents: 67
diff changeset
2446 ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
2447 iterate_reference (0, ref);
kono
parents: 67
diff changeset
2448 if (ref->use == IPA_REF_CHKP)
kono
parents: 67
diff changeset
2449 iterate_reference (1, ref);
kono
parents: 67
diff changeset
2450 gcc_checking_assert (ref->use == IPA_REF_ALIAS);
kono
parents: 67
diff changeset
2451 return ref->referred;
kono
parents: 67
diff changeset
2452 }
kono
parents: 67
diff changeset
2453
kono
parents: 67
diff changeset
2454 /* Return next reachable static symbol with initializer after the node. */
kono
parents: 67
diff changeset
2455
kono
parents: 67
diff changeset
2456 inline symtab_node *
kono
parents: 67
diff changeset
2457 symtab_node::next_defined_symbol (void)
kono
parents: 67
diff changeset
2458 {
kono
parents: 67
diff changeset
2459 symtab_node *node1 = next;
kono
parents: 67
diff changeset
2460
kono
parents: 67
diff changeset
2461 for (; node1; node1 = node1->next)
kono
parents: 67
diff changeset
2462 if (node1->definition)
kono
parents: 67
diff changeset
2463 return node1;
kono
parents: 67
diff changeset
2464
kono
parents: 67
diff changeset
2465 return NULL;
kono
parents: 67
diff changeset
2466 }
kono
parents: 67
diff changeset
2467
kono
parents: 67
diff changeset
2468 /* Iterates I-th reference in the list, REF is also set. */
kono
parents: 67
diff changeset
2469
kono
parents: 67
diff changeset
2470 inline ipa_ref *
kono
parents: 67
diff changeset
2471 symtab_node::iterate_reference (unsigned i, ipa_ref *&ref)
kono
parents: 67
diff changeset
2472 {
kono
parents: 67
diff changeset
2473 vec_safe_iterate (ref_list.references, i, &ref);
kono
parents: 67
diff changeset
2474
kono
parents: 67
diff changeset
2475 return ref;
kono
parents: 67
diff changeset
2476 }
kono
parents: 67
diff changeset
2477
kono
parents: 67
diff changeset
2478 /* Iterates I-th referring item in the list, REF is also set. */
kono
parents: 67
diff changeset
2479
kono
parents: 67
diff changeset
2480 inline ipa_ref *
kono
parents: 67
diff changeset
2481 symtab_node::iterate_referring (unsigned i, ipa_ref *&ref)
kono
parents: 67
diff changeset
2482 {
kono
parents: 67
diff changeset
2483 ref_list.referring.iterate (i, &ref);
kono
parents: 67
diff changeset
2484
kono
parents: 67
diff changeset
2485 return ref;
kono
parents: 67
diff changeset
2486 }
kono
parents: 67
diff changeset
2487
kono
parents: 67
diff changeset
2488 /* Iterates I-th referring alias item in the list, REF is also set. */
kono
parents: 67
diff changeset
2489
kono
parents: 67
diff changeset
2490 inline ipa_ref *
kono
parents: 67
diff changeset
2491 symtab_node::iterate_direct_aliases (unsigned i, ipa_ref *&ref)
kono
parents: 67
diff changeset
2492 {
kono
parents: 67
diff changeset
2493 ref_list.referring.iterate (i, &ref);
kono
parents: 67
diff changeset
2494
kono
parents: 67
diff changeset
2495 if (ref && ref->use != IPA_REF_ALIAS)
kono
parents: 67
diff changeset
2496 return NULL;
kono
parents: 67
diff changeset
2497
kono
parents: 67
diff changeset
2498 return ref;
kono
parents: 67
diff changeset
2499 }
kono
parents: 67
diff changeset
2500
kono
parents: 67
diff changeset
2501 /* Return true if list contains an alias. */
kono
parents: 67
diff changeset
2502
kono
parents: 67
diff changeset
2503 inline bool
kono
parents: 67
diff changeset
2504 symtab_node::has_aliases_p (void)
kono
parents: 67
diff changeset
2505 {
kono
parents: 67
diff changeset
2506 ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
2507
kono
parents: 67
diff changeset
2508 return (iterate_direct_aliases (0, ref) != NULL);
kono
parents: 67
diff changeset
2509 }
kono
parents: 67
diff changeset
2510
kono
parents: 67
diff changeset
2511 /* Return true when RESOLUTION indicate that linker will use
kono
parents: 67
diff changeset
2512 the symbol from non-LTO object files. */
kono
parents: 67
diff changeset
2513
kono
parents: 67
diff changeset
2514 inline bool
kono
parents: 67
diff changeset
2515 resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
kono
parents: 67
diff changeset
2516 {
kono
parents: 67
diff changeset
2517 return (resolution == LDPR_PREVAILING_DEF
kono
parents: 67
diff changeset
2518 || resolution == LDPR_PREEMPTED_REG
kono
parents: 67
diff changeset
2519 || resolution == LDPR_RESOLVED_EXEC
kono
parents: 67
diff changeset
2520 || resolution == LDPR_RESOLVED_DYN);
kono
parents: 67
diff changeset
2521 }
kono
parents: 67
diff changeset
2522
kono
parents: 67
diff changeset
2523 /* Return true when symtab_node is known to be used from other (non-LTO)
kono
parents: 67
diff changeset
2524 object file. Known only when doing LTO via linker plugin. */
kono
parents: 67
diff changeset
2525
kono
parents: 67
diff changeset
2526 inline bool
kono
parents: 67
diff changeset
2527 symtab_node::used_from_object_file_p (void)
kono
parents: 67
diff changeset
2528 {
kono
parents: 67
diff changeset
2529 if (!TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
kono
parents: 67
diff changeset
2530 return false;
kono
parents: 67
diff changeset
2531 if (resolution_used_from_other_file_p (resolution))
kono
parents: 67
diff changeset
2532 return true;
kono
parents: 67
diff changeset
2533 return false;
kono
parents: 67
diff changeset
2534 }
kono
parents: 67
diff changeset
2535
kono
parents: 67
diff changeset
2536 /* Return varpool node for given symbol and check it is a function. */
kono
parents: 67
diff changeset
2537
kono
parents: 67
diff changeset
2538 inline varpool_node *
kono
parents: 67
diff changeset
2539 varpool_node::get (const_tree decl)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2540 {
111
kono
parents: 67
diff changeset
2541 gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
kono
parents: 67
diff changeset
2542 return dyn_cast<varpool_node *> (symtab_node::get (decl));
kono
parents: 67
diff changeset
2543 }
kono
parents: 67
diff changeset
2544
kono
parents: 67
diff changeset
2545 /* Register a symbol NODE. */
kono
parents: 67
diff changeset
2546
kono
parents: 67
diff changeset
2547 inline void
kono
parents: 67
diff changeset
2548 symbol_table::register_symbol (symtab_node *node)
kono
parents: 67
diff changeset
2549 {
kono
parents: 67
diff changeset
2550 node->next = nodes;
kono
parents: 67
diff changeset
2551 node->previous = NULL;
kono
parents: 67
diff changeset
2552
kono
parents: 67
diff changeset
2553 if (nodes)
kono
parents: 67
diff changeset
2554 nodes->previous = node;
kono
parents: 67
diff changeset
2555 nodes = node;
kono
parents: 67
diff changeset
2556
kono
parents: 67
diff changeset
2557 node->order = order++;
kono
parents: 67
diff changeset
2558 }
kono
parents: 67
diff changeset
2559
kono
parents: 67
diff changeset
2560 /* Register a top-level asm statement ASM_STR. */
kono
parents: 67
diff changeset
2561
kono
parents: 67
diff changeset
2562 asm_node *
kono
parents: 67
diff changeset
2563 symbol_table::finalize_toplevel_asm (tree asm_str)
kono
parents: 67
diff changeset
2564 {
kono
parents: 67
diff changeset
2565 asm_node *node;
kono
parents: 67
diff changeset
2566
kono
parents: 67
diff changeset
2567 node = ggc_cleared_alloc<asm_node> ();
kono
parents: 67
diff changeset
2568 node->asm_str = asm_str;
kono
parents: 67
diff changeset
2569 node->order = order++;
kono
parents: 67
diff changeset
2570 node->next = NULL;
kono
parents: 67
diff changeset
2571
kono
parents: 67
diff changeset
2572 if (asmnodes == NULL)
kono
parents: 67
diff changeset
2573 asmnodes = node;
kono
parents: 67
diff changeset
2574 else
kono
parents: 67
diff changeset
2575 asm_last_node->next = node;
kono
parents: 67
diff changeset
2576
kono
parents: 67
diff changeset
2577 asm_last_node = node;
kono
parents: 67
diff changeset
2578 return node;
kono
parents: 67
diff changeset
2579 }
kono
parents: 67
diff changeset
2580
kono
parents: 67
diff changeset
2581 /* Unregister a symbol NODE. */
kono
parents: 67
diff changeset
2582 inline void
kono
parents: 67
diff changeset
2583 symbol_table::unregister (symtab_node *node)
kono
parents: 67
diff changeset
2584 {
kono
parents: 67
diff changeset
2585 if (node->previous)
kono
parents: 67
diff changeset
2586 node->previous->next = node->next;
kono
parents: 67
diff changeset
2587 else
kono
parents: 67
diff changeset
2588 nodes = node->next;
kono
parents: 67
diff changeset
2589
kono
parents: 67
diff changeset
2590 if (node->next)
kono
parents: 67
diff changeset
2591 node->next->previous = node->previous;
kono
parents: 67
diff changeset
2592
kono
parents: 67
diff changeset
2593 node->next = NULL;
kono
parents: 67
diff changeset
2594 node->previous = NULL;
kono
parents: 67
diff changeset
2595 }
kono
parents: 67
diff changeset
2596
kono
parents: 67
diff changeset
2597 /* Release a callgraph NODE with UID and put in to the list of free nodes. */
kono
parents: 67
diff changeset
2598
kono
parents: 67
diff changeset
2599 inline void
kono
parents: 67
diff changeset
2600 symbol_table::release_symbol (cgraph_node *node, int uid)
kono
parents: 67
diff changeset
2601 {
kono
parents: 67
diff changeset
2602 cgraph_count--;
kono
parents: 67
diff changeset
2603
kono
parents: 67
diff changeset
2604 /* Clear out the node to NULL all pointers and add the node to the free
kono
parents: 67
diff changeset
2605 list. */
kono
parents: 67
diff changeset
2606 memset (node, 0, sizeof (*node));
kono
parents: 67
diff changeset
2607 node->type = SYMTAB_FUNCTION;
kono
parents: 67
diff changeset
2608 node->uid = uid;
kono
parents: 67
diff changeset
2609 SET_NEXT_FREE_NODE (node, free_nodes);
kono
parents: 67
diff changeset
2610 free_nodes = node;
kono
parents: 67
diff changeset
2611 }
kono
parents: 67
diff changeset
2612
kono
parents: 67
diff changeset
2613 /* Allocate new callgraph node. */
kono
parents: 67
diff changeset
2614
kono
parents: 67
diff changeset
2615 inline cgraph_node *
kono
parents: 67
diff changeset
2616 symbol_table::allocate_cgraph_symbol (void)
kono
parents: 67
diff changeset
2617 {
kono
parents: 67
diff changeset
2618 cgraph_node *node;
kono
parents: 67
diff changeset
2619
kono
parents: 67
diff changeset
2620 if (free_nodes)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2621 {
111
kono
parents: 67
diff changeset
2622 node = free_nodes;
kono
parents: 67
diff changeset
2623 free_nodes = NEXT_FREE_NODE (node);
kono
parents: 67
diff changeset
2624 }
kono
parents: 67
diff changeset
2625 else
kono
parents: 67
diff changeset
2626 {
kono
parents: 67
diff changeset
2627 node = ggc_cleared_alloc<cgraph_node> ();
kono
parents: 67
diff changeset
2628 node->uid = cgraph_max_uid++;
kono
parents: 67
diff changeset
2629 }
kono
parents: 67
diff changeset
2630
kono
parents: 67
diff changeset
2631 node->summary_uid = cgraph_max_summary_uid++;
kono
parents: 67
diff changeset
2632 return node;
kono
parents: 67
diff changeset
2633 }
kono
parents: 67
diff changeset
2634
kono
parents: 67
diff changeset
2635
kono
parents: 67
diff changeset
2636 /* Return first static symbol with definition. */
kono
parents: 67
diff changeset
2637 inline symtab_node *
kono
parents: 67
diff changeset
2638 symbol_table::first_symbol (void)
kono
parents: 67
diff changeset
2639 {
kono
parents: 67
diff changeset
2640 return nodes;
kono
parents: 67
diff changeset
2641 }
kono
parents: 67
diff changeset
2642
kono
parents: 67
diff changeset
2643 /* Walk all symbols. */
kono
parents: 67
diff changeset
2644 #define FOR_EACH_SYMBOL(node) \
kono
parents: 67
diff changeset
2645 for ((node) = symtab->first_symbol (); (node); (node) = (node)->next)
kono
parents: 67
diff changeset
2646
kono
parents: 67
diff changeset
2647 /* Return first static symbol with definition. */
kono
parents: 67
diff changeset
2648 inline symtab_node *
kono
parents: 67
diff changeset
2649 symbol_table::first_defined_symbol (void)
kono
parents: 67
diff changeset
2650 {
kono
parents: 67
diff changeset
2651 symtab_node *node;
kono
parents: 67
diff changeset
2652
kono
parents: 67
diff changeset
2653 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2654 if (node->definition)
kono
parents: 67
diff changeset
2655 return node;
kono
parents: 67
diff changeset
2656
kono
parents: 67
diff changeset
2657 return NULL;
kono
parents: 67
diff changeset
2658 }
kono
parents: 67
diff changeset
2659
kono
parents: 67
diff changeset
2660 /* Walk all symbols with definitions in current unit. */
kono
parents: 67
diff changeset
2661 #define FOR_EACH_DEFINED_SYMBOL(node) \
kono
parents: 67
diff changeset
2662 for ((node) = symtab->first_defined_symbol (); (node); \
kono
parents: 67
diff changeset
2663 (node) = node->next_defined_symbol ())
kono
parents: 67
diff changeset
2664
kono
parents: 67
diff changeset
2665 /* Return first variable. */
kono
parents: 67
diff changeset
2666 inline varpool_node *
kono
parents: 67
diff changeset
2667 symbol_table::first_variable (void)
kono
parents: 67
diff changeset
2668 {
kono
parents: 67
diff changeset
2669 symtab_node *node;
kono
parents: 67
diff changeset
2670 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2671 if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
kono
parents: 67
diff changeset
2672 return vnode;
kono
parents: 67
diff changeset
2673 return NULL;
kono
parents: 67
diff changeset
2674 }
kono
parents: 67
diff changeset
2675
kono
parents: 67
diff changeset
2676 /* Return next variable after NODE. */
kono
parents: 67
diff changeset
2677 inline varpool_node *
kono
parents: 67
diff changeset
2678 symbol_table::next_variable (varpool_node *node)
kono
parents: 67
diff changeset
2679 {
kono
parents: 67
diff changeset
2680 symtab_node *node1 = node->next;
kono
parents: 67
diff changeset
2681 for (; node1; node1 = node1->next)
kono
parents: 67
diff changeset
2682 if (varpool_node *vnode1 = dyn_cast <varpool_node *> (node1))
kono
parents: 67
diff changeset
2683 return vnode1;
kono
parents: 67
diff changeset
2684 return NULL;
kono
parents: 67
diff changeset
2685 }
kono
parents: 67
diff changeset
2686 /* Walk all variables. */
kono
parents: 67
diff changeset
2687 #define FOR_EACH_VARIABLE(node) \
kono
parents: 67
diff changeset
2688 for ((node) = symtab->first_variable (); \
kono
parents: 67
diff changeset
2689 (node); \
kono
parents: 67
diff changeset
2690 (node) = symtab->next_variable ((node)))
kono
parents: 67
diff changeset
2691
kono
parents: 67
diff changeset
2692 /* Return first static variable with initializer. */
kono
parents: 67
diff changeset
2693 inline varpool_node *
kono
parents: 67
diff changeset
2694 symbol_table::first_static_initializer (void)
kono
parents: 67
diff changeset
2695 {
kono
parents: 67
diff changeset
2696 symtab_node *node;
kono
parents: 67
diff changeset
2697 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2698 {
kono
parents: 67
diff changeset
2699 varpool_node *vnode = dyn_cast <varpool_node *> (node);
kono
parents: 67
diff changeset
2700 if (vnode && DECL_INITIAL (node->decl))
kono
parents: 67
diff changeset
2701 return vnode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2702 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2703 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2704 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2705
111
kono
parents: 67
diff changeset
2706 /* Return next static variable with initializer after NODE. */
kono
parents: 67
diff changeset
2707 inline varpool_node *
kono
parents: 67
diff changeset
2708 symbol_table::next_static_initializer (varpool_node *node)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2709 {
111
kono
parents: 67
diff changeset
2710 symtab_node *node1 = node->next;
kono
parents: 67
diff changeset
2711 for (; node1; node1 = node1->next)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2712 {
111
kono
parents: 67
diff changeset
2713 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
kono
parents: 67
diff changeset
2714 if (vnode1 && DECL_INITIAL (node1->decl))
kono
parents: 67
diff changeset
2715 return vnode1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2716 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2717 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2718 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2719
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2720 /* Walk all static variables with initializer set. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2721 #define FOR_EACH_STATIC_INITIALIZER(node) \
111
kono
parents: 67
diff changeset
2722 for ((node) = symtab->first_static_initializer (); (node); \
kono
parents: 67
diff changeset
2723 (node) = symtab->next_static_initializer (node))
kono
parents: 67
diff changeset
2724
kono
parents: 67
diff changeset
2725 /* Return first static variable with definition. */
kono
parents: 67
diff changeset
2726 inline varpool_node *
kono
parents: 67
diff changeset
2727 symbol_table::first_defined_variable (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2728 {
111
kono
parents: 67
diff changeset
2729 symtab_node *node;
kono
parents: 67
diff changeset
2730 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2731 {
kono
parents: 67
diff changeset
2732 varpool_node *vnode = dyn_cast <varpool_node *> (node);
kono
parents: 67
diff changeset
2733 if (vnode && vnode->definition)
kono
parents: 67
diff changeset
2734 return vnode;
kono
parents: 67
diff changeset
2735 }
kono
parents: 67
diff changeset
2736 return NULL;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2737 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2738
111
kono
parents: 67
diff changeset
2739 /* Return next static variable with definition after NODE. */
kono
parents: 67
diff changeset
2740 inline varpool_node *
kono
parents: 67
diff changeset
2741 symbol_table::next_defined_variable (varpool_node *node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2742 {
111
kono
parents: 67
diff changeset
2743 symtab_node *node1 = node->next;
kono
parents: 67
diff changeset
2744 for (; node1; node1 = node1->next)
kono
parents: 67
diff changeset
2745 {
kono
parents: 67
diff changeset
2746 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
kono
parents: 67
diff changeset
2747 if (vnode1 && vnode1->definition)
kono
parents: 67
diff changeset
2748 return vnode1;
kono
parents: 67
diff changeset
2749 }
kono
parents: 67
diff changeset
2750 return NULL;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2751 }
111
kono
parents: 67
diff changeset
2752 /* Walk all variables with definitions in current unit. */
kono
parents: 67
diff changeset
2753 #define FOR_EACH_DEFINED_VARIABLE(node) \
kono
parents: 67
diff changeset
2754 for ((node) = symtab->first_defined_variable (); (node); \
kono
parents: 67
diff changeset
2755 (node) = symtab->next_defined_variable (node))
kono
parents: 67
diff changeset
2756
kono
parents: 67
diff changeset
2757 /* Return first function with body defined. */
kono
parents: 67
diff changeset
2758 inline cgraph_node *
kono
parents: 67
diff changeset
2759 symbol_table::first_defined_function (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2760 {
111
kono
parents: 67
diff changeset
2761 symtab_node *node;
kono
parents: 67
diff changeset
2762 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2763 {
kono
parents: 67
diff changeset
2764 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
2765 if (cn && cn->definition)
kono
parents: 67
diff changeset
2766 return cn;
kono
parents: 67
diff changeset
2767 }
kono
parents: 67
diff changeset
2768 return NULL;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2769 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2770
111
kono
parents: 67
diff changeset
2771 /* Return next function with body defined after NODE. */
kono
parents: 67
diff changeset
2772 inline cgraph_node *
kono
parents: 67
diff changeset
2773 symbol_table::next_defined_function (cgraph_node *node)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2774 {
111
kono
parents: 67
diff changeset
2775 symtab_node *node1 = node->next;
kono
parents: 67
diff changeset
2776 for (; node1; node1 = node1->next)
kono
parents: 67
diff changeset
2777 {
kono
parents: 67
diff changeset
2778 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
kono
parents: 67
diff changeset
2779 if (cn1 && cn1->definition)
kono
parents: 67
diff changeset
2780 return cn1;
kono
parents: 67
diff changeset
2781 }
kono
parents: 67
diff changeset
2782 return NULL;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2783 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2784
111
kono
parents: 67
diff changeset
2785 /* Walk all functions with body defined. */
kono
parents: 67
diff changeset
2786 #define FOR_EACH_DEFINED_FUNCTION(node) \
kono
parents: 67
diff changeset
2787 for ((node) = symtab->first_defined_function (); (node); \
kono
parents: 67
diff changeset
2788 (node) = symtab->next_defined_function ((node)))
kono
parents: 67
diff changeset
2789
kono
parents: 67
diff changeset
2790 /* Return first function. */
kono
parents: 67
diff changeset
2791 inline cgraph_node *
kono
parents: 67
diff changeset
2792 symbol_table::first_function (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2793 {
111
kono
parents: 67
diff changeset
2794 symtab_node *node;
kono
parents: 67
diff changeset
2795 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2796 if (cgraph_node *cn = dyn_cast <cgraph_node *> (node))
kono
parents: 67
diff changeset
2797 return cn;
kono
parents: 67
diff changeset
2798 return NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2799 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2800
111
kono
parents: 67
diff changeset
2801 /* Return next function. */
kono
parents: 67
diff changeset
2802 inline cgraph_node *
kono
parents: 67
diff changeset
2803 symbol_table::next_function (cgraph_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2804 {
111
kono
parents: 67
diff changeset
2805 symtab_node *node1 = node->next;
kono
parents: 67
diff changeset
2806 for (; node1; node1 = node1->next)
kono
parents: 67
diff changeset
2807 if (cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1))
kono
parents: 67
diff changeset
2808 return cn1;
kono
parents: 67
diff changeset
2809 return NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2810 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2811
111
kono
parents: 67
diff changeset
2812 /* Return first function with body defined. */
kono
parents: 67
diff changeset
2813 inline cgraph_node *
kono
parents: 67
diff changeset
2814 symbol_table::first_function_with_gimple_body (void)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2815 {
111
kono
parents: 67
diff changeset
2816 symtab_node *node;
kono
parents: 67
diff changeset
2817 for (node = nodes; node; node = node->next)
kono
parents: 67
diff changeset
2818 {
kono
parents: 67
diff changeset
2819 cgraph_node *cn = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
2820 if (cn && cn->has_gimple_body_p ())
kono
parents: 67
diff changeset
2821 return cn;
kono
parents: 67
diff changeset
2822 }
kono
parents: 67
diff changeset
2823 return NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2824 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2825
111
kono
parents: 67
diff changeset
2826 /* Return next reachable static variable with initializer after NODE. */
kono
parents: 67
diff changeset
2827 inline cgraph_node *
kono
parents: 67
diff changeset
2828 symbol_table::next_function_with_gimple_body (cgraph_node *node)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2829 {
111
kono
parents: 67
diff changeset
2830 symtab_node *node1 = node->next;
kono
parents: 67
diff changeset
2831 for (; node1; node1 = node1->next)
kono
parents: 67
diff changeset
2832 {
kono
parents: 67
diff changeset
2833 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
kono
parents: 67
diff changeset
2834 if (cn1 && cn1->has_gimple_body_p ())
kono
parents: 67
diff changeset
2835 return cn1;
kono
parents: 67
diff changeset
2836 }
kono
parents: 67
diff changeset
2837 return NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2838 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2839
111
kono
parents: 67
diff changeset
2840 /* Walk all functions. */
kono
parents: 67
diff changeset
2841 #define FOR_EACH_FUNCTION(node) \
kono
parents: 67
diff changeset
2842 for ((node) = symtab->first_function (); (node); \
kono
parents: 67
diff changeset
2843 (node) = symtab->next_function ((node)))
kono
parents: 67
diff changeset
2844
kono
parents: 67
diff changeset
2845 /* Return true when callgraph node is a function with Gimple body defined
kono
parents: 67
diff changeset
2846 in current unit. Functions can also be define externally or they
kono
parents: 67
diff changeset
2847 can be thunks with no Gimple representation.
kono
parents: 67
diff changeset
2848
kono
parents: 67
diff changeset
2849 Note that at WPA stage, the function body may not be present in memory. */
kono
parents: 67
diff changeset
2850
kono
parents: 67
diff changeset
2851 inline bool
kono
parents: 67
diff changeset
2852 cgraph_node::has_gimple_body_p (void)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2853 {
111
kono
parents: 67
diff changeset
2854 return definition && !thunk.thunk_p && !alias;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2855 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2856
111
kono
parents: 67
diff changeset
2857 /* Walk all functions with body defined. */
kono
parents: 67
diff changeset
2858 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
kono
parents: 67
diff changeset
2859 for ((node) = symtab->first_function_with_gimple_body (); (node); \
kono
parents: 67
diff changeset
2860 (node) = symtab->next_function_with_gimple_body (node))
kono
parents: 67
diff changeset
2861
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2862 /* Uniquize all constants that appear in memory.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2863 Each constant in memory thus far output is recorded
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2864 in `const_desc_table'. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2865
111
kono
parents: 67
diff changeset
2866 struct GTY((for_user)) constant_descriptor_tree {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2867 /* A MEM for the constant. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2868 rtx rtl;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2869
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2870 /* The value of the constant. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2871 tree value;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2872
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2873 /* Hash of value. Computing the hash from value each time
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2874 hashfn is called can't work properly, as that means recursive
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2875 use of the hash table during hash table expansion. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2876 hashval_t hash;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2877 };
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2878
111
kono
parents: 67
diff changeset
2879 /* Return true when function is only called directly or it has alias.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2880 i.e. it is not externally visible, address was not taken and
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2881 it is not used in any other non-standard way. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2882
111
kono
parents: 67
diff changeset
2883 inline bool
kono
parents: 67
diff changeset
2884 cgraph_node::only_called_directly_or_aliased_p (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2885 {
111
kono
parents: 67
diff changeset
2886 gcc_assert (!global.inlined_to);
kono
parents: 67
diff changeset
2887 return (!force_output && !address_taken
kono
parents: 67
diff changeset
2888 && !used_from_other_partition
kono
parents: 67
diff changeset
2889 && !DECL_VIRTUAL_P (decl)
kono
parents: 67
diff changeset
2890 && !DECL_STATIC_CONSTRUCTOR (decl)
kono
parents: 67
diff changeset
2891 && !DECL_STATIC_DESTRUCTOR (decl)
kono
parents: 67
diff changeset
2892 && !used_from_object_file_p ()
kono
parents: 67
diff changeset
2893 && !externally_visible);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2894 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2895
111
kono
parents: 67
diff changeset
2896 /* Return true when function can be removed from callgraph
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2897 if all direct calls are eliminated. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2898
111
kono
parents: 67
diff changeset
2899 inline bool
kono
parents: 67
diff changeset
2900 cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2901 {
111
kono
parents: 67
diff changeset
2902 gcc_checking_assert (!global.inlined_to);
kono
parents: 67
diff changeset
2903 /* Instrumentation clones should not be removed before
kono
parents: 67
diff changeset
2904 instrumentation happens. New callers may appear after
kono
parents: 67
diff changeset
2905 instrumentation. */
kono
parents: 67
diff changeset
2906 if (instrumentation_clone
kono
parents: 67
diff changeset
2907 && !chkp_function_instrumented_p (decl))
kono
parents: 67
diff changeset
2908 return false;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2909 /* Extern inlines can always go, we will use the external definition. */
111
kono
parents: 67
diff changeset
2910 if (DECL_EXTERNAL (decl))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2911 return true;
111
kono
parents: 67
diff changeset
2912 /* When function is needed, we can not remove it. */
kono
parents: 67
diff changeset
2913 if (force_output || used_from_other_partition)
kono
parents: 67
diff changeset
2914 return false;
kono
parents: 67
diff changeset
2915 if (DECL_STATIC_CONSTRUCTOR (decl)
kono
parents: 67
diff changeset
2916 || DECL_STATIC_DESTRUCTOR (decl))
kono
parents: 67
diff changeset
2917 return false;
kono
parents: 67
diff changeset
2918 /* Only COMDAT functions can be removed if externally visible. */
kono
parents: 67
diff changeset
2919 if (externally_visible
kono
parents: 67
diff changeset
2920 && (!DECL_COMDAT (decl)
kono
parents: 67
diff changeset
2921 || forced_by_abi
kono
parents: 67
diff changeset
2922 || used_from_object_file_p ()))
kono
parents: 67
diff changeset
2923 return false;
kono
parents: 67
diff changeset
2924 return true;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2925 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2926
111
kono
parents: 67
diff changeset
2927 /* Verify cgraph, if consistency checking is enabled. */
kono
parents: 67
diff changeset
2928
kono
parents: 67
diff changeset
2929 inline void
kono
parents: 67
diff changeset
2930 cgraph_node::checking_verify_cgraph_nodes (void)
kono
parents: 67
diff changeset
2931 {
kono
parents: 67
diff changeset
2932 if (flag_checking)
kono
parents: 67
diff changeset
2933 cgraph_node::verify_cgraph_nodes ();
kono
parents: 67
diff changeset
2934 }
kono
parents: 67
diff changeset
2935
kono
parents: 67
diff changeset
2936 /* Return true when variable can be removed from variable pool
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2937 if all direct calls are eliminated. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2938
111
kono
parents: 67
diff changeset
2939 inline bool
kono
parents: 67
diff changeset
2940 varpool_node::can_remove_if_no_refs_p (void)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2941 {
111
kono
parents: 67
diff changeset
2942 if (DECL_EXTERNAL (decl))
kono
parents: 67
diff changeset
2943 return true;
kono
parents: 67
diff changeset
2944 return (!force_output && !used_from_other_partition
kono
parents: 67
diff changeset
2945 && ((DECL_COMDAT (decl)
kono
parents: 67
diff changeset
2946 && !forced_by_abi
kono
parents: 67
diff changeset
2947 && !used_from_object_file_p ())
kono
parents: 67
diff changeset
2948 || !externally_visible
kono
parents: 67
diff changeset
2949 || DECL_HAS_VALUE_EXPR_P (decl)));
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2950 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2951
111
kono
parents: 67
diff changeset
2952 /* Return true when all references to variable must be visible in ipa_ref_list.
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2953 i.e. if the variable is not externally visible or not used in some magic
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2954 way (asm statement or such).
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
2955 The magic uses are all summarized in force_output flag. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2956
111
kono
parents: 67
diff changeset
2957 inline bool
kono
parents: 67
diff changeset
2958 varpool_node::all_refs_explicit_p ()
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
2959 {
111
kono
parents: 67
diff changeset
2960 return (definition
kono
parents: 67
diff changeset
2961 && !externally_visible
kono
parents: 67
diff changeset
2962 && !used_from_other_partition
kono
parents: 67
diff changeset
2963 && !force_output);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2964 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2965
111
kono
parents: 67
diff changeset
2966 struct tree_descriptor_hasher : ggc_ptr_hash<constant_descriptor_tree>
kono
parents: 67
diff changeset
2967 {
kono
parents: 67
diff changeset
2968 static hashval_t hash (constant_descriptor_tree *);
kono
parents: 67
diff changeset
2969 static bool equal (constant_descriptor_tree *, constant_descriptor_tree *);
kono
parents: 67
diff changeset
2970 };
kono
parents: 67
diff changeset
2971
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
2972 /* Constant pool accessor function. */
111
kono
parents: 67
diff changeset
2973 hash_table<tree_descriptor_hasher> *constant_pool_htab (void);
kono
parents: 67
diff changeset
2974
kono
parents: 67
diff changeset
2975 /* Return node that alias is aliasing. */
kono
parents: 67
diff changeset
2976
kono
parents: 67
diff changeset
2977 inline cgraph_node *
kono
parents: 67
diff changeset
2978 cgraph_node::get_alias_target (void)
kono
parents: 67
diff changeset
2979 {
kono
parents: 67
diff changeset
2980 return dyn_cast <cgraph_node *> (symtab_node::get_alias_target ());
kono
parents: 67
diff changeset
2981 }
kono
parents: 67
diff changeset
2982
kono
parents: 67
diff changeset
2983 /* Return node that alias is aliasing. */
kono
parents: 67
diff changeset
2984
kono
parents: 67
diff changeset
2985 inline varpool_node *
kono
parents: 67
diff changeset
2986 varpool_node::get_alias_target (void)
kono
parents: 67
diff changeset
2987 {
kono
parents: 67
diff changeset
2988 return dyn_cast <varpool_node *> (symtab_node::get_alias_target ());
kono
parents: 67
diff changeset
2989 }
kono
parents: 67
diff changeset
2990
kono
parents: 67
diff changeset
2991 /* Walk the alias chain to return the symbol NODE is alias of.
kono
parents: 67
diff changeset
2992 If NODE is not an alias, return NODE.
kono
parents: 67
diff changeset
2993 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
2994 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
2995 when determining the availability. */
kono
parents: 67
diff changeset
2996
kono
parents: 67
diff changeset
2997 inline symtab_node *
kono
parents: 67
diff changeset
2998 symtab_node::ultimate_alias_target (enum availability *availability,
kono
parents: 67
diff changeset
2999 symtab_node *ref)
kono
parents: 67
diff changeset
3000 {
kono
parents: 67
diff changeset
3001 if (!alias)
kono
parents: 67
diff changeset
3002 {
kono
parents: 67
diff changeset
3003 if (availability)
kono
parents: 67
diff changeset
3004 *availability = get_availability (ref);
kono
parents: 67
diff changeset
3005 return this;
kono
parents: 67
diff changeset
3006 }
kono
parents: 67
diff changeset
3007
kono
parents: 67
diff changeset
3008 return ultimate_alias_target_1 (availability, ref);
kono
parents: 67
diff changeset
3009 }
kono
parents: 67
diff changeset
3010
kono
parents: 67
diff changeset
3011 /* Given function symbol, walk the alias chain to return the function node
kono
parents: 67
diff changeset
3012 is alias of. Do not walk through thunks.
kono
parents: 67
diff changeset
3013 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
3014 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
3015 when determining the availability. */
kono
parents: 67
diff changeset
3016
kono
parents: 67
diff changeset
3017 inline cgraph_node *
kono
parents: 67
diff changeset
3018 cgraph_node::ultimate_alias_target (enum availability *availability,
kono
parents: 67
diff changeset
3019 symtab_node *ref)
kono
parents: 67
diff changeset
3020 {
kono
parents: 67
diff changeset
3021 cgraph_node *n = dyn_cast <cgraph_node *>
kono
parents: 67
diff changeset
3022 (symtab_node::ultimate_alias_target (availability, ref));
kono
parents: 67
diff changeset
3023 if (!n && availability)
kono
parents: 67
diff changeset
3024 *availability = AVAIL_NOT_AVAILABLE;
kono
parents: 67
diff changeset
3025 return n;
kono
parents: 67
diff changeset
3026 }
kono
parents: 67
diff changeset
3027
kono
parents: 67
diff changeset
3028 /* For given variable pool node, walk the alias chain to return the function
kono
parents: 67
diff changeset
3029 the variable is alias of. Do not walk through thunks.
kono
parents: 67
diff changeset
3030 When AVAILABILITY is non-NULL, get minimal availability in the chain.
kono
parents: 67
diff changeset
3031 When REF is non-NULL, assume that reference happens in symbol REF
kono
parents: 67
diff changeset
3032 when determining the availability. */
kono
parents: 67
diff changeset
3033
kono
parents: 67
diff changeset
3034 inline varpool_node *
kono
parents: 67
diff changeset
3035 varpool_node::ultimate_alias_target (availability *availability,
kono
parents: 67
diff changeset
3036 symtab_node *ref)
kono
parents: 67
diff changeset
3037 {
kono
parents: 67
diff changeset
3038 varpool_node *n = dyn_cast <varpool_node *>
kono
parents: 67
diff changeset
3039 (symtab_node::ultimate_alias_target (availability, ref));
kono
parents: 67
diff changeset
3040
kono
parents: 67
diff changeset
3041 if (!n && availability)
kono
parents: 67
diff changeset
3042 *availability = AVAIL_NOT_AVAILABLE;
kono
parents: 67
diff changeset
3043 return n;
kono
parents: 67
diff changeset
3044 }
kono
parents: 67
diff changeset
3045
kono
parents: 67
diff changeset
3046 /* Set callee N of call graph edge and add it to the corresponding set of
kono
parents: 67
diff changeset
3047 callers. */
kono
parents: 67
diff changeset
3048
kono
parents: 67
diff changeset
3049 inline void
kono
parents: 67
diff changeset
3050 cgraph_edge::set_callee (cgraph_node *n)
kono
parents: 67
diff changeset
3051 {
kono
parents: 67
diff changeset
3052 prev_caller = NULL;
kono
parents: 67
diff changeset
3053 if (n->callers)
kono
parents: 67
diff changeset
3054 n->callers->prev_caller = this;
kono
parents: 67
diff changeset
3055 next_caller = n->callers;
kono
parents: 67
diff changeset
3056 n->callers = this;
kono
parents: 67
diff changeset
3057 callee = n;
kono
parents: 67
diff changeset
3058 }
kono
parents: 67
diff changeset
3059
kono
parents: 67
diff changeset
3060 /* Redirect callee of the edge to N. The function does not update underlying
kono
parents: 67
diff changeset
3061 call expression. */
kono
parents: 67
diff changeset
3062
kono
parents: 67
diff changeset
3063 inline void
kono
parents: 67
diff changeset
3064 cgraph_edge::redirect_callee (cgraph_node *n)
kono
parents: 67
diff changeset
3065 {
kono
parents: 67
diff changeset
3066 /* Remove from callers list of the current callee. */
kono
parents: 67
diff changeset
3067 remove_callee ();
kono
parents: 67
diff changeset
3068
kono
parents: 67
diff changeset
3069 /* Insert to callers list of the new callee. */
kono
parents: 67
diff changeset
3070 set_callee (n);
kono
parents: 67
diff changeset
3071 }
kono
parents: 67
diff changeset
3072
kono
parents: 67
diff changeset
3073 /* Return true when the edge represents a direct recursion. */
kono
parents: 67
diff changeset
3074
kono
parents: 67
diff changeset
3075 inline bool
kono
parents: 67
diff changeset
3076 cgraph_edge::recursive_p (void)
kono
parents: 67
diff changeset
3077 {
kono
parents: 67
diff changeset
3078 cgraph_node *c = callee->ultimate_alias_target ();
kono
parents: 67
diff changeset
3079 if (caller->global.inlined_to)
kono
parents: 67
diff changeset
3080 return caller->global.inlined_to->decl == c->decl;
kono
parents: 67
diff changeset
3081 else
kono
parents: 67
diff changeset
3082 return caller->decl == c->decl;
kono
parents: 67
diff changeset
3083 }
kono
parents: 67
diff changeset
3084
kono
parents: 67
diff changeset
3085 /* Remove the edge from the list of the callers of the callee. */
kono
parents: 67
diff changeset
3086
kono
parents: 67
diff changeset
3087 inline void
kono
parents: 67
diff changeset
3088 cgraph_edge::remove_callee (void)
kono
parents: 67
diff changeset
3089 {
kono
parents: 67
diff changeset
3090 gcc_assert (!indirect_unknown_callee);
kono
parents: 67
diff changeset
3091 if (prev_caller)
kono
parents: 67
diff changeset
3092 prev_caller->next_caller = next_caller;
kono
parents: 67
diff changeset
3093 if (next_caller)
kono
parents: 67
diff changeset
3094 next_caller->prev_caller = prev_caller;
kono
parents: 67
diff changeset
3095 if (!prev_caller)
kono
parents: 67
diff changeset
3096 callee->callers = next_caller;
kono
parents: 67
diff changeset
3097 }
kono
parents: 67
diff changeset
3098
kono
parents: 67
diff changeset
3099 /* Return true if call must bind to current definition. */
kono
parents: 67
diff changeset
3100
kono
parents: 67
diff changeset
3101 inline bool
kono
parents: 67
diff changeset
3102 cgraph_edge::binds_to_current_def_p ()
kono
parents: 67
diff changeset
3103 {
kono
parents: 67
diff changeset
3104 if (callee)
kono
parents: 67
diff changeset
3105 return callee->binds_to_current_def_p (caller);
kono
parents: 67
diff changeset
3106 else
kono
parents: 67
diff changeset
3107 return false;
kono
parents: 67
diff changeset
3108 }
kono
parents: 67
diff changeset
3109
kono
parents: 67
diff changeset
3110 /* Return true if the TM_CLONE bit is set for a given FNDECL. */
kono
parents: 67
diff changeset
3111 static inline bool
kono
parents: 67
diff changeset
3112 decl_is_tm_clone (const_tree fndecl)
kono
parents: 67
diff changeset
3113 {
kono
parents: 67
diff changeset
3114 cgraph_node *n = cgraph_node::get (fndecl);
kono
parents: 67
diff changeset
3115 if (n)
kono
parents: 67
diff changeset
3116 return n->tm_clone;
kono
parents: 67
diff changeset
3117 return false;
kono
parents: 67
diff changeset
3118 }
kono
parents: 67
diff changeset
3119
kono
parents: 67
diff changeset
3120 /* Likewise indicate that a node is needed, i.e. reachable via some
kono
parents: 67
diff changeset
3121 external means. */
kono
parents: 67
diff changeset
3122
kono
parents: 67
diff changeset
3123 inline void
kono
parents: 67
diff changeset
3124 cgraph_node::mark_force_output (void)
kono
parents: 67
diff changeset
3125 {
kono
parents: 67
diff changeset
3126 force_output = 1;
kono
parents: 67
diff changeset
3127 gcc_checking_assert (!global.inlined_to);
kono
parents: 67
diff changeset
3128 }
kono
parents: 67
diff changeset
3129
kono
parents: 67
diff changeset
3130 /* Return true if function should be optimized for size. */
kono
parents: 67
diff changeset
3131
kono
parents: 67
diff changeset
3132 inline bool
kono
parents: 67
diff changeset
3133 cgraph_node::optimize_for_size_p (void)
kono
parents: 67
diff changeset
3134 {
kono
parents: 67
diff changeset
3135 if (opt_for_fn (decl, optimize_size))
kono
parents: 67
diff changeset
3136 return true;
kono
parents: 67
diff changeset
3137 if (frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)
kono
parents: 67
diff changeset
3138 return true;
kono
parents: 67
diff changeset
3139 else
kono
parents: 67
diff changeset
3140 return false;
kono
parents: 67
diff changeset
3141 }
kono
parents: 67
diff changeset
3142
kono
parents: 67
diff changeset
3143 /* Return symtab_node for NODE or create one if it is not present
kono
parents: 67
diff changeset
3144 in symtab. */
kono
parents: 67
diff changeset
3145
kono
parents: 67
diff changeset
3146 inline symtab_node *
kono
parents: 67
diff changeset
3147 symtab_node::get_create (tree node)
kono
parents: 67
diff changeset
3148 {
kono
parents: 67
diff changeset
3149 if (TREE_CODE (node) == VAR_DECL)
kono
parents: 67
diff changeset
3150 return varpool_node::get_create (node);
kono
parents: 67
diff changeset
3151 else
kono
parents: 67
diff changeset
3152 return cgraph_node::get_create (node);
kono
parents: 67
diff changeset
3153 }
kono
parents: 67
diff changeset
3154
kono
parents: 67
diff changeset
3155 /* Return availability of NODE when referenced from REF. */
kono
parents: 67
diff changeset
3156
kono
parents: 67
diff changeset
3157 inline enum availability
kono
parents: 67
diff changeset
3158 symtab_node::get_availability (symtab_node *ref)
kono
parents: 67
diff changeset
3159 {
kono
parents: 67
diff changeset
3160 if (is_a <cgraph_node *> (this))
kono
parents: 67
diff changeset
3161 return dyn_cast <cgraph_node *> (this)->get_availability (ref);
kono
parents: 67
diff changeset
3162 else
kono
parents: 67
diff changeset
3163 return dyn_cast <varpool_node *> (this)->get_availability (ref);
kono
parents: 67
diff changeset
3164 }
kono
parents: 67
diff changeset
3165
kono
parents: 67
diff changeset
3166 /* Call calback on symtab node and aliases associated to this node.
kono
parents: 67
diff changeset
3167 When INCLUDE_OVERWRITABLE is false, overwritable symbols are skipped. */
kono
parents: 67
diff changeset
3168
kono
parents: 67
diff changeset
3169 inline bool
kono
parents: 67
diff changeset
3170 symtab_node::call_for_symbol_and_aliases (bool (*callback) (symtab_node *,
kono
parents: 67
diff changeset
3171 void *),
kono
parents: 67
diff changeset
3172 void *data,
kono
parents: 67
diff changeset
3173 bool include_overwritable)
kono
parents: 67
diff changeset
3174 {
kono
parents: 67
diff changeset
3175 if (include_overwritable
kono
parents: 67
diff changeset
3176 || get_availability () > AVAIL_INTERPOSABLE)
kono
parents: 67
diff changeset
3177 {
kono
parents: 67
diff changeset
3178 if (callback (this, data))
kono
parents: 67
diff changeset
3179 return true;
kono
parents: 67
diff changeset
3180 }
kono
parents: 67
diff changeset
3181 if (has_aliases_p ())
kono
parents: 67
diff changeset
3182 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
kono
parents: 67
diff changeset
3183 return false;
kono
parents: 67
diff changeset
3184 }
kono
parents: 67
diff changeset
3185
kono
parents: 67
diff changeset
3186 /* Call callback on function and aliases associated to the function.
kono
parents: 67
diff changeset
3187 When INCLUDE_OVERWRITABLE is false, overwritable symbols are
kono
parents: 67
diff changeset
3188 skipped. */
kono
parents: 67
diff changeset
3189
kono
parents: 67
diff changeset
3190 inline bool
kono
parents: 67
diff changeset
3191 cgraph_node::call_for_symbol_and_aliases (bool (*callback) (cgraph_node *,
kono
parents: 67
diff changeset
3192 void *),
kono
parents: 67
diff changeset
3193 void *data,
kono
parents: 67
diff changeset
3194 bool include_overwritable)
kono
parents: 67
diff changeset
3195 {
kono
parents: 67
diff changeset
3196 if (include_overwritable
kono
parents: 67
diff changeset
3197 || get_availability () > AVAIL_INTERPOSABLE)
kono
parents: 67
diff changeset
3198 {
kono
parents: 67
diff changeset
3199 if (callback (this, data))
kono
parents: 67
diff changeset
3200 return true;
kono
parents: 67
diff changeset
3201 }
kono
parents: 67
diff changeset
3202 if (has_aliases_p ())
kono
parents: 67
diff changeset
3203 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
kono
parents: 67
diff changeset
3204 return false;
kono
parents: 67
diff changeset
3205 }
kono
parents: 67
diff changeset
3206
kono
parents: 67
diff changeset
3207 /* Call calback on varpool symbol and aliases associated to varpool symbol.
kono
parents: 67
diff changeset
3208 When INCLUDE_OVERWRITABLE is false, overwritable symbols are
kono
parents: 67
diff changeset
3209 skipped. */
kono
parents: 67
diff changeset
3210
kono
parents: 67
diff changeset
3211 inline bool
kono
parents: 67
diff changeset
3212 varpool_node::call_for_symbol_and_aliases (bool (*callback) (varpool_node *,
kono
parents: 67
diff changeset
3213 void *),
kono
parents: 67
diff changeset
3214 void *data,
kono
parents: 67
diff changeset
3215 bool include_overwritable)
kono
parents: 67
diff changeset
3216 {
kono
parents: 67
diff changeset
3217 if (include_overwritable
kono
parents: 67
diff changeset
3218 || get_availability () > AVAIL_INTERPOSABLE)
kono
parents: 67
diff changeset
3219 {
kono
parents: 67
diff changeset
3220 if (callback (this, data))
kono
parents: 67
diff changeset
3221 return true;
kono
parents: 67
diff changeset
3222 }
kono
parents: 67
diff changeset
3223 if (has_aliases_p ())
kono
parents: 67
diff changeset
3224 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
kono
parents: 67
diff changeset
3225 return false;
kono
parents: 67
diff changeset
3226 }
kono
parents: 67
diff changeset
3227
kono
parents: 67
diff changeset
3228 /* Return true if refernece may be used in address compare. */
kono
parents: 67
diff changeset
3229
kono
parents: 67
diff changeset
3230 inline bool
kono
parents: 67
diff changeset
3231 ipa_ref::address_matters_p ()
kono
parents: 67
diff changeset
3232 {
kono
parents: 67
diff changeset
3233 if (use != IPA_REF_ADDR)
kono
parents: 67
diff changeset
3234 return false;
kono
parents: 67
diff changeset
3235 /* Addresses taken from virtual tables are never compared. */
kono
parents: 67
diff changeset
3236 if (is_a <varpool_node *> (referring)
kono
parents: 67
diff changeset
3237 && DECL_VIRTUAL_P (referring->decl))
kono
parents: 67
diff changeset
3238 return false;
kono
parents: 67
diff changeset
3239 return referred->address_can_be_compared_p ();
kono
parents: 67
diff changeset
3240 }
kono
parents: 67
diff changeset
3241
kono
parents: 67
diff changeset
3242 /* Build polymorphic call context for indirect call E. */
kono
parents: 67
diff changeset
3243
kono
parents: 67
diff changeset
3244 inline
kono
parents: 67
diff changeset
3245 ipa_polymorphic_call_context::ipa_polymorphic_call_context (cgraph_edge *e)
kono
parents: 67
diff changeset
3246 {
kono
parents: 67
diff changeset
3247 gcc_checking_assert (e->indirect_info->polymorphic);
kono
parents: 67
diff changeset
3248 *this = e->indirect_info->context;
kono
parents: 67
diff changeset
3249 }
kono
parents: 67
diff changeset
3250
kono
parents: 67
diff changeset
3251 /* Build empty "I know nothing" context. */
kono
parents: 67
diff changeset
3252
kono
parents: 67
diff changeset
3253 inline
kono
parents: 67
diff changeset
3254 ipa_polymorphic_call_context::ipa_polymorphic_call_context ()
kono
parents: 67
diff changeset
3255 {
kono
parents: 67
diff changeset
3256 clear_speculation ();
kono
parents: 67
diff changeset
3257 clear_outer_type ();
kono
parents: 67
diff changeset
3258 invalid = false;
kono
parents: 67
diff changeset
3259 }
kono
parents: 67
diff changeset
3260
kono
parents: 67
diff changeset
3261 /* Make context non-speculative. */
kono
parents: 67
diff changeset
3262
kono
parents: 67
diff changeset
3263 inline void
kono
parents: 67
diff changeset
3264 ipa_polymorphic_call_context::clear_speculation ()
kono
parents: 67
diff changeset
3265 {
kono
parents: 67
diff changeset
3266 speculative_outer_type = NULL;
kono
parents: 67
diff changeset
3267 speculative_offset = 0;
kono
parents: 67
diff changeset
3268 speculative_maybe_derived_type = false;
kono
parents: 67
diff changeset
3269 }
kono
parents: 67
diff changeset
3270
kono
parents: 67
diff changeset
3271 /* Produce context specifying all derrived types of OTR_TYPE. If OTR_TYPE is
kono
parents: 67
diff changeset
3272 NULL, the context is set to dummy "I know nothing" setting. */
kono
parents: 67
diff changeset
3273
kono
parents: 67
diff changeset
3274 inline void
kono
parents: 67
diff changeset
3275 ipa_polymorphic_call_context::clear_outer_type (tree otr_type)
kono
parents: 67
diff changeset
3276 {
kono
parents: 67
diff changeset
3277 outer_type = otr_type ? TYPE_MAIN_VARIANT (otr_type) : NULL;
kono
parents: 67
diff changeset
3278 offset = 0;
kono
parents: 67
diff changeset
3279 maybe_derived_type = true;
kono
parents: 67
diff changeset
3280 maybe_in_construction = true;
kono
parents: 67
diff changeset
3281 dynamic = true;
kono
parents: 67
diff changeset
3282 }
kono
parents: 67
diff changeset
3283
kono
parents: 67
diff changeset
3284 /* Adjust all offsets in contexts by OFF bits. */
kono
parents: 67
diff changeset
3285
kono
parents: 67
diff changeset
3286 inline void
kono
parents: 67
diff changeset
3287 ipa_polymorphic_call_context::offset_by (HOST_WIDE_INT off)
kono
parents: 67
diff changeset
3288 {
kono
parents: 67
diff changeset
3289 if (outer_type)
kono
parents: 67
diff changeset
3290 offset += off;
kono
parents: 67
diff changeset
3291 if (speculative_outer_type)
kono
parents: 67
diff changeset
3292 speculative_offset += off;
kono
parents: 67
diff changeset
3293 }
kono
parents: 67
diff changeset
3294
kono
parents: 67
diff changeset
3295 /* Return TRUE if context is fully useless. */
kono
parents: 67
diff changeset
3296
kono
parents: 67
diff changeset
3297 inline bool
kono
parents: 67
diff changeset
3298 ipa_polymorphic_call_context::useless_p () const
kono
parents: 67
diff changeset
3299 {
kono
parents: 67
diff changeset
3300 return (!outer_type && !speculative_outer_type);
kono
parents: 67
diff changeset
3301 }
kono
parents: 67
diff changeset
3302
kono
parents: 67
diff changeset
3303 /* Return true if NODE is local. Instrumentation clones are counted as local
kono
parents: 67
diff changeset
3304 only when original function is local. */
kono
parents: 67
diff changeset
3305
kono
parents: 67
diff changeset
3306 static inline bool
kono
parents: 67
diff changeset
3307 cgraph_local_p (cgraph_node *node)
kono
parents: 67
diff changeset
3308 {
kono
parents: 67
diff changeset
3309 if (!node->instrumentation_clone || !node->instrumented_version)
kono
parents: 67
diff changeset
3310 return node->local.local;
kono
parents: 67
diff changeset
3311
kono
parents: 67
diff changeset
3312 return node->local.local && node->instrumented_version->local.local;
kono
parents: 67
diff changeset
3313 }
kono
parents: 67
diff changeset
3314
kono
parents: 67
diff changeset
3315 /* When using fprintf (or similar), problems can arise with
kono
parents: 67
diff changeset
3316 transient generated strings. Many string-generation APIs
kono
parents: 67
diff changeset
3317 only support one result being alive at once (e.g. by
kono
parents: 67
diff changeset
3318 returning a pointer to a statically-allocated buffer).
kono
parents: 67
diff changeset
3319
kono
parents: 67
diff changeset
3320 If there is more than one generated string within one
kono
parents: 67
diff changeset
3321 fprintf call: the first string gets evicted or overwritten
kono
parents: 67
diff changeset
3322 by the second, before fprintf is fully evaluated.
kono
parents: 67
diff changeset
3323 See e.g. PR/53136.
kono
parents: 67
diff changeset
3324
kono
parents: 67
diff changeset
3325 This function provides a workaround for this, by providing
kono
parents: 67
diff changeset
3326 a simple way to create copies of these transient strings,
kono
parents: 67
diff changeset
3327 without the need to have explicit cleanup:
kono
parents: 67
diff changeset
3328
kono
parents: 67
diff changeset
3329 fprintf (dumpfile, "string 1: %s string 2:%s\n",
kono
parents: 67
diff changeset
3330 xstrdup_for_dump (EXPR_1),
kono
parents: 67
diff changeset
3331 xstrdup_for_dump (EXPR_2));
kono
parents: 67
diff changeset
3332
kono
parents: 67
diff changeset
3333 This is actually a simple wrapper around ggc_strdup, but
kono
parents: 67
diff changeset
3334 the name documents the intent. We require that no GC can occur
kono
parents: 67
diff changeset
3335 within the fprintf call. */
kono
parents: 67
diff changeset
3336
kono
parents: 67
diff changeset
3337 static inline const char *
kono
parents: 67
diff changeset
3338 xstrdup_for_dump (const char *transient_str)
kono
parents: 67
diff changeset
3339 {
kono
parents: 67
diff changeset
3340 return ggc_strdup (transient_str);
kono
parents: 67
diff changeset
3341 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
3342
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3343 #endif /* GCC_CGRAPH_H */