Teach InlineCost to account for a null check which can be folded away
authorPhilip Reames <listmail@philipreames.com>
Fri, 26 Jun 2015 20:51:17 +0000 (20:51 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 26 Jun 2015 20:51:17 +0000 (20:51 +0000)
commit64b906419e5affd63a20cf7d7b3f822f096dce48
treeb67e29a4179ac9954c1c25caf3cf2c7be339a782
parent237b76d7404db808720d6fd27fa4b85474eebedc
Teach InlineCost to account for a null check which can be folded away

If we have a caller that knows a particular argument can never be null, we can exploit this fact while simplifying values in the inline cost analysis. This has the effect of reducing the cost for inlining when a null check is present in the callee, but the value is known non null in the caller. In particular, any dependent control flow can be discounted from the cost estimate.

Note that we use the parameter attributes at the call site to memoize the analysis within the caller's code.  The setting of this attribute is done in InstCombine, the inline cost analysis just consumes it.  This is intentional and important because we want the inline cost analysis results to be easily cachable themselves.  We're not currently doing so, but initial results on LTO indicate this will quickly become important.

Differential Revision: http://reviews.llvm.org/D9129

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240828 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/IPA/InlineCost.cpp
test/Transforms/Inline/nonnull.ll [new file with mode: 0644]