<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-28 17:58 GMT-07:00 Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Wed, May 28, 2014 at 4:00 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class=""><br>
> On 2014-May-28, at 15:48, Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> wrote:<br></div><div class="">
> Emitting all inline functions seems like it will require semantic changes and it's overkill. The specific case I'm thinking of is:<br>
> #include <memory><br>
> struct Bar;<br>
> struct Foo {<br>
> Foo(Bar *b) : p(b) {}<br>
> std::unique_ptr<Bar> p;<br>
> };<br>
><br>
> We need to require a complete type for Bar if we want to emit ~Foo, because ~unique_ptr<Bar> deletes Bar, but we don't require that currently.<br>
<br>
</div></div><div class="">Hmm... nice catch. This would not be a good thing.</div></blockquote><div><br></div><div>A more accurate reduction:</div><div><br></div><div><div>template <typename T></div><div>struct my_unique_ptr {</div>
<div> my_unique_ptr(T *p) : p(p) {}</div>
<div> ~my_unique_ptr() { delete p; }</div><div> T *p;</div><div>};</div><div>struct Bar;</div><div>struct Foo {</div><div> Foo();</div><div> my_unique_ptr<Bar> p;</div><div>}</div></div></div></div></div></blockquote>
<div><br></div><div>This compiles without problems with my patch - the constructor and destructor of my_unique_ptr are never instrumented.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>My original constructor would have instantiated ~unique_ptr<Bar> from the inline ctor.</div><div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>
> I don't know the details of coverage, but is there another way to represent "I saw this inline function, but nobody called it"? My straw man suggestion is to emit a single counter for the entry block that will either always be zero or be comdat merged with another TU that uses the inline function.<br>
<br>
</div>That's an interesting idea, but when inline functions are used, the counters<br>
are declared `linkonce_odr` so that they'll coallesce between TUs. This<br>
sounds like it would violate the ODR. Something similar might work though.<br>
Hmm.</blockquote><div><br></div></div><div>They should actually be weak_odr if you don't want them to be discarded. IMO this is better than @llvm.used, which has pretty weird semantics.</div><div><br></div><div>I don't know enough about what goes into the counters to figure out the odr issue.</div>
</div></div></div>
</blockquote></div><br></div></div>