]> granicus.if.org Git - llvm/commit
[InlineCost] Remove skew when calculating call costs
authorJames Molloy <james.molloy@arm.com>
Mon, 14 Nov 2016 11:14:41 +0000 (11:14 +0000)
committerJames Molloy <james.molloy@arm.com>
Mon, 14 Nov 2016 11:14:41 +0000 (11:14 +0000)
commita52fb282daed4f2217ce55d40bf8028002a1041a
treeba7acc2a2816a90cfdc40a34de2adb9562cea4da
parentc4d8c58337a78668e8662672bd58fb2ce7031c28
[InlineCost] Remove skew when calculating call costs

When calculating the cost of a call instruction we were applying a heuristic penalty as well as the cost of the instruction itself.

However, when calculating the benefit from inlining we weren't discounting the equivalent penalty for the call instruction that would be removed! This caused skew in the calculation and meant we wouldn't inline in the following, trivial case:

  int g() {
    h();
  }
  int f() {
    g();
  }

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286814 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InlineCost.cpp
test/Transforms/Inline/alloca-bonus.ll
test/Transforms/Inline/inline-cold-callee.ll
test/Transforms/Inline/inline-cold.ll
test/Transforms/Inline/inline-hot-callee.ll
test/Transforms/Inline/inline-hot-callsite.ll
test/Transforms/Inline/inline-optsize.ll
test/Transforms/Inline/inline_unreachable-2.ll
test/Transforms/Inline/optimization-remarks-passed-yaml.ll
test/Transforms/Inline/ptr-diff.ll