From: Richard Sandiford Date: Tue, 20 Aug 2019 08:50:59 +0000 (+0000) Subject: Add pass_va_arg_by_reference X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fde65a89fad742c2dca8ad50452e482d22f3c1b2;p=gcc.git Add pass_va_arg_by_reference 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-20 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. From-SVN: r274695 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7975480b788..81d672f8970 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2019-08-20 Richard Sandiford + + * 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. + 2019-08-20 Richard Biener PR target/91498 diff --git a/gcc/calls.c b/gcc/calls.c index 54e30e6cb0d..f49f052bd4a 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -927,6 +927,15 @@ pass_by_reference (CUMULATIVE_ARGS *ca, machine_mode mode, 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. */ diff --git a/gcc/calls.h b/gcc/calls.h index 128bb513074..2f41fa34abb 100644 --- a/gcc/calls.h +++ b/gcc/calls.h @@ -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]); diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index be0162244a2..bbcafa951c9 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -14271,7 +14271,7 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, 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); diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index d551af74e1e..74ca95e12a8 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -6330,7 +6330,7 @@ alpha_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, 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) { diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 2c1158f2df0..0826c819dd6 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -2493,7 +2493,7 @@ gcn_gimplify_va_arg_expr (tree valist, tree type, 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; diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 647bcbef050..e6244eafaac 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4307,7 +4307,7 @@ ix86_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, 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) type = build_pointer_type (type); size = arg_int_size_in_bytes (type); diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index a07244e2206..4449151b6e1 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -5147,7 +5147,7 @@ ia64_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, gimple_seq *post_p) { /* Variable sized types are passed by reference. */ - if (pass_by_reference (NULL, TYPE_MODE (type), type, false)) + if (pass_va_arg_by_reference (type)) { tree ptrtype = build_pointer_type (type); tree addr = std_gimplify_va_arg_expr (valist, ptrtype, pre_p, post_p); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 45ddec13e9f..fd5d78d1d13 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -6780,7 +6780,7 @@ mips_std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, unsigned HOST_WIDE_INT align, boundary; bool indirect; - indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + indirect = pass_va_arg_by_reference (type); if (indirect) type = build_pointer_type (type); @@ -6867,7 +6867,7 @@ mips_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, tree addr; bool indirect_p; - indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, 0); + indirect_p = pass_va_arg_by_reference (type); if (indirect_p) type = build_pointer_type (type); diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index fedbdf52c5c..84762f9edb4 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -856,7 +856,7 @@ msp430_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, unsigned HOST_WIDE_INT align, boundary; bool indirect; - indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + indirect = pass_va_arg_by_reference (type); if (indirect) type = build_pointer_type (type); diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 0ab95d84c3a..778e1364540 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -6377,7 +6377,7 @@ hppa_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, unsigned int size, ofs; bool indirect; - indirect = pass_by_reference (NULL, TYPE_MODE (type), type, 0); + indirect = pass_va_arg_by_reference (type); if (indirect) { type = ptr; diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 62aa4bf6be4..f7c5384e92e 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -2690,7 +2690,7 @@ rs6000_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, int regalign = 0; gimple *stmt; - if (pass_by_reference (NULL, TYPE_MODE (type), type, false)) + if (pass_va_arg_by_reference (type)) { t = rs6000_gimplify_va_arg (valist, ptrtype, pre_p, post_p); return build_va_arg_indirect_ref (t); diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 74f1d254a33..4ea600a8325 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -12476,7 +12476,7 @@ s390_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, s390_check_type_for_vector_abi (type, true, false); - if (pass_by_reference (NULL, TYPE_MODE (type), type, false)) + if (pass_va_arg_by_reference (type)) { if (TARGET_DEBUG_ARG) { diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index a15f27f442c..e5cf9a8dfb1 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -7935,7 +7935,7 @@ sparc_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, bool indirect; tree ptrtype = build_pointer_type (type); - if (pass_by_reference (NULL, TYPE_MODE (type), type, false)) + if (pass_va_arg_by_reference (type)) { indirect = true; size = rsize = UNITS_PER_WORD; diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index f88ad19aa6f..50bf40e865b 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -4053,8 +4053,7 @@ spu_gimplify_va_arg_expr (tree valist, tree type, gimple_seq * pre_p, /* if an object is dynamically sized, a pointer to it is passed instead of the object itself. */ - pass_by_reference_p = pass_by_reference (NULL, TYPE_MODE (type), type, - false); + pass_by_reference_p = pass_va_arg_by_reference (type); if (pass_by_reference_p) type = build_pointer_type (type); size = int_size_in_bytes (type); diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 575780fcccb..849fda551b6 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -471,8 +471,7 @@ tilegx_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, /* If an object is dynamically sized, a pointer to it is passed instead of the object itself. */ - pass_by_reference_p = pass_by_reference (NULL, TYPE_MODE (type), type, - false); + pass_by_reference_p = pass_va_arg_by_reference (type); if (pass_by_reference_p) type = build_pointer_type (type); diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index b4adfa49985..8091ee05922 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -419,8 +419,7 @@ tilepro_gimplify_va_arg_expr (tree valist, tree type, gimple_seq * pre_p, /* if an object is dynamically sized, a pointer to it is passed instead of the object itself. */ - pass_by_reference_p = pass_by_reference (NULL, TYPE_MODE (type), type, - false); + pass_by_reference_p = pass_va_arg_by_reference (type); if (pass_by_reference_p) type = build_pointer_type (type); diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c index 431f64cfcad..4ff331362f7 100644 --- a/gcc/config/visium/visium.c +++ b/gcc/config/visium/visium.c @@ -1637,8 +1637,7 @@ visium_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, tree f_ovfl, f_gbase, f_fbase, f_gbytes, f_fbytes; tree ovfl, base, bytes; HOST_WIDE_INT size, rsize; - const bool by_reference_p - = pass_by_reference (NULL, TYPE_MODE (type), type, false); + const bool by_reference_p = pass_va_arg_by_reference (type); const bool float_reg_arg_p = (TARGET_FPU && !by_reference_p && ((GET_MODE_CLASS (TYPE_MODE (type)) == MODE_FLOAT diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index a99956755ec..9c90c146896 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -3252,7 +3252,7 @@ xtensa_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, tree lab_false, lab_over, lab_false2; bool indirect; - indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + indirect = pass_va_arg_by_reference (type); if (indirect) type = build_pointer_type (type); diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 111ed2ea816..8a83ce8332c 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -2177,7 +2177,7 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, if (ARGS_GROW_DOWNWARD) gcc_unreachable (); - indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false); + indirect = pass_va_arg_by_reference (type); if (indirect) type = build_pointer_type (type);