C++ Patch: Speed Template Instantiation

Jeffrey Oldham oldham@codesourcery.com
Thu Jan 16 22:16:00 GMT 2003


2003-01-16  Jeffrey D. Oldham  <oldham@codesourcery.com>

	* cp-tree.h (tsubst_copy_and_build): New declaration.
	* pt.c (tsubst_copy): Remove 'build_expr_from_tree' from comment.
	(tsubst_expr): Use 'tsubst_copy_and_build'.  Update initial comment.
	(tsubst_copy_and_build): New function.

Approved by	Mark Mitchell (CodeSourcery, LLC)
Tested on	i686-pc-linux-gnu by building C++ code and libstdc++-v3 and 
running C++ regression tests.

This patch speeds compilation by eliminating one round of unnecessary 
tree construction during template substitution.  Effectively, 
tsubst_copy_and_build is the functional composition of 
build_expr_from_tree and tsubst_copy.  When compiling one random source 
file, the number of calls to ggc-page.c:ggc_alloc() was reduced from 
997362 to 995776 (0.16% decrease).  The running times were reduced by 0.92%:

before patch:    8.11    8.13    8.00    8.01    8.04    av: 8.058
after  patch:    7.96    8.03    7.93    8.04    7.96    av: 7.984

Eventually, tsubst_copy and build_expr_from_tree will be completely 
removed from the C++ front end in favor of tsubst_copy_and_build.  Some 
minor clean-up steps need to occur before the removals.

Jeffrey D. Oldham
oldham@codesourcery.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: template.15Jan.16.1.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030116/1d410b18/attachment.ksh>


More information about the Gcc-patches mailing list