make_decl_one_only and inlining
Ian Lance Taylor
iant@google.com
Fri Feb 15 21:39:00 GMT 2013
On Fri, Feb 15, 2013 at 9:57 AM, Johannes Pfau <johannespfau@gmail.com> wrote:
>
> We recently got a bug report for the GCC D compiler frontend which shows that we
> currently don't inline any templated functions. The reason seems to be that
> decl_replaceable_p always returns true for D template functions.
Why is that? decl_replaceable_p is supposed to be true for a function
that may be replaced by an entirely different function at runtime.
This is mainly to implement the correct semantics for weak functions.
You can't inline a weak function, but at runtime the runtime linker
might have resolved the weak function to something completely
different.
> So what's the best/preferred way to put out template function instances so that:
> * Instances in different objects files are merged
> * GCC can still inline such functions
> * Force the instances to be put out, even if they seem to be not used
Set DECL_COMDAT. You said that didn't work but you didn't fully
explain why. A DECL_COMDAT function should be output in every object
file in which it is referenced.
Ian
More information about the Gcc
mailing list