This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add -Wsuggest-attribute=cold

> On Mon, Jul 24, 2017 at 2:56 PM, Jan Hubicka <> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]