<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Context-sensitivity of the inline cost"
   href="https://llvm.org/bugs/show_bug.cgi?id=28383">28383</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Context-sensitivity of the inline cost
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>apilipenko@azulsystems.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>