Diego Biurrun <[email protected]> writes:

> On Wed, Apr 04, 2012 at 01:39:45PM +0100, Måns Rullgård wrote:
>> Diego Biurrun <[email protected]> writes:
>> 
>> > The av_cold attribute is only effective if the compiler can see it
>> > during the compilation of code that calls a function marked
>> > av_cold.  Thus the attribute needs to be part of function
>> > declarations in header files.
>> 
>> Patently false.  Patch rejected.
>
> http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
>
> 6.30 Declaring Attributes of Functions
>
> cold
>   The cold attribute is used to inform the compiler that a function is
>   unlikely executed. The function is optimized for size rather than
>   speed and on many targets it is placed into special subsection of the
>   text section so all cold functions appears close together improving
>   code locality of non-cold parts of program. The paths leading to
>   call of cold functions within code are marked as unlikely by the
>   branch prediction mechanism. It is thus useful to mark functions used
>   to handle unlikely conditions, such as perror, as cold to improve
>   optimization of hot functions that do call marked functions in rare
>   occasions.
>
> How is the compiler supposed to mark paths leading to calls of a cold
> function as unlikely without av_cold in the header file?

First of all, I doubt it actually does this.  Secondly, the way most of
these functions are called, it doesn't matter.  Adding these attributes
only amounts to clutter.

Marking the _definitions_ cold is still useful since they can then be
optimised for size and placed a separate section.  This is something gcc
definitely does.

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to