aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2000-04-28 06:40:28 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2000-04-28 06:40:28 +0000
commit27c58e25f7525fbd9aa7e5db08c9e60a9d825402 (patch)
tree8fb94ae8beb2c4383007b1de702a7846556c1e3d
parent26026d3803c021234bb9ce9b46cba8792764b758 (diff)
downloadgcc-27c58e25f7525fbd9aa7e5db08c9e60a9d825402.zip
gcc-27c58e25f7525fbd9aa7e5db08c9e60a9d825402.tar.gz
gcc-27c58e25f7525fbd9aa7e5db08c9e60a9d825402.tar.bz2
optimize.c (copy_body_r): Use STRIP_TYPE_NOPS when copying variables.
* optimize.c (copy_body_r): Use STRIP_TYPE_NOPS when copying variables. (initialize_inlined_parameters): Try to avoid creating new VAR_DECLs. From-SVN: r33505
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/optimize.c36
2 files changed, 41 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fdad422..c556a21 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2000-04-27 Mark Mitchell <mark@codesourcery.com>
+
+ * optimize.c (copy_body_r): Use STRIP_TYPE_NOPS when copying
+ variables.
+ (initialize_inlined_parameters): Try to avoid creating new
+ VAR_DECLs.
+
2000-04-27 Alex Samuel <samuel@codesourcery.com>
* lex.c (my_get_run_time): Remove.
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 99545f8..9863d4a 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -306,6 +306,7 @@ copy_body_r (tp, walk_subtrees, data)
new_decl = remap_decl (*tp, id);
my_friendly_assert (new_decl != NULL_TREE, 19991203);
/* Replace this variable with the copy. */
+ STRIP_TYPE_NOPS (new_decl);
*tp = new_decl;
}
else if (nonstatic_local_decl_p (*tp)
@@ -384,7 +385,38 @@ initialize_inlined_parameters (id, args, fn)
{
tree init_stmt;
tree var;
-
+ tree value;
+
+ /* Find the initializer. */
+ value = TREE_VALUE (a);
+ /* If the parameter is never assigned to, we may not need to
+ create a new variable here at all. Instead, we may be able
+ to just use the argument value. */
+ if (TREE_READONLY (p) && !TREE_SIDE_EFFECTS (value))
+ {
+ /* Simplify the value, if possible. */
+ value = fold (decl_constant_value (value));
+
+ /* We can't risk substituting complex expressions. They
+ might contain variables that will be assigned to later.
+ Theoretically, we could check the expression to see if
+ all of the variables that determine its value are
+ read-only, but we don't bother. */
+ if (TREE_CONSTANT (value) || TREE_READONLY_DECL_P (value))
+ {
+ /* If this is a declaration, wrap it a NOP_EXPR so that
+ we don't try to put the VALUE on the list of
+ BLOCK_VARS. */
+ if (DECL_P (value))
+ value = build1 (NOP_EXPR, TREE_TYPE (value), value);
+
+ splay_tree_insert (id->decl_map,
+ (splay_tree_key) p,
+ (splay_tree_value) value);
+ continue;
+ }
+ }
+
/* Make an equivalent VAR_DECL. */
var = copy_decl_for_inlining (p, fn, VARRAY_TREE (id->fns, 0));
/* Register the VAR_DECL as the equivalent for the PARM_DECL;
@@ -400,7 +432,7 @@ initialize_inlined_parameters (id, args, fn)
object will be constructed in VAR. */
init_stmt = build_min_nt (EXPR_STMT,
build (INIT_EXPR, TREE_TYPE (p),
- var, TREE_VALUE (a)));
+ 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. */