]> git.ipfire.org Git - thirdparty/gcc.git/commit
Prevent possible overflows in ipa-profile
authorJan Hubicka <hubicka@ucw.cz>
Sun, 22 Jun 2025 01:32:29 +0000 (03:32 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Sun, 22 Jun 2025 01:32:29 +0000 (03:32 +0200)
commit6e38bef16bbfaa7743d1ec8937ed9dfba669136d
tree097afc7c2d8cc1d7371085d146a9192bd962d520
parentdda86c80bca2300a47f91bcfc589951df9c7f1be
Prevent possible overflows in ipa-profile

The bug in scaling profile of fnsplit produced clones made
some afdo counts during gcc bootstrap very large (2^59).
This made computations in ipa-profile to silently overflow
which triggered hot count to be identified as 1 instead of
sane value.

While fixing the fnsplit bug prevents overflow, I think the histogram code
should be made safe too.  sreal is not very fitting here since mantisa is 32bit
and not very good for many additions of many numbers which are possibly of very
different order.  So I use widest_int while 128bit arithmetics would be safe
(we are summing 60 bit counts multiplied by time estimates).  I don't think
we have readily available 128bit type and code is not really time critical since
the histogram is computed once.

gcc/ChangeLog:

* ipa-profile.cc (ipa_profile): Use widest_int to avoid
possible overflows.
gcc/ipa-profile.cc