[PATCH] (PR 65950) Improve predicate for exit(0);

Jan Hubicka hubicka@ucw.cz
Tue Oct 18 07:27:00 GMT 2016


> > Ah, so you have
> >
> > foo () { loop }
> > main()
> > {
> >   if ()
> >    {
> >       foo ();
> >       exit (0);
> >    }
> > ...
> >   return 0;
> > }
> >
> > and foo is marked cold because its only call is on the path to exit (0)?
> 
> 
> Actually the case I have here is just:
> foo () { loop }
> int main(void)
> {
> .....
> foo();
> ...
> exit (0);
> }
> 
> Just an exit at the end of main.
> Basically if we treat exit(0) as a normal function, main becomes hot again.

Yep, it is old noreturn predicate lazynes.  Path is OK

Honza

> 
> Thanks,
> Andrew
> 
> >
> > noreturn prediction is quite aggressive but it works also quite well.  Given
> > you can only detect a very minor fraction of cases (consider exit (0) being
> > in foo itself) I'm not sure that your fix is good progress.  IMHO we might
> > want to switch from 'noreturn' to 'noreturn' + likely error which needs
> > another attribute / auto-discovery and IPA propagation to handle this case
> > better.
> >
> > Anyway, I'll leave the patch to Honza.
> >
> > Richard.
> >
> >> Thanks,
> >> Andrew
> >>
> >>>
> >>> Richard.
> >>>
> >>>> OK?  Bootstrapped and tested on aarch64-linux-gnu with no regressions.
> >>>> Also tested it with SPEC CPU 2006 with no performance regressions.
> >>>>
> >>>> Thanks,
> >>>> Andrew Pinski
> >>>>
> >>>> ChangeLog:
> >>>> * predict.c (is_exit_with_zero_arg): New function.
> >>>> (tree_bb_level_predictions): Don't consider paths leading to exit(0)
> >>>> as nottaken.



More information about the Gcc-patches mailing list