This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: make_decl_one_only and inlining
- From: Ian Lance Taylor <iant at google dot com>
- To: Johannes Pfau <johannespfau at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 15 Feb 2013 13:39:21 -0800
- Subject: Re: make_decl_one_only and inlining
- References: <loom.20130215T183607-580@post.gmane.org>
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