Commit Graph

6 Commits

Author SHA1 Message Date
Anders Carlsson 43760c3d42 Add another test that we can fully devirtualize now.
llvm-svn: 124988
2011-02-06 20:16:20 +00:00
Anders Carlsson 73f97534b0 Pass a 'ForVTable' flag to GetAddrOfThunk and pass it along to GetOrCreateLLVMFunction so that we
won't assert when building a thunk for an implicit virtual member function that is not marked used.

llvm-svn: 124967
2011-02-05 18:48:55 +00:00
Anders Carlsson 3c23948481 Re-land r124768, with a fix for PR9130.
We now emit everything except unused implicit virtual member functions when building the vtable.

llvm-svn: 124935
2011-02-05 04:35:53 +00:00
Rafael Espindola af5b92e8f7 Revert 124768.
This reopens PR99114, but that one at least can be avoided with an #include.
PR9130 cannot.

llvm-svn: 124780
2011-02-03 06:30:58 +00:00
Anders Carlsson bac84bef65 Don't try to mark virtual members referenced for classes where the key function
is not defined in the current translation unit. Doing so lead to compile errors
such as PR9114.

Instead, when CodeGen is building the vtable, don't try to emit a definition
for functions that aren't marked used in the current translation unit.
Fixes PR9114.

llvm-svn: 124768
2011-02-03 02:08:44 +00:00
Anders Carlsson a03f3a85cb 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.

llvm-svn: 124565
2011-01-30 20:45:54 +00:00