<html>
    <head>
      <base href="https://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 --- - unnecessary emission of vtable etc when clang sees an (ununsed) inline key function definition"
   href="https://llvm.org/bugs/show_bug.cgi?id=23521">23521</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>unnecessary emission of vtable etc when clang sees an (ununsed) inline key function definition
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </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>Consider:

  struct S { virtual void f(); };
  inline void S::f() {}

Clang (and GCC and EDG) at -O0 emits a definition for S::f and for S's vtable,
type info and so on. This is unnecessary (and removed at -O1 and above).

Instead, we could do the following:

 * When we see a definition of an inline key function, treat the class as if it
had no key function, and in particular don't force anything to be emitted and
emit the vtable lazily and on demand.
 * When the (vtable, type info, ...) is emitted, ensure we also emit the inline
key function.
 * When we emit an inline key function, also trigger the emission of the
associated class data (vtable etc.)


[This causes a -O0 modules bootstrap to fail right now: clang-format imports a
module that contains ASTMatchers.h, which define a number of classes with
inline key functions. Those key functions in turn use other non-inline
functions in that same header. Thus emitting the key functions gives
clang-format a link dependency on ASTMatchers.o, which is not linked into
clang-format.]</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>