]> granicus.if.org Git - clang/commit
When building with optimizations, emit vtables where the key is not in the
authorAnders Carlsson <andersca@mac.com>
Sun, 30 Jan 2011 20:45:54 +0000 (20:45 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 30 Jan 2011 20:45:54 +0000 (20:45 +0000)
commit6d7f8473cd6e967b3676948894ce72472102f9cb
treef2577997131cf50d2a58dc84c5c9365e65d91324
parent80f0ab78f60379589c815b41de5d149c9479ca98
When building with optimizations, emit vtables where the key is not in the
current translation unit as available_externally.

This helps devirtualize the second example in PR3100, comment 18:

struct S { S() {}; virtual void xyzzy(); };
inline void foo(S *s) { s->xyzzy(); }
void bar() { S s; foo(&s); }

This involved four major changes:

1. In DefineUsedVTables, always mark virtual member functions as referenced for
   non-template classes and class template specializations.
2. In CodeGenVTables::ShouldEmitVTableInThisTU return true if optimizations are
   enabled, even if the key function is not implemented in this translation
   unit. We don't ever do this for code compiled with -fapple-kext, because we
   don't ever want to devirtualize virtual member function calls in that case.
3. Give the correct linkage for vtables where the key function is not defined.
4. Update the linkage for RTTI structures when necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124565 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGRTTI.cpp
lib/CodeGen/CGVTables.cpp
lib/CodeGen/CodeGenModule.cpp
lib/Sema/SemaDeclCXX.cpp
test/CodeGenCXX/vtable-available-externally.cpp [new file with mode: 0644]