[llvm-bugs] [Bug 28383] New: Context-sensitivity of the inline cost

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 1 02:31:06 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28383

            Bug ID: 28383
           Summary: Context-sensitivity of the inline cost
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: apilipenko at azulsystems.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

In order to estimate the cost of inlining for a given call site InlineCost
analyzes the body of the callee AND the caller context. For example, if one of
the arguments is known to be non-null in the caller InlineCost takes this fact
into account and discounts the cost of a null-check on this argument in the
callee.

The current pass manager doesn't account for this context-sensitivity.
CallGraphSCC pass manager traverses SCCs of the call graph in the bottom-up
order running inliner and a set of simplification passes on each SCC. This way
inliner always looks at optimized inlining candidates which increases chances
of inlining. Because of context-sensitivity of the inline cost optimizations of
the current SCC might enable more inlining in this SCC. Although, the pass
manager doesn't expect that and doesn't try to inline in this SCC again after
simplifications unless simplifications resulted in devirtualization. 

The pass manager should expect that new inlineable call sites can appear as a
result of simplifications other than devirtualization and should iterate on the
current SCC as long as the inliner makes progress.

For example, initial function:
foo(%a) {
  checkNonNull(%a)
  foo_impl(%a)
}

checkNonNull has been inlined and instcombine has propagated context-sensitive
non-null fact to the call-site:

foo(%a) {
  if (%a == null)
    uncommon trap
  foo_impl(nonnull %a)
}
Knowledge about %a being not-null might enable inlining of foo_impl. But the
inliner never tries to inline call sites in foo after that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160701/d2d797d1/attachment.html>


More information about the llvm-bugs mailing list