Commit f11a7b6d by Alexandre Oliva Committed by Alexandre Oliva

revert to assign_parms assignments using default defs

Revert the fragile and complicated changes to assign_parms designed to
enable it to use RTL assigments chosen by cfgexpand, and instead have
cfgexpand use the RTL assignments by assign_parms, keying them off of
the default defs that are now necessarily introduced for each parm and
result.  The possible lack of a default def was already a problem, and
the fallbacks in place were not enough, as shown by PR67312.  We now
have checking asserts in set_rtl that verify that we're assigning to
each var a piece of RTL that matches the expectations set forth by
use_register_for_decl.

for  gcc/ChangeLog

	PR rtl-optimization/64164
	PR tree-optimization/67312
	PR middle-end/67340
	PR middle-end/67490
	PR bootstrap/67597
	* cfgexpand.c (parm_in_stack_slot_p): Remove.
	(ssa_default_def_partition): Remove.
	(get_rtl_for_parm_ssa_default_def): Remove.
	(set_rtl): Check that RTL assignments match expectations.
	Loop on SUBREGs, CONCATs and PARALLELs subexprs.  Set only the
	default def location for params and results.  Record SSA names
	or types in REG and MEM attrs, respectively.
	(set_parm_rtl): New.
	(expand_one_ssa_partition): Drop logic that assigned MEMs with
	unassigned addresses.
	(adjust_one_expanded_partition_var): Don't accept NULL RTL on
	deferred stack alloc vars.
	(expand_used_vars): Skip partitions holding parm default defs.
	Move adjust_one_expanded_partition_var loop...
	(pass_expand::execute): ... here.  Drop redundant assert.
	Adjust comments before the final loop over all ssa names.
	Require assigned rtl of parms and results to match exactly.
	Reset its attributes to match them, not any other variables in
	the same partition.
	(expand_debug_expr): Use entry value for PARM's default defs
	only iff they have zero nondebug uses.
	* cfgexpand.h (parm_in_stack_slot_p): Remove.
	(get_rtl_for_parm_ssa_default_def): Remove.
	(set_parm_rtl): Declare.
	* doc/invoke.texi: Improve wording.
	* explow.c (promote_decl_mode): Fix promote_function_mode for
	result decls not by reference.
	(promote_ssa_mode): Disregard BLKmode from promote_decl, and
	bypass TYPE_MODE to get the actual vector mode.
	* function.c: Include tree-dfa.h.  Revert 2015-08-14's and
	2015-08-19's changes as follows.  Drop include of
	basic-block.h and df.h.
	(rtl_for_parm): Remove.
	(maybe_reset_rtl_for_parm): Remove.
	(parm_in_unassigned_mem_p): Remove.
	(use_register_for_decl): Add logic for RESULT_DECLs matching
	assign_parms' behavior.
	(split_complex_args): Revert.
	(assign_parms_augmented_arg_list): Revert.  Add comment
	referencing the logic above.
	(assign_parm_adjust_stack_rtl): Revert.
	(assign_parm_setup_block): Revert.  Use set_parm_rtl instead
	of SET_DECL_RTL.  Set up a REG if the parm demands so.
	(assign_parm_setup_reg): Revert.  Consolidated SET_DECL_RTL
	calls into a single set_parm_rtl.  Set up a temporary RTL
	temporarily for expand_assignment.
	(assign_parm_setup_stack): Revert.  Use set_parm_rtl.
	(assign_parms_unsplit_complex): Revert.  Use set_parm_rtl.
	(assign_bounds): Revert.
	(assign_parms): Revert.  Use set_parm_rtl.
	(allocate_struct_function): Relayout result and parms of
	non-abstruct functions.
	(expand_function_start): Revert.  Use set_parm_rtl.  If the
	result is not a hard reg, create a pseudo from the promoted
	mode of the default def.  Promote static chain mode.
	* tree-outof-ssa.c (remove_ssa_form): Drop unused
	partition_has_default_def.  Set up
	partitions_for_parm_default_defs.
	(finish_out_of_ssa): Remove partition_has_default_def.
	Release partitions_for_parm_default_defs.
	* tree-outof-ssa.h (struct ssaexpand): Remove
	partition_has_default_def.  Add
	partitions_for_parm_default_defs.
	* tree-ssa-coalesce.c: Include tree-dfa.h, tm_p.h and
	stor-layout.h.
	(build_ssa_conflict_graph): Fix conflict-detection of default
	defs of even unused default defs of params and results.
	(for_all_parms): New.
	(create_default_def): New.
	(register_default_def): New.
	(coalesce_with_default): New.
	(create_outofssa_var_map): Create default defs for all parms
	and results, and register their partitions.  Add GIMPLE_RETURN
	operands as coalesce candidates with results.  Add default
	defs of each parm or result as coalesce candidates with its
	other defs.  Mark each result def, and each default def of
	parms, as used_in_copy.
	(gimple_can_coalesce_p): Call it.  Call use_register_for_decl
	with the ssa names, even anonymous ones.  Drop
	parm_in_stack_slot_p calls.  Require same signedness and
	alignment.
	(coalesce_ssa_name): Add coalesce candidates for all defs of
	each parm and result, even unused ones.
	(parm_default_def_partition_arg): New type.
	(set_parm_default_def_partition): New.
	(get_parm_default_def_partitions): New.
	* tree-ssa-coalesce.h (get_parm_default_def_partitions): New.
	* tree-ssa-live.c (partition_view_init): Regard unused defs of
	parms and results as used.
	(verify_live_on_entry): Don't error out just because they're
	not live.

for  gcc/testsuite/ChangeLog

	PR rtl-optimization/64164
	PR tree-optimization/67312
	* gcc.dg/pr67312.c: New.  From Zdenek Sojka.
	* gcc.target/i386/stackalign/return-4.c: Add -O.

From-SVN: r228175
parent edfc19ab
2015-09-27 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/64164
PR tree-optimization/67312
PR middle-end/67340
PR middle-end/67490
PR bootstrap/67597
* cfgexpand.c (parm_in_stack_slot_p): Remove.
(ssa_default_def_partition): Remove.
(get_rtl_for_parm_ssa_default_def): Remove.
(set_rtl): Check that RTL assignments match expectations.
Loop on SUBREGs, CONCATs and PARALLELs subexprs. Set only the
default def location for params and results. Record SSA names
or types in REG and MEM attrs, respectively.
(set_parm_rtl): New.
(expand_one_ssa_partition): Drop logic that assigned MEMs with
unassigned addresses.
(adjust_one_expanded_partition_var): Don't accept NULL RTL on
deferred stack alloc vars.
(expand_used_vars): Skip partitions holding parm default defs.
Move adjust_one_expanded_partition_var loop...
(pass_expand::execute): ... here. Drop redundant assert.
Adjust comments before the final loop over all ssa names.
Require assigned rtl of parms and results to match exactly.
Reset its attributes to match them, not any other variables in
the same partition.
(expand_debug_expr): Use entry value for PARM's default defs
only iff they have zero nondebug uses.
* cfgexpand.h (parm_in_stack_slot_p): Remove.
(get_rtl_for_parm_ssa_default_def): Remove.
(set_parm_rtl): Declare.
* doc/invoke.texi: Improve wording.
* explow.c (promote_decl_mode): Fix promote_function_mode for
result decls not by reference.
(promote_ssa_mode): Disregard BLKmode from promote_decl, and
bypass TYPE_MODE to get the actual vector mode.
* function.c: Include tree-dfa.h. Revert 2015-08-14's and
2015-08-19's changes as follows. Drop include of
basic-block.h and df.h.
(rtl_for_parm): Remove.
(maybe_reset_rtl_for_parm): Remove.
(parm_in_unassigned_mem_p): Remove.
(use_register_for_decl): Add logic for RESULT_DECLs matching
assign_parms' behavior.
(split_complex_args): Revert.
(assign_parms_augmented_arg_list): Revert. Add comment
referencing the logic above.
(assign_parm_adjust_stack_rtl): Revert.
(assign_parm_setup_block): Revert. Use set_parm_rtl instead
of SET_DECL_RTL. Set up a REG if the parm demands so.
(assign_parm_setup_reg): Revert. Consolidated SET_DECL_RTL
calls into a single set_parm_rtl. Set up a temporary RTL
temporarily for expand_assignment.
(assign_parm_setup_stack): Revert. Use set_parm_rtl.
(assign_parms_unsplit_complex): Revert. Use set_parm_rtl.
(assign_bounds): Revert.
(assign_parms): Revert. Use set_parm_rtl.
(allocate_struct_function): Relayout result and parms of
non-abstruct functions.
(expand_function_start): Revert. Use set_parm_rtl. If the
result is not a hard reg, create a pseudo from the promoted
mode of the default def. Promote static chain mode.
* tree-outof-ssa.c (remove_ssa_form): Drop unused
partition_has_default_def. Set up
partitions_for_parm_default_defs.
(finish_out_of_ssa): Remove partition_has_default_def.
Release partitions_for_parm_default_defs.
* tree-outof-ssa.h (struct ssaexpand): Remove
partition_has_default_def. Add
partitions_for_parm_default_defs.
* tree-ssa-coalesce.c: Include tree-dfa.h, tm_p.h and
stor-layout.h.
(build_ssa_conflict_graph): Fix conflict-detection of default
defs of even unused default defs of params and results.
(for_all_parms): New.
(create_default_def): New.
(register_default_def): New.
(coalesce_with_default): New.
(create_outofssa_var_map): Create default defs for all parms
and results, and register their partitions. Add GIMPLE_RETURN
operands as coalesce candidates with results. Add default
defs of each parm or result as coalesce candidates with its
other defs. Mark each result def, and each default def of
parms, as used_in_copy.
(gimple_can_coalesce_p): Call it. Call use_register_for_decl
with the ssa names, even anonymous ones. Drop
parm_in_stack_slot_p calls. Require same signedness and
alignment.
(coalesce_ssa_name): Add coalesce candidates for all defs of
each parm and result, even unused ones.
(parm_default_def_partition_arg): New type.
(set_parm_default_def_partition): New.
(get_parm_default_def_partitions): New.
* tree-ssa-coalesce.h (get_parm_default_def_partitions): New.
* tree-ssa-live.c (partition_view_init): Regard unused defs of
parms and results as used.
(verify_live_on_entry): Don't error out just because they're
not live.
2015-09-26 David Edelsohn <dje.gcc@gmail.com>
* dwarf2out.c (XCOFF_DEBUGGING_INFO): Default 0 definition.
......@@ -22,8 +22,7 @@ along with GCC; see the file COPYING3. If not see
extern tree gimple_assign_rhs_to_tree (gimple *);
extern HOST_WIDE_INT estimated_stack_frame_size (struct cgraph_node *);
extern bool parm_in_stack_slot_p (tree);
extern rtx get_rtl_for_parm_ssa_default_def (tree var);
extern void set_parm_rtl (tree, rtx);
#endif /* GCC_CFGEXPAND_H */
......@@ -8867,12 +8867,13 @@ profitable to parallelize the loops.
@item -ftree-coalesce-vars
@opindex ftree-coalesce-vars
Tell the compiler to attempt to combine small user-defined variables
too, instead of just compiler temporaries. This may severely limit the
ability to debug an optimized program compiled with
While transforming the program out of the SSA representation, attempt to
reduce copying by coalescing versions of different user-defined
variables, instead of just compiler temporaries. This may severely
limit the ability to debug an optimized program compiled with
@option{-fno-var-tracking-assignments}. In the negated form, this flag
prevents SSA coalescing of user variables. This option is enabled by
default if optimization is enabled.
default if optimization is enabled, and it does very little otherwise.
@item -ftree-loop-if-convert
@opindex ftree-loop-if-convert
......
......@@ -830,8 +830,10 @@ promote_decl_mode (const_tree decl, int *punsignedp)
machine_mode mode = DECL_MODE (decl);
machine_mode pmode;
if (TREE_CODE (decl) == RESULT_DECL
|| TREE_CODE (decl) == PARM_DECL)
if (TREE_CODE (decl) == RESULT_DECL && !DECL_BY_REFERENCE (decl))
pmode = promote_function_mode (type, mode, &unsignedp,
TREE_TYPE (current_function_decl), 1);
else if (TREE_CODE (decl) == RESULT_DECL || TREE_CODE (decl) == PARM_DECL)
pmode = promote_function_mode (type, mode, &unsignedp,
TREE_TYPE (current_function_decl), 2);
else
......@@ -857,12 +859,23 @@ promote_ssa_mode (const_tree name, int *punsignedp)
if (SSA_NAME_VAR (name)
&& (TREE_CODE (SSA_NAME_VAR (name)) == PARM_DECL
|| TREE_CODE (SSA_NAME_VAR (name)) == RESULT_DECL))
return promote_decl_mode (SSA_NAME_VAR (name), punsignedp);
{
machine_mode mode = promote_decl_mode (SSA_NAME_VAR (name), punsignedp);
if (mode != BLKmode)
return mode;
}
tree type = TREE_TYPE (name);
int unsignedp = TYPE_UNSIGNED (type);
machine_mode mode = TYPE_MODE (type);
/* Bypass TYPE_MODE when it maps vector modes to BLKmode. */
if (mode == BLKmode)
{
gcc_assert (VECTOR_TYPE_P (type));
mode = type->type_common.mode;
}
machine_mode pmode = promote_mode (type, mode, &unsignedp);
if (punsignedp)
*punsignedp = unsignedp;
......
2015-09-27 Alexandre Oliva <aoliva@redhat.com>
PR rtl-optimization/64164
PR tree-optimization/67312
* gcc.dg/pr67312.c: New. From Zdenek Sojka.
* gcc.target/i386/stackalign/return-4.c: Add -O.
2015-09-27 David Edelsohn <dje.gcc@gmail.com>
* g++.dg/debug/dwarf2/pr44641.C: Add one to expected line numbers.
......
/* { dg-do compile } */
/* { dg-options "-O0 -ftree-coalesce-vars" } */
void foo (int x, int y)
{
y = x;
}
/* { dg-do compile } */
/* { dg-options "-mpreferred-stack-boundary=4" } */
/* { dg-options "-mpreferred-stack-boundary=4 -O" } */
/* { dg-final { scan-assembler-not "and\[lq\]?\[^\\n\]*-64,\[^\\n\]*sp" } } */
/* We only guarantee we won't generate the stack alignment when
optimizing. When not optimizing, the return value will be assigned
to a pseudo with the specified alignment, which in turn will force
stack alignment since the pseudo might have to be spilled. Without
optimization, we wouldn't compute the actual stack requirements
after register allocation and reload, and just use the conservative
estimate. */
/* This compile only test is to detect an assertion failure in stack branch
development. */
......
......@@ -980,7 +980,6 @@ remove_ssa_form (bool perform_ter, struct ssaexpand *sa)
{
bitmap values = NULL;
var_map map;
unsigned i;
map = coalesce_ssa_name ();
......@@ -1005,17 +1004,7 @@ remove_ssa_form (bool perform_ter, struct ssaexpand *sa)
sa->map = map;
sa->values = values;
sa->partition_has_default_def = BITMAP_ALLOC (NULL);
for (i = 1; i < num_ssa_names; i++)
{
tree t = ssa_name (i);
if (t && SSA_NAME_IS_DEFAULT_DEF (t))
{
int p = var_to_partition (map, t);
if (p != NO_PARTITION)
bitmap_set_bit (sa->partition_has_default_def, p);
}
}
sa->partitions_for_parm_default_defs = get_parm_default_def_partitions (map);
}
......@@ -1190,7 +1179,7 @@ finish_out_of_ssa (struct ssaexpand *sa)
if (sa->values)
BITMAP_FREE (sa->values);
delete_var_map (sa->map);
BITMAP_FREE (sa->partition_has_default_def);
BITMAP_FREE (sa->partitions_for_parm_default_defs);
memset (sa, 0, sizeof *sa);
}
......
......@@ -39,9 +39,9 @@ struct ssaexpand
a pseudos REG). */
rtx *partition_to_pseudo;
/* If partition I contains an SSA name that has a default def,
bit I will be set in this bitmap. */
bitmap partition_has_default_def;
/* If partition I contains an SSA name that has a default def for a
parameter, bit I will be set in this bitmap. */
bitmap partitions_for_parm_default_defs;
};
/* This is the singleton described above. */
......
......@@ -22,5 +22,6 @@ along with GCC; see the file COPYING3. If not see
extern var_map coalesce_ssa_name (void);
extern bool gimple_can_coalesce_p (tree, tree);
extern bitmap get_parm_default_def_partitions (var_map);
#endif /* GCC_TREE_SSA_COALESCE_H */
......@@ -200,7 +200,9 @@ partition_view_init (var_map map)
tmp = partition_find (map->var_partition, x);
if (ssa_name (tmp) != NULL_TREE && !virtual_operand_p (ssa_name (tmp))
&& (!has_zero_uses (ssa_name (tmp))
|| !SSA_NAME_IS_DEFAULT_DEF (ssa_name (tmp))))
|| !SSA_NAME_IS_DEFAULT_DEF (ssa_name (tmp))
|| (SSA_NAME_VAR (ssa_name (tmp))
&& !VAR_P (SSA_NAME_VAR (ssa_name (tmp))))))
bitmap_set_bit (used, tmp);
}
......@@ -1404,6 +1406,12 @@ verify_live_on_entry (tree_live_info_p live)
}
if (ok)
continue;
/* Expand adds unused default defs for PARM_DECLs and
RESULT_DECLs. They're ok. */
if (has_zero_uses (var)
&& SSA_NAME_VAR (var)
&& !VAR_P (SSA_NAME_VAR (var)))
continue;
num++;
print_generic_expr (stderr, var, TDF_SLIM);
fprintf (stderr, " is not marked live-on-entry to entry BB%d ",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment