[PATCH] Fix memory/compile-time explosion at -O0

Eric Botcazou ebotcazou@act-europe.fr
Fri Jan 23 13:20:00 GMT 2004


A small Ada testcase (~100 lines) trimmed down by Olivier from a big 
proprietary one compiles instantly with GNAT 3.x but exhausts all the memory 
with recent versions of GCC.  The explosion occurs in the folder and is due 
to a deep recursion between fold and fold_binary_op_with_conditional_arg.

The Ada front-end builds a big tree containing mainly COND_EXPR nodes to 
compute the size of a discriminated type with many variant parts and calls 
fold at each step to simplify it.  Now fold_binary_op_with_conditional_arg 
sometimes inserts a unnecessary COMPOUND_EXPR, which subsequently prevents 
the folding of the COND_EXPR nodes.

The regression was introduced by

2002-10-22  Nathan Sidwell  <nathan@codesourcery.com>

        PR c++/7209
        * fold_const.c (fold_binary_op_with_conditional_arg): Always
        build compound_expr if we used save_expr.

See http://gcc.gnu.org/ml/gcc-patches/2002-10/msg01120.html

The patch ensures that a COMPOUND_EXPR is built only when the expression is 
really a SAVE_EXPR.  It was bootstrapped/regtested on i586-redhat-linux-gnu 
(mainline, all default languages).  OK for mainline and 3.4 branch?

2004-01-23  Eric Botcazou  <ebotcazou@act-europe.fr>
            Olivier Hainque  <hainque@act-europe.fr>

	* fold-const.c (fold_binary_op_with_conditional_arg): Only
	build a COMPOUND_EXPR if 'arg' is really a SAVE_EXPR.

Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fold_const.diff
Type: text/x-diff
Size: 1064 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040123/5931fa80/attachment.bin>

More information about the Gcc-patches mailing list