This is the mail archive of the gcc-patches@gcc.gnu.org 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 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


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