<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 - LLVM cannot devirtualize with MSVC-style RTTI"
   href="https://bugs.llvm.org/show_bug.cgi?id=49765">49765</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM cannot devirtualize with MSVC-style RTTI
          </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>enhancement
          </td>
        </tr>

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

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

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

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

        <tr>
          <th>CC</th>
          <td>aeubanks@google.com, llvm-bugs@lists.llvm.org, peter@pcc.me.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider this simple case when devirtualization should be possible after
inlining the constructor:
<a href="https://gcc.godbolt.org/z/osGe67s9b">https://gcc.godbolt.org/z/osGe67s9b</a>

struct Foo {
  Foo() {}
  virtual ~Foo() {}
  virtual void f() {}
  int x;
};
int main() {
  Foo *p = new Foo();
  p->f();
  delete p;
}

When RTTI data is disabled (/GR- / -fno-rtti-data), we cannot devirtualize the
call to Foo::f. We can optimize the vptr load, but the vtable alias inhibits
full devirtualization. See this instruction:
  call qword ptr [rip + "??_7Foo@@6B@"+8]

LLVM knows exactly which vtable we are loading from, but because of the MSVC
RTTI alias code pattern, it refuses to optimize away the load.

We should either make the optimize more aggressive, or find a better IR pattern
for MSVC-style RTTI.

Arthur had a patch to address this, but maybe it isn't sound:
<a href="https://reviews.llvm.org/D99240">https://reviews.llvm.org/D99240</a></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>