PATCH Re: [ast-optimizer-branch]: Simplify STMT_EXPR's

Jason Merrill jason@redhat.com
Wed Jun 19 03:25:00 GMT 2002


Here's a new patch for this.  Some notes:

Daniel's earlier patch would find the last EXPR_STMT at arbitrary depth.
I don't see anything in the docs or existing practice to suggest that
the return value can be nested further under the initial block, so I only
look there.

In this patch I haven't tried to preserve source position information for
inlined functions, because we don't support wrapping _STMTs in
EXPR_WITH_FILE_LOCATION.  One obvious direction would be to support that.
I don't see a good way to use FILE_STMT to handle this, as we aren't
tracking source position during simplification.  On the other hand, perhaps
we should be.

I ran into trouble with bogus TREE_ANN information on statements in inlined
functions; the annotation info is allocated using the GC code, but is never
marked, which means that after the inline function has been compiled, all
the TREE_ANN fields in its tree structure are pointing to freed memory.
I've worked around this by clearing the aux field in copy_tree_r; a better
fix would be to mark it properly for GC.

Tested i686-pc-linux-gnu.

2002-06-19  Jason Merrill  <jason@redhat.com>

	* c-simplify.c (simplify_stmt_expr): New fn.
	(simplify_expr): Call it.
	(stmt_expr_level): Remove.
	(stmt_has_effect, c_simplify_function_tree): Remove refs.
	(expr_has_effect): Deal with null expression.
	(simplify_expr_wfl): If the subexpression is simplified away, drop
	this one, too.
	* tree-simple.c (is_simple_unary_expr): Don't allow a STMT_EXPR.
	* tree-inline.c (copy_tree_r): Clear the aux field in the copies.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-patch
Size: 6468 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020619/2b512bf9/attachment.bin>


More information about the Gcc-patches mailing list