<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 - -flto invalidates musttail prerequisites"
   href="https://bugs.llvm.org/show_bug.cgi?id=36441">36441</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-flto invalidates musttail prerequisites
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>fedor@indutny.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19906" name="attach_19906" title="Input LLVM IR">attachment 19906</a> <a href="attachment.cgi?id=19906&action=edit" title="Input LLVM IR">[details]</a></span>
Input LLVM IR

Hello!

I'm working on a project that generates LLVM IR with lots of `musttail` calls.
As I was feeding that IR into `clang` with `-flto` option - I got following
error:

cannot guarantee tail call due to mismatched parameter counts
  %15 = musttail call fastcc i8*
@http_parser__invoke_on_complete(%http_parser_state* %0, i8* %14, i8* %2)
cannot guarantee tail call due to mismatched parameter counts
  %33 = musttail call fastcc i8*
@http_parser__invoke_on_complete(%http_parser_state* %0, i8* %32, i8* %2)
cannot guarantee tail call due to mismatched parameter counts
  %10 = musttail call fastcc i8* @http_parser__method(%http_parser_state* %0,
i8* %1, i8* %2, i32 0)
LLVM ERROR: Broken module found, compilation aborted!

Unfortunately, my attempts to reduce it to a minimal test case have so far been
unsuccessful. Thus please find in an attachment - the IR file that I'm
experiencing the problem is.

It looks like unused function parameters are somehow getting removed by LTO,
likely due to inlining. In turn, the compiler can no longer see that the
parameter count is the same.

I might be able to submit a patch to fix this problem given enough hints on
where to look at.

Thanks,
Fedor.</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>