From b12cdd6e8e8dd1f39a941b731ba1056d656a094f Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 20 Aug 2019 08:53:47 +0000 Subject: Add a apply_pass_by_reference_rules helper This patch adds a helper routine that applies pass-by-reference semantics to an existing function_arg_info. The c6x part means that c6x_function_arg and c6x_function_arg_advance see the same "named" value as pass_by_reference did, rather than pass_by_reference seeing "true" and the others seeing "false". This doesn't matter because the c6x port doesn't care about namedness. The rs6000.c patch removes an assignment to "type", but the only later code to use it was the patched promote_mode line. (The reason for patching these places despite the above is that often target code gets used as a basis for new targets or changes to existing ones.) 2019-08-20 Richard Sandiford gcc/ * calls.h (apply_pass_by_reference_rules): Declare. * calls.c (apply_pass_by_reference_rules): New function. * config/c6x/c6x.c (c6x_call_saved_register_used): Use it. * config/rs6000/rs6000-call.c (rs6000_parm_needs_stack): Likewise. * config/s390/s390.c (s390_call_saved_register_used): Likewise. * function.c (assign_parm_find_data_types): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. From-SVN: r274704 --- gcc/var-tracking.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'gcc/var-tracking.c') diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 8b1d447..af18528 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -6426,28 +6426,24 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn) } if (t && t != void_list_node) { - tree argtype = TREE_VALUE (t); rtx reg; - function_arg_info orig_arg (argtype, /*named=*/true); - if (pass_by_reference (&args_so_far_v, orig_arg)) - argtype = build_pointer_type (argtype); - machine_mode mode = TYPE_MODE (argtype); - function_arg_info arg (argtype, /*named=*/true); + function_arg_info arg (TREE_VALUE (t), /*named=*/true); + apply_pass_by_reference_rules (&args_so_far_v, arg); reg = targetm.calls.function_arg (args_so_far, arg); - if (TREE_CODE (argtype) == REFERENCE_TYPE - && INTEGRAL_TYPE_P (TREE_TYPE (argtype)) + if (TREE_CODE (arg.type) == REFERENCE_TYPE + && INTEGRAL_TYPE_P (TREE_TYPE (arg.type)) && reg && REG_P (reg) - && GET_MODE (reg) == mode - && (GET_MODE_CLASS (mode) == MODE_INT - || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT) + && GET_MODE (reg) == arg.mode + && (GET_MODE_CLASS (arg.mode) == MODE_INT + || GET_MODE_CLASS (arg.mode) == MODE_PARTIAL_INT) && REG_P (x) && REGNO (x) == REGNO (reg) - && GET_MODE (x) == mode + && GET_MODE (x) == arg.mode && item) { machine_mode indmode - = TYPE_MODE (TREE_TYPE (argtype)); + = TYPE_MODE (TREE_TYPE (arg.type)); rtx mem = gen_rtx_MEM (indmode, x); cselib_val *val = cselib_lookup (mem, indmode, 0, VOIDmode); if (val && cselib_preserved_value_p (val)) -- cgit v1.1