This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add -Wsuggest-attribute=cold
- From: Jeff Law <law at redhat dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Eric Gallager <egall at gwmail dot gwu dot edu>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 24 Jul 2017 16:19:20 -0600
- Subject: Re: Add -Wsuggest-attribute=cold
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=law at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9271FC1EA9E9
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9271FC1EA9E9
- References: <20170724185633.GA43541@kam.mff.cuni.cz> <CAMfHzOsgJptfs0E+Y=ibhAvnf6vr5UtQNYhbdYcOG=2Wg9H4eA@mail.gmail.com> <20170724190832.GA76225@kam.mff.cuni.cz> <51047328-5f82-a57d-08c3-05432d0d2c98@redhat.com> <20170724220608.GA38863@kam.mff.cuni.cz>
On 07/24/2017 04:06 PM, Jan Hubicka wrote:
>> On 07/24/2017 01:08 PM, Jan Hubicka wrote:
>>>> 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.
>> So what's the advantage of a user adding the attribute if the compiler
>> can infer it? Presumably by adding the attribute, it's known without
>> analysis and can be taken advantage of by its callers?
>
> Like most of the other -Wsuggest it only warn on functions that are externally
> visble. Adding attribute will improve code in other compilation units that does
> not see the function body.
OK. THanks for confirming.
Jeff