[cfe-dev] Explicit instantiation declarations/definitions and optimizations

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Sat Sep 19 20:33:30 PDT 2015


On Sat, Sep 19, 2015 at 8:15 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Sat, Sep 19, 2015 at 6:15 PM, David Blaikie via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> I was just thinking through the possible advice of encouraging users to
>> use explicit template instantiation declarations/definitions to reduce
>> object size.
>>
>> It seems this may hurt performance in non-LTO builds by causing what were
>> inlinable functions to no longer be available for inlining.
>>
>> Should we consider emitting available_externally definitions of such
>> entities (possibly under specific/higher optimization levels)?
>>
>
> We should, and we already do: http://goo.gl/V8G5kU
>
> Do you have a case where we fail to do so? It's possible there's a bug in
> this determination.
>

Sorry, yes, should've included my test case, which boiled down to:

template <typename T> void f() {}
extern template void f<int>(); void g() { f<int>(); }

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.

- Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150919/5a06dae6/attachment.html>


More information about the cfe-dev mailing list