[PATCH][C++] Fix PR29433, make C++ use a lot less time/memory

Richard Guenther rguenther@suse.de
Wed Nov 29 23:04:00 GMT 2006

On Wed, 29 Nov 2006, Mike Stump wrote:

> On Nov 28, 2006, at 8:18 AM, Richard Guenther wrote:
> >This patch is the Nth try to attack the problems around
> >classtype_mangled_name
> Sounds like a very worth while goal.
> >so, if you compile the testcase with -O0 you end up with a maximum virtual
> >memory usage of around 2.5GB
> :-( Ouch.
> >if you add -g to that it'll jump to 3.9GB (because dwarf2out.c thinks
> >xstrduping all identifiers again is a good idea).
> Hum...  Would be nice to teach dwarf to use gc so that it never has to xstrdup
> a C++ symbol name.  It the original radar doesn't cover dwarf, want to file
> one for it?

I think the strdups of IDENTIFIER_NODEs strings are unnecessary anyway as
we never free them (they're obstack allocated).  I'll send a patch for 
this later.

> >Mike, it looks like you invented mangle_class_name_for_template
> I did?  Why you think that?  I would have thought Ken Raeburn did.  I tried to
> fetch the bits from svn/cvs/oldgcc but didn't find bits old enough.  :-(  I
> didn't think I did up that code.

svn annotate lists you along the oldest revision it has (which includes
oldgcc I think):

6613        mrs static char *
 68174    neroden mangle_class_name_for_template (const char* name, tree 
tree arglist)
  6613        mrs {
  6613        mrs   static struct obstack scratch_obstack;
  6613        mrs   static char *scratch_firstobj;

but svn log just shows

r6613 | mrs | 1994-02-24 02:02:37 +0100 (Thu, 24 Feb 1994) | 2 lines

Initial revision

so - maybe you did the oldgcc initial import ;)

> Would be nice to revisit mangling in general and maybe come up with tree style
> representation instead that doesn't use much space, brownie points for
> teaching the assembler and linker to deal with them as well.

I tried to go that route (or at least partly), but we use DECL_NAME in
quite much places for interesting things throughout the C++ frontend :(

So this patch is the best I could come up with (we can reduce the overhead
of mangle_class_name_for_template a bit further).


Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs

More information about the Gcc-patches mailing list