<div dir="ltr">On Tue, Aug 27, 2013 at 5:35 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ccing cfe-commits<br>
<br>
On 26 August 2013 21:44, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
> I finally got back to pr13124.<br>
><br>
> Last time it was discussed<br>
> (<a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022606.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022606.html</a>)<br>
> John was in favor of emitting a copy of the function when emitting the<br>
> available_externally vtable. The folks working on the equivalent gcc<br>
> bug (<a href="http://gcc.gnu.org/pr53808" target="_blank">gcc.gnu.org/pr53808</a>) agree, so I started trying to implement this<br>
> in clang.<br>
><br>
> The first issue I hit is that if codegen is going to output a<br>
> function, sema has to mark it used. Given <a href="http://llvm.org/pr9114" target="_blank">llvm.org/pr9114</a>, it looks<br>
> like sema cannot be more aggressive at marking functions used because<br>
> of vtables.<br>
><br>
> This leaves us with a few unpleasant options:<br>
><br>
> * Marking functions in vtables used if possible. This sounds a bit<br>
> sloppy, so I would like to avoid it.<br>
> * Producing available_externally vtables only when all the functions<br>
> in it are already used or weak_odr. This would cover cases like<br>
><br>
> --------------------<br>
> struct foo {<br>
>   virtual ~foo();<br>
> };<br>
> struct bar : public foo {<br>
>   virtual void zed();<br>
> };<br>
> void f() {<br>
>   foo *x(new bar);<br>
>   delete x;<br>
> }<br>
> void g(bar *x) {<br>
>   x->~bar(); // force the destructor to be used<br>
> }<br>
> --------------------------<br>
><br>
> and<br>
><br>
> ----------------------------------<br>
> template<typename T><br>
> struct bar {<br>
>   virtual ~bar();<br>
> };<br>
> template<typename T><br>
> bar<T>::~bar() {<br>
> }<br>
> extern template class bar<int>; // make the destructor weak_odr<br>
> instead of linkonce_odr<br>
> void f() {<br>
>   bar<int> *x(new bar<int>);<br>
>   delete x;<br>
> }<br>
> ----------------------------<br>
><br>
> These look like corner cases, so it is unclear if it is worth it.<br>
><br>
> * And finally: Just nuke this optimization. That is what this patch implements.<br><br></blockquote><div>This assessment appears accurate.</div><div><br></div><div>-Eli </div></div></div></div>