PR rtl-optimization/82913
[official-gcc.git] / gcc / ipa-inline-transform.c
blobb2363e230439b551a87a68fd52059d5a7d48e20f
1 /* Callgraph transformations to handle inlining
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
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.
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.
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/>. */
21 /* The inline decisions are stored in callgraph in "inline plan" and
22 applied later.
24 To mark given call inline, use inline_call function.
25 The function marks the edge inlinable and, if necessary, produces
26 virtual clone in the callgraph representing the new copy of callee's
27 function body.
29 The inline plan is applied on given function body by inline_transform. */
31 #include "config.h"
32 #include "system.h"
33 #include "coretypes.h"
34 #include "tm.h"
35 #include "function.h"
36 #include "tree.h"
37 #include "alloc-pool.h"
38 #include "tree-pass.h"
39 #include "cgraph.h"
40 #include "tree-cfg.h"
41 #include "symbol-summary.h"
42 #include "tree-vrp.h"
43 #include "ipa-prop.h"
44 #include "ipa-fnsummary.h"
45 #include "ipa-inline.h"
46 #include "tree-inline.h"
47 #include "function.h"
48 #include "cfg.h"
49 #include "basic-block.h"
51 int ncalls_inlined;
52 int nfunctions_inlined;
54 /* Scale frequency of NODE edges by FREQ_SCALE. */
56 static void
57 update_noncloned_frequencies (struct cgraph_node *node,
58 int freq_scale, profile_count num,
59 profile_count den)
61 struct cgraph_edge *e;
63 profile_count::adjust_for_ipa_scaling (&num, &den);
65 /* We do not want to ignore high loop nest after freq drops to 0. */
66 if (!freq_scale)
67 freq_scale = 1;
68 for (e = node->callees; e; e = e->next_callee)
70 e->frequency = e->frequency * (gcov_type) freq_scale / CGRAPH_FREQ_BASE;
71 if (e->frequency > CGRAPH_FREQ_MAX)
72 e->frequency = CGRAPH_FREQ_MAX;
73 if (!e->inline_failed)
74 update_noncloned_frequencies (e->callee, freq_scale, num, den);
75 e->count = e->count.apply_scale (num, den);
77 for (e = node->indirect_calls; e; e = e->next_callee)
79 e->frequency = e->frequency * (gcov_type) freq_scale / CGRAPH_FREQ_BASE;
80 if (e->frequency > CGRAPH_FREQ_MAX)
81 e->frequency = CGRAPH_FREQ_MAX;
82 e->count = e->count.apply_scale (num, den);
84 node->count = node->count.apply_scale (num, den);
87 /* We removed or are going to remove the last call to NODE.
88 Return true if we can and want proactively remove the NODE now.
89 This is important to do, since we want inliner to know when offline
90 copy of function was removed. */
92 static bool
93 can_remove_node_now_p_1 (struct cgraph_node *node, struct cgraph_edge *e)
95 ipa_ref *ref;
97 FOR_EACH_ALIAS (node, ref)
99 cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring);
100 if ((alias->callers && alias->callers != e)
101 || !can_remove_node_now_p_1 (alias, e))
102 return false;
104 /* FIXME: When address is taken of DECL_EXTERNAL function we still
105 can remove its offline copy, but we would need to keep unanalyzed node in
106 the callgraph so references can point to it.
108 Also for comdat group we can ignore references inside a group as we
109 want to prove the group as a whole to be dead. */
110 return (!node->address_taken
111 && node->can_remove_if_no_direct_calls_and_refs_p ()
112 /* Inlining might enable more devirtualizing, so we want to remove
113 those only after all devirtualizable virtual calls are processed.
114 Lacking may edges in callgraph we just preserve them post
115 inlining. */
116 && (!DECL_VIRTUAL_P (node->decl)
117 || !opt_for_fn (node->decl, flag_devirtualize))
118 /* During early inlining some unanalyzed cgraph nodes might be in the
119 callgraph and they might reffer the function in question. */
120 && !cgraph_new_nodes.exists ());
123 /* We are going to eliminate last direct call to NODE (or alias of it) via edge E.
124 Verify that the NODE can be removed from unit and if it is contained in comdat
125 group that the whole comdat group is removable. */
127 static bool
128 can_remove_node_now_p (struct cgraph_node *node, struct cgraph_edge *e)
130 struct cgraph_node *next;
131 if (!can_remove_node_now_p_1 (node, e))
132 return false;
134 /* When we see same comdat group, we need to be sure that all
135 items can be removed. */
136 if (!node->same_comdat_group || !node->externally_visible)
137 return true;
138 for (next = dyn_cast<cgraph_node *> (node->same_comdat_group);
139 next != node; next = dyn_cast<cgraph_node *> (next->same_comdat_group))
141 if (next->alias)
142 continue;
143 if ((next->callers && next->callers != e)
144 || !can_remove_node_now_p_1 (next, e))
145 return false;
147 return true;
150 /* Return true if NODE is a master clone with non-inline clones. */
152 static bool
153 master_clone_with_noninline_clones_p (struct cgraph_node *node)
155 if (node->clone_of)
156 return false;
158 for (struct cgraph_node *n = node->clones; n; n = n->next_sibling_clone)
159 if (n->decl != node->decl)
160 return true;
162 return false;
165 /* E is expected to be an edge being inlined. Clone destination node of
166 the edge and redirect it to the new clone.
167 DUPLICATE is used for bookkeeping on whether we are actually creating new
168 clones or re-using node originally representing out-of-line function call.
169 By default the offline copy is removed, when it appears dead after inlining.
170 UPDATE_ORIGINAL prevents this transformation.
171 If OVERALL_SIZE is non-NULL, the size is updated to reflect the
172 transformation.
173 FREQ_SCALE specify the scaling of frequencies of call sites. */
175 void
176 clone_inlined_nodes (struct cgraph_edge *e, bool duplicate,
177 bool update_original, int *overall_size, int freq_scale)
179 struct cgraph_node *inlining_into;
180 struct cgraph_edge *next;
182 if (e->caller->global.inlined_to)
183 inlining_into = e->caller->global.inlined_to;
184 else
185 inlining_into = e->caller;
187 if (duplicate)
189 /* We may eliminate the need for out-of-line copy to be output.
190 In that case just go ahead and re-use it. This is not just an
191 memory optimization. Making offline copy of fuction disappear
192 from the program will improve future decisions on inlining. */
193 if (!e->callee->callers->next_caller
194 /* Recursive inlining never wants the master clone to
195 be overwritten. */
196 && update_original
197 && can_remove_node_now_p (e->callee, e)
198 /* We cannot overwrite a master clone with non-inline clones
199 until after these clones are materialized. */
200 && !master_clone_with_noninline_clones_p (e->callee))
202 /* TODO: When callee is in a comdat group, we could remove all of it,
203 including all inline clones inlined into it. That would however
204 need small function inlining to register edge removal hook to
205 maintain the priority queue.
207 For now we keep the ohter functions in the group in program until
208 cgraph_remove_unreachable_functions gets rid of them. */
209 gcc_assert (!e->callee->global.inlined_to);
210 e->callee->remove_from_same_comdat_group ();
211 if (e->callee->definition
212 && inline_account_function_p (e->callee))
214 gcc_assert (!e->callee->alias);
215 if (overall_size)
216 *overall_size -= ipa_fn_summaries->get (e->callee)->size;
217 nfunctions_inlined++;
219 duplicate = false;
220 e->callee->externally_visible = false;
221 update_noncloned_frequencies (e->callee, e->frequency,
222 e->count, e->callee->count);
224 dump_callgraph_transformation (e->callee, inlining_into,
225 "inlining to");
227 else
229 struct cgraph_node *n;
231 if (freq_scale == -1)
232 freq_scale = e->frequency;
233 n = e->callee->create_clone (e->callee->decl,
234 MIN (e->count, e->callee->count),
235 freq_scale,
236 update_original, vNULL, true,
237 inlining_into,
238 NULL);
239 n->used_as_abstract_origin = e->callee->used_as_abstract_origin;
240 e->redirect_callee (n);
243 else
244 e->callee->remove_from_same_comdat_group ();
246 e->callee->global.inlined_to = inlining_into;
248 /* Recursively clone all bodies. */
249 for (e = e->callee->callees; e; e = next)
251 next = e->next_callee;
252 if (!e->inline_failed)
253 clone_inlined_nodes (e, duplicate, update_original, overall_size, freq_scale);
257 /* Check all speculations in N and resolve them if they seems useless. */
259 static bool
260 check_speculations (cgraph_node *n)
262 bool speculation_removed = false;
263 cgraph_edge *next;
265 for (cgraph_edge *e = n->callees; e; e = next)
267 next = e->next_callee;
268 if (e->speculative && !speculation_useful_p (e, true))
270 e->resolve_speculation (NULL);
271 speculation_removed = true;
273 else if (!e->inline_failed)
274 speculation_removed |= check_speculations (e->callee);
276 return speculation_removed;
279 /* Mark all call graph edges coming out of NODE and all nodes that have been
280 inlined to it as in_polymorphic_cdtor. */
282 static void
283 mark_all_inlined_calls_cdtor (cgraph_node *node)
285 for (cgraph_edge *cs = node->callees; cs; cs = cs->next_callee)
287 cs->in_polymorphic_cdtor = true;
288 if (!cs->inline_failed)
289 mark_all_inlined_calls_cdtor (cs->callee);
291 for (cgraph_edge *cs = node->indirect_calls; cs; cs = cs->next_callee)
292 cs->in_polymorphic_cdtor = true;
296 /* Mark edge E as inlined and update callgraph accordingly. UPDATE_ORIGINAL
297 specify whether profile of original function should be updated. If any new
298 indirect edges are discovered in the process, add them to NEW_EDGES, unless
299 it is NULL. If UPDATE_OVERALL_SUMMARY is false, do not bother to recompute overall
300 size of caller after inlining. Caller is required to eventually do it via
301 ipa_update_overall_fn_summary.
302 If callee_removed is non-NULL, set it to true if we removed callee node.
304 Return true iff any new callgraph edges were discovered as a
305 result of inlining. */
307 bool
308 inline_call (struct cgraph_edge *e, bool update_original,
309 vec<cgraph_edge *> *new_edges,
310 int *overall_size, bool update_overall_summary,
311 bool *callee_removed)
313 int old_size = 0, new_size = 0;
314 struct cgraph_node *to = NULL;
315 struct cgraph_edge *curr = e;
316 struct cgraph_node *callee = e->callee->ultimate_alias_target ();
317 bool new_edges_found = false;
319 int estimated_growth = 0;
320 if (! update_overall_summary)
321 estimated_growth = estimate_edge_growth (e);
322 /* This is used only for assert bellow. */
323 #if 0
324 bool predicated = inline_edge_summary (e)->predicate != NULL;
325 #endif
327 /* Don't inline inlined edges. */
328 gcc_assert (e->inline_failed);
329 /* Don't even think of inlining inline clone. */
330 gcc_assert (!callee->global.inlined_to);
332 to = e->caller;
333 if (to->global.inlined_to)
334 to = to->global.inlined_to;
335 if (to->thunk.thunk_p)
337 struct cgraph_node *target = to->callees->callee;
338 if (in_lto_p)
339 to->get_untransformed_body ();
340 to->expand_thunk (false, true);
341 /* When thunk is instrumented we may have multiple callees. */
342 for (e = to->callees; e && e->callee != target; e = e->next_callee)
344 gcc_assert (e);
348 e->inline_failed = CIF_OK;
349 DECL_POSSIBLY_INLINED (callee->decl) = true;
351 if (DECL_FUNCTION_PERSONALITY (callee->decl))
352 DECL_FUNCTION_PERSONALITY (to->decl)
353 = DECL_FUNCTION_PERSONALITY (callee->decl);
355 bool reload_optimization_node = false;
356 if (!opt_for_fn (callee->decl, flag_strict_aliasing)
357 && opt_for_fn (to->decl, flag_strict_aliasing))
359 struct gcc_options opts = global_options;
361 cl_optimization_restore (&opts, opts_for_fn (to->decl));
362 opts.x_flag_strict_aliasing = false;
363 if (dump_file)
364 fprintf (dump_file, "Dropping flag_strict_aliasing on %s\n",
365 to->dump_name ());
366 DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
367 = build_optimization_node (&opts);
368 reload_optimization_node = true;
371 ipa_fn_summary *caller_info = ipa_fn_summaries->get (to);
372 ipa_fn_summary *callee_info = ipa_fn_summaries->get (callee);
373 if (!caller_info->fp_expressions && callee_info->fp_expressions)
375 caller_info->fp_expressions = true;
376 if (opt_for_fn (callee->decl, flag_rounding_math)
377 != opt_for_fn (to->decl, flag_rounding_math)
378 || opt_for_fn (callee->decl, flag_trapping_math)
379 != opt_for_fn (to->decl, flag_trapping_math)
380 || opt_for_fn (callee->decl, flag_unsafe_math_optimizations)
381 != opt_for_fn (to->decl, flag_unsafe_math_optimizations)
382 || opt_for_fn (callee->decl, flag_finite_math_only)
383 != opt_for_fn (to->decl, flag_finite_math_only)
384 || opt_for_fn (callee->decl, flag_signaling_nans)
385 != opt_for_fn (to->decl, flag_signaling_nans)
386 || opt_for_fn (callee->decl, flag_cx_limited_range)
387 != opt_for_fn (to->decl, flag_cx_limited_range)
388 || opt_for_fn (callee->decl, flag_signed_zeros)
389 != opt_for_fn (to->decl, flag_signed_zeros)
390 || opt_for_fn (callee->decl, flag_associative_math)
391 != opt_for_fn (to->decl, flag_associative_math)
392 || opt_for_fn (callee->decl, flag_reciprocal_math)
393 != opt_for_fn (to->decl, flag_reciprocal_math)
394 || opt_for_fn (callee->decl, flag_fp_int_builtin_inexact)
395 != opt_for_fn (to->decl, flag_fp_int_builtin_inexact)
396 || opt_for_fn (callee->decl, flag_errno_math)
397 != opt_for_fn (to->decl, flag_errno_math))
399 struct gcc_options opts = global_options;
401 cl_optimization_restore (&opts, opts_for_fn (to->decl));
402 opts.x_flag_rounding_math
403 = opt_for_fn (callee->decl, flag_rounding_math);
404 opts.x_flag_trapping_math
405 = opt_for_fn (callee->decl, flag_trapping_math);
406 opts.x_flag_unsafe_math_optimizations
407 = opt_for_fn (callee->decl, flag_unsafe_math_optimizations);
408 opts.x_flag_finite_math_only
409 = opt_for_fn (callee->decl, flag_finite_math_only);
410 opts.x_flag_signaling_nans
411 = opt_for_fn (callee->decl, flag_signaling_nans);
412 opts.x_flag_cx_limited_range
413 = opt_for_fn (callee->decl, flag_cx_limited_range);
414 opts.x_flag_signed_zeros
415 = opt_for_fn (callee->decl, flag_signed_zeros);
416 opts.x_flag_associative_math
417 = opt_for_fn (callee->decl, flag_associative_math);
418 opts.x_flag_reciprocal_math
419 = opt_for_fn (callee->decl, flag_reciprocal_math);
420 opts.x_flag_fp_int_builtin_inexact
421 = opt_for_fn (callee->decl, flag_fp_int_builtin_inexact);
422 opts.x_flag_errno_math
423 = opt_for_fn (callee->decl, flag_errno_math);
424 if (dump_file)
425 fprintf (dump_file, "Copying FP flags from %s to %s\n",
426 callee->dump_name (), to->dump_name ());
427 DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
428 = build_optimization_node (&opts);
429 reload_optimization_node = true;
433 /* Reload global optimization flags. */
434 if (reload_optimization_node && DECL_STRUCT_FUNCTION (to->decl) == cfun)
435 set_cfun (cfun, true);
437 /* If aliases are involved, redirect edge to the actual destination and
438 possibly remove the aliases. */
439 if (e->callee != callee)
441 struct cgraph_node *alias = e->callee, *next_alias;
442 e->redirect_callee (callee);
443 while (alias && alias != callee)
445 if (!alias->callers
446 && can_remove_node_now_p (alias,
447 !e->next_caller && !e->prev_caller ? e : NULL))
449 next_alias = alias->get_alias_target ();
450 alias->remove ();
451 if (callee_removed)
452 *callee_removed = true;
453 alias = next_alias;
455 else
456 break;
460 clone_inlined_nodes (e, true, update_original, overall_size, e->frequency);
462 gcc_assert (curr->callee->global.inlined_to == to);
464 old_size = ipa_fn_summaries->get (to)->size;
465 ipa_merge_fn_summary_after_inlining (e);
466 if (e->in_polymorphic_cdtor)
467 mark_all_inlined_calls_cdtor (e->callee);
468 if (opt_for_fn (e->caller->decl, optimize))
469 new_edges_found = ipa_propagate_indirect_call_infos (curr, new_edges);
470 check_speculations (e->callee);
471 if (update_overall_summary)
472 ipa_update_overall_fn_summary (to);
473 else
474 /* Update self size by the estimate so overall function growth limits
475 work for further inlining into this function. Before inlining
476 the function we inlined to again we expect the caller to update
477 the overall summary. */
478 ipa_fn_summaries->get (to)->size += estimated_growth;
479 new_size = ipa_fn_summaries->get (to)->size;
481 if (callee->calls_comdat_local)
482 to->calls_comdat_local = true;
483 else if (to->calls_comdat_local && callee->comdat_local_p ())
485 struct cgraph_edge *se = to->callees;
486 for (; se; se = se->next_callee)
487 if (se->inline_failed && se->callee->comdat_local_p ())
488 break;
489 if (se == NULL)
490 to->calls_comdat_local = false;
493 /* FIXME: This assert suffers from roundoff errors, disable it for GCC 5
494 and revisit it after conversion to sreals in GCC 6.
495 See PR 65654. */
496 #if 0
497 /* Verify that estimated growth match real growth. Allow off-by-one
498 error due to ipa_fn_summary::size_scale roudoff errors. */
499 gcc_assert (!update_overall_summary || !overall_size || new_edges_found
500 || abs (estimated_growth - (new_size - old_size)) <= 1
501 || speculation_removed
502 /* FIXME: a hack. Edges with false predicate are accounted
503 wrong, we should remove them from callgraph. */
504 || predicated);
505 #endif
507 /* Account the change of overall unit size; external functions will be
508 removed and are thus not accounted. */
509 if (overall_size && inline_account_function_p (to))
510 *overall_size += new_size - old_size;
511 ncalls_inlined++;
513 /* This must happen after ipa_merge_fn_summary_after_inlining that rely on jump
514 functions of callee to not be updated. */
515 return new_edges_found;
519 /* Copy function body of NODE and redirect all inline clones to it.
520 This is done before inline plan is applied to NODE when there are
521 still some inline clones if it.
523 This is necessary because inline decisions are not really transitive
524 and the other inline clones may have different bodies. */
526 static struct cgraph_node *
527 save_inline_function_body (struct cgraph_node *node)
529 struct cgraph_node *first_clone, *n;
531 if (dump_file)
532 fprintf (dump_file, "\nSaving body of %s for later reuse\n",
533 node->name ());
535 gcc_assert (node == cgraph_node::get (node->decl));
537 /* first_clone will be turned into real function. */
538 first_clone = node->clones;
540 /* Arrange first clone to not be thunk as those do not have bodies. */
541 if (first_clone->thunk.thunk_p)
543 while (first_clone->thunk.thunk_p)
544 first_clone = first_clone->next_sibling_clone;
545 first_clone->prev_sibling_clone->next_sibling_clone
546 = first_clone->next_sibling_clone;
547 if (first_clone->next_sibling_clone)
548 first_clone->next_sibling_clone->prev_sibling_clone
549 = first_clone->prev_sibling_clone;
550 first_clone->next_sibling_clone = node->clones;
551 first_clone->prev_sibling_clone = NULL;
552 node->clones->prev_sibling_clone = first_clone;
553 node->clones = first_clone;
555 first_clone->decl = copy_node (node->decl);
556 first_clone->decl->decl_with_vis.symtab_node = first_clone;
557 gcc_assert (first_clone == cgraph_node::get (first_clone->decl));
559 /* Now reshape the clone tree, so all other clones descends from
560 first_clone. */
561 if (first_clone->next_sibling_clone)
563 for (n = first_clone->next_sibling_clone; n->next_sibling_clone;
564 n = n->next_sibling_clone)
565 n->clone_of = first_clone;
566 n->clone_of = first_clone;
567 n->next_sibling_clone = first_clone->clones;
568 if (first_clone->clones)
569 first_clone->clones->prev_sibling_clone = n;
570 first_clone->clones = first_clone->next_sibling_clone;
571 first_clone->next_sibling_clone->prev_sibling_clone = NULL;
572 first_clone->next_sibling_clone = NULL;
573 gcc_assert (!first_clone->prev_sibling_clone);
575 first_clone->clone_of = NULL;
577 /* Now node in question has no clones. */
578 node->clones = NULL;
580 /* Inline clones share decl with the function they are cloned
581 from. Walk the whole clone tree and redirect them all to the
582 new decl. */
583 if (first_clone->clones)
584 for (n = first_clone->clones; n != first_clone;)
586 gcc_assert (n->decl == node->decl);
587 n->decl = first_clone->decl;
588 if (n->clones)
589 n = n->clones;
590 else if (n->next_sibling_clone)
591 n = n->next_sibling_clone;
592 else
594 while (n != first_clone && !n->next_sibling_clone)
595 n = n->clone_of;
596 if (n != first_clone)
597 n = n->next_sibling_clone;
601 /* Copy the OLD_VERSION_NODE function tree to the new version. */
602 tree_function_versioning (node->decl, first_clone->decl,
603 NULL, true, NULL, false,
604 NULL, NULL);
606 /* The function will be short lived and removed after we inline all the clones,
607 but make it internal so we won't confuse ourself. */
608 DECL_EXTERNAL (first_clone->decl) = 0;
609 TREE_PUBLIC (first_clone->decl) = 0;
610 DECL_COMDAT (first_clone->decl) = 0;
611 first_clone->ipa_transforms_to_apply.release ();
613 /* When doing recursive inlining, the clone may become unnecessary.
614 This is possible i.e. in the case when the recursive function is proved to be
615 non-throwing and the recursion happens only in the EH landing pad.
616 We can not remove the clone until we are done with saving the body.
617 Remove it now. */
618 if (!first_clone->callers)
620 first_clone->remove_symbol_and_inline_clones ();
621 first_clone = NULL;
623 else if (flag_checking)
624 first_clone->verify ();
626 return first_clone;
629 /* Return true when function body of DECL still needs to be kept around
630 for later re-use. */
631 static bool
632 preserve_function_body_p (struct cgraph_node *node)
634 gcc_assert (symtab->global_info_ready);
635 gcc_assert (!node->alias && !node->thunk.thunk_p);
637 /* Look if there is any non-thunk clone around. */
638 for (node = node->clones; node; node = node->next_sibling_clone)
639 if (!node->thunk.thunk_p)
640 return true;
641 return false;
644 /* Apply inline plan to function. */
646 unsigned int
647 inline_transform (struct cgraph_node *node)
649 unsigned int todo = 0;
650 struct cgraph_edge *e, *next;
651 bool has_inline = false;
653 /* FIXME: Currently the pass manager is adding inline transform more than
654 once to some clones. This needs revisiting after WPA cleanups. */
655 if (cfun->after_inlining)
656 return 0;
658 /* We might need the body of this function so that we can expand
659 it inline somewhere else. */
660 if (preserve_function_body_p (node))
661 save_inline_function_body (node);
663 for (e = node->callees; e; e = next)
665 if (!e->inline_failed)
666 has_inline = true;
667 next = e->next_callee;
668 e->redirect_call_stmt_to_callee ();
670 node->remove_all_references ();
672 timevar_push (TV_INTEGRATION);
673 if (node->callees && (opt_for_fn (node->decl, optimize) || has_inline))
675 profile_count num = node->count;
676 profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
677 bool scale = num.initialized_p () && den.ipa_p ()
678 && (den.nonzero_p () || num == profile_count::zero ())
679 && !(num == den.ipa ());
680 if (scale)
682 if (dump_file)
684 fprintf (dump_file, "Applying count scale ");
685 num.dump (dump_file);
686 fprintf (dump_file, "/");
687 den.dump (dump_file);
688 fprintf (dump_file, "\n");
691 basic_block bb;
692 FOR_ALL_BB_FN (bb, cfun)
693 if (num == profile_count::zero ())
694 bb->count = bb->count.global0 ();
695 else
696 bb->count = bb->count.apply_scale (num, den);
697 ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
699 todo = optimize_inline_calls (current_function_decl);
701 timevar_pop (TV_INTEGRATION);
703 cfun->always_inline_functions_inlined = true;
704 cfun->after_inlining = true;
705 todo |= execute_fixup_cfg ();
707 if (!(todo & TODO_update_ssa_any))
708 /* Redirecting edges might lead to a need for vops to be recomputed. */
709 todo |= TODO_update_ssa_only_virtuals;
711 return todo;