[Inliner] Penalise inlining of calls with loops at Oz
authorDavid Green <david.green@arm.com>
Mon, 5 Nov 2018 14:54:34 +0000 (14:54 +0000)
committerDavid Green <david.green@arm.com>
Mon, 5 Nov 2018 14:54:34 +0000 (14:54 +0000)
commitba9f245b0df90a7214293f937ae0c6748c6503f0
treef74f6ef7566dcac60d22d32f3680f32531862d14
parent8d7c351799692a93621bb44ceec744c853c41942
[Inliner] Penalise inlining of calls with loops at Oz

We currently seem to underestimate the size of functions with loops in them,
both in terms of absolute code size and in the difficulties of dealing with
such code. (Calls, for example, can be tail merged to further reduce
codesize). At -Oz, we can then increase code size by inlining small loops
multiple times.

This attempts to penalise functions with loops at -Oz by adding a CallPenalty
for each top level loop in the function. It uses LI (and hence DT) to calculate
the number of loops. As we are dealing with minsize, the inline threshold is
small and functions at this point should be relatively small, making the
construction of these cheap.

Differential Revision: https://reviews.llvm.org/D52716

llvm-svn: 346134
llvm/lib/Analysis/InlineCost.cpp
llvm/test/Transforms/Inline/ARM/loop-add.ll [new file with mode: 0644]
llvm/test/Transforms/Inline/ARM/loop-memcpy.ll [new file with mode: 0644]
llvm/test/Transforms/Inline/ARM/loop-noinline.ll [new file with mode: 0644]