Don't create superfluous parm in expand_omp_taskreg
2015-08-23 Tom de Vries <tom@codesourcery.com> * omp-low.c (expand_omp_taskreg): If in ssa, set rhs of parcopy stmt to parm_decl, rather than generating a dummy default def in cfun. * tree-cfg.c (replace_ssa_name): Assume no default defs. Make sure ssa_name from cfun and child_fn do not share a stmt as def stmt. (move_stmt_op): Handle PARM_DECl. (gather_ssa_name_hash_map_from): New function. (move_sese_region_to_fn): Add default defs for function params, and add them to vars_map. Release copied ssa names. * tree-cfg.h (gather_ssa_name_hash_map_from): Declare. From-SVN: r227103
This commit is contained in:
parent
1b95056999
commit
2eddac76ab
|
@ -1,3 +1,15 @@
|
|||
2015-08-23 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
* omp-low.c (expand_omp_taskreg): If in ssa, set rhs of parcopy stmt to
|
||||
parm_decl, rather than generating a dummy default def in cfun.
|
||||
* tree-cfg.c (replace_ssa_name): Assume no default defs. Make sure
|
||||
ssa_name from cfun and child_fn do not share a stmt as def stmt.
|
||||
(move_stmt_op): Handle PARM_DECl.
|
||||
(gather_ssa_name_hash_map_from): New function.
|
||||
(move_sese_region_to_fn): Add default defs for function params, and add
|
||||
them to vars_map. Release copied ssa names.
|
||||
* tree-cfg.h (gather_ssa_name_hash_map_from): Declare.
|
||||
|
||||
2015-08-23 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
* doc/sourcebuild.texi: Rename vect_no_int_max with
|
||||
|
|
|
@ -5417,7 +5417,7 @@ expand_omp_taskreg (struct omp_region *region)
|
|||
basic_block entry_succ_bb
|
||||
= single_succ_p (entry_bb) ? single_succ (entry_bb)
|
||||
: FALLTHRU_EDGE (entry_bb)->dest;
|
||||
tree arg, narg;
|
||||
tree arg;
|
||||
gimple parcopy_stmt = NULL;
|
||||
|
||||
for (gsi = gsi_start_bb (entry_succ_bb); ; gsi_next (&gsi))
|
||||
|
@ -5462,15 +5462,15 @@ expand_omp_taskreg (struct omp_region *region)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* If we are in ssa form, we must load the value from the default
|
||||
definition of the argument. That should not be defined now,
|
||||
since the argument is not used uninitialized. */
|
||||
gcc_assert (ssa_default_def (cfun, arg) == NULL);
|
||||
narg = make_ssa_name (arg, gimple_build_nop ());
|
||||
set_ssa_default_def (cfun, arg, narg);
|
||||
/* ?? Is setting the subcode really necessary ?? */
|
||||
gimple_omp_set_subcode (parcopy_stmt, TREE_CODE (narg));
|
||||
gimple_assign_set_rhs1 (parcopy_stmt, narg);
|
||||
tree lhs = gimple_assign_lhs (parcopy_stmt);
|
||||
gcc_assert (SSA_NAME_VAR (lhs) == arg);
|
||||
/* We'd like to set the rhs to the default def in the child_fn,
|
||||
but it's too early to create ssa names in the child_fn.
|
||||
Instead, we set the rhs to the parm. In
|
||||
move_sese_region_to_fn, we introduce a default def for the
|
||||
parm, map the parm to it's default def, and once we encounter
|
||||
this stmt, replace the parm with the default def. */
|
||||
gimple_assign_set_rhs1 (parcopy_stmt, arg);
|
||||
update_stmt (parcopy_stmt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6420,17 +6420,19 @@ replace_ssa_name (tree name, hash_map<tree, tree> *vars_map,
|
|||
tree decl = SSA_NAME_VAR (name);
|
||||
if (decl)
|
||||
{
|
||||
gcc_assert (!SSA_NAME_IS_DEFAULT_DEF (name));
|
||||
replace_by_duplicate_decl (&decl, vars_map, to_context);
|
||||
new_name = make_ssa_name_fn (DECL_STRUCT_FUNCTION (to_context),
|
||||
decl, SSA_NAME_DEF_STMT (name));
|
||||
if (SSA_NAME_IS_DEFAULT_DEF (name))
|
||||
set_ssa_default_def (DECL_STRUCT_FUNCTION (to_context),
|
||||
decl, new_name);
|
||||
}
|
||||
else
|
||||
new_name = copy_ssa_name_fn (DECL_STRUCT_FUNCTION (to_context),
|
||||
name, SSA_NAME_DEF_STMT (name));
|
||||
|
||||
/* Now that we've used the def stmt to define new_name, make sure it
|
||||
doesn't define name anymore. */
|
||||
SSA_NAME_DEF_STMT (name) = NULL;
|
||||
|
||||
vars_map->put (name, new_name);
|
||||
}
|
||||
else
|
||||
|
@ -6482,6 +6484,9 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
|
|||
{
|
||||
if (TREE_CODE (t) == SSA_NAME)
|
||||
*tp = replace_ssa_name (t, p->vars_map, p->to_context);
|
||||
else if (TREE_CODE (t) == PARM_DECL
|
||||
&& gimple_in_ssa_p (cfun))
|
||||
*tp = *(p->vars_map->get (t));
|
||||
else if (TREE_CODE (t) == LABEL_DECL)
|
||||
{
|
||||
if (p->new_label_map)
|
||||
|
@ -6992,6 +6997,19 @@ verify_sese (basic_block entry, basic_block exit, vec<basic_block> *bbs_p)
|
|||
BITMAP_FREE (bbs);
|
||||
}
|
||||
|
||||
/* If FROM is an SSA_NAME, mark the version in bitmap DATA. */
|
||||
|
||||
bool
|
||||
gather_ssa_name_hash_map_from (tree const &from, tree const &, void *data)
|
||||
{
|
||||
bitmap release_names = (bitmap)data;
|
||||
|
||||
if (TREE_CODE (from) != SSA_NAME)
|
||||
return true;
|
||||
|
||||
bitmap_set_bit (release_names, SSA_NAME_VERSION (from));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Move a single-entry, single-exit region delimited by ENTRY_BB and
|
||||
EXIT_BB to function DEST_CFUN. The whole region is replaced by a
|
||||
|
@ -7189,6 +7207,14 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
|
|||
d.eh_map = eh_map;
|
||||
d.remap_decls_p = true;
|
||||
|
||||
if (gimple_in_ssa_p (cfun))
|
||||
for (tree arg = DECL_ARGUMENTS (d.to_context); arg; arg = DECL_CHAIN (arg))
|
||||
{
|
||||
tree narg = make_ssa_name_fn (dest_cfun, arg, gimple_build_nop ());
|
||||
set_ssa_default_def (dest_cfun, arg, narg);
|
||||
vars_map.put (arg, narg);
|
||||
}
|
||||
|
||||
FOR_EACH_VEC_ELT (bbs, i, bb)
|
||||
{
|
||||
/* No need to update edge counts on the last block. It has
|
||||
|
@ -7246,6 +7272,19 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
|
|||
if (eh_map)
|
||||
delete eh_map;
|
||||
|
||||
if (gimple_in_ssa_p (cfun))
|
||||
{
|
||||
/* We need to release ssa-names in a defined order, so first find them,
|
||||
and then iterate in ascending version order. */
|
||||
bitmap release_names = BITMAP_ALLOC (NULL);
|
||||
vars_map.traverse<void *, gather_ssa_name_hash_map_from> (release_names);
|
||||
bitmap_iterator bi;
|
||||
unsigned i;
|
||||
EXECUTE_IF_SET_IN_BITMAP (release_names, 0, i, bi)
|
||||
release_ssa_name (ssa_name (i));
|
||||
BITMAP_FREE (release_names);
|
||||
}
|
||||
|
||||
/* Rewire the entry and exit blocks. The successor to the entry
|
||||
block turns into the successor of DEST_FN's ENTRY_BLOCK_PTR in
|
||||
the child function. Similarly, the predecessor of DEST_FN's
|
||||
|
|
|
@ -75,6 +75,7 @@ extern bool gimple_duplicate_sese_tail (edge, edge, basic_block *, unsigned,
|
|||
extern void gather_blocks_in_sese_region (basic_block entry, basic_block exit,
|
||||
vec<basic_block> *bbs_p);
|
||||
extern void verify_sese (basic_block, basic_block, vec<basic_block> *);
|
||||
extern bool gather_ssa_name_hash_map_from (tree const &, tree const &, void *);
|
||||
extern basic_block move_sese_region_to_fn (struct function *, basic_block,
|
||||
basic_block, tree);
|
||||
extern void dump_function_to_file (tree, FILE *, int);
|
||||
|
|
Loading…
Reference in New Issue