diff options
author | Martin Jambor <mjambor@suse.cz> | 2016-01-15 13:43:49 +0100 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2016-01-15 13:43:49 +0100 |
commit | 8f634fb4f1becd81e712775512f26888c4e6900d (patch) | |
tree | 4e93e8a68ee3c2eba698a0a56e941ce8e240c2c7 /gcc/tree-inline.c | |
parent | aa189aee2e2c2602bf2eef67291c1f56273252b5 (diff) | |
download | gcc-8f634fb4f1becd81e712775512f26888c4e6900d.zip gcc-8f634fb4f1becd81e712775512f26888c4e6900d.tar.gz gcc-8f634fb4f1becd81e712775512f26888c4e6900d.tar.bz2 |
Avoid extraneous remapping in copy_gimple_seq_and_replace_locals
2016-01-15 Martin Jambor <mjambor@suse.cz>
* tree-inline.c (remap_decl): Use existing dclarations if
remapping a type and prevent_decl_creation_for_types.
(replace_locals_stmt): Do an initial remapping of non-VLA typed
decls first. Do real remapping with
prevent_decl_creation_for_types set.
* tree-inline.h (copy_body_data): New field
prevent_decl_creation_for_types, moved remap_var_for_cilk to avoid
padding.
From-SVN: r232419
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 6bf2467..106e07a 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -340,8 +340,17 @@ remap_decl (tree decl, copy_body_data *id) return decl; } - /* If we didn't already have an equivalent for this declaration, - create one now. */ + /* When remapping a type within copy_gimple_seq_and_replace_locals, all + necessary DECLs have already been remapped and we do not want to duplicate + a decl coming from outside of the sequence we are copying. */ + if (!n + && id->prevent_decl_creation_for_types + && id->remapping_type_depth > 0 + && (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL)) + return decl; + + /* If we didn't already have an equivalent for this declaration, create one + now. */ if (!n) { /* Make a copy of the variable or label. */ @@ -5225,8 +5234,19 @@ replace_locals_stmt (gimple_stmt_iterator *gsip, /* This will remap a lot of the same decls again, but this should be harmless. */ if (gimple_bind_vars (stmt)) - gimple_bind_set_vars (stmt, remap_decls (gimple_bind_vars (stmt), - NULL, id)); + { + tree old_var, decls = gimple_bind_vars (stmt); + + for (old_var = decls; old_var; old_var = DECL_CHAIN (old_var)) + if (!can_be_nonlocal (old_var, id) + && ! variably_modified_type_p (TREE_TYPE (old_var), id->src_fn)) + remap_decl (old_var, id); + + gcc_checking_assert (!id->prevent_decl_creation_for_types); + id->prevent_decl_creation_for_types = true; + gimple_bind_set_vars (stmt, remap_decls (decls, NULL, id)); + id->prevent_decl_creation_for_types = false; + } } /* Keep iterating. */ |