cgraph_node::scale_profile_to computed an adjusted scale but never
applied it, leaving callgraph edges stale after IPA-CP clone
redistribution and causing edge/BB count verification failures.

The stale counts triggered this ICE during AutoFDO LTO compilation:

  internal compiler error: verify_cgraph_node failed
  #0  internal_error(char const*, ...)
      .../gcc/diagnostic-global-context.cc:787
  #1  cgraph_node::verify_node()
      .../gcc/cgraph.cc:4510
  #2  symtab_node::verify()
      .../gcc/symtab.cc:1377
  #3  optimize_inline_calls(tree_node*)
      .../gcc/tree-inline.cc:5679
  #4  inline_transform(cgraph_node*)
      .../gcc/ipa-inline-transform.cc:871
  #5  execute_one_ipa_transform_pass
      .../gcc/passes.cc:2327
  #6  execute_all_ipa_transforms(bool)
      .../gcc/passes.cc:2390
  #7  cgraph_node::expand()
      .../gcc/cgraphunit.cc:1867
  #8  cgraph_node::expand()
      .../gcc/cgraphunit.cc:1827
  #9  expand_all_functions
      .../gcc/cgraphunit.cc:2057
  #10 symbol_table::compile()
      .../gcc/cgraphunit.cc:2435
  #11 lto_main()
      .../gcc/lto/lto.cc:718

gcc/ChangeLog:

        * cgraph.cc (cgraph_node::scale_profile_to): Apply the computed scale.

Regression tested on aarch64-linux-gnu with no new regressions.
Signed-off-by: Kugan Vivekanandarajah <[email protected]>
---
 gcc/cgraph.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index cdb3201f49c..404bc222d18 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -314,6 +314,7 @@ cgraph_node::scale_profile_to (profile_count ipa_count)
   profile_count num = count.combine_with_ipa_count (ipa_count);
   profile_count den = count;
   profile_count::adjust_for_ipa_scaling (&num, &den);
+  apply_scale (num, den);
 }
 
 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
-- 
2.34.1

Reply via email to