This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add -Wsuggest-attribute=cold
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Eric Gallager <egall at gwmail dot gwu dot edu>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 24 Jul 2017 21:08:32 +0200
- Subject: Re: Add -Wsuggest-attribute=cold
- Authentication-results: sourceware.org; auth=none
- References: <20170724185633.GA43541@kam.mff.cuni.cz> <CAMfHzOsgJptfs0E+Y=ibhAvnf6vr5UtQNYhbdYcOG=2Wg9H4eA@mail.gmail.com>
> On Mon, Jul 24, 2017 at 2:56 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > Hi,
> > this patch adds -Wsuggest-attribute=cold because we can now statically detect
> > cold functions atuomatically.
> >
> > Bootstrapped/regtested x86_64-linux. Plan to commit it tomorrow if there are no
> > complains.
> >
> > Honza
> >
> > * invoke.texi (Wsuggest-attribute=cold): Document.
> > * common.opt (Wsuggest-attribute=cold): New
> > * ipa-pure-const.c (warn_function_cold): New function.
> > * predict.c (compute_function_frequency): Use it.
> > * predict.h (warn_function_cold): Declare.
> >
> > * gcc.dg/cold-1.c: New testcase.
>
> Would it be possible to also do -Wsuggest-attribute=hot for symmetry's
> sake? Just wondering.
It would be nice, but it is kind of impossible to detect hot spots of the
program with reasonable certainity. (that is why profile feedback is useful :)
This cold attribute detection looks really for very simple pattern where the
function inavoidably calls other cold function or does something similarly
unlikely (Eh or trap). This is fairly limited pattern, but it is useful i.e.
to detect which libstdc++ functions can have this annotation that further
improve branch prediction.
Honza