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]

[ast-optimizer-branch] Fixed bootstrapping problems [patch]


The attached patch fixes all the bootstrapping problems we've
been having with -ftree-ssa.  With this patch we can bootstrap
all the default front ends and run c-torture with no regressions[1].

Main fixes:

- All the expressions in a STMT_EXPR and the header expressions
  of control statement nodes are unshared before simplification.
  The only expressions that are not unshared are STMT_EXPR and
  SAVE_EXPR nodes.

- Expressions are simplified by re-writing the given expression.
  The simplifier completely removes SAVE_EXPR nodes from the
  code.

- Control statements are simplified in execution order.
  Otherwise, if the same SAVE_EXPR is shared by the header and
  the body of the statement, simplifying the body first will
  cause the header expression to use an uninitialized variable.
  
- Simplification exposes what I think is a bug in
  cp/pt.c:tsubst_template_parms.  The argument 'parms' should be
  tested for NULL values before de-referencing it.

- Added a new switch to -fdump-tree-simple: 'details'.  It
  produces extremely verbose output while simplifying statements.
  We should probably refine the output.

The patch is large, but most of the changes are due to interface
changes in all the simplify_* functions.

For now on I would ask people submitting patches to the
ast-optimizer-branch to first do a full bootstrap and regression
test with BOOT_CFLAGS="-g -O2 -ftree-ssa".  I have also modified
c-torture.exp to use -ftree-ssa.


Diego.


[1]  Well, no.  We fail to compile gcc.c-torture/compile/20001226-1.c
     because simplification causes the RTL optimizers to grow to about
     600Mb and the whole thing takes more than 5 minutes to run.
     I'm going to be looking at performance and memory
     utilization next.


	* c-decl.c (c_expand_body): Close dump file before simplifying the
	function.
	* c-pretty-print.c (dump_c_node): Handle COMPLEX_CST,
	BIT_FIELD_REF, COMPLEX_EXPR, CONJ_EXPR, REALPART_EXPR,
	IMAGPART_EXPR and VA_ARG_EXPR nodes.
	Display all type casts, not just pointer casts.
	(op_prio): Handle LROTATE_EXPR, RROTATE_EXPR, REALPART_EXPR and
	IMAGPART_EXPR.
	* c-simplify.c: Include "tree-inline.h"
	(dump_file): New local variable.
	(dump_flags): New local variable.
	(stmt_expr_level): New local variable.
	(simplify_tree): Open and close dump file if
	-fdump-tree-simple-details is given.
	Initialize stmt_expr_level.
	(simplify_stmt): Dump statement before and after simplification if
	-fdump-tree-simple-detail is given.
	Unshare the expression of an EXPR_STMT before simplifying it.
	Call simplify_return_stmt to handle RETURN_STMT nodes.
	Do not simplify DECL_STMT nodes.
	Call stmt_has_effect before re-chaining side effects.
	(simplify_for_stmt): Do not return the simplified statement.
	Update all callers.
	Simplify FOR_BODY after the headers.
	Unshare loop header expressions before simplification.
	(simplify_while_stmt): Do not return the simplified statement.
	Update all callers.
	Simplify WHILE_BODY after the headers.
	Unshare the loop header expression before simplification.
	(simplify_do_stmt): Do not return the simplified statement.  Update
	all callers.
	Unshare the loop header expression before simplification.
	(simplify_if_stmt): Do not return the simplified statement.  Update
	all callers.
	Simplify the condition expression before the clauses.
	Unshare the condition expression before simplification.
	(simplify_switch_stmt): Do not return the simplified statement.
	Update all callers.
	Simplify the switch expression before the body.
	Unshare the switch expression before simplification.
	(simplify_decl_stmt): Remove.
	(simplify_expr): Remove argument 'needs_lvalue'.
	Add argument 'stmt'.
	Replace first argument 'expr' with a pointer to the
	expression 'expr_p'.
	Do not return the simplified expression.
	Update all callers and uses.
	Handle TRUTH_NOT_EXPR nodes.  Simplify SAVE_EXPR nodes into a
	SIMPLE id and remove the SAVE_EXPR node.
	Do not simplify BIT_FIELD_REF nodes.
	Remove code that tried to create new lvalues.
	(simplify_array_ref): Replace first argument 'expr' with a pointer
	to the expression 'expr_p'.
	Do not return the simplified expression.
	Add argument 'stmt'.
	Update all callers and uses.
	(simplify_self_mod_expr): Replace first argument 'expr' with a
	pointer to the expression 'expr_p'.
	Do not return the simplified expression.
	Add argument 'stmt'.
	Update all callers and uses.
	Call simplify_lvalue_expr to simplify a copy of the LHS into an
	lvalue for the new assignment.
	Simplify the new binary expression.
	(simplify_component_ref): Replace first argument 'expr' with a
	pointer to the expression 'expr_p'.
	Do not return the simplified expression.
	Add argument 'stmt'.
	Update all callers and uses.
	(simplify_call_expr): Ditto.
	(simplify_tree_list): Ditto.
	(simplify_cond_expr): Ditto.
	Build a replacement IF_STMT and call simplify_if_stmt() to process
	it.  Set the line number of the new statement from the statement
	containing the original expression.
	(simplify_modify_expr): Replace first argument 'expr' with a
	pointer to the expression 'expr_p'.
	Do not return the simplified expression.
	Add argument 'stmt'.
	Update all callers.
	Call simplify_lvalue_expr to simplify the LHS of the assignment.
	(simplify_boolean_expr): Replace first argument 'expr' with a
	pointer to the expression 'expr_p'.
	Do not return the simplified expression.
	Add argument 'stmt'. 
	Update all callers.
	Build a new IF_STMT and simplify it all at once by calling
	simplify_if_stmt.
	(simplify_compound_expr): Replace first argument 'expr' with a
	pointer to the expression 'expr_p'.
	Do not return the simplified expression.
	Add argument 'stmt'. 
	Update all callers.
	(simplify_expr_wfl): Ditto.
	(simplify_lvalue_expr): New function.
	(add_tree): Create a copy of each expression before adding it to
	the list.
	(deep_copy_node): Call copy_tree_r to copy expression nodes.
	(stmt_has_effect): Return nonzero if the statement may be the last
	statement of a statement expression body.
	(mostly_copy_tree_r): New function.
	* tree-dump.c (dump_options): Add 'details'.
	* tree-simple.c: Update documentation about ADDRESSOF expressions.
	(is_simple_stmt): Test for SIMPLE values when checking return
	statements.
	Accept all DECL_STMT nodes.
	(is_simple_compstmt): Return nonzero if T is NULL.  Do not test
	DECL_STMT nodes
	(is_simple_expr): Return nonzero if T is NULL.
	(is_simple_rhs): Ditto.
	(is_simple_modify_expr): Ditto.
	(is_simple_modify_expr_lhs): Ditto.
	(is_simple_binary_expr): Ditto.
	(is_simple_cond_expr): Ditto.
	(is_simple_unary_expr): Call STRIP_NOPS before testing T.
	Always accept ADDR_EXPR nodes.
	Always accept BIT_FIELD_REF nodes.
	(is_simple_call_expr): Return nonzero if T is NULL.
	(is_simple_const): Ditto.
	(is_simple_val): Ditto.
	(is_simple_compref): Ditto.
	(is_simple_compref_lhs): Ditto.
	(is_simple_cast): Ditto.
	(is_simple_cast_op): Ditto.
	(is_simple_id): Return nonzero if T is NULL.  Allow identifiers
	wrapped inside NON_LVALUE_EXPR and EXPR_WITH_FILE_LOCATION nodes.
	Allow real and imaginary parts of a complex variable. 
	Allow compound literals.
	(is_simple_arrayref): Allow arrays of complex types.
	* tree.h (TDF_DETAILS): Define.
	* cp/pt.c (tsubst_template_parms): Check that 'parms' is non-NULL
	before calling TMPL_PARMS_DEPTH.
	* doc/invoke.texi: Document -fdump-tree-simple-details.

In testsuite/ChangeLog:

2002-05-27  Diego Novillo  <dnovillo@redhat.com>

	* lib/c-torture.exp: Add -ftree-ssa to compiler flags.

Attachment: 20020527-bootstrap-fixes.diff.gz
Description: application/gunzip


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