[cfe-dev] split hot and cold part of a function into separate function

Sriraman Tallam via cfe-dev cfe-dev at lists.llvm.org
Fri May 7 18:19:49 PDT 2021


On Fri, May 7, 2021 at 1:08 PM Reid Kleckner <rnk at google.com> wrote:

> I believe intra-function hot cold code splitting is in the scope of the
> Propeller project, which Sriram Tallam worked on. I'm not sure what the
> status of the feature is at this moment.
>

This is available in LLVM with option -fsplit-machine-functions with PGO
and it uses PGO profiles to split a function's cold basic blocks which can
then be placed arbitrarily.  It is tested on instrumented PGO where it
shows gains of a couple of percent.  With Sampled PGO, we are still working
on tuning the split.

We have also added support for Propeller, which uses another round of
profiling to precisely layout basic blocks and split functions.  While this
is more effective that -fsplit-machine-functions, it requires another round
of sampled profiling.  Please see the documentation here to optimize
binaries with Propeller: :
https://github.com/google/autofdo/blob/propeller/OptimizeClangO3WithPropeller.md

Both -fsplit-machine-functions and Propeller use the basic block sections
feature to perform function splitting.



>
> I believe that the hot cold split pass is an IR pass, which means that it
> outlines code at the IR level. This will prevent the register allocator
> from working across the boundary between hot and cold code, so I don't
> believe it has as much performance potential as splitting the function
> during code generation. Looking at the example, I believe GCC is using this
> strategy, it is not calling outlined code.
>

Yep, GCC too splits functions just like -fsplit-machine-functions during
code generation and not early like hot cold splitting.  For performance, we
have found this more effective.


>
> On Thu, May 6, 2021 at 2:17 AM chuanqi.xcq via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> Hi,
>>
>> IIRC, clang/llvm has HotColdSplit and partial inline passes which has
>> similar functionality. However, these two passes are not enabled by default
>> for some reasons.
>>
>> Thanks,
>> Chuanqi
>>
>> ------------------------------------------------------------------
>> From:陈云星 via cfe-dev <cfe-dev at lists.llvm.org>
>> Send Time:2021年5月6日(星期四) 17:11
>> To:cfe-dev <cfe-dev at lists.llvm.org>
>> Subject:[cfe-dev] split hot and cold part of a function into separate
>> function
>>
>> currently, gcc support function attribute “cold”, which can hint compiler
>> split caller function’s cold into two separate function, one is hot the
>> other is cold.
>>
>> One example is here: https://godbolt.org/z/j7sK4hd48
>>
>> my question is Clang/llvm has such function/capability ?
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>

-- 

Sri    Tallam |

Software Engineer |

tmsriram at google.com |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210507/88ba1411/attachment-0001.html>


More information about the cfe-dev mailing list