Reduce function deferral in g++
Geoffrey Keating
geoffk@apple.com
Tue May 25 11:14:00 GMT 2004
On 24/05/2004, at 6:18 PM, Jason Merrill wrote:
> On Mon, 24 May 2004 13:54:36 -0700 (PDT), gkeating@apple.com (Geoffrey
> Keating) wrote:
>
>> * pt.c (mark_decl_instantiated): Only call defer_fn if
>> the function actually needs processing in finish_file.
>
> I'm pretty sure this is wrong; this looks like it would avoid emitting
> members of an explicitly instantiated template class.
I was somewhat surprised to find out that this is not, in fact, true.
What happens is that every time mark_decl_instantiated is called, it is
called like this:
mark_decl_instantiated (result, extern_p);
repo_template_instantiated (result, extern_p);
if (! extern_p)
instantiate_decl (result, /*defer_ok=*/1);
and instantiate_decl actually does the work of outputting the function,
through a complicated mechanism.
[I also checked this with a testcase, and I found that
template <class T> class Z {
T foo () { return 2; }
};
template class Z<char>;
does in fact output Z<char>::foo().]
> However, I don't see any reason to defer the function if extern_p is
> true.
Now I'm beginning to wonder if we need to call defer_fn here at all.
More information about the Gcc-patches
mailing list