throw(), pure and const flags on functions
Jan Hubicka
hubicka@ucw.cz
Tue Apr 14 14:47:00 GMT 2009
> Hi Honza,
> > For shared library we won't be able to derive this ourselves even with
> > LTO since these are in fact part of ABI too. So we IMO should decorate
> > the functions implemented in libstdc++ library itself (not the headers).
> >
> Let's make sure I understand your point. You are saying: for the
> headers, there are hopes that the compiler can do a good work on its
> own. On the other hand, for the library itself, the *.so in particular,
> there are no hopes, even with LTO. Thus, I would say, adding a few
> decorations in the *.cc files, in such cases when either performance or
Only functions both defined and used within single compilation unit are
fine without decorations. LTO change definition of compilation unit to
"whole program without shared libraries".
Functions declared in libstdc++ header and defined in libstdc++ .cc file
do not belong to this category. If you decorate such function with
attribute in the libstdc++ header, GCC will be able to optimize better
programs that do use it (either directly or indirectly via inline
function in libstdc++ header).
The RB tree function I mentioned originally is good example of it. It
is helper for template that is otherwise in header but it is in .cc
file, so every program that do use the template is compiled
suboptimally making GCC believe that rbtree accestors can have arbitrary
side effects.
Honza
> code size is demonstrably improved, makes sense to me. Are there any
> chances you can suggest something yourself with some numbers attached?
>
> Thanks,
> Paolo.
More information about the Libstdc++
mailing list