[cfe-users] optimize template-heavy project with duplicate code removal

David Blaikie via cfe-users cfe-users at lists.llvm.org
Wed Sep 23 16:59:04 PDT 2015

debug or non-debug build?

& no, for a full release build, measuring the final executable size,
there's not much you can do with the compiler.

you can try to factor common portions out of your templates (eg: remove
template parameters where possible - if, for example, a member function of
a class template doesn't need all the template parameters - pull it out
into a standalone function template that takes fewer template parameters,
and call it from the member one)

On Wed, Sep 23, 2015 at 4:43 PM, chen xu via cfe-users <
cfe-users at lists.llvm.org> wrote:

> Hi, our project heavily uses c++ template, and the resulting executable is
> almost 1.5G Bytes, which is too big to be acceptable. Adding -O2 or -Os
> does not seem helping. Is there any way (like link option, etc) to reduce
> the size?
> _______________________________________________
> cfe-users mailing list
> cfe-users at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20150923/ce57bc86/attachment.html>

More information about the cfe-users mailing list