<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Feb 13, 2013, at 4:27 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><blockquote type="cite">On Wed, Feb 13, 2013 at 4:16 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div><div class="h5"><div>On Feb 13, 2013, at 3:40 PM, Nick Lewycky <<a href="mailto:nlewycky@google.com" target="_blank">nlewycky@google.com</a>> wrote:</div><blockquote type="cite">
<div dir="ltr">On 13 February 2013 10:53, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><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>On Feb 13, 2013, at 12:53 AM, Nick Lewycky <<a href="mailto:nlewycky@google.com" target="_blank">nlewycky@google.com</a>> wrote:<br>
> Thinking about this issue more, I'd like to retract this patch. Consider the case where we're implementing the rule that all ODR-used inline functions must have a definition. If Derived::fn is marked inline, we'll see a fictitious use of it and reject a valid translation unit.<br>



><br>
> My next plan is to remove this code from Sema entirely and do the equivalent work inside codegen proper. No reason it can't keep track of probable virtual function targets when writing out a virtual dispatch.<br>



<br>
</div>Ugh.  I am not thrilled by the idea of emitting massive amounts of code because something *might* devirtualize to it.<br>
<br>
Also, this potentially requires template instantiation.<br></blockquote><div><br></div><div>Me neither. However, Sema and CodeGen are already colluding to do this. See SemaExpr.cpp:11168 (MarkExprReferenced), which may trigger instantiation, and CGExprCXX.cpp:200 (EmitCXXMemberCallExpr) which assumes the potential callee was already instantiated.</div>


</div></div></div></blockquote><div><br></div></div></div>If we're willing to break some of the majestic beauty of the frontend-isolated optimizer, we could queue up a late module pass which</div><div>1) recognizes that we've emitted a reference to something that we're required to define in every translation unit that references it (easy to do with metadata),</div>
<div>2) goes back to Sema and IR-gen to produce that code, and</div><div>3) restarts the optimizer on the new functions.</div><div>Repeat until hopefully-rapid convergence.</div></div></blockquote><div><br></div><div>That sounds like a path to optimization-dependent diagnostics, which we have previously gone to lengths to avoid. This case seems less severe, since it is likely that the diagnostics will be produced in *some* translation unit, but I still find it concerning.</div>
</div>
</blockquote></div><br><div>Do we really want to instantiate basically every virtual function in the translation unit even at -O0 just so that we can have a stable set of diagnostics?</div><div><br></div><div>Do you have any estimates at all about how much extra code you'll be generating in an average translation unit?</div><div><br></div><div>John.</div></body></html>