Hi, this counter update causes quite few profile mismatches. What happens is that during inlining the counts in cgrah does not necessarily match counts in the underlying cfgs of functoins. This is because cgraph represents the inline plan and when function was inlined its actual profile needs to be updated.
This code mistakely copies cfg's profile to cgraph when function body is being saved for further clonning. The bug seems to be there from 2010 https://gcc.gnu.org/ml/gcc-patches/2010-05/msg00726.html and was complained about at least once https://gcc.gnu.org/ml/gcc/2014-10/msg00271.html but I managed to ignore it :( Bootstrapped/regtested x86_64-linux, will commit it shortly. Honza * cgraphbuild.c (cgraph_edge::rebuild_references): Do not touch profile. Index: cgraphbuild.c =================================================================== --- cgraphbuild.c (revision 249069) +++ cgraphbuild.c (working copy) @@ -473,8 +473,6 @@ cgraph_edge::rebuild_references (void) else i++; - node->count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count; - FOR_EACH_BB_FN (bb, cfun) { for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))