[CSSPGO] Allow inlining recursive call for preinliner
authorWenlei He <aktoon@gmail.com>
Wed, 1 Sep 2021 22:30:33 +0000 (15:30 -0700)
committerWenlei He <aktoon@gmail.com>
Thu, 2 Sep 2021 18:24:27 +0000 (11:24 -0700)
commitf7fff46acc86163cadfee481be6acc6b76659fc4
treea8d7904c42df30b535b5d156b5b874fbebae7e30
parentc86e1ce73bb6d70d255df9bf7700d09db07e7af8
[CSSPGO] Allow inlining recursive call for preinliner

When preinliner is used for CSSPGO, we try to honor global preinliner decision as much as we can except for uninlinable callees. We rely on InlineCost::Never to prevent us from illegal inlining.

However, it turns out that we use InlineCost::Never for both illeagle inlining and some of the "not-so-beneficial" inlining.

The most common one is recursive inlining, while it can bloat size a lot during CGSCC bottom-up inlining, it's less of a problem when recursive inlining is guided by profile and done in top-down manner.

Ideally it'd be better to have a clear separation between inline legality check vs cost-benefit check, but that requires a bigger change.

This change enables InlineCost computation to allow inlining recursive calls, controlled by InlineParams. In SampleLoader, we now enable recursive inlining for CSSPGO when global preinliner decision is used.

With this change, we saw a few perf improvements on SPEC2017 with CSSPGO and preinliner on: 2% for povray_r, 6% for xalancbmk_s, 3% omnetpp_s, while size is about the same (no noticeable perf change for all other benchmarks)

Differential Revision: https://reviews.llvm.org/D109104
llvm/include/llvm/Analysis/InlineCost.h
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp