This patch splits out a common idiom from the va_arg gimplification
routines, so that there's only one place to update later.
2019-08-19 Richard Sandiford
gcc/
* calls.h (pass_va_arg_by_reference): Declare.
* calls.c (pass_va_arg_by_reference): New function.
* config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): Use it.
* config/alpha/alpha.c (alpha_gimplify_va_arg): Likewise.
* config/gcn/gcn.c (gcn_gimplify_va_arg_expr): Likewise.
* config/i386/i386.c (ix86_gimplify_va_arg): Likewise.
* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
* config/mips/mips.c (mips_std_gimplify_va_arg_expr): Likewise.
(mips_gimplify_va_arg_expr): Likewise.
* config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Likewise.
* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
* config/rs6000/rs6000-call.c (rs6000_gimplify_va_arg): Likewise.
* config/s390/s390.c (s390_gimplify_va_arg): Likewise.
* config/sparc/sparc.c (sparc_gimplify_va_arg): Likewise.
* config/spu/spu.c (spu_gimplify_va_arg_expr): Likewise.
* config/tilegx/tilegx.c (tilegx_gimplify_va_arg_expr): Likewise.
* config/tilepro/tilepro.c (tilepro_gimplify_va_arg_expr): Likewise.
* config/visium/visium.c (visium_gimplify_va_arg): Likewise.
* config/xtensa/xtensa.c (xtensa_gimplify_va_arg_expr): Likewise.
* targhooks.c (std_gimplify_va_arg_expr): Likewise.
Index: gcc/calls.h
===
--- gcc/calls.h 2019-03-08 18:15:33.696751769 +
+++ gcc/calls.h 2019-08-19 15:58:10.742205564 +0100
@@ -35,6 +35,7 @@ extern void fixup_tail_calls (void);
extern bool pass_by_reference (CUMULATIVE_ARGS *, machine_mode,
tree, bool);
+extern bool pass_va_arg_by_reference (tree);
extern bool reference_callee_copied (CUMULATIVE_ARGS *, machine_mode,
tree, bool);
extern void maybe_warn_alloc_args_overflow (tree, tree, tree[2], int[2]);
Index: gcc/calls.c
===
--- gcc/calls.c 2019-08-13 22:35:04.921302360 +0100
+++ gcc/calls.c 2019-08-19 15:58:10.742205564 +0100
@@ -927,6 +927,15 @@ pass_by_reference (CUMULATIVE_ARGS *ca,
type, named_arg);
}
+/* Return true if TYPE should be passed by reference when passed to
+ the "..." arguments of a function. */
+
+bool
+pass_va_arg_by_reference (tree type)
+{
+ return pass_by_reference (NULL, TYPE_MODE (type), type, false);
+}
+
/* Return true if TYPE, which is passed by reference, should be callee
copied instead of caller copied. */
Index: gcc/config/aarch64/aarch64.c
===
--- gcc/config/aarch64/aarch64.c2019-08-15 10:00:02.366735649 +0100
+++ gcc/config/aarch64/aarch64.c2019-08-19 15:58:10.746205533 +0100
@@ -14271,7 +14271,7 @@ aarch64_gimplify_va_arg_expr (tree valis
HOST_WIDE_INT size, rsize, adjust, align;
tree t, u, cond1, cond2;
- indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+ indirect_p = pass_va_arg_by_reference (type);
if (indirect_p)
type = build_pointer_type (type);
Index: gcc/config/alpha/alpha.c
===
--- gcc/config/alpha/alpha.c2019-08-13 22:35:11.721252311 +0100
+++ gcc/config/alpha/alpha.c2019-08-19 15:58:10.750205506 +0100
@@ -6330,7 +6330,7 @@ alpha_gimplify_va_arg (tree valist, tree
t = fold_convert (build_nonstandard_integer_type (64, 0), offset_field);
offset = get_initialized_tmp_var (t, pre_p, NULL);
- indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+ indirect = pass_va_arg_by_reference (type);
if (indirect)
{
Index: gcc/config/gcn/gcn.c
===
--- gcc/config/gcn/gcn.c2019-08-13 22:35:11.733252223 +0100
+++ gcc/config/gcn/gcn.c2019-08-19 15:58:10.750205506 +0100
@@ -2493,7 +2493,7 @@ gcn_gimplify_va_arg_expr (tree valist, t
tree t, u;
bool indirect;
- indirect = pass_by_reference (NULL, TYPE_MODE (type), type, 0);
+ indirect = pass_va_arg_by_reference (type);
if (indirect)
{
type = ptr;
Index: gcc/config/i386/i386.c
===
--- gcc/config/i386/i386.c 2019-08-19 15:57:56.338309784 +0100
+++ gcc/config/i386/i386.c 2019-08-19 15:58:10.754205475 +0100
@@ -4307,7 +4307,7 @@ ix86_gimplify_va_arg (tree valist, tree
ovf = build3 (COMPONENT_REF, TREE_TYPE (f_ovf), valist, f_ovf, NULL_TREE);
sav = build3 (COMPONENT_REF, TREE_TYPE (f_sav), valist, f_sav, NULL_TREE);
- indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+ indirect_p = pass_va_arg_by_reference (type);
if (indirect_p)