C++ PATCH: Reduce memory usage when inlining
Jason Merrill
jason@cygnus.com
Mon May 1 16:49:00 GMT 2000
OK, that last patch broke libio, and I reverted it shortly after checking
it in; here's take 2. The tree.c hunk is just something I noticed while
looking at this.
2000-05-01 Jason Merrill <jason@casey.cygnus.com>
* tree.c (build_target_expr_with_type): If we already have a
TARGET_EXPR, just return it.
* optimize.c (initialize_inlined_parameters): Don't generate an
EXPR_STMT if we can just use DECL_INITIAL.
* decl.c (emit_local_var): Only make the initialization a
full-expression if stmts_are_full_exprs_p.
Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.193
diff -c -p -r1.193 tree.c
*** tree.c 2000/04/11 17:29:54 1.193
--- tree.c 2000/05/01 23:45:45
*************** build_target_expr_with_type (init, type)
*** 294,299 ****
--- 294,302 ----
tree slot;
tree rval;
+ if (TREE_CODE (init) == TARGET_EXPR)
+ return init;
+
slot = build (VAR_DECL, type);
DECL_ARTIFICIAL (slot) = 1;
DECL_CONTEXT (slot) = current_function_decl;
Index: optimize.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/optimize.c,v
retrieving revision 1.31
diff -c -p -r1.31 optimize.c
*** optimize.c 2000/05/01 16:51:17 1.31
--- optimize.c 2000/05/01 23:45:46
*************** initialize_inlined_parameters (id, args,
*** 429,449 ****
splay_tree_insert (id->decl_map,
(splay_tree_key) p,
(splay_tree_value) var);
/* Initialize this VAR_DECL from the equivalent argument. If
the argument is an object, created via a constructor or copy,
this will not result in an extra copy: the TARGET_EXPR
representing the argument will be bound to VAR, and the
object will be constructed in VAR. */
! init_stmt = build_min_nt (EXPR_STMT,
! build (INIT_EXPR, TREE_TYPE (p),
! var, value));
! /* Declare this new variable. Note that we do this *after* the
! initialization because we are going to reverse all the
! initialization statements below. */
! TREE_CHAIN (init_stmt) = build_min_nt (DECL_STMT, var);
! /* Add this initialization to the list. */
! TREE_CHAIN (TREE_CHAIN (init_stmt)) = init_stmts;
! init_stmts = init_stmt;
}
/* The initialization statements have been built up in reverse
--- 429,458 ----
splay_tree_insert (id->decl_map,
(splay_tree_key) p,
(splay_tree_value) var);
+
+ /* Declare this new variable. */
+ init_stmt = build_min_nt (DECL_STMT, var);
+ TREE_CHAIN (init_stmt) = init_stmts;
+ init_stmts = init_stmt;
+
/* Initialize this VAR_DECL from the equivalent argument. If
the argument is an object, created via a constructor or copy,
this will not result in an extra copy: the TARGET_EXPR
representing the argument will be bound to VAR, and the
object will be constructed in VAR. */
! if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
! DECL_INITIAL (var) = value;
! else
! {
! init_stmt = build_min_nt (EXPR_STMT,
! build (INIT_EXPR, TREE_TYPE (p),
! var, value));
! /* Add this initialization to the list. Note that we want the
! declaration *after* the initialization because we are going
! to reverse all the initialization statements below. */
! TREE_CHAIN (init_stmt) = init_stmts;
! init_stmts = init_stmt;
! }
}
/* The initialization statements have been built up in reverse
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.599
diff -c -p -r1.599 decl.c
*** decl.c 2000/05/01 06:01:33 1.599
--- decl.c 2000/05/01 23:45:57
*************** emit_local_var (decl)
*** 7871,7879 ****
}
/* Actually do the initialization. */
! expand_start_target_temps ();
expand_decl_init (decl);
! expand_end_target_temps ();
}
/* Finish processing of a declaration;
--- 7871,7883 ----
}
/* Actually do the initialization. */
! if (stmts_are_full_exprs_p)
! expand_start_target_temps ();
!
expand_decl_init (decl);
!
! if (stmts_are_full_exprs_p)
! expand_end_target_temps ();
}
/* Finish processing of a declaration;
More information about the Gcc-patches
mailing list