Re: Fix overflows in -fprofile-reorder-functions

2019-12-10 Thread Jan Hubicka
> On Tue, 10 Dec 2019, Jan Hubicka wrote: > > > > I would recommend to make these variables uint64_t, then you can simply do > > > > > > tp_first_run_a--; > > > tp_first_run_b--; > > > > > > making 0 wrap around to UINT64_MAX. Then they will naturally sort after > > > all > > > other nodes.

Re: Fix overflows in -fprofile-reorder-functions

2019-12-10 Thread Alexander Monakov
On Tue, 10 Dec 2019, Jan Hubicka wrote: > > I would recommend to make these variables uint64_t, then you can simply do > > > > tp_first_run_a--; > > tp_first_run_b--; > > > > making 0 wrap around to UINT64_MAX. Then they will naturally sort after all > > other nodes. > > Then we would still

Re: Fix overflows in -fprofile-reorder-functions

2019-12-10 Thread Jan Hubicka
> 2On Sun, 8 Dec 2019, Jan Hubicka wrote: > > > Other explanation would be that our new qsort with broken comparator due to > > overflow can actualy remove some entries in the array, but that sounds bit > > crazy. > > gcc_qsort only reorders elements, making it possible for gcc_qsort_chk (that >

Re: Fix overflows in -fprofile-reorder-functions

2019-12-08 Thread Jan Hubicka
> 2On Sun, 8 Dec 2019, Jan Hubicka wrote: > > > Other explanation would be that our new qsort with broken comparator due to > > overflow can actualy remove some entries in the array, but that sounds bit > > crazy. > > gcc_qsort only reorders elements, making it possible for gcc_qsort_chk (that >

Re: Fix overflows in -fprofile-reorder-functions

2019-12-08 Thread Andreas Schwab
On Dez 08 2019, Jan Hubicka wrote: > Index: cgraphunit.c > === > --- cgraphunit.c (revision 279076) > +++ cgraphunit.c (working copy) > @@ -2359,19 +2359,33 @@ cgraph_node::expand (void) > /* Node comparator that is respons

Re: Fix overflows in -fprofile-reorder-functions

2019-12-08 Thread Alexander Monakov
2On Sun, 8 Dec 2019, Jan Hubicka wrote: > Other explanation would be that our new qsort with broken comparator due to > overflow can actualy remove some entries in the array, but that sounds bit > crazy. gcc_qsort only reorders elements, making it possible for gcc_qsort_chk (that runs afterwards)

Re: Fix overflows in -fprofile-reorder-functions

2019-12-08 Thread Jan Hubicka
> Hi, > this patch fixes three sissues with -fprofile-reorder-functions: > 1) First is that tp_first_run is stored as 32bit integer while it can easily >overflow (and does so during Firefox profiling). Actually the overflow problem is possible only with mismatched profiles (which does happen f

Fix overflows in -fprofile-reorder-functions

2019-12-08 Thread Jan Hubicka
Hi, this patch fixes three sissues with -fprofile-reorder-functions: 1) First is that tp_first_run is stored as 32bit integer while it can easily overflow (and does so during Firefox profiling). 2) Second problem is that flag_profile_functions can not be tested w/o function context. The ch