> During WPA we merge 2 functions where one is built with -O3 > -fprofile-use while the other one uses -O0. We end up with: > > prevailing node: > > BitwiseCast (const double aFrom) > { > long unsigned int temp; > long unsigned int D.4528; > > <bb 2> : > BitwiseCast (aFrom_2(D), &temp); > _4 = temp; > temp ={v} {CLOBBER}; > > <bb 3> : > <L0>: > return _4; > > } > > merged node: > BitwiseCast (const double aFrom) > { > <bb 2> [count: 1509]: > _3 = VIEW_CONVERT_EXPR<long unsigned int>(aFrom_2(D)); > return _3; > } > > What happens is that we copy dst->count = src->count.ipa() but > we skip merging of BBs (a different CFG). Then we end up in situation > where profile of a ENTRY_BB_FOR_FN == uninitialized while > dst->count.quality is precise.
In usual case there of diverging CFGs both functions have non-trivial profile, one is ipa and other is guessed (so count.initialized_p returns false) In this case we do want to copy the count which will lead in scaling the local profile by the known entry frequency. This is arranged by fixup_cfg that does this kind of transitions. Is this the bug that riggers Firefox ICE? What goes wrong later? Honza > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > gcc/ChangeLog: > > PR ipa/97295 > * ipa-utils.c (ipa_merge_profiles): > --- > gcc/ipa-utils.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c > index 23e7f714306..fe2149069be 100644 > --- a/gcc/ipa-utils.c > +++ b/gcc/ipa-utils.c > @@ -437,10 +437,7 @@ ipa_merge_profiles (struct cgraph_node *dst, > else if (dst->count.ipa ().initialized_p ()) > ; > else if (src->count.ipa ().initialized_p ()) > - { > - copy_counts = true; > - dst->count = src->count.ipa (); > - } > + copy_counts = true; > /* If no updating needed return early. */ > if (dst->count == orig_count) > @@ -620,6 +617,9 @@ ipa_merge_profiles (struct cgraph_node *dst, > bool dstscale = !copy_counts > && dstnum.initialized_p () && !(dstnum == dstden); > + if (copy_counts) > + dst->count = src->count.ipa (); > + > /* TODO: merge also statement histograms. */ > FOR_ALL_BB_FN (srcbb, srccfun) > { > -- > 2.28.0 >