Richard Guenther - Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing 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] |
- From: Richard Guenther
- To: Michael Matz
- Cc: Mark Mitchell , Daniel Jacobowitz , Gabriel Dos Reis , gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Feb 2007 15:39:00 +0100 (CET)
- Subject: Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- References: 457D726E.7060905@redhat.com Pine.LNX.4.64.0612111628100.3105@zhemvz.fhfr.qr <Pine.GSO.4.58.0612110926270.19022@sun> Pine.LNX.4.64.0612111635030.3105@zhemvz.fhfr.qr 457D7AB1.10706@redhat.com Pine.LNX.4.64.0612111647520.3105@zhemvz.fhfr.qr 20061211155733.GA2660@nevyn.them.org Pine.LNX.4.64.0612111658590.29962@wotan.suse.de 20061211174548.GA7094@nevyn.them.org Pine.LNX.4.64.0612121519200.29962@wotan.suse.de 20061212150652.GA18750@nevyn.them.org Pine.LNX.4.64.0612121723070.29962@wotan.suse.de 457EF130.5040902@codesourcery.com Pine.LNX.4.64.0612131535100.29962@wotan.suse.de 4580405A.4000109@codesourcery.com <Pine.LNX.4.64.0702201500170.25448@wotan.suse.de>
On Tue, 20 Feb 2007, Michael Matz wrote:
Hi,
On Wed, 13 Dec 2006, Mark Mitchell wrote:
Nobody is arguing that DW_AT_name should be the huge string for the long term. However, I would argue that it should stay that huge string until we add the template arguments to debug info, and until GDB understands that information.
Okay, so the attached patch does that. On the testcase from PR29433 it has these results (on x86_64, but with -m32):
trunk, -O0, total: 1403994 kB (3:00 min) patched, -O0, total: 353658 kB (1:11 min) trunk, -O0 -g, total: 2539302 kB (3:17 min) patched, -O0 -g, total: 1668378 kB (2:32 min)
So it saves between 900MB and 1.1 GB :) [It also saves memory with -g because the strings are ggc_stddup'd again] I've removed the hand-crafted mangle_class_name_for_template and classtype_mangled_name functions and instead used the diagnostics machinery for real by not simply looking at DECL_NAME of a type (in dwarf2out), but instead use the dwarf_name langhook there. In C that will be equivalent to using DECL_NAME in C++ it will call cxx_printable_name, which prints nice (long) names for complicated types. The verbosity needs to be 2 for that, and instead of adding yet another langhook or wrapper function which is called just once, I've called it directly.
There are small differences in the names as formerly produced and those now produced, when scopes enter the game:
Typical changes are ("-" is old, "+" is new):
.string "._16"
.string "<anonymous struct>::<anonymous union>"
.string "_Ios_Openmode"
.string "std::_Ios_Openmode"
.string "new_allocator<char>"
.string "__gnu_cxx::new_allocator<char>"
.string "_Rep"
.string "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep"
.string "Category"
.string "QChar::Category"
(Overall there are only 184 changes in the PR29433 testcase)
That results in some gdb testsuite errors, where it doesn't look for the qualified symbol name, but those should be easily fixable.
The patch contains one unrelated fix, so that it doesn't call ggc_strdup needlessly even if the node was found in the hashtable already.
Bootstrapped, regtested on x86_64-linux.
Ciao, Michael.
* dwarf2out.c (add_AT_string): Call ggc_strdup once per string. (type_tag): Use lang_hooks.dwarf_name instead of DECL_NAME. * pt.c (classtype_mangled_name, mangle_class_name_for_template): Remove functions. (push_template_decl_real, lookup_template_class): Remove calls to above functions.
There's also still pending the following which we may want for backward compatibility.
Richard.
2007-02-20 Richard Guenther rguenther@suse.de
* class.c (note_name_declared_in_class): Make declaration
changes meaning a pedwarn.
* g++.dg/warn/changes-meaning.C: New testcase.
Index: cp/class.c
--- cp/class.c (revision 121946) +++ cp/class.c (working copy) @@ -6299,9 +6299,9 @@ note_name_declared_in_class (tree name, A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. */ - error ("declaration of %q#D", decl); - error ("changes meaning of %qD from %q+#D", - DECL_NAME (OVL_CURRENT (decl)), (tree) n->value); + pedwarn ("declaration of %q#D", decl); + pedwarn ("changes meaning of %qD from %q+#D", + DECL_NAME (OVL_CURRENT (decl)), (tree) n->value); } } Index: testsuite/g++.dg/warn/changes-meaning.C
*** testsuite/g++.dg/warn/changes-meaning.C (revision 0) --- testsuite/g++.dg/warn/changes-meaning.C (revision 0)
*** 0 **** --- 1,11 ----
- /* { dg-do compile } */
- /* { dg-options "-fpermissive" } */
- template class auto_ptr {}; /* { dg-warning "changes meaning" } */
- template
- class counted_ptr
- {
- public:
- auto_ptr<_Tp> auto_ptr(); /* { dg-warning "" } */
- };
- References:
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
* From: Michael Matz
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |