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

陈云星 via cfe-dev cfe-dev at lists.llvm.org
Sun May 9 04:53:19 PDT 2021



> 2021年5月9日 上午3:39,Sriraman Tallam <tmsriram at google.com> 写道:
> 
> 
> 
> On Fri, May 7, 2021 at 10:19 PM 陈云星 <chen.yunxing at me.com <mailto:chen.yunxing at me.com>> wrote:
> can we do not depends on p profiling?
> 
> use hint just like: [unlikely]
> 
> Could you please rephrase?  I think you mean if we could split without profile information?  We don't support that right now and we haven't had much success with that with regards to performance. If you are not using profile-guided builds, you are dropping a lot of performance anyways.
> 
>  
Yes. Because profile need choice perfect workload, and it maybe hard or infeasible for some software. Which has many workload need to support well and need balance between these workload.
> 
> Which make more controllable for programmers 
> 
> 发自我的iPhone
> 
>> 在 2021年5月8日,上午9:20,Sriraman Tallam <tmsriram at google.com <mailto:tmsriram at google.com>> 写道:
>> 
>> 
>> 
>> 
>> On Fri, May 7, 2021 at 1:08 PM Reid Kleckner <rnk at google.com <mailto: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 <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 <mailto: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 <mailto:cfe-dev at lists.llvm.org>>
>> Send Time:2021年5月6日(星期四) 17:11
>> To:cfe-dev <cfe-dev at lists.llvm.org <mailto: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 <https://godbolt.org/z/j7sK4hd48>
>> 
>> my question is Clang/llvm has such function/capability ?
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>> 
>> 
>> -- 
>> 
>> Sri    Tallam |
>>  Software Engineer |
>>  tmsriram at google.com <mailto:tmsriram at google.com> |
> 
> 
> -- 
> 
> Sri    Tallam |
>  Software Engineer |
>  tmsriram at google.com <mailto:tmsriram at google.com> |

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210509/627d74dc/attachment-0001.html>


More information about the cfe-dev mailing list