diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2015-08-19 17:00:32 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2015-08-19 17:00:32 +0000 |
commit | c24f5688adae2f885279e8fdce74a030e6944b7b (patch) | |
tree | 31f9d298632e1c8a23bdf19a980e7ed54c790474 /gcc/cfgexpand.c | |
parent | 8dc89e4d7ed340095fa0d27de5de584156b38c0b (diff) | |
download | gcc-c24f5688adae2f885279e8fdce74a030e6944b7b.zip gcc-c24f5688adae2f885279e8fdce74a030e6944b7b.tar.gz gcc-c24f5688adae2f885279e8fdce74a030e6944b7b.tar.bz2 |
[PR64164] fix regressions reported on m68k and armeb
Defer stack slot address assignment for all parms that can't live in
pseudos, and accept pseudos assignments in assign_param_setup_block.
for gcc/ChangeLog
PR rtl-optimization/64164
* cfgexpand.c (parm_maybe_byref_p): Renamed to...
(parm_in_stack_slot_p): ... this. Disregard mode, what
matters is whether the parm will live in a pseudo or a stack
slot.
(expand_one_ssa_partition): Deal with params without a default
def. Disregard mode.
* cfgexpand.h: Renamed function declaration.
* tree-ssa-coalesce.c: Adjust.
* function.c (split_complex_args): Allocate stack slot for
unassigned parms before splitting.
(parm_in_unassigned_mem_p): New. Use it instead of
parm_maybe_byref_p throughout this file.
(assign_parm_setup_block): Use it. Accept pseudos in the
expand-assigned rtl.
(assign_parm_setup_reg): Drop BLKmode requirement.
(assign_parm_setup_stack): Allocate and fill in the address of
unassigned MEM parms.
From-SVN: r227015
Diffstat (limited to 'gcc/cfgexpand.c')
-rw-r--r-- | gcc/cfgexpand.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 0bc20f6..d567a87 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -172,17 +172,23 @@ leader_merge (tree cur, tree next) return cur; } -/* Return true if VAR is a PARM_DECL or a RESULT_DECL of type BLKmode. +/* Return true if VAR is a PARM_DECL or a RESULT_DECL that ought to be + assigned to a stack slot. We can't have expand_one_ssa_partition + choose their address: the pseudo holding the address would be set + up too late for assign_params to copy the parameter if needed. + Such parameters are likely passed as a pointer to the value, rather than as a value, and so we must not coalesce them, nor allocate stack space for them before determining the calling conventions for - them. For their SSA_NAMEs, expand_one_ssa_partition emits RTL as - MEMs with pc_rtx as the address, and then it replaces the pc_rtx - with NULL so as to make sure the MEM is not used before it is - adjusted in assign_parm_setup_reg. */ + them. + + For their SSA_NAMEs, expand_one_ssa_partition emits RTL as MEMs + with pc_rtx as the address, and then it replaces the pc_rtx with + NULL so as to make sure the MEM is not used before it is adjusted + in assign_parm_setup_reg. */ bool -parm_maybe_byref_p (tree var) +parm_in_stack_slot_p (tree var) { if (!var || VAR_P (var)) return false; @@ -190,7 +196,7 @@ parm_maybe_byref_p (tree var) gcc_assert (TREE_CODE (var) == PARM_DECL || TREE_CODE (var) == RESULT_DECL); - return TYPE_MODE (TREE_TYPE (var)) == BLKmode; + return !use_register_for_decl (var); } /* Return the partition of the default SSA_DEF for decl VAR. */ @@ -1343,17 +1349,35 @@ expand_one_ssa_partition (tree var) if (!use_register_for_decl (var)) { - if (parm_maybe_byref_p (SSA_NAME_VAR (var)) - && ssa_default_def_partition (SSA_NAME_VAR (var)) == part) + /* We can't risk having the parm assigned to a MEM location + whose address references a pseudo, for the pseudo will only + be set up after arguments are copied to the stack slot. + + If the parm doesn't have a default def (e.g., because its + incoming value is unused), then we want to let assign_params + do the allocation, too. In this case we want to make sure + SSA_NAMEs associated with the parm don't get assigned to more + than one partition, lest we'd create two unassigned stac + slots for the same parm, thus the assert at the end of the + block. */ + if (parm_in_stack_slot_p (SSA_NAME_VAR (var)) + && (ssa_default_def_partition (SSA_NAME_VAR (var)) == part + || !ssa_default_def (cfun, SSA_NAME_VAR (var)))) { expand_one_stack_var_at (var, pc_rtx, 0, 0); rtx x = SA.partition_to_pseudo[part]; gcc_assert (GET_CODE (x) == MEM); - gcc_assert (GET_MODE (x) == BLKmode); gcc_assert (XEXP (x, 0) == pc_rtx); /* Reset the address, so that any attempt to use it will ICE. It will be adjusted in assign_parm_setup_reg. */ XEXP (x, 0) = NULL_RTX; + /* If the RTL associated with the parm is not what we have + just created, the parm has been split over multiple + partitions. In order for this to work, we must have a + default def for the parm, otherwise assign_params won't + know what to do. */ + gcc_assert (DECL_RTL_IF_SET (SSA_NAME_VAR (var)) == x + || ssa_default_def (cfun, SSA_NAME_VAR (var))); } else if (defer_stack_allocation (var, true)) add_stack_var (var); |