Branch data Line data Source code
1 : : /* Callgraph handling code.
2 : : Copyright (C) 2003-2025 Free Software Foundation, Inc.
3 : : Contributed by Jan Hubicka
4 : :
5 : : This file is part of GCC.
6 : :
7 : : GCC is free software; you can redistribute it and/or modify it under
8 : : the terms of the GNU General Public License as published by the Free
9 : : Software Foundation; either version 3, or (at your option) any later
10 : : version.
11 : :
12 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : : for more details.
16 : :
17 : : You should have received a copy of the GNU General Public License
18 : : along with GCC; see the file COPYING3. If not see
19 : : <http://www.gnu.org/licenses/>. */
20 : :
21 : : /* This file contains basic routines manipulating call graph
22 : :
23 : : The call-graph is a data structure designed for inter-procedural
24 : : optimization. It represents a multi-graph where nodes are functions
25 : : (symbols within symbol table) and edges are call sites. */
26 : :
27 : : #include "config.h"
28 : : #include "system.h"
29 : : #include "coretypes.h"
30 : : #include "backend.h"
31 : : #include "target.h"
32 : : #include "rtl.h"
33 : : #include "tree.h"
34 : : #include "gimple.h"
35 : : #include "predict.h"
36 : : #include "alloc-pool.h"
37 : : #include "gimple-ssa.h"
38 : : #include "cgraph.h"
39 : : #include "lto-streamer.h"
40 : : #include "fold-const.h"
41 : : #include "varasm.h"
42 : : #include "calls.h"
43 : : #include "print-tree.h"
44 : : #include "langhooks.h"
45 : : #include "intl.h"
46 : : #include "tree-eh.h"
47 : : #include "gimple-iterator.h"
48 : : #include "tree-cfg.h"
49 : : #include "tree-ssa.h"
50 : : #include "value-prof.h"
51 : : #include "ipa-utils.h"
52 : : #include "symbol-summary.h"
53 : : #include "tree-vrp.h"
54 : : #include "sreal.h"
55 : : #include "ipa-cp.h"
56 : : #include "ipa-prop.h"
57 : : #include "ipa-fnsummary.h"
58 : : #include "cfgloop.h"
59 : : #include "gimple-pretty-print.h"
60 : : #include "tree-dfa.h"
61 : : #include "profile.h"
62 : : #include "context.h"
63 : : #include "gimplify.h"
64 : : #include "stringpool.h"
65 : : #include "attribs.h"
66 : : #include "selftest.h"
67 : : #include "tree-into-ssa.h"
68 : : #include "ipa-inline.h"
69 : : #include "tree-nested.h"
70 : : #include "symtab-thunks.h"
71 : : #include "symtab-clones.h"
72 : : #include "attr-callback.h"
73 : :
74 : : /* FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this. */
75 : : #include "tree-pass.h"
76 : :
77 : : /* Queue of cgraph nodes scheduled to be lowered. */
78 : : symtab_node *x_cgraph_nodes_queue;
79 : : #define cgraph_nodes_queue ((cgraph_node *)x_cgraph_nodes_queue)
80 : :
81 : : /* Symbol table global context. */
82 : : symbol_table *symtab;
83 : :
84 : : /* List of hooks triggered on cgraph_edge events. */
85 : : struct cgraph_edge_hook_list {
86 : : cgraph_edge_hook hook;
87 : : void *data;
88 : : struct cgraph_edge_hook_list *next;
89 : : };
90 : :
91 : : /* List of hooks triggered on cgraph_node events. */
92 : : struct cgraph_node_hook_list {
93 : : cgraph_node_hook hook;
94 : : void *data;
95 : : struct cgraph_node_hook_list *next;
96 : : };
97 : :
98 : : /* List of hooks triggered on events involving two cgraph_edges. */
99 : : struct cgraph_2edge_hook_list {
100 : : cgraph_2edge_hook hook;
101 : : void *data;
102 : : struct cgraph_2edge_hook_list *next;
103 : : };
104 : :
105 : : /* List of hooks triggered on events involving two cgraph_nodes. */
106 : : struct cgraph_2node_hook_list {
107 : : cgraph_2node_hook hook;
108 : : void *data;
109 : : struct cgraph_2node_hook_list *next;
110 : : };
111 : :
112 : : /* Hash descriptor for cgraph_function_version_info. */
113 : :
114 : : struct function_version_hasher : ggc_ptr_hash<cgraph_function_version_info>
115 : : {
116 : : static hashval_t hash (cgraph_function_version_info *);
117 : : static bool equal (cgraph_function_version_info *,
118 : : cgraph_function_version_info *);
119 : : };
120 : :
121 : : /* Map a cgraph_node to cgraph_function_version_info using this htab.
122 : : The cgraph_function_version_info has a THIS_NODE field that is the
123 : : corresponding cgraph_node.. */
124 : :
125 : : static GTY(()) hash_table<function_version_hasher> *cgraph_fnver_htab = NULL;
126 : :
127 : : /* Hash function for cgraph_fnver_htab. */
128 : : hashval_t
129 : 289052 : function_version_hasher::hash (cgraph_function_version_info *ptr)
130 : : {
131 : 289052 : int uid = ptr->this_node->get_uid ();
132 : 289052 : return (hashval_t)(uid);
133 : : }
134 : :
135 : : /* eq function for cgraph_fnver_htab. */
136 : : bool
137 : 262095 : function_version_hasher::equal (cgraph_function_version_info *n1,
138 : : cgraph_function_version_info *n2)
139 : : {
140 : 262095 : return n1->this_node->get_uid () == n2->this_node->get_uid ();
141 : : }
142 : :
143 : : /* Mark as GC root all allocated nodes. */
144 : : static GTY(()) struct cgraph_function_version_info *
145 : : version_info_node = NULL;
146 : :
147 : : /* Return true if NODE's address can be compared. */
148 : :
149 : : bool
150 : 5029494 : symtab_node::address_can_be_compared_p ()
151 : : {
152 : : /* Address of virtual tables and functions is never compared. */
153 : 5029494 : if (DECL_VIRTUAL_P (decl))
154 : : return false;
155 : : /* Address of C++ cdtors is never compared. */
156 : 4931538 : if (is_a <cgraph_node *> (this)
157 : 545851 : && (DECL_CXX_CONSTRUCTOR_P (decl)
158 : 541464 : || DECL_CXX_DESTRUCTOR_P (decl)))
159 : : return false;
160 : : /* Constant pool symbols addresses are never compared.
161 : : flag_merge_constants permits us to assume the same on readonly vars. */
162 : 4925730 : if (is_a <varpool_node *> (this)
163 : 4385687 : && (DECL_IN_CONSTANT_POOL (decl)
164 : 4385684 : || ((flag_merge_constants >= 2 || DECL_MERGEABLE (decl))
165 : 2281 : && TREE_READONLY (decl) && !TREE_THIS_VOLATILE (decl))))
166 : 2277 : return false;
167 : : return true;
168 : : }
169 : :
170 : : /* Get the cgraph_function_version_info node corresponding to node. */
171 : : cgraph_function_version_info *
172 : 118230218 : cgraph_node::function_version (void)
173 : : {
174 : 118230218 : cgraph_function_version_info key;
175 : 118230218 : key.this_node = this;
176 : :
177 : 118230218 : if (cgraph_fnver_htab == NULL)
178 : : return NULL;
179 : :
180 : 46322 : return cgraph_fnver_htab->find (&key);
181 : : }
182 : :
183 : : /* If profile is IPA, turn it into local one. */
184 : : void
185 : 0 : cgraph_node::make_profile_local ()
186 : : {
187 : 0 : if (!count.ipa ().initialized_p ())
188 : : return;
189 : 0 : if (!(count == profile_count::zero ()))
190 : 0 : count = count.guessed_local ();
191 : 0 : for (cgraph_edge *e = callees; e; e = e->next_callee)
192 : : {
193 : 0 : if (!e->inline_failed)
194 : 0 : e->callee->make_profile_local ();
195 : 0 : if (!(e->count == profile_count::zero ()))
196 : 0 : e->count = e->count.guessed_local ();
197 : : }
198 : 0 : for (cgraph_edge *e = indirect_calls; e; e = e->next_callee)
199 : 0 : if (!(e->count == profile_count::zero ()))
200 : 0 : e->count = e->count.guessed_local ();
201 : : }
202 : :
203 : : /* Turn profile to global0. Walk into inlined functions.
204 : : QUALITY must be GUESSED_GLOBAL0, GUESSED_GLOBAL0_ADJUSTED
205 : : or GUESSED_GLOBAL0_AFDO */
206 : : void
207 : 5 : cgraph_node::make_profile_global0 (profile_quality quality)
208 : : {
209 : 5 : if (count == profile_count::zero ())
210 : : ;
211 : 5 : else if (quality == GUESSED_GLOBAL0)
212 : : {
213 : 5 : if (count.quality () == GUESSED_GLOBAL0)
214 : : return;
215 : 5 : count = count.global0 ();
216 : : }
217 : 0 : else if (quality == GUESSED_GLOBAL0_ADJUSTED)
218 : : {
219 : 0 : if (count.quality () == GUESSED_GLOBAL0
220 : 0 : || count.quality () == GUESSED_GLOBAL0_ADJUSTED)
221 : : return;
222 : 0 : count = count.global0adjusted ();
223 : : }
224 : 0 : else if (quality == GUESSED_GLOBAL0_AFDO)
225 : : {
226 : 0 : if (count.quality () == GUESSED_GLOBAL0
227 : 0 : || count.quality () == GUESSED_GLOBAL0_ADJUSTED
228 : 0 : || count.quality () == GUESSED_GLOBAL0_AFDO)
229 : : return;
230 : 0 : count = count.global0afdo ();
231 : : }
232 : : else
233 : 0 : gcc_unreachable ();
234 : 6 : for (cgraph_edge *e = callees; e; e = e->next_callee)
235 : : {
236 : 1 : if (!e->inline_failed)
237 : 0 : e->callee->make_profile_global0 (quality);
238 : 1 : if (e->count == profile_count::zero ())
239 : : ;
240 : 1 : else if (quality == GUESSED_GLOBAL0)
241 : 1 : e->count = e->count.global0 ();
242 : 0 : else if (quality == GUESSED_GLOBAL0_ADJUSTED)
243 : 0 : e->count = e->count.global0adjusted ();
244 : 0 : else if (quality == GUESSED_GLOBAL0_AFDO)
245 : 0 : e->count = e->count.global0afdo ();
246 : : else
247 : 0 : gcc_unreachable ();
248 : : }
249 : 5 : for (cgraph_edge *e = indirect_calls; e; e = e->next_callee)
250 : 0 : if (e->count == profile_count::zero ())
251 : : ;
252 : 0 : else if (quality == GUESSED_GLOBAL0)
253 : 0 : e->count = e->count.global0 ();
254 : 0 : else if (quality == GUESSED_GLOBAL0_ADJUSTED)
255 : 0 : e->count = e->count.global0adjusted ();
256 : 0 : else if (quality == GUESSED_GLOBAL0_AFDO)
257 : 0 : e->count = e->count.global0afdo ();
258 : : else
259 : 0 : gcc_unreachable ();
260 : : }
261 : :
262 : : /* Scale profile by NUM/DEN. Walk into inlined functions. */
263 : :
264 : : void
265 : 1672137 : cgraph_node::apply_scale (profile_count num, profile_count den)
266 : : {
267 : 1789543 : if (num == den && !(num == profile_count::zero ()))
268 : 115553 : return;
269 : :
270 : 2824072 : for (cgraph_edge *e = callees; e; e = e->next_callee)
271 : : {
272 : 1267488 : if (!e->inline_failed)
273 : 166920 : e->callee->apply_scale (num, den);
274 : 1267488 : e->count = e->count.apply_scale (num, den);
275 : : }
276 : 1586716 : for (cgraph_edge *e = indirect_calls; e; e = e->next_callee)
277 : 30132 : e->count = e->count.apply_scale (num, den);
278 : 1556584 : count = count.apply_scale (num, den);
279 : : }
280 : :
281 : : /* Scale profile to given IPA_COUNT.
282 : : IPA_COUNT should pass ipa_p () with a single exception.
283 : : It can be also GUESSED_LOCAL in case we want to
284 : : drop any IPA info about the profile. */
285 : :
286 : : void
287 : 30 : cgraph_node::scale_profile_to (profile_count ipa_count)
288 : : {
289 : : /* If we do not know the adjustment, it is better to keep profile
290 : : as it is. */
291 : 30 : if (!ipa_count.initialized_p ()
292 : 30 : || ipa_count == count)
293 : 10 : return;
294 : : /* ipa-cp converts value to guessed-local in case it believes
295 : : that we lost track of IPA profile. */
296 : 25 : if (ipa_count.quality () == GUESSED_LOCAL)
297 : : {
298 : 0 : make_profile_local ();
299 : 0 : return;
300 : : }
301 : 25 : if (ipa_count == profile_count::zero ())
302 : : {
303 : 5 : make_profile_global0 (GUESSED_GLOBAL0);
304 : 5 : return;
305 : : }
306 : 20 : if (ipa_count == profile_count::adjusted_zero ())
307 : : {
308 : 0 : make_profile_global0 (GUESSED_GLOBAL0_ADJUSTED);
309 : 0 : return;
310 : : }
311 : 40 : gcc_assert (ipa_count.ipa () == ipa_count
312 : : && !inlined_to);
313 : 20 : profile_count num = count.combine_with_ipa_count (ipa_count);
314 : 20 : profile_count den = count;
315 : 20 : profile_count::adjust_for_ipa_scaling (&num, &den);
316 : : }
317 : :
318 : : /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
319 : : corresponding to cgraph_node NODE. */
320 : : cgraph_function_version_info *
321 : 1523 : cgraph_node::insert_new_function_version (void)
322 : : {
323 : 1523 : version_info_node = NULL;
324 : 1523 : version_info_node = ggc_cleared_alloc<cgraph_function_version_info> ();
325 : 1523 : version_info_node->this_node = this;
326 : 1523 : version_info_node->assembler_name = DECL_ASSEMBLER_NAME (this->decl);
327 : :
328 : 1523 : if (cgraph_fnver_htab == NULL)
329 : 197 : cgraph_fnver_htab = hash_table<function_version_hasher>::create_ggc (2);
330 : :
331 : 1523 : *cgraph_fnver_htab->find_slot (version_info_node, INSERT)
332 : 1523 : = version_info_node;
333 : 1523 : return version_info_node;
334 : : }
335 : :
336 : : /* Remove the cgraph_function_version_info node given by DECL_V. */
337 : : void
338 : 97997730 : cgraph_node::delete_function_version (cgraph_function_version_info *decl_v)
339 : : {
340 : 97997730 : if (decl_v == NULL)
341 : : return;
342 : :
343 : 268 : if (version_info_node == decl_v)
344 : 205 : version_info_node = NULL;
345 : :
346 : 268 : if (decl_v->prev != NULL)
347 : 162 : decl_v->prev->next = decl_v->next;
348 : :
349 : 268 : if (decl_v->next != NULL)
350 : 226 : decl_v->next->prev = decl_v->prev;
351 : :
352 : 268 : if (cgraph_fnver_htab != NULL)
353 : 268 : cgraph_fnver_htab->remove_elt (decl_v);
354 : : }
355 : :
356 : : /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
357 : : DECL is a duplicate declaration. */
358 : : void
359 : 258 : cgraph_node::delete_function_version_by_decl (tree decl)
360 : : {
361 : 258 : cgraph_node *decl_node = cgraph_node::get (decl);
362 : :
363 : 258 : if (decl_node == NULL)
364 : : return;
365 : :
366 : 204 : delete_function_version (decl_node->function_version ());
367 : :
368 : 204 : decl_node->remove ();
369 : : }
370 : :
371 : : /* Add decl to the structure of semantically identical function versions.
372 : : The node is inserted at the point maintaining the priority ordering on the
373 : : versions. */
374 : : void
375 : 8908 : cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
376 : : tree decl)
377 : : {
378 : 8908 : cgraph_node *decl_node = cgraph_node::get_create (decl);
379 : 8908 : cgraph_function_version_info *decl_v = NULL;
380 : :
381 : 8908 : gcc_assert (decl_node != NULL);
382 : :
383 : 8908 : decl_v = decl_node->function_version ();
384 : :
385 : : /* If the nodes are already linked, skip. */
386 : 8908 : if (decl_v != NULL && (decl_v->next || decl_v->prev))
387 : : return;
388 : :
389 : 175 : if (decl_v == NULL)
390 : 175 : decl_v = decl_node->insert_new_function_version ();
391 : :
392 : 175 : gcc_assert (decl_v);
393 : 1057 : gcc_assert (fn_v);
394 : :
395 : : /* Go to start of the FMV structure. */
396 : 5509 : while (fn_v->prev)
397 : : fn_v = fn_v->prev;
398 : :
399 : 1057 : cgraph_function_version_info *insert_point_before = NULL;
400 : 1057 : cgraph_function_version_info *insert_point_after = fn_v;
401 : :
402 : : /* Find the insertion point for the new version to maintain ordering.
403 : : The default node must always go at the beginning. */
404 : 1057 : if (!is_function_default_version (decl))
405 : : while (insert_point_after
406 : 9987 : && (targetm.compare_version_priority
407 : 4802 : (decl, insert_point_after->this_node->decl) > 0
408 : 696 : || is_function_default_version
409 : 696 : (insert_point_after->this_node->decl)
410 : 575 : || lookup_attribute
411 : 575 : ("target_clones",
412 : 575 : DECL_ATTRIBUTES (insert_point_after->this_node->decl))))
413 : : {
414 : 4227 : insert_point_before = insert_point_after;
415 : 4227 : insert_point_after = insert_point_after->next;
416 : : }
417 : :
418 : 1057 : decl_v->prev = insert_point_before;
419 : 1057 : decl_v->next= insert_point_after;
420 : :
421 : 1057 : if (insert_point_before)
422 : 922 : insert_point_before->next = decl_v;
423 : 1057 : if (insert_point_after)
424 : 674 : insert_point_after->prev = decl_v;
425 : : }
426 : :
427 : : /* Initialize callgraph dump file. */
428 : :
429 : : void
430 : 305575 : symbol_table::initialize (void)
431 : : {
432 : 305575 : if (!dump_file)
433 : 305573 : dump_file = dump_begin (TDI_cgraph, NULL);
434 : :
435 : 305575 : if (!ipa_clones_dump_file)
436 : 305575 : ipa_clones_dump_file = dump_begin (TDI_clones, NULL);
437 : 305575 : }
438 : :
439 : : /* Allocate new callgraph node and insert it into basic data structures. */
440 : :
441 : : cgraph_node *
442 : 101753419 : symbol_table::create_empty (void)
443 : : {
444 : 101753419 : cgraph_count++;
445 : 101753419 : return new (ggc_alloc<cgraph_node> ()) cgraph_node ();
446 : : }
447 : :
448 : : /* Register HOOK to be called with DATA on each removed edge. */
449 : : cgraph_edge_hook_list *
450 : 1907696 : symbol_table::add_edge_removal_hook (cgraph_edge_hook hook, void *data)
451 : : {
452 : 1907696 : cgraph_edge_hook_list *entry;
453 : 3815392 : cgraph_edge_hook_list **ptr = &m_first_edge_removal_hook;
454 : :
455 : 1907696 : entry = (cgraph_edge_hook_list *) xmalloc (sizeof (*entry));
456 : 1907696 : entry->hook = hook;
457 : 1907696 : entry->data = data;
458 : 1907696 : entry->next = NULL;
459 : 6598517 : while (*ptr)
460 : 4690821 : ptr = &(*ptr)->next;
461 : 1907696 : *ptr = entry;
462 : 1907696 : return entry;
463 : : }
464 : :
465 : : /* Remove ENTRY from the list of hooks called on removing edges. */
466 : : void
467 : 1907682 : symbol_table::remove_edge_removal_hook (cgraph_edge_hook_list *entry)
468 : : {
469 : 1907682 : cgraph_edge_hook_list **ptr = &m_first_edge_removal_hook;
470 : :
471 : 5200686 : while (*ptr != entry)
472 : 3293004 : ptr = &(*ptr)->next;
473 : 1907682 : *ptr = entry->next;
474 : 1907682 : free (entry);
475 : 1907682 : }
476 : :
477 : : /* Call all edge removal hooks. */
478 : : void
479 : 45027747 : symbol_table::call_edge_removal_hooks (cgraph_edge *e)
480 : : {
481 : 45027747 : cgraph_edge_hook_list *entry = m_first_edge_removal_hook;
482 : 73662541 : while (entry)
483 : : {
484 : 28634794 : entry->hook (e, entry->data);
485 : 28634794 : entry = entry->next;
486 : : }
487 : 45027747 : }
488 : :
489 : : /* Register HOOK to be called with DATA on each removed node. */
490 : : cgraph_node_hook_list *
491 : 8168983 : symbol_table::add_cgraph_removal_hook (cgraph_node_hook hook, void *data)
492 : : {
493 : 8168983 : cgraph_node_hook_list *entry;
494 : 16337966 : cgraph_node_hook_list **ptr = &m_first_cgraph_removal_hook;
495 : :
496 : 8168983 : entry = (cgraph_node_hook_list *) xmalloc (sizeof (*entry));
497 : 8168983 : entry->hook = hook;
498 : 8168983 : entry->data = data;
499 : 8168983 : entry->next = NULL;
500 : 42795558 : while (*ptr)
501 : 34626575 : ptr = &(*ptr)->next;
502 : 8168983 : *ptr = entry;
503 : 8168983 : return entry;
504 : : }
505 : :
506 : : /* Remove ENTRY from the list of hooks called on removing nodes. */
507 : : void
508 : 8060768 : symbol_table::remove_cgraph_removal_hook (cgraph_node_hook_list *entry)
509 : : {
510 : 8060768 : cgraph_node_hook_list **ptr = &m_first_cgraph_removal_hook;
511 : :
512 : 38250736 : while (*ptr != entry)
513 : 30189968 : ptr = &(*ptr)->next;
514 : 8060768 : *ptr = entry->next;
515 : 8060768 : free (entry);
516 : 8060768 : }
517 : :
518 : : /* Call all node removal hooks. */
519 : : void
520 : 98030532 : symbol_table::call_cgraph_removal_hooks (cgraph_node *node)
521 : : {
522 : 98030532 : cgraph_node_hook_list *entry = m_first_cgraph_removal_hook;
523 : 139037964 : while (entry)
524 : : {
525 : 41007432 : entry->hook (node, entry->data);
526 : 41007432 : entry = entry->next;
527 : : }
528 : 98030532 : }
529 : :
530 : : /* Call all node removal hooks. */
531 : : void
532 : 121177 : symbol_table::call_cgraph_insertion_hooks (cgraph_node *node)
533 : : {
534 : 121177 : cgraph_node_hook_list *entry = m_first_cgraph_insertion_hook;
535 : 364317 : while (entry)
536 : : {
537 : 243140 : entry->hook (node, entry->data);
538 : 243140 : entry = entry->next;
539 : : }
540 : 121177 : }
541 : :
542 : :
543 : : /* Register HOOK to be called with DATA on each inserted node. */
544 : : cgraph_node_hook_list *
545 : 8656091 : symbol_table::add_cgraph_insertion_hook (cgraph_node_hook hook, void *data)
546 : : {
547 : 8656091 : cgraph_node_hook_list *entry;
548 : 17312182 : cgraph_node_hook_list **ptr = &m_first_cgraph_insertion_hook;
549 : :
550 : 8656091 : entry = (cgraph_node_hook_list *) xmalloc (sizeof (*entry));
551 : 8656091 : entry->hook = hook;
552 : 8656091 : entry->data = data;
553 : 8656091 : entry->next = NULL;
554 : 25640472 : while (*ptr)
555 : 16984381 : ptr = &(*ptr)->next;
556 : 8656091 : *ptr = entry;
557 : 8656091 : return entry;
558 : : }
559 : :
560 : : /* Remove ENTRY from the list of hooks called on inserted nodes. */
561 : : void
562 : 8508624 : symbol_table::remove_cgraph_insertion_hook (cgraph_node_hook_list *entry)
563 : : {
564 : 8508624 : cgraph_node_hook_list **ptr = &m_first_cgraph_insertion_hook;
565 : :
566 : 23512761 : while (*ptr != entry)
567 : 15004137 : ptr = &(*ptr)->next;
568 : 8508624 : *ptr = entry->next;
569 : 8508624 : free (entry);
570 : 8508624 : }
571 : :
572 : : /* Register HOOK to be called with DATA on each duplicated edge. */
573 : : cgraph_2edge_hook_list *
574 : 1675638 : symbol_table::add_edge_duplication_hook (cgraph_2edge_hook hook, void *data)
575 : : {
576 : 1675638 : cgraph_2edge_hook_list *entry;
577 : 3351276 : cgraph_2edge_hook_list **ptr = &m_first_edge_duplicated_hook;
578 : :
579 : 1675638 : entry = (cgraph_2edge_hook_list *) xmalloc (sizeof (*entry));
580 : 1675638 : entry->hook = hook;
581 : 1675638 : entry->data = data;
582 : 1675638 : entry->next = NULL;
583 : 5378443 : while (*ptr)
584 : 3702805 : ptr = &(*ptr)->next;
585 : 1675638 : *ptr = entry;
586 : 1675638 : return entry;
587 : : }
588 : :
589 : : /* Remove ENTRY from the list of hooks called on duplicating edges. */
590 : : void
591 : 1675624 : symbol_table::remove_edge_duplication_hook (cgraph_2edge_hook_list *entry)
592 : : {
593 : 1675624 : cgraph_2edge_hook_list **ptr = &m_first_edge_duplicated_hook;
594 : :
595 : 3980612 : while (*ptr != entry)
596 : 2304988 : ptr = &(*ptr)->next;
597 : 1675624 : *ptr = entry->next;
598 : 1675624 : free (entry);
599 : 1675624 : }
600 : :
601 : : /* Call all edge duplication hooks. */
602 : : void
603 : 7043447 : symbol_table::call_edge_duplication_hooks (cgraph_edge *cs1, cgraph_edge *cs2)
604 : : {
605 : 7043447 : cgraph_2edge_hook_list *entry = m_first_edge_duplicated_hook;
606 : 20952638 : while (entry)
607 : : {
608 : 13909191 : entry->hook (cs1, cs2, entry->data);
609 : 13909191 : entry = entry->next;
610 : : }
611 : 7043447 : }
612 : :
613 : : /* Register HOOK to be called with DATA on each duplicated node. */
614 : : cgraph_2node_hook_list *
615 : 8027023 : symbol_table::add_cgraph_duplication_hook (cgraph_2node_hook hook, void *data)
616 : : {
617 : 8027023 : cgraph_2node_hook_list *entry;
618 : 16054046 : cgraph_2node_hook_list **ptr = &m_first_cgraph_duplicated_hook;
619 : :
620 : 8027023 : entry = (cgraph_2node_hook_list *) xmalloc (sizeof (*entry));
621 : 8027023 : entry->hook = hook;
622 : 8027023 : entry->data = data;
623 : 8027023 : entry->next = NULL;
624 : 39767280 : while (*ptr)
625 : 31740257 : ptr = &(*ptr)->next;
626 : 8027023 : *ptr = entry;
627 : 8027023 : return entry;
628 : : }
629 : :
630 : : /* Remove ENTRY from the list of hooks called on duplicating nodes. */
631 : : void
632 : 7931818 : symbol_table::remove_cgraph_duplication_hook (cgraph_2node_hook_list *entry)
633 : : {
634 : 7931818 : cgraph_2node_hook_list **ptr = &m_first_cgraph_duplicated_hook;
635 : :
636 : 36184908 : while (*ptr != entry)
637 : 28253090 : ptr = &(*ptr)->next;
638 : 7931818 : *ptr = entry->next;
639 : 7931818 : free (entry);
640 : 7931818 : }
641 : :
642 : : /* Call all node duplication hooks. */
643 : : void
644 : 3216276 : symbol_table::call_cgraph_duplication_hooks (cgraph_node *node,
645 : : cgraph_node *node2)
646 : : {
647 : 3216276 : cgraph_2node_hook_list *entry = m_first_cgraph_duplicated_hook;
648 : 22740263 : while (entry)
649 : : {
650 : 19523987 : entry->hook (node, node2, entry->data);
651 : 19523987 : entry = entry->next;
652 : : }
653 : 3216276 : }
654 : :
655 : : /* Return cgraph node assigned to DECL. Create new one when needed. */
656 : :
657 : : cgraph_node *
658 : 98335997 : cgraph_node::create (tree decl)
659 : : {
660 : 98335997 : cgraph_node *node = symtab->create_empty ();
661 : 98335997 : gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
662 : :
663 : 98335997 : node->decl = decl;
664 : 98335997 : node->semantic_interposition = opt_for_fn (decl, flag_semantic_interposition);
665 : :
666 : 98276397 : if ((flag_openacc || flag_openmp)
667 : 98601196 : && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
668 : : {
669 : 8372 : node->offloadable = 1;
670 : 8372 : if (ENABLE_OFFLOADING)
671 : : g->have_offload = true;
672 : : }
673 : :
674 : 98335997 : if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl)))
675 : 122 : node->ifunc_resolver = true;
676 : :
677 : 98335997 : node->register_symbol ();
678 : 98335997 : maybe_record_nested_function (node);
679 : :
680 : 98335997 : return node;
681 : : }
682 : :
683 : : /* Try to find a call graph node for declaration DECL and if it does not exist
684 : : or if it corresponds to an inline clone, create a new one. */
685 : :
686 : : cgraph_node *
687 : 539212326 : cgraph_node::get_create (tree decl)
688 : : {
689 : 539212326 : cgraph_node *first_clone = cgraph_node::get (decl);
690 : :
691 : 539212326 : if (first_clone && !first_clone->inlined_to)
692 : : return first_clone;
693 : :
694 : 98267501 : cgraph_node *node = cgraph_node::create (decl);
695 : 98267501 : if (first_clone)
696 : : {
697 : 8 : first_clone->clone_of = node;
698 : 8 : node->clones = first_clone;
699 : 8 : node->order = first_clone->order;
700 : 8 : symtab->symtab_prevail_in_asm_name_hash (node);
701 : 8 : node->decl->decl_with_vis.symtab_node = node;
702 : 8 : if (dump_file && symtab->state != PARSING)
703 : 2 : fprintf (dump_file, "Introduced new external node "
704 : : "(%s) and turned into root of the clone tree.\n",
705 : : node->dump_name ());
706 : : }
707 : 98267493 : else if (dump_file && symtab->state != PARSING)
708 : 1138 : fprintf (dump_file, "Introduced new external node "
709 : : "(%s).\n", node->dump_name ());
710 : : return node;
711 : : }
712 : :
713 : : /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing
714 : : the function body is associated with
715 : : (not necessarily cgraph_node (DECL)). */
716 : :
717 : : cgraph_node *
718 : 7133510 : cgraph_node::create_alias (tree alias, tree target)
719 : : {
720 : 7133510 : cgraph_node *alias_node;
721 : :
722 : 7133510 : gcc_assert (TREE_CODE (target) == FUNCTION_DECL
723 : : || TREE_CODE (target) == IDENTIFIER_NODE);
724 : 7133510 : gcc_assert (TREE_CODE (alias) == FUNCTION_DECL);
725 : 7133510 : alias_node = cgraph_node::get_create (alias);
726 : 7133510 : gcc_assert (!alias_node->definition);
727 : 7133510 : alias_node->alias_target = target;
728 : 7133510 : alias_node->definition = true;
729 : 7133510 : alias_node->alias = true;
730 : 7133510 : if (lookup_attribute ("weakref", DECL_ATTRIBUTES (alias)) != NULL)
731 : 47 : alias_node->transparent_alias = alias_node->weakref = true;
732 : 7133510 : if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (alias)))
733 : 317 : alias_node->ifunc_resolver = true;
734 : 7133510 : return alias_node;
735 : : }
736 : :
737 : : /* Attempt to mark ALIAS as an alias to DECL. Return alias node if successful
738 : : and NULL otherwise.
739 : : Same body aliases are output whenever the body of DECL is output,
740 : : and cgraph_node::get (ALIAS) transparently returns
741 : : cgraph_node::get (DECL). */
742 : :
743 : : cgraph_node *
744 : 7113603 : cgraph_node::create_same_body_alias (tree alias, tree decl)
745 : : {
746 : 7113603 : cgraph_node *n;
747 : :
748 : : /* If aliases aren't supported by the assembler, fail. */
749 : 7113603 : if (!TARGET_SUPPORTS_ALIASES)
750 : : return NULL;
751 : :
752 : : /* Langhooks can create same body aliases of symbols not defined.
753 : : Those are useless. Drop them on the floor. */
754 : 7113603 : if (symtab->global_info_ready)
755 : : return NULL;
756 : :
757 : 7113603 : n = cgraph_node::create_alias (alias, decl);
758 : 7113603 : n->cpp_implicit_alias = true;
759 : 7113603 : if (symtab->cpp_implicit_aliases_done)
760 : 3685508 : n->resolve_alias (cgraph_node::get (decl));
761 : : return n;
762 : : }
763 : :
764 : : /* Add thunk alias into callgraph. The alias declaration is ALIAS and it
765 : : aliases DECL with an adjustments made into the first parameter.
766 : : See comments in struct cgraph_thunk_info for detail on the parameters. */
767 : :
768 : : cgraph_node *
769 : 4398 : cgraph_node::create_thunk (tree alias, tree, bool this_adjusting,
770 : : HOST_WIDE_INT fixed_offset,
771 : : HOST_WIDE_INT virtual_value,
772 : : HOST_WIDE_INT indirect_offset,
773 : : tree virtual_offset,
774 : : tree real_alias)
775 : : {
776 : 4398 : cgraph_node *node;
777 : :
778 : 4398 : node = cgraph_node::get (alias);
779 : 4398 : if (node)
780 : 3664 : node->reset ();
781 : : else
782 : 734 : node = cgraph_node::create (alias);
783 : :
784 : : /* Make sure that if VIRTUAL_OFFSET is in sync with VIRTUAL_VALUE. */
785 : 4398 : gcc_checking_assert (virtual_offset
786 : : ? virtual_value == wi::to_wide (virtual_offset)
787 : : : virtual_value == 0);
788 : :
789 : 4398 : node->thunk = true;
790 : 4398 : node->definition = true;
791 : :
792 : 4398 : thunk_info *i;
793 : 4398 : thunk_info local_info;
794 : 4398 : if (symtab->state < CONSTRUCTION)
795 : : i = &local_info;
796 : : else
797 : 0 : i = thunk_info::get_create (node);
798 : 4398 : i->fixed_offset = fixed_offset;
799 : 4398 : i->virtual_value = virtual_value;
800 : 4398 : i->indirect_offset = indirect_offset;
801 : 4398 : i->alias = real_alias;
802 : 4398 : i->this_adjusting = this_adjusting;
803 : 4398 : i->virtual_offset_p = virtual_offset != NULL;
804 : 4398 : if (symtab->state < CONSTRUCTION)
805 : 4398 : i->register_early (node);
806 : :
807 : 4398 : return node;
808 : : }
809 : :
810 : : /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
811 : : Return NULL if there's no such node. */
812 : :
813 : : cgraph_node *
814 : 0 : cgraph_node::get_for_asmname (tree asmname)
815 : : {
816 : : /* We do not want to look at inline clones. */
817 : 0 : for (symtab_node *node = symtab_node::get_for_asmname (asmname);
818 : 0 : node;
819 : 0 : node = node->next_sharing_asm_name)
820 : : {
821 : 0 : cgraph_node *cn = dyn_cast <cgraph_node *> (node);
822 : 0 : if (cn && !cn->inlined_to)
823 : : return cn;
824 : : }
825 : : return NULL;
826 : : }
827 : :
828 : : /* Returns a hash value for X (which really is a cgraph_edge). */
829 : :
830 : : hashval_t
831 : 218003483 : cgraph_edge_hasher::hash (cgraph_edge *e)
832 : : {
833 : : /* This is a really poor hash function, but it is what htab_hash_pointer
834 : : uses. */
835 : 218003483 : return (hashval_t) ((intptr_t)e->call_stmt >> 3);
836 : : }
837 : :
838 : : /* Returns a hash value for X (which really is a cgraph_edge). */
839 : :
840 : : hashval_t
841 : 43288451 : cgraph_edge_hasher::hash (gimple *call_stmt)
842 : : {
843 : : /* This is a really poor hash function, but it is what htab_hash_pointer
844 : : uses. */
845 : 43288451 : return (hashval_t) ((intptr_t)call_stmt >> 3);
846 : : }
847 : :
848 : : /* Return nonzero if the call_stmt of cgraph_edge X is stmt *Y. */
849 : :
850 : : inline bool
851 : 266891153 : cgraph_edge_hasher::equal (cgraph_edge *x, gimple *y)
852 : : {
853 : 266891153 : return x->call_stmt == y;
854 : : }
855 : :
856 : : /* Add call graph edge E to call site hash of its caller. */
857 : :
858 : : static inline void
859 : 4026 : cgraph_update_edge_in_call_site_hash (cgraph_edge *e)
860 : : {
861 : 4026 : gimple *call = e->call_stmt;
862 : 4026 : *e->caller->call_site_hash->find_slot_with_hash
863 : 4026 : (call, cgraph_edge_hasher::hash (call), INSERT) = e;
864 : 4026 : }
865 : :
866 : : /* Add call graph edge E to call site hash of its caller. */
867 : :
868 : : static inline void
869 : 8190716 : cgraph_add_edge_to_call_site_hash (cgraph_edge *e)
870 : : {
871 : : /* There are two speculative edges for every statement (one direct,
872 : : one indirect); always hash the direct one. */
873 : 8190716 : if (e->speculative && e->indirect_unknown_callee)
874 : : return;
875 : : /* We always want to hash the carrying edge of a callback, not the edges
876 : : pointing to the callbacks themselves, as their call statement doesn't
877 : : exist. */
878 : 8190705 : if (e->callback)
879 : : return;
880 : 8190693 : cgraph_edge **slot = e->caller->call_site_hash->find_slot_with_hash
881 : 8190693 : (e->call_stmt, cgraph_edge_hasher::hash (e->call_stmt), INSERT);
882 : 8190693 : if (*slot)
883 : : {
884 : 4107 : cgraph_edge *edge = (cgraph_edge *) *slot;
885 : 4107 : gcc_assert (edge->speculative || edge->has_callback);
886 : 4107 : if (edge->has_callback)
887 : : /* If the slot is already occupied, then the hashed edge is the
888 : : callback-carrying edge, which is desired behavior. In some cases,
889 : : the callback flag of E is not set yet and so the early exit above is
890 : : not taken. */
891 : : return;
892 : 4015 : if (e->callee && (!e->prev_callee
893 : 4 : || !e->prev_callee->speculative
894 : 4 : || e->prev_callee->call_stmt != e->call_stmt))
895 : 507 : *slot = e;
896 : 4015 : return;
897 : : }
898 : 8186586 : gcc_assert (!*slot || e->speculative);
899 : 8186586 : *slot = e;
900 : : }
901 : :
902 : : /* Return the callgraph edge representing the GIMPLE_CALL statement
903 : : CALL_STMT. */
904 : :
905 : : cgraph_edge *
906 : 210180503 : cgraph_node::get_edge (gimple *call_stmt)
907 : : {
908 : 210180503 : cgraph_edge *e, *e2;
909 : 210180503 : int n = 0;
910 : :
911 : 210180503 : if (call_site_hash)
912 : 34049796 : return call_site_hash->find_with_hash
913 : 34049796 : (call_stmt, cgraph_edge_hasher::hash (call_stmt));
914 : :
915 : : /* This loop may turn out to be performance problem. In such case adding
916 : : hashtables into call nodes with very many edges is probably best
917 : : solution. It is not good idea to add pointer into CALL_EXPR itself
918 : : because we want to make possible having multiple cgraph nodes representing
919 : : different clones of the same body before the body is actually cloned. */
920 : 1716703886 : for (e = callees; e; e = e->next_callee)
921 : : {
922 : 1668731620 : if (e->call_stmt == call_stmt)
923 : : break;
924 : 1540573179 : n++;
925 : : }
926 : :
927 : 176130707 : if (!e)
928 : 61808608 : for (e = indirect_calls; e; e = e->next_callee)
929 : : {
930 : 16777587 : if (e->call_stmt == call_stmt)
931 : : break;
932 : 13836342 : n++;
933 : : }
934 : :
935 : : /* We want to work with the callback-carrying edge whenever possible. When it
936 : : comes to callback edges, a call statement might have multiple callback
937 : : edges attached to it. These can be easily obtained from the carrying edge
938 : : instead. */
939 : 176130707 : if (e && e->callback)
940 : 55382 : e = e->get_callback_carrying_edge ();
941 : :
942 : 176130707 : if (n > 100)
943 : : {
944 : 30254 : call_site_hash = hash_table<cgraph_edge_hasher>::create_ggc (120);
945 : 3106162 : for (e2 = callees; e2; e2 = e2->next_callee)
946 : 3075908 : cgraph_add_edge_to_call_site_hash (e2);
947 : 114281 : for (e2 = indirect_calls; e2; e2 = e2->next_callee)
948 : 84027 : cgraph_add_edge_to_call_site_hash (e2);
949 : : }
950 : :
951 : : return e;
952 : : }
953 : :
954 : : /* Change field call_stmt of edge E to NEW_STMT. If UPDATE_DERIVED_EDGES and E
955 : : is any component of speculative edge, then update all components.
956 : : speculations can be resolved in the process and edge can be removed and
957 : : deallocated. if update_derived_edges and e is a part of a callback pair,
958 : : update all associated edges and return their carrying edge. return the edge
959 : : that now represents the call. */
960 : :
961 : : cgraph_edge *
962 : 2766590 : cgraph_edge::set_call_stmt (cgraph_edge *e, gcall *new_stmt,
963 : : bool update_derived_edges)
964 : : {
965 : 2766590 : tree decl;
966 : :
967 : 2766590 : cgraph_node *new_direct_callee = NULL;
968 : 2730890 : if ((e->indirect_unknown_callee || e->speculative)
969 : 2817843 : && (decl = gimple_call_fndecl (new_stmt)))
970 : : {
971 : : /* Constant propagation and especially inlining can turn an indirect call
972 : : into a direct one. */
973 : 0 : new_direct_callee = cgraph_node::get (decl);
974 : 0 : gcc_checking_assert (new_direct_callee);
975 : : }
976 : :
977 : : /* Speculative edges has three component, update all of them
978 : : when asked to. */
979 : 2766590 : if (update_derived_edges && e->speculative
980 : : /* If we are about to resolve the speculation by calling make_direct
981 : : below, do not bother going over all the speculative edges now. */
982 : 6872 : && !new_direct_callee)
983 : : {
984 : 6872 : cgraph_edge *direct, *indirect, *next;
985 : 6872 : ipa_ref *ref;
986 : 6872 : bool e_indirect = e->indirect_unknown_callee;
987 : 6872 : int n = 0;
988 : :
989 : 6872 : direct = e->first_speculative_call_target ();
990 : 6872 : indirect = e->speculative_call_indirect_edge ();
991 : :
992 : 6872 : gcall *old_stmt = direct->call_stmt;
993 : 15553 : for (cgraph_edge *d = direct; d; d = next)
994 : : {
995 : 8681 : next = d->next_speculative_call_target ();
996 : 8681 : cgraph_edge *d2 = set_call_stmt (d, new_stmt, false);
997 : 8681 : gcc_assert (d2 == d);
998 : 8681 : n++;
999 : : }
1000 : 6872 : gcc_checking_assert (indirect->num_speculative_call_targets_p () == n);
1001 : 19733 : for (unsigned int i = 0; e->caller->iterate_reference (i, ref); i++)
1002 : 12861 : if (ref->speculative && ref->stmt == old_stmt)
1003 : : {
1004 : 8681 : ref->stmt = new_stmt;
1005 : 8681 : n--;
1006 : : }
1007 : :
1008 : 6872 : indirect = set_call_stmt (indirect, new_stmt, false);
1009 : 6872 : return e_indirect ? indirect : direct;
1010 : : }
1011 : :
1012 : 2759718 : if (new_direct_callee)
1013 : 0 : e = make_direct (e, new_direct_callee);
1014 : :
1015 : : /* When updating a callback or a callback-carrying edge, update every edge
1016 : : involved. */
1017 : 2759718 : if (update_derived_edges && (e->callback || e->has_callback))
1018 : : {
1019 : 753 : cgraph_edge *current, *next, *carrying;
1020 : 753 : carrying = e->has_callback ? e : e->get_callback_carrying_edge ();
1021 : :
1022 : 753 : current = e->first_callback_edge ();
1023 : 753 : if (current)
1024 : : {
1025 : 106 : for (cgraph_edge *d = current; d; d = next)
1026 : : {
1027 : 53 : next = d->next_callback_edge ();
1028 : 53 : cgraph_edge *d2 = set_call_stmt (d, new_stmt, false);
1029 : 53 : gcc_assert (d2 == d);
1030 : : }
1031 : : }
1032 : 753 : carrying = set_call_stmt (carrying, new_stmt, false);
1033 : 753 : return carrying;
1034 : : }
1035 : :
1036 : : /* Only direct speculative edges go to call_site_hash. */
1037 : 2758965 : if (e->caller->call_site_hash
1038 : 473829 : && (!e->speculative || !e->indirect_unknown_callee)
1039 : : /* It is possible that edge was previously speculative. In this case
1040 : : we have different value in call stmt hash which needs preserving. */
1041 : 3232794 : && e->caller->get_edge (e->call_stmt) == e)
1042 : 469801 : e->caller->call_site_hash->remove_elt_with_hash
1043 : 469801 : (e->call_stmt, cgraph_edge_hasher::hash (e->call_stmt));
1044 : :
1045 : 2758965 : e->call_stmt = new_stmt;
1046 : :
1047 : 2758965 : function *fun = DECL_STRUCT_FUNCTION (e->caller->decl);
1048 : 2758965 : e->can_throw_external = stmt_can_throw_external (fun, new_stmt);
1049 : : /* Update call stite hash. For speculative calls we only record the first
1050 : : direct edge. */
1051 : 2758965 : if (e->caller->call_site_hash
1052 : 473829 : && (!e->speculative
1053 : 0 : || (e->callee
1054 : 0 : && (!e->prev_callee || !e->prev_callee->speculative
1055 : 0 : || e->prev_callee->call_stmt != e->call_stmt))
1056 : 0 : || (e->speculative && !e->callee)))
1057 : 473829 : cgraph_add_edge_to_call_site_hash (e);
1058 : : return e;
1059 : : }
1060 : :
1061 : : /* Allocate a cgraph_edge structure and fill it with data according to the
1062 : : parameters of which only CALLEE can be NULL (when creating an indirect call
1063 : : edge). CLONING_P should be set if properties that are copied from an
1064 : : original edge should not be calculated. */
1065 : :
1066 : : cgraph_edge *
1067 : 45466988 : symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
1068 : : gcall *call_stmt, profile_count count,
1069 : : bool indir_unknown_callee, bool cloning_p)
1070 : : {
1071 : 45466988 : cgraph_edge *edge;
1072 : :
1073 : : /* LTO does not actually have access to the call_stmt since these
1074 : : have not been loaded yet. */
1075 : 45466988 : if (call_stmt)
1076 : : {
1077 : : /* This is a rather expensive check possibly triggering
1078 : : construction of call stmt hashtable. */
1079 : 44611207 : cgraph_edge *e;
1080 : 44611207 : gcc_checking_assert (!(e = caller->get_edge (call_stmt))
1081 : : || e->speculative || e->has_callback || e->callback);
1082 : :
1083 : 44611207 : gcc_assert (is_gimple_call (call_stmt));
1084 : : }
1085 : :
1086 : 45466988 : edge = ggc_alloc<cgraph_edge> ();
1087 : 45466988 : edge->m_summary_id = -1;
1088 : 45466988 : edges_count++;
1089 : :
1090 : 45466988 : ++edges_max_uid;
1091 : 45466988 : gcc_assert (edges_max_uid != 0);
1092 : 45466988 : edge->m_uid = edges_max_uid;
1093 : 45466988 : edge->aux = NULL;
1094 : 45466988 : edge->caller = caller;
1095 : 45466988 : edge->callee = callee;
1096 : 45466988 : edge->prev_caller = NULL;
1097 : 45466988 : edge->next_caller = NULL;
1098 : 45466988 : edge->prev_callee = NULL;
1099 : 45466988 : edge->next_callee = NULL;
1100 : 45466988 : edge->lto_stmt_uid = 0;
1101 : 45466988 : edge->speculative_id = 0;
1102 : :
1103 : 45466988 : edge->count = count;
1104 : 45466988 : edge->call_stmt = call_stmt;
1105 : 45466988 : edge->indirect_info = NULL;
1106 : 45466988 : edge->indirect_inlining_edge = 0;
1107 : 45466988 : edge->speculative = false;
1108 : 45466988 : edge->has_callback = false;
1109 : 45466988 : edge->callback = false;
1110 : 45466988 : edge->callback_id = 0;
1111 : 45466988 : edge->indirect_unknown_callee = indir_unknown_callee;
1112 : 45466988 : if (call_stmt && caller->call_site_hash)
1113 : 4556952 : cgraph_add_edge_to_call_site_hash (edge);
1114 : :
1115 : 45466988 : if (cloning_p)
1116 : : return edge;
1117 : :
1118 : 38443319 : edge->can_throw_external
1119 : 38443319 : = call_stmt ? stmt_can_throw_external (DECL_STRUCT_FUNCTION (caller->decl),
1120 : : call_stmt) : false;
1121 : 38443319 : edge->inline_failed = CIF_FUNCTION_NOT_CONSIDERED;
1122 : 38443319 : edge->call_stmt_cannot_inline_p = false;
1123 : :
1124 : 38443319 : if (opt_for_fn (edge->caller->decl, flag_devirtualize)
1125 : 38443319 : && call_stmt && DECL_STRUCT_FUNCTION (caller->decl))
1126 : 30351447 : edge->in_polymorphic_cdtor
1127 : 30351447 : = decl_maybe_in_construction_p (NULL, NULL, call_stmt,
1128 : : caller->decl);
1129 : : else
1130 : 8091872 : edge->in_polymorphic_cdtor = caller->thunk;
1131 : :
1132 : 37768135 : if (callee && symtab->state != LTO_STREAMING
1133 : 75615868 : && edge->callee->comdat_local_p ())
1134 : 7696 : edge->caller->calls_comdat_local = true;
1135 : :
1136 : : return edge;
1137 : : }
1138 : :
1139 : : /* Create edge from a given function to CALLEE in the cgraph. CLONING_P should
1140 : : be set if properties that are copied from an original edge should not be
1141 : : calculated. */
1142 : :
1143 : : cgraph_edge *
1144 : 44603634 : cgraph_node::create_edge (cgraph_node *callee,
1145 : : gcall *call_stmt, profile_count count, bool cloning_p)
1146 : : {
1147 : 44603634 : cgraph_edge *edge = symtab->create_edge (this, callee, call_stmt, count,
1148 : : false, cloning_p);
1149 : :
1150 : 44603634 : if (!cloning_p)
1151 : 37768135 : initialize_inline_failed (edge);
1152 : :
1153 : 44603634 : edge->next_caller = callee->callers;
1154 : 44603634 : if (callee->callers)
1155 : 34672536 : callee->callers->prev_caller = edge;
1156 : 44603634 : edge->next_callee = callees;
1157 : 44603634 : if (callees)
1158 : 34496619 : callees->prev_callee = edge;
1159 : 44603634 : callees = edge;
1160 : 44603634 : callee->callers = edge;
1161 : :
1162 : 44603634 : return edge;
1163 : : }
1164 : :
1165 : : /* Allocate cgraph_indirect_call_info and set its fields to default values. */
1166 : :
1167 : : cgraph_indirect_call_info *
1168 : 863354 : cgraph_allocate_init_indirect_info (void)
1169 : : {
1170 : 863354 : cgraph_indirect_call_info *ii;
1171 : :
1172 : 863354 : ii = ggc_cleared_alloc<cgraph_indirect_call_info> ();
1173 : 863354 : ii->param_index = -1;
1174 : 863354 : return ii;
1175 : : }
1176 : :
1177 : : /* Create an indirect edge with a yet-undetermined callee where the call
1178 : : statement destination is a formal parameter of the caller with index
1179 : : PARAM_INDEX. CLONING_P should be set if properties that are copied from an
1180 : : original edge should not be calculated and indirect_info structure should
1181 : : not be calculated. */
1182 : :
1183 : : cgraph_edge *
1184 : 863354 : cgraph_node::create_indirect_edge (gcall *call_stmt, int ecf_flags,
1185 : : profile_count count,
1186 : : bool cloning_p)
1187 : : {
1188 : 863354 : cgraph_edge *edge = symtab->create_edge (this, NULL, call_stmt, count, true,
1189 : : cloning_p);
1190 : 863354 : tree target;
1191 : :
1192 : 863354 : if (!cloning_p)
1193 : 675184 : initialize_inline_failed (edge);
1194 : :
1195 : 863354 : edge->indirect_info = cgraph_allocate_init_indirect_info ();
1196 : 863354 : edge->indirect_info->ecf_flags = ecf_flags;
1197 : 863354 : edge->indirect_info->vptr_changed = true;
1198 : :
1199 : : /* Record polymorphic call info. */
1200 : 863354 : if (!cloning_p
1201 : 863354 : && call_stmt
1202 : 672827 : && (target = gimple_call_fn (call_stmt))
1203 : 1536181 : && virtual_method_call_p (target))
1204 : : {
1205 : 101392 : ipa_polymorphic_call_context context (decl, target, call_stmt);
1206 : :
1207 : : /* Only record types can have virtual calls. */
1208 : 101392 : edge->indirect_info->polymorphic = true;
1209 : 101392 : edge->indirect_info->param_index = -1;
1210 : 101392 : edge->indirect_info->otr_token
1211 : 101392 : = tree_to_uhwi (OBJ_TYPE_REF_TOKEN (target));
1212 : 101392 : edge->indirect_info->otr_type = obj_type_ref_class (target);
1213 : 101392 : gcc_assert (TREE_CODE (edge->indirect_info->otr_type) == RECORD_TYPE);
1214 : 101392 : edge->indirect_info->context = context;
1215 : : }
1216 : :
1217 : 863354 : edge->next_callee = indirect_calls;
1218 : 863354 : if (indirect_calls)
1219 : 412443 : indirect_calls->prev_callee = edge;
1220 : 863354 : indirect_calls = edge;
1221 : :
1222 : 863354 : return edge;
1223 : : }
1224 : :
1225 : : /* Remove the edge from the list of the callees of the caller. */
1226 : :
1227 : : void
1228 : 4721756 : cgraph_edge::remove_caller (void)
1229 : : {
1230 : 4721756 : if (prev_callee)
1231 : 3825881 : prev_callee->next_callee = next_callee;
1232 : 4721756 : if (next_callee)
1233 : 3214149 : next_callee->prev_callee = prev_callee;
1234 : 4721756 : if (!prev_callee)
1235 : : {
1236 : 895875 : if (indirect_unknown_callee)
1237 : 1495 : caller->indirect_calls = next_callee;
1238 : : else
1239 : 894380 : caller->callees = next_callee;
1240 : : }
1241 : 4721756 : if (caller->call_site_hash
1242 : 4721756 : && this == caller->get_edge (call_stmt))
1243 : 574135 : caller->call_site_hash->remove_elt_with_hash
1244 : 574135 : (call_stmt, cgraph_edge_hasher::hash (call_stmt));
1245 : 4721756 : }
1246 : :
1247 : : /* Put the edge onto the free list. */
1248 : :
1249 : : void
1250 : 45027747 : symbol_table::free_edge (cgraph_edge *e)
1251 : : {
1252 : 45027747 : edges_count--;
1253 : 45027747 : if (e->m_summary_id != -1)
1254 : 21068689 : edge_released_summary_ids.safe_push (e->m_summary_id);
1255 : :
1256 : 45027747 : if (e->indirect_info)
1257 : 856661 : ggc_free (e->indirect_info);
1258 : 45027747 : ggc_free (e);
1259 : 45027747 : }
1260 : :
1261 : : /* Remove the edge in the cgraph. */
1262 : :
1263 : : void
1264 : 115832 : cgraph_edge::remove (cgraph_edge *edge)
1265 : : {
1266 : : /* Call all edge removal hooks. */
1267 : 115832 : symtab->call_edge_removal_hooks (edge);
1268 : :
1269 : 115832 : if (!edge->indirect_unknown_callee)
1270 : : /* Remove from callers list of the callee. */
1271 : 112945 : edge->remove_callee ();
1272 : :
1273 : : /* Remove from callees list of the callers. */
1274 : 115832 : edge->remove_caller ();
1275 : :
1276 : : /* Put the edge onto the free list. */
1277 : 115832 : symtab->free_edge (edge);
1278 : 115832 : }
1279 : :
1280 : : /* Turn edge into speculative call calling N2. Update
1281 : : the profile so the direct call is taken COUNT times
1282 : : with FREQUENCY.
1283 : :
1284 : : At clone materialization time, the indirect call E will
1285 : : be expanded as:
1286 : :
1287 : : if (call_dest == N2)
1288 : : n2 ();
1289 : : else
1290 : : call call_dest
1291 : :
1292 : : At this time the function just creates the direct call,
1293 : : the reference representing the if conditional and attaches
1294 : : them all to the original indirect call statement.
1295 : :
1296 : : speculative_id is used to link direct calls with their corresponding
1297 : : IPA_REF_ADDR references when representing speculative calls.
1298 : :
1299 : : Return direct edge created. */
1300 : :
1301 : : cgraph_edge *
1302 : 19747 : cgraph_edge::make_speculative (cgraph_node *n2, profile_count direct_count,
1303 : : unsigned int speculative_id)
1304 : : {
1305 : 19747 : cgraph_node *n = caller;
1306 : 19747 : ipa_ref *ref = NULL;
1307 : 19747 : cgraph_edge *e2;
1308 : :
1309 : 19747 : if (dump_file)
1310 : 26 : fprintf (dump_file, "Indirect call -> speculative call %s => %s\n",
1311 : : n->dump_name (), n2->dump_name ());
1312 : 19747 : speculative = true;
1313 : 19747 : e2 = n->create_edge (n2, call_stmt, direct_count);
1314 : 19747 : initialize_inline_failed (e2);
1315 : 19747 : e2->speculative = true;
1316 : 19747 : if (TREE_NOTHROW (n2->decl))
1317 : 9534 : e2->can_throw_external = false;
1318 : : else
1319 : 10213 : e2->can_throw_external = can_throw_external;
1320 : 19747 : e2->lto_stmt_uid = lto_stmt_uid;
1321 : 19747 : e2->speculative_id = speculative_id;
1322 : 19747 : e2->in_polymorphic_cdtor = in_polymorphic_cdtor;
1323 : 19747 : indirect_info->num_speculative_call_targets++;
1324 : 19747 : count -= e2->count;
1325 : 19747 : symtab->call_edge_duplication_hooks (this, e2);
1326 : 19747 : ref = n->create_reference (n2, IPA_REF_ADDR, call_stmt);
1327 : 19747 : ref->lto_stmt_uid = lto_stmt_uid;
1328 : 19747 : ref->speculative_id = speculative_id;
1329 : 19747 : ref->speculative = speculative;
1330 : 19747 : n2->mark_address_taken ();
1331 : 19747 : return e2;
1332 : : }
1333 : :
1334 : : /* Create a callback edge calling N2. Callback edges
1335 : : never get turned into actual calls, they are just used
1336 : : as clues and allow for optimizing functions which do not
1337 : : have any callsites during compile time, e.g. functions
1338 : : passed to standard library functions.
1339 : :
1340 : : The edge will be attached to the same call statement as
1341 : : the callback-carrying edge, which is the instance this method
1342 : : is called on.
1343 : :
1344 : : callback_id is used to pair the returned edge with the attribute that
1345 : : originated it.
1346 : :
1347 : : Return the resulting callback edge. */
1348 : :
1349 : : cgraph_edge *
1350 : 15052 : cgraph_edge::make_callback (cgraph_node *n2, unsigned int callback_id)
1351 : : {
1352 : 15052 : cgraph_node *n = caller;
1353 : 15052 : cgraph_edge *e2;
1354 : :
1355 : 15052 : has_callback = true;
1356 : 15052 : e2 = n->create_edge (n2, call_stmt, count);
1357 : 15052 : if (dump_file)
1358 : 3 : fprintf (
1359 : : dump_file,
1360 : : "Created callback edge %s -> %s belonging to carrying edge %s -> %s\n",
1361 : 3 : e2->caller->dump_name (), e2->callee->dump_name (), caller->dump_name (),
1362 : 3 : callee->dump_name ());
1363 : 15052 : e2->inline_failed = CIF_CALLBACK_EDGE;
1364 : 15052 : e2->callback = true;
1365 : 15052 : e2->callback_id = callback_id;
1366 : 15052 : if (TREE_NOTHROW (n2->decl))
1367 : 14801 : e2->can_throw_external = false;
1368 : : else
1369 : 251 : e2->can_throw_external = can_throw_external;
1370 : 15052 : e2->lto_stmt_uid = lto_stmt_uid;
1371 : 15052 : n2->mark_address_taken ();
1372 : 15052 : return e2;
1373 : : }
1374 : :
1375 : : /* Returns the callback_carrying edge of a callback edge on which
1376 : : it is called on or NULL when no such edge can be found.
1377 : :
1378 : : An edge is taken to be the callback-carrying if it has it's has_callback
1379 : : flag set and the edges share their call statements. */
1380 : :
1381 : : cgraph_edge *
1382 : 82876 : cgraph_edge::get_callback_carrying_edge ()
1383 : : {
1384 : 82876 : gcc_checking_assert (callback);
1385 : 82876 : cgraph_edge *e;
1386 : 653389 : for (e = caller->callees; e; e = e->next_callee)
1387 : : {
1388 : 653199 : if (e->has_callback && e->call_stmt == call_stmt
1389 : 82686 : && e->lto_stmt_uid == lto_stmt_uid)
1390 : : break;
1391 : : }
1392 : 82876 : return e;
1393 : : }
1394 : :
1395 : : /* Returns the first callback edge in the list of callees of the caller node.
1396 : : Note that the edges might be in arbitrary order. Must be called on a
1397 : : callback or callback-carrying edge. */
1398 : :
1399 : : cgraph_edge *
1400 : 47425 : cgraph_edge::first_callback_edge ()
1401 : : {
1402 : 47425 : gcc_checking_assert (has_callback || callback);
1403 : 47425 : cgraph_edge *e = NULL;
1404 : 217238 : for (e = caller->callees; e; e = e->next_callee)
1405 : : {
1406 : 201027 : if (e->callback && e->call_stmt == call_stmt
1407 : 31214 : && e->lto_stmt_uid == lto_stmt_uid)
1408 : : break;
1409 : : }
1410 : 47425 : return e;
1411 : : }
1412 : :
1413 : : /* Given a callback edge, returns the next callback edge belonging to the same
1414 : : carrying edge. Must be called on a callback edge, not the callback-carrying
1415 : : edge. */
1416 : :
1417 : : cgraph_edge *
1418 : 31214 : cgraph_edge::next_callback_edge ()
1419 : : {
1420 : 31214 : gcc_checking_assert (callback);
1421 : 31214 : cgraph_edge *e = NULL;
1422 : 320930 : for (e = next_callee; e; e = e->next_callee)
1423 : : {
1424 : 289716 : if (e->callback && e->call_stmt == call_stmt
1425 : 0 : && e->lto_stmt_uid == lto_stmt_uid)
1426 : : break;
1427 : : }
1428 : 31214 : return e;
1429 : : }
1430 : :
1431 : : /* When called on a callback-carrying edge, removes all of its attached callback
1432 : : edges and sets has_callback to FALSE. */
1433 : :
1434 : : void
1435 : 2 : cgraph_edge::purge_callback_edges ()
1436 : : {
1437 : 2 : gcc_checking_assert (has_callback);
1438 : 2 : cgraph_edge *e, *next;
1439 : 2 : for (e = first_callback_edge (); e; e = next)
1440 : : {
1441 : 0 : next = e->next_callback_edge ();
1442 : 0 : cgraph_edge::remove (e);
1443 : : }
1444 : 2 : has_callback = false;
1445 : 2 : }
1446 : :
1447 : : /* Speculative call consists of an indirect edge and one or more
1448 : : direct edge+ref pairs.
1449 : :
1450 : : Given an edge which is part of speculative call, return the first
1451 : : direct call edge in the speculative call sequence. */
1452 : :
1453 : : cgraph_edge *
1454 : 47492 : cgraph_edge::first_speculative_call_target ()
1455 : : {
1456 : 47492 : cgraph_edge *e = this;
1457 : :
1458 : 47492 : gcc_checking_assert (e->speculative);
1459 : 47492 : if (e->callee)
1460 : : {
1461 : 14558 : while (e->prev_callee && e->prev_callee->speculative
1462 : 1581 : && e->prev_callee->call_stmt == e->call_stmt
1463 : 38369 : && e->prev_callee->lto_stmt_uid == e->lto_stmt_uid)
1464 : : e = e->prev_callee;
1465 : : return e;
1466 : : }
1467 : : /* Call stmt site hash always points to the first target of the
1468 : : speculative call sequence. */
1469 : 9123 : if (e->call_stmt)
1470 : 9111 : return e->caller->get_edge (e->call_stmt);
1471 : 17 : for (cgraph_edge *e2 = e->caller->callees; true; e2 = e2->next_callee)
1472 : 17 : if (e2->speculative
1473 : 12 : && e->call_stmt == e2->call_stmt
1474 : 12 : && e->lto_stmt_uid == e2->lto_stmt_uid)
1475 : : return e2;
1476 : : }
1477 : :
1478 : : /* We always maintain first direct edge in the call site hash, if one
1479 : : exists. E is going to be removed. See if it is first one and update
1480 : : hash accordingly. INDIRECT is the indirect edge of speculative call.
1481 : : We assume that INDIRECT->num_speculative_call_targets_p () is already
1482 : : updated for removal of E. */
1483 : : static void
1484 : 40336 : update_call_stmt_hash_for_removing_direct_edge (cgraph_edge *e,
1485 : : cgraph_edge *indirect)
1486 : : {
1487 : 40336 : if (e->caller->call_site_hash)
1488 : : {
1489 : 4026 : if (e->caller->get_edge (e->call_stmt) != e)
1490 : : ;
1491 : 4026 : else if (!indirect->num_speculative_call_targets_p ())
1492 : 3523 : cgraph_update_edge_in_call_site_hash (indirect);
1493 : : else
1494 : : {
1495 : 503 : gcc_checking_assert (e->next_callee && e->next_callee->speculative
1496 : : && e->next_callee->call_stmt == e->call_stmt);
1497 : 503 : cgraph_update_edge_in_call_site_hash (e->next_callee);
1498 : : }
1499 : : }
1500 : 40336 : }
1501 : :
1502 : : /* Speculative call EDGE turned out to be direct call to CALLEE_DECL. Remove
1503 : : the speculative call sequence and return edge representing the call, the
1504 : : original EDGE can be removed and deallocated. Return the edge that now
1505 : : represents the call.
1506 : :
1507 : : For "speculative" indirect call that contains multiple "speculative"
1508 : : targets (i.e. edge->indirect_info->num_speculative_call_targets > 1),
1509 : : decrease the count and only remove current direct edge.
1510 : :
1511 : : If no speculative direct call left to the speculative indirect call, remove
1512 : : the speculative of both the indirect call and corresponding direct edge.
1513 : :
1514 : : It is up to caller to iteratively resolve each "speculative" direct call and
1515 : : redirect the call as appropriate. */
1516 : :
1517 : : cgraph_edge *
1518 : 8839 : cgraph_edge::resolve_speculation (cgraph_edge *edge, tree callee_decl)
1519 : : {
1520 : 8839 : cgraph_edge *e2;
1521 : 8839 : ipa_ref *ref;
1522 : :
1523 : 8839 : gcc_assert (edge->speculative && (!callee_decl || edge->callee));
1524 : 8839 : if (!edge->callee)
1525 : 0 : e2 = edge->first_speculative_call_target ();
1526 : : else
1527 : : e2 = edge;
1528 : 8839 : ref = e2->speculative_call_target_ref ();
1529 : 8839 : edge = edge->speculative_call_indirect_edge ();
1530 : 8839 : if (!callee_decl
1531 : 10247 : || !ref->referred->semantically_equivalent_p
1532 : 1408 : (symtab_node::get (callee_decl)))
1533 : : {
1534 : 7740 : if (dump_file)
1535 : : {
1536 : 78 : if (callee_decl)
1537 : : {
1538 : 0 : fprintf (dump_file, "Speculative indirect call %s => %s has "
1539 : : "turned out to have contradicting known target ",
1540 : 0 : edge->caller->dump_name (),
1541 : 0 : e2->callee->dump_name ());
1542 : 0 : print_generic_expr (dump_file, callee_decl);
1543 : 0 : fprintf (dump_file, "\n");
1544 : : }
1545 : : else
1546 : : {
1547 : 78 : fprintf (dump_file, "Removing speculative call %s => %s\n",
1548 : 78 : edge->caller->dump_name (),
1549 : 78 : e2->callee->dump_name ());
1550 : : }
1551 : : }
1552 : : }
1553 : : else
1554 : : {
1555 : 1099 : cgraph_edge *tmp = edge;
1556 : 1099 : if (dump_file)
1557 : 87 : fprintf (dump_file, "Speculative call turned into direct call.\n");
1558 : : edge = e2;
1559 : : e2 = tmp;
1560 : : /* FIXME: If EDGE is inlined, we should scale up the frequencies
1561 : : and counts in the functions inlined through it. */
1562 : : }
1563 : 8839 : edge->count += e2->count;
1564 : 8839 : if (edge->num_speculative_call_targets_p ())
1565 : : {
1566 : : /* The indirect edge has multiple speculative targets, don't remove
1567 : : speculative until all related direct edges are resolved. */
1568 : 7740 : edge->indirect_info->num_speculative_call_targets--;
1569 : 7740 : if (!edge->indirect_info->num_speculative_call_targets)
1570 : 918 : edge->speculative = false;
1571 : : }
1572 : : else
1573 : 1099 : edge->speculative = false;
1574 : 8839 : e2->speculative = false;
1575 : 8839 : update_call_stmt_hash_for_removing_direct_edge (e2, edge);
1576 : 8839 : ref->remove_reference ();
1577 : 8839 : if (e2->indirect_unknown_callee || e2->inline_failed)
1578 : 7980 : remove (e2);
1579 : : else
1580 : 859 : e2->callee->remove_symbol_and_inline_clones ();
1581 : 8839 : return edge;
1582 : : }
1583 : :
1584 : : /* Return edge corresponding to speculative call to a given target.
1585 : : NULL if speculative call does not have one. */
1586 : :
1587 : : cgraph_edge *
1588 : 0 : cgraph_edge::speculative_call_for_target (cgraph_node *target)
1589 : : {
1590 : 0 : for (cgraph_edge *direct = first_speculative_call_target ();
1591 : 0 : direct;
1592 : 0 : direct = direct->next_speculative_call_target ())
1593 : 0 : if (direct->speculative_call_target_ref ()
1594 : 0 : ->referred->semantically_equivalent_p (target))
1595 : : return direct;
1596 : : return NULL;
1597 : : }
1598 : :
1599 : : /* Make an indirect or speculative EDGE with an unknown callee an ordinary edge
1600 : : leading to CALLEE. Speculations can be resolved in the process and EDGE can
1601 : : be removed and deallocated. Return the edge that now represents the
1602 : : call. */
1603 : :
1604 : : cgraph_edge *
1605 : 4960 : cgraph_edge::make_direct (cgraph_edge *edge, cgraph_node *callee)
1606 : : {
1607 : 4960 : gcc_assert (edge->indirect_unknown_callee || edge->speculative);
1608 : :
1609 : : /* If we are redirecting speculative call, make it non-speculative. */
1610 : 4960 : if (edge->speculative)
1611 : : {
1612 : 1242 : cgraph_edge *found = NULL;
1613 : 1242 : cgraph_edge *direct, *next;
1614 : :
1615 : 1242 : edge = edge->speculative_call_indirect_edge ();
1616 : :
1617 : : /* Look all speculative targets and remove all but one corresponding
1618 : : to callee (if it exists). */
1619 : 1242 : for (direct = edge->first_speculative_call_target ();
1620 : 3240 : direct;
1621 : : direct = next)
1622 : : {
1623 : 1998 : next = direct->next_speculative_call_target ();
1624 : :
1625 : : /* Compare ref not direct->callee. Direct edge is possibly
1626 : : inlined or redirected. */
1627 : 1998 : if (!direct->speculative_call_target_ref ()
1628 : 1998 : ->referred->semantically_equivalent_p (callee)
1629 : 1998 : || found)
1630 : 899 : edge = direct->resolve_speculation (direct, NULL);
1631 : : else
1632 : : found = direct;
1633 : : }
1634 : :
1635 : : /* On successful speculation just remove the indirect edge and
1636 : : return the pre existing direct edge.
1637 : : It is important to not remove it and redirect because the direct
1638 : : edge may be inlined or redirected. */
1639 : 1242 : if (found)
1640 : : {
1641 : 1099 : cgraph_edge *e2 = resolve_speculation (found, callee->decl);
1642 : 1099 : gcc_checking_assert (!found->speculative && e2 == found);
1643 : : return found;
1644 : : }
1645 : 143 : gcc_checking_assert (!edge->speculative);
1646 : : }
1647 : :
1648 : 3861 : edge->indirect_unknown_callee = 0;
1649 : 3861 : ggc_free (edge->indirect_info);
1650 : 3861 : edge->indirect_info = NULL;
1651 : :
1652 : : /* Get the edge out of the indirect edge list. */
1653 : 3861 : if (edge->prev_callee)
1654 : 98 : edge->prev_callee->next_callee = edge->next_callee;
1655 : 3861 : if (edge->next_callee)
1656 : 493 : edge->next_callee->prev_callee = edge->prev_callee;
1657 : 3861 : if (!edge->prev_callee)
1658 : 3763 : edge->caller->indirect_calls = edge->next_callee;
1659 : :
1660 : : /* Put it into the normal callee list */
1661 : 3861 : edge->prev_callee = NULL;
1662 : 3861 : edge->next_callee = edge->caller->callees;
1663 : 3861 : if (edge->caller->callees)
1664 : 2455 : edge->caller->callees->prev_callee = edge;
1665 : 3861 : edge->caller->callees = edge;
1666 : :
1667 : : /* Insert to callers list of the new callee. */
1668 : 3861 : edge->set_callee (callee);
1669 : :
1670 : : /* We need to re-determine the inlining status of the edge. */
1671 : 3861 : initialize_inline_failed (edge);
1672 : 3861 : return edge;
1673 : : }
1674 : :
1675 : : /* Redirect callee of the edge to N. The function does not update underlying
1676 : : call expression. */
1677 : :
1678 : : void
1679 : 4448896 : cgraph_edge::redirect_callee (cgraph_node *n)
1680 : : {
1681 : 4448896 : bool loc = callee->comdat_local_p ();
1682 : 4448896 : cgraph_node *old_callee = callee;
1683 : :
1684 : : /* Remove from callers list of the current callee. */
1685 : 4448896 : remove_callee ();
1686 : :
1687 : : /* Insert to callers list of the new callee. */
1688 : 4448896 : set_callee (n);
1689 : :
1690 : 4448896 : if (callback)
1691 : : {
1692 : : /* When redirecting a callback callee, redirect its ref as well. */
1693 : 268 : ipa_ref *old_ref = caller->find_reference (old_callee, call_stmt,
1694 : 268 : lto_stmt_uid, IPA_REF_ADDR);
1695 : 268 : gcc_checking_assert(old_ref);
1696 : 268 : old_ref->remove_reference ();
1697 : 268 : ipa_ref *new_ref = caller->create_reference (n, IPA_REF_ADDR, call_stmt);
1698 : 268 : new_ref->lto_stmt_uid = lto_stmt_uid;
1699 : : /* If the last reference to OLD_CALLEE has been redirected, unset
1700 : : address_taken. old_ref is only used as a placeholder when looking for
1701 : : a different reference. */
1702 : 268 : if (!old_callee->iterate_referring (0, old_ref))
1703 : 226 : old_callee->address_taken = 0;
1704 : 268 : n->mark_address_taken ();
1705 : : }
1706 : :
1707 : 4448896 : if (!inline_failed)
1708 : : return;
1709 : 605984 : if (!loc && n->comdat_local_p ())
1710 : : {
1711 : 56 : cgraph_node *to = caller->inlined_to ? caller->inlined_to : caller;
1712 : 56 : to->calls_comdat_local = true;
1713 : : }
1714 : 605928 : else if (loc && !n->comdat_local_p ())
1715 : : {
1716 : 97 : cgraph_node *to = caller->inlined_to ? caller->inlined_to : caller;
1717 : 97 : gcc_checking_assert (to->calls_comdat_local);
1718 : 97 : to->calls_comdat_local = to->check_calls_comdat_local_p ();
1719 : : }
1720 : : }
1721 : :
1722 : : /* If necessary, change the function declaration in the call statement
1723 : : associated with E so that it corresponds to the edge callee. Speculations
1724 : : can be resolved in the process and EDGE can be removed and deallocated.
1725 : :
1726 : : The edge could be one of speculative direct call generated from speculative
1727 : : indirect call. In this circumstance, decrease the speculative targets
1728 : : count (i.e. num_speculative_call_targets) and redirect call stmt to the
1729 : : corresponding i-th target. If no speculative direct call left to the
1730 : : speculative indirect call, remove "speculative" of the indirect call and
1731 : : also redirect stmt to it's final direct target.
1732 : :
1733 : : When called from within tree-inline, KILLED_SSAs has to contain the pointer
1734 : : to killed_new_ssa_names within the copy_body_data structure and SSAs
1735 : : discovered to be useless (if LHS is removed) will be added to it, otherwise
1736 : : it needs to be NULL.
1737 : :
1738 : : It is up to caller to iteratively transform each "speculative"
1739 : : direct call as appropriate. */
1740 : :
1741 : : gimple *
1742 : 9770833 : cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e,
1743 : : hash_set <tree> *killed_ssas)
1744 : : {
1745 : 9770833 : tree decl = gimple_call_fndecl (e->call_stmt);
1746 : 9770833 : gcall *new_stmt;
1747 : :
1748 : 9770833 : if (e->speculative)
1749 : : {
1750 : : /* If there already is an direct call (i.e. as a result of inliner's
1751 : : substitution), forget about speculating. */
1752 : 31497 : if (decl)
1753 : 0 : e = make_direct (e->speculative_call_indirect_edge (),
1754 : : cgraph_node::get (decl));
1755 : : else
1756 : : {
1757 : : /* Be sure we redirect all speculative targets before poking
1758 : : about indirect edge. */
1759 : 31497 : gcc_checking_assert (e->callee);
1760 : 31497 : cgraph_edge *indirect = e->speculative_call_indirect_edge ();
1761 : 31497 : gcall *new_stmt;
1762 : 31497 : ipa_ref *ref;
1763 : :
1764 : : /* Expand speculation into GIMPLE code. */
1765 : 31497 : if (dump_file)
1766 : : {
1767 : 150 : fprintf (dump_file,
1768 : : "Expanding speculative call of %s -> %s count: ",
1769 : 75 : e->caller->dump_name (),
1770 : : e->callee->dump_name ());
1771 : 75 : e->count.dump (dump_file);
1772 : 75 : fprintf (dump_file, "\n");
1773 : : }
1774 : 31497 : push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl));
1775 : :
1776 : 31497 : profile_count all = indirect->count;
1777 : 31497 : for (cgraph_edge *e2 = e->first_speculative_call_target ();
1778 : 72968 : e2;
1779 : 41471 : e2 = e2->next_speculative_call_target ())
1780 : 41471 : all = all + e2->count;
1781 : 31497 : profile_probability prob = e->count.probability_in (all);
1782 : 31497 : if (!prob.initialized_p ())
1783 : 135 : prob = profile_probability::even ();
1784 : 31497 : ref = e->speculative_call_target_ref ();
1785 : 62994 : new_stmt = gimple_ic (e->call_stmt,
1786 : : dyn_cast<cgraph_node *> (ref->referred),
1787 : : prob);
1788 : 31497 : e->speculative = false;
1789 : 31497 : if (indirect->num_speculative_call_targets_p ())
1790 : : {
1791 : : /* The indirect edge has multiple speculative targets, don't
1792 : : remove speculative until all related direct edges are
1793 : : redirected. */
1794 : 31497 : indirect->indirect_info->num_speculative_call_targets--;
1795 : 31497 : if (!indirect->indirect_info->num_speculative_call_targets)
1796 : 23747 : indirect->speculative = false;
1797 : : }
1798 : : else
1799 : 0 : indirect->speculative = false;
1800 : : /* Indirect edges are not both in the call site hash.
1801 : : get it updated. */
1802 : 31497 : update_call_stmt_hash_for_removing_direct_edge (e, indirect);
1803 : 31497 : cgraph_edge::set_call_stmt (e, new_stmt, false);
1804 : 31497 : e->count = gimple_bb (e->call_stmt)->count;
1805 : :
1806 : : /* Once we are done with expanding the sequence, update also indirect
1807 : : call probability. Until then the basic block accounts for the
1808 : : sum of indirect edge and all non-expanded speculations. */
1809 : 31497 : if (!indirect->speculative)
1810 : 23747 : indirect->count = gimple_bb (indirect->call_stmt)->count;
1811 : 31497 : ref->speculative = false;
1812 : 31497 : ref->stmt = NULL;
1813 : 31497 : pop_cfun ();
1814 : : /* Continue redirecting E to proper target. */
1815 : : }
1816 : : }
1817 : :
1818 : :
1819 : 9770833 : if (e->indirect_unknown_callee
1820 : 9674998 : || decl == e->callee->decl)
1821 : 8756178 : return e->call_stmt;
1822 : :
1823 : : /* When redirecting a callback edge, all we need to do is replace
1824 : : the original address with the address of the function we are
1825 : : redirecting to. */
1826 : 1014655 : if (e->callback)
1827 : : {
1828 : 3423 : cgraph_edge *carrying = e->get_callback_carrying_edge ();
1829 : 3423 : if (!callback_is_special_cased (carrying->callee->decl, e->call_stmt)
1830 : 6078 : && !lookup_attribute (CALLBACK_ATTR_IDENT,
1831 : 2655 : DECL_ATTRIBUTES (carrying->callee->decl)))
1832 : : /* Callback attribute is removed if the dispatching function changes
1833 : : signature, as the indices wouldn't be correct anymore. These edges
1834 : : will get cleaned up later, ignore their redirection for now. */
1835 : 0 : return e->call_stmt;
1836 : 3423 : int fn_idx = callback_fetch_fn_position (e, carrying);
1837 : 3423 : tree previous_arg = gimple_call_arg (e->call_stmt, fn_idx);
1838 : 3423 : location_t loc = EXPR_LOCATION (previous_arg);
1839 : 3423 : tree new_addr = build_fold_addr_expr_loc (loc, e->callee->decl);
1840 : 3423 : gimple_call_set_arg (e->call_stmt, fn_idx, new_addr);
1841 : 3423 : return e->call_stmt;
1842 : : }
1843 : :
1844 : 1011232 : if (decl && ipa_saved_clone_sources)
1845 : : {
1846 : 824995 : tree *p = ipa_saved_clone_sources->get (e->callee);
1847 : 824995 : if (p && decl == *p)
1848 : : {
1849 : 33841 : gimple_call_set_fndecl (e->call_stmt, e->callee->decl);
1850 : 33841 : return e->call_stmt;
1851 : : }
1852 : : }
1853 : 977391 : if (flag_checking && decl)
1854 : : {
1855 : 942136 : if (cgraph_node *node = cgraph_node::get (decl))
1856 : : {
1857 : 803427 : clone_info *info = clone_info::get (node);
1858 : 803427 : gcc_assert (!info || !info->param_adjustments);
1859 : : }
1860 : : }
1861 : :
1862 : 977391 : clone_info *callee_info = clone_info::get (e->callee);
1863 : 977391 : if (symtab->dump_file)
1864 : : {
1865 : 0 : fprintf (symtab->dump_file, "updating call of %s -> %s: ",
1866 : 0 : e->caller->dump_name (), e->callee->dump_name ());
1867 : 0 : print_gimple_stmt (symtab->dump_file, e->call_stmt, 0, dump_flags);
1868 : 0 : if (callee_info && callee_info->param_adjustments)
1869 : 0 : callee_info->param_adjustments->dump (symtab->dump_file);
1870 : : }
1871 : :
1872 : 489978 : if (ipa_param_adjustments *padjs
1873 : 977391 : = callee_info ? callee_info->param_adjustments : NULL)
1874 : : {
1875 : : /* We need to defer cleaning EH info on the new statement to
1876 : : fixup-cfg. We may not have dominator information at this point
1877 : : and thus would end up with unreachable blocks and have no way
1878 : : to communicate that we need to run CFG cleanup then. */
1879 : 461444 : int lp_nr = lookup_stmt_eh_lp (e->call_stmt);
1880 : 461444 : if (lp_nr != 0)
1881 : 145381 : remove_stmt_from_eh_lp (e->call_stmt);
1882 : :
1883 : 461444 : tree old_fntype = gimple_call_fntype (e->call_stmt);
1884 : 461444 : new_stmt = padjs->modify_call (e, false, killed_ssas);
1885 : 461444 : cgraph_node *origin = e->callee;
1886 : 673633 : while (origin->clone_of)
1887 : : origin = origin->clone_of;
1888 : :
1889 : 461444 : if ((origin->former_clone_of
1890 : 360720 : && old_fntype == TREE_TYPE (origin->former_clone_of))
1891 : 463662 : || old_fntype == TREE_TYPE (origin->decl))
1892 : 358504 : gimple_call_set_fntype (new_stmt, TREE_TYPE (e->callee->decl));
1893 : : else
1894 : : {
1895 : 102940 : tree new_fntype = padjs->build_new_function_type (old_fntype, true);
1896 : 102940 : gimple_call_set_fntype (new_stmt, new_fntype);
1897 : : }
1898 : :
1899 : 461444 : if (lp_nr != 0)
1900 : 145381 : add_stmt_to_eh_lp (new_stmt, lp_nr);
1901 : : }
1902 : : else
1903 : : {
1904 : 515947 : if (flag_checking
1905 : 515947 : && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE,
1906 : : BUILT_IN_UNREACHABLE_TRAP))
1907 : 351728 : ipa_verify_edge_has_no_modifications (e);
1908 : 515947 : new_stmt = e->call_stmt;
1909 : 515947 : gimple_call_set_fndecl (new_stmt, e->callee->decl);
1910 : 515947 : update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
1911 : : }
1912 : :
1913 : : /* If changing the call to __cxa_pure_virtual or similar noreturn function,
1914 : : adjust gimple_call_fntype too. */
1915 : 977391 : if (gimple_call_noreturn_p (new_stmt)
1916 : 167250 : && VOID_TYPE_P (TREE_TYPE (TREE_TYPE (e->callee->decl)))
1917 : 167178 : && TYPE_ARG_TYPES (TREE_TYPE (e->callee->decl))
1918 : 1144563 : && (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (e->callee->decl)))
1919 : 167172 : == void_type_node))
1920 : 166430 : gimple_call_set_fntype (new_stmt, TREE_TYPE (e->callee->decl));
1921 : :
1922 : : /* If the call becomes noreturn, remove the LHS if possible. */
1923 : 977391 : tree lhs = gimple_call_lhs (new_stmt);
1924 : 977391 : if (lhs
1925 : 299862 : && gimple_call_noreturn_p (new_stmt)
1926 : 1029401 : && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (new_stmt)))
1927 : 59 : || should_remove_lhs_p (lhs)))
1928 : : {
1929 : 51969 : gimple_call_set_lhs (new_stmt, NULL_TREE);
1930 : : /* We need to fix up the SSA name to avoid checking errors. */
1931 : 51969 : if (TREE_CODE (lhs) == SSA_NAME)
1932 : : {
1933 : 41837 : tree var = create_tmp_reg_fn (DECL_STRUCT_FUNCTION (e->caller->decl),
1934 : 41837 : TREE_TYPE (lhs), NULL);
1935 : 41837 : SET_SSA_NAME_VAR_OR_IDENTIFIER (lhs, var);
1936 : 41837 : SSA_NAME_DEF_STMT (lhs) = gimple_build_nop ();
1937 : 41837 : set_ssa_default_def (DECL_STRUCT_FUNCTION (e->caller->decl),
1938 : : var, lhs);
1939 : : }
1940 : 51969 : update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
1941 : : }
1942 : :
1943 : : /* If new callee has no static chain, remove it. */
1944 : 977391 : if (gimple_call_chain (new_stmt) && !DECL_STATIC_CHAIN (e->callee->decl))
1945 : : {
1946 : 56 : gimple_call_set_chain (new_stmt, NULL);
1947 : 56 : update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
1948 : : }
1949 : :
1950 : 977391 : maybe_remove_unused_call_args (DECL_STRUCT_FUNCTION (e->caller->decl),
1951 : : new_stmt);
1952 : :
1953 : : /* Update callback edges if setting the carrying edge's statement, or else
1954 : : their pairing would fall apart. */
1955 : 977391 : e->caller->set_call_stmt_including_clones (e->call_stmt, new_stmt, e->has_callback);
1956 : :
1957 : 977391 : if (symtab->dump_file)
1958 : : {
1959 : 0 : fprintf (symtab->dump_file, " updated to:");
1960 : 0 : print_gimple_stmt (symtab->dump_file, e->call_stmt, 0, dump_flags);
1961 : : }
1962 : : return new_stmt;
1963 : : }
1964 : :
1965 : : /* Update or remove the corresponding cgraph edge if a GIMPLE_CALL
1966 : : OLD_STMT changed into NEW_STMT. OLD_CALL is gimple_call_fndecl
1967 : : of OLD_STMT if it was previously call statement.
1968 : : If NEW_STMT is NULL, the call has been dropped without any
1969 : : replacement. */
1970 : :
1971 : : static void
1972 : 117768 : cgraph_update_edges_for_call_stmt_node (cgraph_node *node,
1973 : : gimple *old_stmt, tree old_call,
1974 : : gimple *new_stmt)
1975 : : {
1976 : 117768 : tree new_call = (new_stmt && is_gimple_call (new_stmt))
1977 : 122869 : ? gimple_call_fndecl (new_stmt) : 0;
1978 : :
1979 : : /* We are seeing indirect calls, then there is nothing to update. */
1980 : 117768 : if (!new_call && !old_call)
1981 : : return;
1982 : : /* See if we turned indirect call into direct call or folded call to one builtin
1983 : : into different builtin. */
1984 : 115794 : if (old_call != new_call)
1985 : : {
1986 : 114798 : cgraph_edge *e = node->get_edge (old_stmt);
1987 : 114798 : cgraph_edge *ne = NULL;
1988 : 114798 : profile_count count;
1989 : :
1990 : 114798 : if (e)
1991 : : {
1992 : : /* If call was devirtualized during cloning, mark edge
1993 : : as resolved. */
1994 : 93534 : if (e->speculative)
1995 : : {
1996 : 0 : if (new_stmt && is_gimple_call (new_stmt))
1997 : : {
1998 : 0 : tree decl = gimple_call_fndecl (new_stmt);
1999 : 0 : if (decl)
2000 : 0 : e = cgraph_edge::resolve_speculation (e, decl);
2001 : : }
2002 : : else
2003 : 0 : e = cgraph_edge::resolve_speculation (e, NULL);
2004 : : }
2005 : : /* Keep calls marked as dead dead. */
2006 : 93534 : if (new_stmt && is_gimple_call (new_stmt) && e->callee
2007 : 94108 : && fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE,
2008 : : BUILT_IN_UNREACHABLE_TRAP))
2009 : : {
2010 : 5 : cgraph_edge::set_call_stmt (node->get_edge (old_stmt),
2011 : : as_a <gcall *> (new_stmt));
2012 : 32 : return;
2013 : : }
2014 : : /* See if the edge is already there and has the correct callee. It
2015 : : might be so because of indirect inlining has already updated
2016 : : it. We also might've cloned and redirected the edge. */
2017 : 93529 : if (new_call && e->callee)
2018 : : {
2019 : : cgraph_node *callee = e->callee;
2020 : 1139 : while (callee)
2021 : : {
2022 : 592 : if (callee->decl == new_call
2023 : 592 : || callee->former_clone_of == new_call)
2024 : : {
2025 : 22 : cgraph_edge::set_call_stmt (e, as_a <gcall *> (new_stmt));
2026 : 22 : return;
2027 : : }
2028 : 570 : callee = callee->clone_of;
2029 : : }
2030 : : }
2031 : :
2032 : : /* Otherwise remove edge and create new one; we can't simply redirect
2033 : : since function has changed, so inline plan and other information
2034 : : attached to edge is invalid. */
2035 : 93507 : count = e->count;
2036 : 93507 : if (e->indirect_unknown_callee || e->inline_failed)
2037 : 93507 : cgraph_edge::remove (e);
2038 : : else
2039 : 0 : e->callee->remove_symbol_and_inline_clones ();
2040 : : }
2041 : 21264 : else if (new_call)
2042 : : {
2043 : : /* We are seeing new direct call; compute profile info based on BB. */
2044 : 4 : basic_block bb = gimple_bb (new_stmt);
2045 : 4 : count = bb->count;
2046 : : }
2047 : :
2048 : 93511 : if (new_call)
2049 : : {
2050 : 2323 : ne = node->create_edge (cgraph_node::get_create (new_call),
2051 : : as_a <gcall *> (new_stmt), count);
2052 : 2323 : gcc_assert (ne->inline_failed);
2053 : : }
2054 : : }
2055 : : /* We only updated the call stmt; update pointer in cgraph edge.. */
2056 : 996 : else if (old_stmt != new_stmt)
2057 : 0 : cgraph_edge::set_call_stmt (node->get_edge (old_stmt),
2058 : : as_a <gcall *> (new_stmt));
2059 : : }
2060 : :
2061 : : /* Update or remove the corresponding cgraph edge if a GIMPLE_CALL
2062 : : OLD_STMT changed into NEW_STMT. OLD_DECL is gimple_call_fndecl
2063 : : of OLD_STMT before it was updated (updating can happen inplace). */
2064 : :
2065 : : void
2066 : 96123 : cgraph_update_edges_for_call_stmt (gimple *old_stmt, tree old_decl,
2067 : : gimple *new_stmt)
2068 : : {
2069 : 96123 : cgraph_node *orig = cgraph_node::get (cfun->decl);
2070 : 96123 : cgraph_node *node;
2071 : :
2072 : 96123 : gcc_checking_assert (orig);
2073 : 96123 : gcc_assert (!orig->thunk);
2074 : 96123 : cgraph_update_edges_for_call_stmt_node (orig, old_stmt, old_decl, new_stmt);
2075 : 96123 : if (orig->clones)
2076 : 42646 : for (node = orig->clones; node != orig;)
2077 : : {
2078 : : /* Do not attempt to adjust bodies of yet unexpanded thunks. */
2079 : 21647 : if (!node->thunk)
2080 : 21645 : cgraph_update_edges_for_call_stmt_node (node, old_stmt, old_decl,
2081 : : new_stmt);
2082 : 21647 : if (node->clones)
2083 : : node = node->clones;
2084 : 21635 : else if (node->next_sibling_clone)
2085 : : node = node->next_sibling_clone;
2086 : : else
2087 : : {
2088 : 42010 : while (node != orig && !node->next_sibling_clone)
2089 : 21011 : node = node->clone_of;
2090 : 20999 : if (node != orig)
2091 : 0 : node = node->next_sibling_clone;
2092 : : }
2093 : : }
2094 : 96123 : }
2095 : :
2096 : :
2097 : : /* Remove all callees from the node. */
2098 : :
2099 : : void
2100 : 218816118 : cgraph_node::remove_callees (void)
2101 : : {
2102 : 218816118 : cgraph_edge *e, *f;
2103 : :
2104 : 218816118 : calls_comdat_local = false;
2105 : :
2106 : : /* It is sufficient to remove the edges from the lists of callers of
2107 : : the callees. The callee list of the node can be zapped with one
2108 : : assignment. */
2109 : 258268335 : for (e = callees; e; e = f)
2110 : : {
2111 : 39452217 : f = e->next_callee;
2112 : 39452217 : symtab->call_edge_removal_hooks (e);
2113 : 39452217 : if (!e->indirect_unknown_callee)
2114 : 39452217 : e->remove_callee ();
2115 : 39452217 : symtab->free_edge (e);
2116 : : }
2117 : 219669892 : for (e = indirect_calls; e; e = f)
2118 : : {
2119 : 853774 : f = e->next_callee;
2120 : 853774 : symtab->call_edge_removal_hooks (e);
2121 : 853774 : if (!e->indirect_unknown_callee)
2122 : 0 : e->remove_callee ();
2123 : 853774 : symtab->free_edge (e);
2124 : : }
2125 : 218816118 : indirect_calls = NULL;
2126 : 218816118 : callees = NULL;
2127 : 218816118 : if (call_site_hash)
2128 : : {
2129 : 30181 : call_site_hash->empty ();
2130 : 30181 : call_site_hash = NULL;
2131 : : }
2132 : 218816118 : }
2133 : :
2134 : : /* Remove all callers from the node. */
2135 : :
2136 : : void
2137 : 97997526 : cgraph_node::remove_callers (void)
2138 : : {
2139 : 97997526 : cgraph_edge *e, *f;
2140 : :
2141 : : /* It is sufficient to remove the edges from the lists of callees of
2142 : : the callers. The caller list of the node can be zapped with one
2143 : : assignment. */
2144 : 102603450 : for (e = callers; e; e = f)
2145 : : {
2146 : 4605924 : f = e->next_caller;
2147 : : /* When removing a callback-carrying edge, remove all its attached edges
2148 : : as well. */
2149 : 4605924 : if (e->has_callback)
2150 : : {
2151 : 0 : cgraph_edge *cbe, *next_cbe = NULL;
2152 : 0 : for (cbe = e->first_callback_edge (); cbe; cbe = next_cbe)
2153 : : {
2154 : 0 : next_cbe = cbe->next_callback_edge ();
2155 : 0 : cgraph_edge::remove (cbe);
2156 : : }
2157 : : }
2158 : 4605924 : symtab->call_edge_removal_hooks (e);
2159 : 4605924 : e->remove_caller ();
2160 : 4605924 : symtab->free_edge (e);
2161 : : }
2162 : 97997526 : callers = NULL;
2163 : 97997526 : }
2164 : :
2165 : : /* Helper function for cgraph_release_function_body and free_lang_data.
2166 : : It releases body from function DECL without having to inspect its
2167 : : possibly non-existent symtab node. */
2168 : :
2169 : : void
2170 : 108057781 : release_function_body (tree decl)
2171 : : {
2172 : 108057781 : function *fn = DECL_STRUCT_FUNCTION (decl);
2173 : 108057781 : if (fn)
2174 : : {
2175 : 96456355 : if (fn->cfg
2176 : 96456355 : && loops_for_fn (fn))
2177 : : {
2178 : 1773126 : fn->curr_properties &= ~PROP_loops;
2179 : 1773126 : loop_optimizer_finalize (fn);
2180 : : }
2181 : 96456355 : if (fn->gimple_df)
2182 : : {
2183 : 1781699 : delete_tree_ssa (fn);
2184 : 1781699 : fn->eh = NULL;
2185 : : }
2186 : 96456355 : if (fn->cfg)
2187 : : {
2188 : 1773127 : gcc_assert (!dom_info_available_p (fn, CDI_DOMINATORS));
2189 : 1773127 : gcc_assert (!dom_info_available_p (fn, CDI_POST_DOMINATORS));
2190 : 1773127 : delete_tree_cfg_annotations (fn);
2191 : 1773127 : free_cfg (fn);
2192 : 1773127 : fn->cfg = NULL;
2193 : : }
2194 : 96456355 : if (fn->value_histograms)
2195 : 12 : free_histograms (fn);
2196 : 96456355 : gimple_set_body (decl, NULL);
2197 : : /* Struct function hangs a lot of data that would leak if we didn't
2198 : : removed all pointers to it. */
2199 : 96456355 : ggc_free (fn);
2200 : 96456355 : DECL_STRUCT_FUNCTION (decl) = NULL;
2201 : : }
2202 : 108057781 : DECL_SAVED_TREE (decl) = NULL;
2203 : 108057781 : }
2204 : :
2205 : : /* Release memory used to represent body of function.
2206 : : Use this only for functions that are released before being translated to
2207 : : target code (i.e. RTL). Functions that are compiled to RTL and beyond
2208 : : are free'd in final.cc via free_after_compilation().
2209 : : KEEP_ARGUMENTS are useful only if you want to rebuild body as thunk. */
2210 : :
2211 : : void
2212 : 108046475 : cgraph_node::release_body (bool keep_arguments)
2213 : : {
2214 : 108046475 : ipa_transforms_to_apply.release ();
2215 : 108046475 : if (!used_as_abstract_origin && symtab->state != PARSING)
2216 : : {
2217 : 107442875 : DECL_RESULT (decl) = NULL;
2218 : :
2219 : 107442875 : if (!keep_arguments)
2220 : 107411943 : DECL_ARGUMENTS (decl) = NULL;
2221 : : }
2222 : : /* If the node is abstract and needed, then do not clear
2223 : : DECL_INITIAL of its associated function declaration because it's
2224 : : needed to emit debug info later. */
2225 : 108046475 : if (!used_as_abstract_origin && DECL_INITIAL (decl))
2226 : 95901473 : DECL_INITIAL (decl) = error_mark_node;
2227 : 108046475 : release_function_body (decl);
2228 : 108046475 : lto_free_function_in_decl_state_for_node (this);
2229 : 108046475 : if (flag_checking && clones)
2230 : : {
2231 : : /* It is invalid to release body before materializing clones except
2232 : : for thunks that don't really need a body. Verify also that we do
2233 : : not leak pointers to the call statements. */
2234 : 42 : for (cgraph_node *node = clones; node;
2235 : 24 : node = node->next_sibling_clone)
2236 : 24 : gcc_assert (node->thunk && !node->callees->call_stmt);
2237 : : }
2238 : 108046475 : remove_callees ();
2239 : 108046475 : remove_all_references ();
2240 : 108046475 : }
2241 : :
2242 : : /* Remove function from symbol table. */
2243 : :
2244 : : void
2245 : 97997526 : cgraph_node::remove (void)
2246 : : {
2247 : 97997526 : bool clone_info_set = false;
2248 : 97997526 : clone_info *info, saved_info;
2249 : 97997526 : if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this))
2250 : 4 : fprintf (symtab->ipa_clones_dump_file,
2251 : : "Callgraph removal;%s;%d;%s;%d;%d\n", asm_name (), get_uid (),
2252 : 4 : DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl),
2253 : 8 : DECL_SOURCE_COLUMN (decl));
2254 : :
2255 : 97997526 : if ((info = clone_info::get (this)) != NULL)
2256 : : {
2257 : 375859 : saved_info = *info;
2258 : 375859 : clone_info_set = true;
2259 : : }
2260 : 97997526 : symtab->call_cgraph_removal_hooks (this);
2261 : 97997526 : remove_callers ();
2262 : 97997526 : remove_callees ();
2263 : 97997526 : ipa_transforms_to_apply.release ();
2264 : 97997526 : delete_function_version (function_version ());
2265 : :
2266 : : /* Incremental inlining access removed nodes stored in the postorder list.
2267 : : */
2268 : 97997526 : force_output = false;
2269 : 97997526 : forced_by_abi = false;
2270 : :
2271 : 195619193 : unregister (clone_info_set ? &saved_info : NULL);
2272 : 97997526 : if (prev_sibling_clone)
2273 : 754772 : prev_sibling_clone->next_sibling_clone = next_sibling_clone;
2274 : 97242754 : else if (clone_of)
2275 : : {
2276 : 1851947 : clone_of->clones = next_sibling_clone;
2277 : 1851947 : if (!clones)
2278 : : {
2279 : 1847901 : bool need_body = false;
2280 : 1847901 : for (cgraph_node *n = clone_of; n; n = n->clone_of)
2281 : 1843092 : if (n->analyzed || n->clones)
2282 : : {
2283 : : need_body = true;
2284 : : break;
2285 : : }
2286 : 1843088 : if (!need_body)
2287 : 4809 : clone_of->release_body ();
2288 : : }
2289 : : }
2290 : 97997526 : if (next_sibling_clone)
2291 : 951256 : next_sibling_clone->prev_sibling_clone = prev_sibling_clone;
2292 : 97997526 : if (clones)
2293 : : {
2294 : 38838 : cgraph_node *n, *next;
2295 : :
2296 : 38838 : if (clone_of)
2297 : : {
2298 : 175119 : for (n = clones; n->next_sibling_clone; n = n->next_sibling_clone)
2299 : 136281 : n->clone_of = clone_of;
2300 : 38838 : n->clone_of = clone_of;
2301 : 38838 : n->next_sibling_clone = clone_of->clones;
2302 : 38838 : if (clone_of->clones)
2303 : 33895 : clone_of->clones->prev_sibling_clone = n;
2304 : 38838 : clone_of->clones = clones;
2305 : : }
2306 : : else
2307 : : {
2308 : : /* We are removing node with clones. This makes clones inconsistent,
2309 : : but assume they will be removed subsequently and just keep clone
2310 : : tree intact. This can happen in unreachable function removal since
2311 : : we remove unreachable functions in random order, not by bottom-up
2312 : : walk of clone trees. */
2313 : 0 : for (n = clones; n; n = next)
2314 : : {
2315 : 0 : next = n->next_sibling_clone;
2316 : 0 : n->next_sibling_clone = NULL;
2317 : 0 : n->prev_sibling_clone = NULL;
2318 : 0 : n->clone_of = NULL;
2319 : : }
2320 : : }
2321 : : }
2322 : :
2323 : : /* While all the clones are removed after being proceeded, the function
2324 : : itself is kept in the cgraph even after it is compiled. Check whether
2325 : : we are done with this body and reclaim it proactively if this is the case.
2326 : : */
2327 : 97997526 : if (symtab->state != LTO_STREAMING)
2328 : : {
2329 : 97995481 : cgraph_node *n = cgraph_node::get (decl);
2330 : 97995481 : if (!n
2331 : 97995481 : || (!n->clones && !n->clone_of && !n->inlined_to
2332 : 1185253 : && ((symtab->global_info_ready || in_lto_p)
2333 : 9347 : && (TREE_ASM_WRITTEN (n->decl)
2334 : 9316 : || DECL_EXTERNAL (n->decl)
2335 : 5286 : || !n->analyzed
2336 : 5222 : || (!flag_wpa && n->in_other_partition)))))
2337 : 94965440 : release_body ();
2338 : : }
2339 : : else
2340 : 2045 : lto_free_function_in_decl_state_for_node (this);
2341 : :
2342 : 97997526 : decl = NULL;
2343 : 97997526 : if (call_site_hash)
2344 : : {
2345 : 0 : call_site_hash->empty ();
2346 : 0 : call_site_hash = NULL;
2347 : : }
2348 : :
2349 : 97997526 : symtab->release_symbol (this);
2350 : 97997526 : }
2351 : :
2352 : : /* Likewise indicate that a node is having address taken. */
2353 : :
2354 : : void
2355 : 4843345 : cgraph_node::mark_address_taken (void)
2356 : : {
2357 : : /* Indirect inlining can figure out that all uses of the address are
2358 : : inlined. */
2359 : 4843345 : if (inlined_to)
2360 : : {
2361 : 0 : gcc_assert (cfun->after_inlining);
2362 : 0 : gcc_assert (callers->indirect_inlining_edge);
2363 : : return;
2364 : : }
2365 : : /* FIXME: address_taken flag is used both as a shortcut for testing whether
2366 : : IPA_REF_ADDR reference exists (and thus it should be set on node
2367 : : representing alias we take address of) and as a test whether address
2368 : : of the object was taken (and thus it should be set on node alias is
2369 : : referring to). We should remove the first use and the remove the
2370 : : following set. */
2371 : 4843345 : address_taken = 1;
2372 : 4843345 : cgraph_node *node = ultimate_alias_target ();
2373 : 4843345 : node->address_taken = 1;
2374 : : }
2375 : :
2376 : : /* Return local info node for the compiled function. */
2377 : :
2378 : : cgraph_node *
2379 : 12713870 : cgraph_node::local_info_node (tree decl)
2380 : : {
2381 : 12713870 : gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
2382 : 12713870 : cgraph_node *node = get (decl);
2383 : 12713870 : if (!node)
2384 : : return NULL;
2385 : 12713870 : return node->ultimate_alias_target ();
2386 : : }
2387 : :
2388 : : /* Return RTL info for the compiled function. */
2389 : :
2390 : : cgraph_rtl_info *
2391 : 59882652 : cgraph_node::rtl_info (const_tree decl)
2392 : : {
2393 : 59882652 : gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
2394 : 59882652 : cgraph_node *node = get (decl);
2395 : 59882652 : if (!node)
2396 : : return NULL;
2397 : 59740460 : enum availability avail;
2398 : 59740460 : node = node->ultimate_alias_target (&avail);
2399 : 59740460 : if (decl != current_function_decl
2400 : 56732145 : && (avail < AVAIL_AVAILABLE
2401 : 51580385 : || (node->decl != current_function_decl
2402 : 51506673 : && !TREE_ASM_WRITTEN (node->decl))))
2403 : : return NULL;
2404 : : /* Allocate if it doesn't exist. */
2405 : 51048013 : if (node->rtl == NULL)
2406 : : {
2407 : 1349978 : node->rtl = ggc_cleared_alloc<cgraph_rtl_info> ();
2408 : 1349978 : SET_HARD_REG_SET (node->rtl->function_used_regs);
2409 : : }
2410 : 51048013 : return node->rtl;
2411 : : }
2412 : :
2413 : : /* Return a string describing the failure REASON. */
2414 : :
2415 : : const char*
2416 : 9831 : cgraph_inline_failed_string (cgraph_inline_failed_t reason)
2417 : : {
2418 : : #undef DEFCIFCODE
2419 : : #define DEFCIFCODE(code, type, string) string,
2420 : :
2421 : 9831 : static const char *cif_string_table[CIF_N_REASONS] = {
2422 : : #include "cif-code.def"
2423 : : };
2424 : :
2425 : : /* Signedness of an enum type is implementation defined, so cast it
2426 : : to unsigned before testing. */
2427 : 9831 : gcc_assert ((unsigned) reason < CIF_N_REASONS);
2428 : 9831 : return cif_string_table[reason];
2429 : : }
2430 : :
2431 : : /* Return a type describing the failure REASON. */
2432 : :
2433 : : cgraph_inline_failed_type_t
2434 : 74196872 : cgraph_inline_failed_type (cgraph_inline_failed_t reason)
2435 : : {
2436 : : #undef DEFCIFCODE
2437 : : #define DEFCIFCODE(code, type, string) type,
2438 : :
2439 : 74196872 : static cgraph_inline_failed_type_t cif_type_table[CIF_N_REASONS] = {
2440 : : #include "cif-code.def"
2441 : : };
2442 : :
2443 : : /* Signedness of an enum type is implementation defined, so cast it
2444 : : to unsigned before testing. */
2445 : 74196872 : gcc_assert ((unsigned) reason < CIF_N_REASONS);
2446 : 74196872 : return cif_type_table[reason];
2447 : : }
2448 : :
2449 : : /* Names used to print out the availability enum. */
2450 : : const char * const cgraph_availability_names[] =
2451 : : {"unset", "not_available", "overwritable", "available", "local"};
2452 : :
2453 : : /* Output flags of edge to a file F. */
2454 : :
2455 : : void
2456 : 22672 : cgraph_edge::dump_edge_flags (FILE *f)
2457 : : {
2458 : 22672 : if (speculative)
2459 : 282 : fprintf (f, "(speculative) ");
2460 : 22672 : if (callback)
2461 : 4 : fprintf (f, "(callback) ");
2462 : 22672 : if (has_callback)
2463 : 6 : fprintf (f, "(has_callback) ");
2464 : 22672 : if (!inline_failed)
2465 : 1789 : fprintf (f, "(inlined) ");
2466 : 22672 : if (call_stmt_cannot_inline_p)
2467 : 0 : fprintf (f, "(call_stmt_cannot_inline_p) ");
2468 : 22672 : if (indirect_inlining_edge)
2469 : 325 : fprintf (f, "(indirect_inlining) ");
2470 : 22672 : if (count.initialized_p ())
2471 : : {
2472 : 21913 : fprintf (f, "(");
2473 : 21913 : count.dump (f);
2474 : 21913 : fprintf (f, ",");
2475 : 21913 : fprintf (f, "%.2f per call) ", sreal_frequency ().to_double ());
2476 : : }
2477 : 22672 : if (can_throw_external)
2478 : 2684 : fprintf (f, "(can throw external) ");
2479 : 22672 : }
2480 : :
2481 : : /* Dump edge to stderr. */
2482 : :
2483 : : void
2484 : 0 : cgraph_edge::debug (void)
2485 : : {
2486 : 0 : fprintf (stderr, "%s -> %s ", caller->dump_asm_name (),
2487 : 0 : callee == NULL ? "(null)" : callee->dump_asm_name ());
2488 : 0 : dump_edge_flags (stderr);
2489 : 0 : fprintf (stderr, "\n\n");
2490 : 0 : caller->debug ();
2491 : 0 : if (callee != NULL)
2492 : 0 : callee->debug ();
2493 : 0 : }
2494 : :
2495 : : /* Dump call graph node to file F. */
2496 : :
2497 : : void
2498 : 5860 : cgraph_node::dump (FILE *f)
2499 : : {
2500 : 5860 : cgraph_edge *edge;
2501 : :
2502 : 5860 : dump_base (f);
2503 : :
2504 : 5860 : if (inlined_to)
2505 : 776 : fprintf (f, " Function %s is inline copy in %s\n",
2506 : : dump_name (),
2507 : : inlined_to->dump_name ());
2508 : 5860 : if (clone_of)
2509 : 762 : fprintf (f, " Clone of %s\n", clone_of->dump_asm_name ());
2510 : 5860 : if (symtab->function_flags_ready)
2511 : 10584 : fprintf (f, " Availability: %s\n",
2512 : 5292 : cgraph_availability_names [get_availability ()]);
2513 : :
2514 : 5860 : if (profile_id)
2515 : 155 : fprintf (f, " Profile id: %i\n",
2516 : : profile_id);
2517 : 5860 : if (unit_id)
2518 : 134 : fprintf (f, " Unit id: %i\n",
2519 : : unit_id);
2520 : 5860 : cgraph_function_version_info *vi = function_version ();
2521 : 5860 : if (vi != NULL)
2522 : : {
2523 : 0 : fprintf (f, " Version info: ");
2524 : 0 : if (vi->prev != NULL)
2525 : : {
2526 : 0 : fprintf (f, "prev: ");
2527 : 0 : fprintf (f, "%s ", vi->prev->this_node->dump_asm_name ());
2528 : : }
2529 : 0 : if (vi->next != NULL)
2530 : : {
2531 : 0 : fprintf (f, "next: ");
2532 : 0 : fprintf (f, "%s ", vi->next->this_node->dump_asm_name ());
2533 : : }
2534 : 0 : if (vi->dispatcher_resolver != NULL_TREE)
2535 : 0 : fprintf (f, "dispatcher: %s",
2536 : 0 : lang_hooks.decl_printable_name (vi->dispatcher_resolver, 2));
2537 : :
2538 : 0 : fprintf (f, "\n");
2539 : : }
2540 : 5860 : fprintf (f, " Function flags:");
2541 : 5860 : if (count.initialized_p ())
2542 : : {
2543 : 3622 : fprintf (f, " count:");
2544 : 3622 : count.dump (f);
2545 : : }
2546 : 5860 : if (tp_first_run > 0)
2547 : 70 : fprintf (f, " first_run:%" PRId64, (int64_t) tp_first_run);
2548 : 5860 : if (cgraph_node *origin = nested_function_origin (this))
2549 : 0 : fprintf (f, " nested in:%s", origin->dump_asm_name ());
2550 : 5860 : if (gimple_has_body_p (decl))
2551 : 3862 : fprintf (f, " body");
2552 : 5860 : if (process)
2553 : 0 : fprintf (f, " process");
2554 : 5860 : if (local)
2555 : 1137 : fprintf (f, " local");
2556 : 5860 : if (redefined_extern_inline)
2557 : 0 : fprintf (f, " redefined_extern_inline");
2558 : 5860 : if (only_called_at_startup)
2559 : 400 : fprintf (f, " only_called_at_startup");
2560 : 5860 : if (only_called_at_exit)
2561 : 7 : fprintf (f, " only_called_at_exit");
2562 : 5860 : if (tm_clone)
2563 : 0 : fprintf (f, " tm_clone");
2564 : 5860 : if (calls_comdat_local)
2565 : 9 : fprintf (f, " calls_comdat_local");
2566 : 5860 : if (icf_merged)
2567 : 24 : fprintf (f, " icf_merged");
2568 : 5860 : if (merged_comdat)
2569 : 0 : fprintf (f, " merged_comdat");
2570 : 5860 : if (merged_extern_inline)
2571 : 0 : fprintf (f, " merged_extern_inline");
2572 : 5860 : if (split_part)
2573 : 23 : fprintf (f, " split_part");
2574 : 5860 : if (indirect_call_target)
2575 : 218 : fprintf (f, " indirect_call_target");
2576 : 5860 : if (nonfreeing_fn)
2577 : 343 : fprintf (f, " nonfreeing_fn");
2578 : 5860 : if (DECL_STATIC_CONSTRUCTOR (decl))
2579 : 48 : fprintf (f," static_constructor (priority:%i)", get_init_priority ());
2580 : 5860 : if (DECL_STATIC_DESTRUCTOR (decl))
2581 : 7 : fprintf (f," static_destructor (priority:%i)", get_fini_priority ());
2582 : 5860 : if (frequency == NODE_FREQUENCY_HOT)
2583 : 62 : fprintf (f, " hot");
2584 : 5860 : if (frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)
2585 : 40 : fprintf (f, " unlikely_executed");
2586 : 5860 : if (frequency == NODE_FREQUENCY_EXECUTED_ONCE)
2587 : 693 : fprintf (f, " executed_once");
2588 : 5860 : if (opt_for_fn (decl, optimize_size))
2589 : 176 : fprintf (f, " optimize_size");
2590 : 5860 : if (parallelized_function)
2591 : 4 : fprintf (f, " parallelized_function");
2592 : 5860 : if (DECL_IS_MALLOC (decl))
2593 : 72 : fprintf (f, " decl_is_malloc");
2594 : 5860 : if (DECL_IS_OPERATOR_NEW_P (decl))
2595 : 35 : fprintf (f, " %soperator_new",
2596 : 35 : DECL_IS_REPLACEABLE_OPERATOR (decl) ? "replaceable_" : "");
2597 : 5860 : if (DECL_IS_OPERATOR_DELETE_P (decl))
2598 : 26 : fprintf (f, " %soperator_delete",
2599 : 26 : DECL_IS_REPLACEABLE_OPERATOR (decl) ? "replaceable_" : "");
2600 : :
2601 : 5860 : if (DECL_STATIC_CHAIN (decl))
2602 : 6 : fprintf (f, " static_chain");
2603 : :
2604 : 5860 : fprintf (f, "\n");
2605 : :
2606 : 5860 : if (thunk)
2607 : : {
2608 : 49 : fprintf (f, " Thunk");
2609 : 49 : thunk_info::get (this)->dump (f);
2610 : : }
2611 : 5811 : else if (former_thunk_p ())
2612 : : {
2613 : 21 : fprintf (f, " Former thunk ");
2614 : 21 : thunk_info::get (this)->dump (f);
2615 : : }
2616 : 5790 : else gcc_checking_assert (!thunk_info::get (this));
2617 : :
2618 : 5860 : fprintf (f, " Called by: ");
2619 : :
2620 : 5860 : profile_count sum = profile_count::zero ();
2621 : 13575 : for (edge = callers; edge; edge = edge->next_caller)
2622 : : {
2623 : 7715 : fprintf (f, "%s ", edge->caller->dump_asm_name ());
2624 : 7715 : edge->dump_edge_flags (f);
2625 : 7715 : if (edge->count.initialized_p ())
2626 : 7455 : sum += edge->count.ipa ();
2627 : : }
2628 : :
2629 : 5860 : fprintf (f, "\n Calls: ");
2630 : 20050 : for (edge = callees; edge; edge = edge->next_callee)
2631 : : {
2632 : 14190 : fprintf (f, "%s ", edge->callee->dump_asm_name ());
2633 : 14190 : edge->dump_edge_flags (f);
2634 : : }
2635 : 5860 : fprintf (f, "\n");
2636 : :
2637 : 5860 : if (!body_removed && count.ipa ().initialized_p ())
2638 : : {
2639 : 110 : bool ok = true;
2640 : 110 : bool min = false;
2641 : : ipa_ref *ref;
2642 : :
2643 : 110 : FOR_EACH_ALIAS (this, ref)
2644 : 0 : if (dyn_cast <cgraph_node *> (ref->referring)->count.initialized_p ())
2645 : 0 : sum += dyn_cast <cgraph_node *> (ref->referring)->count.ipa ();
2646 : :
2647 : 110 : if (inlined_to
2648 : 110 : || (symtab->state < EXPANSION
2649 : 110 : && ultimate_alias_target () == this && only_called_directly_p ()))
2650 : 3 : ok = !count.ipa ().differs_from_p (sum);
2651 : 107 : else if (count.ipa () > profile_count::from_gcov_type (100)
2652 : 107 : && count.ipa () < sum.apply_scale (99, 100))
2653 : 0 : ok = false, min = true;
2654 : 110 : if (!ok)
2655 : : {
2656 : 0 : fprintf (f, " Invalid sum of caller counts ");
2657 : 0 : sum.dump (f);
2658 : 0 : if (min)
2659 : 0 : fprintf (f, ", should be at most ");
2660 : : else
2661 : 0 : fprintf (f, ", should be ");
2662 : 0 : count.ipa ().dump (f);
2663 : 0 : fprintf (f, "\n");
2664 : : }
2665 : : }
2666 : :
2667 : 6627 : for (edge = indirect_calls; edge; edge = edge->next_callee)
2668 : : {
2669 : 767 : if (edge->indirect_info->polymorphic)
2670 : : {
2671 : 293 : fprintf (f, " Polymorphic indirect call of type ");
2672 : 293 : print_generic_expr (f, edge->indirect_info->otr_type, TDF_SLIM);
2673 : 293 : fprintf (f, " token:%i", (int) edge->indirect_info->otr_token);
2674 : : }
2675 : : else
2676 : 474 : fprintf (f, " Indirect call");
2677 : 767 : edge->dump_edge_flags (f);
2678 : 767 : if (edge->indirect_info->param_index != -1)
2679 : : {
2680 : 217 : fprintf (f, "of param:%i ", edge->indirect_info->param_index);
2681 : 217 : if (edge->indirect_info->agg_contents)
2682 : 19 : fprintf (f, "loaded from %s %s at offset %i ",
2683 : 19 : edge->indirect_info->member_ptr ? "member ptr" : "aggregate",
2684 : 19 : edge->indirect_info->by_ref ? "passed by reference" : "",
2685 : 19 : (int)edge->indirect_info->offset);
2686 : 217 : if (edge->indirect_info->vptr_changed)
2687 : 23 : fprintf (f, "(vptr maybe changed) ");
2688 : : }
2689 : 767 : fprintf (f, "num speculative call targets: %i\n",
2690 : 767 : edge->indirect_info->num_speculative_call_targets);
2691 : 767 : if (edge->indirect_info->polymorphic)
2692 : 293 : edge->indirect_info->context.dump (f);
2693 : : }
2694 : 5860 : }
2695 : :
2696 : : /* Dump call graph node to file F in graphviz format. */
2697 : :
2698 : : void
2699 : 0 : cgraph_node::dump_graphviz (FILE *f)
2700 : : {
2701 : 0 : cgraph_edge *edge;
2702 : :
2703 : 0 : for (edge = callees; edge; edge = edge->next_callee)
2704 : : {
2705 : 0 : cgraph_node *callee = edge->callee;
2706 : :
2707 : 0 : fprintf (f, "\t\"%s\" -> \"%s\"\n", dump_name (), callee->dump_name ());
2708 : : }
2709 : 0 : }
2710 : :
2711 : :
2712 : : /* Dump call graph node NODE to stderr. */
2713 : :
2714 : : DEBUG_FUNCTION void
2715 : 0 : cgraph_node::debug (void)
2716 : : {
2717 : 0 : dump (stderr);
2718 : 0 : }
2719 : :
2720 : : /* Dump the callgraph to file F. */
2721 : :
2722 : : void
2723 : 77 : cgraph_node::dump_cgraph (FILE *f)
2724 : : {
2725 : 77 : cgraph_node *node;
2726 : :
2727 : 77 : fprintf (f, "callgraph:\n\n");
2728 : 362 : FOR_EACH_FUNCTION (node)
2729 : 285 : node->dump (f);
2730 : 77 : }
2731 : :
2732 : : /* Return true when the DECL can possibly be inlined. */
2733 : :
2734 : : bool
2735 : 87830562 : cgraph_function_possibly_inlined_p (tree decl)
2736 : : {
2737 : 87830562 : if (!symtab->global_info_ready)
2738 : 80123472 : return !DECL_UNINLINABLE (decl);
2739 : 7707090 : return DECL_POSSIBLY_INLINED (decl);
2740 : : }
2741 : :
2742 : : /* Return function availability. See cgraph.h for description of individual
2743 : : return values. */
2744 : : enum availability
2745 : 817434174 : cgraph_node::get_availability (symtab_node *ref)
2746 : : {
2747 : 817434174 : if (ref)
2748 : : {
2749 : 576816437 : cgraph_node *cref = dyn_cast <cgraph_node *> (ref);
2750 : 576816437 : if (cref)
2751 : 576816437 : ref = cref->inlined_to;
2752 : : }
2753 : 817434174 : enum availability avail;
2754 : 817434174 : if (!analyzed && !in_other_partition)
2755 : 486034460 : avail = AVAIL_NOT_AVAILABLE;
2756 : 331399714 : else if (local)
2757 : 94235033 : avail = AVAIL_LOCAL;
2758 : 237164681 : else if (inlined_to)
2759 : 2291880 : avail = AVAIL_AVAILABLE;
2760 : 234872801 : else if (transparent_alias)
2761 : 134 : ultimate_alias_target (&avail, ref);
2762 : 234872667 : else if (ifunc_resolver
2763 : 234872667 : || lookup_attribute ("noipa", DECL_ATTRIBUTES (decl)))
2764 : 3468398 : avail = AVAIL_INTERPOSABLE;
2765 : 231404269 : else if (!externally_visible)
2766 : 27552650 : avail = AVAIL_AVAILABLE;
2767 : : /* If this is a reference from symbol itself and there are no aliases, we
2768 : : may be sure that the symbol was not interposed by something else because
2769 : : the symbol itself would be unreachable otherwise.
2770 : :
2771 : : Also comdat groups are always resolved in groups. */
2772 : 34777 : else if ((this == ref && !has_aliases_p ())
2773 : 203852364 : || (ref && get_comdat_group ()
2774 : 1526019 : && get_comdat_group () == ref->get_comdat_group ()))
2775 : 37541 : avail = AVAIL_AVAILABLE;
2776 : : /* Inline functions are safe to be analyzed even if their symbol can
2777 : : be overwritten at runtime. It is not meaningful to enforce any sane
2778 : : behavior on replacing inline function by different body. */
2779 : 203814078 : else if (DECL_DECLARED_INLINE_P (decl))
2780 : 75133781 : avail = AVAIL_AVAILABLE;
2781 : :
2782 : : /* If the function can be overwritten, return OVERWRITABLE. Take
2783 : : care at least of two notable extensions - the COMDAT functions
2784 : : used to share template instantiations in C++ (this is symmetric
2785 : : to code cp_cannot_inline_tree_fn and probably shall be shared and
2786 : : the inlinability hooks completely eliminated). */
2787 : :
2788 : 128680297 : else if (decl_replaceable_p (decl, semantic_interposition)
2789 : 128680297 : && !DECL_EXTERNAL (decl))
2790 : 9386593 : avail = AVAIL_INTERPOSABLE;
2791 : 119293704 : else avail = AVAIL_AVAILABLE;
2792 : :
2793 : 817434174 : return avail;
2794 : : }
2795 : :
2796 : : /* Worker for cgraph_node_can_be_local_p. */
2797 : : static bool
2798 : 871898 : cgraph_node_cannot_be_local_p_1 (cgraph_node *node, void *)
2799 : : {
2800 : 871898 : return !(!node->force_output
2801 : 851145 : && !node->ifunc_resolver
2802 : : /* Limitation of gas requires us to output targets of symver aliases
2803 : : as global symbols. This is binutils PR 25295. */
2804 : 851105 : && !node->symver
2805 : 851105 : && ((DECL_COMDAT (node->decl)
2806 : 367145 : && !node->forced_by_abi
2807 : 344732 : && !node->used_from_object_file_p ()
2808 : 344732 : && !node->same_comdat_group)
2809 : 556329 : || !node->externally_visible)
2810 : 443003 : && !DECL_STATIC_CONSTRUCTOR (node->decl)
2811 : 441249 : && !DECL_STATIC_DESTRUCTOR (node->decl));
2812 : : }
2813 : :
2814 : : /* Return true if cgraph_node can be made local for API change.
2815 : : Extern inline functions and C++ COMDAT functions can be made local
2816 : : at the expense of possible code size growth if function is used in multiple
2817 : : compilation units. */
2818 : : bool
2819 : 1181877 : cgraph_node::can_be_local_p (void)
2820 : : {
2821 : 1181877 : return (!address_taken
2822 : 1181877 : && !call_for_symbol_thunks_and_aliases (cgraph_node_cannot_be_local_p_1,
2823 : 1181877 : NULL, true));
2824 : : }
2825 : :
2826 : : /* Call callback on cgraph_node, thunks and aliases associated to cgraph_node.
2827 : : When INCLUDE_OVERWRITABLE is false, overwritable symbols are
2828 : : skipped. When EXCLUDE_VIRTUAL_THUNKS is true, virtual thunks are
2829 : : skipped. */
2830 : : bool
2831 : 132873583 : cgraph_node::call_for_symbol_thunks_and_aliases (bool (*callback)
2832 : : (cgraph_node *, void *),
2833 : : void *data,
2834 : : bool include_overwritable,
2835 : : bool exclude_virtual_thunks)
2836 : : {
2837 : 132873583 : cgraph_edge *e;
2838 : 132873583 : ipa_ref *ref;
2839 : 132873583 : enum availability avail = AVAIL_AVAILABLE;
2840 : :
2841 : 132873583 : if (include_overwritable
2842 : 132873583 : || (avail = get_availability ()) > AVAIL_INTERPOSABLE)
2843 : : {
2844 : 132861911 : if (callback (this, data))
2845 : : return true;
2846 : : }
2847 : 140531484 : FOR_EACH_ALIAS (this, ref)
2848 : : {
2849 : 13068985 : cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
2850 : 13068985 : if (include_overwritable
2851 : 13068985 : || alias->get_availability () > AVAIL_INTERPOSABLE)
2852 : 13068743 : if (alias->call_for_symbol_thunks_and_aliases (callback, data,
2853 : : include_overwritable,
2854 : : exclude_virtual_thunks))
2855 : : return true;
2856 : : }
2857 : 127462499 : if (avail <= AVAIL_INTERPOSABLE)
2858 : : return false;
2859 : 133111089 : for (e = callers; e; e = e->next_caller)
2860 : 5660262 : if (e->caller->thunk
2861 : 2782 : && (include_overwritable
2862 : 426 : || e->caller->get_availability () > AVAIL_INTERPOSABLE)
2863 : 5663044 : && !(exclude_virtual_thunks
2864 : 22 : && thunk_info::get (e->caller)->virtual_offset_p))
2865 : 2770 : if (e->caller->call_for_symbol_thunks_and_aliases (callback, data,
2866 : : include_overwritable,
2867 : : exclude_virtual_thunks))
2868 : : return true;
2869 : :
2870 : : return false;
2871 : : }
2872 : :
2873 : : /* Worker to bring NODE local. */
2874 : :
2875 : : bool
2876 : 0 : cgraph_node::make_local (cgraph_node *node, void *)
2877 : : {
2878 : 0 : gcc_checking_assert (node->can_be_local_p ());
2879 : 0 : if (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl))
2880 : : {
2881 : 0 : node->make_decl_local ();
2882 : 0 : node->set_section (NULL);
2883 : 0 : node->set_comdat_group (NULL);
2884 : 0 : node->externally_visible = false;
2885 : 0 : node->forced_by_abi = false;
2886 : 0 : node->local = true;
2887 : 0 : node->unique_name = ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
2888 : 0 : || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
2889 : 0 : && !flag_incremental_link);
2890 : 0 : node->resolution = LDPR_PREVAILING_DEF_IRONLY;
2891 : 0 : gcc_assert (node->get_availability () == AVAIL_LOCAL);
2892 : : }
2893 : 0 : return false;
2894 : : }
2895 : :
2896 : : /* Bring cgraph node local. */
2897 : :
2898 : : void
2899 : 0 : cgraph_node::make_local (void)
2900 : : {
2901 : 0 : call_for_symbol_thunks_and_aliases (cgraph_node::make_local, NULL, true);
2902 : 0 : }
2903 : :
2904 : : /* Worker to set nothrow flag. */
2905 : :
2906 : : static void
2907 : 942970 : set_nothrow_flag_1 (cgraph_node *node, bool nothrow, bool non_call,
2908 : : bool *changed)
2909 : : {
2910 : 942970 : cgraph_edge *e;
2911 : :
2912 : 942970 : if (nothrow && !TREE_NOTHROW (node->decl))
2913 : : {
2914 : : /* With non-call exceptions we can't say for sure if other function body
2915 : : was not possibly optimized to still throw. */
2916 : 942945 : if (!non_call || node->binds_to_current_def_p ())
2917 : : {
2918 : 937181 : TREE_NOTHROW (node->decl) = true;
2919 : 937181 : *changed = true;
2920 : 2305360 : for (e = node->callers; e; e = e->next_caller)
2921 : 1368179 : e->can_throw_external = false;
2922 : : }
2923 : : }
2924 : 0 : else if (!nothrow && TREE_NOTHROW (node->decl))
2925 : : {
2926 : 0 : TREE_NOTHROW (node->decl) = false;
2927 : 0 : *changed = true;
2928 : : }
2929 : : ipa_ref *ref;
2930 : 998834 : FOR_EACH_ALIAS (node, ref)
2931 : : {
2932 : 55864 : cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
2933 : 55864 : if (!nothrow || alias->get_availability () > AVAIL_INTERPOSABLE)
2934 : 55439 : set_nothrow_flag_1 (alias, nothrow, non_call, changed);
2935 : : }
2936 : 2348607 : for (cgraph_edge *e = node->callers; e; e = e->next_caller)
2937 : 1405637 : if (e->caller->thunk
2938 : 1405637 : && (!nothrow || e->caller->get_availability () > AVAIL_INTERPOSABLE))
2939 : 135 : set_nothrow_flag_1 (e->caller, nothrow, non_call, changed);
2940 : 942970 : }
2941 : :
2942 : : /* Set TREE_NOTHROW on NODE's decl and on aliases of NODE
2943 : : if any to NOTHROW. */
2944 : :
2945 : : bool
2946 : 899613 : cgraph_node::set_nothrow_flag (bool nothrow)
2947 : : {
2948 : 899613 : bool changed = false;
2949 : 899613 : bool non_call = opt_for_fn (decl, flag_non_call_exceptions);
2950 : :
2951 : 899613 : if (!nothrow || get_availability () > AVAIL_INTERPOSABLE)
2952 : 887287 : set_nothrow_flag_1 (this, nothrow, non_call, &changed);
2953 : : else
2954 : : {
2955 : : ipa_ref *ref;
2956 : :
2957 : 19891 : FOR_EACH_ALIAS (this, ref)
2958 : : {
2959 : 7565 : cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
2960 : 7565 : if (!nothrow || alias->get_availability () > AVAIL_INTERPOSABLE)
2961 : 109 : set_nothrow_flag_1 (alias, nothrow, non_call, &changed);
2962 : : }
2963 : : }
2964 : 899613 : return changed;
2965 : : }
2966 : :
2967 : : /* Worker to set malloc flag. */
2968 : : static void
2969 : 26597 : set_malloc_flag_1 (cgraph_node *node, bool malloc_p, bool *changed)
2970 : : {
2971 : 26597 : if (malloc_p && !DECL_IS_MALLOC (node->decl))
2972 : : {
2973 : 26174 : DECL_IS_MALLOC (node->decl) = true;
2974 : 26174 : *changed = true;
2975 : : }
2976 : :
2977 : : ipa_ref *ref;
2978 : 26598 : FOR_EACH_ALIAS (node, ref)
2979 : : {
2980 : 1 : cgraph_node *alias = dyn_cast<cgraph_node *> (ref->referring);
2981 : 1 : if (!malloc_p || alias->get_availability () > AVAIL_INTERPOSABLE)
2982 : 1 : set_malloc_flag_1 (alias, malloc_p, changed);
2983 : : }
2984 : :
2985 : 58822 : for (cgraph_edge *e = node->callers; e; e = e->next_caller)
2986 : 32225 : if (e->caller->thunk
2987 : 32225 : && (!malloc_p || e->caller->get_availability () > AVAIL_INTERPOSABLE))
2988 : 0 : set_malloc_flag_1 (e->caller, malloc_p, changed);
2989 : 26597 : }
2990 : :
2991 : : /* Set DECL_IS_MALLOC on NODE's decl and on NODE's aliases if any. */
2992 : :
2993 : : bool
2994 : 26596 : cgraph_node::set_malloc_flag (bool malloc_p)
2995 : : {
2996 : 26596 : bool changed = false;
2997 : :
2998 : 26596 : if (!malloc_p || get_availability () > AVAIL_INTERPOSABLE)
2999 : 26596 : set_malloc_flag_1 (this, malloc_p, &changed);
3000 : : else
3001 : : {
3002 : : ipa_ref *ref;
3003 : :
3004 : 0 : FOR_EACH_ALIAS (this, ref)
3005 : : {
3006 : 0 : cgraph_node *alias = dyn_cast<cgraph_node *> (ref->referring);
3007 : 0 : if (!malloc_p || alias->get_availability () > AVAIL_INTERPOSABLE)
3008 : 0 : set_malloc_flag_1 (alias, malloc_p, &changed);
3009 : : }
3010 : : }
3011 : 26596 : return changed;
3012 : : }
3013 : :
3014 : : /* Worker to set malloc flag. */
3015 : : static void
3016 : 241860 : add_detected_attribute_1 (cgraph_node *node, const char *attr, bool *changed)
3017 : : {
3018 : 241860 : if (!lookup_attribute (attr, DECL_ATTRIBUTES (node->decl)))
3019 : : {
3020 : 215199 : DECL_ATTRIBUTES (node->decl) = tree_cons (get_identifier (attr),
3021 : 215199 : NULL_TREE, DECL_ATTRIBUTES (node->decl));
3022 : 215199 : *changed = true;
3023 : : }
3024 : :
3025 : : ipa_ref *ref;
3026 : 242399 : FOR_EACH_ALIAS (node, ref)
3027 : : {
3028 : 539 : cgraph_node *alias = dyn_cast<cgraph_node *> (ref->referring);
3029 : 539 : if (alias->get_availability () > AVAIL_INTERPOSABLE)
3030 : 130 : add_detected_attribute_1 (alias, attr, changed);
3031 : : }
3032 : :
3033 : 777796 : for (cgraph_edge *e = node->callers; e; e = e->next_caller)
3034 : 535936 : if (e->caller->thunk
3035 : 535936 : && (e->caller->get_availability () > AVAIL_INTERPOSABLE))
3036 : 14 : add_detected_attribute_1 (e->caller, attr, changed);
3037 : 241860 : }
3038 : :
3039 : : /* Add attribyte ATTR to function and its aliases. */
3040 : :
3041 : : bool
3042 : 245482 : cgraph_node::add_detected_attribute (const char *attr)
3043 : : {
3044 : 245482 : bool changed = false;
3045 : :
3046 : 245482 : if (get_availability () > AVAIL_INTERPOSABLE)
3047 : 241716 : add_detected_attribute_1 (this, attr, &changed);
3048 : : else
3049 : : {
3050 : : ipa_ref *ref;
3051 : :
3052 : 3790 : FOR_EACH_ALIAS (this, ref)
3053 : : {
3054 : 24 : cgraph_node *alias = dyn_cast<cgraph_node *> (ref->referring);
3055 : 24 : if (alias->get_availability () > AVAIL_INTERPOSABLE)
3056 : 0 : add_detected_attribute_1 (alias, attr, &changed);
3057 : : }
3058 : : }
3059 : 245482 : return changed;
3060 : : }
3061 : :
3062 : : /* Worker to set noreturng flag. */
3063 : : static void
3064 : 28245 : set_noreturn_flag_1 (cgraph_node *node, bool noreturn_p, bool *changed)
3065 : : {
3066 : 28245 : if (noreturn_p && !TREE_THIS_VOLATILE (node->decl))
3067 : : {
3068 : 28245 : TREE_THIS_VOLATILE (node->decl) = true;
3069 : 28245 : *changed = true;
3070 : : }
3071 : :
3072 : : ipa_ref *ref;
3073 : 28908 : FOR_EACH_ALIAS (node, ref)
3074 : : {
3075 : 663 : cgraph_node *alias = dyn_cast<cgraph_node *> (ref->referring);
3076 : 663 : if (!noreturn_p || alias->get_availability () > AVAIL_INTERPOSABLE)
3077 : 663 : set_noreturn_flag_1 (alias, noreturn_p, changed);
3078 : : }
3079 : :
3080 : 45639 : for (cgraph_edge *e = node->callers; e; e = e->next_caller)
3081 : 17394 : if (e->caller->thunk
3082 : 17394 : && (!noreturn_p || e->caller->get_availability () > AVAIL_INTERPOSABLE))
3083 : 20 : set_noreturn_flag_1 (e->caller, noreturn_p, changed);
3084 : 28245 : }
3085 : :
3086 : : /* Set TREE_THIS_VOLATILE on NODE's decl and on NODE's aliases if any. */
3087 : :
3088 : : bool
3089 : 27719 : cgraph_node::set_noreturn_flag (bool noreturn_p)
3090 : : {
3091 : 27719 : bool changed = false;
3092 : :
3093 : 27719 : if (!noreturn_p || get_availability () > AVAIL_INTERPOSABLE)
3094 : 27553 : set_noreturn_flag_1 (this, noreturn_p, &changed);
3095 : : else
3096 : : {
3097 : : ipa_ref *ref;
3098 : :
3099 : 183 : FOR_EACH_ALIAS (this, ref)
3100 : : {
3101 : 17 : cgraph_node *alias = dyn_cast<cgraph_node *> (ref->referring);
3102 : 17 : if (!noreturn_p || alias->get_availability () > AVAIL_INTERPOSABLE)
3103 : 9 : set_noreturn_flag_1 (alias, noreturn_p, &changed);
3104 : : }
3105 : : }
3106 : 27719 : return changed;
3107 : : }
3108 : :
3109 : : /* Worker to set_const_flag. */
3110 : :
3111 : : static void
3112 : 1102977 : set_const_flag_1 (cgraph_node *node, bool set_const, bool looping,
3113 : : bool *changed)
3114 : : {
3115 : : /* Static constructors and destructors without a side effect can be
3116 : : optimized out. */
3117 : 1102977 : if (set_const && !looping)
3118 : : {
3119 : 1096975 : if (DECL_STATIC_CONSTRUCTOR (node->decl))
3120 : : {
3121 : 250 : DECL_STATIC_CONSTRUCTOR (node->decl) = 0;
3122 : 250 : *changed = true;
3123 : : }
3124 : 1096975 : if (DECL_STATIC_DESTRUCTOR (node->decl))
3125 : : {
3126 : 1 : DECL_STATIC_DESTRUCTOR (node->decl) = 0;
3127 : 1 : *changed = true;
3128 : : }
3129 : : }
3130 : 1102977 : if (!set_const)
3131 : : {
3132 : 2215 : if (TREE_READONLY (node->decl))
3133 : : {
3134 : 159 : TREE_READONLY (node->decl) = 0;
3135 : 159 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
3136 : 159 : *changed = true;
3137 : : }
3138 : : }
3139 : : else
3140 : : {
3141 : : /* Consider function:
3142 : :
3143 : : bool a(int *p)
3144 : : {
3145 : : return *p==*p;
3146 : : }
3147 : :
3148 : : During early optimization we will turn this into:
3149 : :
3150 : : bool a(int *p)
3151 : : {
3152 : : return true;
3153 : : }
3154 : :
3155 : : Now if this function will be detected as CONST however when interposed
3156 : : it may end up being just pure. We always must assume the worst
3157 : : scenario here. */
3158 : 1100762 : if (TREE_READONLY (node->decl))
3159 : : {
3160 : 737 : if (!looping && DECL_LOOPING_CONST_OR_PURE_P (node->decl))
3161 : : {
3162 : 420 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
3163 : 420 : *changed = true;
3164 : : }
3165 : : }
3166 : 1100025 : else if (node->binds_to_current_def_p ())
3167 : : {
3168 : 173754 : TREE_READONLY (node->decl) = true;
3169 : 173754 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = looping;
3170 : 173754 : DECL_PURE_P (node->decl) = false;
3171 : 173754 : *changed = true;
3172 : : }
3173 : : else
3174 : : {
3175 : 926271 : if (dump_file && (dump_flags & TDF_DETAILS))
3176 : 0 : fprintf (dump_file, "Dropping state to PURE because function does "
3177 : : "not bind to current def.\n");
3178 : 926271 : if (!DECL_PURE_P (node->decl))
3179 : : {
3180 : 440671 : DECL_PURE_P (node->decl) = true;
3181 : 440671 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = looping;
3182 : 440671 : *changed = true;
3183 : : }
3184 : 485600 : else if (!looping && DECL_LOOPING_CONST_OR_PURE_P (node->decl))
3185 : : {
3186 : 143 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
3187 : 143 : *changed = true;
3188 : : }
3189 : : }
3190 : : }
3191 : :
3192 : : ipa_ref *ref;
3193 : 1243694 : FOR_EACH_ALIAS (node, ref)
3194 : : {
3195 : 140717 : cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
3196 : 140717 : if (!set_const || alias->get_availability () > AVAIL_INTERPOSABLE)
3197 : 140654 : set_const_flag_1 (alias, set_const, looping, changed);
3198 : : }
3199 : 1103073 : for (struct cgraph_node *n = node->simd_clones; n != NULL;
3200 : 96 : n = n->simdclone->next_clone)
3201 : 96 : set_const_flag_1 (n, set_const, looping, changed);
3202 : 2876119 : for (cgraph_edge *e = node->callers; e; e = e->next_caller)
3203 : 1773142 : if (e->caller->thunk
3204 : 1773142 : && (!set_const || e->caller->get_availability () > AVAIL_INTERPOSABLE))
3205 : : {
3206 : : /* Virtual thunks access virtual offset in the vtable, so they can
3207 : : only be pure, never const. */
3208 : 369 : if (set_const
3209 : 369 : && (thunk_info::get (e->caller)->virtual_offset_p
3210 : 238 : || !node->binds_to_current_def_p (e->caller)))
3211 : 131 : *changed |= e->caller->set_pure_flag (true, looping);
3212 : : else
3213 : 238 : set_const_flag_1 (e->caller, set_const, looping, changed);
3214 : : }
3215 : 1102977 : }
3216 : :
3217 : : /* If SET_CONST is true, mark function, aliases and thunks to be ECF_CONST.
3218 : : If SET_CONST if false, clear the flag.
3219 : :
3220 : : When setting the flag be careful about possible interposition and
3221 : : do not set the flag for functions that can be interposed and set pure
3222 : : flag for functions that can bind to other definition.
3223 : :
3224 : : Return true if any change was done. */
3225 : :
3226 : : bool
3227 : 987905 : cgraph_node::set_const_flag (bool set_const, bool looping)
3228 : : {
3229 : 987905 : bool changed = false;
3230 : 987905 : if (!set_const || get_availability () > AVAIL_INTERPOSABLE)
3231 : 961794 : set_const_flag_1 (this, set_const, looping, &changed);
3232 : : else
3233 : : {
3234 : : ipa_ref *ref;
3235 : :
3236 : 26990 : FOR_EACH_ALIAS (this, ref)
3237 : : {
3238 : 879 : cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
3239 : 879 : if (!set_const || alias->get_availability () > AVAIL_INTERPOSABLE)
3240 : 195 : set_const_flag_1 (alias, set_const, looping, &changed);
3241 : : }
3242 : : }
3243 : 987905 : return changed;
3244 : : }
3245 : :
3246 : : /* Info used by set_pure_flag_1. */
3247 : :
3248 : : struct set_pure_flag_info
3249 : : {
3250 : : bool pure;
3251 : : bool looping;
3252 : : bool changed;
3253 : : };
3254 : :
3255 : : /* Worker to set_pure_flag. */
3256 : :
3257 : : static bool
3258 : 371371 : set_pure_flag_1 (cgraph_node *node, void *data)
3259 : : {
3260 : 371371 : struct set_pure_flag_info *info = (struct set_pure_flag_info *)data;
3261 : : /* Static constructors and destructors without a side effect can be
3262 : : optimized out. */
3263 : 371371 : if (info->pure && !info->looping)
3264 : : {
3265 : 304603 : if (DECL_STATIC_CONSTRUCTOR (node->decl))
3266 : : {
3267 : 0 : DECL_STATIC_CONSTRUCTOR (node->decl) = 0;
3268 : 0 : info->changed = true;
3269 : : }
3270 : 304603 : if (DECL_STATIC_DESTRUCTOR (node->decl))
3271 : : {
3272 : 0 : DECL_STATIC_DESTRUCTOR (node->decl) = 0;
3273 : 0 : info->changed = true;
3274 : : }
3275 : : }
3276 : 371371 : if (info->pure)
3277 : : {
3278 : 369156 : if (!DECL_PURE_P (node->decl) && !TREE_READONLY (node->decl))
3279 : : {
3280 : 368567 : DECL_PURE_P (node->decl) = true;
3281 : 368567 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = info->looping;
3282 : 368567 : info->changed = true;
3283 : : }
3284 : 589 : else if (DECL_LOOPING_CONST_OR_PURE_P (node->decl)
3285 : 589 : && !info->looping)
3286 : : {
3287 : 312 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
3288 : 312 : info->changed = true;
3289 : : }
3290 : : }
3291 : : else
3292 : : {
3293 : 2215 : if (DECL_PURE_P (node->decl))
3294 : : {
3295 : 75 : DECL_PURE_P (node->decl) = false;
3296 : 75 : DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
3297 : 75 : info->changed = true;
3298 : : }
3299 : : }
3300 : 371371 : return false;
3301 : : }
3302 : :
3303 : : /* Set DECL_PURE_P on cgraph_node's decl and on aliases of the node
3304 : : if any to PURE.
3305 : :
3306 : : When setting the flag, be careful about possible interposition.
3307 : : Return true if any change was done. */
3308 : :
3309 : : bool
3310 : 382085 : cgraph_node::set_pure_flag (bool pure, bool looping)
3311 : : {
3312 : 382085 : struct set_pure_flag_info info = {pure, looping, false};
3313 : 382085 : call_for_symbol_thunks_and_aliases (set_pure_flag_1, &info, !pure, true);
3314 : 382085 : for (struct cgraph_node *n = simd_clones; n != NULL;
3315 : 0 : n = n->simdclone->next_clone)
3316 : 0 : set_pure_flag_1 (n, &info);
3317 : 382085 : return info.changed;
3318 : : }
3319 : :
3320 : : /* Return true when cgraph_node cannot return or throw and thus
3321 : : it is safe to ignore its side effects for IPA analysis. */
3322 : :
3323 : : bool
3324 : 14510430 : cgraph_node::cannot_return_p (void)
3325 : : {
3326 : 14510430 : int flags = flags_from_decl_or_type (decl);
3327 : 14510430 : if (!opt_for_fn (decl, flag_exceptions))
3328 : 4706805 : return (flags & ECF_NORETURN) != 0;
3329 : : else
3330 : 9803625 : return ((flags & (ECF_NORETURN | ECF_NOTHROW))
3331 : 9803625 : == (ECF_NORETURN | ECF_NOTHROW));
3332 : : }
3333 : :
3334 : : /* Return true when call of edge cannot lead to return from caller
3335 : : and thus it is safe to ignore its side effects for IPA analysis
3336 : : when computing side effects of the caller.
3337 : : FIXME: We could actually mark all edges that have no reaching
3338 : : patch to the exit block or throw to get better results. */
3339 : : bool
3340 : 3052999 : cgraph_edge::cannot_lead_to_return_p (void)
3341 : : {
3342 : 3052999 : if (caller->cannot_return_p ())
3343 : : return true;
3344 : 2965842 : if (indirect_unknown_callee)
3345 : : {
3346 : 100911 : int flags = indirect_info->ecf_flags;
3347 : 100911 : if (!opt_for_fn (caller->decl, flag_exceptions))
3348 : 19451 : return (flags & ECF_NORETURN) != 0;
3349 : : else
3350 : 81460 : return ((flags & (ECF_NORETURN | ECF_NOTHROW))
3351 : 81460 : == (ECF_NORETURN | ECF_NOTHROW));
3352 : : }
3353 : : else
3354 : 2864931 : return callee->cannot_return_p ();
3355 : : }
3356 : :
3357 : : /* Return true if the edge after scaling it profile by SCALE
3358 : : may be considered hot. */
3359 : :
3360 : : bool
3361 : 5487743 : cgraph_edge::maybe_hot_p (sreal scale)
3362 : : {
3363 : : /* Never consider calls in functions optimized for size hot. */
3364 : 5487743 : if (opt_for_fn (caller->decl, optimize_size))
3365 : : return false;
3366 : :
3367 : : /* If reliable IPA count is available, just use it. */
3368 : 5432363 : profile_count c = count.ipa ();
3369 : 5432363 : if (c.reliable_p ()
3370 : 5432363 : || (c.quality () == AFDO && c.nonzero_p ()))
3371 : 702845 : return maybe_hot_count_p (NULL, c * scale);
3372 : :
3373 : : /* In auto-FDO, count 0 may lead to hot code in case the
3374 : : call is simply not called often enough to receive some samples. */
3375 : 4729518 : if ((c.quality () == AFDO
3376 : 4729518 : || count.quality () == GUESSED_GLOBAL0_ADJUSTED)
3377 : 4729518 : && callee && callee->count.quality () == AFDO)
3378 : 0 : return maybe_hot_count_p (NULL, c.force_nonzero () * scale);
3379 : :
3380 : : /* See if we can determine hotness using caller frequency. */
3381 : 4729518 : if (caller->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3382 : 4726399 : || (callee
3383 : 4298100 : && callee->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))
3384 : : return false;
3385 : 4722786 : if (caller->frequency > NODE_FREQUENCY_UNLIKELY_EXECUTED
3386 : 4722786 : && (callee
3387 : 4294487 : && callee->frequency <= NODE_FREQUENCY_EXECUTED_ONCE))
3388 : : return false;
3389 : : /* ??? This may make sense for hot functions determined by
3390 : : user attribute, but if function is hot by profile, it may
3391 : : contains non-hot calls. In most practical cases this case
3392 : : is handled by the reliable ipa count above, but i.e. after
3393 : : inlining function with no profile to function with profile
3394 : : we get here.. */
3395 : 4667744 : if (caller->frequency == NODE_FREQUENCY_HOT)
3396 : : return true;
3397 : :
3398 : : /* Use IPA count and if it s not available appy local heuristics. */
3399 : 4667742 : if (c.initialized_p ())
3400 : : {
3401 : : /* A special case; AFDO zero means that function may quite possibly
3402 : : be executed few times per execution. If scale is large, we still
3403 : : want to consider the call hot. */
3404 : 0 : if (c.quality () == AFDO)
3405 : 0 : c = c.force_nonzero ();
3406 : 0 : return maybe_hot_count_p (NULL, c * scale);
3407 : : }
3408 : 4667742 : if (!count.initialized_p ())
3409 : : return true;
3410 : 3406702 : cgraph_node *where = caller->inlined_to ? caller->inlined_to : caller;
3411 : 3406702 : if (!where->count.initialized_p ())
3412 : : return true;
3413 : 3406702 : c = count * scale;
3414 : 3406702 : if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE)
3415 : : {
3416 : 72327 : if (c * 2 < where->count * 3)
3417 : : return false;
3418 : : }
3419 : 3334375 : else if (c * param_hot_bb_frequency_fraction < where->count)
3420 : : return false;
3421 : : return true;
3422 : : }
3423 : :
3424 : : /* Return true if the edge may be considered hot. */
3425 : :
3426 : : bool
3427 : 2201906 : cgraph_edge::maybe_hot_p ()
3428 : : {
3429 : 2201906 : return maybe_hot_p (1);
3430 : : }
3431 : :
3432 : : /* Worker for cgraph_can_remove_if_no_direct_calls_p. */
3433 : :
3434 : : static bool
3435 : 839579 : nonremovable_p (cgraph_node *node, void *)
3436 : : {
3437 : 839579 : return !node->can_remove_if_no_direct_calls_and_refs_p ();
3438 : : }
3439 : :
3440 : : /* Return true if whole comdat group can be removed if there are no direct
3441 : : calls to THIS. */
3442 : :
3443 : : bool
3444 : 1070733 : cgraph_node::can_remove_if_no_direct_calls_p (bool will_inline)
3445 : : {
3446 : 1070733 : struct ipa_ref *ref;
3447 : :
3448 : : /* For local symbols or non-comdat group it is the same as
3449 : : can_remove_if_no_direct_calls_p. */
3450 : 1070733 : if (!externally_visible || !same_comdat_group)
3451 : : {
3452 : 849535 : if (DECL_EXTERNAL (decl))
3453 : : return true;
3454 : 849535 : if (address_taken)
3455 : : return false;
3456 : 812616 : return !call_for_symbol_and_aliases (nonremovable_p, NULL, true);
3457 : : }
3458 : :
3459 : 221198 : if (will_inline && address_taken)
3460 : : return false;
3461 : :
3462 : : /* Otherwise check if we can remove the symbol itself and then verify
3463 : : that only uses of the comdat groups are direct call to THIS
3464 : : or its aliases. */
3465 : 221198 : if (!can_remove_if_no_direct_calls_and_refs_p ())
3466 : : return false;
3467 : :
3468 : : /* Check that all refs come from within the comdat group. */
3469 : 423257 : for (int i = 0; iterate_referring (i, ref); i++)
3470 : 216288 : if (ref->referring->get_comdat_group () != get_comdat_group ())
3471 : : return false;
3472 : :
3473 : 206969 : struct cgraph_node *target = ultimate_alias_target ();
3474 : 206969 : for (cgraph_node *next = dyn_cast<cgraph_node *> (same_comdat_group);
3475 : 624061 : next != this; next = dyn_cast<cgraph_node *> (next->same_comdat_group))
3476 : : {
3477 : 221007 : if (!externally_visible)
3478 : 0 : continue;
3479 : 221007 : if (!next->alias
3480 : 221007 : && !next->can_remove_if_no_direct_calls_and_refs_p ())
3481 : : return false;
3482 : :
3483 : : /* If we see different symbol than THIS, be sure to check calls. */
3484 : 221007 : if (next->ultimate_alias_target () != target)
3485 : 23412 : for (cgraph_edge *e = next->callers; e; e = e->next_caller)
3486 : 4917 : if (e->caller->get_comdat_group () != get_comdat_group ()
3487 : 4917 : || will_inline)
3488 : : return false;
3489 : :
3490 : : /* If function is not being inlined, we care only about
3491 : : references outside of the comdat group. */
3492 : 219040 : if (!will_inline)
3493 : 220235 : for (int i = 0; next->iterate_referring (i, ref); i++)
3494 : 11689 : if (ref->referring->get_comdat_group () != get_comdat_group ())
3495 : : return false;
3496 : : }
3497 : : return true;
3498 : : }
3499 : :
3500 : : /* Return true when function cgraph_node can be expected to be removed
3501 : : from program when direct calls in this compilation unit are removed.
3502 : :
3503 : : As a special case COMDAT functions are
3504 : : cgraph_can_remove_if_no_direct_calls_p while the are not
3505 : : cgraph_only_called_directly_p (it is possible they are called from other
3506 : : unit)
3507 : :
3508 : : This function behaves as cgraph_only_called_directly_p because eliminating
3509 : : all uses of COMDAT function does not make it necessarily disappear from
3510 : : the program unless we are compiling whole program or we do LTO. In this
3511 : : case we know we win since dynamic linking will not really discard the
3512 : : linkonce section. */
3513 : :
3514 : : bool
3515 : 3256585 : cgraph_node::will_be_removed_from_program_if_no_direct_calls_p
3516 : : (bool will_inline)
3517 : : {
3518 : 3256585 : gcc_assert (!inlined_to);
3519 : 3256585 : if (DECL_EXTERNAL (decl))
3520 : : return true;
3521 : :
3522 : 3256585 : if (!in_lto_p && !flag_whole_program)
3523 : : {
3524 : : /* If the symbol is in comdat group, we need to verify that whole comdat
3525 : : group becomes unreachable. Technically we could skip references from
3526 : : within the group, too. */
3527 : 3002985 : if (!only_called_directly_p ())
3528 : : return false;
3529 : 725990 : if (same_comdat_group && externally_visible)
3530 : : {
3531 : 0 : struct cgraph_node *target = ultimate_alias_target ();
3532 : :
3533 : 0 : if (will_inline && address_taken)
3534 : : return true;
3535 : 0 : for (cgraph_node *next = dyn_cast<cgraph_node *> (same_comdat_group);
3536 : 0 : next != this;
3537 : 0 : next = dyn_cast<cgraph_node *> (next->same_comdat_group))
3538 : : {
3539 : 0 : if (!externally_visible)
3540 : 0 : continue;
3541 : 0 : if (!next->alias
3542 : 0 : && !next->only_called_directly_p ())
3543 : : return false;
3544 : :
3545 : : /* If we see different symbol than THIS,
3546 : : be sure to check calls. */
3547 : 0 : if (next->ultimate_alias_target () != target)
3548 : 0 : for (cgraph_edge *e = next->callers; e; e = e->next_caller)
3549 : 0 : if (e->caller->get_comdat_group () != get_comdat_group ()
3550 : 0 : || will_inline)
3551 : : return false;
3552 : : }
3553 : : }
3554 : 725990 : return true;
3555 : : }
3556 : : else
3557 : 253600 : return can_remove_if_no_direct_calls_p (will_inline);
3558 : : }
3559 : :
3560 : :
3561 : : /* Worker for cgraph_only_called_directly_p. */
3562 : :
3563 : : static bool
3564 : 16068197 : cgraph_not_only_called_directly_p_1 (cgraph_node *node, void *)
3565 : : {
3566 : 16068197 : return !node->only_called_directly_or_aliased_p ();
3567 : : }
3568 : :
3569 : : /* Return true when function cgraph_node and all its aliases are only called
3570 : : directly.
3571 : : i.e. it is not externally visible, address was not taken and
3572 : : it is not used in any other non-standard way. */
3573 : :
3574 : : bool
3575 : 15971043 : cgraph_node::only_called_directly_p (void)
3576 : : {
3577 : 15971043 : gcc_assert (ultimate_alias_target () == this);
3578 : 15971043 : return !call_for_symbol_and_aliases (cgraph_not_only_called_directly_p_1,
3579 : 15971043 : NULL, true);
3580 : : }
3581 : :
3582 : :
3583 : : /* Collect all callers of NODE. Worker for collect_callers_of_node. */
3584 : :
3585 : : static bool
3586 : 132843 : collect_callers_of_node_1 (cgraph_node *node, void *data)
3587 : : {
3588 : 132843 : vec<cgraph_edge *> *redirect_callers = (vec<cgraph_edge *> *)data;
3589 : 132843 : cgraph_edge *cs;
3590 : 132843 : enum availability avail;
3591 : 132843 : node->ultimate_alias_target (&avail);
3592 : :
3593 : 132843 : if (avail > AVAIL_INTERPOSABLE)
3594 : 463872 : for (cs = node->callers; cs != NULL; cs = cs->next_caller)
3595 : 331029 : if (!cs->indirect_inlining_edge
3596 : 331029 : && !cs->caller->thunk)
3597 : 330983 : redirect_callers->safe_push (cs);
3598 : 132843 : return false;
3599 : : }
3600 : :
3601 : : /* Collect all callers of cgraph_node and its aliases that are known to lead to
3602 : : cgraph_node (i.e. are not overwritable). */
3603 : :
3604 : : auto_vec<cgraph_edge *>
3605 : 131015 : cgraph_node::collect_callers (void)
3606 : : {
3607 : 131015 : auto_vec<cgraph_edge *> redirect_callers;
3608 : 131015 : call_for_symbol_thunks_and_aliases (collect_callers_of_node_1,
3609 : : &redirect_callers, false);
3610 : 131015 : return redirect_callers;
3611 : : }
3612 : :
3613 : :
3614 : : /* Return TRUE if NODE2 a clone of NODE or is equivalent to it. Return
3615 : : optimistically true if this cannot be determined. */
3616 : :
3617 : : static bool
3618 : 34255 : clone_of_p (cgraph_node *node, cgraph_node *node2)
3619 : : {
3620 : 34255 : node = node->ultimate_alias_target ();
3621 : 34255 : node2 = node2->ultimate_alias_target ();
3622 : :
3623 : 34255 : if (node2->clone_of == node
3624 : 4063 : || node2->former_clone_of == node->decl)
3625 : : return true;
3626 : :
3627 : 4125 : if (!node->thunk && !node->former_thunk_p ())
3628 : : {
3629 : : while (node2
3630 : 12002 : && node->decl != node2->decl
3631 : 20004 : && node->decl != node2->former_clone_of)
3632 : 8001 : node2 = node2->clone_of;
3633 : 4001 : return node2 != NULL;
3634 : : }
3635 : :
3636 : : /* There are no virtual clones of thunks so check former_clone_of or if we
3637 : : might have skipped thunks because this adjustments are no longer
3638 : : necessary. */
3639 : 62 : while (node->thunk || node->former_thunk_p ())
3640 : : {
3641 : 62 : if (!thunk_info::get (node)->this_adjusting)
3642 : : return false;
3643 : : /* In case of instrumented expanded thunks, which can have multiple calls
3644 : : in them, we do not know how to continue and just have to be
3645 : : optimistic. The same applies if all calls have already been inlined
3646 : : into the thunk. */
3647 : 62 : if (!node->callees || node->callees->next_callee)
3648 : : return true;
3649 : 59 : node = node->callees->callee->ultimate_alias_target ();
3650 : :
3651 : 59 : clone_info *info = clone_info::get (node2);
3652 : 59 : if (!info || !info->param_adjustments
3653 : 118 : || info->param_adjustments->first_param_intact_p ())
3654 : 0 : return false;
3655 : 59 : if (node2->former_clone_of == node->decl
3656 : 59 : || node2->former_clone_of == node->former_clone_of)
3657 : : return true;
3658 : :
3659 : : cgraph_node *n2 = node2;
3660 : 0 : while (n2 && node->decl != n2->decl)
3661 : 0 : n2 = n2->clone_of;
3662 : 0 : if (n2)
3663 : : return true;
3664 : : }
3665 : :
3666 : : return false;
3667 : : }
3668 : :
3669 : : /* Verify edge count and frequency. */
3670 : :
3671 : : bool
3672 : 199185623 : cgraph_edge::verify_count ()
3673 : : {
3674 : 199185623 : bool error_found = false;
3675 : 199185623 : if (!count.verify ())
3676 : : {
3677 : 0 : error ("caller edge count invalid");
3678 : 0 : error_found = true;
3679 : : }
3680 : 199185623 : return error_found;
3681 : : }
3682 : :
3683 : : /* Switch to THIS_CFUN if needed and print STMT to stderr. */
3684 : : static void
3685 : 0 : cgraph_debug_gimple_stmt (function *this_cfun, gimple *stmt)
3686 : : {
3687 : 0 : bool fndecl_was_null = false;
3688 : : /* debug_gimple_stmt needs correct cfun */
3689 : 0 : if (cfun != this_cfun)
3690 : 0 : set_cfun (this_cfun);
3691 : : /* ...and an actual current_function_decl */
3692 : 0 : if (!current_function_decl)
3693 : : {
3694 : 0 : current_function_decl = this_cfun->decl;
3695 : 0 : fndecl_was_null = true;
3696 : : }
3697 : 0 : debug_gimple_stmt (stmt);
3698 : 0 : if (fndecl_was_null)
3699 : 0 : current_function_decl = NULL;
3700 : 0 : }
3701 : :
3702 : : /* Verify that call graph edge corresponds to DECL from the associated
3703 : : statement. Return true if the verification should fail. */
3704 : :
3705 : : bool
3706 : 98849926 : cgraph_edge::verify_corresponds_to_fndecl (tree decl)
3707 : : {
3708 : 98849926 : cgraph_node *node;
3709 : :
3710 : 98849926 : if (!decl || callee->inlined_to)
3711 : : return false;
3712 : 95027429 : if (symtab->state == LTO_STREAMING)
3713 : : return false;
3714 : 95027429 : node = cgraph_node::get (decl);
3715 : :
3716 : : /* We do not know if a node from a different partition is an alias or what it
3717 : : aliases and therefore cannot do the former_clone_of check reliably. When
3718 : : body_removed is set, we have lost all information about what was alias or
3719 : : thunk of and also cannot proceed. */
3720 : 95027429 : if (!node
3721 : 94922688 : || node->body_removed
3722 : 94243249 : || node->in_other_partition
3723 : 94243249 : || callee->icf_merged
3724 : 94141809 : || callee->in_other_partition)
3725 : : return false;
3726 : :
3727 : 94141809 : node = node->ultimate_alias_target ();
3728 : :
3729 : : /* Optimizers can redirect unreachable calls or calls triggering undefined
3730 : : behavior to __builtin_unreachable or __builtin_unreachable trap. */
3731 : :
3732 : 94141809 : if (fndecl_built_in_p (callee->decl, BUILT_IN_UNREACHABLE,
3733 : : BUILT_IN_UNREACHABLE_TRAP))
3734 : : return false;
3735 : :
3736 : 91295054 : if (callee->former_clone_of != node->decl
3737 : 91293452 : && (node != callee->ultimate_alias_target ())
3738 : 91329309 : && !clone_of_p (node, callee))
3739 : : return true;
3740 : : else
3741 : 91295054 : return false;
3742 : : }
3743 : :
3744 : : /* Disable warnings about missing quoting in GCC diagnostics for
3745 : : the verification errors. Their format strings don't follow GCC
3746 : : diagnostic conventions and the calls are ultimately followed by
3747 : : one to internal_error. */
3748 : : #if __GNUC__ >= 10
3749 : : # pragma GCC diagnostic push
3750 : : # pragma GCC diagnostic ignored "-Wformat-diag"
3751 : : #endif
3752 : :
3753 : : /* Verify consistency of speculative call in NODE corresponding to STMT
3754 : : and LTO_STMT_UID. If INDIRECT is set, assume that it is the indirect
3755 : : edge of call sequence. Return true if error is found.
3756 : :
3757 : : This function is called to every component of indirect call (direct edges,
3758 : : indirect edge and refs). To save duplicated work, do full testing only
3759 : : in that case. */
3760 : : static bool
3761 : 454430 : verify_speculative_call (struct cgraph_node *node, gimple *stmt,
3762 : : unsigned int lto_stmt_uid,
3763 : : struct cgraph_edge *indirect)
3764 : : {
3765 : 454430 : if (indirect == NULL)
3766 : : {
3767 : 450154 : for (indirect = node->indirect_calls; indirect;
3768 : 108700 : indirect = indirect->next_callee)
3769 : 450154 : if (indirect->call_stmt == stmt
3770 : 341572 : && indirect->lto_stmt_uid == lto_stmt_uid)
3771 : : break;
3772 : 341454 : if (!indirect)
3773 : : {
3774 : 0 : error ("missing indirect call in speculative call sequence");
3775 : 0 : return true;
3776 : : }
3777 : 341454 : if (!indirect->speculative)
3778 : : {
3779 : 0 : error ("indirect call in speculative call sequence has no "
3780 : : "speculative flag");
3781 : 0 : return true;
3782 : : }
3783 : : return false;
3784 : : }
3785 : :
3786 : : /* Maximal number of targets. We probably will never want to have more than
3787 : : this. */
3788 : : const unsigned int num = 256;
3789 : : cgraph_edge *direct_calls[num];
3790 : : ipa_ref *refs[num];
3791 : :
3792 : 29034832 : for (unsigned int i = 0; i < num; i++)
3793 : : {
3794 : 28921856 : direct_calls[i] = NULL;
3795 : 28921856 : refs[i] = NULL;
3796 : : }
3797 : :
3798 : 112976 : cgraph_edge *first_call = NULL;
3799 : 112976 : cgraph_edge *prev_call = NULL;
3800 : :
3801 : 657512 : for (cgraph_edge *direct = node->callees; direct;
3802 : 544536 : direct = direct->next_callee)
3803 : 544536 : if (direct->call_stmt == stmt && direct->lto_stmt_uid == lto_stmt_uid)
3804 : : {
3805 : 170727 : if (!first_call)
3806 : 112976 : first_call = direct;
3807 : 170727 : if (prev_call && direct != prev_call->next_callee)
3808 : : {
3809 : 0 : error ("speculative edges are not adjacent");
3810 : 0 : return true;
3811 : : }
3812 : 170727 : prev_call = direct;
3813 : 170727 : if (!direct->speculative)
3814 : : {
3815 : 0 : error ("direct call to %s in speculative call sequence has no "
3816 : 0 : "speculative flag", direct->callee->dump_name ());
3817 : 0 : return true;
3818 : : }
3819 : 170727 : if (direct->speculative_id >= num)
3820 : : {
3821 : 0 : error ("direct call to %s in speculative call sequence has "
3822 : : "speculative_id %i out of range",
3823 : 0 : direct->callee->dump_name (), direct->speculative_id);
3824 : 0 : return true;
3825 : : }
3826 : 170727 : if (direct_calls[direct->speculative_id])
3827 : : {
3828 : 0 : error ("duplicate direct call to %s in speculative call sequence "
3829 : : "with speculative_id %i",
3830 : 0 : direct->callee->dump_name (), direct->speculative_id);
3831 : 0 : return true;
3832 : : }
3833 : 170727 : direct_calls[direct->speculative_id] = direct;
3834 : : }
3835 : :
3836 : 112976 : if (first_call->call_stmt
3837 : 112976 : && first_call != node->get_edge (first_call->call_stmt))
3838 : : {
3839 : 0 : error ("call stmt hash does not point to first direct edge of "
3840 : : "speculative call sequence");
3841 : 0 : return true;
3842 : : }
3843 : :
3844 : : ipa_ref *ref;
3845 : 434142 : for (int i = 0; node->iterate_reference (i, ref); i++)
3846 : 321166 : if (ref->speculative
3847 : 262217 : && ref->stmt == stmt && ref->lto_stmt_uid == lto_stmt_uid)
3848 : : {
3849 : 170727 : if (ref->speculative_id >= num)
3850 : : {
3851 : 0 : error ("direct call to %s in speculative call sequence has "
3852 : : "speculative_id %i out of range",
3853 : 0 : ref->referred->dump_name (), ref->speculative_id);
3854 : 0 : return true;
3855 : : }
3856 : 170727 : if (refs[ref->speculative_id])
3857 : : {
3858 : 0 : error ("duplicate reference %s in speculative call sequence "
3859 : : "with speculative_id %i",
3860 : 0 : ref->referred->dump_name (), ref->speculative_id);
3861 : 0 : return true;
3862 : : }
3863 : 170727 : refs[ref->speculative_id] = ref;
3864 : : }
3865 : :
3866 : : int num_targets = 0;
3867 : 29034832 : for (unsigned int i = 0 ; i < num ; i++)
3868 : : {
3869 : 28921856 : if (refs[i] && !direct_calls[i])
3870 : : {
3871 : 0 : error ("missing direct call for speculation %i", i);
3872 : 0 : return true;
3873 : : }
3874 : 28921856 : if (!refs[i] && direct_calls[i])
3875 : : {
3876 : 0 : error ("missing ref for speculation %i", i);
3877 : 0 : return true;
3878 : : }
3879 : 28921856 : if (refs[i] != NULL)
3880 : 170727 : num_targets++;
3881 : : }
3882 : :
3883 : 112976 : if (num_targets != indirect->num_speculative_call_targets_p ())
3884 : : {
3885 : 0 : error ("number of speculative targets %i mismatched with "
3886 : : "num_speculative_call_targets %i",
3887 : : num_targets,
3888 : : indirect->num_speculative_call_targets_p ());
3889 : 0 : return true;
3890 : : }
3891 : : return false;
3892 : : }
3893 : :
3894 : : /* Verify cgraph nodes of given cgraph node. */
3895 : : DEBUG_FUNCTION void
3896 : 52799287 : cgraph_node::verify_node (void)
3897 : : {
3898 : 52799287 : cgraph_edge *e;
3899 : 52799287 : function *this_cfun = DECL_STRUCT_FUNCTION (decl);
3900 : 52799287 : basic_block this_block;
3901 : 52799287 : gimple_stmt_iterator gsi;
3902 : 52799287 : bool error_found = false;
3903 : 52799287 : int i;
3904 : 52799287 : ipa_ref *ref = NULL;
3905 : :
3906 : 52799287 : if (seen_error ())
3907 : 52799287 : return;
3908 : :
3909 : 52799287 : timevar_push (TV_CGRAPH_VERIFY);
3910 : 52799287 : error_found |= verify_base ();
3911 : 159351295 : for (e = callees; e; e = e->next_callee)
3912 : 106552008 : if (e->aux)
3913 : : {
3914 : 0 : error ("aux field set for edge %s->%s",
3915 : 0 : identifier_to_locale (e->caller->name ()),
3916 : 0 : identifier_to_locale (e->callee->name ()));
3917 : 0 : error_found = true;
3918 : : }
3919 : 52799287 : if (!count.verify ())
3920 : : {
3921 : 0 : error ("cgraph count invalid");
3922 : 0 : error_found = true;
3923 : : }
3924 : 52799287 : if (inlined_to && same_comdat_group)
3925 : : {
3926 : 0 : error ("inline clone in same comdat group list");
3927 : 0 : error_found = true;
3928 : : }
3929 : 52799287 : if (inlined_to && !count.compatible_p (inlined_to->count))
3930 : : {
3931 : 0 : error ("inline clone count is not compatible");
3932 : 0 : count.debug ();
3933 : 0 : inlined_to->count.debug ();
3934 : 0 : error_found = true;
3935 : : }
3936 : 52799287 : if (tp_first_run < 0)
3937 : : {
3938 : 0 : error ("tp_first_run must be non-negative");
3939 : 0 : error_found = true;
3940 : : }
3941 : 52799287 : if (!definition && !in_other_partition && local)
3942 : : {
3943 : 0 : error ("local symbols must be defined");
3944 : 0 : error_found = true;
3945 : : }
3946 : 52799287 : if (inlined_to && externally_visible)
3947 : : {
3948 : 0 : error ("externally visible inline clone");
3949 : 0 : error_found = true;
3950 : : }
3951 : 52799287 : if (inlined_to && address_taken)
3952 : : {
3953 : 0 : error ("inline clone with address taken");
3954 : 0 : error_found = true;
3955 : : }
3956 : 52799287 : if (inlined_to && force_output)
3957 : : {
3958 : 0 : error ("inline clone is forced to output");
3959 : 0 : error_found = true;
3960 : : }
3961 : 52799287 : if (symtab->state != LTO_STREAMING)
3962 : : {
3963 : 52689071 : if (calls_comdat_local && !same_comdat_group)
3964 : : {
3965 : 0 : error ("calls_comdat_local is set outside of a comdat group");
3966 : 0 : error_found = true;
3967 : : }
3968 : 52689071 : if (!inlined_to && calls_comdat_local != check_calls_comdat_local_p ())
3969 : : {
3970 : 0 : error ("invalid calls_comdat_local flag");
3971 : 0 : error_found = true;
3972 : : }
3973 : : }
3974 : 52799287 : if (DECL_IS_MALLOC (decl)
3975 : 52799287 : && !POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
3976 : : {
3977 : 0 : error ("malloc attribute should be used for a function that "
3978 : : "returns a pointer");
3979 : 0 : error_found = true;
3980 : : }
3981 : 52799287 : if (definition
3982 : 35789750 : && externally_visible
3983 : : /* For aliases in lto1 free_lang_data doesn't guarantee preservation
3984 : : of opt_for_fn (decl, flag_semantic_interposition). See PR105399. */
3985 : 19526873 : && (!alias || !in_lto_p)
3986 : 52799287 : && semantic_interposition
3987 : 19524016 : != opt_for_fn (decl, flag_semantic_interposition))
3988 : : {
3989 : 0 : error ("semantic interposition mismatch");
3990 : 0 : error_found = true;
3991 : : }
3992 : 55223843 : for (e = indirect_calls; e; e = e->next_callee)
3993 : : {
3994 : 2424556 : if (e->aux)
3995 : : {
3996 : 0 : error ("aux field set for indirect edge from %s",
3997 : 0 : identifier_to_locale (e->caller->name ()));
3998 : 0 : error_found = true;
3999 : : }
4000 : 2424556 : if (!e->count.compatible_p (count))
4001 : : {
4002 : 0 : error ("edge count is not compatible with function count");
4003 : 0 : e->count.debug ();
4004 : 0 : count.debug ();
4005 : 0 : error_found = true;
4006 : : }
4007 : 2424556 : if (inlined_to && !e->count.compatible_p (inlined_to->count))
4008 : : {
4009 : 0 : error ("edge count is not compatible with inlined to function count");
4010 : 0 : e->count.debug ();
4011 : 0 : count.debug ();
4012 : 0 : error_found = true;
4013 : : }
4014 : 2424556 : if (!e->indirect_unknown_callee
4015 : 2424556 : || !e->indirect_info)
4016 : : {
4017 : 0 : error ("An indirect edge from %s is not marked as indirect or has "
4018 : : "associated indirect_info, the corresponding statement is: ",
4019 : 0 : identifier_to_locale (e->caller->name ()));
4020 : 0 : cgraph_debug_gimple_stmt (this_cfun, e->call_stmt);
4021 : 0 : error_found = true;
4022 : : }
4023 : 2424556 : if (e->call_stmt && e->lto_stmt_uid)
4024 : : {
4025 : 0 : error ("edge has both call_stmt and lto_stmt_uid set");
4026 : 0 : error_found = true;
4027 : : }
4028 : : }
4029 : 52799287 : bool check_comdat = comdat_local_p ();
4030 : 143008346 : for (e = callers; e; e = e->next_caller)
4031 : : {
4032 : 90209059 : if (e->verify_count ())
4033 : 0 : error_found = true;
4034 : 90209059 : if (check_comdat
4035 : 90209059 : && !in_same_comdat_group_p (e->caller))
4036 : : {
4037 : 0 : error ("comdat-local function called by %s outside its comdat",
4038 : : identifier_to_locale (e->caller->name ()));
4039 : 0 : error_found = true;
4040 : : }
4041 : 90209059 : if (!e->inline_failed)
4042 : : {
4043 : 8437223 : if (inlined_to
4044 : 8437223 : != (e->caller->inlined_to
4045 : 8437223 : ? e->caller->inlined_to : e->caller))
4046 : : {
4047 : 0 : error ("inlined_to pointer is wrong");
4048 : 0 : error_found = true;
4049 : : }
4050 : 8437223 : if (callers->next_caller)
4051 : : {
4052 : 0 : error ("multiple inline callers");
4053 : 0 : error_found = true;
4054 : : }
4055 : : }
4056 : : else
4057 : 81771836 : if (inlined_to)
4058 : : {
4059 : 0 : error ("inlined_to pointer set for noninline callers");
4060 : 0 : error_found = true;
4061 : : }
4062 : : }
4063 : 159351295 : for (e = callees; e; e = e->next_callee)
4064 : : {
4065 : 106552008 : if (e->verify_count ())
4066 : 0 : error_found = true;
4067 : 106552008 : if (!e->count.compatible_p (count))
4068 : : {
4069 : 0 : error ("edge count is not compatible with function count");
4070 : 0 : e->count.debug ();
4071 : 0 : count.debug ();
4072 : 0 : error_found = true;
4073 : : }
4074 : 106552008 : if (gimple_has_body_p (e->caller->decl)
4075 : 100458735 : && !e->caller->inlined_to
4076 : 91744351 : && !e->speculative
4077 : 91682092 : && !e->callback
4078 : 91659510 : && !e->has_callback
4079 : : /* Optimized out calls are redirected to __builtin_unreachable. */
4080 : 91571474 : && (e->count.nonzero_p ()
4081 : 51289103 : || ! e->callee->decl
4082 : 51289103 : || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE,
4083 : : BUILT_IN_UNREACHABLE_TRAP))
4084 : : && count
4085 : 91056828 : == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count
4086 : 197600460 : && (!e->count.ipa_p ()
4087 : 42202900 : && e->count.differs_from_p (gimple_bb (e->call_stmt)->count)))
4088 : : {
4089 : 0 : error ("caller edge count does not match BB count");
4090 : 0 : fprintf (stderr, "edge count: ");
4091 : 0 : e->count.dump (stderr);
4092 : 0 : fprintf (stderr, "\n bb count: ");
4093 : 0 : gimple_bb (e->call_stmt)->count.dump (stderr);
4094 : 0 : fprintf (stderr, "\n");
4095 : 0 : error_found = true;
4096 : : }
4097 : 106552008 : if (e->call_stmt && e->lto_stmt_uid)
4098 : : {
4099 : 0 : error ("edge has both call_stmt and lto_stmt_uid set");
4100 : 0 : error_found = true;
4101 : : }
4102 : 106552008 : if (e->speculative
4103 : 106552008 : && verify_speculative_call (e->caller, e->call_stmt, e->lto_stmt_uid,
4104 : : NULL))
4105 : : error_found = true;
4106 : : }
4107 : 55223843 : for (e = indirect_calls; e; e = e->next_callee)
4108 : : {
4109 : 2424556 : if (e->verify_count ())
4110 : 0 : error_found = true;
4111 : 2424556 : if (gimple_has_body_p (e->caller->decl)
4112 : 2370185 : && !e->caller->inlined_to
4113 : 2104268 : && !e->speculative
4114 : 2066874 : && e->count.ipa_p ()
4115 : : && count
4116 : 761633 : == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count
4117 : 3186185 : && (!e->count.ipa_p ()
4118 : 0 : && e->count.differs_from_p (gimple_bb (e->call_stmt)->count)))
4119 : : {
4120 : 0 : error ("indirect call count does not match BB count");
4121 : 0 : fprintf (stderr, "edge count: ");
4122 : 0 : e->count.dump (stderr);
4123 : 0 : fprintf (stderr, "\n bb count: ");
4124 : 0 : gimple_bb (e->call_stmt)->count.dump (stderr);
4125 : 0 : fprintf (stderr, "\n");
4126 : 0 : error_found = true;
4127 : : }
4128 : 2424556 : if (e->speculative
4129 : 2424556 : && verify_speculative_call (e->caller, e->call_stmt, e->lto_stmt_uid,
4130 : : e))
4131 : : error_found = true;
4132 : : }
4133 : 118945401 : for (i = 0; iterate_reference (i, ref); i++)
4134 : : {
4135 : 66146114 : if (ref->stmt && ref->lto_stmt_uid)
4136 : : {
4137 : 0 : error ("reference has both stmt and lto_stmt_uid set");
4138 : 0 : error_found = true;
4139 : : }
4140 : 66146114 : if (ref->speculative
4141 : 66146114 : && verify_speculative_call (this, ref->stmt,
4142 : : ref->lto_stmt_uid, NULL))
4143 : : error_found = true;
4144 : : }
4145 : :
4146 : 52799287 : if (!callers && inlined_to)
4147 : : {
4148 : 0 : error ("inlined_to pointer is set but no predecessors found");
4149 : 0 : error_found = true;
4150 : : }
4151 : 52799287 : if (inlined_to == this)
4152 : : {
4153 : 0 : error ("inlined_to pointer refers to itself");
4154 : 0 : error_found = true;
4155 : : }
4156 : :
4157 : 52799287 : if (clone_of)
4158 : : {
4159 : 6089211 : cgraph_node *first_clone = clone_of->clones;
4160 : 6089211 : if (first_clone != this)
4161 : : {
4162 : 3069401 : if (prev_sibling_clone->clone_of != clone_of)
4163 : : {
4164 : 0 : error ("cgraph_node has wrong clone_of");
4165 : 0 : error_found = true;
4166 : : }
4167 : : }
4168 : : }
4169 : 52799287 : if (clones)
4170 : : {
4171 : : cgraph_node *n;
4172 : 8474156 : for (n = clones; n; n = n->next_sibling_clone)
4173 : 6804509 : if (n->clone_of != this)
4174 : : break;
4175 : 1669647 : if (n)
4176 : : {
4177 : 0 : error ("cgraph_node has wrong clone list");
4178 : 0 : error_found = true;
4179 : : }
4180 : : }
4181 : 52799287 : if ((prev_sibling_clone || next_sibling_clone) && !clone_of)
4182 : : {
4183 : 0 : error ("cgraph_node is in clone list but it is not clone");
4184 : 0 : error_found = true;
4185 : : }
4186 : 52799287 : if (!prev_sibling_clone && clone_of && clone_of->clones != this)
4187 : : {
4188 : 0 : error ("cgraph_node has wrong prev_clone pointer");
4189 : 0 : error_found = true;
4190 : : }
4191 : 52799287 : if (prev_sibling_clone && prev_sibling_clone->next_sibling_clone != this)
4192 : : {
4193 : 0 : error ("double linked list of clones corrupted");
4194 : 0 : error_found = true;
4195 : : }
4196 : :
4197 : 52799287 : if (analyzed && alias)
4198 : : {
4199 : 1472639 : bool ref_found = false;
4200 : 1472639 : int i;
4201 : 1472639 : ipa_ref *ref = NULL;
4202 : :
4203 : 1472639 : if (callees)
4204 : : {
4205 : 0 : error ("Alias has call edges");
4206 : 0 : error_found = true;
4207 : : }
4208 : 2945278 : for (i = 0; iterate_reference (i, ref); i++)
4209 : 1472639 : if (ref->use != IPA_REF_ALIAS)
4210 : : {
4211 : 0 : error ("Alias has non-alias reference");
4212 : 0 : error_found = true;
4213 : : }
4214 : 1472639 : else if (ref_found)
4215 : : {
4216 : 0 : error ("Alias has more than one alias reference");
4217 : 0 : error_found = true;
4218 : : }
4219 : : else
4220 : : ref_found = true;
4221 : 1472639 : if (!ref_found)
4222 : : {
4223 : 0 : error ("Analyzed alias has no reference");
4224 : 0 : error_found = true;
4225 : : }
4226 : : }
4227 : :
4228 : 52799287 : if (analyzed && thunk)
4229 : : {
4230 : 22180 : if (!callees)
4231 : : {
4232 : 0 : error ("No edge out of thunk node");
4233 : 0 : error_found = true;
4234 : : }
4235 : 22180 : else if (callees->next_callee)
4236 : : {
4237 : 0 : error ("More than one edge out of thunk node");
4238 : 0 : error_found = true;
4239 : : }
4240 : 22180 : if (gimple_has_body_p (decl) && !inlined_to)
4241 : : {
4242 : 0 : error ("Thunk is not supposed to have body");
4243 : 0 : error_found = true;
4244 : : }
4245 : : }
4246 : 35765609 : else if (analyzed && gimple_has_body_p (decl)
4247 : 30942812 : && !TREE_ASM_WRITTEN (decl)
4248 : 30942812 : && (!DECL_EXTERNAL (decl) || inlined_to)
4249 : 82907732 : && !flag_wpa)
4250 : : {
4251 : 30104278 : if ((this_cfun->curr_properties & PROP_assumptions_done) != 0)
4252 : : ;
4253 : 30104170 : else if (this_cfun->cfg)
4254 : : {
4255 : 30104170 : hash_set<gimple *> stmts;
4256 : :
4257 : : /* Reach the trees by walking over the CFG, and note the
4258 : : enclosing basic-blocks in the call edges. */
4259 : 249113160 : FOR_EACH_BB_FN (this_block, this_cfun)
4260 : : {
4261 : 219008990 : for (gsi = gsi_start_phis (this_block);
4262 : 264874793 : !gsi_end_p (gsi); gsi_next (&gsi))
4263 : 45865803 : stmts.add (gsi_stmt (gsi));
4264 : 438017980 : for (gsi = gsi_start_bb (this_block);
4265 : 1322620001 : !gsi_end_p (gsi);
4266 : 1103611011 : gsi_next (&gsi))
4267 : : {
4268 : 1103611011 : gimple *stmt = gsi_stmt (gsi);
4269 : 1103611011 : stmts.add (stmt);
4270 : 1103611011 : if (is_gimple_call (stmt))
4271 : : {
4272 : 106054664 : cgraph_edge *e = get_edge (stmt);
4273 : 106054664 : tree decl = gimple_call_fndecl (stmt);
4274 : 106054664 : if (e)
4275 : : {
4276 : 101095635 : if (e->aux)
4277 : : {
4278 : 0 : error ("shared call_stmt:");
4279 : 0 : cgraph_debug_gimple_stmt (this_cfun, stmt);
4280 : 0 : error_found = true;
4281 : : }
4282 : 101095635 : if (!e->indirect_unknown_callee)
4283 : : {
4284 : : /* Callback edges violate this assertion
4285 : : because their call statement doesn't exist,
4286 : : their associated statement belongs to the
4287 : : callback-dispatching function. */
4288 : 98849926 : if (!e->callback
4289 : 98849926 : && e->verify_corresponds_to_fndecl (decl))
4290 : : {
4291 : 0 : error ("edge points to wrong declaration:");
4292 : 0 : debug_tree (e->callee->decl);
4293 : 0 : fprintf (stderr," Instead of:");
4294 : 0 : debug_tree (decl);
4295 : 0 : error_found = true;
4296 : : }
4297 : : }
4298 : 2245709 : else if (decl)
4299 : : {
4300 : 0 : error ("an indirect edge with unknown callee "
4301 : : "corresponding to a call_stmt with "
4302 : : "a known declaration:");
4303 : 0 : error_found = true;
4304 : 0 : cgraph_debug_gimple_stmt (this_cfun, e->call_stmt);
4305 : : }
4306 : 101095635 : e->aux = (void *)1;
4307 : : }
4308 : 4959029 : else if (decl)
4309 : : {
4310 : 0 : error ("missing callgraph edge for call stmt:");
4311 : 0 : cgraph_debug_gimple_stmt (this_cfun, stmt);
4312 : 0 : error_found = true;
4313 : : }
4314 : : }
4315 : : }
4316 : : }
4317 : 100738061 : for (i = 0; iterate_reference (i, ref); i++)
4318 : 61534913 : if (ref->stmt && !stmts.contains (ref->stmt))
4319 : : {
4320 : 0 : error ("reference to dead statement");
4321 : 0 : cgraph_debug_gimple_stmt (this_cfun, ref->stmt);
4322 : 0 : error_found = true;
4323 : : }
4324 : 30104170 : }
4325 : : else
4326 : : /* No CFG available?! */
4327 : 0 : gcc_unreachable ();
4328 : :
4329 : 129028020 : for (e = callees; e; e = e->next_callee)
4330 : : {
4331 : 98923742 : if (!e->callback && e->callback_id)
4332 : : {
4333 : 0 : error ("non-callback edge has callback_id set");
4334 : 0 : error_found = true;
4335 : : }
4336 : :
4337 : 98923742 : if (e->callback && e->has_callback)
4338 : : {
4339 : 0 : error ("edge has both callback and has_callback set");
4340 : 0 : error_found = true;
4341 : : }
4342 : :
4343 : 98923742 : if (e->callback)
4344 : : {
4345 : 24071 : if (!e->get_callback_carrying_edge ())
4346 : : {
4347 : 0 : error ("callback edge %s->%s has no callback-carrying",
4348 : 0 : identifier_to_locale (e->caller->name ()),
4349 : 0 : identifier_to_locale (e->callee->name ()));
4350 : 0 : error_found = true;
4351 : : }
4352 : : }
4353 : :
4354 : 98923742 : if (e->has_callback
4355 : 98923742 : && !callback_is_special_cased (e->callee->decl, e->call_stmt))
4356 : : {
4357 : 84419 : int ncallbacks = 0;
4358 : 84419 : int nfound_edges = 0;
4359 : 84419 : for (tree cb = lookup_attribute (CALLBACK_ATTR_IDENT, DECL_ATTRIBUTES (
4360 : : e->callee->decl));
4361 : 168838 : cb; cb = lookup_attribute (CALLBACK_ATTR_IDENT, TREE_CHAIN (cb)),
4362 : : ncallbacks++)
4363 : : ;
4364 : 775186 : for (cgraph_edge *cbe = callees; cbe; cbe = cbe->next_callee)
4365 : : {
4366 : 690767 : if (cbe->callback && cbe->call_stmt == e->call_stmt
4367 : 20713 : && cbe->lto_stmt_uid == e->lto_stmt_uid)
4368 : : {
4369 : 20713 : nfound_edges++;
4370 : : }
4371 : : }
4372 : 84419 : if (ncallbacks < nfound_edges)
4373 : : {
4374 : 0 : error ("callback edge %s->%s callback edge count mismatch, "
4375 : : "expected at most %d, found %d",
4376 : 0 : identifier_to_locale (e->caller->name ()),
4377 : 0 : identifier_to_locale (e->callee->name ()), ncallbacks,
4378 : : nfound_edges);
4379 : : }
4380 : : }
4381 : :
4382 : 98923742 : if (!e->aux && !e->speculative && !e->callback && !e->has_callback)
4383 : : {
4384 : 0 : error ("edge %s->%s has no corresponding call_stmt",
4385 : 0 : identifier_to_locale (e->caller->name ()),
4386 : 0 : identifier_to_locale (e->callee->name ()));
4387 : 0 : cgraph_debug_gimple_stmt (this_cfun, e->call_stmt);
4388 : 0 : error_found = true;
4389 : : }
4390 : 98923742 : e->aux = 0;
4391 : : }
4392 : 32449527 : for (e = indirect_calls; e; e = e->next_callee)
4393 : : {
4394 : 2345249 : if (!e->aux && !e->speculative)
4395 : : {
4396 : 0 : error ("an indirect edge from %s has no corresponding call_stmt",
4397 : 0 : identifier_to_locale (e->caller->name ()));
4398 : 0 : cgraph_debug_gimple_stmt (this_cfun, e->call_stmt);
4399 : 0 : error_found = true;
4400 : : }
4401 : 2345249 : e->aux = 0;
4402 : : }
4403 : : }
4404 : :
4405 : 52799287 : if (nested_function_info *info = nested_function_info::get (this))
4406 : : {
4407 : 0 : if (info->nested != NULL)
4408 : : {
4409 : 0 : for (cgraph_node *n = info->nested; n != NULL;
4410 : 0 : n = next_nested_function (n))
4411 : : {
4412 : 0 : nested_function_info *ninfo = nested_function_info::get (n);
4413 : 0 : if (ninfo->origin == NULL)
4414 : : {
4415 : 0 : error ("missing origin for a node in a nested list");
4416 : 0 : error_found = true;
4417 : : }
4418 : 0 : else if (ninfo->origin != this)
4419 : : {
4420 : 0 : error ("origin points to a different parent");
4421 : 0 : error_found = true;
4422 : 0 : break;
4423 : : }
4424 : : }
4425 : : }
4426 : 0 : if (info->next_nested != NULL && info->origin == NULL)
4427 : : {
4428 : 0 : error ("missing origin for a node in a nested list");
4429 : 0 : error_found = true;
4430 : : }
4431 : : }
4432 : :
4433 : 52799287 : if (error_found)
4434 : : {
4435 : 0 : dump (stderr);
4436 : 0 : internal_error ("verify_cgraph_node failed");
4437 : : }
4438 : 52799287 : timevar_pop (TV_CGRAPH_VERIFY);
4439 : : }
4440 : :
4441 : : /* Verify whole cgraph structure. */
4442 : : DEBUG_FUNCTION void
4443 : 872 : cgraph_node::verify_cgraph_nodes (void)
4444 : : {
4445 : 872 : cgraph_node *node;
4446 : :
4447 : 872 : if (seen_error ())
4448 : : return;
4449 : :
4450 : 5240 : FOR_EACH_FUNCTION (node)
4451 : 4392 : node->verify ();
4452 : : }
4453 : :
4454 : : #if __GNUC__ >= 10
4455 : : # pragma GCC diagnostic pop
4456 : : #endif
4457 : :
4458 : : /* Walk the alias chain to return the function cgraph_node is alias of.
4459 : : Walk through thunks, too.
4460 : : When AVAILABILITY is non-NULL, get minimal availability in the chain.
4461 : : When REF is non-NULL, assume that reference happens in symbol REF
4462 : : when determining the availability. */
4463 : :
4464 : : cgraph_node *
4465 : 132717584 : cgraph_node::function_symbol (enum availability *availability,
4466 : : struct symtab_node *ref)
4467 : : {
4468 : 132717584 : cgraph_node *node = ultimate_alias_target (availability, ref);
4469 : :
4470 : 265440205 : while (node->thunk)
4471 : : {
4472 : 5037 : enum availability a;
4473 : :
4474 : 5037 : ref = node;
4475 : 5037 : node = node->callees->callee;
4476 : 8984 : node = node->ultimate_alias_target (availability ? &a : NULL, ref);
4477 : 5037 : if (availability && a < *availability)
4478 : 38 : *availability = a;
4479 : : }
4480 : 132717584 : return node;
4481 : : }
4482 : :
4483 : : /* Walk the alias chain to return the function cgraph_node is alias of.
4484 : : Walk through non virtual thunks, too. Thus we return either a function
4485 : : or a virtual thunk node.
4486 : : When AVAILABILITY is non-NULL, get minimal availability in the chain.
4487 : : When REF is non-NULL, assume that reference happens in symbol REF
4488 : : when determining the availability. */
4489 : :
4490 : : cgraph_node *
4491 : 33497361 : cgraph_node::function_or_virtual_thunk_symbol
4492 : : (enum availability *availability,
4493 : : struct symtab_node *ref)
4494 : : {
4495 : 33497361 : cgraph_node *node = ultimate_alias_target (availability, ref);
4496 : :
4497 : 66995778 : while (node->thunk && !thunk_info::get (node)->virtual_offset_p)
4498 : : {
4499 : 1056 : enum availability a;
4500 : :
4501 : 1056 : ref = node;
4502 : 1056 : node = node->callees->callee;
4503 : 1056 : node = node->ultimate_alias_target (availability ? &a : NULL, ref);
4504 : 1056 : if (availability && a < *availability)
4505 : 320 : *availability = a;
4506 : : }
4507 : 33497361 : return node;
4508 : : }
4509 : :
4510 : : /* When doing LTO, read cgraph_node's body from disk if it is not already
4511 : : present. Also perform any necessary clone materializations. */
4512 : :
4513 : : bool
4514 : 6345409 : cgraph_node::get_untransformed_body ()
4515 : : {
4516 : 6345409 : lto_file_decl_data *file_data;
4517 : 6345409 : const char *data, *name;
4518 : 6345409 : size_t len;
4519 : 6345409 : tree decl = this->decl;
4520 : :
4521 : : /* See if there is clone to be materialized.
4522 : : (inline clones does not need materialization, but we can be seeing
4523 : : an inline clone of real clone). */
4524 : 6345409 : cgraph_node *p = this;
4525 : 9122355 : for (cgraph_node *c = clone_of; c; c = c->clone_of)
4526 : : {
4527 : 2776946 : if (c->decl != decl)
4528 : 129917 : p->materialize_clone ();
4529 : 2776946 : p = c;
4530 : : }
4531 : :
4532 : : /* Check if body is already there. Either we have gimple body or
4533 : : the function is thunk and in that case we set DECL_ARGUMENTS. */
4534 : 6345409 : if (DECL_ARGUMENTS (decl) || gimple_has_body_p (decl))
4535 : 6261292 : return false;
4536 : :
4537 : 168234 : gcc_assert (in_lto_p && !DECL_RESULT (decl));
4538 : :
4539 : 84117 : timevar_push (TV_IPA_LTO_GIMPLE_IN);
4540 : :
4541 : 84117 : file_data = lto_file_data;
4542 : 84117 : name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
4543 : :
4544 : : /* We may have renamed the declaration, e.g., a static function. */
4545 : 84117 : name = lto_get_decl_name_mapping (file_data, name);
4546 : 84117 : struct lto_in_decl_state *decl_state
4547 : 84117 : = lto_get_function_in_decl_state (file_data, decl);
4548 : :
4549 : 84117 : cgraph_node *origin = this;
4550 : 168406 : while (origin->clone_of)
4551 : : origin = origin->clone_of;
4552 : :
4553 : 84117 : int stream_order = origin->order - file_data->order_base;
4554 : 168234 : data = lto_get_section_data (file_data, LTO_section_function_body,
4555 : : name, stream_order, &len,
4556 : 84117 : decl_state->compressed);
4557 : 84117 : if (!data)
4558 : 0 : fatal_error (input_location, "%s: section %s.%d is missing",
4559 : : file_data->file_name, name, stream_order);
4560 : :
4561 : 84117 : gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL);
4562 : :
4563 : 84117 : if (!quiet_flag)
4564 : 0 : fprintf (stderr, " in:%s", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4565 : 84117 : lto_input_function_body (file_data, this, data);
4566 : 84117 : lto_stats.num_function_bodies++;
4567 : 84117 : lto_free_section_data (file_data, LTO_section_function_body, name,
4568 : 84117 : data, len, decl_state->compressed);
4569 : 84117 : lto_free_function_in_decl_state_for_node (this);
4570 : : /* Keep lto file data so ipa-inline-analysis knows about cross module
4571 : : inlining. */
4572 : :
4573 : 84117 : timevar_pop (TV_IPA_LTO_GIMPLE_IN);
4574 : :
4575 : 84117 : return true;
4576 : : }
4577 : :
4578 : : /* Prepare function body. When doing LTO, read cgraph_node's body from disk
4579 : : if it is not already present. When some IPA transformations are scheduled,
4580 : : apply them. */
4581 : :
4582 : : bool
4583 : 28865 : cgraph_node::get_body (void)
4584 : : {
4585 : 28865 : bool updated;
4586 : :
4587 : 28865 : updated = get_untransformed_body ();
4588 : :
4589 : : /* Getting transformed body makes no sense for inline clones;
4590 : : we should never use this on real clones because they are materialized
4591 : : early.
4592 : : TODO: Materializing clones here will likely lead to smaller LTRANS
4593 : : footprint. */
4594 : 28865 : gcc_assert (!inlined_to && !clone_of);
4595 : 28865 : if (ipa_transforms_to_apply.exists ())
4596 : : {
4597 : 12380 : opt_pass *saved_current_pass = current_pass;
4598 : 12380 : FILE *saved_dump_file = dump_file;
4599 : 12380 : const char *saved_dump_file_name = dump_file_name;
4600 : 12380 : dump_flags_t saved_dump_flags = dump_flags;
4601 : 12380 : dump_file_name = NULL;
4602 : 12380 : set_dump_file (NULL);
4603 : :
4604 : 12380 : push_cfun (DECL_STRUCT_FUNCTION (decl));
4605 : :
4606 : 12380 : update_ssa (TODO_update_ssa_only_virtuals);
4607 : 12380 : execute_all_ipa_transforms (true);
4608 : 12380 : cgraph_edge::rebuild_edges ();
4609 : 12380 : free_dominance_info (CDI_DOMINATORS);
4610 : 12380 : free_dominance_info (CDI_POST_DOMINATORS);
4611 : 12380 : pop_cfun ();
4612 : 12380 : updated = true;
4613 : :
4614 : 12380 : current_pass = saved_current_pass;
4615 : 12380 : set_dump_file (saved_dump_file);
4616 : 12380 : dump_file_name = saved_dump_file_name;
4617 : 12380 : dump_flags = saved_dump_flags;
4618 : : }
4619 : 28865 : return updated;
4620 : : }
4621 : :
4622 : : /* Return the DECL_STRUCT_FUNCTION of the function. */
4623 : :
4624 : : struct function *
4625 : 103839 : cgraph_node::get_fun () const
4626 : : {
4627 : 103839 : const cgraph_node *node = this;
4628 : 103839 : struct function *fun = DECL_STRUCT_FUNCTION (node->decl);
4629 : :
4630 : 103839 : while (!fun && node->clone_of)
4631 : : {
4632 : 0 : node = node->clone_of;
4633 : 0 : fun = DECL_STRUCT_FUNCTION (node->decl);
4634 : : }
4635 : :
4636 : 103839 : return fun;
4637 : : }
4638 : :
4639 : : /* Reset all state within cgraph.cc so that we can rerun the compiler
4640 : : within the same process. For use by toplev::finalize. */
4641 : :
4642 : : void
4643 : 261196 : cgraph_cc_finalize (void)
4644 : : {
4645 : 261196 : nested_function_info::release ();
4646 : 261196 : thunk_info::release ();
4647 : 261196 : clone_info::release ();
4648 : 261196 : symtab = NULL;
4649 : :
4650 : 261196 : x_cgraph_nodes_queue = NULL;
4651 : :
4652 : 261196 : cgraph_fnver_htab = NULL;
4653 : 261196 : version_info_node = NULL;
4654 : 261196 : }
4655 : :
4656 : : /* A worker for call_for_symbol_and_aliases. */
4657 : :
4658 : : bool
4659 : 756419 : cgraph_node::call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *,
4660 : : void *),
4661 : : void *data,
4662 : : bool include_overwritable)
4663 : : {
4664 : 756419 : ipa_ref *ref;
4665 : 1487090 : FOR_EACH_ALIAS (this, ref)
4666 : : {
4667 : 838709 : cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
4668 : 838709 : if (include_overwritable
4669 : 838709 : || alias->get_availability () > AVAIL_INTERPOSABLE)
4670 : 838709 : if (alias->call_for_symbol_and_aliases (callback, data,
4671 : : include_overwritable))
4672 : : return true;
4673 : : }
4674 : : return false;
4675 : : }
4676 : :
4677 : : /* Return true if NODE has thunk. */
4678 : :
4679 : : bool
4680 : 39111 : cgraph_node::has_thunk_p (cgraph_node *node, void *)
4681 : : {
4682 : 73578 : for (cgraph_edge *e = node->callers; e; e = e->next_caller)
4683 : 34467 : if (e->caller->thunk)
4684 : : return true;
4685 : : return false;
4686 : : }
4687 : :
4688 : : /* Expected frequency of executions within the function. */
4689 : :
4690 : : sreal
4691 : 205791294 : cgraph_edge::sreal_frequency ()
4692 : : {
4693 : 205791294 : return count.to_sreal_scale (caller->inlined_to
4694 : 205791294 : ? caller->inlined_to->count
4695 : 205791294 : : caller->count);
4696 : : }
4697 : :
4698 : : /* Expected frequency of executions within the function.
4699 : : If edge is speculative, sum all its indirect targets. */
4700 : :
4701 : : sreal
4702 : 934 : cgraph_edge::combined_sreal_frequency ()
4703 : : {
4704 : 934 : if (!speculative)
4705 : 867 : return sreal_frequency ();
4706 : 67 : cgraph_edge *e = this;
4707 : 67 : if (e->callee)
4708 : 0 : e = e->speculative_call_indirect_edge ();
4709 : 67 : sreal sum = e->sreal_frequency ();
4710 : 67 : for (e = e->first_speculative_call_target ();
4711 : 141 : e;
4712 : 74 : e = e->next_speculative_call_target ())
4713 : 74 : sum += e->sreal_frequency ();
4714 : 67 : return sum;
4715 : : }
4716 : :
4717 : :
4718 : : /* During LTO stream in this can be used to check whether call can possibly
4719 : : be internal to the current translation unit. */
4720 : :
4721 : : bool
4722 : 478240 : cgraph_edge::possibly_call_in_translation_unit_p (void)
4723 : : {
4724 : 478240 : gcc_checking_assert (in_lto_p && caller->prevailing_p ());
4725 : :
4726 : : /* While incremental linking we may end up getting function body later. */
4727 : 478240 : if (flag_incremental_link == INCREMENTAL_LINK_LTO)
4728 : : return true;
4729 : :
4730 : : /* We may be smarter here and avoid streaming in indirect calls we can't
4731 : : track, but that would require arranging streaming the indirect call
4732 : : summary first. */
4733 : 478011 : if (!callee)
4734 : : return true;
4735 : :
4736 : : /* If callee is local to the original translation unit, it will be
4737 : : defined. */
4738 : 475295 : if (!TREE_PUBLIC (callee->decl) && !DECL_EXTERNAL (callee->decl))
4739 : : return true;
4740 : :
4741 : : /* Otherwise we need to lookup prevailing symbol (symbol table is not merged,
4742 : : yet) and see if it is a definition. In fact we may also resolve aliases,
4743 : : but that is probably not too important. */
4744 : 479337 : symtab_node *node = callee;
4745 : 479337 : for (int n = 10; node->previous_sharing_asm_name && n ; n--)
4746 : 10101 : node = node->previous_sharing_asm_name;
4747 : 469236 : if (node->previous_sharing_asm_name)
4748 : 234 : node = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (callee->decl));
4749 : 469236 : gcc_assert (TREE_PUBLIC (node->decl) || DECL_EXTERNAL (node->decl));
4750 : 469236 : return node->get_availability () >= AVAIL_INTERPOSABLE;
4751 : : }
4752 : :
4753 : : /* Return num_speculative_targets of this edge. */
4754 : :
4755 : : int
4756 : 184098 : cgraph_edge::num_speculative_call_targets_p (void)
4757 : : {
4758 : 184098 : return indirect_info ? indirect_info->num_speculative_call_targets : 0;
4759 : : }
4760 : :
4761 : : /* Check if function calls comdat local. This is used to recompute
4762 : : calls_comdat_local flag after function transformations. */
4763 : : bool
4764 : 49524902 : cgraph_node::check_calls_comdat_local_p ()
4765 : : {
4766 : 159019858 : for (cgraph_edge *e = callees; e; e = e->next_callee)
4767 : 3794794 : if (e->inline_failed
4768 : 118447777 : ? e->callee->comdat_local_p ()
4769 : 3794794 : : e->callee->check_calls_comdat_local_p ())
4770 : 51613 : return true;
4771 : : return false;
4772 : : }
4773 : :
4774 : : /* Return true if this node represents a former, i.e. an expanded, thunk. */
4775 : :
4776 : : bool
4777 : 5052085 : cgraph_node::former_thunk_p (void)
4778 : : {
4779 : 5052085 : if (thunk)
4780 : : return false;
4781 : 5052085 : thunk_info *i = thunk_info::get (this);
4782 : 5052085 : if (!i)
4783 : : return false;
4784 : 67 : gcc_checking_assert (i->fixed_offset || i->virtual_offset_p
4785 : : || i->indirect_offset);
4786 : : return true;
4787 : : }
4788 : :
4789 : : /* A stashed copy of "symtab" for use by selftest::symbol_table_test.
4790 : : This needs to be a global so that it can be a GC root, and thus
4791 : : prevent the stashed copy from being garbage-collected if the GC runs
4792 : : during a symbol_table_test. */
4793 : :
4794 : : symbol_table *saved_symtab;
4795 : :
4796 : : #if CHECKING_P
4797 : :
4798 : : namespace selftest {
4799 : :
4800 : : /* class selftest::symbol_table_test. */
4801 : :
4802 : : /* Constructor. Store the old value of symtab, and create a new one. */
4803 : :
4804 : 64 : symbol_table_test::symbol_table_test ()
4805 : : {
4806 : 64 : gcc_assert (saved_symtab == NULL);
4807 : 64 : saved_symtab = symtab;
4808 : 64 : symtab = new (ggc_alloc<symbol_table> ()) symbol_table ();
4809 : 64 : }
4810 : :
4811 : : /* Destructor. Restore the old value of symtab. */
4812 : :
4813 : 64 : symbol_table_test::~symbol_table_test ()
4814 : : {
4815 : 64 : gcc_assert (saved_symtab != NULL);
4816 : 64 : symtab = saved_symtab;
4817 : 64 : saved_symtab = NULL;
4818 : 64 : }
4819 : :
4820 : : /* Verify that symbol_table_test works. */
4821 : :
4822 : : static void
4823 : 4 : test_symbol_table_test ()
4824 : : {
4825 : : /* Simulate running two selftests involving symbol tables. */
4826 : 12 : for (int i = 0; i < 2; i++)
4827 : : {
4828 : 8 : symbol_table_test stt;
4829 : 8 : tree test_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
4830 : : get_identifier ("test_decl"),
4831 : : build_function_type_list (void_type_node,
4832 : : NULL_TREE));
4833 : 8 : cgraph_node *node = cgraph_node::get_create (test_decl);
4834 : 8 : gcc_assert (node);
4835 : :
4836 : : /* Verify that the node has order 0 on both iterations,
4837 : : and thus that nodes have predictable dump names in selftests. */
4838 : 8 : ASSERT_EQ (node->order, 0);
4839 : 8 : ASSERT_STREQ (node->dump_name (), "test_decl/1");
4840 : 8 : }
4841 : 4 : }
4842 : :
4843 : : /* Run all of the selftests within this file. */
4844 : :
4845 : : void
4846 : 4 : cgraph_cc_tests ()
4847 : : {
4848 : 4 : test_symbol_table_test ();
4849 : 4 : }
4850 : :
4851 : : } // namespace selftest
4852 : :
4853 : : #endif /* CHECKING_P */
4854 : :
4855 : : #include "gt-cgraph.h"
|