ccing cfe-commits On 26 August 2013 21:44, Rafael Espíndola <[email protected]> wrote: > I finally got back to pr13124. > > Last time it was discussed > (http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022606.html) > John was in favor of emitting a copy of the function when emitting the > available_externally vtable. The folks working on the equivalent gcc > bug (gcc.gnu.org/pr53808) agree, so I started trying to implement this > in clang. > > The first issue I hit is that if codegen is going to output a > function, sema has to mark it used. Given llvm.org/pr9114, it looks > like sema cannot be more aggressive at marking functions used because > of vtables. > > This leaves us with a few unpleasant options: > > * Marking functions in vtables used if possible. This sounds a bit > sloppy, so I would like to avoid it. > * Producing available_externally vtables only when all the functions > in it are already used or weak_odr. This would cover cases like > > -------------------- > struct foo { > virtual ~foo(); > }; > struct bar : public foo { > virtual void zed(); > }; > void f() { > foo *x(new bar); > delete x; > } > void g(bar *x) { > x->~bar(); // force the destructor to be used > } > -------------------------- > > and > > ---------------------------------- > template<typename T> > struct bar { > virtual ~bar(); > }; > template<typename T> > bar<T>::~bar() { > } > extern template class bar<int>; // make the destructor weak_odr > instead of linkonce_odr > void f() { > bar<int> *x(new bar<int>); > delete x; > } > ---------------------------- > > These look like corner cases, so it is unclear if it is worth it. > > * And finally: Just nuke this optimization. That is what this patch > implements. > > Cheers, > Rafael
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
