aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2020-12-18 00:37:24 -0800
committerKazu Hirata <kazu@google.com>2020-12-18 00:37:24 -0800
commit9895c7012d61525ed541ef74d9eb43300bac9b0c (patch)
treec53b70c6014ab38290d27f2d13f7a7400ac56109 /clang/lib/Frontend/CompilerInvocation.cpp
parentf4511aec2bf482f2ae5bbd14138a229b72c41c80 (diff)
downloadllvm-9895c7012d61525ed541ef74d9eb43300bac9b0c.zip
llvm-9895c7012d61525ed541ef74d9eb43300bac9b0c.tar.gz
llvm-9895c7012d61525ed541ef74d9eb43300bac9b0c.tar.bz2
[InlineCost] Implement cost-benefit-based inliner
This patch adds an alternative cost metric for the inliner to take into account both the cost (i.e. size) and cycle count savings into account. Without this patch, we decide to inline a given call site if the size of inlining the call site is below the threshold that is computed according to the hotness of the call site. This patch adds a new cost metric, turned off by default, to take over the handling of hot call sites. Specifically, with the new cost metric, we decide to inline a given call site if the ratio of cycle savings to size exceeds a threshold. The cycle savings are computed from call site costs, parameter propagation, folded conditional branches, etc, all weighted by their respective profile counts. The size is primarily the callee size, but we subtract call site costs and the size of basic blocks that are never executed. The new cost metric implicitly takes advantage of the machine function splitter recently introduced by Snehasish Kumar, which dramatically reduces the cost of duplicating (e.g. inlining) cold basic blocks by placing cold basic blocks of hot functions in the .text.split section. We evaluated the new cost metric on clang bootstrap and SPECInt 2017. For clang bootstrap, we observe 0.69% runtime improvement. For SPECInt we report the change in IntRate the C/C++ benchmarks. All benchmarks apart from perlbench and omnetpp improve, on average by 0.21% with the max for mcf at 1.96%. Benchmark % Change 500.perlbench_r -0.45 502.gcc_r 0.13 505.mcf_r 1.96 520.omnetpp_r -0.28 523.xalancbmk_r 0.49 525.x264_r 0.00 531.deepsjeng_r 0.00 541.leela_r 0.35 557.xz_r 0.21 Differential Revision: https://reviews.llvm.org/D92780
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions