This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Improve PR29433, don't duplicate identifier names in dwarf2out


This patch changes dwarf2out.c to not duplicate the strings in
identifier nodes as these are collected in an obstack that is never freed.
dwarf2out.c never frees any of the xstrduped stuff either.

This brings compile-time memory usage of PR29433 with -O0 -g down from
3.9GB to 2.5GB which is about the same as for a -O0 compile.  (See the
C++ patch for PR29433 on how to bring this down to around 400MB).

Bootstrapped on x86_64-unknown-linux-gnu, tests still running.

Ok for mainline if they pass?

Thanks,
Richard.

:ADDPATCH debug:

2006-11-30  Richard Guenther  <rguenther@suse.de>

	PR c++/29433
	* dwarf2out.c (struct pubname_struct): Make name const.
	(add_pubtype): Do not xstrdup identifiers.

Index: dwarf2out.c
===================================================================
*** dwarf2out.c	(revision 119362)
--- dwarf2out.c	(working copy)
*************** die_node;
*** 3756,3762 ****
  typedef struct pubname_struct GTY(())
  {
    dw_die_ref die;
!   char *name;
  }
  pubname_entry;
  
--- 3756,3762 ----
  typedef struct pubname_struct GTY(())
  {
    dw_die_ref die;
!   const char *name;
  }
  pubname_entry;
  
*************** add_pubtype (tree decl, dw_die_ref die)
*** 7358,7369 ****
  	  if (TYPE_NAME (decl))
  	    {
  	      if (TREE_CODE (TYPE_NAME (decl)) == IDENTIFIER_NODE)
! 		e.name = xstrdup ((const char *) IDENTIFIER_POINTER 
! 				                              (TYPE_NAME (decl)));
  	      else if (TREE_CODE (TYPE_NAME (decl)) == TYPE_DECL
  		       && DECL_NAME (TYPE_NAME (decl)))
! 		e.name = xstrdup ((const char *) IDENTIFIER_POINTER 
! 				                  (DECL_NAME (TYPE_NAME (decl))));
               else
  	       e.name = xstrdup ((const char *) get_AT_string (die, DW_AT_name));
  	    }
--- 7358,7367 ----
  	  if (TYPE_NAME (decl))
  	    {
  	      if (TREE_CODE (TYPE_NAME (decl)) == IDENTIFIER_NODE)
! 		e.name = IDENTIFIER_POINTER (TYPE_NAME (decl));
  	      else if (TREE_CODE (TYPE_NAME (decl)) == TYPE_DECL
  		       && DECL_NAME (TYPE_NAME (decl)))
! 		e.name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (decl)));
               else
  	       e.name = xstrdup ((const char *) get_AT_string (die, DW_AT_name));
  	    }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]