<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Incorrect use information after instcombine impacts inline cost estimate"
   href="https://bugs.llvm.org/show_bug.cgi?id=51667">51667</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect use information after instcombine impacts inline cost estimate
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>tomasz.miasko@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In LLVM IR below, the h function calls functions f and g with internal linkage.
Neither f or g have any other uses, so both callsites should receive a bonus
for inlining internal function with a single use. The call to f does receive
the bonus, while g does not receive it:

$ opt a.ll -S -instcombine -inline -pass-remarks=inline
remark: <unknown>:0:0: 'f' inlined into 'h' with (cost=-15035, threshold=337)
remark: <unknown>:0:0: 'g' inlined into 'h' with (cost=-35, threshold=337)

Everything works as expected when instcombine and inline passes are run
separately: 

$ opt a.ll -S -instcombine > b.ll
$ opt b.ll -S -inline -pass-remarks=inline 
remark: <unknown>:0:0: 'f' inlined into 'h' with (cost=-15035, threshold=337)
remark: <unknown>:0:0: 'g' inlined into 'h' with (cost=-15035, threshold=337)

LLVM IR:

; ModuleID = 'a.ll'
source_filename = "a.a146b597-cgu.0"
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%0 = type { i64, i64, i64 }
%1 = type { i64, i64, i64 }

define internal void @f(%0* align 8 %a) unnamed_addr {
start:
  ret void
}

define internal void @g(%0* align 8 %a) unnamed_addr {
start:
  ret void
}

define void @h(%0* align 8 %a, %1* align 8 %b) unnamed_addr {
start:
  call void @f(%0* align 8 %a)
  call void bitcast (void (%0*)* @g to void (%1*)*)(%1* align 8 %b)
  ret void
}</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>