<html>
    <head>
      <base href="http://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 --- - missing nop after branch"
   href="http://llvm.org/bugs/show_bug.cgi?id=17111">17111</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>missing nop after branch
          </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>Linux
          </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>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nlewycky@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase:

  class Base {
  protected:
    Base() {}

  public:
    virtual ~Base();
    virtual void BaseMethod() {}
  };

  struct Derived : public Base {
    ~Derived() {
      DerivedMethod();
    }

    void DerivedMethod();

    virtual void BaseMethod();
  };

  void Derived::DerivedMethod() {}
  void Derived::BaseMethod() {}

The bug is in the assembly generated for the destructor. Here's a snippet:

  .Ltmp4:
         std 5, 120(31)
         bl _ZN7Derived13DerivedMethodEv
  .Ltmp5:
         b .LBB4_1

That doesn't leave enough space for the linker to insert the TOC reload when
resolving the R_PPC64_REL24 relocation. There needs to be a nop after the
branch+link instruction.

Reproduce with:

  clang -target powerpc64-pc-linux-gnu -fpic testcase.cc -S -o -

Ultimately the symptom is a failure when linking:

  error: call lacks nop, can't restore toc; recompile with -fPIC</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>