<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 - --wrap doesn't work with lto"
   href="https://bugs.llvm.org/show_bug.cgi?id=33145">33145</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>--wrap doesn't work with lto
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rafael.espindola@gmail.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=18498" name="attach_18498" title="testcase">attachment 18498</a> <a href="attachment.cgi?id=18498&action=edit" title="testcase">[details]</a></span>
testcase

In the included testcase we have

void foo() {
  bar();
  __real_bar();
}

When linking without lto, we get

0000000000001000 <foo>:
    1000:       50                      push   %rax
    1001:       31 c0                   xor    %eax,%eax
    1003:       e8 28 00 00 00          callq  1030 <__wrap_bar@plt>
    1008:       31 c0                   xor    %eax,%eax
    100a:       59                      pop    %rcx
    100b:       e9 30 00 00 00          jmpq   1040 <bar@plt>

Which is what is expected.

With lto we get

0000000000001000 <foo>:
    1000:       50                      push   %rax
    1001:       31 c0                   xor    %eax,%eax
    1003:       e8 28 00 00 00          callq  1030 <this_is_bar@plt>
    1008:       31 c0                   xor    %eax,%eax
    100a:       59                      pop    %rcx
    100b:       e9 30 00 00 00          jmpq   1040 <this_is_real_bar@plt>

Showing that bar and __real_bar were inlined before the wrapping.</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>