<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Sep 19, 2015 at 8:33 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Sat, Sep 19, 2015 at 8:15 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Sat, Sep 19, 2015 at 6:15 PM, David Blaikie via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><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 dir="ltr"><span style="font-size:12.8px">I was just thinking through the possible advice of encouraging users to use explicit template instantiation declarations/definitions to reduce object size.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">It seems this may hurt performance in non-LTO builds by causing what were inlinable functions to no longer be available for inlining.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Should we consider emitting available_externally definitions of such entities (possibly under specific/higher optimization levels)?</span></div></blockquote><div><br></div></span><div>We should, and we already do: <a href="http://goo.gl/V8G5kU" target="_blank">http://goo.gl/V8G5kU</a></div><div><br></div><div>Do you have a case where we fail to do so? It's possible there's a bug in this determination.</div></div></div></div></blockquote></div></div><div><br>Sorry, yes, should've included my test case, which boiled down to:<br><br><pre style="color:rgb(0,0,0)">template <typename T> void f() {}
extern template void f<int>();
<span style="font-family:monospace,monospace">void g() { f<int>(); }</span><span style="font-family:monospace,monospace;color:rgb(34,34,34)"> </span></pre></div></div>The difference being the absence of the "inline" keyword on f's definition. I wonder if that's the right tradeoff (I can understand using the inline keyword to hint the inliner a little more strongly - but this seems like a much stronger dependence on the keyword than I'd expect). Perhaps it is.</div></div></blockquote><div><br></div><div>The C++ standard doesn't permit us to instantiate f<int> in this case; per [temp.explicit]/10,</div><div><br></div><div>"Except for inline functions, declarations with types deduced from their initializer or return value (<span class="">7.1.6.4</span>), const variables of literal types, variables of reference types, and class template specializations, explicit instantiation declarations have the effect of suppressing the implicit instantiation of the entity to which they refer."</div><div><br></div><div>So whether or not this is the right tradeoff, it's not our call to make. We emit function definitions available_externally in (more or less) all the cases that C++ lets us do so.</div>
</div></div></div>