[AutoFDO] Inline replay for cold/small callees from sample profile loader
authorWenlei He <aktoon@gmail.com>
Tue, 26 Nov 2019 23:53:06 +0000 (15:53 -0800)
committerWenlei He <aktoon@gmail.com>
Fri, 6 Dec 2019 19:44:45 +0000 (11:44 -0800)
commit7b61ae68ecd7a127e69c9e0d2563bddb7eccad7a
treed32b5fa5be46c4ff6f6dfe85e9be8ba06ca86a9d
parentdbd112972416f48f7e5b117e7a14b6e4b4d38146
[AutoFDO] Inline replay for cold/small callees from sample profile loader

Summary:
Sample profile loader of AutoFDO tries to replay previous inlining using context sensitive profile. The replay only repeats inlining if the call site block is hot. As a result it punts inlining of small functions, some of which can be beneficial for size, and will still be inlined by CSGCC inliner later. The oscillation between sample profile loader's inlining and regular CGSSC inlining cause unnecessary loss of context-sensitive profile. It doesn't have much impact for inline decision itself, but it negatively affects post-inline profile quality as CGSCC inliner have to scale counts which is not as accurate as the original context sensitive profile, and bad post-inline profile can misguide code layout.

This change added regular Inline Cost calculation for sample profile loader, so we can inline small functions upfront under switch -sample-profile-inline-size. In addition -sample-profile-cold-inline-threshold is added so we can tune the separate size threshold - currently the default is chosen to be the same as regular inliner's cold call-site threshold.

Reviewers: wmi, davidxl

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70750
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/test/Transforms/SampleProfile/Inputs/inline-cold.prof [new file with mode: 0644]
llvm/test/Transforms/SampleProfile/inline-cold.ll [new file with mode: 0644]