annotate gcc/cgraphclones.c @ 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
111
kono
parents:
diff changeset
1 /* Callgraph clones
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Jan Hubicka
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
10 version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
15 for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
21 /* This module provide facilities for cloning functions. I.e. creating
111
kono
parents:
diff changeset
22 new functions based on existing functions with simple modifications,
kono
parents:
diff changeset
23 such as replacement of parameters.
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 To allow whole program optimization without actual presence of function
kono
parents:
diff changeset
26 bodies, an additional infrastructure is provided for so-called virtual
kono
parents:
diff changeset
27 clones
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 A virtual clone in the callgraph is a function that has no
kono
parents:
diff changeset
30 associated body, just a description of how to create its body based
kono
parents:
diff changeset
31 on a different function (which itself may be a virtual clone).
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 The description of function modifications includes adjustments to
kono
parents:
diff changeset
34 the function's signature (which allows, for example, removing or
kono
parents:
diff changeset
35 adding function arguments), substitutions to perform on the
kono
parents:
diff changeset
36 function body, and, for inlined functions, a pointer to the
kono
parents:
diff changeset
37 function that it will be inlined into.
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 It is also possible to redirect any edge of the callgraph from a
kono
parents:
diff changeset
40 function to its virtual clone. This implies updating of the call
kono
parents:
diff changeset
41 site to adjust for the new function signature.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 Most of the transformations performed by inter-procedural
kono
parents:
diff changeset
44 optimizations can be represented via virtual clones. For
kono
parents:
diff changeset
45 instance, a constant propagation pass can produce a virtual clone
kono
parents:
diff changeset
46 of the function which replaces one of its arguments by a
kono
parents:
diff changeset
47 constant. The inliner can represent its decisions by producing a
kono
parents:
diff changeset
48 clone of a function whose body will be later integrated into
kono
parents:
diff changeset
49 a given function.
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 Using virtual clones, the program can be easily updated
kono
parents:
diff changeset
52 during the Execute stage, solving most of pass interactions
kono
parents:
diff changeset
53 problems that would otherwise occur during Transform.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 Virtual clones are later materialized in the LTRANS stage and
kono
parents:
diff changeset
56 turned into real functions. Passes executed after the virtual
kono
parents:
diff changeset
57 clone were introduced also perform their Transform stage
kono
parents:
diff changeset
58 on new functions, so for a pass there is no significant
kono
parents:
diff changeset
59 difference between operating on a real function or a virtual
kono
parents:
diff changeset
60 clone introduced before its Execute stage.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 Optimization passes then work on virtual clones introduced before
kono
parents:
diff changeset
63 their Execute stage as if they were real functions. The
kono
parents:
diff changeset
64 only difference is that clones are not visible during the
kono
parents:
diff changeset
65 Generate Summary stage. */
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 #include "config.h"
kono
parents:
diff changeset
68 #include "system.h"
kono
parents:
diff changeset
69 #include "coretypes.h"
kono
parents:
diff changeset
70 #include "backend.h"
kono
parents:
diff changeset
71 #include "target.h"
kono
parents:
diff changeset
72 #include "rtl.h"
kono
parents:
diff changeset
73 #include "tree.h"
kono
parents:
diff changeset
74 #include "gimple.h"
kono
parents:
diff changeset
75 #include "stringpool.h"
kono
parents:
diff changeset
76 #include "cgraph.h"
kono
parents:
diff changeset
77 #include "lto-streamer.h"
kono
parents:
diff changeset
78 #include "tree-eh.h"
kono
parents:
diff changeset
79 #include "tree-cfg.h"
kono
parents:
diff changeset
80 #include "tree-inline.h"
kono
parents:
diff changeset
81 #include "dumpfile.h"
kono
parents:
diff changeset
82 #include "gimple-pretty-print.h"
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
83 #include "alloc-pool.h"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
84 #include "symbol-summary.h"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
85 #include "tree-vrp.h"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 #include "ipa-prop.h"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87 #include "ipa-fnsummary.h"
111
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 /* Create clone of edge in the node N represented by CALL_EXPR
kono
parents:
diff changeset
90 the callgraph. */
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 cgraph_edge *
kono
parents:
diff changeset
93 cgraph_edge::clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
kono
parents:
diff changeset
94 profile_count num, profile_count den,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
95 bool update_original)
111
kono
parents:
diff changeset
96 {
kono
parents:
diff changeset
97 cgraph_edge *new_edge;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98 profile_count::adjust_for_ipa_scaling (&num, &den);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 profile_count prof_count = count.apply_scale (num, den);
111
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 if (indirect_unknown_callee)
kono
parents:
diff changeset
102 {
kono
parents:
diff changeset
103 tree decl;
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 if (call_stmt && (decl = gimple_call_fndecl (call_stmt))
kono
parents:
diff changeset
106 /* When the call is speculative, we need to resolve it
kono
parents:
diff changeset
107 via cgraph_resolve_speculation and not here. */
kono
parents:
diff changeset
108 && !speculative)
kono
parents:
diff changeset
109 {
kono
parents:
diff changeset
110 cgraph_node *callee = cgraph_node::get (decl);
kono
parents:
diff changeset
111 gcc_checking_assert (callee);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
112 new_edge = n->create_edge (callee, call_stmt, prof_count, true);
111
kono
parents:
diff changeset
113 }
kono
parents:
diff changeset
114 else
kono
parents:
diff changeset
115 {
kono
parents:
diff changeset
116 new_edge = n->create_indirect_edge (call_stmt,
kono
parents:
diff changeset
117 indirect_info->ecf_flags,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
118 prof_count, true);
111
kono
parents:
diff changeset
119 *new_edge->indirect_info = *indirect_info;
kono
parents:
diff changeset
120 }
kono
parents:
diff changeset
121 }
kono
parents:
diff changeset
122 else
kono
parents:
diff changeset
123 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
124 new_edge = n->create_edge (callee, call_stmt, prof_count, true);
111
kono
parents:
diff changeset
125 if (indirect_info)
kono
parents:
diff changeset
126 {
kono
parents:
diff changeset
127 new_edge->indirect_info
kono
parents:
diff changeset
128 = ggc_cleared_alloc<cgraph_indirect_call_info> ();
kono
parents:
diff changeset
129 *new_edge->indirect_info = *indirect_info;
kono
parents:
diff changeset
130 }
kono
parents:
diff changeset
131 }
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 new_edge->inline_failed = inline_failed;
kono
parents:
diff changeset
134 new_edge->indirect_inlining_edge = indirect_inlining_edge;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
135 if (!call_stmt)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
136 new_edge->lto_stmt_uid = stmt_uid;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
137 new_edge->speculative_id = speculative_id;
111
kono
parents:
diff changeset
138 /* Clone flags that depend on call_stmt availability manually. */
kono
parents:
diff changeset
139 new_edge->can_throw_external = can_throw_external;
kono
parents:
diff changeset
140 new_edge->call_stmt_cannot_inline_p = call_stmt_cannot_inline_p;
kono
parents:
diff changeset
141 new_edge->speculative = speculative;
kono
parents:
diff changeset
142 new_edge->in_polymorphic_cdtor = in_polymorphic_cdtor;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
143
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
144 /* Update IPA profile. Local profiles need no updating in original. */
111
kono
parents:
diff changeset
145 if (update_original)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
146 count = count.combine_with_ipa_count_within (count.ipa ()
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
147 - new_edge->count.ipa (),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
148 caller->count);
111
kono
parents:
diff changeset
149 symtab->call_edge_duplication_hooks (this, new_edge);
kono
parents:
diff changeset
150 return new_edge;
kono
parents:
diff changeset
151 }
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 /* Set flags of NEW_NODE and its decl. NEW_NODE is a newly created private
kono
parents:
diff changeset
154 clone or its thunk. */
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 static void
kono
parents:
diff changeset
157 set_new_clone_decl_and_node_flags (cgraph_node *new_node)
kono
parents:
diff changeset
158 {
kono
parents:
diff changeset
159 DECL_EXTERNAL (new_node->decl) = 0;
kono
parents:
diff changeset
160 TREE_PUBLIC (new_node->decl) = 0;
kono
parents:
diff changeset
161 DECL_COMDAT (new_node->decl) = 0;
kono
parents:
diff changeset
162 DECL_WEAK (new_node->decl) = 0;
kono
parents:
diff changeset
163 DECL_VIRTUAL_P (new_node->decl) = 0;
kono
parents:
diff changeset
164 DECL_STATIC_CONSTRUCTOR (new_node->decl) = 0;
kono
parents:
diff changeset
165 DECL_STATIC_DESTRUCTOR (new_node->decl) = 0;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
166 DECL_SET_IS_OPERATOR_NEW (new_node->decl, 0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
167 DECL_SET_IS_OPERATOR_DELETE (new_node->decl, 0);
111
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 new_node->externally_visible = 0;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
170 new_node->local = 1;
111
kono
parents:
diff changeset
171 new_node->lowered = true;
kono
parents:
diff changeset
172 }
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 /* Duplicate thunk THUNK if necessary but make it to refer to NODE.
kono
parents:
diff changeset
175 ARGS_TO_SKIP, if non-NULL, determines which parameters should be omitted.
kono
parents:
diff changeset
176 Function can return NODE if no thunk is necessary, which can happen when
kono
parents:
diff changeset
177 thunk is this_adjusting but we are removing this parameter. */
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 static cgraph_node *
kono
parents:
diff changeset
180 duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
kono
parents:
diff changeset
181 {
kono
parents:
diff changeset
182 cgraph_node *new_thunk, *thunk_of;
kono
parents:
diff changeset
183 thunk_of = thunk->callees->callee->ultimate_alias_target ();
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 if (thunk_of->thunk.thunk_p)
kono
parents:
diff changeset
186 node = duplicate_thunk_for_node (thunk_of, node);
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 if (!DECL_ARGUMENTS (thunk->decl))
kono
parents:
diff changeset
189 thunk->get_untransformed_body ();
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 cgraph_edge *cs;
kono
parents:
diff changeset
192 for (cs = node->callers; cs; cs = cs->next_caller)
kono
parents:
diff changeset
193 if (cs->caller->thunk.thunk_p
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 && cs->caller->thunk.fixed_offset == thunk->thunk.fixed_offset
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 && cs->caller->thunk.virtual_value == thunk->thunk.virtual_value
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196 && cs->caller->thunk.indirect_offset == thunk->thunk.indirect_offset
111
kono
parents:
diff changeset
197 && cs->caller->thunk.this_adjusting == thunk->thunk.this_adjusting
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
198 && cs->caller->thunk.virtual_offset_p == thunk->thunk.virtual_offset_p)
111
kono
parents:
diff changeset
199 return cs->caller;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 tree new_decl;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
202 if (node->clone.param_adjustments)
111
kono
parents:
diff changeset
203 {
kono
parents:
diff changeset
204 /* We do not need to duplicate this_adjusting thunks if we have removed
kono
parents:
diff changeset
205 this. */
kono
parents:
diff changeset
206 if (thunk->thunk.this_adjusting
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
207 && !node->clone.param_adjustments->first_param_intact_p ())
111
kono
parents:
diff changeset
208 return node;
kono
parents:
diff changeset
209
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
210 new_decl = copy_node (thunk->decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
211 ipa_param_body_adjustments body_adj (node->clone.param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 new_decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 body_adj.modify_formal_parameters ();
111
kono
parents:
diff changeset
214 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
216 new_decl = copy_node (thunk->decl);
111
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 gcc_checking_assert (!DECL_STRUCT_FUNCTION (new_decl));
kono
parents:
diff changeset
219 gcc_checking_assert (!DECL_INITIAL (new_decl));
kono
parents:
diff changeset
220 gcc_checking_assert (!DECL_RESULT (new_decl));
kono
parents:
diff changeset
221 gcc_checking_assert (!DECL_RTL_SET_P (new_decl));
kono
parents:
diff changeset
222
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
223 DECL_NAME (new_decl) = clone_function_name_numbered (thunk->decl,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
224 "artificial_thunk");
111
kono
parents:
diff changeset
225 SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
kono
parents:
diff changeset
226
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 /* We need to force DECL_IGNORED_P because the new thunk is created after
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228 early debug was run. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 DECL_IGNORED_P (new_decl) = 1;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230
111
kono
parents:
diff changeset
231 new_thunk = cgraph_node::create (new_decl);
kono
parents:
diff changeset
232 set_new_clone_decl_and_node_flags (new_thunk);
kono
parents:
diff changeset
233 new_thunk->definition = true;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234 new_thunk->can_change_signature = node->can_change_signature;
111
kono
parents:
diff changeset
235 new_thunk->thunk = thunk->thunk;
kono
parents:
diff changeset
236 new_thunk->unique_name = in_lto_p;
kono
parents:
diff changeset
237 new_thunk->former_clone_of = thunk->decl;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
238 new_thunk->clone.param_adjustments = node->clone.param_adjustments;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
239 new_thunk->unit_id = thunk->unit_id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
240 new_thunk->merged_comdat = thunk->merged_comdat;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
241 new_thunk->merged_extern_inline = thunk->merged_extern_inline;
111
kono
parents:
diff changeset
242
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
243 cgraph_edge *e = new_thunk->create_edge (node, NULL, new_thunk->count);
111
kono
parents:
diff changeset
244 symtab->call_edge_duplication_hooks (thunk->callees, e);
kono
parents:
diff changeset
245 symtab->call_cgraph_duplication_hooks (thunk, new_thunk);
kono
parents:
diff changeset
246 return new_thunk;
kono
parents:
diff changeset
247 }
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 /* If E does not lead to a thunk, simply redirect it to N. Otherwise create
kono
parents:
diff changeset
250 one or more equivalent thunks for N and redirect E to the first in the
kono
parents:
diff changeset
251 chain. Note that it is then necessary to call
kono
parents:
diff changeset
252 n->expand_all_artificial_thunks once all callers are redirected. */
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 void
kono
parents:
diff changeset
255 cgraph_edge::redirect_callee_duplicating_thunks (cgraph_node *n)
kono
parents:
diff changeset
256 {
kono
parents:
diff changeset
257 cgraph_node *orig_to = callee->ultimate_alias_target ();
kono
parents:
diff changeset
258 if (orig_to->thunk.thunk_p)
kono
parents:
diff changeset
259 n = duplicate_thunk_for_node (orig_to, n);
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 redirect_callee (n);
kono
parents:
diff changeset
262 }
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 /* Call expand_thunk on all callers that are thunks and if analyze those nodes
kono
parents:
diff changeset
265 that were expanded. */
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 void
kono
parents:
diff changeset
268 cgraph_node::expand_all_artificial_thunks ()
kono
parents:
diff changeset
269 {
kono
parents:
diff changeset
270 cgraph_edge *e;
kono
parents:
diff changeset
271 for (e = callers; e;)
kono
parents:
diff changeset
272 if (e->caller->thunk.thunk_p)
kono
parents:
diff changeset
273 {
kono
parents:
diff changeset
274 cgraph_node *thunk = e->caller;
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 e = e->next_caller;
kono
parents:
diff changeset
277 if (thunk->expand_thunk (false, false))
kono
parents:
diff changeset
278 {
kono
parents:
diff changeset
279 thunk->thunk.thunk_p = false;
kono
parents:
diff changeset
280 thunk->analyze ();
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
281 ipa_analyze_node (thunk);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
282 inline_analyze_function (thunk);
111
kono
parents:
diff changeset
283 }
kono
parents:
diff changeset
284 thunk->expand_all_artificial_thunks ();
kono
parents:
diff changeset
285 }
kono
parents:
diff changeset
286 else
kono
parents:
diff changeset
287 e = e->next_caller;
kono
parents:
diff changeset
288 }
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 void
kono
parents:
diff changeset
291 dump_callgraph_transformation (const cgraph_node *original,
kono
parents:
diff changeset
292 const cgraph_node *clone,
kono
parents:
diff changeset
293 const char *suffix)
kono
parents:
diff changeset
294 {
kono
parents:
diff changeset
295 if (symtab->ipa_clones_dump_file)
kono
parents:
diff changeset
296 {
kono
parents:
diff changeset
297 fprintf (symtab->ipa_clones_dump_file,
kono
parents:
diff changeset
298 "Callgraph clone;%s;%d;%s;%d;%d;%s;%d;%s;%d;%d;%s\n",
kono
parents:
diff changeset
299 original->asm_name (), original->order,
kono
parents:
diff changeset
300 DECL_SOURCE_FILE (original->decl),
kono
parents:
diff changeset
301 DECL_SOURCE_LINE (original->decl),
kono
parents:
diff changeset
302 DECL_SOURCE_COLUMN (original->decl), clone->asm_name (),
kono
parents:
diff changeset
303 clone->order, DECL_SOURCE_FILE (clone->decl),
kono
parents:
diff changeset
304 DECL_SOURCE_LINE (clone->decl), DECL_SOURCE_COLUMN (clone->decl),
kono
parents:
diff changeset
305 suffix);
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 symtab->cloned_nodes.add (original);
kono
parents:
diff changeset
308 symtab->cloned_nodes.add (clone);
kono
parents:
diff changeset
309 }
kono
parents:
diff changeset
310 }
kono
parents:
diff changeset
311
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
312 /* Turn profile of N to local profile. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
313
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
314 static void
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
315 localize_profile (cgraph_node *n)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
316 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
317 n->count = n->count.guessed_local ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
318 for (cgraph_edge *e = n->callees; e; e=e->next_callee)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
319 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
320 e->count = e->count.guessed_local ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
321 if (!e->inline_failed)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
322 localize_profile (e->callee);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
323 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
324 for (cgraph_edge *e = n->indirect_calls; e; e=e->next_callee)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
325 e->count = e->count.guessed_local ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
326 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
327
111
kono
parents:
diff changeset
328 /* Create node representing clone of N executed COUNT times. Decrease
kono
parents:
diff changeset
329 the execution counts from original node too.
kono
parents:
diff changeset
330 The new clone will have decl set to DECL that may or may not be the same
kono
parents:
diff changeset
331 as decl of N.
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 When UPDATE_ORIGINAL is true, the counts are subtracted from the original
kono
parents:
diff changeset
334 function's profile to reflect the fact that part of execution is handled
kono
parents:
diff changeset
335 by node.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 When CALL_DUPLICATION_HOOK is true, the ipa passes are acknowledged about
111
kono
parents:
diff changeset
337 the new clone. Otherwise the caller is responsible for doing so later.
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 If the new node is being inlined into another one, NEW_INLINED_TO should be
kono
parents:
diff changeset
340 the outline function the new one is (even indirectly) inlined to. All hooks
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
341 will see this in node's inlined_to, when invoked. Can be NULL if the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 node is not inlined.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
344 If PARAM_ADJUSTMENTS is non-NULL, the parameter manipulation information
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
345 will be overwritten by the new structure. Otherwise the new node will
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
346 share parameter manipulation information with the original node. */
111
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 cgraph_node *
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
349 cgraph_node::create_clone (tree new_decl, profile_count prof_count,
111
kono
parents:
diff changeset
350 bool update_original,
kono
parents:
diff changeset
351 vec<cgraph_edge *> redirect_callers,
kono
parents:
diff changeset
352 bool call_duplication_hook,
kono
parents:
diff changeset
353 cgraph_node *new_inlined_to,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
354 ipa_param_adjustments *param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
355 const char *suffix)
111
kono
parents:
diff changeset
356 {
kono
parents:
diff changeset
357 cgraph_node *new_node = symtab->create_empty ();
kono
parents:
diff changeset
358 cgraph_edge *e;
kono
parents:
diff changeset
359 unsigned i;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
360 profile_count old_count = count;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
361 bool nonzero = count.ipa ().nonzero_p ();
111
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 if (new_inlined_to)
kono
parents:
diff changeset
364 dump_callgraph_transformation (this, new_inlined_to, "inlining to");
kono
parents:
diff changeset
365
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
366 /* When inlining we scale precisely to prof_count, when cloning we can
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
367 preserve local profile. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
368 if (!new_inlined_to)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
369 prof_count = count.combine_with_ipa_count (prof_count);
111
kono
parents:
diff changeset
370 new_node->count = prof_count;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
371
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
372 /* Update IPA profile. Local profiles need no updating in original. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
373 if (update_original)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
374 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
375 if (inlined_to)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
376 count = count.combine_with_ipa_count_within (count.ipa ()
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
377 - prof_count.ipa (),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
378 inlined_to->count);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
379 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
380 count = count.combine_with_ipa_count (count.ipa () - prof_count.ipa ());
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
381 }
111
kono
parents:
diff changeset
382 new_node->decl = new_decl;
kono
parents:
diff changeset
383 new_node->register_symbol ();
kono
parents:
diff changeset
384 new_node->origin = origin;
kono
parents:
diff changeset
385 new_node->lto_file_data = lto_file_data;
kono
parents:
diff changeset
386 if (new_node->origin)
kono
parents:
diff changeset
387 {
kono
parents:
diff changeset
388 new_node->next_nested = new_node->origin->nested;
kono
parents:
diff changeset
389 new_node->origin->nested = new_node;
kono
parents:
diff changeset
390 }
kono
parents:
diff changeset
391 new_node->analyzed = analyzed;
kono
parents:
diff changeset
392 new_node->definition = definition;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
393 new_node->versionable = versionable;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
394 new_node->can_change_signature = can_change_signature;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
395 new_node->redefined_extern_inline = redefined_extern_inline;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
396 new_node->tm_may_enter_irr = tm_may_enter_irr;
111
kono
parents:
diff changeset
397 new_node->externally_visible = false;
kono
parents:
diff changeset
398 new_node->no_reorder = no_reorder;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
399 new_node->local = true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
400 new_node->inlined_to = new_inlined_to;
111
kono
parents:
diff changeset
401 new_node->rtl = rtl;
kono
parents:
diff changeset
402 new_node->frequency = frequency;
kono
parents:
diff changeset
403 new_node->tp_first_run = tp_first_run;
kono
parents:
diff changeset
404 new_node->tm_clone = tm_clone;
kono
parents:
diff changeset
405 new_node->icf_merged = icf_merged;
kono
parents:
diff changeset
406 new_node->merged_comdat = merged_comdat;
kono
parents:
diff changeset
407 new_node->thunk = thunk;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
408 new_node->unit_id = unit_id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
409 new_node->merged_comdat = merged_comdat;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
410 new_node->merged_extern_inline = merged_extern_inline;
111
kono
parents:
diff changeset
411
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
412 if (param_adjustments)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
413 new_node->clone.param_adjustments = param_adjustments;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
414 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
415 new_node->clone.param_adjustments = clone.param_adjustments;
111
kono
parents:
diff changeset
416 new_node->clone.tree_map = NULL;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
417 new_node->clone.performed_splits = vec_safe_copy (clone.performed_splits);
111
kono
parents:
diff changeset
418 new_node->split_part = split_part;
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 FOR_EACH_VEC_ELT (redirect_callers, i, e)
kono
parents:
diff changeset
421 {
kono
parents:
diff changeset
422 /* Redirect calls to the old version node to point to its new
kono
parents:
diff changeset
423 version. The only exception is when the edge was proved to
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
424 be unreachable during the cloning procedure. */
111
kono
parents:
diff changeset
425 if (!e->callee
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
426 || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
111
kono
parents:
diff changeset
427 e->redirect_callee_duplicating_thunks (new_node);
kono
parents:
diff changeset
428 }
kono
parents:
diff changeset
429 new_node->expand_all_artificial_thunks ();
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 for (e = callees;e; e=e->next_callee)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
432 e->clone (new_node, e->call_stmt, e->lto_stmt_uid, new_node->count, old_count,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
433 update_original);
111
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 for (e = indirect_calls; e; e = e->next_callee)
kono
parents:
diff changeset
436 e->clone (new_node, e->call_stmt, e->lto_stmt_uid,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
437 new_node->count, old_count, update_original);
111
kono
parents:
diff changeset
438 new_node->clone_references (this);
kono
parents:
diff changeset
439
kono
parents:
diff changeset
440 new_node->next_sibling_clone = clones;
kono
parents:
diff changeset
441 if (clones)
kono
parents:
diff changeset
442 clones->prev_sibling_clone = new_node;
kono
parents:
diff changeset
443 clones = new_node;
kono
parents:
diff changeset
444 new_node->clone_of = this;
kono
parents:
diff changeset
445
kono
parents:
diff changeset
446 if (call_duplication_hook)
kono
parents:
diff changeset
447 symtab->call_cgraph_duplication_hooks (this, new_node);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
448 /* With partial train run we do not want to assume that original's
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
449 count is zero whenever we redurect all executed edges to clone.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
450 Simply drop profile to local one in this case. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
451 if (update_original
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
452 && opt_for_fn (decl, flag_profile_partial_training)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
453 && nonzero
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
454 && count.ipa_p ()
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
455 && !count.ipa ().nonzero_p ()
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
456 && !inlined_to)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
457 localize_profile (this);
111
kono
parents:
diff changeset
458
kono
parents:
diff changeset
459 if (!new_inlined_to)
kono
parents:
diff changeset
460 dump_callgraph_transformation (this, new_node, suffix);
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 return new_node;
kono
parents:
diff changeset
463 }
kono
parents:
diff changeset
464
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
465 static GTY(()) hash_map<const char *, unsigned> *clone_fn_ids;
111
kono
parents:
diff changeset
466
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
467 /* Return a new assembler name for a clone of decl named NAME. Apart
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
468 from the string SUFFIX, the new name will end with a unique (for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
469 each NAME) unspecified number. If clone numbering is not needed
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
470 then the two argument clone_function_name should be used instead.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
471 Should not be called directly except for by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
472 lto-partition.c:privatize_symbol_name_1. */
111
kono
parents:
diff changeset
473
kono
parents:
diff changeset
474 tree
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
475 clone_function_name_numbered (const char *name, const char *suffix)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
476 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
477 /* Initialize the function->counter mapping the first time it's
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
478 needed. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
479 if (!clone_fn_ids)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
480 clone_fn_ids = hash_map<const char *, unsigned int>::create_ggc (64);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
481 unsigned int &suffix_counter = clone_fn_ids->get_or_insert (
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
482 IDENTIFIER_POINTER (get_identifier (name)));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
483 return clone_function_name (name, suffix, suffix_counter++);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
484 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
485
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
486 /* Return a new assembler name for a clone of DECL. Apart from string
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
487 SUFFIX, the new name will end with a unique (for each DECL
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
488 assembler name) unspecified number. If clone numbering is not
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
489 needed then the two argument clone_function_name should be used
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
490 instead. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
491
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
492 tree
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
493 clone_function_name_numbered (tree decl, const char *suffix)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
494 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
495 tree name = DECL_ASSEMBLER_NAME (decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
496 return clone_function_name_numbered (IDENTIFIER_POINTER (name),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
497 suffix);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
498 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
499
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
500 /* Return a new assembler name for a clone of decl named NAME. Apart
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
501 from the string SUFFIX, the new name will end with the specified
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
502 NUMBER. If clone numbering is not needed then the two argument
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
503 clone_function_name should be used instead. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
504
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
505 tree
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
506 clone_function_name (const char *name, const char *suffix,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
507 unsigned long number)
111
kono
parents:
diff changeset
508 {
kono
parents:
diff changeset
509 size_t len = strlen (name);
kono
parents:
diff changeset
510 char *tmp_name, *prefix;
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 prefix = XALLOCAVEC (char, len + strlen (suffix) + 2);
kono
parents:
diff changeset
513 memcpy (prefix, name, len);
kono
parents:
diff changeset
514 strcpy (prefix + len + 1, suffix);
kono
parents:
diff changeset
515 prefix[len] = symbol_table::symbol_suffix_separator ();
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
516 ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, number);
111
kono
parents:
diff changeset
517 return get_identifier (tmp_name);
kono
parents:
diff changeset
518 }
kono
parents:
diff changeset
519
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
520 /* Return a new assembler name for a clone of DECL. Apart from the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
521 string SUFFIX, the new name will end with the specified NUMBER. If
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
522 clone numbering is not needed then the two argument
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
523 clone_function_name should be used instead. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
524
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
525 tree
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
526 clone_function_name (tree decl, const char *suffix,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
527 unsigned long number)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
528 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
529 return clone_function_name (
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
530 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), suffix, number);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
531 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
532
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
533 /* Return a new assembler name ending with the string SUFFIX for a
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
534 clone of DECL. */
111
kono
parents:
diff changeset
535
kono
parents:
diff changeset
536 tree
kono
parents:
diff changeset
537 clone_function_name (tree decl, const char *suffix)
kono
parents:
diff changeset
538 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
539 tree identifier = DECL_ASSEMBLER_NAME (decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
540 /* For consistency this needs to behave the same way as
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
541 ASM_FORMAT_PRIVATE_NAME does, but without the final number
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
542 suffix. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
543 char *separator = XALLOCAVEC (char, 2);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
544 separator[0] = symbol_table::symbol_suffix_separator ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
545 separator[1] = 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
546 #if defined (NO_DOT_IN_LABEL) && defined (NO_DOLLAR_IN_LABEL)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
547 const char *prefix = "__";
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
548 #else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
549 const char *prefix = "";
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
550 #endif
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
551 char *result = ACONCAT ((prefix,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
552 IDENTIFIER_POINTER (identifier),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
553 separator,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
554 suffix,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
555 (char*)0));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
556 return get_identifier (result);
111
kono
parents:
diff changeset
557 }
kono
parents:
diff changeset
558
kono
parents:
diff changeset
559
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
560 /* Create callgraph node clone with new declaration. The actual body will be
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
561 copied later at compilation stage. The name of the new clone will be
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
562 constructed from the name of the original node, SUFFIX and NUM_SUFFIX.
111
kono
parents:
diff changeset
563
kono
parents:
diff changeset
564 TODO: after merging in ipa-sra use function call notes instead of args_to_skip
kono
parents:
diff changeset
565 bitmap interface.
kono
parents:
diff changeset
566 */
kono
parents:
diff changeset
567 cgraph_node *
kono
parents:
diff changeset
568 cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
kono
parents:
diff changeset
569 vec<ipa_replace_map *, va_gc> *tree_map,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
570 ipa_param_adjustments *param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
571 const char * suffix, unsigned num_suffix)
111
kono
parents:
diff changeset
572 {
kono
parents:
diff changeset
573 tree old_decl = decl;
kono
parents:
diff changeset
574 cgraph_node *new_node = NULL;
kono
parents:
diff changeset
575 tree new_decl;
kono
parents:
diff changeset
576 size_t len, i;
kono
parents:
diff changeset
577 ipa_replace_map *map;
kono
parents:
diff changeset
578 char *name;
kono
parents:
diff changeset
579
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
580 gcc_checking_assert (versionable);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
581 /* TODO: It would be nice if we could recognize that param_adjustments do not
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
582 actually perform any changes, but at the moment let's require it simply
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
583 does not exist. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
584 gcc_assert (can_change_signature || !param_adjustments);
111
kono
parents:
diff changeset
585
kono
parents:
diff changeset
586 /* Make a new FUNCTION_DECL tree node */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
587 if (!param_adjustments)
111
kono
parents:
diff changeset
588 new_decl = copy_node (old_decl);
kono
parents:
diff changeset
589 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
590 new_decl = param_adjustments->adjust_decl (old_decl);
111
kono
parents:
diff changeset
591
kono
parents:
diff changeset
592 /* These pointers represent function body and will be populated only when clone
kono
parents:
diff changeset
593 is materialized. */
kono
parents:
diff changeset
594 gcc_assert (new_decl != old_decl);
kono
parents:
diff changeset
595 DECL_STRUCT_FUNCTION (new_decl) = NULL;
kono
parents:
diff changeset
596 DECL_ARGUMENTS (new_decl) = NULL;
kono
parents:
diff changeset
597 DECL_INITIAL (new_decl) = NULL;
kono
parents:
diff changeset
598 DECL_RESULT (new_decl) = NULL;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
599 /* We cannot do DECL_RESULT (new_decl) = NULL; here because of LTO partitioning
111
kono
parents:
diff changeset
600 sometimes storing only clone decl instead of original. */
kono
parents:
diff changeset
601
kono
parents:
diff changeset
602 /* Generate a new name for the new version. */
kono
parents:
diff changeset
603 len = IDENTIFIER_LENGTH (DECL_NAME (old_decl));
kono
parents:
diff changeset
604 name = XALLOCAVEC (char, len + strlen (suffix) + 2);
kono
parents:
diff changeset
605 memcpy (name, IDENTIFIER_POINTER (DECL_NAME (old_decl)), len);
kono
parents:
diff changeset
606 strcpy (name + len + 1, suffix);
kono
parents:
diff changeset
607 name[len] = '.';
kono
parents:
diff changeset
608 DECL_NAME (new_decl) = get_identifier (name);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
609 SET_DECL_ASSEMBLER_NAME (new_decl,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
610 clone_function_name (old_decl, suffix, num_suffix));
111
kono
parents:
diff changeset
611 SET_DECL_RTL (new_decl, NULL);
kono
parents:
diff changeset
612
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
613 new_node = create_clone (new_decl, count, false,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
614 redirect_callers, false, NULL, param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
615 suffix);
111
kono
parents:
diff changeset
616
kono
parents:
diff changeset
617 /* Update the properties.
kono
parents:
diff changeset
618 Make clone visible only within this translation unit. Make sure
kono
parents:
diff changeset
619 that is not weak also.
kono
parents:
diff changeset
620 ??? We cannot use COMDAT linkage because there is no
kono
parents:
diff changeset
621 ABI support for this. */
kono
parents:
diff changeset
622 set_new_clone_decl_and_node_flags (new_node);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
623 new_node->ipcp_clone = ipcp_clone;
111
kono
parents:
diff changeset
624 new_node->clone.tree_map = tree_map;
kono
parents:
diff changeset
625 if (!implicit_section)
kono
parents:
diff changeset
626 new_node->set_section (get_section ());
kono
parents:
diff changeset
627
kono
parents:
diff changeset
628 /* Clones of global symbols or symbols with unique names are unique. */
kono
parents:
diff changeset
629 if ((TREE_PUBLIC (old_decl)
kono
parents:
diff changeset
630 && !DECL_EXTERNAL (old_decl)
kono
parents:
diff changeset
631 && !DECL_WEAK (old_decl)
kono
parents:
diff changeset
632 && !DECL_COMDAT (old_decl))
kono
parents:
diff changeset
633 || in_lto_p)
kono
parents:
diff changeset
634 new_node->unique_name = true;
kono
parents:
diff changeset
635 FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
kono
parents:
diff changeset
636 new_node->maybe_create_reference (map->new_tree, NULL);
kono
parents:
diff changeset
637
kono
parents:
diff changeset
638 if (ipa_transforms_to_apply.exists ())
kono
parents:
diff changeset
639 new_node->ipa_transforms_to_apply
kono
parents:
diff changeset
640 = ipa_transforms_to_apply.copy ();
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 symtab->call_cgraph_duplication_hooks (this, new_node);
kono
parents:
diff changeset
643
kono
parents:
diff changeset
644 return new_node;
kono
parents:
diff changeset
645 }
kono
parents:
diff changeset
646
kono
parents:
diff changeset
647 /* callgraph node being removed from symbol table; see if its entry can be
kono
parents:
diff changeset
648 replaced by other inline clone. */
kono
parents:
diff changeset
649 cgraph_node *
kono
parents:
diff changeset
650 cgraph_node::find_replacement (void)
kono
parents:
diff changeset
651 {
kono
parents:
diff changeset
652 cgraph_node *next_inline_clone, *replacement;
kono
parents:
diff changeset
653
kono
parents:
diff changeset
654 for (next_inline_clone = clones;
kono
parents:
diff changeset
655 next_inline_clone
kono
parents:
diff changeset
656 && next_inline_clone->decl != decl;
kono
parents:
diff changeset
657 next_inline_clone = next_inline_clone->next_sibling_clone)
kono
parents:
diff changeset
658 ;
kono
parents:
diff changeset
659
kono
parents:
diff changeset
660 /* If there is inline clone of the node being removed, we need
kono
parents:
diff changeset
661 to put it into the position of removed node and reorganize all
kono
parents:
diff changeset
662 other clones to be based on it. */
kono
parents:
diff changeset
663 if (next_inline_clone)
kono
parents:
diff changeset
664 {
kono
parents:
diff changeset
665 cgraph_node *n;
kono
parents:
diff changeset
666 cgraph_node *new_clones;
kono
parents:
diff changeset
667
kono
parents:
diff changeset
668 replacement = next_inline_clone;
kono
parents:
diff changeset
669
kono
parents:
diff changeset
670 /* Unlink inline clone from the list of clones of removed node. */
kono
parents:
diff changeset
671 if (next_inline_clone->next_sibling_clone)
kono
parents:
diff changeset
672 next_inline_clone->next_sibling_clone->prev_sibling_clone
kono
parents:
diff changeset
673 = next_inline_clone->prev_sibling_clone;
kono
parents:
diff changeset
674 if (next_inline_clone->prev_sibling_clone)
kono
parents:
diff changeset
675 {
kono
parents:
diff changeset
676 gcc_assert (clones != next_inline_clone);
kono
parents:
diff changeset
677 next_inline_clone->prev_sibling_clone->next_sibling_clone
kono
parents:
diff changeset
678 = next_inline_clone->next_sibling_clone;
kono
parents:
diff changeset
679 }
kono
parents:
diff changeset
680 else
kono
parents:
diff changeset
681 {
kono
parents:
diff changeset
682 gcc_assert (clones == next_inline_clone);
kono
parents:
diff changeset
683 clones = next_inline_clone->next_sibling_clone;
kono
parents:
diff changeset
684 }
kono
parents:
diff changeset
685
kono
parents:
diff changeset
686 new_clones = clones;
kono
parents:
diff changeset
687 clones = NULL;
kono
parents:
diff changeset
688
kono
parents:
diff changeset
689 /* Copy clone info. */
kono
parents:
diff changeset
690 next_inline_clone->clone = clone;
kono
parents:
diff changeset
691
kono
parents:
diff changeset
692 /* Now place it into clone tree at same level at NODE. */
kono
parents:
diff changeset
693 next_inline_clone->clone_of = clone_of;
kono
parents:
diff changeset
694 next_inline_clone->prev_sibling_clone = NULL;
kono
parents:
diff changeset
695 next_inline_clone->next_sibling_clone = NULL;
kono
parents:
diff changeset
696 if (clone_of)
kono
parents:
diff changeset
697 {
kono
parents:
diff changeset
698 if (clone_of->clones)
kono
parents:
diff changeset
699 clone_of->clones->prev_sibling_clone = next_inline_clone;
kono
parents:
diff changeset
700 next_inline_clone->next_sibling_clone = clone_of->clones;
kono
parents:
diff changeset
701 clone_of->clones = next_inline_clone;
kono
parents:
diff changeset
702 }
kono
parents:
diff changeset
703
kono
parents:
diff changeset
704 /* Merge the clone list. */
kono
parents:
diff changeset
705 if (new_clones)
kono
parents:
diff changeset
706 {
kono
parents:
diff changeset
707 if (!next_inline_clone->clones)
kono
parents:
diff changeset
708 next_inline_clone->clones = new_clones;
kono
parents:
diff changeset
709 else
kono
parents:
diff changeset
710 {
kono
parents:
diff changeset
711 n = next_inline_clone->clones;
kono
parents:
diff changeset
712 while (n->next_sibling_clone)
kono
parents:
diff changeset
713 n = n->next_sibling_clone;
kono
parents:
diff changeset
714 n->next_sibling_clone = new_clones;
kono
parents:
diff changeset
715 new_clones->prev_sibling_clone = n;
kono
parents:
diff changeset
716 }
kono
parents:
diff changeset
717 }
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 /* Update clone_of pointers. */
kono
parents:
diff changeset
720 n = new_clones;
kono
parents:
diff changeset
721 while (n)
kono
parents:
diff changeset
722 {
kono
parents:
diff changeset
723 n->clone_of = next_inline_clone;
kono
parents:
diff changeset
724 n = n->next_sibling_clone;
kono
parents:
diff changeset
725 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
726
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
727 /* Update order in order to be able to find a LTO section
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
728 with function body. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
729 replacement->order = order;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
730
111
kono
parents:
diff changeset
731 return replacement;
kono
parents:
diff changeset
732 }
kono
parents:
diff changeset
733 else
kono
parents:
diff changeset
734 return NULL;
kono
parents:
diff changeset
735 }
kono
parents:
diff changeset
736
kono
parents:
diff changeset
737 /* Like cgraph_set_call_stmt but walk the clone tree and update all
kono
parents:
diff changeset
738 clones sharing the same function body.
kono
parents:
diff changeset
739 When WHOLE_SPECULATIVE_EDGES is true, all three components of
kono
parents:
diff changeset
740 speculative edge gets updated. Otherwise we update only direct
kono
parents:
diff changeset
741 call. */
kono
parents:
diff changeset
742
kono
parents:
diff changeset
743 void
kono
parents:
diff changeset
744 cgraph_node::set_call_stmt_including_clones (gimple *old_stmt,
kono
parents:
diff changeset
745 gcall *new_stmt,
kono
parents:
diff changeset
746 bool update_speculative)
kono
parents:
diff changeset
747 {
kono
parents:
diff changeset
748 cgraph_node *node;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
749 cgraph_edge *master_edge = get_edge (old_stmt);
111
kono
parents:
diff changeset
750
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
751 if (master_edge)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
752 cgraph_edge::set_call_stmt (master_edge, new_stmt, update_speculative);
111
kono
parents:
diff changeset
753
kono
parents:
diff changeset
754 node = clones;
kono
parents:
diff changeset
755 if (node)
kono
parents:
diff changeset
756 while (node != this)
kono
parents:
diff changeset
757 {
kono
parents:
diff changeset
758 cgraph_edge *edge = node->get_edge (old_stmt);
kono
parents:
diff changeset
759 if (edge)
kono
parents:
diff changeset
760 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
761 edge = cgraph_edge::set_call_stmt (edge, new_stmt,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
762 update_speculative);
111
kono
parents:
diff changeset
763 /* If UPDATE_SPECULATIVE is false, it means that we are turning
kono
parents:
diff changeset
764 speculative call into a real code sequence. Update the
kono
parents:
diff changeset
765 callgraph edges. */
kono
parents:
diff changeset
766 if (edge->speculative && !update_speculative)
kono
parents:
diff changeset
767 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
768 cgraph_edge *indirect = edge->speculative_call_indirect_edge ();
111
kono
parents:
diff changeset
769
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
770 for (cgraph_edge *next, *direct
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
771 = edge->first_speculative_call_target ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
772 direct;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
773 direct = next)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
774 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
775 next = direct->next_speculative_call_target ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
776 direct->speculative_call_target_ref ()->speculative = false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
777 direct->speculative = false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
778 }
111
kono
parents:
diff changeset
779 indirect->speculative = false;
kono
parents:
diff changeset
780 }
kono
parents:
diff changeset
781 }
kono
parents:
diff changeset
782 if (node->clones)
kono
parents:
diff changeset
783 node = node->clones;
kono
parents:
diff changeset
784 else if (node->next_sibling_clone)
kono
parents:
diff changeset
785 node = node->next_sibling_clone;
kono
parents:
diff changeset
786 else
kono
parents:
diff changeset
787 {
kono
parents:
diff changeset
788 while (node != this && !node->next_sibling_clone)
kono
parents:
diff changeset
789 node = node->clone_of;
kono
parents:
diff changeset
790 if (node != this)
kono
parents:
diff changeset
791 node = node->next_sibling_clone;
kono
parents:
diff changeset
792 }
kono
parents:
diff changeset
793 }
kono
parents:
diff changeset
794 }
kono
parents:
diff changeset
795
kono
parents:
diff changeset
796 /* Like cgraph_create_edge walk the clone tree and update all clones sharing
kono
parents:
diff changeset
797 same function body. If clones already have edge for OLD_STMT; only
kono
parents:
diff changeset
798 update the edge same way as cgraph_set_call_stmt_including_clones does.
kono
parents:
diff changeset
799
kono
parents:
diff changeset
800 TODO: COUNT and LOOP_DEPTH should be properly distributed based on relative
kono
parents:
diff changeset
801 frequencies of the clones. */
kono
parents:
diff changeset
802
kono
parents:
diff changeset
803 void
kono
parents:
diff changeset
804 cgraph_node::create_edge_including_clones (cgraph_node *callee,
kono
parents:
diff changeset
805 gimple *old_stmt, gcall *stmt,
kono
parents:
diff changeset
806 profile_count count,
kono
parents:
diff changeset
807 cgraph_inline_failed_t reason)
kono
parents:
diff changeset
808 {
kono
parents:
diff changeset
809 cgraph_node *node;
kono
parents:
diff changeset
810
kono
parents:
diff changeset
811 if (!get_edge (stmt))
kono
parents:
diff changeset
812 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
813 cgraph_edge *edge = create_edge (callee, stmt, count);
111
kono
parents:
diff changeset
814 edge->inline_failed = reason;
kono
parents:
diff changeset
815 }
kono
parents:
diff changeset
816
kono
parents:
diff changeset
817 node = clones;
kono
parents:
diff changeset
818 if (node)
kono
parents:
diff changeset
819 while (node != this)
kono
parents:
diff changeset
820 /* Thunk clones do not get updated while copying inline function body. */
kono
parents:
diff changeset
821 if (!node->thunk.thunk_p)
kono
parents:
diff changeset
822 {
kono
parents:
diff changeset
823 cgraph_edge *edge = node->get_edge (old_stmt);
kono
parents:
diff changeset
824
kono
parents:
diff changeset
825 /* It is possible that clones already contain the edge while
kono
parents:
diff changeset
826 master didn't. Either we promoted indirect call into direct
kono
parents:
diff changeset
827 call in the clone or we are processing clones of unreachable
kono
parents:
diff changeset
828 master where edges has been removed. */
kono
parents:
diff changeset
829 if (edge)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
830 edge = cgraph_edge::set_call_stmt (edge, stmt);
111
kono
parents:
diff changeset
831 else if (! node->get_edge (stmt))
kono
parents:
diff changeset
832 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
833 edge = node->create_edge (callee, stmt, count);
111
kono
parents:
diff changeset
834 edge->inline_failed = reason;
kono
parents:
diff changeset
835 }
kono
parents:
diff changeset
836
kono
parents:
diff changeset
837 if (node->clones)
kono
parents:
diff changeset
838 node = node->clones;
kono
parents:
diff changeset
839 else if (node->next_sibling_clone)
kono
parents:
diff changeset
840 node = node->next_sibling_clone;
kono
parents:
diff changeset
841 else
kono
parents:
diff changeset
842 {
kono
parents:
diff changeset
843 while (node != this && !node->next_sibling_clone)
kono
parents:
diff changeset
844 node = node->clone_of;
kono
parents:
diff changeset
845 if (node != this)
kono
parents:
diff changeset
846 node = node->next_sibling_clone;
kono
parents:
diff changeset
847 }
kono
parents:
diff changeset
848 }
kono
parents:
diff changeset
849 }
kono
parents:
diff changeset
850
kono
parents:
diff changeset
851 /* Remove the node from cgraph and all inline clones inlined into it.
kono
parents:
diff changeset
852 Skip however removal of FORBIDDEN_NODE and return true if it needs to be
kono
parents:
diff changeset
853 removed. This allows to call the function from outer loop walking clone
kono
parents:
diff changeset
854 tree. */
kono
parents:
diff changeset
855
kono
parents:
diff changeset
856 bool
kono
parents:
diff changeset
857 cgraph_node::remove_symbol_and_inline_clones (cgraph_node *forbidden_node)
kono
parents:
diff changeset
858 {
kono
parents:
diff changeset
859 cgraph_edge *e, *next;
kono
parents:
diff changeset
860 bool found = false;
kono
parents:
diff changeset
861
kono
parents:
diff changeset
862 if (this == forbidden_node)
kono
parents:
diff changeset
863 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
864 cgraph_edge::remove (callers);
111
kono
parents:
diff changeset
865 return true;
kono
parents:
diff changeset
866 }
kono
parents:
diff changeset
867 for (e = callees; e; e = next)
kono
parents:
diff changeset
868 {
kono
parents:
diff changeset
869 next = e->next_callee;
kono
parents:
diff changeset
870 if (!e->inline_failed)
kono
parents:
diff changeset
871 found |= e->callee->remove_symbol_and_inline_clones (forbidden_node);
kono
parents:
diff changeset
872 }
kono
parents:
diff changeset
873 remove ();
kono
parents:
diff changeset
874 return found;
kono
parents:
diff changeset
875 }
kono
parents:
diff changeset
876
kono
parents:
diff changeset
877 /* The edges representing the callers of the NEW_VERSION node were
kono
parents:
diff changeset
878 fixed by cgraph_function_versioning (), now the call_expr in their
kono
parents:
diff changeset
879 respective tree code should be updated to call the NEW_VERSION. */
kono
parents:
diff changeset
880
kono
parents:
diff changeset
881 static void
kono
parents:
diff changeset
882 update_call_expr (cgraph_node *new_version)
kono
parents:
diff changeset
883 {
kono
parents:
diff changeset
884 cgraph_edge *e;
kono
parents:
diff changeset
885
kono
parents:
diff changeset
886 gcc_assert (new_version);
kono
parents:
diff changeset
887
kono
parents:
diff changeset
888 /* Update the call expr on the edges to call the new version. */
kono
parents:
diff changeset
889 for (e = new_version->callers; e; e = e->next_caller)
kono
parents:
diff changeset
890 {
kono
parents:
diff changeset
891 function *inner_function = DECL_STRUCT_FUNCTION (e->caller->decl);
kono
parents:
diff changeset
892 gimple_call_set_fndecl (e->call_stmt, new_version->decl);
kono
parents:
diff changeset
893 maybe_clean_eh_stmt_fn (inner_function, e->call_stmt);
kono
parents:
diff changeset
894 }
kono
parents:
diff changeset
895 }
kono
parents:
diff changeset
896
kono
parents:
diff changeset
897
kono
parents:
diff changeset
898 /* Create a new cgraph node which is the new version of
kono
parents:
diff changeset
899 callgraph node. REDIRECT_CALLERS holds the callers
kono
parents:
diff changeset
900 edges which should be redirected to point to
kono
parents:
diff changeset
901 NEW_VERSION. ALL the callees edges of the node
kono
parents:
diff changeset
902 are cloned to the new version node. Return the new
kono
parents:
diff changeset
903 version node.
kono
parents:
diff changeset
904
kono
parents:
diff changeset
905 If non-NULL BLOCK_TO_COPY determine what basic blocks
kono
parents:
diff changeset
906 was copied to prevent duplications of calls that are dead
kono
parents:
diff changeset
907 in the clone. */
kono
parents:
diff changeset
908
kono
parents:
diff changeset
909 cgraph_node *
kono
parents:
diff changeset
910 cgraph_node::create_version_clone (tree new_decl,
kono
parents:
diff changeset
911 vec<cgraph_edge *> redirect_callers,
kono
parents:
diff changeset
912 bitmap bbs_to_copy,
kono
parents:
diff changeset
913 const char *suffix)
kono
parents:
diff changeset
914 {
kono
parents:
diff changeset
915 cgraph_node *new_version;
kono
parents:
diff changeset
916 cgraph_edge *e;
kono
parents:
diff changeset
917 unsigned i;
kono
parents:
diff changeset
918
kono
parents:
diff changeset
919 new_version = cgraph_node::create (new_decl);
kono
parents:
diff changeset
920
kono
parents:
diff changeset
921 new_version->analyzed = analyzed;
kono
parents:
diff changeset
922 new_version->definition = definition;
kono
parents:
diff changeset
923 new_version->local = local;
kono
parents:
diff changeset
924 new_version->externally_visible = false;
kono
parents:
diff changeset
925 new_version->no_reorder = no_reorder;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
926 new_version->local = new_version->definition;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
927 new_version->inlined_to = inlined_to;
111
kono
parents:
diff changeset
928 new_version->rtl = rtl;
kono
parents:
diff changeset
929 new_version->count = count;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
930 new_version->unit_id = unit_id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
931 new_version->merged_comdat = merged_comdat;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
932 new_version->merged_extern_inline = merged_extern_inline;
111
kono
parents:
diff changeset
933
kono
parents:
diff changeset
934 for (e = callees; e; e=e->next_callee)
kono
parents:
diff changeset
935 if (!bbs_to_copy
kono
parents:
diff changeset
936 || bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
kono
parents:
diff changeset
937 e->clone (new_version, e->call_stmt,
kono
parents:
diff changeset
938 e->lto_stmt_uid, count, count,
kono
parents:
diff changeset
939 true);
kono
parents:
diff changeset
940 for (e = indirect_calls; e; e=e->next_callee)
kono
parents:
diff changeset
941 if (!bbs_to_copy
kono
parents:
diff changeset
942 || bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
kono
parents:
diff changeset
943 e->clone (new_version, e->call_stmt,
kono
parents:
diff changeset
944 e->lto_stmt_uid, count, count,
kono
parents:
diff changeset
945 true);
kono
parents:
diff changeset
946 FOR_EACH_VEC_ELT (redirect_callers, i, e)
kono
parents:
diff changeset
947 {
kono
parents:
diff changeset
948 /* Redirect calls to the old version node to point to its new
kono
parents:
diff changeset
949 version. */
kono
parents:
diff changeset
950 e->redirect_callee (new_version);
kono
parents:
diff changeset
951 }
kono
parents:
diff changeset
952
kono
parents:
diff changeset
953 dump_callgraph_transformation (this, new_version, suffix);
kono
parents:
diff changeset
954
kono
parents:
diff changeset
955 return new_version;
kono
parents:
diff changeset
956 }
kono
parents:
diff changeset
957
kono
parents:
diff changeset
958 /* Perform function versioning.
kono
parents:
diff changeset
959 Function versioning includes copying of the tree and
kono
parents:
diff changeset
960 a callgraph update (creating a new cgraph node and updating
kono
parents:
diff changeset
961 its callees and callers).
kono
parents:
diff changeset
962
kono
parents:
diff changeset
963 REDIRECT_CALLERS varray includes the edges to be redirected
kono
parents:
diff changeset
964 to the new version.
kono
parents:
diff changeset
965
kono
parents:
diff changeset
966 TREE_MAP is a mapping of tree nodes we want to replace with
kono
parents:
diff changeset
967 new ones (according to results of prior analysis).
kono
parents:
diff changeset
968
kono
parents:
diff changeset
969 If non-NULL ARGS_TO_SKIP determine function parameters to remove
kono
parents:
diff changeset
970 from new version.
kono
parents:
diff changeset
971 If SKIP_RETURN is true, the new version will return void.
kono
parents:
diff changeset
972 If non-NULL BLOCK_TO_COPY determine what basic blocks to copy.
kono
parents:
diff changeset
973 If non_NULL NEW_ENTRY determine new entry BB of the clone.
kono
parents:
diff changeset
974
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
975 If TARGET_ATTRIBUTES is non-null, when creating a new declaration,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
976 add the attributes to DECL_ATTRIBUTES. And call valid_attribute_p
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
977 that will promote value of the attribute DECL_FUNCTION_SPECIFIC_TARGET
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
978 of the declaration.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
979
111
kono
parents:
diff changeset
980 Return the new version's cgraph node. */
kono
parents:
diff changeset
981
kono
parents:
diff changeset
982 cgraph_node *
kono
parents:
diff changeset
983 cgraph_node::create_version_clone_with_body
kono
parents:
diff changeset
984 (vec<cgraph_edge *> redirect_callers,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
985 vec<ipa_replace_map *, va_gc> *tree_map,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
986 ipa_param_adjustments *param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
987 bitmap bbs_to_copy, basic_block new_entry_block, const char *suffix,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
988 tree target_attributes)
111
kono
parents:
diff changeset
989 {
kono
parents:
diff changeset
990 tree old_decl = decl;
kono
parents:
diff changeset
991 cgraph_node *new_version_node = NULL;
kono
parents:
diff changeset
992 tree new_decl;
kono
parents:
diff changeset
993
kono
parents:
diff changeset
994 if (!tree_versionable_function_p (old_decl))
kono
parents:
diff changeset
995 return NULL;
kono
parents:
diff changeset
996
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
997 /* TODO: Restore an assert that we do not change signature if
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
998 can_change_signature is false. We cannot just check that
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
999 param_adjustments is NULL because unfortunately ipa-split removes return
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1000 values from such functions. */
111
kono
parents:
diff changeset
1001
kono
parents:
diff changeset
1002 /* Make a new FUNCTION_DECL tree node for the new version. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1003 if (param_adjustments)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1004 new_decl = param_adjustments->adjust_decl (old_decl);
111
kono
parents:
diff changeset
1005 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1006 new_decl = copy_node (old_decl);
111
kono
parents:
diff changeset
1007
kono
parents:
diff changeset
1008 /* Generate a new name for the new version. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1009 DECL_NAME (new_decl) = clone_function_name_numbered (old_decl, suffix);
111
kono
parents:
diff changeset
1010 SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
kono
parents:
diff changeset
1011 SET_DECL_RTL (new_decl, NULL);
kono
parents:
diff changeset
1012
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1013 DECL_VIRTUAL_P (new_decl) = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1014
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1015 if (target_attributes)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1016 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1017 DECL_ATTRIBUTES (new_decl) = target_attributes;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1018
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1019 location_t saved_loc = input_location;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1020 tree v = TREE_VALUE (target_attributes);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1021 input_location = DECL_SOURCE_LOCATION (new_decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1022 bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 1);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1023 input_location = saved_loc;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1024 if (!r)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1025 return NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1026 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1027
111
kono
parents:
diff changeset
1028 /* When the old decl was a con-/destructor make sure the clone isn't. */
kono
parents:
diff changeset
1029 DECL_STATIC_CONSTRUCTOR (new_decl) = 0;
kono
parents:
diff changeset
1030 DECL_STATIC_DESTRUCTOR (new_decl) = 0;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1031 DECL_SET_IS_OPERATOR_NEW (new_decl, 0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1032 DECL_SET_IS_OPERATOR_DELETE (new_decl, 0);
111
kono
parents:
diff changeset
1033
kono
parents:
diff changeset
1034 /* Create the new version's call-graph node.
kono
parents:
diff changeset
1035 and update the edges of the new node. */
kono
parents:
diff changeset
1036 new_version_node = create_version_clone (new_decl, redirect_callers,
kono
parents:
diff changeset
1037 bbs_to_copy, suffix);
kono
parents:
diff changeset
1038
kono
parents:
diff changeset
1039 if (ipa_transforms_to_apply.exists ())
kono
parents:
diff changeset
1040 new_version_node->ipa_transforms_to_apply
kono
parents:
diff changeset
1041 = ipa_transforms_to_apply.copy ();
kono
parents:
diff changeset
1042 /* Copy the OLD_VERSION_NODE function tree to the new version. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1043 tree_function_versioning (old_decl, new_decl, tree_map, param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1044 false, bbs_to_copy, new_entry_block);
111
kono
parents:
diff changeset
1045
kono
parents:
diff changeset
1046 /* Update the new version's properties.
kono
parents:
diff changeset
1047 Make The new version visible only within this translation unit. Make sure
kono
parents:
diff changeset
1048 that is not weak also.
kono
parents:
diff changeset
1049 ??? We cannot use COMDAT linkage because there is no
kono
parents:
diff changeset
1050 ABI support for this. */
kono
parents:
diff changeset
1051 new_version_node->make_decl_local ();
kono
parents:
diff changeset
1052 DECL_VIRTUAL_P (new_version_node->decl) = 0;
kono
parents:
diff changeset
1053 new_version_node->externally_visible = 0;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1054 new_version_node->local = 1;
111
kono
parents:
diff changeset
1055 new_version_node->lowered = true;
kono
parents:
diff changeset
1056 if (!implicit_section)
kono
parents:
diff changeset
1057 new_version_node->set_section (get_section ());
kono
parents:
diff changeset
1058 /* Clones of global symbols or symbols with unique names are unique. */
kono
parents:
diff changeset
1059 if ((TREE_PUBLIC (old_decl)
kono
parents:
diff changeset
1060 && !DECL_EXTERNAL (old_decl)
kono
parents:
diff changeset
1061 && !DECL_WEAK (old_decl)
kono
parents:
diff changeset
1062 && !DECL_COMDAT (old_decl))
kono
parents:
diff changeset
1063 || in_lto_p)
kono
parents:
diff changeset
1064 new_version_node->unique_name = true;
kono
parents:
diff changeset
1065
kono
parents:
diff changeset
1066 /* Update the call_expr on the edges to call the new version node. */
kono
parents:
diff changeset
1067 update_call_expr (new_version_node);
kono
parents:
diff changeset
1068
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1069 symtab->call_cgraph_insertion_hooks (new_version_node);
111
kono
parents:
diff changeset
1070 return new_version_node;
kono
parents:
diff changeset
1071 }
kono
parents:
diff changeset
1072
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1073 /* 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
1074 standalone node - not a clone any more. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1075
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1076 void cgraph_node::remove_from_clone_tree ()
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1077 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1078 if (next_sibling_clone)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1079 next_sibling_clone->prev_sibling_clone = prev_sibling_clone;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1080 if (prev_sibling_clone)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1081 prev_sibling_clone->next_sibling_clone = next_sibling_clone;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1082 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1083 clone_of->clones = next_sibling_clone;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1084 next_sibling_clone = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1085 prev_sibling_clone = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1086 clone_of = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1087 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1088
111
kono
parents:
diff changeset
1089 /* Given virtual clone, turn it into actual clone. */
kono
parents:
diff changeset
1090
kono
parents:
diff changeset
1091 static void
kono
parents:
diff changeset
1092 cgraph_materialize_clone (cgraph_node *node)
kono
parents:
diff changeset
1093 {
kono
parents:
diff changeset
1094 bitmap_obstack_initialize (NULL);
kono
parents:
diff changeset
1095 node->former_clone_of = node->clone_of->decl;
kono
parents:
diff changeset
1096 if (node->clone_of->former_clone_of)
kono
parents:
diff changeset
1097 node->former_clone_of = node->clone_of->former_clone_of;
kono
parents:
diff changeset
1098 /* Copy the OLD_VERSION_NODE function tree to the new version. */
kono
parents:
diff changeset
1099 tree_function_versioning (node->clone_of->decl, node->decl,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1100 node->clone.tree_map, node->clone.param_adjustments,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1101 true, NULL, NULL);
111
kono
parents:
diff changeset
1102 if (symtab->dump_file)
kono
parents:
diff changeset
1103 {
kono
parents:
diff changeset
1104 dump_function_to_file (node->clone_of->decl, symtab->dump_file,
kono
parents:
diff changeset
1105 dump_flags);
kono
parents:
diff changeset
1106 dump_function_to_file (node->decl, symtab->dump_file, dump_flags);
kono
parents:
diff changeset
1107 }
kono
parents:
diff changeset
1108
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1109 cgraph_node *clone_of = node->clone_of;
111
kono
parents:
diff changeset
1110 /* Function is no longer clone. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1111 node->remove_from_clone_tree ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1112 if (!clone_of->analyzed && !clone_of->clones)
111
kono
parents:
diff changeset
1113 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1114 clone_of->release_body ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1115 clone_of->remove_callees ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1116 clone_of->remove_all_references ();
111
kono
parents:
diff changeset
1117 }
kono
parents:
diff changeset
1118 bitmap_obstack_release (NULL);
kono
parents:
diff changeset
1119 }
kono
parents:
diff changeset
1120
kono
parents:
diff changeset
1121 /* Once all functions from compilation unit are in memory, produce all clones
kono
parents:
diff changeset
1122 and update all calls. We might also do this on demand if we don't want to
kono
parents:
diff changeset
1123 bring all functions to memory prior compilation, but current WHOPR
kono
parents:
diff changeset
1124 implementation does that and it is a bit easier to keep everything right in
kono
parents:
diff changeset
1125 this order. */
kono
parents:
diff changeset
1126
kono
parents:
diff changeset
1127 void
kono
parents:
diff changeset
1128 symbol_table::materialize_all_clones (void)
kono
parents:
diff changeset
1129 {
kono
parents:
diff changeset
1130 cgraph_node *node;
kono
parents:
diff changeset
1131 bool stabilized = false;
kono
parents:
diff changeset
1132
kono
parents:
diff changeset
1133
kono
parents:
diff changeset
1134 if (symtab->dump_file)
kono
parents:
diff changeset
1135 fprintf (symtab->dump_file, "Materializing clones\n");
kono
parents:
diff changeset
1136
kono
parents:
diff changeset
1137 cgraph_node::checking_verify_cgraph_nodes ();
kono
parents:
diff changeset
1138
kono
parents:
diff changeset
1139 /* We can also do topological order, but number of iterations should be
kono
parents:
diff changeset
1140 bounded by number of IPA passes since single IPA pass is probably not
kono
parents:
diff changeset
1141 going to create clones of clones it created itself. */
kono
parents:
diff changeset
1142 while (!stabilized)
kono
parents:
diff changeset
1143 {
kono
parents:
diff changeset
1144 stabilized = true;
kono
parents:
diff changeset
1145 FOR_EACH_FUNCTION (node)
kono
parents:
diff changeset
1146 {
kono
parents:
diff changeset
1147 if (node->clone_of && node->decl != node->clone_of->decl
kono
parents:
diff changeset
1148 && !gimple_has_body_p (node->decl))
kono
parents:
diff changeset
1149 {
kono
parents:
diff changeset
1150 if (!node->clone_of->clone_of)
kono
parents:
diff changeset
1151 node->clone_of->get_untransformed_body ();
kono
parents:
diff changeset
1152 if (gimple_has_body_p (node->clone_of->decl))
kono
parents:
diff changeset
1153 {
kono
parents:
diff changeset
1154 if (symtab->dump_file)
kono
parents:
diff changeset
1155 {
kono
parents:
diff changeset
1156 fprintf (symtab->dump_file, "cloning %s to %s\n",
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1157 node->clone_of->dump_name (),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1158 node->dump_name ());
111
kono
parents:
diff changeset
1159 if (node->clone.tree_map)
kono
parents:
diff changeset
1160 {
kono
parents:
diff changeset
1161 unsigned int i;
kono
parents:
diff changeset
1162 fprintf (symtab->dump_file, " replace map: ");
kono
parents:
diff changeset
1163 for (i = 0;
kono
parents:
diff changeset
1164 i < vec_safe_length (node->clone.tree_map);
kono
parents:
diff changeset
1165 i++)
kono
parents:
diff changeset
1166 {
kono
parents:
diff changeset
1167 ipa_replace_map *replace_info;
kono
parents:
diff changeset
1168 replace_info = (*node->clone.tree_map)[i];
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1169 fprintf (symtab->dump_file, "%i -> ",
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1170 (*node->clone.tree_map)[i]->parm_num);
111
kono
parents:
diff changeset
1171 print_generic_expr (symtab->dump_file,
kono
parents:
diff changeset
1172 replace_info->new_tree);
kono
parents:
diff changeset
1173 }
kono
parents:
diff changeset
1174 fprintf (symtab->dump_file, "\n");
kono
parents:
diff changeset
1175 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1176 if (node->clone.param_adjustments)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1177 node->clone.param_adjustments->dump (symtab->dump_file);
111
kono
parents:
diff changeset
1178 }
kono
parents:
diff changeset
1179 cgraph_materialize_clone (node);
kono
parents:
diff changeset
1180 stabilized = false;
kono
parents:
diff changeset
1181 }
kono
parents:
diff changeset
1182 }
kono
parents:
diff changeset
1183 }
kono
parents:
diff changeset
1184 }
kono
parents:
diff changeset
1185 FOR_EACH_FUNCTION (node)
kono
parents:
diff changeset
1186 if (!node->analyzed && node->callees)
kono
parents:
diff changeset
1187 {
kono
parents:
diff changeset
1188 node->remove_callees ();
kono
parents:
diff changeset
1189 node->remove_all_references ();
kono
parents:
diff changeset
1190 }
kono
parents:
diff changeset
1191 else
kono
parents:
diff changeset
1192 node->clear_stmts_in_references ();
kono
parents:
diff changeset
1193 if (symtab->dump_file)
kono
parents:
diff changeset
1194 fprintf (symtab->dump_file, "Materialization Call site updates done.\n");
kono
parents:
diff changeset
1195
kono
parents:
diff changeset
1196 cgraph_node::checking_verify_cgraph_nodes ();
kono
parents:
diff changeset
1197
kono
parents:
diff changeset
1198 symtab->remove_unreachable_nodes (symtab->dump_file);
kono
parents:
diff changeset
1199 }
kono
parents:
diff changeset
1200
kono
parents:
diff changeset
1201 #include "gt-cgraphclones.h"