[Inliner] Make the CallPenalty configurable
authorPhilipp Krones <philipp.krones@embecosm.com>
Wed, 14 Jul 2021 11:21:40 +0000 (12:21 +0100)
committerSimon Cook <simon.cook@embecosm.com>
Mon, 26 Jul 2021 11:07:49 +0000 (12:07 +0100)
commit46c03668774c27877bd96957931fafae24383e3f
treee22ea5e686cb8ee518cd05fd15cee4a7c3b16299
parentd995d63767624a60a5d3276f9f16d7b995435af1
[Inliner] Make the CallPenalty configurable

Tests with multiple benchmarks, like Embench [1], showed that the
CallPenalty magic number has the most influence on inlining decisions
when optimizing for size.

On the other hand, there was no good default value for this parameter.
Some benchmarks profited strongly from a reduced call penalty. On
example is the picojpeg benchmark compiled for RISC-V, which got 6%
smaller with a CallPenalty of 10 instead of 12. Other benchmarks
increased in size, like matmult.

This commit makes the compromise of turning the magic number constant of
CallPenalty into a configurable value. This introduces the flag
`--inline-call-penalty`. With that flag users can fine tune the inliner
to their needs.

The CallPenalty constant was also used for loops. This commit replaces
the CallPenalty constant with a new LoopPenalty constant that is now
used instead.

This is a slimmed down version of https://reviews.llvm.org/D30899

[1]: https://github.com/embench/embench-iot

Differential Revision: https://reviews.llvm.org/D105976
llvm/include/llvm/Analysis/InlineCost.h
llvm/lib/Analysis/InlineCost.cpp
llvm/test/Transforms/Inline/inline-call-penalty-option.ll [new file with mode: 0644]