annotate gcc/cgraph.h @ 158:494b0b89df80 default tip

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