[PATCH] Teach InlineCost to account for a null check which can be folded away

Philip Reames listmail at philipreames.com
Fri Apr 24 16:19:47 PDT 2015


On 04/20/2015 02:45 PM, Philip Reames wrote:
> Hi chandlerc, nlewycky,
> 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 this is only adjusting the inline cost analysis.  As separate changes, I'm going to add support for propagating the null attribute to the call site.  An alternate approach would be the have the inline cost analysis ask a ValueTracking question about the caller's formal argument.  Separating this into two pieces using the already existing nonnull attribute seemed preferable.
> Does anyone think I need to teach InlineFunction to exploit the attribute in the same way?  Or are we willing to assume this will happen correctly after inlining?
> http://reviews.llvm.org/D9129
> Files:
>    lib/Analysis/IPA/InlineCost.cpp
>    test/Transforms/Inline/nonnull.ll
>    http://reviews.llvm.org/settings/panel/emailpreferences/

More information about the llvm-commits mailing list