From e28e45ca600cf8c139bf7f058478566e5e0f2aa9 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 21 Nov 2019 17:11:19 +0000 Subject: Backported from mainline 2019-09-06 Jakub Jelinek * function.c (assign_parm_find_data_types): Use RECORD_OR_UNION_TYPE_P before testing TYPE_TRANSPARENT_AGGR. * calls.c (initialize_argument_information, load_register_parameters): Likewise. 2019-09-05 Jakub Jelinek PR middle-end/91001 PR middle-end/91105 PR middle-end/91106 * calls.c (load_register_parameters): For TYPE_TRANSPARENT_AGGR types, use type of their first field instead of type of args[i].tree_value. * gcc.c-torture/compile/pr91001.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@278575 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/function.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/function.c') diff --git a/gcc/function.c b/gcc/function.c index d81e8b1ba8a..37d99aedcd7 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -2477,8 +2477,7 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm, /* If the parm is to be passed as a transparent union or record, use the type of the first field for the tests below. We have already verified that the modes are the same. */ - if ((TREE_CODE (passed_type) == UNION_TYPE - || TREE_CODE (passed_type) == RECORD_TYPE) + if (RECORD_OR_UNION_TYPE_P (passed_type) && TYPE_TRANSPARENT_AGGR (passed_type)) passed_type = TREE_TYPE (first_field (passed_type)); -- cgit v1.2.3 From d7a161d3e726c955559ce5291fbd44dd39dac206 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 21 Nov 2019 17:17:20 +0000 Subject: Backported from mainline 2019-11-08 Jakub Jelinek PR c++/92384 * function.c (assign_parm_setup_block, assign_parm_setup_stack): Don't copy TYPE_EMPTY_P arguments from data->entry_parm to data->stack_parm slot. (assign_parms): For TREE_ADDRESSABLE parms with TYPE_EMPTY_P type force creation of a unique data.stack_parm slot. * g++.dg/torture/pr92384.C: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@278582 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/function.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'gcc/function.c') diff --git a/gcc/function.c b/gcc/function.c index 37d99aedcd7..ebc7eda1604 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3097,7 +3097,7 @@ assign_parm_setup_block (struct assign_parm_data_all *all, move_block_from_reg (REGNO (entry_parm), mem, size_stored / UNITS_PER_WORD); } - else if (data->stack_parm == 0) + else if (data->stack_parm == 0 && !TYPE_EMPTY_P (data->passed_type)) { push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn); emit_block_move (stack_parm, data->entry_parm, GEN_INT (size), @@ -3473,7 +3473,9 @@ assign_parm_setup_stack (struct assign_parm_data_all *all, tree parm, dest = validize_mem (copy_rtx (data->stack_parm)); src = validize_mem (copy_rtx (data->entry_parm)); - if (MEM_P (src)) + if (TYPE_EMPTY_P (data->passed_type)) + /* Empty types don't really need to be copied. */; + else if (MEM_P (src)) { /* Use a block move to handle potentially misaligned entry_parm. */ if (!to_conversion) @@ -3748,6 +3750,16 @@ assign_parms (tree fndecl) { assign_parm_find_stack_rtl (parm, &data); assign_parm_adjust_entry_rtl (&data); + /* For arguments that occupy no space in the parameter + passing area, have non-zero size and have address taken, + force creation of a stack slot so that they have distinct + address from other parameters. */ + if (TYPE_EMPTY_P (data.passed_type) + && TREE_ADDRESSABLE (parm) + && data.entry_parm == data.stack_parm + && MEM_P (data.entry_parm) + && int_size_in_bytes (data.passed_type)) + data.stack_parm = NULL_RTX; } if (!POINTER_BOUNDS_TYPE_P (data.passed_type)) { -- cgit v1.2.3