Re: Questions about __attribute((cold))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Fine wrote:

> while (xxx1) {
>    xxx2;
>    if (xxx3) {
>        xxx4; }
>    xxx5; }
> 
> Where each xxxn is replaced by some useful code.  I want to invent a
> syntax to be used across my project in several such cases to get the
> compiler to push xxx4 out of line to avoid polluting the L1 cache.

You may also need -freorder-blocks-and-partition for that.  From
invoke.texi:

> @item -freorder-blocks-and-partition
> @opindex freorder-blocks-and-partition
> In addition to reordering basic blocks in the compiled function, in order
> to reduce number of taken branches, partitions hot and cold basic blocks
> into separate sections of the assembly and .o files, to improve
> paging and cache locality performance.
> 
> This optimization is automatically turned off in the presence of
> exception handling, for linkonce sections, for functions with a user-defined
> section attribute and on any architecture that does not support named
> sections.

If you read that section of the manual it looks like -freorder-functions
and -freorder-blocks are enabled by default at -O2 and -O3, but not
-freorder-blocks-and-partition.  To me that implies that hot/cold
partitioning by default will happen at the function level but not at the
basic block level (as you seek) unless you also specify
-freorder-blocks-and-partition.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux