LCOV - code coverage report
Current view: top level - gcc - calls.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 78.2 % 2093 1636
Test Date: 2026-06-20 15:32:29 Functions: 86.0 % 50 43
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Convert function calls to rtl insns, for GNU C compiler.
       2              :    Copyright (C) 1989-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : #include "config.h"
      21              : #include "system.h"
      22              : #include "coretypes.h"
      23              : #include "backend.h"
      24              : #include "target.h"
      25              : #include "rtl.h"
      26              : #include "tree.h"
      27              : #include "gimple.h"
      28              : #include "predict.h"
      29              : #include "memmodel.h"
      30              : #include "tm_p.h"
      31              : #include "stringpool.h"
      32              : #include "expmed.h"
      33              : #include "optabs.h"
      34              : #include "emit-rtl.h"
      35              : #include "cgraph.h"
      36              : #include "diagnostic-core.h"
      37              : #include "fold-const.h"
      38              : #include "stor-layout.h"
      39              : #include "varasm.h"
      40              : #include "internal-fn.h"
      41              : #include "dojump.h"
      42              : #include "explow.h"
      43              : #include "calls.h"
      44              : #include "expr.h"
      45              : #include "output.h"
      46              : #include "langhooks.h"
      47              : #include "except.h"
      48              : #include "dbgcnt.h"
      49              : #include "rtl-iter.h"
      50              : #include "tree-vrp.h"
      51              : #include "tree-ssanames.h"
      52              : #include "intl.h"
      53              : #include "stringpool.h"
      54              : #include "hash-map.h"
      55              : #include "hash-traits.h"
      56              : #include "attribs.h"
      57              : #include "builtins.h"
      58              : #include "gimple-iterator.h"
      59              : #include "gimple-fold.h"
      60              : #include "attr-fnspec.h"
      61              : #include "value-query.h"
      62              : #include "tree-pretty-print.h"
      63              : #include "tree-eh.h"
      64              : #include "regs.h"
      65              : #include "function-abi.h"
      66              : 
      67              : /* Like PREFERRED_STACK_BOUNDARY but in units of bytes, not bits.  */
      68              : #define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
      69              : 
      70              : /* Data structure and subroutines used within expand_call.  */
      71              : 
      72              : struct arg_data
      73              : {
      74              :   /* Tree node for this argument.  */
      75              :   tree tree_value;
      76              :   /* Mode for value; TYPE_MODE unless promoted.  */
      77              :   machine_mode mode;
      78              :   /* Current RTL value for argument, or 0 if it isn't precomputed.  */
      79              :   rtx value;
      80              :   /* Initially-compute RTL value for argument; only for const functions.  */
      81              :   rtx initial_value;
      82              :   /* Register to pass this argument in, 0 if passed on stack, or an
      83              :      PARALLEL if the arg is to be copied into multiple non-contiguous
      84              :      registers.  */
      85              :   rtx reg;
      86              :   /* Register to pass this argument in when generating tail call sequence.
      87              :      This is not the same register as for normal calls on machines with
      88              :      register windows.  */
      89              :   rtx tail_call_reg;
      90              :   /* If REG is a PARALLEL, this is a copy of VALUE pulled into the correct
      91              :      form for emit_group_move.  */
      92              :   rtx parallel_value;
      93              :   /* If REG was promoted from the actual mode of the argument expression,
      94              :      indicates whether the promotion is sign- or zero-extended.  */
      95              :   int unsignedp;
      96              :   /* Number of bytes to put in registers.  0 means put the whole arg
      97              :      in registers.  Also 0 if not passed in registers.  */
      98              :   int partial;
      99              :   /* True if argument must be passed on stack.
     100              :      Note that some arguments may be passed on the stack
     101              :      even though pass_on_stack is false, just because FUNCTION_ARG says so.
     102              :      pass_on_stack identifies arguments that *cannot* go in registers.  */
     103              :   bool pass_on_stack;
     104              :   /* Some fields packaged up for locate_and_pad_parm.  */
     105              :   struct locate_and_pad_arg_data locate;
     106              :   /* Location on the stack at which parameter should be stored.  The store
     107              :      has already been done if STACK == VALUE.  */
     108              :   rtx stack;
     109              :   /* Location on the stack of the start of this argument slot.  This can
     110              :      differ from STACK if this arg pads downward.  This location is known
     111              :      to be aligned to TARGET_FUNCTION_ARG_BOUNDARY.  */
     112              :   rtx stack_slot;
     113              :   /* Place that this stack area has been saved, if needed.  */
     114              :   rtx save_area;
     115              :   /* If an argument's alignment does not permit direct copying into registers,
     116              :      copy in smaller-sized pieces into pseudos.  These are stored in a
     117              :      block pointed to by this field.  The next field says how many
     118              :      word-sized pseudos we made.  */
     119              :   rtx *aligned_regs;
     120              :   int n_aligned_regs;
     121              : };
     122              : 
     123              : /* A vector of one char per byte of stack space.  A byte if nonzero if
     124              :    the corresponding stack location has been used.
     125              :    This vector is used to prevent a function call within an argument from
     126              :    clobbering any stack already set up.  */
     127              : static char *stack_usage_map;
     128              : 
     129              : /* Size of STACK_USAGE_MAP.  */
     130              : static unsigned int highest_outgoing_arg_in_use;
     131              : 
     132              : /* Assume that any stack location at this byte index is used,
     133              :    without checking the contents of stack_usage_map.  */
     134              : static unsigned HOST_WIDE_INT stack_usage_watermark = HOST_WIDE_INT_M1U;
     135              : 
     136              : /* A bitmap of virtual-incoming stack space.  Bit is set if the corresponding
     137              :    stack location's tail call argument has been already stored into the stack.
     138              :    This bitmap is used to prevent sibling call optimization if function tries
     139              :    to use parent's incoming argument slots when they have been already
     140              :    overwritten with tail call arguments.  */
     141              : static sbitmap stored_args_map;
     142              : 
     143              : /* Assume that any virtual-incoming location at this byte index has been
     144              :    stored, without checking the contents of stored_args_map.  */
     145              : static unsigned HOST_WIDE_INT stored_args_watermark;
     146              : 
     147              : /* stack_arg_under_construction is nonzero when an argument may be
     148              :    initialized with a constructor call (including a C function that
     149              :    returns a BLKmode struct) and expand_call must take special action
     150              :    to make sure the object being constructed does not overlap the
     151              :    argument list for the constructor call.  */
     152              : static int stack_arg_under_construction;
     153              : 
     154              : static void precompute_register_parameters (int, struct arg_data *, int *);
     155              : static bool store_one_arg (struct arg_data *, rtx, int, int, int);
     156              : static void store_unaligned_arguments_into_pseudos (struct arg_data *, int);
     157              : static bool finalize_must_preallocate (bool, int, struct arg_data *,
     158              :                                        struct args_size *);
     159              : static void precompute_arguments (int, struct arg_data *);
     160              : static void compute_argument_addresses (struct arg_data *, rtx, int);
     161              : static rtx rtx_for_function_call (tree, tree);
     162              : static void load_register_parameters (struct arg_data *, int, rtx *, int,
     163              :                                       int, bool *);
     164              : static int special_function_p (const_tree, int);
     165              : static bool check_sibcall_argument_overlap_1 (rtx);
     166              : static bool check_sibcall_argument_overlap (rtx_insn *, struct arg_data *,
     167              :                                             bool);
     168              : static tree split_complex_types (tree);
     169              : 
     170              : #ifdef REG_PARM_STACK_SPACE
     171              : static rtx save_fixed_argument_area (int, rtx, int *, int *);
     172              : static void restore_fixed_argument_area (rtx, rtx, int, int);
     173              : #endif
     174              : 
     175              : /* Return true if bytes [LOWER_BOUND, UPPER_BOUND) of the outgoing
     176              :    stack region might already be in use.  */
     177              : 
     178              : static bool
     179        53816 : stack_region_maybe_used_p (poly_uint64 lower_bound, poly_uint64 upper_bound,
     180              :                            unsigned int reg_parm_stack_space)
     181              : {
     182        53816 :   unsigned HOST_WIDE_INT const_lower, const_upper;
     183        53816 :   const_lower = constant_lower_bound (lower_bound);
     184        53816 :   if (!upper_bound.is_constant (&const_upper))
     185              :     const_upper = HOST_WIDE_INT_M1U;
     186              : 
     187        53816 :   if (const_upper > stack_usage_watermark)
     188              :     return true;
     189              : 
     190              :   /* Don't worry about things in the fixed argument area;
     191              :      it has already been saved.  */
     192        53816 :   const_lower = MAX (const_lower, reg_parm_stack_space);
     193        53816 :   const_upper = MIN (const_upper, highest_outgoing_arg_in_use);
     194       486712 :   for (unsigned HOST_WIDE_INT i = const_lower; i < const_upper; ++i)
     195       432896 :     if (stack_usage_map[i])
     196              :       return true;
     197              :   return false;
     198              : }
     199              : 
     200              : /* Record that bytes [LOWER_BOUND, UPPER_BOUND) of the outgoing
     201              :    stack region are now in use.  */
     202              : 
     203              : static void
     204        53816 : mark_stack_region_used (poly_uint64 lower_bound, poly_uint64 upper_bound)
     205              : {
     206        53816 :   unsigned HOST_WIDE_INT const_lower, const_upper;
     207        53816 :   const_lower = constant_lower_bound (lower_bound);
     208        53816 :   if (upper_bound.is_constant (&const_upper)
     209        53816 :       && const_upper <= highest_outgoing_arg_in_use)
     210       486712 :     for (unsigned HOST_WIDE_INT i = const_lower; i < const_upper; ++i)
     211       432896 :       stack_usage_map[i] = 1;
     212              :   else
     213            0 :     stack_usage_watermark = MIN (stack_usage_watermark, const_lower);
     214        53816 : }
     215              : 
     216              : /* Force FUNEXP into a form suitable for the address of a CALL,
     217              :    and return that as an rtx.  Also load the static chain register
     218              :    if FNDECL is a nested function.
     219              : 
     220              :    CALL_FUSAGE points to a variable holding the prospective
     221              :    CALL_INSN_FUNCTION_USAGE information.  */
     222              : 
     223              : rtx
     224      5953719 : prepare_call_address (tree fndecl_or_type, rtx funexp, rtx static_chain_value,
     225              :                       rtx *call_fusage, int reg_parm_seen, int flags)
     226              : {
     227              :   /* Make a valid memory address and copy constants through pseudo-regs,
     228              :      but not for a constant address if -fno-function-cse.  */
     229      5953719 :   if (GET_CODE (funexp) != SYMBOL_REF)
     230              :     {
     231              :       /* If it's an indirect call by descriptor, generate code to perform
     232              :          runtime identification of the pointer and load the descriptor.  */
     233       182430 :       if ((flags & ECF_BY_DESCRIPTOR) && !flag_trampolines)
     234              :         {
     235            0 :           const int bit_val = targetm.calls.custom_function_descriptors;
     236            0 :           rtx call_lab = gen_label_rtx ();
     237              : 
     238            0 :           gcc_assert (fndecl_or_type && TYPE_P (fndecl_or_type));
     239            0 :           fndecl_or_type
     240            0 :             = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, NULL_TREE,
     241              :                           fndecl_or_type);
     242            0 :           DECL_STATIC_CHAIN (fndecl_or_type) = 1;
     243            0 :           rtx chain = targetm.calls.static_chain (fndecl_or_type, false);
     244              : 
     245            0 :           if (GET_MODE (funexp) != Pmode)
     246            0 :             funexp = convert_memory_address (Pmode, funexp);
     247              : 
     248              :           /* Avoid long live ranges around function calls.  */
     249            0 :           funexp = copy_to_mode_reg (Pmode, funexp);
     250              : 
     251            0 :           if (REG_P (chain))
     252            0 :             emit_insn (gen_rtx_CLOBBER (VOIDmode, chain));
     253              : 
     254              :           /* Emit the runtime identification pattern.  */
     255            0 :           rtx mask = gen_rtx_AND (Pmode, funexp, GEN_INT (bit_val));
     256            0 :           emit_cmp_and_jump_insns (mask, const0_rtx, EQ, NULL_RTX, Pmode, 1,
     257              :                                    call_lab);
     258              : 
     259              :           /* Statically predict the branch to very likely taken.  */
     260            0 :           rtx_insn *insn = get_last_insn ();
     261            0 :           if (JUMP_P (insn))
     262            0 :             predict_insn_def (insn, PRED_BUILTIN_EXPECT, TAKEN);
     263              : 
     264              :           /* Load the descriptor.  */
     265            0 :           rtx mem = gen_rtx_MEM (ptr_mode,
     266            0 :                                  plus_constant (Pmode, funexp, - bit_val));
     267            0 :           MEM_NOTRAP_P (mem) = 1;
     268            0 :           mem = convert_memory_address (Pmode, mem);
     269            0 :           emit_move_insn (chain, mem);
     270              : 
     271            0 :           mem = gen_rtx_MEM (ptr_mode,
     272            0 :                              plus_constant (Pmode, funexp,
     273            0 :                                             POINTER_SIZE / BITS_PER_UNIT
     274            0 :                                               - bit_val));
     275            0 :           MEM_NOTRAP_P (mem) = 1;
     276            0 :           mem = convert_memory_address (Pmode, mem);
     277            0 :           emit_move_insn (funexp, mem);
     278              : 
     279            0 :           emit_label (call_lab);
     280              : 
     281            0 :           if (REG_P (chain))
     282              :             {
     283            0 :               use_reg (call_fusage, chain);
     284            0 :               STATIC_CHAIN_REG_P (chain) = 1;
     285              :             }
     286              : 
     287              :           /* Make sure we're not going to be overwritten below.  */
     288            0 :           gcc_assert (!static_chain_value);
     289              :         }
     290              : 
     291              :       /* If we are using registers for parameters, force the
     292              :          function address into a register now.  */
     293       137404 :       funexp = ((reg_parm_seen
     294       137404 :                  && targetm.small_register_classes_for_mode_p (FUNCTION_MODE))
     295       319834 :                  ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
     296        45026 :                  : memory_address (FUNCTION_MODE, funexp));
     297              :     }
     298              :   else
     299              :     {
     300              :       /* funexp could be a SYMBOL_REF represents a function pointer which is
     301              :          of ptr_mode.  In this case, it should be converted into address mode
     302              :          to be a valid address for memory rtx pattern.  See PR 64971.  */
     303      6479179 :       if (GET_MODE (funexp) != Pmode)
     304            0 :         funexp = convert_memory_address (Pmode, funexp);
     305              : 
     306      5771289 :       if (!(flags & ECF_SIBCALL))
     307              :         {
     308      5771289 :           if (!NO_FUNCTION_CSE && optimize && ! flag_no_function_cse)
     309              :             funexp = force_reg (Pmode, funexp);
     310              :         }
     311              :     }
     312              : 
     313      5953719 :   if (static_chain_value != 0
     314      5953719 :       && (TREE_CODE (fndecl_or_type) != FUNCTION_DECL
     315        15437 :           || DECL_STATIC_CHAIN (fndecl_or_type)))
     316              :     {
     317        37756 :       rtx chain;
     318              : 
     319        37756 :       chain = targetm.calls.static_chain (fndecl_or_type, false);
     320        37756 :       static_chain_value = convert_memory_address (Pmode, static_chain_value);
     321              : 
     322        37756 :       emit_move_insn (chain, static_chain_value);
     323        37756 :       if (REG_P (chain))
     324              :         {
     325        37756 :           use_reg (call_fusage, chain);
     326        37756 :           STATIC_CHAIN_REG_P (chain) = 1;
     327              :         }
     328              :     }
     329              : 
     330      5953719 :   return funexp;
     331              : }
     332              : 
     333              : /* Generate instructions to call function FUNEXP,
     334              :    and optionally pop the results.
     335              :    The CALL_INSN is the first insn generated.
     336              : 
     337              :    FNDECL is the declaration node of the function.  This is given to the
     338              :    hook TARGET_RETURN_POPS_ARGS to determine whether this function pops
     339              :    its own args.
     340              : 
     341              :    FUNTYPE is the data type of the function.  This is given to the hook
     342              :    TARGET_RETURN_POPS_ARGS to determine whether this function pops its
     343              :    own args.  We used to allow an identifier for library functions, but
     344              :    that doesn't work when the return type is an aggregate type and the
     345              :    calling convention says that the pointer to this aggregate is to be
     346              :    popped by the callee.
     347              : 
     348              :    STACK_SIZE is the number of bytes of arguments on the stack,
     349              :    ROUNDED_STACK_SIZE is that number rounded up to
     350              :    PREFERRED_STACK_BOUNDARY; zero if the size is variable.  This is
     351              :    both to put into the call insn and to generate explicit popping
     352              :    code if necessary.
     353              : 
     354              :    STRUCT_VALUE_SIZE is the number of bytes wanted in a structure value.
     355              :    It is zero if this call doesn't want a structure value.
     356              : 
     357              :    NEXT_ARG_REG is the rtx that results from executing
     358              :      targetm.calls.function_arg (&args_so_far,
     359              :                                  function_arg_info::end_marker ());
     360              :    just after all the args have had their registers assigned.
     361              :    This could be whatever you like, but normally it is the first
     362              :    arg-register beyond those used for args in this call,
     363              :    or 0 if all the arg-registers are used in this call.
     364              :    It is passed on to `gen_call' so you can put this info in the call insn.
     365              : 
     366              :    VALREG is a hard register in which a value is returned,
     367              :    or 0 if the call does not return a value.
     368              : 
     369              :    OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
     370              :    the args to this call were processed.
     371              :    We restore `inhibit_defer_pop' to that value.
     372              : 
     373              :    CALL_FUSAGE is either empty or an EXPR_LIST of USE expressions that
     374              :    denote registers used by the called function.  */
     375              : 
     376              : static void
     377      5953236 : emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNUSED,
     378              :              tree funtype ATTRIBUTE_UNUSED,
     379              :              poly_int64 stack_size ATTRIBUTE_UNUSED,
     380              :              poly_int64 rounded_stack_size,
     381              :              poly_int64 struct_value_size ATTRIBUTE_UNUSED,
     382              :              rtx next_arg_reg ATTRIBUTE_UNUSED, rtx valreg,
     383              :              int old_inhibit_defer_pop, rtx call_fusage, int ecf_flags,
     384              :              cumulative_args_t args_so_far ATTRIBUTE_UNUSED)
     385              : {
     386      6695420 :   rtx rounded_stack_size_rtx = gen_int_mode (rounded_stack_size, Pmode);
     387      5953236 :   rtx call, funmem, pat;
     388      5953236 :   bool already_popped = false;
     389      5953236 :   poly_int64 n_popped = 0;
     390              : 
     391              :   /* Sibling call patterns never pop arguments (no sibcall(_value)_pop
     392              :      patterns exist).  Any popping that the callee does on return will
     393              :      be from our caller's frame rather than ours.  */
     394      5953236 :   if (!(ecf_flags & ECF_SIBCALL))
     395              :     {
     396      5827530 :       n_popped += targetm.calls.return_pops_args (fndecl, funtype, stack_size);
     397              : 
     398              : #ifdef CALL_POPS_ARGS
     399              :       n_popped += CALL_POPS_ARGS (*get_cumulative_args (args_so_far));
     400              : #endif
     401              :     }
     402              : 
     403              :   /* Ensure address is valid.  SYMBOL_REF is already valid, so no need,
     404              :      and we don't want to load it into a register as an optimization,
     405              :      because prepare_call_address already did it if it should be done.  */
     406      5953236 :   if (GET_CODE (funexp) != SYMBOL_REF)
     407       182401 :     funexp = memory_address (FUNCTION_MODE, funexp);
     408              : 
     409      5953236 :   funmem = gen_rtx_MEM (FUNCTION_MODE, funexp);
     410      5953236 :   if (fndecl && TREE_CODE (fndecl) == FUNCTION_DECL)
     411              :     {
     412      5653123 :       tree t = fndecl;
     413              : 
     414              :       /* Although a built-in FUNCTION_DECL and its non-__builtin
     415              :          counterpart compare equal and get a shared mem_attrs, they
     416              :          produce different dump output in compare-debug compilations,
     417              :          if an entry gets garbage collected in one compilation, then
     418              :          adds a different (but equivalent) entry, while the other
     419              :          doesn't run the garbage collector at the same spot and then
     420              :          shares the mem_attr with the equivalent entry. */
     421      5653123 :       if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL)
     422              :         {
     423      1197580 :           tree t2 = builtin_decl_explicit (DECL_FUNCTION_CODE (t));
     424      1197580 :           if (t2)
     425      5653123 :             t = t2;
     426              :         }
     427              : 
     428      5653123 :         set_mem_expr (funmem, t);
     429      5653123 :     }
     430       300113 :   else if (fntree)
     431       182418 :     set_mem_expr (funmem, build_simple_mem_ref (CALL_EXPR_FN (fntree)));
     432              : 
     433      5953236 :   if (ecf_flags & ECF_SIBCALL)
     434              :     {
     435       125706 :       if (valreg)
     436        36884 :         pat = targetm.gen_sibcall_value (valreg, funmem,
     437              :                                          rounded_stack_size_rtx,
     438              :                                          next_arg_reg, NULL_RTX);
     439              :       else
     440        88822 :         pat = targetm.gen_sibcall (funmem, rounded_stack_size_rtx,
     441              :                                    next_arg_reg,
     442        88822 :                                    gen_int_mode (struct_value_size, Pmode));
     443              :     }
     444              :   /* If the target has "call" or "call_value" insns, then prefer them
     445              :      if no arguments are actually popped.  If the target does not have
     446              :      "call" or "call_value" insns, then we must use the popping versions
     447              :      even if the call has no arguments to pop.  */
     448      5827530 :   else if (maybe_ne (n_popped, 0)
     449     11527740 :            || !(valreg
     450      2414904 :                 ? targetm.have_call_value ()
     451      3285306 :                 : targetm.have_call ()))
     452              :     {
     453       254640 :       rtx n_pop = gen_int_mode (n_popped, Pmode);
     454              : 
     455              :       /* If this subroutine pops its own args, record that in the call insn
     456              :          if possible, for the sake of frame pointer elimination.  */
     457              : 
     458       127320 :       if (valreg)
     459            0 :         pat = targetm.gen_call_value_pop (valreg, funmem,
     460              :                                           rounded_stack_size_rtx,
     461              :                                           next_arg_reg, n_pop);
     462              :       else
     463       127320 :         pat = targetm.gen_call_pop (funmem, rounded_stack_size_rtx,
     464              :                                     next_arg_reg, n_pop);
     465              : 
     466              :       already_popped = true;
     467              :     }
     468              :   else
     469              :     {
     470      5700210 :       if (valreg)
     471      2414904 :         pat = targetm.gen_call_value (valreg, funmem, rounded_stack_size_rtx,
     472              :                                       next_arg_reg, NULL_RTX);
     473              :       else
     474      3285306 :         pat = targetm.gen_call (funmem, rounded_stack_size_rtx, next_arg_reg,
     475      3285306 :                                 gen_int_mode (struct_value_size, Pmode));
     476              :     }
     477      5953236 :   emit_insn (pat);
     478              : 
     479              :   /* Find the call we just emitted.  */
     480      5953236 :   rtx_call_insn *call_insn = last_call_insn ();
     481              : 
     482              :   /* Some target create a fresh MEM instead of reusing the one provided
     483              :      above.  Set its MEM_EXPR.  */
     484      5953236 :   call = get_call_rtx_from (call_insn);
     485      5953236 :   if (call
     486      6071536 :       && MEM_EXPR (XEXP (call, 0)) == NULL_TREE
     487      6071536 :       && MEM_EXPR (funmem) != NULL_TREE)
     488          605 :     set_mem_expr (XEXP (call, 0), MEM_EXPR (funmem));
     489              : 
     490              :   /* Put the register usage information there.  */
     491      5953236 :   add_function_usage_to (call_insn, call_fusage);
     492              : 
     493              :   /* If this is a const call, then set the insn's unchanging bit.  */
     494      5953236 :   if (ecf_flags & ECF_CONST)
     495       206016 :     RTL_CONST_CALL_P (call_insn) = 1;
     496              : 
     497              :   /* If this is a pure call, then set the insn's unchanging bit.  */
     498      5953236 :   if (ecf_flags & ECF_PURE)
     499       308690 :     RTL_PURE_CALL_P (call_insn) = 1;
     500              : 
     501              :   /* If this is a const call, then set the insn's unchanging bit.  */
     502      5953236 :   if (ecf_flags & ECF_LOOPING_CONST_OR_PURE)
     503        38920 :     RTL_LOOPING_CONST_OR_PURE_CALL_P (call_insn) = 1;
     504              : 
     505              :   /* Create a nothrow REG_EH_REGION note, if needed.  */
     506      5953236 :   make_reg_eh_region_note (call_insn, ecf_flags, 0);
     507              : 
     508      5953236 :   if (ecf_flags & ECF_NORETURN)
     509       769493 :     add_reg_note (call_insn, REG_NORETURN, const0_rtx);
     510              : 
     511      5953236 :   if (ecf_flags & ECF_RETURNS_TWICE)
     512              :     {
     513         1647 :       add_reg_note (call_insn, REG_SETJMP, const0_rtx);
     514         1647 :       cfun->calls_setjmp = 1;
     515              :     }
     516              : 
     517      5953236 :   CALL_INSN_ABI_ID (call_insn) = (funtype ? fntype_abi (funtype).id () : 0);
     518      5953236 :   SIBLING_CALL_P (call_insn) = ((ecf_flags & ECF_SIBCALL) != 0);
     519              : 
     520              :   /* Restore this now, so that we do defer pops for this call's args
     521              :      if the context of the call as a whole permits.  */
     522      5953236 :   inhibit_defer_pop = old_inhibit_defer_pop;
     523              : 
     524      5953236 :   if (maybe_ne (n_popped, 0))
     525              :     {
     526       127320 :       if (!already_popped)
     527            0 :         CALL_INSN_FUNCTION_USAGE (call_insn)
     528            0 :           = gen_rtx_EXPR_LIST (VOIDmode,
     529              :                                gen_rtx_CLOBBER (VOIDmode, stack_pointer_rtx),
     530              :                                CALL_INSN_FUNCTION_USAGE (call_insn));
     531       127320 :       rounded_stack_size -= n_popped;
     532       254640 :       rounded_stack_size_rtx = gen_int_mode (rounded_stack_size, Pmode);
     533       127320 :       stack_pointer_delta -= n_popped;
     534              : 
     535       127320 :       add_args_size_note (call_insn, stack_pointer_delta);
     536              : 
     537              :       /* If popup is needed, stack realign must use DRAP  */
     538       127320 :       if (SUPPORTS_STACK_ALIGNMENT)
     539       127320 :         crtl->need_drap = true;
     540              :     }
     541              :   /* For noreturn calls when not accumulating outgoing args force
     542              :      REG_ARGS_SIZE note to prevent crossjumping of calls with different
     543              :      args sizes.  */
     544      5825916 :   else if (!ACCUMULATE_OUTGOING_ARGS && (ecf_flags & ECF_NORETURN) != 0)
     545       769313 :     add_args_size_note (call_insn, stack_pointer_delta);
     546              : 
     547      5953236 :   if (!ACCUMULATE_OUTGOING_ARGS)
     548              :     {
     549              :       /* If returning from the subroutine does not automatically pop the args,
     550              :          we need an instruction to pop them sooner or later.
     551              :          Perhaps do it now; perhaps just record how much space to pop later.
     552              : 
     553              :          If returning from the subroutine does pop the args, indicate that the
     554              :          stack pointer will be changed.  */
     555              : 
     556      5878672 :       if (maybe_ne (rounded_stack_size, 0))
     557              :         {
     558       943231 :           if (ecf_flags & ECF_NORETURN)
     559              :             /* Just pretend we did the pop.  */
     560      5953236 :             stack_pointer_delta -= rounded_stack_size;
     561       889068 :           else if (flag_defer_pop && inhibit_defer_pop == 0
     562       782617 :               && ! (ecf_flags & (ECF_CONST | ECF_PURE)))
     563      5953236 :             pending_stack_adjust += rounded_stack_size;
     564              :           else
     565       123215 :             adjust_stack (rounded_stack_size_rtx);
     566              :         }
     567              :     }
     568              :   /* When we accumulate outgoing args, we must avoid any stack manipulations.
     569              :      Restore the stack pointer to its original value now.  Usually
     570              :      ACCUMULATE_OUTGOING_ARGS targets don't get here, but there are exceptions.
     571              :      On  i386 ACCUMULATE_OUTGOING_ARGS can be enabled on demand, and
     572              :      popping variants of functions exist as well.
     573              : 
     574              :      ??? We may optimize similar to defer_pop above, but it is
     575              :      probably not worthwhile.
     576              : 
     577              :      ??? It will be worthwhile to enable combine_stack_adjustments even for
     578              :      such machines.  */
     579        74564 :   else if (maybe_ne (n_popped, 0))
     580            0 :     anti_adjust_stack (gen_int_mode (n_popped, Pmode));
     581      5953236 : }
     582              : 
     583              : /* Determine if the function identified by FNDECL is one with
     584              :    special properties we wish to know about.  Modify FLAGS accordingly.
     585              : 
     586              :    For example, if the function might return more than one time (setjmp), then
     587              :    set ECF_RETURNS_TWICE.
     588              : 
     589              :    Set ECF_MAY_BE_ALLOCA for any memory allocation function that might allocate
     590              :    space from the stack such as alloca.  */
     591              : 
     592              : static int
     593   4402814475 : special_function_p (const_tree fndecl, int flags)
     594              : {
     595   4402814475 :   tree name_decl = DECL_NAME (fndecl);
     596              : 
     597   4402814475 :   if (maybe_special_function_p (fndecl)
     598   7486447214 :       && IDENTIFIER_LENGTH (name_decl) <= 11)
     599              :     {
     600    567871081 :       const char *name = IDENTIFIER_POINTER (name_decl);
     601    567871081 :       const char *tname = name;
     602              : 
     603              :       /* We assume that alloca will always be called by name.  It
     604              :          makes no sense to pass it as a pointer-to-function to
     605              :          anything that does not understand its behavior.  */
     606    567871081 :       if (IDENTIFIER_LENGTH (name_decl) == 6
     607    145575345 :           && name[0] == 'a'
     608    568544730 :           && ! strcmp (name, "alloca"))
     609        79196 :         flags |= ECF_MAY_BE_ALLOCA;
     610              : 
     611              :       /* Disregard prefix _ or __.  */
     612    567871081 :       if (name[0] == '_')
     613              :         {
     614     39769893 :           if (name[1] == '_')
     615     13049375 :             tname += 2;
     616              :           else
     617     26720518 :             tname += 1;
     618              :         }
     619              : 
     620              :       /* ECF_RETURNS_TWICE is safe even for -ffreestanding.  */
     621    567871081 :       if (! strcmp (tname, "setjmp")
     622    567518177 :           || ! strcmp (tname, "sigsetjmp")
     623    567489590 :           || ! strcmp (name, "savectx")
     624    567489590 :           || ! strcmp (name, "vfork")
     625    567468275 :           || ! strcmp (name, "getcontext"))
     626       428936 :         flags |= ECF_RETURNS_TWICE;
     627              :     }
     628              : 
     629   4402814475 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
     630   4402814475 :       && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (fndecl)))
     631     13539199 :     flags |= ECF_MAY_BE_ALLOCA;
     632              : 
     633   4402814475 :   return flags;
     634              : }
     635              : 
     636              : /* Return fnspec for DECL.  */
     637              : 
     638              : static attr_fnspec
     639      5653121 : decl_fnspec (tree fndecl)
     640              : {
     641      5653121 :   tree attr;
     642      5653121 :   tree type = TREE_TYPE (fndecl);
     643      5653121 :   if (type)
     644              :     {
     645      5653121 :       attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
     646      5653121 :       if (attr)
     647              :         {
     648       355304 :           return TREE_VALUE (TREE_VALUE (attr));
     649              :         }
     650              :     }
     651      5297817 :   if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     652      1185555 :     return builtin_fnspec (fndecl);
     653      4112262 :   return "";
     654              : }
     655              : 
     656              : /* Similar to special_function_p; return a set of ERF_ flags for the
     657              :    function FNDECL.  */
     658              : static int
     659      5653121 : decl_return_flags (tree fndecl)
     660              : {
     661      5653121 :   attr_fnspec fnspec = decl_fnspec (fndecl);
     662              : 
     663      5653121 :   unsigned int arg;
     664      5653121 :   if (fnspec.returns_arg (&arg))
     665       161269 :     return ERF_RETURNS_ARG | arg;
     666              : 
     667      5491852 :   if (fnspec.returns_noalias_p ())
     668        61293 :     return ERF_NOALIAS;
     669              :   return 0;
     670              : }
     671              : 
     672              : /* Return true when FNDECL represents a call to setjmp.  */
     673              : 
     674              : bool
     675     31966720 : setjmp_call_p (const_tree fndecl)
     676              : {
     677     31966720 :   if (DECL_IS_RETURNS_TWICE (fndecl))
     678              :     return true;
     679     31965208 :   if (special_function_p (fndecl, 0) & ECF_RETURNS_TWICE)
     680         2277 :     return true;
     681              : 
     682              :   return false;
     683              : }
     684              : 
     685              : 
     686              : /* Return true if STMT may be an alloca call.  */
     687              : 
     688              : bool
     689     18479784 : gimple_maybe_alloca_call_p (const gimple *stmt)
     690              : {
     691     18479784 :   tree fndecl;
     692              : 
     693     18479784 :   if (!is_gimple_call (stmt))
     694              :     return false;
     695              : 
     696     18479784 :   fndecl = gimple_call_fndecl (stmt);
     697     18479784 :   if (fndecl && (special_function_p (fndecl, 0) & ECF_MAY_BE_ALLOCA))
     698              :     return true;
     699              : 
     700              :   return false;
     701              : }
     702              : 
     703              : /* Return true if STMT is a builtin alloca call.  */
     704              : 
     705              : bool
     706    160761852 : gimple_alloca_call_p (const gimple *stmt)
     707              : {
     708    160761852 :   tree fndecl;
     709              : 
     710    160761852 :   if (!is_gimple_call (stmt))
     711              :     return false;
     712              : 
     713     27047084 :   fndecl = gimple_call_fndecl (stmt);
     714     27047084 :   if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     715      7162804 :     switch (DECL_FUNCTION_CODE (fndecl))
     716              :       {
     717       169609 :       CASE_BUILT_IN_ALLOCA:
     718       169609 :         return gimple_call_num_args (stmt) > 0;
     719              :       default:
     720              :         break;
     721              :       }
     722              : 
     723              :   return false;
     724              : }
     725              : 
     726              : /* Return true when exp contains a builtin alloca call.  */
     727              : 
     728              : bool
     729      2908773 : alloca_call_p (const_tree exp)
     730              : {
     731      2908773 :   tree fndecl;
     732      2908773 :   if (TREE_CODE (exp) == CALL_EXPR
     733      2908773 :       && (fndecl = get_callee_fndecl (exp))
     734      5817546 :       && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
     735      1637238 :     switch (DECL_FUNCTION_CODE (fndecl))
     736              :       {
     737              :       CASE_BUILT_IN_ALLOCA:
     738              :         return true;
     739              :       default:
     740              :         break;
     741              :       }
     742              : 
     743              :   return false;
     744              : }
     745              : 
     746              : /* Return TRUE if FNDECL is either a TM builtin or a TM cloned
     747              :    function.  Return FALSE otherwise.  */
     748              : 
     749              : static bool
     750       866481 : is_tm_builtin (const_tree fndecl)
     751              : {
     752       866481 :   if (fndecl == NULL)
     753              :     return false;
     754              : 
     755      1637085 :   if (decl_is_tm_clone (fndecl))
     756              :     return true;
     757              : 
     758       843971 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
     759              :     {
     760       458759 :       switch (DECL_FUNCTION_CODE (fndecl))
     761              :         {
     762       316770 :         case BUILT_IN_TM_COMMIT:
     763       316770 :         case BUILT_IN_TM_COMMIT_EH:
     764       316770 :         case BUILT_IN_TM_ABORT:
     765       316770 :         case BUILT_IN_TM_IRREVOCABLE:
     766       316770 :         case BUILT_IN_TM_GETTMCLONE_IRR:
     767       316770 :         case BUILT_IN_TM_MEMCPY:
     768       316770 :         case BUILT_IN_TM_MEMMOVE:
     769       316770 :         case BUILT_IN_TM_MEMSET:
     770       316770 :         CASE_BUILT_IN_TM_STORE (1):
     771       316770 :         CASE_BUILT_IN_TM_STORE (2):
     772       316770 :         CASE_BUILT_IN_TM_STORE (4):
     773       316770 :         CASE_BUILT_IN_TM_STORE (8):
     774       316770 :         CASE_BUILT_IN_TM_STORE (FLOAT):
     775       316770 :         CASE_BUILT_IN_TM_STORE (DOUBLE):
     776       316770 :         CASE_BUILT_IN_TM_STORE (LDOUBLE):
     777       316770 :         CASE_BUILT_IN_TM_STORE (M64):
     778       316770 :         CASE_BUILT_IN_TM_STORE (M128):
     779       316770 :         CASE_BUILT_IN_TM_STORE (M256):
     780       316770 :         CASE_BUILT_IN_TM_LOAD (1):
     781       316770 :         CASE_BUILT_IN_TM_LOAD (2):
     782       316770 :         CASE_BUILT_IN_TM_LOAD (4):
     783       316770 :         CASE_BUILT_IN_TM_LOAD (8):
     784       316770 :         CASE_BUILT_IN_TM_LOAD (FLOAT):
     785       316770 :         CASE_BUILT_IN_TM_LOAD (DOUBLE):
     786       316770 :         CASE_BUILT_IN_TM_LOAD (LDOUBLE):
     787       316770 :         CASE_BUILT_IN_TM_LOAD (M64):
     788       316770 :         CASE_BUILT_IN_TM_LOAD (M128):
     789       316770 :         CASE_BUILT_IN_TM_LOAD (M256):
     790       316770 :         case BUILT_IN_TM_LOG:
     791       316770 :         case BUILT_IN_TM_LOG_1:
     792       316770 :         case BUILT_IN_TM_LOG_2:
     793       316770 :         case BUILT_IN_TM_LOG_4:
     794       316770 :         case BUILT_IN_TM_LOG_8:
     795       316770 :         case BUILT_IN_TM_LOG_FLOAT:
     796       316770 :         case BUILT_IN_TM_LOG_DOUBLE:
     797       316770 :         case BUILT_IN_TM_LOG_LDOUBLE:
     798       316770 :         case BUILT_IN_TM_LOG_M64:
     799       316770 :         case BUILT_IN_TM_LOG_M128:
     800       316770 :         case BUILT_IN_TM_LOG_M256:
     801       316770 :           return true;
     802              :         default:
     803              :           break;
     804              :         }
     805              :     }
     806              :   return false;
     807              : }
     808              : 
     809              : /* Detect flags (function attributes) from the function decl or type node.  */
     810              : 
     811              : int
     812   8384225177 : flags_from_decl_or_type (const_tree exp)
     813              : {
     814   8384225177 :   int flags = 0;
     815              : 
     816   8384225177 :   if (DECL_P (exp))
     817              :     {
     818              :       /* The function exp may have the `malloc' attribute.  */
     819   4353029671 :       if (DECL_IS_MALLOC (exp))
     820     94079806 :         flags |= ECF_MALLOC;
     821              : 
     822              :       /* The function exp may have the `returns_twice' attribute.  */
     823   4353029671 :       if (DECL_IS_RETURNS_TWICE (exp))
     824       264236 :         flags |= ECF_RETURNS_TWICE;
     825              : 
     826              :       /* Process the pure and const attributes.  */
     827   4353029671 :       if (TREE_READONLY (exp))
     828    278687616 :         flags |= ECF_CONST;
     829   4353029671 :       if (DECL_PURE_P (exp))
     830    249231253 :         flags |= ECF_PURE;
     831   4353029671 :       if (DECL_LOOPING_CONST_OR_PURE_P (exp))
     832     21848533 :         flags |= ECF_LOOPING_CONST_OR_PURE;
     833              : 
     834   4353029671 :       if (DECL_IS_NOVOPS (exp))
     835       634758 :         flags |= ECF_NOVOPS;
     836   4353029671 :       if (lookup_attribute ("leaf", DECL_ATTRIBUTES (exp)))
     837    854842976 :         flags |= ECF_LEAF;
     838   4353029671 :       if (lookup_attribute ("cold", DECL_ATTRIBUTES (exp)))
     839    362617988 :         flags |= ECF_COLD;
     840              : 
     841   4353029671 :       if (TREE_NOTHROW (exp))
     842   1894219372 :         flags |= ECF_NOTHROW;
     843              : 
     844   4353029671 :       if (flag_tm)
     845              :         {
     846       866481 :           if (is_tm_builtin (exp))
     847       339280 :             flags |= ECF_TM_BUILTIN;
     848       527201 :           else if ((flags & (ECF_CONST|ECF_NOVOPS)) != 0
     849      1038902 :                    || lookup_attribute ("transaction_pure",
     850       511701 :                                         TYPE_ATTRIBUTES (TREE_TYPE (exp))))
     851       122878 :             flags |= ECF_TM_PURE;
     852              :         }
     853              : 
     854   4353029671 :       if (lookup_attribute ("expected_throw", DECL_ATTRIBUTES (exp)))
     855     15338940 :         flags |= ECF_XTHROW;
     856              : 
     857   4353029671 :       flags = special_function_p (exp, flags);
     858              : 
     859   4353029671 :       if ((flags & ECF_CONST) == 0
     860   8427371726 :           && lookup_attribute ("unsequenced noptr",
     861   4074342055 :                                TYPE_ATTRIBUTES (TREE_TYPE (exp))))
     862              :         {
     863              :           /* [[unsequenced]] with no pointers in arguments is like
     864              :              [[gnu::const]] without finite guarantee.  */
     865       120856 :           flags |= ECF_CONST;
     866       120856 :           if ((flags & ECF_PURE) == 0)
     867       120856 :             flags |= ECF_LOOPING_CONST_OR_PURE;
     868              :         }
     869       120856 :       if ((flags & (ECF_CONST | ECF_PURE)) == 0
     870   8177898761 :           && lookup_attribute ("reproducible noptr",
     871   3824989946 :                                TYPE_ATTRIBUTES (TREE_TYPE (exp))))
     872              :         /* [[reproducible]] with no pointers in arguments is like
     873              :            [[gnu::pure]] without finite guarantee.  */
     874       145392 :         flags |= ECF_PURE | ECF_LOOPING_CONST_OR_PURE;
     875              :     }
     876   4031195506 :   else if (TYPE_P (exp))
     877              :     {
     878   4031195506 :       if (TYPE_READONLY (exp))
     879     40969587 :         flags |= ECF_CONST;
     880              : 
     881   4031195506 :       if (flag_tm
     882   4031195506 :           && ((flags & ECF_CONST) != 0
     883       824010 :               || lookup_attribute ("transaction_pure", TYPE_ATTRIBUTES (exp))))
     884       107220 :         flags |= ECF_TM_PURE;
     885              : 
     886   4031195506 :       if ((flags & ECF_CONST) == 0
     887   4031195506 :           && lookup_attribute ("unsequenced noptr", TYPE_ATTRIBUTES (exp)))
     888              :         /* [[unsequenced]] with no pointers in arguments is like
     889              :            [[gnu::const]] without finite guarantee.  */
     890       119175 :         flags |= ECF_CONST | ECF_LOOPING_CONST_OR_PURE;
     891       119175 :       if ((flags & ECF_CONST) == 0
     892   4031076331 :           && lookup_attribute ("reproducible noptr", TYPE_ATTRIBUTES (exp)))
     893              :         /* [[reproducible]] with no pointers in arguments is like
     894              :            [[gnu::pure]] without finite guarantee.  */
     895       149615 :         flags |= ECF_PURE | ECF_LOOPING_CONST_OR_PURE;
     896              :     }
     897              :   else
     898            0 :     gcc_unreachable ();
     899              : 
     900   8384225177 :   if (TREE_THIS_VOLATILE (exp))
     901              :     {
     902    779481366 :       flags |= ECF_NORETURN;
     903    779481366 :       if (flags & (ECF_CONST|ECF_PURE))
     904    115948649 :         flags |= ECF_LOOPING_CONST_OR_PURE;
     905              :     }
     906              : 
     907   8384225177 :   return flags;
     908              : }
     909              : 
     910              : /* Detect flags from a CALL_EXPR.  */
     911              : 
     912              : int
     913    315412773 : call_expr_flags (const_tree t)
     914              : {
     915    315412773 :   int flags;
     916    315412773 :   tree decl = get_callee_fndecl (t);
     917              : 
     918    315412773 :   if (decl)
     919    283355524 :     flags = flags_from_decl_or_type (decl);
     920     32057249 :   else if (CALL_EXPR_FN (t) == NULL_TREE)
     921      1031509 :     flags = internal_fn_flags (CALL_EXPR_IFN (t));
     922              :   else
     923              :     {
     924     31025740 :       tree type = TREE_TYPE (CALL_EXPR_FN (t));
     925     31025740 :       if (type && TREE_CODE (type) == POINTER_TYPE)
     926      6967418 :         flags = flags_from_decl_or_type (TREE_TYPE (type));
     927              :       else
     928              :         flags = 0;
     929     31025740 :       if (CALL_EXPR_BY_DESCRIPTOR (t))
     930            0 :         flags |= ECF_BY_DESCRIPTOR;
     931              :     }
     932              : 
     933    315412773 :   return flags;
     934              : }
     935              : 
     936              : /* Return true if ARG should be passed by invisible reference.  */
     937              : 
     938              : bool
     939     21444241 : pass_by_reference (CUMULATIVE_ARGS *ca, function_arg_info arg)
     940              : {
     941     21444241 :   if (tree type = arg.type)
     942              :     {
     943              :       /* If this type contains non-trivial constructors, then it is
     944              :          forbidden for the middle-end to create any new copies.  */
     945     21238946 :       if (TREE_ADDRESSABLE (type))
     946              :         return true;
     947              : 
     948              :       /* GCC post 3.4 passes *all* variable sized types by reference.  */
     949     21238807 :       if (!TYPE_SIZE (type) || !poly_int_tree_p (TYPE_SIZE (type)))
     950              :         return true;
     951              : 
     952              :       /* If a record type should be passed the same as its first (and only)
     953              :          member, use the type and mode of that member.  */
     954     21238293 :       if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type))
     955              :         {
     956           18 :           arg.type = TREE_TYPE (first_field (type));
     957           18 :           arg.mode = TYPE_MODE (arg.type);
     958              :         }
     959              :     }
     960              : 
     961     21443588 :   return targetm.calls.pass_by_reference (pack_cumulative_args (ca), arg);
     962              : }
     963              : 
     964              : /* Return true if TYPE should be passed by reference when passed to
     965              :    the "..." arguments of a function.  */
     966              : 
     967              : bool
     968        52267 : pass_va_arg_by_reference (tree type)
     969              : {
     970        52267 :   return pass_by_reference (NULL, function_arg_info (type, /*named=*/false));
     971              : }
     972              : 
     973              : /* Decide whether ARG, which occurs in the state described by CA,
     974              :    should be passed by reference.  Return true if so and update
     975              :    ARG accordingly.  */
     976              : 
     977              : bool
     978      9201307 : apply_pass_by_reference_rules (CUMULATIVE_ARGS *ca, function_arg_info &arg)
     979              : {
     980      9201307 :   if (pass_by_reference (ca, arg))
     981              :     {
     982        10128 :       arg.type = build_pointer_type (arg.type);
     983        10128 :       arg.mode = TYPE_MODE (arg.type);
     984        10128 :       arg.pass_by_reference = true;
     985        10128 :       return true;
     986              :     }
     987              :   return false;
     988              : }
     989              : 
     990              : /* Return true if ARG, which is passed by reference, should be callee
     991              :    copied instead of caller copied.  */
     992              : 
     993              : bool
     994         5352 : reference_callee_copied (CUMULATIVE_ARGS *ca, const function_arg_info &arg)
     995              : {
     996         5352 :   if (arg.type && TREE_ADDRESSABLE (arg.type))
     997              :     return false;
     998         5332 :   return targetm.calls.callee_copies (pack_cumulative_args (ca), arg);
     999              : }
    1000              : 
    1001              : 
    1002              : /* Precompute all register parameters as described by ARGS, storing values
    1003              :    into fields within the ARGS array.
    1004              : 
    1005              :    NUM_ACTUALS indicates the total number elements in the ARGS array.
    1006              : 
    1007              :    Set REG_PARM_SEEN if we encounter a register parameter.  */
    1008              : 
    1009              : static void
    1010      5835543 : precompute_register_parameters (int num_actuals, struct arg_data *args,
    1011              :                                 int *reg_parm_seen)
    1012              : {
    1013      5835543 :   int i;
    1014              : 
    1015      5835543 :   *reg_parm_seen = 0;
    1016              : 
    1017     17820953 :   for (i = 0; i < num_actuals; i++)
    1018     11985412 :     if (args[i].reg != 0 && ! args[i].pass_on_stack)
    1019              :       {
    1020      9834632 :         *reg_parm_seen = 1;
    1021              : 
    1022      9834632 :         if (args[i].value == 0)
    1023              :           {
    1024      9834632 :             push_temp_slots ();
    1025      9834632 :             args[i].value = expand_normal (args[i].tree_value);
    1026      9834630 :             preserve_temp_slots (args[i].value);
    1027      9834630 :             pop_temp_slots ();
    1028              :           }
    1029              : 
    1030              :         /* If we are to promote the function arg to a wider mode,
    1031              :            do it now.  */
    1032              : 
    1033      9834630 :         machine_mode old_mode = TYPE_MODE (TREE_TYPE (args[i].tree_value));
    1034              : 
    1035              :         /* Some ABIs require scalar floating point modes to be returned
    1036              :            in a wider scalar integer mode.  We need to explicitly
    1037              :            reinterpret to an integer mode of the correct precision
    1038              :            before extending to the desired result.  */
    1039      9834630 :         if (SCALAR_INT_MODE_P (args[i].mode)
    1040      9446891 :             && SCALAR_FLOAT_MODE_P (old_mode)
    1041      9834630 :             && known_gt (GET_MODE_SIZE (args[i].mode),
    1042              :                          GET_MODE_SIZE (old_mode)))
    1043            0 :           args[i].value = convert_float_to_wider_int (args[i].mode, old_mode,
    1044              :                                                       args[i].value);
    1045      9834630 :         else if (args[i].mode != old_mode)
    1046       305725 :           args[i].value = convert_modes (args[i].mode, old_mode,
    1047              :                                          args[i].value, args[i].unsignedp);
    1048              : 
    1049              :         /* If the value is a non-legitimate constant, force it into a
    1050              :            pseudo now.  TLS symbols sometimes need a call to resolve.  */
    1051      9834630 :         if (CONSTANT_P (args[i].value)
    1052      9834630 :             && (!targetm.legitimate_constant_p (args[i].mode, args[i].value)
    1053      4298141 :                 || targetm.precompute_tls_p (args[i].mode, args[i].value)))
    1054         4104 :           args[i].value = force_reg (args[i].mode, args[i].value);
    1055              : 
    1056              :         /* If we're going to have to load the value by parts, pull the
    1057              :            parts into pseudos.  The part extraction process can involve
    1058              :            non-trivial computation.  */
    1059      9834630 :         if (GET_CODE (args[i].reg) == PARALLEL)
    1060              :           {
    1061       284748 :             tree type = TREE_TYPE (args[i].tree_value);
    1062       284748 :             args[i].parallel_value
    1063       284748 :               = emit_group_load_into_temps (args[i].reg, args[i].value,
    1064       284748 :                                             type, int_size_in_bytes (type));
    1065              :           }
    1066              : 
    1067              :         /* If the value is expensive, and we are inside an appropriately
    1068              :            short loop, put the value into a pseudo and then put the pseudo
    1069              :            into the hard reg.
    1070              : 
    1071              :            For small register classes, also do this if this call uses
    1072              :            register parameters.  This is to avoid reload conflicts while
    1073              :            loading the parameters registers.  */
    1074              : 
    1075      5056506 :         else if ((! (REG_P (args[i].value)
    1076              :                      || (GET_CODE (args[i].value) == SUBREG
    1077        17344 :                          && REG_P (SUBREG_REG (args[i].value)))))
    1078      5039162 :                  && args[i].mode != BLKmode
    1079      5037540 :                  && (set_src_cost (args[i].value, args[i].mode,
    1080      5037540 :                                    optimize_insn_for_speed_p ())
    1081              :                      > COSTS_N_INSNS (1))
    1082     10404572 :                  && ((*reg_parm_seen
    1083       854690 :                       && targetm.small_register_classes_for_mode_p (args[i].mode))
    1084            0 :                      || optimize))
    1085       854690 :           args[i].value = copy_to_mode_reg (args[i].mode, args[i].value);
    1086              :       }
    1087      5835541 : }
    1088              : 
    1089              : #ifdef REG_PARM_STACK_SPACE
    1090              : 
    1091              :   /* The argument list is the property of the called routine and it
    1092              :      may clobber it.  If the fixed area has been used for previous
    1093              :      parameters, we must save and restore it.  */
    1094              : 
    1095              : static rtx
    1096        73378 : save_fixed_argument_area (int reg_parm_stack_space, rtx argblock, int *low_to_save, int *high_to_save)
    1097              : {
    1098        73378 :   unsigned int low;
    1099        73378 :   unsigned int high;
    1100              : 
    1101              :   /* Compute the boundary of the area that needs to be saved, if any.  */
    1102        73378 :   high = reg_parm_stack_space;
    1103        73378 :   if (ARGS_GROW_DOWNWARD)
    1104              :     high += 1;
    1105              : 
    1106        73378 :   if (high > highest_outgoing_arg_in_use)
    1107              :     high = highest_outgoing_arg_in_use;
    1108              : 
    1109       264258 :   for (low = 0; low < high; low++)
    1110       190880 :     if (stack_usage_map[low] != 0 || low >= stack_usage_watermark)
    1111              :       {
    1112              :         int num_to_save;
    1113              :         machine_mode save_mode;
    1114              :         int delta;
    1115              :         rtx addr;
    1116              :         rtx stack_area;
    1117              :         rtx save_area;
    1118              : 
    1119            0 :         while (stack_usage_map[--high] == 0)
    1120              :           ;
    1121              : 
    1122            0 :         *low_to_save = low;
    1123            0 :         *high_to_save = high;
    1124              : 
    1125            0 :         num_to_save = high - low + 1;
    1126              : 
    1127              :         /* If we don't have the required alignment, must do this
    1128              :            in BLKmode.  */
    1129            0 :         scalar_int_mode imode;
    1130            0 :         if (int_mode_for_size (num_to_save * BITS_PER_UNIT, 1).exists (&imode)
    1131            0 :             && (low & (MIN (GET_MODE_SIZE (imode),
    1132            0 :                             BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)) == 0)
    1133            0 :           save_mode = imode;
    1134              :         else
    1135              :           save_mode = BLKmode;
    1136              : 
    1137            0 :         if (ARGS_GROW_DOWNWARD)
    1138              :           delta = -high;
    1139              :         else
    1140            0 :           delta = low;
    1141              : 
    1142            0 :         addr = plus_constant (Pmode, argblock, delta);
    1143            0 :         stack_area = gen_rtx_MEM (save_mode, memory_address (save_mode, addr));
    1144              : 
    1145            0 :         set_mem_align (stack_area, PARM_BOUNDARY);
    1146            0 :         if (save_mode == BLKmode)
    1147              :           {
    1148            0 :             save_area = assign_stack_temp (BLKmode, num_to_save);
    1149            0 :             emit_block_move (validize_mem (save_area), stack_area,
    1150              :                              GEN_INT (num_to_save), BLOCK_OP_CALL_PARM);
    1151              :           }
    1152              :         else
    1153              :           {
    1154            0 :             save_area = gen_reg_rtx (save_mode);
    1155            0 :             emit_move_insn (save_area, stack_area);
    1156              :           }
    1157              : 
    1158            0 :         return save_area;
    1159              :       }
    1160              : 
    1161              :   return NULL_RTX;
    1162              : }
    1163              : 
    1164              : static void
    1165            0 : restore_fixed_argument_area (rtx save_area, rtx argblock, int high_to_save, int low_to_save)
    1166              : {
    1167            0 :   machine_mode save_mode = GET_MODE (save_area);
    1168            0 :   int delta;
    1169            0 :   rtx addr, stack_area;
    1170              : 
    1171            0 :   if (ARGS_GROW_DOWNWARD)
    1172              :     delta = -high_to_save;
    1173              :   else
    1174            0 :     delta = low_to_save;
    1175              : 
    1176            0 :   addr = plus_constant (Pmode, argblock, delta);
    1177            0 :   stack_area = gen_rtx_MEM (save_mode, memory_address (save_mode, addr));
    1178            0 :   set_mem_align (stack_area, PARM_BOUNDARY);
    1179              : 
    1180            0 :   if (save_mode != BLKmode)
    1181            0 :     emit_move_insn (stack_area, save_area);
    1182              :   else
    1183            0 :     emit_block_move (stack_area, validize_mem (save_area),
    1184            0 :                      GEN_INT (high_to_save - low_to_save + 1),
    1185              :                      BLOCK_OP_CALL_PARM);
    1186            0 : }
    1187              : #endif /* REG_PARM_STACK_SPACE */
    1188              : 
    1189              : /* If any elements in ARGS refer to parameters that are to be passed in
    1190              :    registers, but not in memory, and whose alignment does not permit a
    1191              :    direct copy into registers.  Copy the values into a group of pseudos
    1192              :    which we will later copy into the appropriate hard registers.
    1193              : 
    1194              :    Pseudos for each unaligned argument will be stored into the array
    1195              :    args[argnum].aligned_regs.  The caller is responsible for deallocating
    1196              :    the aligned_regs array if it is nonzero.  */
    1197              : 
    1198              : static void
    1199            0 : store_unaligned_arguments_into_pseudos (struct arg_data *args, int num_actuals)
    1200              : {
    1201            0 :   int i, j;
    1202              : 
    1203            0 :   for (i = 0; i < num_actuals; i++)
    1204            0 :     if (args[i].reg != 0 && ! args[i].pass_on_stack
    1205            0 :         && GET_CODE (args[i].reg) != PARALLEL
    1206            0 :         && args[i].mode == BLKmode
    1207            0 :         && MEM_P (args[i].value)
    1208            0 :         && (MEM_ALIGN (args[i].value)
    1209            0 :             < (unsigned int) MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD)))
    1210              :       {
    1211            0 :         int bytes = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
    1212            0 :         int endian_correction = 0;
    1213              : 
    1214            0 :         if (args[i].partial)
    1215              :           {
    1216            0 :             gcc_assert (args[i].partial % UNITS_PER_WORD == 0);
    1217            0 :             args[i].n_aligned_regs = args[i].partial / UNITS_PER_WORD;
    1218              :           }
    1219              :         else
    1220              :           {
    1221            0 :             args[i].n_aligned_regs
    1222            0 :               = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
    1223              :           }
    1224              : 
    1225            0 :         args[i].aligned_regs = XNEWVEC (rtx, args[i].n_aligned_regs);
    1226              : 
    1227              :         /* Structures smaller than a word are normally aligned to the
    1228              :            least significant byte.  On a BYTES_BIG_ENDIAN machine,
    1229              :            this means we must skip the empty high order bytes when
    1230              :            calculating the bit offset.  */
    1231            0 :         if (bytes < UNITS_PER_WORD
    1232              : #ifdef BLOCK_REG_PADDING
    1233              :             && (BLOCK_REG_PADDING (args[i].mode,
    1234              :                                    TREE_TYPE (args[i].tree_value), 1)
    1235              :                 == PAD_DOWNWARD)
    1236              : #else
    1237              :             && BYTES_BIG_ENDIAN
    1238              : #endif
    1239              :             )
    1240              :           endian_correction = BITS_PER_WORD - bytes * BITS_PER_UNIT;
    1241              : 
    1242            0 :         for (j = 0; j < args[i].n_aligned_regs; j++)
    1243              :           {
    1244            0 :             rtx reg = gen_reg_rtx (word_mode);
    1245            0 :             rtx word = operand_subword_force (args[i].value, j, BLKmode);
    1246            0 :             int bitsize = MIN (bytes * BITS_PER_UNIT, BITS_PER_WORD);
    1247              : 
    1248            0 :             args[i].aligned_regs[j] = reg;
    1249            0 :             word = extract_bit_field (word, bitsize, 0, 1, NULL_RTX,
    1250              :                                       word_mode, word_mode, false, NULL);
    1251              : 
    1252              :             /* There is no need to restrict this code to loading items
    1253              :                in TYPE_ALIGN sized hunks.  The bitfield instructions can
    1254              :                load up entire word sized registers efficiently.
    1255              : 
    1256              :                ??? This may not be needed anymore.
    1257              :                We use to emit a clobber here but that doesn't let later
    1258              :                passes optimize the instructions we emit.  By storing 0 into
    1259              :                the register later passes know the first AND to zero out the
    1260              :                bitfield being set in the register is unnecessary.  The store
    1261              :                of 0 will be deleted as will at least the first AND.  */
    1262              : 
    1263            0 :             emit_move_insn (reg, const0_rtx);
    1264              : 
    1265            0 :             bytes -= bitsize / BITS_PER_UNIT;
    1266            0 :             store_bit_field (reg, bitsize, endian_correction, 0, 0,
    1267              :                              word_mode, word, false, false);
    1268              :           }
    1269              :       }
    1270            0 : }
    1271              : 
    1272              : /* Issue an error if CALL_EXPR was flagged as requiring
    1273              :    tall-call optimization.  */
    1274              : 
    1275              : void
    1276      5717383 : maybe_complain_about_tail_call (tree call_expr, const char *reason)
    1277              : {
    1278      5717383 :   gcc_assert (TREE_CODE (call_expr) == CALL_EXPR);
    1279      5717383 :   if (CALL_EXPR_TAILCALL (call_expr)
    1280        11046 :       && dump_file
    1281      5717383 :       && (dump_flags & TDF_DETAILS))
    1282              :     {
    1283            0 :       fprintf (dump_file, ";; Cannot tail-call: %s: ", reason);
    1284            0 :       print_generic_expr (dump_file, call_expr, TDF_SLIM);
    1285            0 :       fprintf (dump_file, "\n");
    1286              :     }
    1287      5717383 :   if (CALL_EXPR_MUST_TAIL_CALL (call_expr))
    1288              :     {
    1289           20 :       error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
    1290           20 :       CALL_EXPR_MUST_TAIL_CALL (call_expr) = 0;
    1291              :     }
    1292      5717383 : }
    1293              : 
    1294              : /* Fill in ARGS_SIZE and ARGS array based on the parameters found in
    1295              :    CALL_EXPR EXP.
    1296              : 
    1297              :    NUM_ACTUALS is the total number of parameters.
    1298              : 
    1299              :    N_NAMED_ARGS is the total number of named arguments.
    1300              : 
    1301              :    STRUCT_VALUE_ADDR_VALUE is the implicit argument for a struct return
    1302              :    value, or null.
    1303              : 
    1304              :    FNDECL is the tree code for the target of this call (if known)
    1305              : 
    1306              :    ARGS_SO_FAR holds state needed by the target to know where to place
    1307              :    the next argument.
    1308              : 
    1309              :    REG_PARM_STACK_SPACE is the number of bytes of stack space reserved
    1310              :    for arguments which are passed in registers.
    1311              : 
    1312              :    OLD_STACK_LEVEL is a pointer to an rtx which olds the old stack level
    1313              :    and may be modified by this routine.
    1314              : 
    1315              :    OLD_PENDING_ADJ and FLAGS are pointers to integer flags which
    1316              :    may be modified by this routine.
    1317              : 
    1318              :    MUST_PREALLOCATE is a pointer to bool which may be
    1319              :    modified by this routine.
    1320              : 
    1321              :    MAY_TAILCALL is cleared if we encounter an invisible pass-by-reference
    1322              :    that requires allocation of stack space.
    1323              : 
    1324              :    CALL_FROM_THUNK_P is true if this call is the jump from a thunk to
    1325              :    the thunked-to function.  */
    1326              : 
    1327              : static void
    1328      5835539 : initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
    1329              :                                  struct arg_data *args,
    1330              :                                  struct args_size *args_size,
    1331              :                                  int n_named_args ATTRIBUTE_UNUSED,
    1332              :                                  tree exp, tree struct_value_addr_value,
    1333              :                                  tree fndecl, tree fntype,
    1334              :                                  cumulative_args_t args_so_far,
    1335              :                                  int reg_parm_stack_space,
    1336              :                                  rtx *old_stack_level,
    1337              :                                  poly_int64 *old_pending_adj,
    1338              :                                  bool *must_preallocate, int *ecf_flags,
    1339              :                                  bool *may_tailcall, bool call_from_thunk_p)
    1340              : {
    1341      5835539 :   CUMULATIVE_ARGS *args_so_far_pnt = get_cumulative_args (args_so_far);
    1342      5835539 :   location_t loc = EXPR_LOCATION (exp);
    1343              : 
    1344              :   /* Count arg position in order args appear.  */
    1345      5835539 :   int argpos;
    1346              : 
    1347      5835539 :   int i;
    1348              : 
    1349      5835539 :   args_size->constant = 0;
    1350      5835539 :   args_size->var = 0;
    1351              : 
    1352              :   /* In this loop, we consider args in the order they are written.
    1353              :      We fill up ARGS from the back.  */
    1354              : 
    1355      5835539 :   i = num_actuals - 1;
    1356      5835539 :   {
    1357      5835539 :     int j = i;
    1358      5835539 :     call_expr_arg_iterator iter;
    1359      5835539 :     tree arg;
    1360              : 
    1361      5835539 :     if (struct_value_addr_value)
    1362              :       {
    1363       225857 :         args[j].tree_value = struct_value_addr_value;
    1364       225857 :         j--;
    1365              :       }
    1366      5835539 :     argpos = 0;
    1367     17595054 :     FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
    1368              :       {
    1369     11759515 :         tree argtype = TREE_TYPE (arg);
    1370              : 
    1371     11759515 :         if (targetm.calls.split_complex_arg
    1372            0 :             && argtype
    1373            0 :             && TREE_CODE (argtype) == COMPLEX_TYPE
    1374     11759515 :             && targetm.calls.split_complex_arg (argtype))
    1375              :           {
    1376            0 :             tree subtype = TREE_TYPE (argtype);
    1377            0 :             args[j].tree_value = build1 (REALPART_EXPR, subtype, arg);
    1378            0 :             j--;
    1379            0 :             args[j].tree_value = build1 (IMAGPART_EXPR, subtype, arg);
    1380              :           }
    1381              :         else
    1382     11759515 :           args[j].tree_value = arg;
    1383     11759515 :         j--;
    1384     11759515 :         argpos++;
    1385              :       }
    1386              :   }
    1387              : 
    1388      5835539 :   bool promote_p
    1389     11488660 :     = targetm.calls.promote_prototypes (fndecl
    1390      5653121 :                                         ? TREE_TYPE (fndecl)
    1391              :                                         : fntype);
    1392              : 
    1393              :   /* I counts args in order (to be) pushed; ARGPOS counts in order written.  */
    1394     17820911 :   for (argpos = 0; argpos < num_actuals; i--, argpos++)
    1395              :     {
    1396     11985372 :       tree type = TREE_TYPE (args[i].tree_value);
    1397     11985372 :       int unsignedp;
    1398              : 
    1399              :       /* Replace erroneous argument with constant zero.  */
    1400     11985372 :       if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    1401            0 :         args[i].tree_value = integer_zero_node, type = integer_type_node;
    1402              : 
    1403              :       /* If TYPE is a transparent union or record, pass things the way
    1404              :          we would pass the first field of the union or record.  We have
    1405              :          already verified that the modes are the same.  */
    1406     11985372 :       if (RECORD_OR_UNION_TYPE_P (type) && TYPE_TRANSPARENT_AGGR (type))
    1407         3638 :         type = TREE_TYPE (first_field (type));
    1408              : 
    1409              :       /* Decide where to pass this arg.
    1410              : 
    1411              :          args[i].reg is nonzero if all or part is passed in registers.
    1412              : 
    1413              :          args[i].partial is nonzero if part but not all is passed in registers,
    1414              :          and the exact value says how many bytes are passed in registers.
    1415              : 
    1416              :          args[i].pass_on_stack is true if the argument must at least be
    1417              :          computed on the stack.  It may then be loaded back into registers
    1418              :          if args[i].reg is nonzero.
    1419              : 
    1420              :          These decisions are driven by the FUNCTION_... macros and must agree
    1421              :          with those made by function.cc.  */
    1422              : 
    1423              :       /* See if this argument should be passed by invisible reference.  */
    1424     11985372 :       function_arg_info arg (type, argpos < n_named_args);
    1425     11985372 :       if (pass_by_reference (args_so_far_pnt, arg))
    1426              :         {
    1427          382 :           const bool callee_copies
    1428          382 :             = reference_callee_copied (args_so_far_pnt, arg);
    1429          382 :           tree base;
    1430              : 
    1431              :           /* If we're compiling a thunk, pass directly the address of an object
    1432              :              already in memory, instead of making a copy.  Likewise if we want
    1433              :              to make the copy in the callee instead of the caller.  */
    1434          382 :           if ((call_from_thunk_p || callee_copies)
    1435           20 :               && TREE_CODE (args[i].tree_value) != WITH_SIZE_EXPR
    1436           20 :               && ((base = get_base_address (args[i].tree_value)), true)
    1437           20 :               && TREE_CODE (base) != SSA_NAME
    1438          402 :               && (!DECL_P (base) || MEM_P (DECL_RTL (base))))
    1439              :             {
    1440              :               /* We may have turned the parameter value into an SSA name.
    1441              :                  Go back to the original parameter so we can take the
    1442              :                  address.  */
    1443           20 :               if (TREE_CODE (args[i].tree_value) == SSA_NAME)
    1444              :                 {
    1445            0 :                   gcc_assert (SSA_NAME_IS_DEFAULT_DEF (args[i].tree_value));
    1446            0 :                   args[i].tree_value = SSA_NAME_VAR (args[i].tree_value);
    1447            0 :                   gcc_assert (TREE_CODE (args[i].tree_value) == PARM_DECL);
    1448              :                 }
    1449              :               /* Argument setup code may have copied the value to register.  We
    1450              :                  revert that optimization now because the tail call code must
    1451              :                  use the original location.  */
    1452           20 :               if (TREE_CODE (args[i].tree_value) == PARM_DECL
    1453            0 :                   && !MEM_P (DECL_RTL (args[i].tree_value))
    1454            0 :                   && DECL_INCOMING_RTL (args[i].tree_value)
    1455           20 :                   && MEM_P (DECL_INCOMING_RTL (args[i].tree_value)))
    1456            0 :                 set_decl_rtl (args[i].tree_value,
    1457            0 :                               DECL_INCOMING_RTL (args[i].tree_value));
    1458              : 
    1459           20 :               mark_addressable (args[i].tree_value);
    1460              : 
    1461              :               /* We can't use sibcalls if a callee-copied argument is
    1462              :                  stored in the current function's frame.  */
    1463           20 :               if (!call_from_thunk_p && DECL_P (base) && !TREE_STATIC (base))
    1464              :                 {
    1465            0 :                   *may_tailcall = false;
    1466            0 :                   maybe_complain_about_tail_call (exp, _("a callee-copied "
    1467              :                                                          "argument is stored "
    1468              :                                                          "in the current "
    1469              :                                                          "function's frame"));
    1470              :                 }
    1471              : 
    1472           20 :               args[i].tree_value = build_fold_addr_expr_loc (loc,
    1473              :                                                          args[i].tree_value);
    1474           20 :               type = TREE_TYPE (args[i].tree_value);
    1475              : 
    1476           20 :               if (*ecf_flags & ECF_CONST)
    1477            0 :                 *ecf_flags &= ~(ECF_CONST | ECF_LOOPING_CONST_OR_PURE);
    1478              :             }
    1479              :           else
    1480              :             {
    1481              :               /* We make a copy of the object and pass the address to the
    1482              :                  function being called.  */
    1483          362 :               rtx copy;
    1484              : 
    1485          362 :               if (!COMPLETE_TYPE_P (type)
    1486          362 :                   || TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST
    1487          467 :                   || (flag_stack_check == GENERIC_STACK_CHECK
    1488            0 :                       && compare_tree_int (TYPE_SIZE_UNIT (type),
    1489              :                                            STACK_CHECK_MAX_VAR_SIZE) > 0))
    1490              :                 {
    1491              :                   /* This is a variable-sized object.  Make space on the stack
    1492              :                      for it.  */
    1493          257 :                   rtx size_rtx = expr_size (args[i].tree_value);
    1494              : 
    1495          257 :                   if (*old_stack_level == 0)
    1496              :                     {
    1497          158 :                       emit_stack_save (SAVE_BLOCK, old_stack_level);
    1498          158 :                       *old_pending_adj = pending_stack_adjust;
    1499          158 :                       pending_stack_adjust = 0;
    1500              :                     }
    1501              : 
    1502              :                   /* We can pass TRUE as the 4th argument because we just
    1503              :                      saved the stack pointer and will restore it right after
    1504              :                      the call.  */
    1505          514 :                   copy = allocate_dynamic_stack_space (size_rtx,
    1506          257 :                                                        TYPE_ALIGN (type),
    1507          257 :                                                        TYPE_ALIGN (type),
    1508              :                                                        max_int_size_in_bytes
    1509              :                                                        (type),
    1510              :                                                        true);
    1511          257 :                   copy = gen_rtx_MEM (BLKmode, copy);
    1512          257 :                   set_mem_attributes (copy, type, 1);
    1513              :                 }
    1514              :               else
    1515          105 :                 copy = assign_temp (type, 1, 0);
    1516              : 
    1517          362 :               store_expr (args[i].tree_value, copy, 0, false, false);
    1518              : 
    1519              :               /* Just change the const function to pure and then let
    1520              :                  the next test clear the pure based on
    1521              :                  callee_copies.  */
    1522          362 :               if (*ecf_flags & ECF_CONST)
    1523              :                 {
    1524            1 :                   *ecf_flags &= ~ECF_CONST;
    1525            1 :                   *ecf_flags |= ECF_PURE;
    1526              :                 }
    1527              : 
    1528          362 :               if (!callee_copies && *ecf_flags & ECF_PURE)
    1529            3 :                 *ecf_flags &= ~(ECF_PURE | ECF_LOOPING_CONST_OR_PURE);
    1530              : 
    1531          362 :               args[i].tree_value
    1532          362 :                 = build_fold_addr_expr_loc (loc, make_tree (type, copy));
    1533          362 :               type = TREE_TYPE (args[i].tree_value);
    1534          362 :               *may_tailcall = false;
    1535          362 :               maybe_complain_about_tail_call (exp,
    1536          362 :                                               _("argument must be passed"
    1537              :                                                 " by copying"));
    1538              :             }
    1539          382 :           arg.pass_by_reference = true;
    1540              :         }
    1541              : 
    1542     11985372 :       unsignedp = TYPE_UNSIGNED (type);
    1543     11985372 :       if (promote_p
    1544     11985372 :           && INTEGRAL_TYPE_P (type)
    1545     15926075 :           && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
    1546              :         type = integer_type_node;
    1547              : 
    1548     11985372 :       arg.type = type;
    1549     11985372 :       arg.mode
    1550     23600186 :         = promote_function_mode (type, TYPE_MODE (type), &unsignedp,
    1551     11614814 :                                  fndecl ? TREE_TYPE (fndecl) : fntype, 0);
    1552              : 
    1553     11985372 :       args[i].unsignedp = unsignedp;
    1554     11985372 :       args[i].mode = arg.mode;
    1555              : 
    1556     11985372 :       targetm.calls.warn_parameter_passing_abi (args_so_far, type);
    1557              : 
    1558     11985372 :       args[i].reg = targetm.calls.function_arg (args_so_far, arg);
    1559              : 
    1560              :       /* If this is a sibling call and the machine has register windows, the
    1561              :          register window has to be unwinded before calling the routine, so
    1562              :          arguments have to go into the incoming registers.  */
    1563     11985372 :       if (targetm.calls.function_incoming_arg != targetm.calls.function_arg)
    1564            0 :         args[i].tail_call_reg
    1565            0 :           = targetm.calls.function_incoming_arg (args_so_far, arg);
    1566              :       else
    1567     11985372 :         args[i].tail_call_reg = args[i].reg;
    1568              : 
    1569     11985372 :       if (args[i].reg)
    1570      9834620 :         args[i].partial = targetm.calls.arg_partial_bytes (args_so_far, arg);
    1571              : 
    1572     11985372 :       args[i].pass_on_stack = targetm.calls.must_pass_in_stack (arg);
    1573              : 
    1574              :       /* If FUNCTION_ARG returned a (parallel [(expr_list (nil) ...) ...]),
    1575              :          it means that we are to pass this arg in the register(s) designated
    1576              :          by the PARALLEL, but also to pass it in the stack.  */
    1577     11985372 :       if (args[i].reg && GET_CODE (args[i].reg) == PARALLEL
    1578       284748 :           && XEXP (XVECEXP (args[i].reg, 0, 0), 0) == 0)
    1579            0 :         args[i].pass_on_stack = true;
    1580              : 
    1581              :       /* If this is an addressable type, we must preallocate the stack
    1582              :          since we must evaluate the object into its final location.
    1583              : 
    1584              :          If this is to be passed in both registers and the stack, it is simpler
    1585              :          to preallocate.  */
    1586     11985372 :       if (TREE_ADDRESSABLE (type)
    1587     11985372 :           || (args[i].pass_on_stack && args[i].reg != 0))
    1588            0 :         *must_preallocate = true;
    1589              : 
    1590              :       /* Compute the stack-size of this argument.  */
    1591     11985372 :       if (args[i].reg == 0 || args[i].partial != 0
    1592      9834620 :                || reg_parm_stack_space > 0
    1593      9768519 :                || args[i].pass_on_stack)
    1594      2216853 :         locate_and_pad_parm (arg.mode, type,
    1595              : #ifdef STACK_PARMS_IN_REG_PARM_AREA
    1596              :                              1,
    1597              : #else
    1598              :                              args[i].reg != 0,
    1599              : #endif
    1600              :                              reg_parm_stack_space,
    1601      2216853 :                              args[i].pass_on_stack ? 0 : args[i].partial,
    1602              :                              fndecl, args_size, &args[i].locate);
    1603              : #ifdef BLOCK_REG_PADDING
    1604              :       else
    1605              :         /* The argument is passed entirely in registers.  See at which
    1606              :            end it should be padded.  */
    1607              :         args[i].locate.where_pad =
    1608              :           BLOCK_REG_PADDING (arg.mode, type,
    1609              :                              int_size_in_bytes (type) <= UNITS_PER_WORD);
    1610              : #endif
    1611              : 
    1612              :       /* Update ARGS_SIZE, the total stack space for args so far.  */
    1613              : 
    1614     11985372 :       args_size->constant += args[i].locate.size.constant;
    1615     11985372 :       if (args[i].locate.size.var)
    1616            0 :         ADD_PARM_SIZE (*args_size, args[i].locate.size.var);
    1617              : 
    1618              :       /* Increment ARGS_SO_FAR, which has info about which arg-registers
    1619              :          have been used, etc.  */
    1620              : 
    1621              :       /* ??? Traditionally we've passed TYPE_MODE here, instead of the
    1622              :          promoted_mode used for function_arg above.  However, the
    1623              :          corresponding handling of incoming arguments in function.cc
    1624              :          does pass the promoted mode.  */
    1625     11985372 :       arg.mode = TYPE_MODE (type);
    1626     11985372 :       targetm.calls.function_arg_advance (args_so_far, arg);
    1627              :     }
    1628      5835539 : }
    1629              : 
    1630              : /* Update ARGS_SIZE to contain the total size for the argument block.
    1631              :    Return the original constant component of the argument block's size.
    1632              : 
    1633              :    REG_PARM_STACK_SPACE holds the number of bytes of stack space reserved
    1634              :    for arguments passed in registers.  */
    1635              : 
    1636              : static poly_int64
    1637      5835543 : compute_argument_block_size (int reg_parm_stack_space,
    1638              :                              struct args_size *args_size,
    1639              :                              tree fndecl ATTRIBUTE_UNUSED,
    1640              :                              tree fntype ATTRIBUTE_UNUSED,
    1641              :                              int preferred_stack_boundary ATTRIBUTE_UNUSED)
    1642              : {
    1643      5835543 :   poly_int64 unadjusted_args_size = args_size->constant;
    1644              : 
    1645              :   /* For accumulate outgoing args mode we don't need to align, since the frame
    1646              :      will be already aligned.  Align to STACK_BOUNDARY in order to prevent
    1647              :      backends from generating misaligned frame sizes.  */
    1648      5835543 :   if (ACCUMULATE_OUTGOING_ARGS && preferred_stack_boundary > STACK_BOUNDARY)
    1649         1069 :     preferred_stack_boundary = STACK_BOUNDARY;
    1650              : 
    1651              :   /* Compute the actual size of the argument block required.  The variable
    1652              :      and constant sizes must be combined, the size may have to be rounded,
    1653              :      and there may be a minimum required size.  */
    1654              : 
    1655      5835543 :   if (args_size->var)
    1656              :     {
    1657            0 :       args_size->var = ARGS_SIZE_TREE (*args_size);
    1658            0 :       args_size->constant = 0;
    1659              : 
    1660            0 :       preferred_stack_boundary /= BITS_PER_UNIT;
    1661            0 :       if (preferred_stack_boundary > 1)
    1662              :         {
    1663              :           /* We don't handle this case yet.  To handle it correctly we have
    1664              :              to add the delta, round and subtract the delta.
    1665              :              Currently no machine description requires this support.  */
    1666            0 :           gcc_assert (multiple_p (stack_pointer_delta,
    1667              :                                   preferred_stack_boundary));
    1668            0 :           args_size->var = round_up (args_size->var, preferred_stack_boundary);
    1669              :         }
    1670              : 
    1671            0 :       if (reg_parm_stack_space > 0)
    1672              :         {
    1673            0 :           args_size->var
    1674            0 :             = size_binop (MAX_EXPR, args_size->var,
    1675              :                           ssize_int (reg_parm_stack_space));
    1676              : 
    1677              :           /* The area corresponding to register parameters is not to count in
    1678              :              the size of the block we need.  So make the adjustment.  */
    1679            0 :           if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl))))
    1680            0 :             args_size->var
    1681            0 :               = size_binop (MINUS_EXPR, args_size->var,
    1682              :                             ssize_int (reg_parm_stack_space));
    1683              :         }
    1684              :     }
    1685              :   else
    1686              :     {
    1687      5835543 :       preferred_stack_boundary /= BITS_PER_UNIT;
    1688      5835543 :       if (preferred_stack_boundary < 1)
    1689       125706 :         preferred_stack_boundary = 1;
    1690      5835543 :       args_size->constant = (aligned_upper_bound (args_size->constant
    1691      5835543 :                                                   + stack_pointer_delta,
    1692              :                                                   preferred_stack_boundary)
    1693      5835543 :                              - stack_pointer_delta);
    1694              : 
    1695      5835543 :       args_size->constant = upper_bound (args_size->constant,
    1696              :                                          reg_parm_stack_space);
    1697              : 
    1698      5835543 :       if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl))))
    1699      5799248 :         args_size->constant -= reg_parm_stack_space;
    1700              :     }
    1701      5835543 :   return unadjusted_args_size;
    1702              : }
    1703              : 
    1704              : /* Precompute parameters as needed for a function call.
    1705              : 
    1706              :    FLAGS is mask of ECF_* constants.
    1707              : 
    1708              :    NUM_ACTUALS is the number of arguments.
    1709              : 
    1710              :    ARGS is an array containing information for each argument; this
    1711              :    routine fills in the INITIAL_VALUE and VALUE fields for each
    1712              :    precomputed argument.  */
    1713              : 
    1714              : static void
    1715      5709837 : precompute_arguments (int num_actuals, struct arg_data *args)
    1716              : {
    1717      5709837 :   int i;
    1718              : 
    1719              :   /* If this is a libcall, then precompute all arguments so that we do not
    1720              :      get extraneous instructions emitted as part of the libcall sequence.  */
    1721              : 
    1722              :   /* If we preallocated the stack space, and some arguments must be passed
    1723              :      on the stack, then we must precompute any parameter which contains a
    1724              :      function call which will store arguments on the stack.
    1725              :      Otherwise, evaluating the parameter may clobber previous parameters
    1726              :      which have already been stored into the stack.  (we have code to avoid
    1727              :      such case by saving the outgoing stack arguments, but it results in
    1728              :      worse code)  */
    1729      5709837 :   if (!ACCUMULATE_OUTGOING_ARGS)
    1730      5636471 :     return;
    1731              : 
    1732       366526 :   for (i = 0; i < num_actuals; i++)
    1733              :     {
    1734       293160 :       tree type;
    1735       293160 :       machine_mode mode;
    1736              : 
    1737       293160 :       if (TREE_CODE (args[i].tree_value) != CALL_EXPR)
    1738       293160 :         continue;
    1739              : 
    1740              :       /* If this is an addressable type, we cannot pre-evaluate it.  */
    1741            0 :       type = TREE_TYPE (args[i].tree_value);
    1742            0 :       gcc_assert (!TREE_ADDRESSABLE (type));
    1743              : 
    1744            0 :       args[i].initial_value = args[i].value
    1745            0 :         = expand_normal (args[i].tree_value);
    1746              : 
    1747            0 :       mode = TYPE_MODE (type);
    1748            0 :       if (mode != args[i].mode)
    1749              :         {
    1750            0 :           int unsignedp = args[i].unsignedp;
    1751            0 :           args[i].value
    1752            0 :             = convert_modes (args[i].mode, mode,
    1753              :                              args[i].value, args[i].unsignedp);
    1754              : 
    1755              :           /* CSE will replace this only if it contains args[i].value
    1756              :              pseudo, so convert it down to the declared mode using
    1757              :              a SUBREG.  */
    1758            0 :           if (REG_P (args[i].value)
    1759            0 :               && GET_MODE_CLASS (args[i].mode) == MODE_INT
    1760            0 :               && promote_mode (type, mode, &unsignedp) != args[i].mode)
    1761              :             {
    1762            0 :               args[i].initial_value
    1763            0 :                 = gen_lowpart_SUBREG (mode, args[i].value);
    1764            0 :               SUBREG_PROMOTED_VAR_P (args[i].initial_value) = 1;
    1765            0 :               SUBREG_PROMOTED_SET (args[i].initial_value, args[i].unsignedp);
    1766              :             }
    1767              :         }
    1768              :     }
    1769              : }
    1770              : 
    1771              : /* Given the current state of MUST_PREALLOCATE and information about
    1772              :    arguments to a function call in NUM_ACTUALS, ARGS and ARGS_SIZE,
    1773              :    compute and return the final value for MUST_PREALLOCATE.  */
    1774              : 
    1775              : static bool
    1776      5835539 : finalize_must_preallocate (bool must_preallocate, int num_actuals,
    1777              :                            struct arg_data *args, struct args_size *args_size)
    1778              : {
    1779              :   /* See if we have or want to preallocate stack space.
    1780              : 
    1781              :      If we would have to push a partially-in-regs parm
    1782              :      before other stack parms, preallocate stack space instead.
    1783              : 
    1784              :      If the size of some parm is not a multiple of the required stack
    1785              :      alignment, we must preallocate.
    1786              : 
    1787              :      If the total size of arguments that would otherwise create a copy in
    1788              :      a temporary (such as a CALL) is more than half the total argument list
    1789              :      size, preallocation is faster.
    1790              : 
    1791              :      Another reason to preallocate is if we have a machine (like the m88k)
    1792              :      where stack alignment is required to be maintained between every
    1793              :      pair of insns, not just when the call is made.  However, we assume here
    1794              :      that such machines either do not have push insns (and hence preallocation
    1795              :      would occur anyway) or the problem is taken care of with
    1796              :      PUSH_ROUNDING.  */
    1797              : 
    1798      5835539 :   if (! must_preallocate)
    1799              :     {
    1800              :       bool partial_seen = false;
    1801              :       poly_int64 copy_to_evaluate_size = 0;
    1802              :       int i;
    1803              : 
    1804     17451979 :       for (i = 0; i < num_actuals && ! must_preallocate; i++)
    1805              :         {
    1806     11690999 :           if (args[i].partial > 0 && ! args[i].pass_on_stack)
    1807              :             partial_seen = true;
    1808     11690999 :           else if (partial_seen && args[i].reg == 0)
    1809            0 :             must_preallocate = true;
    1810              : 
    1811     11690999 :           if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
    1812     11690999 :               && (TREE_CODE (args[i].tree_value) == CALL_EXPR
    1813       279105 :                   || TREE_CODE (args[i].tree_value) == TARGET_EXPR
    1814       279105 :                   || TREE_CODE (args[i].tree_value) == COND_EXPR
    1815       279105 :                   || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
    1816            0 :             copy_to_evaluate_size
    1817            0 :               += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
    1818              :         }
    1819              : 
    1820      5760980 :       if (maybe_ne (args_size->constant, 0)
    1821      5760980 :           && maybe_ge (copy_to_evaluate_size * 2, args_size->constant))
    1822              :         must_preallocate = true;
    1823              :     }
    1824      5835539 :   return must_preallocate;
    1825              : }
    1826              : 
    1827              : /* If we preallocated stack space, compute the address of each argument
    1828              :    and store it into the ARGS array.
    1829              : 
    1830              :    We need not ensure it is a valid memory address here; it will be
    1831              :    validized when it is used.
    1832              : 
    1833              :    ARGBLOCK is an rtx for the address of the outgoing arguments.  */
    1834              : 
    1835              : static void
    1836      5835543 : compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals)
    1837              : {
    1838      5835543 :   if (argblock)
    1839              :     {
    1840       199078 :       rtx arg_reg = argblock;
    1841       199078 :       int i;
    1842       199078 :       poly_int64 arg_offset = 0;
    1843              : 
    1844       199078 :       if (GET_CODE (argblock) == PLUS)
    1845              :         {
    1846            0 :           arg_reg = XEXP (argblock, 0);
    1847            0 :           arg_offset = rtx_to_poly_int64 (XEXP (argblock, 1));
    1848              :         }
    1849              : 
    1850       715670 :       for (i = 0; i < num_actuals; i++)
    1851              :         {
    1852       528938 :           rtx offset = ARGS_SIZE_RTX (args[i].locate.offset);
    1853       528938 :           rtx slot_offset = ARGS_SIZE_RTX (args[i].locate.slot_offset);
    1854       516592 :           rtx addr;
    1855       516592 :           unsigned int align, boundary;
    1856       516592 :           poly_uint64 units_on_stack = 0;
    1857       516592 :           machine_mode partial_mode = VOIDmode;
    1858              : 
    1859              :           /* Skip this parm if it will not be passed on the stack.  */
    1860       516592 :           if (! args[i].pass_on_stack
    1861       516592 :               && args[i].reg != 0
    1862       452225 :               && args[i].partial == 0)
    1863       516592 :             continue;
    1864              : 
    1865        64367 :           if (TYPE_EMPTY_P (TREE_TYPE (args[i].tree_value)))
    1866          311 :             continue;
    1867              : 
    1868        72400 :           addr = simplify_gen_binary (PLUS, Pmode, arg_reg, offset);
    1869        72400 :           addr = plus_constant (Pmode, addr, arg_offset);
    1870              : 
    1871        64056 :           if (args[i].partial != 0)
    1872              :             {
    1873              :               /* Only part of the parameter is being passed on the stack.
    1874              :                  Generate a simple memory reference of the correct size.  */
    1875            0 :               units_on_stack = args[i].locate.size.constant;
    1876            0 :               poly_uint64 bits_on_stack = units_on_stack * BITS_PER_UNIT;
    1877            0 :               partial_mode = int_mode_for_size (bits_on_stack, 1).else_blk ();
    1878            0 :               args[i].stack = gen_rtx_MEM (partial_mode, addr);
    1879            0 :               set_mem_size (args[i].stack, units_on_stack);
    1880              :             }
    1881              :           else
    1882              :             {
    1883        64056 :               args[i].stack = gen_rtx_MEM (args[i].mode, addr);
    1884        64056 :               set_mem_attributes (args[i].stack,
    1885        64056 :                                   TREE_TYPE (args[i].tree_value), 1);
    1886              :             }
    1887        64056 :           align = BITS_PER_UNIT;
    1888        64056 :           boundary = args[i].locate.boundary;
    1889        64056 :           poly_int64 offset_val;
    1890        64056 :           if (args[i].locate.where_pad != PAD_DOWNWARD)
    1891              :             align = boundary;
    1892            0 :           else if (poly_int_rtx_p (offset, &offset_val))
    1893              :             {
    1894            0 :               align = least_bit_hwi (boundary);
    1895            0 :               unsigned int offset_align
    1896            0 :                 = known_alignment (offset_val) * BITS_PER_UNIT;
    1897            0 :               if (offset_align != 0)
    1898            0 :                 align = MIN (align, offset_align);
    1899              :             }
    1900        64056 :           set_mem_align (args[i].stack, align);
    1901              : 
    1902        72400 :           addr = simplify_gen_binary (PLUS, Pmode, arg_reg, slot_offset);
    1903        72400 :           addr = plus_constant (Pmode, addr, arg_offset);
    1904              : 
    1905        64056 :           if (args[i].partial != 0)
    1906              :             {
    1907              :               /* Only part of the parameter is being passed on the stack.
    1908              :                  Generate a simple memory reference of the correct size.
    1909              :                */
    1910            0 :               args[i].stack_slot = gen_rtx_MEM (partial_mode, addr);
    1911            0 :               set_mem_size (args[i].stack_slot, units_on_stack);
    1912              :             }
    1913              :           else
    1914              :             {
    1915        64056 :               args[i].stack_slot = gen_rtx_MEM (args[i].mode, addr);
    1916        64056 :               set_mem_attributes (args[i].stack_slot,
    1917        64056 :                                   TREE_TYPE (args[i].tree_value), 1);
    1918              :             }
    1919        64056 :           set_mem_align (args[i].stack_slot, args[i].locate.boundary);
    1920              : 
    1921              :           /* Function incoming arguments may overlap with sibling call
    1922              :              outgoing arguments and we cannot allow reordering of reads
    1923              :              from function arguments with stores to outgoing arguments
    1924              :              of sibling calls.  */
    1925        64056 :           set_mem_alias_set (args[i].stack, 0);
    1926        64056 :           set_mem_alias_set (args[i].stack_slot, 0);
    1927              :         }
    1928              :     }
    1929      5835543 : }
    1930              : 
    1931              : /* Given a FNDECL and EXP, return an rtx suitable for use as a target address
    1932              :    in a call instruction.
    1933              : 
    1934              :    FNDECL is the tree node for the target function.  For an indirect call
    1935              :    FNDECL will be NULL_TREE.
    1936              : 
    1937              :    ADDR is the operand 0 of CALL_EXPR for this call.  */
    1938              : 
    1939              : static rtx
    1940      5835541 : rtx_for_function_call (tree fndecl, tree addr)
    1941              : {
    1942      5835541 :   rtx funexp;
    1943              : 
    1944              :   /* Get the function to call, in the form of RTL.  */
    1945      5835541 :   if (fndecl)
    1946              :     {
    1947      5653123 :       if (!TREE_USED (fndecl) && fndecl != current_function_decl)
    1948       546884 :         TREE_USED (fndecl) = 1;
    1949              : 
    1950              :       /* Get a SYMBOL_REF rtx for the function address.  */
    1951      5653123 :       funexp = XEXP (DECL_RTL (fndecl), 0);
    1952              :     }
    1953              :   else
    1954              :     /* Generate an rtx (probably a pseudo-register) for the address.  */
    1955              :     {
    1956       182418 :       push_temp_slots ();
    1957       182418 :       funexp = expand_normal (addr);
    1958       182418 :       pop_temp_slots ();        /* FUNEXP can't be BLKmode.  */
    1959              :     }
    1960      5835541 :   return funexp;
    1961              : }
    1962              : 
    1963              : /* Return the static chain for this function, if any.  */
    1964              : 
    1965              : rtx
    1966     15895219 : rtx_for_static_chain (const_tree fndecl_or_type, bool incoming_p)
    1967              : {
    1968     31790438 :   if (DECL_P (fndecl_or_type) && !DECL_STATIC_CHAIN (fndecl_or_type))
    1969              :     return NULL;
    1970              : 
    1971       213099 :   return targetm.calls.static_chain (fndecl_or_type, incoming_p);
    1972              : }
    1973              : 
    1974              : /* Internal state for internal_arg_pointer_based_exp and its helpers.  */
    1975              : static struct
    1976              : {
    1977              :   /* Last insn that has been scanned by internal_arg_pointer_based_exp_scan,
    1978              :      or NULL_RTX if none has been scanned yet.  */
    1979              :   rtx_insn *scan_start;
    1980              :   /* Vector indexed by REGNO - FIRST_PSEUDO_REGISTER, recording if a pseudo is
    1981              :      based on crtl->args.internal_arg_pointer.  The element is NULL_RTX if the
    1982              :      pseudo isn't based on it, a CONST_INT offset if the pseudo is based on it
    1983              :      with fixed offset, or PC if this is with variable or unknown offset.  */
    1984              :   vec<rtx> cache;
    1985              : } internal_arg_pointer_exp_state;
    1986              : 
    1987              : static rtx internal_arg_pointer_based_exp (const_rtx, bool);
    1988              : 
    1989              : /* Helper function for internal_arg_pointer_based_exp.  Scan insns in
    1990              :    the tail call sequence, starting with first insn that hasn't been
    1991              :    scanned yet, and note for each pseudo on the LHS whether it is based
    1992              :    on crtl->args.internal_arg_pointer or not, and what offset from that
    1993              :    that pointer it has.  */
    1994              : 
    1995              : static void
    1996         1502 : internal_arg_pointer_based_exp_scan (void)
    1997              : {
    1998         1502 :   rtx_insn *insn, *scan_start = internal_arg_pointer_exp_state.scan_start;
    1999              : 
    2000         1502 :   if (scan_start == NULL_RTX)
    2001         1289 :     insn = get_insns ();
    2002              :   else
    2003          213 :     insn = NEXT_INSN (scan_start);
    2004              : 
    2005         8954 :   while (insn)
    2006              :     {
    2007         7452 :       rtx set = single_set (insn);
    2008         7452 :       if (set && REG_P (SET_DEST (set)) && !HARD_REGISTER_P (SET_DEST (set)))
    2009              :         {
    2010         2039 :           rtx val = NULL_RTX;
    2011         2039 :           unsigned int idx = REGNO (SET_DEST (set)) - FIRST_PSEUDO_REGISTER;
    2012              :           /* Punt on pseudos set multiple times.  */
    2013         2039 :           if (idx < internal_arg_pointer_exp_state.cache.length ()
    2014            0 :               && (internal_arg_pointer_exp_state.cache[idx]
    2015            0 :                   != NULL_RTX))
    2016            0 :             val = pc_rtx;
    2017              :           else
    2018         2039 :             val = internal_arg_pointer_based_exp (SET_SRC (set), false);
    2019         2039 :           if (val != NULL_RTX)
    2020              :             {
    2021            0 :               if (idx >= internal_arg_pointer_exp_state.cache.length ())
    2022            0 :                 internal_arg_pointer_exp_state.cache
    2023            0 :                   .safe_grow_cleared (idx + 1, true);
    2024            0 :               internal_arg_pointer_exp_state.cache[idx] = val;
    2025              :             }
    2026              :         }
    2027         7452 :       if (NEXT_INSN (insn) == NULL_RTX)
    2028         1454 :         scan_start = insn;
    2029              :       insn = NEXT_INSN (insn);
    2030              :     }
    2031              : 
    2032         1502 :   internal_arg_pointer_exp_state.scan_start = scan_start;
    2033         1502 : }
    2034              : 
    2035              : /* Compute whether RTL is based on crtl->args.internal_arg_pointer.  Return
    2036              :    NULL_RTX if RTL isn't based on it, a CONST_INT offset if RTL is based on
    2037              :    it with fixed offset, or PC if this is with variable or unknown offset.
    2038              :    TOPLEVEL is true if the function is invoked at the topmost level.  */
    2039              : 
    2040              : static rtx
    2041        13421 : internal_arg_pointer_based_exp (const_rtx rtl, bool toplevel)
    2042              : {
    2043        13421 :   if (CONSTANT_P (rtl))
    2044              :     return NULL_RTX;
    2045              : 
    2046        13331 :   if (rtl == crtl->args.internal_arg_pointer)
    2047         5433 :     return const0_rtx;
    2048              : 
    2049         7898 :   if (REG_P (rtl) && HARD_REGISTER_P (rtl))
    2050              :     return NULL_RTX;
    2051              : 
    2052         7880 :   poly_int64 offset;
    2053         7880 :   if (GET_CODE (rtl) == PLUS && poly_int_rtx_p (XEXP (rtl, 1), &offset))
    2054              :     {
    2055         3298 :       rtx val = internal_arg_pointer_based_exp (XEXP (rtl, 0), toplevel);
    2056         3298 :       if (val == NULL_RTX || val == pc_rtx)
    2057              :         return val;
    2058         5377 :       return plus_constant (Pmode, val, offset);
    2059              :     }
    2060              : 
    2061              :   /* When called at the topmost level, scan pseudo assignments in between the
    2062              :      last scanned instruction in the tail call sequence and the latest insn
    2063              :      in that sequence.  */
    2064         4582 :   if (toplevel)
    2065         1502 :     internal_arg_pointer_based_exp_scan ();
    2066              : 
    2067         4582 :   if (REG_P (rtl))
    2068              :     {
    2069         1796 :       unsigned int idx = REGNO (rtl) - FIRST_PSEUDO_REGISTER;
    2070         1904 :       if (idx < internal_arg_pointer_exp_state.cache.length ())
    2071            0 :         return internal_arg_pointer_exp_state.cache[idx];
    2072              : 
    2073              :       return NULL_RTX;
    2074              :     }
    2075              : 
    2076         2786 :   subrtx_iterator::array_type array;
    2077         7524 :   FOR_EACH_SUBRTX (iter, array, rtl, NONCONST)
    2078              :     {
    2079         4738 :       const_rtx x = *iter;
    2080         4738 :       if (REG_P (x) && internal_arg_pointer_based_exp (x, false) != NULL_RTX)
    2081            0 :         return pc_rtx;
    2082         4738 :       if (MEM_P (x))
    2083         1723 :         iter.skip_subrtxes ();
    2084              :     }
    2085              : 
    2086         2786 :   return NULL_RTX;
    2087         2786 : }
    2088              : 
    2089              : /* Return true if SIZE bytes starting from address ADDR might overlap an
    2090              :    already-clobbered argument area.  This function is used to determine
    2091              :    if we should give up a sibcall.  */
    2092              : 
    2093              : static bool
    2094        18451 : mem_might_overlap_already_clobbered_arg_p (rtx addr, poly_uint64 size)
    2095              : {
    2096        18451 :   poly_int64 i;
    2097        18451 :   unsigned HOST_WIDE_INT start, end;
    2098        18451 :   rtx val;
    2099              : 
    2100        18451 :   if (bitmap_empty_p (stored_args_map)
    2101        18451 :       && stored_args_watermark == HOST_WIDE_INT_M1U)
    2102              :     return false;
    2103         6977 :   val = internal_arg_pointer_based_exp (addr, true);
    2104         6977 :   if (val == NULL_RTX)
    2105              :     return false;
    2106         5437 :   else if (!poly_int_rtx_p (val, &i))
    2107              :     return true;
    2108              : 
    2109         5433 :   if (known_eq (size, 0U))
    2110              :     return false;
    2111              : 
    2112         5433 :   if (STACK_GROWS_DOWNWARD)
    2113         5433 :     i -= crtl->args.pretend_args_size;
    2114              :   else
    2115              :     i += crtl->args.pretend_args_size;
    2116              : 
    2117         5433 :   if (ARGS_GROW_DOWNWARD)
    2118              :     i = -i - size;
    2119              : 
    2120              :   /* We can ignore any references to the function's pretend args,
    2121              :      which at this point would manifest as negative values of I.  */
    2122         5433 :   if (known_le (i, 0) && known_le (size, poly_uint64 (-i)))
    2123              :     return false;
    2124              : 
    2125         5433 :   start = maybe_lt (i, 0) ? 0 : constant_lower_bound (i);
    2126         5433 :   if (!(i + size).is_constant (&end))
    2127              :     end = HOST_WIDE_INT_M1U;
    2128              : 
    2129         5433 :   if (end > stored_args_watermark)
    2130              :     return true;
    2131              : 
    2132         5433 :   end = MIN (end, SBITMAP_SIZE (stored_args_map));
    2133        31481 :   for (unsigned HOST_WIDE_INT k = start; k < end; ++k)
    2134        26052 :     if (bitmap_bit_p (stored_args_map, k))
    2135              :       return true;
    2136              : 
    2137              :   return false;
    2138              : }
    2139              : 
    2140              : /* Do the register loads required for any wholly-register parms or any
    2141              :    parms which are passed both on the stack and in a register.  Their
    2142              :    expressions were already evaluated.
    2143              : 
    2144              :    Mark all register-parms as living through the call, putting these USE
    2145              :    insns in the CALL_INSN_FUNCTION_USAGE field.
    2146              : 
    2147              :    When IS_SIBCALL, perform the check_sibcall_argument_overlap
    2148              :    checking, setting *SIBCALL_FAILURE if appropriate.  */
    2149              : 
    2150              : static void
    2151      5835541 : load_register_parameters (struct arg_data *args, int num_actuals,
    2152              :                           rtx *call_fusage, int flags, int is_sibcall,
    2153              :                           bool *sibcall_failure)
    2154              : {
    2155      5835541 :   int i, j;
    2156              : 
    2157     17820951 :   for (i = 0; i < num_actuals; i++)
    2158              :     {
    2159     23970820 :       rtx reg = ((flags & ECF_SIBCALL)
    2160     11985410 :                  ? args[i].tail_call_reg : args[i].reg);
    2161     11985410 :       if (reg)
    2162              :         {
    2163      9834630 :           int partial = args[i].partial;
    2164      9834630 :           int nregs;
    2165      9834630 :           poly_int64 size = 0;
    2166      9834630 :           HOST_WIDE_INT const_size = 0;
    2167      9834630 :           rtx_insn *before_arg = get_last_insn ();
    2168      9834630 :           tree tree_value = args[i].tree_value;
    2169      9834630 :           tree type = TREE_TYPE (tree_value);
    2170      9834630 :           if (RECORD_OR_UNION_TYPE_P (type) && TYPE_TRANSPARENT_AGGR (type))
    2171         3081 :             type = TREE_TYPE (first_field (type));
    2172              :           /* Set non-negative if we must move a word at a time, even if
    2173              :              just one word (e.g, partial == 4 && mode == DFmode).  Set
    2174              :              to -1 if we just use a normal move insn.  This value can be
    2175              :              zero if the argument is a zero size structure.  */
    2176      9834630 :           nregs = -1;
    2177      9834630 :           if (GET_CODE (reg) == PARALLEL)
    2178              :             ;
    2179      9549882 :           else if (partial)
    2180              :             {
    2181            0 :               gcc_assert (partial % UNITS_PER_WORD == 0);
    2182            0 :               nregs = partial / UNITS_PER_WORD;
    2183              :             }
    2184      9549882 :           else if (TYPE_MODE (type) == BLKmode)
    2185              :             {
    2186              :               /* Variable-sized parameters should be described by a
    2187              :                  PARALLEL instead.  */
    2188         1622 :               const_size = int_size_in_bytes (type);
    2189         1622 :               gcc_assert (const_size >= 0);
    2190         1640 :               nregs = (const_size + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD;
    2191         1622 :               size = const_size;
    2192              :             }
    2193              :           else
    2194     19096520 :             size = GET_MODE_SIZE (args[i].mode);
    2195              : 
    2196              :           /* Handle calls that pass values in multiple non-contiguous
    2197              :              locations.  The Irix 6 ABI has examples of this.  */
    2198              : 
    2199      9834630 :           if (GET_CODE (reg) == PARALLEL)
    2200       284748 :             emit_group_move (reg, args[i].parallel_value);
    2201              : 
    2202              :           /* If simple case, just do move.  If normal partial, store_one_arg
    2203              :              has already loaded the register for us.  In all other cases,
    2204              :              load the register(s) from memory.  */
    2205              : 
    2206      9549882 :           else if (nregs == -1)
    2207              :             {
    2208      9548260 :               emit_move_insn (reg, args[i].value);
    2209              : #ifdef BLOCK_REG_PADDING
    2210              :               /* Handle case where we have a value that needs shifting
    2211              :                  up to the msb.  eg. a QImode value and we're padding
    2212              :                  upward on a BYTES_BIG_ENDIAN machine.  */
    2213              :               if (args[i].locate.where_pad
    2214              :                   == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD))
    2215              :                 {
    2216              :                   gcc_checking_assert (ordered_p (size, UNITS_PER_WORD));
    2217              :                   if (maybe_lt (size, UNITS_PER_WORD))
    2218              :                     {
    2219              :                       rtx x;
    2220              :                       poly_int64 shift
    2221              :                         = (UNITS_PER_WORD - size) * BITS_PER_UNIT;
    2222              : 
    2223              :                       /* Assigning REG here rather than a temp makes
    2224              :                          CALL_FUSAGE report the whole reg as used.
    2225              :                          Strictly speaking, the call only uses SIZE
    2226              :                          bytes at the msb end, but it doesn't seem worth
    2227              :                          generating rtl to say that.  */
    2228              :                       reg = gen_rtx_REG (word_mode, REGNO (reg));
    2229              :                       x = expand_shift (LSHIFT_EXPR, word_mode,
    2230              :                                         reg, shift, reg, 1);
    2231              :                       if (x != reg)
    2232              :                         emit_move_insn (reg, x);
    2233              :                     }
    2234              :                 }
    2235              : #endif
    2236              :             }
    2237              : 
    2238              :           /* If we have pre-computed the values to put in the registers in
    2239              :              the case of non-aligned structures, copy them in now.  */
    2240              : 
    2241         1622 :           else if (args[i].n_aligned_regs != 0)
    2242            0 :             for (j = 0; j < args[i].n_aligned_regs; j++)
    2243            0 :               emit_move_insn (gen_rtx_REG (word_mode, REGNO (reg) + j),
    2244            0 :                               args[i].aligned_regs[j]);
    2245              : 
    2246              :           /* If we need a single register and the source is a constant
    2247              :              VAR_DECL with a simple constructor, expand that constructor
    2248              :              via a pseudo rather than read from (possibly misaligned)
    2249              :              memory.  PR middle-end/95126.  */
    2250         1622 :           else if (nregs == 1
    2251         1622 :                    && partial == 0
    2252         1604 :                    && !args[i].pass_on_stack
    2253         1604 :                    && VAR_P (tree_value)
    2254         1127 :                    && TREE_READONLY (tree_value)
    2255           16 :                    && !TREE_SIDE_EFFECTS (tree_value)
    2256         1638 :                    && immediate_const_ctor_p (DECL_INITIAL (tree_value)))
    2257              :             {
    2258           16 :               HOST_WIDE_INT size = int_expr_size (DECL_INITIAL (tree_value));
    2259           16 :               rtx target = gen_reg_rtx (word_mode);
    2260           16 :               store_constructor (DECL_INITIAL (tree_value), target, 0,
    2261           16 :                                  size, false);
    2262              :               /* On big-endian targets, store_constructor places fields
    2263              :                  from the MSB, which places any padding bits in the least
    2264              :                  significant bytes.  If required, use a logical right shift
    2265              :                  to place things where expected in a register parameter.  */
    2266           16 :               if (BYTES_BIG_ENDIAN
    2267              :                   && size < UNITS_PER_WORD
    2268              :                   && args[i].locate.where_pad == PAD_DOWNWARD)
    2269              :                 target = expand_shift (RSHIFT_EXPR, word_mode, target,
    2270              :                                        (UNITS_PER_WORD - size) * BITS_PER_UNIT,
    2271              :                                        NULL_RTX, 1);
    2272           16 :               reg = gen_rtx_REG (word_mode, REGNO (reg));
    2273           16 :               emit_move_insn (reg, target);
    2274              :             }
    2275         1606 :           else if (partial == 0 || args[i].pass_on_stack)
    2276              :             {
    2277              :               /* SIZE and CONST_SIZE are 0 for partial arguments and
    2278              :                  the size of a BLKmode type otherwise.  */
    2279         1606 :               gcc_checking_assert (known_eq (size, const_size));
    2280         1606 :               rtx mem = validize_mem (copy_rtx (args[i].value));
    2281              : 
    2282              :               /* Check for overlap with already clobbered argument area,
    2283              :                  providing that this has non-zero size.  */
    2284         1606 :               if (is_sibcall
    2285           38 :                   && const_size != 0
    2286         1644 :                   && (mem_might_overlap_already_clobbered_arg_p
    2287         1644 :                       (XEXP (args[i].value, 0), const_size)))
    2288            0 :                 *sibcall_failure = true;
    2289              : 
    2290         1606 :               if (const_size % UNITS_PER_WORD == 0
    2291         2991 :                   || MEM_ALIGN (mem) % BITS_PER_WORD == 0)
    2292          434 :                 move_block_to_reg (REGNO (reg), mem, nregs, args[i].mode);
    2293              :               else
    2294              :                 {
    2295         1172 :                   if (nregs > 1)
    2296            0 :                     move_block_to_reg (REGNO (reg), mem, nregs - 1,
    2297              :                                        args[i].mode);
    2298         1172 :                   rtx dest = gen_rtx_REG (word_mode, REGNO (reg) + nregs - 1);
    2299         1172 :                   unsigned int bitoff = (nregs - 1) * BITS_PER_WORD;
    2300         1172 :                   unsigned int bitsize = const_size * BITS_PER_UNIT - bitoff;
    2301         1172 :                   rtx x = extract_bit_field (mem, bitsize, bitoff, 1, dest,
    2302              :                                              word_mode, word_mode, false,
    2303              :                                              NULL);
    2304         1172 :                   if (BYTES_BIG_ENDIAN)
    2305              :                     x = expand_shift (LSHIFT_EXPR, word_mode, x,
    2306              :                                       BITS_PER_WORD - bitsize, dest, 1);
    2307         1172 :                   if (x != dest)
    2308         1140 :                     emit_move_insn (dest, x);
    2309              :                 }
    2310              : 
    2311              :               /* Handle a BLKmode that needs shifting.  */
    2312              :               if (nregs == 1 && const_size < UNITS_PER_WORD
    2313              : #ifdef BLOCK_REG_PADDING
    2314              :                   && args[i].locate.where_pad == PAD_DOWNWARD
    2315              : #else
    2316              :                   && BYTES_BIG_ENDIAN
    2317              : #endif
    2318              :                   )
    2319              :                 {
    2320              :                   rtx dest = gen_rtx_REG (word_mode, REGNO (reg));
    2321              :                   int shift = (UNITS_PER_WORD - const_size) * BITS_PER_UNIT;
    2322              :                   enum tree_code dir = (BYTES_BIG_ENDIAN
    2323              :                                         ? RSHIFT_EXPR : LSHIFT_EXPR);
    2324              :                   rtx x;
    2325              : 
    2326              :                   x = expand_shift (dir, word_mode, dest, shift, dest, 1);
    2327              :                   if (x != dest)
    2328              :                     emit_move_insn (dest, x);
    2329              :                 }
    2330              :             }
    2331              : 
    2332              :           /* When a parameter is a block, and perhaps in other cases, it is
    2333              :              possible that it did a load from an argument slot that was
    2334              :              already clobbered.  */
    2335      9834630 :           if (is_sibcall
    2336      9834630 :               && check_sibcall_argument_overlap (before_arg, &args[i], false))
    2337            0 :             *sibcall_failure = true;
    2338              : 
    2339              :           /* Handle calls that pass values in multiple non-contiguous
    2340              :              locations.  The Irix 6 ABI has examples of this.  */
    2341      9834630 :           if (GET_CODE (reg) == PARALLEL)
    2342       284748 :             use_group_regs (call_fusage, reg);
    2343      9549882 :           else if (nregs == -1)
    2344      9548260 :             use_reg_mode (call_fusage, reg, TYPE_MODE (type));
    2345         1622 :           else if (nregs > 0)
    2346         1608 :             use_regs (call_fusage, REGNO (reg), nregs);
    2347              :         }
    2348              :     }
    2349      5835541 : }
    2350              : 
    2351              : /* We need to pop PENDING_STACK_ADJUST bytes.  But, if the arguments
    2352              :    wouldn't fill up an even multiple of PREFERRED_UNIT_STACK_BOUNDARY
    2353              :    bytes, then we would need to push some additional bytes to pad the
    2354              :    arguments.  So, we try to compute an adjust to the stack pointer for an
    2355              :    amount that will leave the stack under-aligned by UNADJUSTED_ARGS_SIZE
    2356              :    bytes.  Then, when the arguments are pushed the stack will be perfectly
    2357              :    aligned.
    2358              : 
    2359              :    Return true if this optimization is possible, storing the adjustment
    2360              :    in ADJUSTMENT_OUT and setting ARGS_SIZE->CONSTANT to the number of
    2361              :    bytes that should be popped after the call.  */
    2362              : 
    2363              : static bool
    2364        14358 : combine_pending_stack_adjustment_and_call (poly_int64 *adjustment_out,
    2365              :                                            poly_int64 unadjusted_args_size,
    2366              :                                            struct args_size *args_size,
    2367              :                                            unsigned int preferred_unit_stack_boundary)
    2368              : {
    2369              :   /* The number of bytes to pop so that the stack will be
    2370              :      under-aligned by UNADJUSTED_ARGS_SIZE bytes.  */
    2371        14358 :   poly_int64 adjustment;
    2372              :   /* The alignment of the stack after the arguments are pushed, if we
    2373              :      just pushed the arguments without adjust the stack here.  */
    2374        14358 :   unsigned HOST_WIDE_INT unadjusted_alignment;
    2375              : 
    2376        14358 :   if (!known_misalignment (stack_pointer_delta + unadjusted_args_size,
    2377              :                            preferred_unit_stack_boundary,
    2378              :                            &unadjusted_alignment))
    2379              :     return false;
    2380              : 
    2381              :   /* We want to get rid of as many of the PENDING_STACK_ADJUST bytes
    2382              :      as possible -- leaving just enough left to cancel out the
    2383              :      UNADJUSTED_ALIGNMENT.  In other words, we want to ensure that the
    2384              :      PENDING_STACK_ADJUST is non-negative, and congruent to
    2385              :      -UNADJUSTED_ALIGNMENT modulo the PREFERRED_UNIT_STACK_BOUNDARY.  */
    2386              : 
    2387              :   /* Begin by trying to pop all the bytes.  */
    2388        14358 :   unsigned HOST_WIDE_INT tmp_misalignment;
    2389        14358 :   if (!known_misalignment (pending_stack_adjust,
    2390              :                            preferred_unit_stack_boundary,
    2391              :                            &tmp_misalignment))
    2392              :     return false;
    2393        14358 :   unadjusted_alignment -= tmp_misalignment;
    2394        14358 :   adjustment = pending_stack_adjust;
    2395              :   /* Push enough additional bytes that the stack will be aligned
    2396              :      after the arguments are pushed.  */
    2397        14358 :   if (preferred_unit_stack_boundary > 1 && unadjusted_alignment)
    2398        14165 :     adjustment -= preferred_unit_stack_boundary - unadjusted_alignment;
    2399              : 
    2400              :   /* We need to know whether the adjusted argument size
    2401              :      (UNADJUSTED_ARGS_SIZE - ADJUSTMENT) constitutes an allocation
    2402              :      or a deallocation.  */
    2403        14358 :   if (!ordered_p (adjustment, unadjusted_args_size))
    2404              :     return false;
    2405              : 
    2406              :   /* Now, sets ARGS_SIZE->CONSTANT so that we pop the right number of
    2407              :      bytes after the call.  The right number is the entire
    2408              :      PENDING_STACK_ADJUST less our ADJUSTMENT plus the amount required
    2409              :      by the arguments in the first place.  */
    2410              :   args_size->constant
    2411        14358 :     = pending_stack_adjust - adjustment + unadjusted_args_size;
    2412              : 
    2413        14358 :   *adjustment_out = adjustment;
    2414        14358 :   return true;
    2415              : }
    2416              : 
    2417              : /* Scan X expression if it does not dereference any argument slots
    2418              :    we already clobbered by tail call arguments (as noted in stored_args_map
    2419              :    bitmap).
    2420              :    Return true if X expression dereferences such argument slots,
    2421              :    false otherwise.  */
    2422              : 
    2423              : static bool
    2424      1565897 : check_sibcall_argument_overlap_1 (rtx x)
    2425              : {
    2426      1565897 :   RTX_CODE code;
    2427      1565897 :   int i, j;
    2428      1565897 :   const char *fmt;
    2429              : 
    2430      1565897 :   if (x == NULL_RTX)
    2431              :     return false;
    2432              : 
    2433      1565897 :   code = GET_CODE (x);
    2434              : 
    2435              :   /* We need not check the operands of the CALL expression itself.  */
    2436      1565897 :   if (code == CALL)
    2437              :     return false;
    2438              : 
    2439      1440191 :   if (code == MEM)
    2440        17965 :     return (mem_might_overlap_already_clobbered_arg_p
    2441        35930 :             (XEXP (x, 0), GET_MODE_SIZE (GET_MODE (x))));
    2442              : 
    2443              :   /* Scan all subexpressions.  */
    2444      1422226 :   fmt = GET_RTX_FORMAT (code);
    2445      3423234 :   for (i = 0; i < GET_RTX_LENGTH (code); i++, fmt++)
    2446              :     {
    2447      2001008 :       if (*fmt == 'e')
    2448              :         {
    2449       985635 :           if (check_sibcall_argument_overlap_1 (XEXP (x, i)))
    2450              :             return true;
    2451              :         }
    2452      1015373 :       else if (*fmt == 'E')
    2453              :         {
    2454         2441 :           for (j = 0; j < XVECLEN (x, i); j++)
    2455         1577 :             if (check_sibcall_argument_overlap_1 (XVECEXP (x, i, j)))
    2456              :               return true;
    2457              :         }
    2458              :     }
    2459              :   return false;
    2460              : }
    2461              : 
    2462              : /* Scan sequence after INSN if it does not dereference any argument slots
    2463              :    we already clobbered by tail call arguments (as noted in stored_args_map
    2464              :    bitmap).  If MARK_STORED_ARGS_MAP, add stack slots for ARG to
    2465              :    stored_args_map bitmap afterwards (when ARG is a register
    2466              :    MARK_STORED_ARGS_MAP should be false).  Return true if sequence after
    2467              :    INSN dereferences such argument slots, false otherwise.  */
    2468              : 
    2469              : static bool
    2470       349129 : check_sibcall_argument_overlap (rtx_insn *insn, struct arg_data *arg,
    2471              :                                 bool mark_stored_args_map)
    2472              : {
    2473       349129 :   poly_uint64 low, high;
    2474       349129 :   unsigned HOST_WIDE_INT const_low, const_high;
    2475              : 
    2476       349129 :   if (insn == NULL_RTX)
    2477       165961 :     insn = get_insns ();
    2478              :   else
    2479       183168 :     insn = NEXT_INSN (insn);
    2480              : 
    2481       927814 :   for (; insn; insn = NEXT_INSN (insn))
    2482       578685 :     if (INSN_P (insn)
    2483       578685 :         && check_sibcall_argument_overlap_1 (PATTERN (insn)))
    2484              :       break;
    2485              : 
    2486       349129 :   if (mark_stored_args_map)
    2487              :     {
    2488        10465 :       if (ARGS_GROW_DOWNWARD)
    2489              :         low = -arg->locate.slot_offset.constant - arg->locate.size.constant;
    2490              :       else
    2491        10465 :         low = arg->locate.slot_offset.constant;
    2492        10465 :       high = low + arg->locate.size.constant;
    2493              : 
    2494        10465 :       const_low = constant_lower_bound (low);
    2495        10465 :       if (high.is_constant (&const_high))
    2496        72433 :         for (unsigned HOST_WIDE_INT i = const_low; i < const_high; ++i)
    2497        61968 :           bitmap_set_bit (stored_args_map, i);
    2498              :       else
    2499              :         stored_args_watermark = MIN (stored_args_watermark, const_low);
    2500              :     }
    2501       349129 :   return insn != NULL_RTX;
    2502              : }
    2503              : 
    2504              : /* Given that a function returns a value of mode MODE at the most
    2505              :    significant end of hard register VALUE, shift VALUE left or right
    2506              :    as specified by LEFT_P.  Return true if some action was needed.  */
    2507              : 
    2508              : bool
    2509            0 : shift_return_value (machine_mode mode, bool left_p, rtx value)
    2510              : {
    2511            0 :   gcc_assert (REG_P (value) && HARD_REGISTER_P (value));
    2512            0 :   machine_mode value_mode = GET_MODE (value);
    2513            0 :   poly_int64 shift = GET_MODE_BITSIZE (value_mode) - GET_MODE_BITSIZE (mode);
    2514              : 
    2515            0 :   if (known_eq (shift, 0))
    2516              :     return false;
    2517              : 
    2518              :   /* Use ashr rather than lshr for right shifts.  This is for the benefit
    2519              :      of the MIPS port, which requires SImode values to be sign-extended
    2520              :      when stored in 64-bit registers.  */
    2521            0 :   if (!force_expand_binop (value_mode, left_p ? ashl_optab : ashr_optab,
    2522              :                            value, gen_int_shift_amount (value_mode, shift),
    2523              :                            value, 1, OPTAB_WIDEN))
    2524            0 :     gcc_unreachable ();
    2525              :   return true;
    2526              : }
    2527              : 
    2528              : /* If X is a likely-spilled register value, copy it to a pseudo
    2529              :    register and return that register.  Return X otherwise.  */
    2530              : 
    2531              : static rtx
    2532       190762 : avoid_likely_spilled_reg (rtx x)
    2533              : {
    2534       190762 :   rtx new_rtx;
    2535              : 
    2536       190762 :   if (REG_P (x)
    2537       190762 :       && HARD_REGISTER_P (x)
    2538       374843 :       && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (x))))
    2539              :     {
    2540              :       /* Make sure that we generate a REG rather than a CONCAT.
    2541              :          Moves into CONCATs can need nontrivial instructions,
    2542              :          and the whole point of this function is to avoid
    2543              :          using the hard register directly in such a situation.  */
    2544       184081 :       generating_concat_p = 0;
    2545       184081 :       new_rtx = gen_reg_rtx (GET_MODE (x));
    2546       184081 :       generating_concat_p = 1;
    2547       184081 :       emit_move_insn (new_rtx, x);
    2548       184081 :       return new_rtx;
    2549              :     }
    2550              :   return x;
    2551              : }
    2552              : 
    2553              : /* Helper function for expand_call.
    2554              :    Return false is EXP is not implementable as a sibling call.  */
    2555              : 
    2556              : static bool
    2557       136023 : can_implement_as_sibling_call_p (tree exp,
    2558              :                                  rtx structure_value_addr,
    2559              :                                  tree funtype,
    2560              :                                  tree fndecl,
    2561              :                                  int flags,
    2562              :                                  tree addr,
    2563              :                                  const args_size &args_size)
    2564              : {
    2565       136023 :   if (!targetm.have_sibcall_epilogue ()
    2566       136023 :       && !targetm.emit_epilogue_for_sibcall)
    2567              :     {
    2568            0 :       maybe_complain_about_tail_call (exp, _("machine description does not "
    2569              :                                              "have a sibcall_epilogue "
    2570              :                                              "instruction pattern"));
    2571            0 :       return false;
    2572              :     }
    2573              : 
    2574              :   /* Doing sibling call optimization needs some work, since
    2575              :      structure_value_addr can be allocated on the stack.
    2576              :      It does not seem worth the effort since few optimizable
    2577              :      sibling calls will return a structure.  */
    2578       136023 :   if (structure_value_addr != NULL_RTX)
    2579              :     {
    2580          506 :       maybe_complain_about_tail_call (exp, _("callee returns a structure"));
    2581          506 :       return false;
    2582              :     }
    2583              : 
    2584              :   /* Check whether the target is able to optimize the call
    2585              :      into a sibcall.  */
    2586       135517 :   if (!targetm.function_ok_for_sibcall (fndecl, exp))
    2587              :     {
    2588         6404 :       maybe_complain_about_tail_call (exp, _("target is not able to optimize "
    2589              :                                              "the call into a sibling call"));
    2590         6404 :       return false;
    2591              :     }
    2592              : 
    2593              :   /* Functions that do not return exactly once may not be sibcall
    2594              :      optimized.  */
    2595       129113 :   if (flags & ECF_RETURNS_TWICE)
    2596              :     {
    2597            0 :       maybe_complain_about_tail_call (exp, _("callee returns twice"));
    2598            0 :       return false;
    2599              :     }
    2600       129372 :   if ((flags & ECF_NORETURN) && !CALL_EXPR_MUST_TAIL_CALL (exp))
    2601              :     {
    2602          247 :       maybe_complain_about_tail_call (exp, _("callee does not return"));
    2603          247 :       return false;
    2604              :     }
    2605              : 
    2606       128866 :   if (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (addr)))
    2607       128868 :       && !CALL_EXPR_MUST_TAIL_CALL (exp))
    2608              :     {
    2609            0 :       maybe_complain_about_tail_call (exp, _("volatile function type"));
    2610            0 :       return false;
    2611              :     }
    2612              : 
    2613              :   /* __sanitizer_cov_trace_pc is supposed to inspect its return address
    2614              :      to identify the caller, and therefore should not be tailcalled.  */
    2615       118638 :   if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
    2616       146526 :       && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SANITIZER_COV_TRACE_PC)
    2617              :     {
    2618              :       /* No need for maybe_complain_about_tail_call here:
    2619              :          the call is synthesized by the compiler.  */
    2620              :       return false;
    2621              :     }
    2622              : 
    2623              :   /* If the called function is nested in the current one, it might access
    2624              :      some of the caller's arguments, but could clobber them beforehand if
    2625              :      the argument areas are shared.  */
    2626       128830 :   if (fndecl && decl_function_context (fndecl) == current_function_decl)
    2627              :     {
    2628          111 :       maybe_complain_about_tail_call (exp, _("nested function"));
    2629          111 :       return false;
    2630              :     }
    2631              : 
    2632              :   /* If this function requires more stack slots than the current
    2633              :      function, we cannot change it into a sibling call.
    2634              :      crtl->args.pretend_args_size is not part of the
    2635              :      stack allocated by our caller.  */
    2636       128719 :   if (maybe_gt (args_size.constant,
    2637              :                 crtl->args.size - crtl->args.pretend_args_size))
    2638              :     {
    2639         3013 :       maybe_complain_about_tail_call (exp, _("callee required more stack "
    2640              :                                              "slots than the caller"));
    2641         3013 :       return false;
    2642              :     }
    2643              : 
    2644              :   /* If the callee pops its own arguments, then it must pop exactly
    2645              :      the same number of arguments as the current function.  */
    2646       125706 :   if (maybe_ne (targetm.calls.return_pops_args (fndecl, funtype,
    2647              :                                                 args_size.constant),
    2648       251412 :                 targetm.calls.return_pops_args (current_function_decl,
    2649       125706 :                                                 TREE_TYPE
    2650              :                                                 (current_function_decl),
    2651              :                                                 crtl->args.size)))
    2652              :     {
    2653            0 :       maybe_complain_about_tail_call (exp, _("inconsistent number of"
    2654              :                                              " popped arguments"));
    2655            0 :       return false;
    2656              :     }
    2657              : 
    2658       125706 :   if (!lang_hooks.decls.ok_for_sibcall (fndecl))
    2659              :     {
    2660            0 :       maybe_complain_about_tail_call (exp, _("frontend does not support"
    2661              :                                              " sibling call"));
    2662            0 :       return false;
    2663              :     }
    2664              : 
    2665              :   /* All checks passed.  */
    2666              :   return true;
    2667              : }
    2668              : 
    2669              : /* Update stack alignment when the parameter is passed in the stack
    2670              :    since the outgoing parameter requires extra alignment on the calling
    2671              :    function side. */
    2672              : 
    2673              : static void
    2674      2254764 : update_stack_alignment_for_call (struct locate_and_pad_arg_data *locate)
    2675              : {
    2676      2254764 :   if (crtl->stack_alignment_needed < locate->boundary)
    2677         2262 :     crtl->stack_alignment_needed = locate->boundary;
    2678      2254764 :   if (crtl->preferred_stack_boundary < locate->boundary)
    2679         5457 :     crtl->preferred_stack_boundary = locate->boundary;
    2680      2254764 : }
    2681              : 
    2682              : /* Generate all the code for a CALL_EXPR exp
    2683              :    and return an rtx for its value.
    2684              :    Store the value in TARGET (specified as an rtx) if convenient.
    2685              :    If the value is stored in TARGET then TARGET is returned.
    2686              :    If IGNORE is nonzero, then we ignore the value of the function call.  */
    2687              : 
    2688              : rtx
    2689      5835539 : expand_call (tree exp, rtx target, int ignore)
    2690              : {
    2691              :   /* Nonzero if we are currently expanding a call.  */
    2692      5835539 :   static int currently_expanding_call = 0;
    2693              : 
    2694              :   /* RTX for the function to be called.  */
    2695      5835539 :   rtx funexp;
    2696              :   /* Sequence of insns to perform a normal "call".  */
    2697      5835539 :   rtx_insn *normal_call_insns = NULL;
    2698              :   /* Sequence of insns to perform a tail "call".  */
    2699      5835539 :   rtx_insn *tail_call_insns = NULL;
    2700              :   /* Data type of the function.  */
    2701      5835539 :   tree funtype;
    2702      5835539 :   tree type_arg_types;
    2703      5835539 :   tree rettype;
    2704              :   /* Declaration of the function being called,
    2705              :      or 0 if the function is computed (not known by name).  */
    2706      5835539 :   tree fndecl = 0;
    2707              :   /* The type of the function being called.  */
    2708      5835539 :   tree fntype;
    2709      5835539 :   bool try_tail_call = CALL_EXPR_TAILCALL (exp);
    2710              :   /* tree-tailcall decided not to do tail calls. Error for the musttail case,
    2711              :      unfortunately we don't know the reason so it's fairly vague.
    2712              :      When tree-tailcall reported an error it already cleared the flag,
    2713              :      so this shouldn't really happen unless the
    2714              :      the musttail pass gave up walking before finding the call.  */
    2715      5835539 :   if (!try_tail_call)
    2716      5699472 :     maybe_complain_about_tail_call (exp, _("other reasons"));
    2717      5835539 :   int pass;
    2718              : 
    2719              :   /* Register in which non-BLKmode value will be returned,
    2720              :      or 0 if no value or if value is BLKmode.  */
    2721      5835539 :   rtx valreg;
    2722              :   /* Address where we should return a BLKmode value;
    2723              :      0 if value not BLKmode.  */
    2724      5835539 :   rtx structure_value_addr = 0;
    2725              :   /* Nonzero if that address is being passed by treating it as
    2726              :      an extra, implicit first parameter.  Otherwise,
    2727              :      it is passed by being copied directly into struct_value_rtx.  */
    2728      5835539 :   int structure_value_addr_parm = 0;
    2729              :   /* Holds the value of implicit argument for the struct value.  */
    2730      5835539 :   tree structure_value_addr_value = NULL_TREE;
    2731              :   /* Size of aggregate value wanted, or zero if none wanted
    2732              :      or if we are using the non-reentrant PCC calling convention
    2733              :      or expecting the value in registers.  */
    2734      5835539 :   poly_int64 struct_value_size = 0;
    2735              :   /* True if called function returns an aggregate in memory PCC style,
    2736              :      by returning the address of where to find it.  */
    2737      5835539 :   bool pcc_struct_value = false;
    2738      5835539 :   rtx struct_value = 0;
    2739              : 
    2740              :   /* Number of actual parameters in this call, including struct value addr.  */
    2741      5835539 :   int num_actuals;
    2742              :   /* Number of named args.  Args after this are anonymous ones
    2743              :      and they must all go on the stack.  */
    2744      5835539 :   int n_named_args;
    2745              :   /* Number of complex actual arguments that need to be split.  */
    2746      5835539 :   int num_complex_actuals = 0;
    2747              : 
    2748              :   /* Vector of information about each argument.
    2749              :      Arguments are numbered in the order they will be pushed,
    2750              :      not the order they are written.  */
    2751      5835539 :   struct arg_data *args;
    2752              : 
    2753              :   /* Total size in bytes of all the stack-parms scanned so far.  */
    2754      5835539 :   struct args_size args_size;
    2755      5835539 :   struct args_size adjusted_args_size;
    2756              :   /* Size of arguments before any adjustments (such as rounding).  */
    2757      5835539 :   poly_int64 unadjusted_args_size;
    2758              :   /* Data on reg parms scanned so far.  */
    2759      5835539 :   CUMULATIVE_ARGS args_so_far_v;
    2760      5835539 :   cumulative_args_t args_so_far;
    2761              :   /* Nonzero if a reg parm has been scanned.  */
    2762      5835539 :   int reg_parm_seen;
    2763              : 
    2764              :   /* True if we must avoid push-insns in the args for this call.
    2765              :      If stack space is allocated for register parameters, but not by the
    2766              :      caller, then it is preallocated in the fixed part of the stack frame.
    2767              :      So the entire argument block must then be preallocated (i.e., we
    2768              :      ignore PUSH_ROUNDING in that case).  */
    2769      5835539 :   bool must_preallocate = !targetm.calls.push_argument (0);
    2770              : 
    2771              :   /* Size of the stack reserved for parameter registers.  */
    2772      5835539 :   int reg_parm_stack_space = 0;
    2773              : 
    2774              :   /* Address of space preallocated for stack parms
    2775              :      (on machines that lack push insns), or 0 if space not preallocated.  */
    2776      5835539 :   rtx argblock = 0;
    2777              : 
    2778              :   /* Mask of ECF_ and ERF_ flags.  */
    2779      5835539 :   int flags = 0;
    2780      5835539 :   int return_flags = 0;
    2781              : #ifdef REG_PARM_STACK_SPACE
    2782              :   /* Define the boundary of the register parm stack space that needs to be
    2783              :      saved, if any.  */
    2784      5835539 :   int low_to_save, high_to_save;
    2785      5835539 :   rtx save_area = 0;            /* Place that it is saved */
    2786              : #endif
    2787              : 
    2788      5835539 :   unsigned int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
    2789      5835539 :   char *initial_stack_usage_map = stack_usage_map;
    2790      5835539 :   unsigned HOST_WIDE_INT initial_stack_usage_watermark = stack_usage_watermark;
    2791      5835539 :   char *stack_usage_map_buf = NULL;
    2792              : 
    2793      5835539 :   poly_int64 old_stack_allocated;
    2794              : 
    2795              :   /* State variables to track stack modifications.  */
    2796      5835539 :   rtx old_stack_level = 0;
    2797      5835539 :   int old_stack_arg_under_construction = 0;
    2798      5835539 :   poly_int64 old_pending_adj = 0;
    2799      5835539 :   int old_inhibit_defer_pop = inhibit_defer_pop;
    2800              : 
    2801              :   /* Some stack pointer alterations we make are performed via
    2802              :      allocate_dynamic_stack_space. This modifies the stack_pointer_delta,
    2803              :      which we then also need to save/restore along the way.  */
    2804      5835539 :   poly_int64 old_stack_pointer_delta = 0;
    2805              : 
    2806      5835539 :   rtx call_fusage;
    2807      5835539 :   tree addr = CALL_EXPR_FN (exp);
    2808      5835539 :   int i;
    2809              :   /* The alignment of the stack, in bits.  */
    2810      5835539 :   unsigned HOST_WIDE_INT preferred_stack_boundary;
    2811              :   /* The alignment of the stack, in bytes.  */
    2812      5835539 :   unsigned HOST_WIDE_INT preferred_unit_stack_boundary;
    2813              :   /* The static chain value to use for this call.  */
    2814      5835539 :   rtx static_chain_value;
    2815              :   /* See if this is "nothrow" function call.  */
    2816      5835539 :   if (TREE_NOTHROW (exp))
    2817      2010644 :     flags |= ECF_NOTHROW;
    2818              : 
    2819              :   /* See if we can find a DECL-node for the actual function, and get the
    2820              :      function attributes (flags) from the function decl or type node.  */
    2821      5835539 :   fndecl = get_callee_fndecl (exp);
    2822      5835539 :   if (fndecl)
    2823              :     {
    2824      5653121 :       fntype = TREE_TYPE (fndecl);
    2825      5653121 :       flags |= flags_from_decl_or_type (fndecl);
    2826      5653121 :       return_flags |= decl_return_flags (fndecl);
    2827              :     }
    2828              :   else
    2829              :     {
    2830       182418 :       fntype = TREE_TYPE (TREE_TYPE (addr));
    2831       182418 :       flags |= flags_from_decl_or_type (fntype);
    2832       182418 :       if (CALL_EXPR_BY_DESCRIPTOR (exp))
    2833            0 :         flags |= ECF_BY_DESCRIPTOR;
    2834              :     }
    2835      5835539 :   rettype = TREE_TYPE (exp);
    2836              : 
    2837      5835539 :   struct_value = targetm.calls.struct_value_rtx (fntype, 0);
    2838              : 
    2839              :   /* Warn if this value is an aggregate type,
    2840              :      regardless of which calling convention we are using for it.  */
    2841      5835539 :   if (AGGREGATE_TYPE_P (rettype))
    2842       356606 :     warning (OPT_Waggregate_return, "function call has aggregate value");
    2843              : 
    2844              :   /* If the result of a non looping pure or const function call is
    2845              :      ignored (or void), and none of its arguments are volatile, we can
    2846              :      avoid expanding the call and just evaluate the arguments for
    2847              :      side-effects.  */
    2848      5835539 :   if ((flags & (ECF_CONST | ECF_PURE))
    2849       415477 :       && (!(flags & ECF_LOOPING_CONST_OR_PURE))
    2850       376135 :       && (flags & ECF_NOTHROW)
    2851      6204395 :       && (ignore || target == const0_rtx
    2852       368855 :           || TYPE_MODE (rettype) == VOIDmode))
    2853              :     {
    2854            1 :       bool volatilep = false;
    2855            1 :       tree arg;
    2856            1 :       call_expr_arg_iterator iter;
    2857              : 
    2858            4 :       FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
    2859            3 :         if (TREE_THIS_VOLATILE (arg))
    2860              :           {
    2861              :             volatilep = true;
    2862              :             break;
    2863              :           }
    2864              : 
    2865            1 :       if (! volatilep)
    2866              :         {
    2867            0 :           FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
    2868            0 :             expand_expr (arg, const0_rtx, VOIDmode, EXPAND_NORMAL);
    2869            0 :           return const0_rtx;
    2870              :         }
    2871              :     }
    2872              : 
    2873              : #ifdef REG_PARM_STACK_SPACE
    2874     11488660 :   reg_parm_stack_space = REG_PARM_STACK_SPACE (!fndecl ? fntype : fndecl);
    2875              : #endif
    2876              : 
    2877      5106590 :   if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl)))
    2878     10905834 :       && reg_parm_stack_space > 0 && targetm.calls.push_argument (0))
    2879            0 :     must_preallocate = true;
    2880              : 
    2881              :   /* Set up a place to return a structure.  */
    2882              : 
    2883              :   /* Cater to broken compilers.  */
    2884      5835539 :   if (aggregate_value_p (exp, fntype))
    2885              :     {
    2886              :       /* This call returns a big structure.  */
    2887       225857 :       flags &= ~(ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE);
    2888              : 
    2889              : #ifdef PCC_STATIC_STRUCT_RETURN
    2890              :       {
    2891              :         pcc_struct_value = true;
    2892              :       }
    2893              : #else /* not PCC_STATIC_STRUCT_RETURN */
    2894       225857 :       {
    2895       225857 :         if (!poly_int_tree_p (TYPE_SIZE_UNIT (rettype), &struct_value_size))
    2896           55 :           struct_value_size = -1;
    2897              : 
    2898              :         /* Even if it is semantically safe to use the target as the return
    2899              :            slot, it may be not sufficiently aligned for the return type.  */
    2900       225857 :         if (CALL_EXPR_RETURN_SLOT_OPT (exp)
    2901       216021 :             && target
    2902       200779 :             && MEM_P (target)
    2903              :             /* If rettype is addressable, we may not create a temporary.
    2904              :                If target is properly aligned at runtime and the compiler
    2905              :                just doesn't know about it, it will work fine, otherwise it
    2906              :                will be UB.  */
    2907       373174 :             && (TREE_ADDRESSABLE (rettype)
    2908       124649 :                 || !(MEM_ALIGN (target) < TYPE_ALIGN (rettype)
    2909            0 :                      && targetm.slow_unaligned_access (TYPE_MODE (rettype),
    2910            0 :                                                        MEM_ALIGN (target)))))
    2911       147317 :           structure_value_addr = XEXP (target, 0);
    2912              :         else
    2913              :           {
    2914              :             /* For variable-sized objects, we must be called with a target
    2915              :                specified.  If we were to allocate space on the stack here,
    2916              :                we would have no way of knowing when to free it.  */
    2917        78540 :             rtx d = assign_temp (rettype, 1, 1);
    2918        78540 :             structure_value_addr = XEXP (d, 0);
    2919        78540 :             target = 0;
    2920              :           }
    2921              :       }
    2922              : #endif /* not PCC_STATIC_STRUCT_RETURN */
    2923              :     }
    2924              : 
    2925              :   /* Figure out the amount to which the stack should be aligned.  */
    2926      5835539 :   preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
    2927      5835539 :   if (fndecl)
    2928              :     {
    2929      5653121 :       struct cgraph_rtl_info *i = cgraph_node::rtl_info (fndecl);
    2930              :       /* Without automatic stack alignment, we can't increase preferred
    2931              :          stack boundary.  With automatic stack alignment, it is
    2932              :          unnecessary since unless we can guarantee that all callers will
    2933              :          align the outgoing stack properly, callee has to align its
    2934              :          stack anyway.  */
    2935      5653121 :       if (i
    2936      1301939 :           && i->preferred_incoming_stack_boundary
    2937       968238 :           && i->preferred_incoming_stack_boundary < preferred_stack_boundary)
    2938       302137 :         preferred_stack_boundary = i->preferred_incoming_stack_boundary;
    2939              :     }
    2940              : 
    2941              :   /* Operand 0 is a pointer-to-function; get the type of the function.  */
    2942      5835539 :   funtype = TREE_TYPE (addr);
    2943      5835539 :   gcc_assert (POINTER_TYPE_P (funtype));
    2944      5835539 :   funtype = TREE_TYPE (funtype);
    2945              : 
    2946              :   /* Count whether there are actual complex arguments that need to be split
    2947              :      into their real and imaginary parts.  Munge the type_arg_types
    2948              :      appropriately here as well.  */
    2949      5835539 :   if (targetm.calls.split_complex_arg)
    2950              :     {
    2951            0 :       call_expr_arg_iterator iter;
    2952            0 :       tree arg;
    2953            0 :       FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
    2954              :         {
    2955            0 :           tree type = TREE_TYPE (arg);
    2956            0 :           if (type && TREE_CODE (type) == COMPLEX_TYPE
    2957            0 :               && targetm.calls.split_complex_arg (type))
    2958            0 :             num_complex_actuals++;
    2959              :         }
    2960            0 :       type_arg_types = split_complex_types (TYPE_ARG_TYPES (funtype));
    2961              :     }
    2962              :   else
    2963      5835539 :     type_arg_types = TYPE_ARG_TYPES (funtype);
    2964              : 
    2965      5835539 :   if (flags & ECF_MAY_BE_ALLOCA)
    2966           29 :     cfun->calls_alloca = 1;
    2967              : 
    2968              :   /* If struct_value_rtx is 0, it means pass the address
    2969              :      as if it were an extra parameter.  Put the argument expression
    2970              :      in structure_value_addr_value.  */
    2971      5835539 :   if (structure_value_addr && struct_value == 0)
    2972              :     {
    2973              :       /* If structure_value_addr is a REG other than
    2974              :          virtual_outgoing_args_rtx, we can use always use it.  If it
    2975              :          is not a REG, we must always copy it into a register.
    2976              :          If it is virtual_outgoing_args_rtx, we must copy it to another
    2977              :          register in some cases.  */
    2978       225857 :       rtx temp = (!REG_P (structure_value_addr)
    2979         6800 :                   || (ACCUMULATE_OUTGOING_ARGS
    2980            0 :                       && stack_arg_under_construction
    2981            0 :                       && structure_value_addr == virtual_outgoing_args_rtx)
    2982       225857 :                   ? copy_addr_to_reg (convert_memory_address
    2983              :                                       (Pmode, structure_value_addr))
    2984       219057 :                   : structure_value_addr);
    2985              : 
    2986       225857 :       structure_value_addr_value =
    2987       225857 :         make_tree (build_pointer_type (TREE_TYPE (funtype)), temp);
    2988       225857 :       structure_value_addr_parm = 1;
    2989              :     }
    2990              : 
    2991              :   /* Count the arguments and set NUM_ACTUALS.  */
    2992      5835539 :   num_actuals
    2993      5835539 :     = call_expr_nargs (exp) + num_complex_actuals + structure_value_addr_parm;
    2994              : 
    2995              :   /* Compute number of named args.
    2996              :      First, do a raw count of the args for INIT_CUMULATIVE_ARGS.  */
    2997              : 
    2998      5835539 :   if (type_arg_types != 0)
    2999      5811712 :     n_named_args
    3000      5811712 :       = (list_length (type_arg_types)
    3001              :          /* Count the struct value address, if it is passed as a parm.  */
    3002              :          + structure_value_addr_parm);
    3003        23827 :   else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype))
    3004          564 :     n_named_args = structure_value_addr_parm;
    3005              :   else
    3006              :     /* If we know nothing, treat all args as named.  */
    3007              :     n_named_args = num_actuals;
    3008              : 
    3009              :   /* Start updating where the next arg would go.
    3010              : 
    3011              :      On some machines (such as the PA) indirect calls have a different
    3012              :      calling convention than normal calls.  The fourth argument in
    3013              :      INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
    3014              :      or not.  */
    3015      5835539 :   INIT_CUMULATIVE_ARGS (args_so_far_v, funtype, NULL_RTX, fndecl, n_named_args);
    3016      5835539 :   args_so_far = pack_cumulative_args (&args_so_far_v);
    3017              : 
    3018              :   /* Now possibly adjust the number of named args.
    3019              :      Normally, don't include the last named arg if anonymous args follow.
    3020              :      We do include the last named arg if
    3021              :      targetm.calls.strict_argument_naming() returns nonzero.
    3022              :      (If no anonymous args follow, the result of list_length is actually
    3023              :      one too large.  This is harmless.)
    3024              : 
    3025              :      If targetm.calls.pretend_outgoing_varargs_named() returns
    3026              :      nonzero, and targetm.calls.strict_argument_naming() returns zero,
    3027              :      this machine will be able to place unnamed args that were passed
    3028              :      in registers into the stack.  So treat all args as named.  This
    3029              :      allows the insns emitting for a specific argument list to be
    3030              :      independent of the function declaration.
    3031              : 
    3032              :      If targetm.calls.pretend_outgoing_varargs_named() returns zero,
    3033              :      we do not have any reliable way to pass unnamed args in
    3034              :      registers, so we must force them into memory.  */
    3035              : 
    3036        23827 :   if ((type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype))
    3037      5836103 :       && targetm.calls.strict_argument_naming (args_so_far))
    3038              :     ;
    3039        23263 :   else if (type_arg_types != 0
    3040        23263 :            && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far))
    3041              :     /* Don't include the last named arg.  */
    3042            0 :     --n_named_args;
    3043        23263 :   else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype)
    3044        23263 :            && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far))
    3045              :     n_named_args = 0;
    3046              :   else
    3047              :     /* Treat all args as named.  */
    3048              :     n_named_args = num_actuals;
    3049              : 
    3050              :   /* Make a vector to hold all the information about each arg.  */
    3051      5835539 :   args = XCNEWVEC (struct arg_data, num_actuals);
    3052              : 
    3053              :   /* Build up entries in the ARGS array, compute the size of the
    3054              :      arguments into ARGS_SIZE, etc.  */
    3055      5835539 :   initialize_argument_information (num_actuals, args, &args_size,
    3056              :                                    n_named_args, exp,
    3057              :                                    structure_value_addr_value, fndecl, fntype,
    3058              :                                    args_so_far, reg_parm_stack_space,
    3059              :                                    &old_stack_level, &old_pending_adj,
    3060              :                                    &must_preallocate, &flags,
    3061      5835539 :                                    &try_tail_call, CALL_FROM_THUNK_P (exp));
    3062              : 
    3063      5835539 :   if (args_size.var)
    3064            0 :     must_preallocate = true;
    3065              : 
    3066              :   /* Now make final decision about preallocating stack space.  */
    3067      5835539 :   must_preallocate = finalize_must_preallocate (must_preallocate,
    3068              :                                                 num_actuals, args,
    3069              :                                                 &args_size);
    3070              : 
    3071              :   /* If the structure value address will reference the stack pointer, we
    3072              :      must stabilize it.  We don't need to do this if we know that we are
    3073              :      not going to adjust the stack pointer in processing this call.  */
    3074              : 
    3075      5835539 :   if (structure_value_addr
    3076       225857 :       && (reg_mentioned_p (virtual_stack_dynamic_rtx, structure_value_addr)
    3077       225857 :           || reg_mentioned_p (virtual_outgoing_args_rtx,
    3078              :                               structure_value_addr))
    3079      5835539 :       && (args_size.var
    3080            0 :           || (!ACCUMULATE_OUTGOING_ARGS
    3081            0 :               && maybe_ne (args_size.constant, 0))))
    3082            0 :     structure_value_addr = copy_to_reg (structure_value_addr);
    3083              : 
    3084              :   /* Tail calls can make things harder to debug, and we've traditionally
    3085              :      pushed these optimizations into -O2.  Don't try if we're already
    3086              :      expanding a call, as that means we're an argument.  Don't try if
    3087              :      there's cleanups, as we know there's code to follow the call.  */
    3088      5835539 :   if (currently_expanding_call++ != 0)
    3089              :     {
    3090         6518 :       maybe_complain_about_tail_call (exp, _("inside another call"));
    3091         6518 :       try_tail_call = 0;
    3092              :     }
    3093      5835539 :   if (!flag_optimize_sibling_calls
    3094      2944161 :         && !CALL_FROM_THUNK_P (exp)
    3095      8779263 :         && !CALL_EXPR_MUST_TAIL_CALL (exp))
    3096      2943393 :     try_tail_call = 0;
    3097      5835539 :   if (args_size.var)
    3098              :     {
    3099            0 :       maybe_complain_about_tail_call (exp, _("variable size arguments"));
    3100            0 :       try_tail_call = 0;
    3101              :     }
    3102      5835539 :   if (dbg_cnt (tail_call) == false)
    3103            0 :     try_tail_call = 0;
    3104              : 
    3105              :   /* Workaround buggy C/C++ wrappers around Fortran routines with
    3106              :      character(len=constant) arguments if the hidden string length arguments
    3107              :      are passed on the stack; if the callers forget to pass those arguments,
    3108              :      attempting to tail call in such routines leads to stack corruption.
    3109              :      Avoid tail calls in functions where at least one such hidden string
    3110              :      length argument is passed (partially or fully) on the stack in the
    3111              :      caller and the callee needs to pass any arguments on the stack.
    3112              :      See PR90329.  */
    3113      5835539 :   if (try_tail_call && maybe_ne (args_size.constant, 0))
    3114        14601 :     for (tree arg = DECL_ARGUMENTS (current_function_decl);
    3115        51791 :          arg; arg = DECL_CHAIN (arg))
    3116        37190 :       if (DECL_HIDDEN_STRING_LENGTH (arg) && DECL_INCOMING_RTL (arg))
    3117              :         {
    3118            0 :           subrtx_iterator::array_type array;
    3119            0 :           FOR_EACH_SUBRTX (iter, array, DECL_INCOMING_RTL (arg), NONCONST)
    3120            0 :             if (MEM_P (*iter))
    3121              :               {
    3122            0 :                 try_tail_call = 0;
    3123            0 :                 maybe_complain_about_tail_call (exp, _("hidden string length "
    3124              :                                                        "argument passed on "
    3125              :                                                        "stack"));
    3126            0 :                 break;
    3127              :               }
    3128            0 :         }
    3129              : 
    3130              :   /* If the user has marked the function as requiring tail-call
    3131              :      optimization, attempt it.  */
    3132      5835539 :   if (CALL_EXPR_MUST_TAIL_CALL (exp))
    3133          714 :     try_tail_call = 1;
    3134              : 
    3135              :   /*  Rest of purposes for tail call optimizations to fail.  */
    3136      5835539 :   if (try_tail_call)
    3137       136023 :     try_tail_call = can_implement_as_sibling_call_p (exp,
    3138              :                                                      structure_value_addr,
    3139              :                                                      funtype,
    3140              :                                                      fndecl,
    3141              :                                                      flags, addr, args_size);
    3142              : 
    3143              :   /* Check if caller and callee disagree in promotion of function
    3144              :      return value.  */
    3145      5835539 :   if (try_tail_call)
    3146              :     {
    3147       125706 :       machine_mode caller_mode, caller_promoted_mode;
    3148       125706 :       machine_mode callee_mode, callee_promoted_mode;
    3149       125706 :       int caller_unsignedp, callee_unsignedp;
    3150       125706 :       tree caller_res = DECL_RESULT (current_function_decl);
    3151              : 
    3152       125706 :       caller_unsignedp = TYPE_UNSIGNED (TREE_TYPE (caller_res));
    3153       125706 :       caller_mode = DECL_MODE (caller_res);
    3154       125706 :       callee_unsignedp = TYPE_UNSIGNED (TREE_TYPE (funtype));
    3155       125706 :       callee_mode = TYPE_MODE (TREE_TYPE (funtype));
    3156       125706 :       caller_promoted_mode
    3157       125706 :         = promote_function_mode (TREE_TYPE (caller_res), caller_mode,
    3158              :                                  &caller_unsignedp,
    3159       125706 :                                  TREE_TYPE (current_function_decl), 1);
    3160       125706 :       callee_promoted_mode
    3161       125706 :         = promote_function_mode (TREE_TYPE (funtype), callee_mode,
    3162              :                                  &callee_unsignedp,
    3163              :                                  funtype, 1);
    3164       125706 :       if (caller_mode != VOIDmode
    3165       125706 :           && (caller_promoted_mode != callee_promoted_mode
    3166        23636 :               || ((caller_mode != caller_promoted_mode
    3167        23636 :                    || callee_mode != callee_promoted_mode)
    3168            0 :                   && (caller_unsignedp != callee_unsignedp
    3169            0 :                       || partial_subreg_p (caller_mode, callee_mode)))))
    3170              :         {
    3171            0 :           try_tail_call = 0;
    3172            0 :           maybe_complain_about_tail_call (exp, _("caller and callee disagree "
    3173              :                                                  "in promotion of function "
    3174              :                                                  "return value"));
    3175              :         }
    3176              :     }
    3177              : 
    3178              :   /* Ensure current function's preferred stack boundary is at least
    3179              :      what we need.  Stack alignment may also increase preferred stack
    3180              :      boundary.  */
    3181     17820911 :   for (i = 0; i < num_actuals; i++)
    3182     11985372 :     if (reg_parm_stack_space > 0
    3183     11906564 :         || args[i].reg == 0
    3184      9768519 :         || args[i].partial != 0
    3185      9768519 :         || args[i].pass_on_stack)
    3186      2216853 :       update_stack_alignment_for_call (&args[i].locate);
    3187      5835539 :   if (crtl->preferred_stack_boundary < preferred_stack_boundary)
    3188       865866 :     crtl->preferred_stack_boundary = preferred_stack_boundary;
    3189              :   else
    3190              :     preferred_stack_boundary = crtl->preferred_stack_boundary;
    3191              : 
    3192      5835539 :   preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
    3193              : 
    3194      5835539 :   if (flag_callgraph_info)
    3195            0 :     record_final_call (fndecl, EXPR_LOCATION (exp));
    3196              : 
    3197              :   /* We want to make two insn chains; one for a sibling call, the other
    3198              :      for a normal call.  We will select one of the two chains after
    3199              :      initial RTL generation is complete.  */
    3200     11718623 :   for (pass = try_tail_call ? 0 : 1; pass < 2; pass++)
    3201              :     {
    3202      5835543 :       bool sibcall_failure = false;
    3203      5835543 :       bool normal_failure = false;
    3204              :       /* We want to emit any pending stack adjustments before the tail
    3205              :          recursion "call".  That way we know any adjustment after the tail
    3206              :          recursion call can be ignored if we indeed use the tail
    3207              :          call expansion.  */
    3208      5835543 :       saved_pending_stack_adjust save;
    3209      5835543 :       rtx_insn *insns, *before_call, *after_args;
    3210      5835543 :       rtx next_arg_reg;
    3211              : 
    3212      5835543 :       if (pass == 0)
    3213              :         {
    3214              :           /* State variables we need to save and restore between
    3215              :              iterations.  */
    3216       125706 :           save_pending_stack_adjust (&save);
    3217              :         }
    3218      5835543 :       if (pass)
    3219      5709837 :         flags &= ~ECF_SIBCALL;
    3220              :       else
    3221       125706 :         flags |= ECF_SIBCALL;
    3222              : 
    3223              :       /* Other state variables that we must reinitialize each time
    3224              :          through the loop (that are not initialized by the loop itself).  */
    3225      5835543 :       argblock = 0;
    3226      5835543 :       call_fusage = 0;
    3227              : 
    3228              :       /* Start a new sequence for the normal call case.
    3229              : 
    3230              :          From this point on, if the sibling call fails, we want to set
    3231              :          sibcall_failure instead of continuing the loop.  */
    3232      5835543 :       start_sequence ();
    3233              : 
    3234              :       /* Don't let pending stack adjusts add up to too much.
    3235              :          Also, do all pending adjustments now if there is any chance
    3236              :          this might be a call to alloca or if we are expanding a sibling
    3237              :          call sequence.
    3238              :          Also do the adjustments before a throwing call, otherwise
    3239              :          exception handling can fail; PR 19225. */
    3240      5835543 :       if (maybe_ge (pending_stack_adjust, 32)
    3241      5772287 :           || (maybe_ne (pending_stack_adjust, 0)
    3242       139281 :               && (flags & ECF_MAY_BE_ALLOCA))
    3243      5772287 :           || (maybe_ne (pending_stack_adjust, 0)
    3244       139281 :               && flag_exceptions && !(flags & ECF_NOTHROW))
    3245     11501602 :           || pass == 0)
    3246       294711 :         do_pending_stack_adjust ();
    3247              : 
    3248              :       /* Precompute any arguments as needed.  */
    3249      5835543 :       if (pass)
    3250      5709837 :         precompute_arguments (num_actuals, args);
    3251              : 
    3252              :       /* Check the canary value for sibcall or function which doesn't
    3253              :          return and could throw.  */
    3254      5709837 :       if ((pass == 0
    3255      5709837 :            || ((flags & ECF_NORETURN) != 0 && tree_could_throw_p (exp)))
    3256       458204 :           && crtl->stack_protect_guard
    3257           33 :           && targetm.stack_protect_runtime_enabled_p ())
    3258           33 :         stack_protect_epilogue ();
    3259              : 
    3260      5835543 :       adjusted_args_size = args_size;
    3261              :       /* Compute the actual size of the argument block required.  The variable
    3262              :          and constant sizes must be combined, the size may have to be rounded,
    3263              :          and there may be a minimum required size.  When generating a sibcall
    3264              :          pattern, do not round up, since we'll be re-using whatever space our
    3265              :          caller provided.  */
    3266      5835543 :       unadjusted_args_size
    3267     11545380 :         = compute_argument_block_size (reg_parm_stack_space,
    3268              :                                        &adjusted_args_size,
    3269              :                                        fndecl, fntype,
    3270              :                                        (pass == 0 ? 0
    3271              :                                         : preferred_stack_boundary));
    3272              : 
    3273      5835543 :       old_stack_allocated = stack_pointer_delta - pending_stack_adjust;
    3274              : 
    3275              :       /* The argument block when performing a sibling call is the
    3276              :          incoming argument block.  */
    3277      5835543 :       if (pass == 0)
    3278              :         {
    3279       125706 :           argblock = crtl->args.internal_arg_pointer;
    3280       125706 :           if (STACK_GROWS_DOWNWARD)
    3281       125706 :             argblock
    3282       130626 :               = plus_constant (Pmode, argblock, crtl->args.pretend_args_size);
    3283              :           else
    3284              :             argblock
    3285              :               = plus_constant (Pmode, argblock, -crtl->args.pretend_args_size);
    3286              : 
    3287       125706 :           HOST_WIDE_INT map_size = constant_lower_bound (args_size.constant);
    3288       125706 :           stored_args_map = sbitmap_alloc (map_size);
    3289       125706 :           bitmap_clear (stored_args_map);
    3290       125706 :           stored_args_watermark = HOST_WIDE_INT_M1U;
    3291              :         }
    3292              : 
    3293              :       /* If we have no actual push instructions, or shouldn't use them,
    3294              :          make space for all args right now.  */
    3295      5709837 :       else if (adjusted_args_size.var != 0)
    3296              :         {
    3297            0 :           if (old_stack_level == 0)
    3298              :             {
    3299            0 :               emit_stack_save (SAVE_BLOCK, &old_stack_level);
    3300            0 :               old_stack_pointer_delta = stack_pointer_delta;
    3301            0 :               old_pending_adj = pending_stack_adjust;
    3302            0 :               pending_stack_adjust = 0;
    3303              :               /* stack_arg_under_construction says whether a stack arg is
    3304              :                  being constructed at the old stack level.  Pushing the stack
    3305              :                  gets a clean outgoing argument block.  */
    3306            0 :               old_stack_arg_under_construction = stack_arg_under_construction;
    3307            0 :               stack_arg_under_construction = 0;
    3308              :             }
    3309            0 :           argblock = push_block (ARGS_SIZE_RTX (adjusted_args_size), 0, 0);
    3310            0 :           if (flag_stack_usage_info)
    3311            0 :             current_function_has_unbounded_dynamic_stack_size = 1;
    3312              :         }
    3313              :       else
    3314              :         {
    3315              :           /* Note that we must go through the motions of allocating an argument
    3316              :              block even if the size is zero because we may be storing args
    3317              :              in the area reserved for register arguments, which may be part of
    3318              :              the stack frame.  */
    3319              : 
    3320      5709837 :           poly_int64 needed = adjusted_args_size.constant;
    3321              : 
    3322              :           /* Store the maximum argument space used.  It will be pushed by
    3323              :              the prologue (if ACCUMULATE_OUTGOING_ARGS, or stack overflow
    3324              :              checking).  */
    3325              : 
    3326      5709837 :           crtl->outgoing_args_size = upper_bound (crtl->outgoing_args_size,
    3327              :                                                   needed);
    3328              : 
    3329      5709837 :           if (must_preallocate)
    3330              :             {
    3331        73372 :               if (ACCUMULATE_OUTGOING_ARGS)
    3332              :                 {
    3333              :                   /* Since the stack pointer will never be pushed, it is
    3334              :                      possible for the evaluation of a parm to clobber
    3335              :                      something we have already written to the stack.
    3336              :                      Since most function calls on RISC machines do not use
    3337              :                      the stack, this is uncommon, but must work correctly.
    3338              : 
    3339              :                      Therefore, we save any area of the stack that was already
    3340              :                      written and that we are using.  Here we set up to do this
    3341              :                      by making a new stack usage map from the old one.  The
    3342              :                      actual save will be done by store_one_arg.
    3343              : 
    3344              :                      Another approach might be to try to reorder the argument
    3345              :                      evaluations to avoid this conflicting stack usage.  */
    3346              : 
    3347              :                   /* Since we will be writing into the entire argument area,
    3348              :                      the map must be allocated for its entire size, not just
    3349              :                      the part that is the responsibility of the caller.  */
    3350        73366 :                   if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl))))
    3351        67401 :                     needed += reg_parm_stack_space;
    3352              : 
    3353        73366 :                   poly_int64 limit = needed;
    3354        73366 :                   if (ARGS_GROW_DOWNWARD)
    3355              :                     limit += 1;
    3356              : 
    3357              :                   /* For polynomial sizes, this is the maximum possible
    3358              :                      size needed for arguments with a constant size
    3359              :                      and offset.  */
    3360        73366 :                   HOST_WIDE_INT const_limit = constant_lower_bound (limit);
    3361        73366 :                   highest_outgoing_arg_in_use
    3362        73366 :                     = MAX (initial_highest_arg_in_use, const_limit);
    3363              : 
    3364        73366 :                   free (stack_usage_map_buf);
    3365        73366 :                   stack_usage_map_buf = XNEWVEC (char, highest_outgoing_arg_in_use);
    3366        73366 :                   stack_usage_map = stack_usage_map_buf;
    3367              : 
    3368        73366 :                   if (initial_highest_arg_in_use)
    3369            0 :                     memcpy (stack_usage_map, initial_stack_usage_map,
    3370              :                             initial_highest_arg_in_use);
    3371              : 
    3372        73366 :                   if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
    3373        17653 :                     memset (&stack_usage_map[initial_highest_arg_in_use], 0,
    3374              :                            (highest_outgoing_arg_in_use
    3375        17653 :                             - initial_highest_arg_in_use));
    3376        73366 :                   needed = 0;
    3377              : 
    3378              :                   /* The address of the outgoing argument list must not be
    3379              :                      copied to a register here, because argblock would be left
    3380              :                      pointing to the wrong place after the call to
    3381              :                      allocate_dynamic_stack_space below.  */
    3382              : 
    3383        73366 :                   argblock = virtual_outgoing_args_rtx;
    3384              :                 }
    3385              :               else
    3386              :                 {
    3387              :                   /* Try to reuse some or all of the pending_stack_adjust
    3388              :                      to get this space.  */
    3389            6 :                   if (inhibit_defer_pop == 0
    3390           12 :                       && (combine_pending_stack_adjustment_and_call
    3391            6 :                           (&needed,
    3392              :                            unadjusted_args_size,
    3393              :                            &adjusted_args_size,
    3394              :                            preferred_unit_stack_boundary)))
    3395              :                     {
    3396              :                       /* combine_pending_stack_adjustment_and_call computes
    3397              :                          an adjustment before the arguments are allocated.
    3398              :                          Account for them and see whether or not the stack
    3399              :                          needs to go up or down.  */
    3400            6 :                       needed = unadjusted_args_size - needed;
    3401              : 
    3402              :                       /* Checked by
    3403              :                          combine_pending_stack_adjustment_and_call.  */
    3404            6 :                       gcc_checking_assert (ordered_p (needed, 0));
    3405            6 :                       if (maybe_lt (needed, 0))
    3406              :                         {
    3407              :                           /* We're releasing stack space.  */
    3408              :                           /* ??? We can avoid any adjustment at all if we're
    3409              :                              already aligned.  FIXME.  */
    3410            0 :                           pending_stack_adjust = -needed;
    3411            0 :                           do_pending_stack_adjust ();
    3412            0 :                           needed = 0;
    3413              :                         }
    3414              :                       else
    3415              :                         /* We need to allocate space.  We'll do that in
    3416              :                            push_block below.  */
    3417            6 :                         pending_stack_adjust = 0;
    3418              :                     }
    3419              : 
    3420              :                   /* Special case this because overhead of `push_block' in
    3421              :                      this case is non-trivial.  */
    3422            6 :                   if (known_eq (needed, 0))
    3423            4 :                     argblock = virtual_outgoing_args_rtx;
    3424              :                   else
    3425              :                     {
    3426            2 :                       rtx needed_rtx = gen_int_mode (needed, Pmode);
    3427            2 :                       argblock = push_block (needed_rtx, 0, 0);
    3428            2 :                       if (ARGS_GROW_DOWNWARD)
    3429              :                         argblock = plus_constant (Pmode, argblock, needed);
    3430              :                     }
    3431              : 
    3432              :                   /* We only really need to call `copy_to_reg' in the case
    3433              :                      where push insns are going to be used to pass ARGBLOCK
    3434              :                      to a function call in ARGS.  In that case, the stack
    3435              :                      pointer changes value from the allocation point to the
    3436              :                      call point, and hence the value of
    3437              :                      VIRTUAL_OUTGOING_ARGS_RTX changes as well.  But might
    3438              :                      as well always do it.  */
    3439            6 :                   argblock = copy_to_reg (argblock);
    3440              :                 }
    3441              :             }
    3442              :         }
    3443              : 
    3444      5835543 :       if (ACCUMULATE_OUTGOING_ARGS)
    3445              :         {
    3446              :           /* The save/restore code in store_one_arg handles all
    3447              :              cases except one: a constructor call (including a C
    3448              :              function returning a BLKmode struct) to initialize
    3449              :              an argument.  */
    3450        74552 :           if (stack_arg_under_construction)
    3451              :             {
    3452            0 :               rtx push_size
    3453              :                 = (gen_int_mode
    3454            0 :                    (adjusted_args_size.constant
    3455            0 :                     + (OUTGOING_REG_PARM_STACK_SPACE (!fndecl ? fntype
    3456              :                                                       : TREE_TYPE (fndecl))
    3457            0 :                        ? 0 : reg_parm_stack_space), Pmode));
    3458            0 :               if (old_stack_level == 0)
    3459              :                 {
    3460            0 :                   emit_stack_save (SAVE_BLOCK, &old_stack_level);
    3461            0 :                   old_stack_pointer_delta = stack_pointer_delta;
    3462            0 :                   old_pending_adj = pending_stack_adjust;
    3463            0 :                   pending_stack_adjust = 0;
    3464              :                   /* stack_arg_under_construction says whether a stack
    3465              :                      arg is being constructed at the old stack level.
    3466              :                      Pushing the stack gets a clean outgoing argument
    3467              :                      block.  */
    3468            0 :                   old_stack_arg_under_construction
    3469            0 :                     = stack_arg_under_construction;
    3470            0 :                   stack_arg_under_construction = 0;
    3471              :                   /* Make a new map for the new argument list.  */
    3472            0 :                   free (stack_usage_map_buf);
    3473            0 :                   stack_usage_map_buf = XCNEWVEC (char, highest_outgoing_arg_in_use);
    3474            0 :                   stack_usage_map = stack_usage_map_buf;
    3475            0 :                   highest_outgoing_arg_in_use = 0;
    3476            0 :                   stack_usage_watermark = HOST_WIDE_INT_M1U;
    3477              :                 }
    3478              :               /* We can pass TRUE as the 4th argument because we just
    3479              :                  saved the stack pointer and will restore it right after
    3480              :                  the call.  */
    3481            0 :               allocate_dynamic_stack_space (push_size, 0, BIGGEST_ALIGNMENT,
    3482              :                                             -1, true);
    3483              :             }
    3484              : 
    3485              :           /* If argument evaluation might modify the stack pointer,
    3486              :              copy the address of the argument list to a register.  */
    3487       368918 :           for (i = 0; i < num_actuals; i++)
    3488       294366 :             if (args[i].pass_on_stack)
    3489              :               {
    3490            0 :                 argblock = copy_addr_to_reg (argblock);
    3491            0 :                 break;
    3492              :               }
    3493              :         }
    3494              : 
    3495      5835543 :       compute_argument_addresses (args, argblock, num_actuals);
    3496              : 
    3497              :       /* Stack is properly aligned, pops can't safely be deferred during
    3498              :          the evaluation of the arguments.  */
    3499      5835543 :       NO_DEFER_POP;
    3500              : 
    3501              :       /* Precompute all register parameters.  It isn't safe to compute
    3502              :          anything once we have started filling any specific hard regs.
    3503              :          TLS symbols sometimes need a call to resolve.  Precompute
    3504              :          register parameters before any stack pointer manipulation
    3505              :          to avoid unaligned stack in the called function.  */
    3506      5835543 :       precompute_register_parameters (num_actuals, args, &reg_parm_seen);
    3507              : 
    3508      5835541 :       OK_DEFER_POP;
    3509              : 
    3510              :       /* Perform stack alignment before the first push (the last arg).  */
    3511      5835541 :       if (argblock == 0
    3512      5636463 :           && maybe_gt (adjusted_args_size.constant, reg_parm_stack_space)
    3513      6741556 :           && maybe_ne (adjusted_args_size.constant, unadjusted_args_size))
    3514              :         {
    3515              :           /* When the stack adjustment is pending, we get better code
    3516              :              by combining the adjustments.  */
    3517       726523 :           if (maybe_ne (pending_stack_adjust, 0)
    3518        14352 :               && ! inhibit_defer_pop
    3519       740875 :               && (combine_pending_stack_adjustment_and_call
    3520        14352 :                   (&pending_stack_adjust,
    3521              :                    unadjusted_args_size,
    3522              :                    &adjusted_args_size,
    3523              :                    preferred_unit_stack_boundary)))
    3524        14352 :             do_pending_stack_adjust ();
    3525       712171 :           else if (argblock == 0)
    3526       712171 :             anti_adjust_stack (gen_int_mode (adjusted_args_size.constant
    3527              :                                              - unadjusted_args_size,
    3528       712171 :                                              Pmode));
    3529              :         }
    3530              :       /* Now that the stack is properly aligned, pops can't safely
    3531              :          be deferred during the evaluation of the arguments.  */
    3532      5835541 :       NO_DEFER_POP;
    3533              : 
    3534              :       /* Record the maximum pushed stack space size.  We need to delay
    3535              :          doing it this far to take into account the optimization done
    3536              :          by combine_pending_stack_adjustment_and_call.  */
    3537      5835541 :       if (flag_stack_usage_info
    3538         1044 :           && !ACCUMULATE_OUTGOING_ARGS
    3539         1044 :           && pass
    3540      5836585 :           && adjusted_args_size.var == 0)
    3541              :         {
    3542              :           poly_int64 pushed = (adjusted_args_size.constant
    3543         1044 :                                + pending_stack_adjust);
    3544         1044 :           current_function_pushed_stack_size
    3545         2088 :             = upper_bound (current_function_pushed_stack_size, pushed);
    3546              :         }
    3547              : 
    3548      5835541 :       funexp = rtx_for_function_call (fndecl, addr);
    3549              : 
    3550      5835541 :       if (CALL_EXPR_STATIC_CHAIN (exp))
    3551        37756 :         static_chain_value = expand_normal (CALL_EXPR_STATIC_CHAIN (exp));
    3552              :       else
    3553              :         static_chain_value = 0;
    3554              : 
    3555              : #ifdef REG_PARM_STACK_SPACE
    3556              :       /* Save the fixed argument area if it's part of the caller's frame and
    3557              :          is clobbered by argument setup for this call.  */
    3558      5835541 :       if (ACCUMULATE_OUTGOING_ARGS && pass)
    3559        73366 :         save_area = save_fixed_argument_area (reg_parm_stack_space, argblock,
    3560              :                                               &low_to_save, &high_to_save);
    3561              : #endif
    3562              : 
    3563              :       /* Now store (and compute if necessary) all non-register parms.
    3564              :          These come before register parms, since they can require block-moves,
    3565              :          which could clobber the registers used for register parms.
    3566              :          Parms which have partial registers are not stored here,
    3567              :          but we do preallocate space here if they want that.  */
    3568              : 
    3569     17820951 :       for (i = 0; i < num_actuals; i++)
    3570              :         {
    3571     11985410 :           if (args[i].reg == 0 || args[i].pass_on_stack)
    3572              :             {
    3573      2150780 :               rtx_insn *before_arg = get_last_insn ();
    3574              : 
    3575              :               /* We don't allow passing huge (> 2^30 B) arguments
    3576              :                  by value.  It would cause an overflow later on.  */
    3577      2150780 :               if (constant_lower_bound (adjusted_args_size.constant)
    3578              :                   >= (1 << (HOST_BITS_PER_INT - 2)))
    3579              :                 {
    3580            6 :                   sorry ("passing too large argument on stack");
    3581              :                   /* Don't worry about stack clean-up.  */
    3582            6 :                   if (pass == 0)
    3583            0 :                     sibcall_failure = true;
    3584              :                   else
    3585              :                     normal_failure = true;
    3586            6 :                   continue;
    3587              :                 }
    3588              : 
    3589      2150774 :               if (store_one_arg (&args[i], argblock, flags,
    3590      2150774 :                                  adjusted_args_size.var != 0,
    3591              :                                  reg_parm_stack_space)
    3592      2150774 :                   || (pass == 0
    3593        10465 :                       && check_sibcall_argument_overlap (before_arg,
    3594              :                                                          &args[i], true)))
    3595            4 :                 sibcall_failure = true;
    3596      2150774 :               gcc_checking_assert (!args[i].stack || argblock);
    3597              :             }
    3598              : 
    3599     11985404 :           if (args[i].stack)
    3600        64056 :             call_fusage
    3601        64056 :               = gen_rtx_EXPR_LIST (TYPE_MODE (TREE_TYPE (args[i].tree_value)),
    3602              :                                    gen_rtx_USE (VOIDmode, args[i].stack),
    3603              :                                    call_fusage);
    3604              :         }
    3605              : 
    3606              :       /* If we have a parm that is passed in registers but not in memory
    3607              :          and whose alignment does not permit a direct copy into registers,
    3608              :          make a group of pseudos that correspond to each register that we
    3609              :          will later fill.  */
    3610      5835541 :       if (STRICT_ALIGNMENT)
    3611              :         store_unaligned_arguments_into_pseudos (args, num_actuals);
    3612              : 
    3613              :       /* Now store any partially-in-registers parm.
    3614              :          This is the last place a block-move can happen.  */
    3615      5835541 :       if (reg_parm_seen)
    3616     14811729 :         for (i = 0; i < num_actuals; i++)
    3617     10473396 :           if (args[i].partial != 0 && ! args[i].pass_on_stack)
    3618              :             {
    3619            0 :               rtx_insn *before_arg = get_last_insn ();
    3620              : 
    3621              :              /* On targets with weird calling conventions (e.g. PA) it's
    3622              :                 hard to ensure that all cases of argument overlap between
    3623              :                 stack and registers work.  Play it safe and bail out.  */
    3624            0 :               if (ARGS_GROW_DOWNWARD && !STACK_GROWS_DOWNWARD)
    3625              :                 {
    3626              :                   sibcall_failure = true;
    3627              :                   break;
    3628              :                 }
    3629              : 
    3630            0 :               if (store_one_arg (&args[i], argblock, flags,
    3631            0 :                                  adjusted_args_size.var != 0,
    3632              :                                  reg_parm_stack_space)
    3633            0 :                   || (pass == 0
    3634            0 :                       && check_sibcall_argument_overlap (before_arg,
    3635              :                                                          &args[i], true)))
    3636            0 :                 sibcall_failure = true;
    3637              :             }
    3638              : 
    3639              :       /* Set up the next argument register.  For sibling calls on machines
    3640              :          with register windows this should be the incoming register.  */
    3641      5835541 :       if (pass == 0)
    3642       125706 :         next_arg_reg = targetm.calls.function_incoming_arg
    3643       125706 :           (args_so_far, function_arg_info::end_marker ());
    3644              :       else
    3645      5709835 :         next_arg_reg = targetm.calls.function_arg
    3646      5709835 :           (args_so_far, function_arg_info::end_marker ());
    3647              : 
    3648      5835541 :       targetm.calls.start_call_args (args_so_far);
    3649              : 
    3650      5835541 :       bool any_regs = false;
    3651     23656492 :       for (i = 0; i < num_actuals; i++)
    3652     11985410 :         if (args[i].reg != NULL_RTX)
    3653              :           {
    3654      9834630 :             any_regs = true;
    3655      9834630 :             targetm.calls.call_args (args_so_far, args[i].reg, funtype);
    3656              :           }
    3657      5835541 :       if (!any_regs)
    3658      1497208 :         targetm.calls.call_args (args_so_far, pc_rtx, funtype);
    3659              : 
    3660              :       /* Figure out the register where the value, if any, will come back.  */
    3661      5835541 :       valreg = 0;
    3662      5835541 :       if (TYPE_MODE (rettype) != VOIDmode
    3663      5835541 :           && ! structure_value_addr)
    3664              :         {
    3665      2346326 :           if (pcc_struct_value)
    3666              :             valreg = hard_function_value (build_pointer_type (rettype),
    3667              :                                           fndecl, NULL, (pass == 0));
    3668              :           else
    3669      2346326 :             valreg = hard_function_value (rettype, fndecl, fntype,
    3670              :                                           (pass == 0));
    3671              : 
    3672              :           /* If VALREG is a PARALLEL whose first member has a zero
    3673              :              offset, use that.  This is for targets such as m68k that
    3674              :              return the same value in multiple places.  */
    3675      2346326 :           if (GET_CODE (valreg) == PARALLEL)
    3676              :             {
    3677        11261 :               rtx elem = XVECEXP (valreg, 0, 0);
    3678        11261 :               rtx where = XEXP (elem, 0);
    3679        11261 :               rtx offset = XEXP (elem, 1);
    3680        11261 :               if (offset == const0_rtx
    3681        11244 :                   && GET_MODE (where) == GET_MODE (valreg))
    3682      5835541 :                 valreg = where;
    3683              :             }
    3684              :         }
    3685              : 
    3686              :       /* If register arguments require space on the stack and stack space
    3687              :          was not preallocated, allocate stack space here for arguments
    3688              :          passed in registers.  */
    3689      5106588 :       if (OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl)))
    3690        36295 :           && !ACCUMULATE_OUTGOING_ARGS
    3691      5864719 :           && !must_preallocate && reg_parm_stack_space > 0)
    3692        29178 :         anti_adjust_stack (GEN_INT (reg_parm_stack_space));
    3693              : 
    3694              :       /* Cover pushed arguments with call usage, so that cselib knows to
    3695              :          invalidate the stores in them at the call insn.  */
    3696      5835541 :       if (pass == 1 && !argblock
    3697      5835541 :           && (maybe_ne (adjusted_args_size.constant, 0)
    3698      4712987 :               || adjusted_args_size.var))
    3699              :         {
    3700       923476 :           rtx addr = virtual_outgoing_args_rtx;
    3701       923476 :           poly_int64 size = adjusted_args_size.constant;
    3702       923476 :           if (!STACK_GROWS_DOWNWARD)
    3703              :             {
    3704              :               if (adjusted_args_size.var)
    3705              :                 /* ??? We can't compute the exact base address.  */
    3706              :                 addr = gen_rtx_PLUS (GET_MODE (addr), addr,
    3707              :                                      gen_rtx_SCRATCH (GET_MODE (addr)));
    3708              :               else
    3709              :                 addr = plus_constant (GET_MODE (addr), addr, -size);
    3710              :             }
    3711       923476 :           rtx fu = gen_rtx_MEM (BLKmode, addr);
    3712       923476 :           if (adjusted_args_size.var == 0)
    3713       923476 :             set_mem_size (fu, size);
    3714       923476 :           call_fusage
    3715       923476 :             = gen_rtx_EXPR_LIST (BLKmode,
    3716              :                                  gen_rtx_USE (VOIDmode, fu),
    3717              :                                  call_fusage);
    3718              :         }
    3719              : 
    3720              :       /* Pass the function the address in which to return a
    3721              :          structure value.  */
    3722      5835541 :       if (pass != 0 && structure_value_addr && ! structure_value_addr_parm)
    3723              :         {
    3724            0 :           structure_value_addr
    3725            0 :             = convert_memory_address (Pmode, structure_value_addr);
    3726            0 :           emit_move_insn (struct_value,
    3727            0 :                           force_reg (Pmode,
    3728              :                                      force_operand (structure_value_addr,
    3729              :                                                     NULL_RTX)));
    3730              : 
    3731            0 :           if (REG_P (struct_value))
    3732            0 :             use_reg (&call_fusage, struct_value);
    3733              :         }
    3734              : 
    3735      5835541 :       after_args = get_last_insn ();
    3736      6017959 :       funexp = prepare_call_address (fndecl ? fndecl : fntype, funexp,
    3737              :                                      static_chain_value, &call_fusage,
    3738              :                                      reg_parm_seen, flags);
    3739              : 
    3740      5835541 :       load_register_parameters (args, num_actuals, &call_fusage, flags,
    3741              :                                 pass == 0, &sibcall_failure);
    3742              : 
    3743              :       /* Save a pointer to the last insn before the call, so that we can
    3744              :          later safely search backwards to find the CALL_INSN.  */
    3745      5835541 :       before_call = get_last_insn ();
    3746              : 
    3747      5835541 :       if (pass == 1 && (return_flags & ERF_RETURNS_ARG))
    3748              :         {
    3749       157534 :           int arg_nr = return_flags & ERF_RETURN_ARG_MASK;
    3750       157534 :           arg_nr = num_actuals - arg_nr - 1;
    3751       157534 :           if (arg_nr >= 0
    3752       157534 :               && arg_nr < num_actuals
    3753       157528 :               && args[arg_nr].reg
    3754       150669 :               && valreg
    3755       145365 :               && REG_P (valreg)
    3756       145365 :               && GET_MODE (args[arg_nr].reg) == GET_MODE (valreg))
    3757       145365 :           call_fusage
    3758       145365 :             = gen_rtx_EXPR_LIST (TYPE_MODE (TREE_TYPE (args[arg_nr].tree_value)),
    3759              :                                  gen_rtx_SET (valreg, args[arg_nr].reg),
    3760              :                                  call_fusage);
    3761              :         }
    3762              :       /* All arguments and registers used for the call must be set up by
    3763              :          now!  */
    3764              : 
    3765              :       /* Stack must be properly aligned now.  */
    3766     11545376 :       gcc_assert (!pass
    3767              :                   || multiple_p (stack_pointer_delta,
    3768              :                                  preferred_unit_stack_boundary));
    3769              : 
    3770              :       /* Generate the actual call instruction.  */
    3771      5835541 :       emit_call_1 (funexp, exp, fndecl, funtype, unadjusted_args_size,
    3772              :                    adjusted_args_size.constant, struct_value_size,
    3773              :                    next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage,
    3774              :                    flags, args_so_far);
    3775              : 
    3776      5835541 :       rtx_call_insn *last;
    3777      5835541 :       rtx datum = NULL_RTX;
    3778      5835541 :       if (fndecl != NULL_TREE)
    3779              :         {
    3780      5653123 :           datum = XEXP (DECL_RTL (fndecl), 0);
    3781      5653123 :           gcc_assert (datum != NULL_RTX
    3782              :                       && GET_CODE (datum) == SYMBOL_REF);
    3783              :         }
    3784      5835541 :       last = last_call_insn ();
    3785      5835541 :       add_reg_note (last, REG_CALL_DECL, datum);
    3786              : 
    3787              :       /* If the call setup or the call itself overlaps with anything
    3788              :          of the argument setup we probably clobbered our call address.
    3789              :          In that case we can't do sibcalls.  */
    3790      5835541 :       if (pass == 0
    3791      5835541 :           && check_sibcall_argument_overlap (after_args, 0, false))
    3792            0 :         sibcall_failure = true;
    3793              : 
    3794              :       /* If a non-BLKmode value is returned at the most significant end
    3795              :          of a register, shift the register right by the appropriate amount
    3796              :          and update VALREG accordingly.  BLKmode values are handled by the
    3797              :          group load/store machinery below.  */
    3798      5835541 :       if (!structure_value_addr
    3799              :           && !pcc_struct_value
    3800      5609684 :           && TYPE_MODE (rettype) != VOIDmode
    3801      2346326 :           && TYPE_MODE (rettype) != BLKmode
    3802      2343702 :           && REG_P (valreg)
    3803      8169619 :           && targetm.calls.return_in_msb (rettype))
    3804              :         {
    3805            0 :           if (shift_return_value (TYPE_MODE (rettype), false, valreg))
    3806            0 :             sibcall_failure = true;
    3807            0 :           valreg = gen_rtx_REG (TYPE_MODE (rettype), REGNO (valreg));
    3808              :         }
    3809              : 
    3810              :       /* If the return register exists, for malloc like
    3811              :          function calls, mark the return register with the
    3812              :          alignment and noalias reg note.  */
    3813      5835541 :       if (pass && (flags & ECF_MALLOC) && valreg)
    3814              :         {
    3815       134644 :           rtx temp = gen_reg_rtx (GET_MODE (valreg));
    3816       134644 :           rtx_insn *last;
    3817              : 
    3818              :           /* The return value from a malloc-like function is a pointer.  */
    3819       134644 :           if (TREE_CODE (rettype) == POINTER_TYPE)
    3820       138817 :             mark_reg_pointer (temp, MALLOC_ABI_ALIGNMENT);
    3821              : 
    3822       134644 :           last = emit_move_insn (temp, valreg);
    3823              : 
    3824              :           /* The return value from a malloc-like function cannot alias
    3825              :              anything else.  */
    3826       134644 :           add_reg_note (last, REG_NOALIAS, temp);
    3827       134644 :           valreg = temp;
    3828              :         }
    3829              : 
    3830              :       /* For calls to `setjmp', etc., inform
    3831              :          function.cc:setjmp_warnings that it should complain if
    3832              :          nonvolatile values are live.  For functions that cannot
    3833              :          return, inform flow that control does not fall through.  */
    3834              : 
    3835      5835541 :       if ((flags & ECF_NORETURN) || pass == 0)
    3836              :         {
    3837              :           /* The barrier must be emitted
    3838              :              immediately after the CALL_INSN.  Some ports emit more
    3839              :              than just a CALL_INSN above, so we must search for it here.  */
    3840              : 
    3841       895187 :           rtx_insn *last = get_last_insn ();
    3842       895301 :           while (!CALL_P (last))
    3843              :             {
    3844          114 :               last = PREV_INSN (last);
    3845              :               /* There was no CALL_INSN?  */
    3846          114 :               gcc_assert (last != before_call);
    3847              :             }
    3848              : 
    3849       895187 :           emit_barrier_after (last);
    3850              : 
    3851              :           /* Stack adjustments after a noreturn call are dead code.
    3852              :              However when NO_DEFER_POP is in effect, we must preserve
    3853              :              stack_pointer_delta.  */
    3854       895187 :           if (inhibit_defer_pop == 0)
    3855              :             {
    3856       895187 :               stack_pointer_delta = old_stack_allocated;
    3857       895187 :               pending_stack_adjust = 0;
    3858              :             }
    3859              :         }
    3860              : 
    3861              :       /* If value type not void, return an rtx for the value.  */
    3862              : 
    3863      5835541 :       if (TYPE_MODE (rettype) == VOIDmode
    3864      5835541 :           || ignore)
    3865      3900558 :         target = const0_rtx;
    3866      1934983 :       else if (structure_value_addr)
    3867              :         {
    3868       204709 :           if (target == 0 || !MEM_P (target))
    3869              :             {
    3870        57392 :               target
    3871        57392 :                 = gen_rtx_MEM (TYPE_MODE (rettype),
    3872        57392 :                                memory_address (TYPE_MODE (rettype),
    3873              :                                                structure_value_addr));
    3874        57392 :               set_mem_attributes (target, rettype, 1);
    3875              :             }
    3876              :         }
    3877      1730274 :       else if (pcc_struct_value)
    3878              :         {
    3879              :           /* This is the special C++ case where we need to
    3880              :              know what the true target was.  We take care to
    3881              :              never use this value more than once in one expression.  */
    3882              :           target = gen_rtx_MEM (TYPE_MODE (rettype),
    3883              :                                 copy_to_reg (valreg));
    3884              :           set_mem_attributes (target, rettype, 1);
    3885              :         }
    3886              :       /* Handle calls that return values in multiple non-contiguous locations.
    3887              :          The Irix 6 ABI has examples of this.  */
    3888      1730274 :       else if (GET_CODE (valreg) == PARALLEL)
    3889              :         {
    3890        10993 :           if (target == 0)
    3891         1955 :             target = emit_group_move_into_temps (valreg);
    3892         9038 :           else if (rtx_equal_p (target, valreg))
    3893              :             ;
    3894         9038 :           else if (GET_CODE (target) == PARALLEL)
    3895              :             /* Handle the result of a emit_group_move_into_temps
    3896              :                call in the previous pass.  */
    3897            0 :             emit_group_move (target, valreg);
    3898              :           else
    3899         9038 :             emit_group_store (target, valreg, rettype,
    3900         9038 :                               int_size_in_bytes (rettype));
    3901              :         }
    3902      1719281 :       else if (target
    3903      1577476 :                && GET_MODE (target) == TYPE_MODE (rettype)
    3904      3296757 :                && GET_MODE (target) == GET_MODE (valreg))
    3905              :         {
    3906      1577473 :           bool may_overlap = false;
    3907              : 
    3908              :           /* We have to copy a return value in a CLASS_LIKELY_SPILLED hard
    3909              :              reg to a plain register.  */
    3910      1577473 :           if (!REG_P (target) || HARD_REGISTER_P (target))
    3911        48954 :             valreg = avoid_likely_spilled_reg (valreg);
    3912              : 
    3913              :           /* If TARGET is a MEM in the argument area, and we have
    3914              :              saved part of the argument area, then we can't store
    3915              :              directly into TARGET as it may get overwritten when we
    3916              :              restore the argument save area below.  Don't work too
    3917              :              hard though and simply force TARGET to a register if it
    3918              :              is a MEM; the optimizer is quite likely to sort it out.  */
    3919      1577473 :           if (ACCUMULATE_OUTGOING_ARGS && pass && MEM_P (target))
    3920         1063 :             for (i = 0; i < num_actuals; i++)
    3921          669 :               if (args[i].save_area)
    3922              :                 {
    3923              :                   may_overlap = true;
    3924              :                   break;
    3925              :                 }
    3926              : 
    3927          394 :           if (may_overlap)
    3928            0 :             target = copy_to_reg (valreg);
    3929              :           else
    3930              :             {
    3931              :               /* TARGET and VALREG cannot be equal at this point
    3932              :                  because the latter would not have
    3933              :                  REG_FUNCTION_VALUE_P true, while the former would if
    3934              :                  it were referring to the same register.
    3935              : 
    3936              :                  If they refer to the same register, this move will be
    3937              :                  a no-op, except when function inlining is being
    3938              :                  done.  */
    3939      1577473 :               emit_move_insn (target, valreg);
    3940              : 
    3941              :               /* If we are setting a MEM, this code must be executed.
    3942              :                  Since it is emitted after the call insn, sibcall
    3943              :                  optimization cannot be performed in that case.  */
    3944      1577473 :               if (MEM_P (target))
    3945        47383 :                 sibcall_failure = true;
    3946              :             }
    3947              :         }
    3948              :       else
    3949       141808 :         target = copy_to_reg (avoid_likely_spilled_reg (valreg));
    3950              : 
    3951              :       /* If we promoted this return value, make the proper SUBREG.
    3952              :          TARGET might be const0_rtx here, so be careful.  */
    3953      5835541 :       if (REG_P (target)
    3954      1673115 :           && TYPE_MODE (rettype) != BLKmode
    3955      7508400 :           && GET_MODE (target) != TYPE_MODE (rettype))
    3956              :         {
    3957            1 :           tree type = rettype;
    3958            1 :           int unsignedp = TYPE_UNSIGNED (type);
    3959            1 :           machine_mode ret_mode = TYPE_MODE (type);
    3960            1 :           machine_mode pmode;
    3961              : 
    3962              :           /* Ensure we promote as expected, and get the new unsignedness.  */
    3963            1 :           pmode = promote_function_mode (type, ret_mode, &unsignedp,
    3964              :                                          funtype, 1);
    3965            1 :           gcc_assert (GET_MODE (target) == pmode);
    3966              : 
    3967            1 :           if (SCALAR_INT_MODE_P (pmode)
    3968            1 :               && SCALAR_FLOAT_MODE_P (ret_mode)
    3969            1 :               && known_gt (GET_MODE_SIZE (pmode), GET_MODE_SIZE (ret_mode)))
    3970            0 :             target = convert_wider_int_to_float (ret_mode, pmode, target);
    3971              :           else
    3972              :             {
    3973            1 :               target = gen_lowpart_SUBREG (ret_mode, target);
    3974            1 :               SUBREG_PROMOTED_VAR_P (target) = 1;
    3975            2 :               SUBREG_PROMOTED_SET (target, unsignedp);
    3976              :             }
    3977              :         }
    3978              : 
    3979              :       /* If size of args is variable or this was a constructor call for a stack
    3980              :          argument, restore saved stack-pointer value.  */
    3981              : 
    3982      5835541 :       if (old_stack_level)
    3983              :         {
    3984          158 :           rtx_insn *prev = get_last_insn ();
    3985              : 
    3986          158 :           emit_stack_restore (SAVE_BLOCK, old_stack_level);
    3987          158 :           stack_pointer_delta = old_stack_pointer_delta;
    3988              : 
    3989          158 :           fixup_args_size_notes (prev, get_last_insn (), stack_pointer_delta);
    3990              : 
    3991          158 :           pending_stack_adjust = old_pending_adj;
    3992          158 :           old_stack_allocated = stack_pointer_delta - pending_stack_adjust;
    3993          158 :           stack_arg_under_construction = old_stack_arg_under_construction;
    3994          158 :           highest_outgoing_arg_in_use = initial_highest_arg_in_use;
    3995          158 :           stack_usage_map = initial_stack_usage_map;
    3996          158 :           stack_usage_watermark = initial_stack_usage_watermark;
    3997          158 :           sibcall_failure = true;
    3998              :         }
    3999      5835383 :       else if (ACCUMULATE_OUTGOING_ARGS && pass)
    4000              :         {
    4001              : #ifdef REG_PARM_STACK_SPACE
    4002        73366 :           if (save_area)
    4003            0 :             restore_fixed_argument_area (save_area, argblock,
    4004              :                                          high_to_save, low_to_save);
    4005              : #endif
    4006              : 
    4007              :           /* If we saved any argument areas, restore them.  */
    4008       366526 :           for (i = 0; i < num_actuals; i++)
    4009       293160 :             if (args[i].save_area)
    4010              :               {
    4011            0 :                 machine_mode save_mode = GET_MODE (args[i].save_area);
    4012            0 :                 rtx stack_area
    4013            0 :                   = gen_rtx_MEM (save_mode,
    4014            0 :                                  memory_address (save_mode,
    4015              :                                                  XEXP (args[i].stack_slot, 0)));
    4016              : 
    4017            0 :                 if (save_mode != BLKmode)
    4018            0 :                   emit_move_insn (stack_area, args[i].save_area);
    4019              :                 else
    4020            0 :                   emit_block_move (stack_area, args[i].save_area,
    4021              :                                    (gen_int_mode
    4022            0 :                                     (args[i].locate.size.constant, Pmode)),
    4023              :                                    BLOCK_OP_CALL_PARM);
    4024              :               }
    4025              : 
    4026        73366 :           highest_outgoing_arg_in_use = initial_highest_arg_in_use;
    4027        73366 :           stack_usage_map = initial_stack_usage_map;
    4028        73366 :           stack_usage_watermark = initial_stack_usage_watermark;
    4029              :         }
    4030              : 
    4031              :       /* If this was alloca, record the new stack level.  */
    4032      5835541 :       if (flags & ECF_MAY_BE_ALLOCA)
    4033           29 :         record_new_stack_level ();
    4034              : 
    4035              :       /* Free up storage we no longer need.  */
    4036     17820951 :       for (i = 0; i < num_actuals; ++i)
    4037     11985410 :         free (args[i].aligned_regs);
    4038              : 
    4039      5835541 :       targetm.calls.end_call_args (args_so_far);
    4040              : 
    4041      5835541 :       insns = end_sequence ();
    4042              : 
    4043      5835541 :       if (pass == 0)
    4044              :         {
    4045       125706 :           tail_call_insns = insns;
    4046              : 
    4047              :           /* Restore the pending stack adjustment now that we have
    4048              :              finished generating the sibling call sequence.  */
    4049              : 
    4050       125706 :           restore_pending_stack_adjust (&save);
    4051              : 
    4052              :           /* Prepare arg structure for next iteration.  */
    4053       474839 :           for (i = 0; i < num_actuals; i++)
    4054              :             {
    4055       223427 :               args[i].value = 0;
    4056       223427 :               args[i].aligned_regs = 0;
    4057       223427 :               args[i].stack = 0;
    4058              :             }
    4059              : 
    4060       125706 :           sbitmap_free (stored_args_map);
    4061       125706 :           internal_arg_pointer_exp_state.scan_start = NULL;
    4062       125706 :           internal_arg_pointer_exp_state.cache.release ();
    4063              :         }
    4064              :       else
    4065              :         {
    4066      5709835 :           normal_call_insns = insns;
    4067              : 
    4068              :           /* Verify that we've deallocated all the stack we used.  */
    4069      5709835 :           gcc_assert ((flags & ECF_NORETURN)
    4070              :                       || normal_failure
    4071              :                       || known_eq (old_stack_allocated,
    4072              :                                    stack_pointer_delta
    4073              :                                    - pending_stack_adjust));
    4074      5709829 :           if (normal_failure)
    4075              :             normal_call_insns = NULL;
    4076              :         }
    4077              : 
    4078              :       /* If something prevents making this a sibling call,
    4079              :          zero out the sequence.  */
    4080      5835541 :       if (sibcall_failure)
    4081        47545 :         tail_call_insns = NULL;
    4082              :       else
    4083              :         break;
    4084              :     }
    4085              : 
    4086              :   /* If tail call production succeeded, we need to remove REG_EQUIV notes on
    4087              :      arguments too, as argument area is now clobbered by the call.  */
    4088      5835537 :   if (tail_call_insns)
    4089              :     {
    4090       125702 :       emit_insn (tail_call_insns);
    4091       125702 :       crtl->tail_call_emit = true;
    4092              :     }
    4093              :   else
    4094              :     {
    4095      5709835 :       emit_insn (normal_call_insns);
    4096      5709835 :       if (try_tail_call)
    4097              :         /* Ideally we'd emit a message for all of the ways that it could
    4098              :            have failed.  */
    4099            4 :         maybe_complain_about_tail_call (exp, _("tail call production failed"));
    4100              :     }
    4101              : 
    4102      5835537 :   currently_expanding_call--;
    4103              : 
    4104      5835537 :   free (stack_usage_map_buf);
    4105      5835537 :   free (args);
    4106      5835537 :   return target;
    4107              : }
    4108              : 
    4109              : /* A sibling call sequence invalidates any REG_EQUIV notes made for
    4110              :    this function's incoming arguments.
    4111              : 
    4112              :    At the start of RTL generation we know the only REG_EQUIV notes
    4113              :    in the rtl chain are those for incoming arguments, so we can look
    4114              :    for REG_EQUIV notes between the start of the function and the
    4115              :    NOTE_INSN_FUNCTION_BEG.
    4116              : 
    4117              :    This is (slight) overkill.  We could keep track of the highest
    4118              :    argument we clobber and be more selective in removing notes, but it
    4119              :    does not seem to be worth the effort.  */
    4120              : 
    4121              : void
    4122       120563 : fixup_tail_calls (void)
    4123              : {
    4124       120563 :   rtx_insn *insn;
    4125              : 
    4126       556105 :   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
    4127              :     {
    4128       556105 :       rtx note;
    4129              : 
    4130              :       /* There are never REG_EQUIV notes for the incoming arguments
    4131              :          after the NOTE_INSN_FUNCTION_BEG note, so stop if we see it.  */
    4132       556105 :       if (NOTE_P (insn)
    4133       362186 :           && NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG)
    4134              :         break;
    4135              : 
    4136       435542 :       note = find_reg_note (insn, REG_EQUIV, 0);
    4137       435542 :       if (note)
    4138        19500 :         remove_note (insn, note);
    4139       435542 :       note = find_reg_note (insn, REG_EQUIV, 0);
    4140       435542 :       gcc_assert (!note);
    4141              :     }
    4142       120563 : }
    4143              : 
    4144              : /* Traverse a list of TYPES and expand all complex types into their
    4145              :    components.  */
    4146              : static tree
    4147            0 : split_complex_types (tree types)
    4148              : {
    4149            0 :   tree p;
    4150              : 
    4151              :   /* Before allocating memory, check for the common case of no complex.  */
    4152            0 :   for (p = types; p; p = TREE_CHAIN (p))
    4153              :     {
    4154            0 :       tree type = TREE_VALUE (p);
    4155            0 :       if (TREE_CODE (type) == COMPLEX_TYPE
    4156            0 :           && targetm.calls.split_complex_arg (type))
    4157            0 :         goto found;
    4158              :     }
    4159              :   return types;
    4160              : 
    4161            0 :  found:
    4162            0 :   types = copy_list (types);
    4163              : 
    4164            0 :   for (p = types; p; p = TREE_CHAIN (p))
    4165              :     {
    4166            0 :       tree complex_type = TREE_VALUE (p);
    4167              : 
    4168            0 :       if (TREE_CODE (complex_type) == COMPLEX_TYPE
    4169            0 :           && targetm.calls.split_complex_arg (complex_type))
    4170              :         {
    4171            0 :           tree next, imag;
    4172              : 
    4173              :           /* Rewrite complex type with component type.  */
    4174            0 :           TREE_VALUE (p) = TREE_TYPE (complex_type);
    4175            0 :           next = TREE_CHAIN (p);
    4176              : 
    4177              :           /* Add another component type for the imaginary part.  */
    4178            0 :           imag = build_tree_list (NULL_TREE, TREE_VALUE (p));
    4179            0 :           TREE_CHAIN (p) = imag;
    4180            0 :           TREE_CHAIN (imag) = next;
    4181              : 
    4182              :           /* Skip the newly created node.  */
    4183            0 :           p = TREE_CHAIN (p);
    4184              :         }
    4185              :     }
    4186              : 
    4187              :   return types;
    4188              : }
    4189              : 
    4190              : /* Output a library call to function ORGFUN (a SYMBOL_REF rtx)
    4191              :    for a value of mode OUTMODE,
    4192              :    with NARGS different arguments, passed as ARGS.
    4193              :    Store the return value if RETVAL is nonzero: store it in VALUE if
    4194              :    VALUE is nonnull, otherwise pick a convenient location.  In either
    4195              :    case return the location of the stored value.
    4196              : 
    4197              :    FN_TYPE should be LCT_NORMAL for `normal' calls, LCT_CONST for
    4198              :    `const' calls, LCT_PURE for `pure' calls, or another LCT_ value for
    4199              :    other types of library calls.  */
    4200              : 
    4201              : rtx
    4202       117695 : emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
    4203              :                            enum libcall_type fn_type,
    4204              :                            machine_mode outmode, int nargs, rtx_mode_t *args)
    4205              : {
    4206              :   /* Total size in bytes of all the stack-parms scanned so far.  */
    4207       117695 :   struct args_size args_size;
    4208              :   /* Size of arguments before any adjustments (such as rounding).  */
    4209       117695 :   struct args_size original_args_size;
    4210       117695 :   int argnum;
    4211       117695 :   rtx fun;
    4212              :   /* Todo, choose the correct decl type of orgfun. Sadly this information
    4213              :      isn't present here, so we default to native calling abi here.  */
    4214       117695 :   tree fndecl ATTRIBUTE_UNUSED = NULL_TREE; /* library calls default to host calling abi ? */
    4215       117695 :   tree fntype ATTRIBUTE_UNUSED = NULL_TREE; /* library calls default to host calling abi ? */
    4216       117695 :   int count;
    4217       117695 :   rtx argblock = 0;
    4218       117695 :   CUMULATIVE_ARGS args_so_far_v;
    4219       117695 :   cumulative_args_t args_so_far;
    4220       117695 :   struct arg
    4221              :   {
    4222              :     rtx value;
    4223              :     machine_mode mode;
    4224              :     rtx reg;
    4225              :     int partial;
    4226              :     struct locate_and_pad_arg_data locate;
    4227              :     rtx save_area;
    4228              :   };
    4229       117695 :   struct arg *argvec;
    4230       117695 :   int old_inhibit_defer_pop = inhibit_defer_pop;
    4231       117695 :   rtx call_fusage = 0;
    4232       117695 :   rtx mem_value = 0;
    4233       117695 :   rtx valreg;
    4234       117695 :   bool pcc_struct_value = false;
    4235       117695 :   poly_int64 struct_value_size = 0;
    4236       117695 :   int flags;
    4237       117695 :   int reg_parm_stack_space = 0;
    4238       117695 :   poly_int64 needed;
    4239       117695 :   rtx_insn *before_call;
    4240       117695 :   bool have_push_fusage;
    4241       117695 :   tree tfom;                    /* type_for_mode (outmode, 0) */
    4242              : 
    4243              : #ifdef REG_PARM_STACK_SPACE
    4244              :   /* Define the boundary of the register parm stack space that needs to be
    4245              :      save, if any.  */
    4246       117695 :   int low_to_save = 0, high_to_save = 0;
    4247       117695 :   rtx save_area = 0;            /* Place that it is saved.  */
    4248              : #endif
    4249              : 
    4250              :   /* Size of the stack reserved for parameter registers.  */
    4251       117695 :   unsigned int initial_highest_arg_in_use = highest_outgoing_arg_in_use;
    4252       117695 :   char *initial_stack_usage_map = stack_usage_map;
    4253       117695 :   unsigned HOST_WIDE_INT initial_stack_usage_watermark = stack_usage_watermark;
    4254       117695 :   char *stack_usage_map_buf = NULL;
    4255              : 
    4256       117695 :   rtx struct_value = targetm.calls.struct_value_rtx (0, 0);
    4257              : 
    4258              : #ifdef REG_PARM_STACK_SPACE
    4259       117695 :   reg_parm_stack_space = REG_PARM_STACK_SPACE ((tree) 0);
    4260              : #endif
    4261              : 
    4262              :   /* By default, library functions cannot throw.  */
    4263       117695 :   flags = ECF_NOTHROW;
    4264              : 
    4265       117695 :   switch (fn_type)
    4266              :     {
    4267              :     case LCT_NORMAL:
    4268              :       break;
    4269              :     case LCT_CONST:
    4270              :       flags |= ECF_CONST;
    4271              :       break;
    4272              :     case LCT_PURE:
    4273              :       flags |= ECF_PURE;
    4274              :       break;
    4275              :     case LCT_NORETURN:
    4276              :       flags |= ECF_NORETURN;
    4277              :       break;
    4278              :     case LCT_THROW:
    4279              :       flags &= ~ECF_NOTHROW;
    4280              :       break;
    4281              :     case LCT_RETURNS_TWICE:
    4282              :       flags = ECF_RETURNS_TWICE;
    4283              :       break;
    4284              :     }
    4285       117695 :   fun = orgfun;
    4286              : 
    4287              :   /* Ensure current function's preferred stack boundary is at least
    4288              :      what we need.  */
    4289       117695 :   if (crtl->preferred_stack_boundary < PREFERRED_STACK_BOUNDARY)
    4290        12590 :     crtl->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
    4291              : 
    4292              :   /* If this kind of value comes back in memory,
    4293              :      decide where in memory it should come back.  */
    4294       117695 :   if (outmode != VOIDmode)
    4295              :     {
    4296       115545 :       tfom = lang_hooks.types.type_for_mode (outmode, 0);
    4297       115545 :       if (aggregate_value_p (tfom, 0))
    4298              :         {
    4299              : #ifdef PCC_STATIC_STRUCT_RETURN
    4300              :           rtx pointer_reg
    4301              :             = hard_function_value (build_pointer_type (tfom), 0, 0, 0);
    4302              :           mem_value = gen_rtx_MEM (outmode, pointer_reg);
    4303              :           pcc_struct_value = true;
    4304              :           if (value == 0)
    4305              :             value = gen_reg_rtx (outmode);
    4306              : #else /* not PCC_STATIC_STRUCT_RETURN */
    4307        20166 :           struct_value_size = GET_MODE_SIZE (outmode);
    4308        10083 :           if (value != 0 && MEM_P (value))
    4309              :             mem_value = value;
    4310              :           else
    4311        10083 :             mem_value = assign_temp (tfom, 1, 1);
    4312              : #endif
    4313              :           /* This call returns a big structure.  */
    4314        10083 :           flags &= ~(ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE);
    4315              :         }
    4316              :     }
    4317              :   else
    4318         2150 :     tfom = void_type_node;
    4319              : 
    4320              :   /* ??? Unfinished: must pass the memory address as an argument.  */
    4321              : 
    4322              :   /* Copy all the libcall-arguments out of the varargs data
    4323              :      and into a vector ARGVEC.
    4324              : 
    4325              :      Compute how to pass each argument.  We only support a very small subset
    4326              :      of the full argument passing conventions to limit complexity here since
    4327              :      library functions shouldn't have many args.  */
    4328              : 
    4329       117695 :   argvec = XALLOCAVEC (struct arg, nargs + 1);
    4330       117695 :   memset (argvec, 0, (nargs + 1) * sizeof (struct arg));
    4331              : 
    4332              : #ifdef INIT_CUMULATIVE_LIBCALL_ARGS
    4333              :   INIT_CUMULATIVE_LIBCALL_ARGS (args_so_far_v, outmode, fun);
    4334              : #else
    4335       117695 :   INIT_CUMULATIVE_ARGS (args_so_far_v, NULL_TREE, fun, 0, nargs);
    4336              : #endif
    4337       117695 :   args_so_far = pack_cumulative_args (&args_so_far_v);
    4338              : 
    4339       117695 :   args_size.constant = 0;
    4340       117695 :   args_size.var = 0;
    4341              : 
    4342       117695 :   count = 0;
    4343              : 
    4344       117695 :   push_temp_slots ();
    4345              : 
    4346              :   /* If there's a structure value address to be passed,
    4347              :      either pass it in the special place, or pass it as an extra argument.  */
    4348       117695 :   if (mem_value && struct_value == 0 && ! pcc_struct_value)
    4349              :     {
    4350        10083 :       rtx addr = XEXP (mem_value, 0);
    4351              : 
    4352        10083 :       nargs++;
    4353              : 
    4354              :       /* Make sure it is a reasonable operand for a move or push insn.  */
    4355        10083 :       if (!REG_P (addr) && !MEM_P (addr)
    4356        20166 :           && !(CONSTANT_P (addr)
    4357            0 :                && targetm.legitimate_constant_p (Pmode, addr)))
    4358        10083 :         addr = force_operand (addr, NULL_RTX);
    4359              : 
    4360        10083 :       argvec[count].value = addr;
    4361        10083 :       argvec[count].mode = Pmode;
    4362        10083 :       argvec[count].partial = 0;
    4363              : 
    4364        10083 :       function_arg_info ptr_arg (Pmode, /*named=*/true);
    4365        10083 :       argvec[count].reg = targetm.calls.function_arg (args_so_far, ptr_arg);
    4366        10083 :       gcc_assert (targetm.calls.arg_partial_bytes (args_so_far, ptr_arg) == 0);
    4367              : 
    4368        10083 :       locate_and_pad_parm (Pmode, NULL_TREE,
    4369              : #ifdef STACK_PARMS_IN_REG_PARM_AREA
    4370              :                            1,
    4371              : #else
    4372        10083 :                            argvec[count].reg != 0,
    4373              : #endif
    4374              :                            reg_parm_stack_space, 0,
    4375              :                            NULL_TREE, &args_size, &argvec[count].locate);
    4376              : 
    4377        10083 :       if (argvec[count].reg == 0 || argvec[count].partial != 0
    4378            0 :           || reg_parm_stack_space > 0)
    4379        10083 :         args_size.constant += argvec[count].locate.size.constant;
    4380              : 
    4381        10083 :       targetm.calls.function_arg_advance (args_so_far, ptr_arg);
    4382              : 
    4383        10083 :       count++;
    4384              :     }
    4385              : 
    4386       322990 :   for (unsigned int i = 0; count < nargs; i++, count++)
    4387              :     {
    4388       205295 :       rtx val = args[i].first;
    4389       205295 :       function_arg_info arg (args[i].second, /*named=*/true);
    4390       205295 :       int unsigned_p = 0;
    4391              : 
    4392              :       /* We cannot convert the arg value to the mode the library wants here;
    4393              :          must do it earlier where we know the signedness of the arg.  */
    4394       205295 :       gcc_assert (arg.mode != BLKmode
    4395              :                   && (GET_MODE (val) == arg.mode
    4396              :                       || GET_MODE (val) == VOIDmode));
    4397              : 
    4398              :       /* Make sure it is a reasonable operand for a move or push insn.  */
    4399        44702 :       if (!REG_P (val) && !MEM_P (val)
    4400       280250 :           && !(CONSTANT_P (val)
    4401        36910 :                && targetm.legitimate_constant_p (arg.mode, val)))
    4402         1139 :         val = force_operand (val, NULL_RTX);
    4403              : 
    4404       205295 :       if (pass_by_reference (&args_so_far_v, arg))
    4405              :         {
    4406            0 :           rtx slot;
    4407            0 :           int must_copy = !reference_callee_copied (&args_so_far_v, arg);
    4408              : 
    4409              :           /* If this was a CONST function, it is now PURE since it now
    4410              :              reads memory.  */
    4411            0 :           if (flags & ECF_CONST)
    4412              :             {
    4413            0 :               flags &= ~ECF_CONST;
    4414            0 :               flags |= ECF_PURE;
    4415              :             }
    4416              : 
    4417            0 :           if (MEM_P (val) && !must_copy)
    4418              :             {
    4419            0 :               tree val_expr = MEM_EXPR (val);
    4420            0 :               if (val_expr)
    4421            0 :                 mark_addressable (val_expr);
    4422              :               slot = val;
    4423              :             }
    4424              :           else
    4425              :             {
    4426            0 :               slot = assign_temp (lang_hooks.types.type_for_mode (arg.mode, 0),
    4427              :                                   1, 1);
    4428            0 :               emit_move_insn (slot, val);
    4429              :             }
    4430              : 
    4431            0 :           call_fusage = gen_rtx_EXPR_LIST (VOIDmode,
    4432              :                                            gen_rtx_USE (VOIDmode, slot),
    4433              :                                            call_fusage);
    4434            0 :           if (must_copy)
    4435            0 :             call_fusage = gen_rtx_EXPR_LIST (VOIDmode,
    4436              :                                              gen_rtx_CLOBBER (VOIDmode,
    4437              :                                                               slot),
    4438              :                                              call_fusage);
    4439              : 
    4440            0 :           arg.mode = Pmode;
    4441            0 :           arg.pass_by_reference = true;
    4442            0 :           val = force_operand (XEXP (slot, 0), NULL_RTX);
    4443              :         }
    4444              : 
    4445       205295 :       arg.mode = promote_function_mode (NULL_TREE, arg.mode, &unsigned_p,
    4446              :                                         NULL_TREE, 0);
    4447       205295 :       argvec[count].mode = arg.mode;
    4448       205295 :       argvec[count].value = convert_modes (arg.mode, GET_MODE (val), val,
    4449              :                                            unsigned_p);
    4450       205295 :       argvec[count].reg = targetm.calls.function_arg (args_so_far, arg);
    4451              : 
    4452       205295 :       argvec[count].partial
    4453       205295 :         = targetm.calls.arg_partial_bytes (args_so_far, arg);
    4454              : 
    4455       205295 :       if (argvec[count].reg == 0
    4456       177467 :           || argvec[count].partial != 0
    4457       177467 :           || reg_parm_stack_space > 0)
    4458              :         {
    4459        27828 :           locate_and_pad_parm (arg.mode, NULL_TREE,
    4460              : #ifdef STACK_PARMS_IN_REG_PARM_AREA
    4461              :                                1,
    4462              : #else
    4463              :                                argvec[count].reg != 0,
    4464              : #endif
    4465              :                                reg_parm_stack_space, argvec[count].partial,
    4466              :                                NULL_TREE, &args_size, &argvec[count].locate);
    4467        27828 :           args_size.constant += argvec[count].locate.size.constant;
    4468        27828 :           gcc_assert (!argvec[count].locate.size.var);
    4469              :         }
    4470              : #ifdef BLOCK_REG_PADDING
    4471              :       else
    4472              :         /* The argument is passed entirely in registers.  See at which
    4473              :            end it should be padded.  */
    4474              :         argvec[count].locate.where_pad =
    4475              :           BLOCK_REG_PADDING (arg.mode, NULL_TREE,
    4476              :                              known_le (GET_MODE_SIZE (arg.mode),
    4477              :                                        UNITS_PER_WORD));
    4478              : #endif
    4479              : 
    4480       205295 :       targetm.calls.function_arg_advance (args_so_far, arg);
    4481              :     }
    4482              : 
    4483       333073 :   for (int i = 0; i < nargs; i++)
    4484       215378 :     if (reg_parm_stack_space > 0
    4485       215378 :         || argvec[i].reg == 0
    4486       177467 :         || argvec[i].partial != 0)
    4487        37911 :       update_stack_alignment_for_call (&argvec[i].locate);
    4488              : 
    4489              :   /* If this machine requires an external definition for library
    4490              :      functions, write one out.  */
    4491       117695 :   assemble_external_libcall (fun);
    4492              : 
    4493       117695 :   original_args_size = args_size;
    4494       117695 :   args_size.constant = (aligned_upper_bound (args_size.constant
    4495       117695 :                                              + stack_pointer_delta,
    4496              :                                              STACK_BYTES)
    4497       117695 :                         - stack_pointer_delta);
    4498              : 
    4499       117695 :   args_size.constant = upper_bound (args_size.constant,
    4500              :                                     reg_parm_stack_space);
    4501              : 
    4502       117695 :   if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl))))
    4503       117695 :     args_size.constant -= reg_parm_stack_space;
    4504              : 
    4505       117695 :   crtl->outgoing_args_size = upper_bound (crtl->outgoing_args_size,
    4506              :                                           args_size.constant);
    4507              : 
    4508       117695 :   if (flag_stack_usage_info && !ACCUMULATE_OUTGOING_ARGS)
    4509              :     {
    4510            0 :       poly_int64 pushed = args_size.constant + pending_stack_adjust;
    4511            0 :       current_function_pushed_stack_size
    4512            0 :         = upper_bound (current_function_pushed_stack_size, pushed);
    4513              :     }
    4514              : 
    4515       117695 :   if (ACCUMULATE_OUTGOING_ARGS)
    4516              :     {
    4517              :       /* Since the stack pointer will never be pushed, it is possible for
    4518              :          the evaluation of a parm to clobber something we have already
    4519              :          written to the stack.  Since most function calls on RISC machines
    4520              :          do not use the stack, this is uncommon, but must work correctly.
    4521              : 
    4522              :          Therefore, we save any area of the stack that was already written
    4523              :          and that we are using.  Here we set up to do this by making a new
    4524              :          stack usage map from the old one.
    4525              : 
    4526              :          Another approach might be to try to reorder the argument
    4527              :          evaluations to avoid this conflicting stack usage.  */
    4528              : 
    4529           12 :       needed = args_size.constant;
    4530              : 
    4531              :       /* Since we will be writing into the entire argument area, the
    4532              :          map must be allocated for its entire size, not just the part that
    4533              :          is the responsibility of the caller.  */
    4534           12 :       if (! OUTGOING_REG_PARM_STACK_SPACE ((!fndecl ? fntype : TREE_TYPE (fndecl))))
    4535           12 :         needed += reg_parm_stack_space;
    4536              : 
    4537           12 :       poly_int64 limit = needed;
    4538           12 :       if (ARGS_GROW_DOWNWARD)
    4539              :         limit += 1;
    4540              : 
    4541              :       /* For polynomial sizes, this is the maximum possible size needed
    4542              :          for arguments with a constant size and offset.  */
    4543           12 :       HOST_WIDE_INT const_limit = constant_lower_bound (limit);
    4544           12 :       highest_outgoing_arg_in_use = MAX (initial_highest_arg_in_use,
    4545              :                                          const_limit);
    4546              : 
    4547           12 :       stack_usage_map_buf = XNEWVEC (char, highest_outgoing_arg_in_use);
    4548           12 :       stack_usage_map = stack_usage_map_buf;
    4549              : 
    4550           12 :       if (initial_highest_arg_in_use)
    4551            0 :         memcpy (stack_usage_map, initial_stack_usage_map,
    4552              :                 initial_highest_arg_in_use);
    4553              : 
    4554           12 :       if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
    4555            0 :         memset (&stack_usage_map[initial_highest_arg_in_use], 0,
    4556            0 :                highest_outgoing_arg_in_use - initial_highest_arg_in_use);
    4557           12 :       needed = 0;
    4558              : 
    4559              :       /* We must be careful to use virtual regs before they're instantiated,
    4560              :          and real regs afterwards.  Loop optimization, for example, can create
    4561              :          new libcalls after we've instantiated the virtual regs, and if we
    4562              :          use virtuals anyway, they won't match the rtl patterns.  */
    4563              : 
    4564           12 :       if (virtuals_instantiated)
    4565            0 :         argblock = plus_constant (Pmode, stack_pointer_rtx,
    4566              :                                   STACK_POINTER_OFFSET);
    4567              :       else
    4568           12 :         argblock = virtual_outgoing_args_rtx;
    4569              :     }
    4570              :   else
    4571              :     {
    4572       117683 :       if (!targetm.calls.push_argument (0))
    4573            0 :         argblock = push_block (gen_int_mode (args_size.constant, Pmode), 0, 0);
    4574              :     }
    4575              : 
    4576              :   /* We push args individually in reverse order, perform stack alignment
    4577              :      before the first push (the last arg).  */
    4578           12 :   if (argblock == 0)
    4579       117683 :     anti_adjust_stack (gen_int_mode (args_size.constant
    4580              :                                      - original_args_size.constant,
    4581       117683 :                                      Pmode));
    4582              : 
    4583       117695 :   argnum = nargs - 1;
    4584              : 
    4585              : #ifdef REG_PARM_STACK_SPACE
    4586       117695 :   if (ACCUMULATE_OUTGOING_ARGS)
    4587              :     {
    4588              :       /* The argument list is the property of the called routine and it
    4589              :          may clobber it.  If the fixed area has been used for previous
    4590              :          parameters, we must save and restore it.  */
    4591           12 :       save_area = save_fixed_argument_area (reg_parm_stack_space, argblock,
    4592              :                                             &low_to_save, &high_to_save);
    4593              :     }
    4594              : #endif
    4595              : 
    4596       117695 :   rtx call_cookie
    4597       117695 :     = targetm.calls.function_arg (args_so_far,
    4598       117695 :                                   function_arg_info::end_marker ());
    4599              : 
    4600              :   /* Push the args that need to be pushed.  */
    4601              : 
    4602       117695 :   have_push_fusage = false;
    4603              : 
    4604              :   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
    4605              :      are to be pushed.  */
    4606       333073 :   for (count = 0; count < nargs; count++, argnum--)
    4607              :     {
    4608       215378 :       machine_mode mode = argvec[argnum].mode;
    4609       215378 :       rtx val = argvec[argnum].value;
    4610       215378 :       rtx reg = argvec[argnum].reg;
    4611       215378 :       int partial = argvec[argnum].partial;
    4612       215378 :       unsigned int parm_align = argvec[argnum].locate.boundary;
    4613       215378 :       poly_int64 lower_bound = 0, upper_bound = 0;
    4614              : 
    4615       215378 :       if (! (reg != 0 && partial == 0))
    4616              :         {
    4617        37911 :           rtx use;
    4618              : 
    4619        37911 :           if (ACCUMULATE_OUTGOING_ARGS)
    4620              :             {
    4621              :               /* If this is being stored into a pre-allocated, fixed-size,
    4622              :                  stack area, save any previous data at that location.  */
    4623              : 
    4624            0 :               if (ARGS_GROW_DOWNWARD)
    4625              :                 {
    4626              :                   /* stack_slot is negative, but we want to index stack_usage_map
    4627              :                      with positive values.  */
    4628              :                   upper_bound = -argvec[argnum].locate.slot_offset.constant + 1;
    4629              :                   lower_bound = upper_bound - argvec[argnum].locate.size.constant;
    4630              :                 }
    4631              :               else
    4632              :                 {
    4633            0 :                   lower_bound = argvec[argnum].locate.slot_offset.constant;
    4634            0 :                   upper_bound = lower_bound + argvec[argnum].locate.size.constant;
    4635              :                 }
    4636              : 
    4637            0 :               if (stack_region_maybe_used_p (lower_bound, upper_bound,
    4638              :                                              reg_parm_stack_space))
    4639              :                 {
    4640              :                   /* We need to make a save area.  */
    4641            0 :                   poly_uint64 size
    4642            0 :                     = argvec[argnum].locate.size.constant * BITS_PER_UNIT;
    4643            0 :                   machine_mode save_mode
    4644            0 :                     = int_mode_for_size (size, 1).else_blk ();
    4645            0 :                   rtx adr
    4646            0 :                     = plus_constant (Pmode, argblock,
    4647              :                                      argvec[argnum].locate.offset.constant);
    4648            0 :                   rtx stack_area
    4649            0 :                     = gen_rtx_MEM (save_mode, memory_address (save_mode, adr));
    4650              : 
    4651            0 :                   if (save_mode == BLKmode)
    4652              :                     {
    4653            0 :                       argvec[argnum].save_area
    4654            0 :                         = assign_stack_temp (BLKmode,
    4655              :                                              argvec[argnum].locate.size.constant
    4656              :                                              );
    4657              : 
    4658            0 :                       emit_block_move (validize_mem
    4659              :                                          (copy_rtx (argvec[argnum].save_area)),
    4660              :                                        stack_area,
    4661              :                                        (gen_int_mode
    4662              :                                         (argvec[argnum].locate.size.constant,
    4663            0 :                                          Pmode)),
    4664              :                                        BLOCK_OP_CALL_PARM);
    4665              :                     }
    4666              :                   else
    4667              :                     {
    4668            0 :                       argvec[argnum].save_area = gen_reg_rtx (save_mode);
    4669              : 
    4670            0 :                       emit_move_insn (argvec[argnum].save_area, stack_area);
    4671              :                     }
    4672              :                 }
    4673              :             }
    4674              : 
    4675        37911 :           emit_push_insn (val, mode, lang_hooks.types.type_for_mode (mode, 0),
    4676              :                           NULL_RTX, parm_align, partial, reg, 0, argblock,
    4677              :                           (gen_int_mode
    4678        37911 :                            (argvec[argnum].locate.offset.constant, Pmode)),
    4679              :                           reg_parm_stack_space,
    4680        73948 :                           ARGS_SIZE_RTX (argvec[argnum].locate.alignment_pad), false);
    4681              : 
    4682              :           /* Now mark the segment we just used.  */
    4683        37911 :           if (ACCUMULATE_OUTGOING_ARGS)
    4684            0 :             mark_stack_region_used (lower_bound, upper_bound);
    4685              : 
    4686        37911 :           NO_DEFER_POP;
    4687              : 
    4688              :           /* Indicate argument access so that alias.cc knows that these
    4689              :              values are live.  */
    4690        37911 :           if (argblock)
    4691            0 :             use = plus_constant (Pmode, argblock,
    4692              :                                  argvec[argnum].locate.offset.constant);
    4693        37911 :           else if (have_push_fusage)
    4694        23017 :             continue;
    4695              :           else
    4696              :             {
    4697              :               /* When arguments are pushed, trying to tell alias.cc where
    4698              :                  exactly this argument is won't work, because the
    4699              :                  auto-increment causes confusion.  So we merely indicate
    4700              :                  that we access something with a known mode somewhere on
    4701              :                  the stack.  */
    4702        41266 :               use = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
    4703              :                                   gen_rtx_SCRATCH (Pmode));
    4704        14894 :               have_push_fusage = true;
    4705              :             }
    4706        14894 :           use = gen_rtx_MEM (argvec[argnum].mode, use);
    4707        14894 :           use = gen_rtx_USE (VOIDmode, use);
    4708        14894 :           call_fusage = gen_rtx_EXPR_LIST (VOIDmode, use, call_fusage);
    4709              :         }
    4710              :     }
    4711              : 
    4712       117695 :   argnum = nargs - 1;
    4713              : 
    4714       117695 :   fun = prepare_call_address (NULL, fun, NULL, &call_fusage, 0, 0);
    4715              : 
    4716       117695 :   targetm.calls.start_call_args (args_so_far);
    4717              : 
    4718              :   /* When expanding a normal call, args are stored in push order,
    4719              :      which is the reverse of what we have here.  */
    4720       117695 :   bool any_regs = false;
    4721       333073 :   for (int i = nargs; i-- > 0; )
    4722       215378 :     if (argvec[i].reg != NULL_RTX)
    4723              :       {
    4724       177467 :         targetm.calls.call_args (args_so_far, argvec[i].reg, NULL_TREE);
    4725       177467 :         any_regs = true;
    4726              :       }
    4727       117695 :   if (!any_regs)
    4728        14721 :     targetm.calls.call_args (args_so_far, pc_rtx, NULL_TREE);
    4729              : 
    4730              :   /* Now load any reg parms into their regs.  */
    4731              : 
    4732              :   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
    4733              :      are to be pushed.  */
    4734       333073 :   for (count = 0; count < nargs; count++, argnum--)
    4735              :     {
    4736       215378 :       machine_mode mode = argvec[argnum].mode;
    4737       215378 :       rtx val = argvec[argnum].value;
    4738       215378 :       rtx reg = argvec[argnum].reg;
    4739       215378 :       int partial = argvec[argnum].partial;
    4740              : 
    4741              :       /* Handle calls that pass values in multiple non-contiguous
    4742              :          locations.  The PA64 has examples of this for library calls.  */
    4743       215378 :       if (reg != 0 && GET_CODE (reg) == PARALLEL)
    4744        13508 :         emit_group_load (reg, val, NULL_TREE, GET_MODE_SIZE (mode));
    4745       208624 :       else if (reg != 0 && partial == 0)
    4746              :         {
    4747       170713 :           emit_move_insn (reg, val);
    4748              : #ifdef BLOCK_REG_PADDING
    4749              :           poly_int64 size = GET_MODE_SIZE (argvec[argnum].mode);
    4750              : 
    4751              :           /* Copied from load_register_parameters.  */
    4752              : 
    4753              :           /* Handle case where we have a value that needs shifting
    4754              :              up to the msb.  eg. a QImode value and we're padding
    4755              :              upward on a BYTES_BIG_ENDIAN machine.  */
    4756              :           if (known_lt (size, UNITS_PER_WORD)
    4757              :               && (argvec[argnum].locate.where_pad
    4758              :                   == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)))
    4759              :             {
    4760              :               rtx x;
    4761              :               poly_int64 shift = (UNITS_PER_WORD - size) * BITS_PER_UNIT;
    4762              : 
    4763              :               /* Assigning REG here rather than a temp makes CALL_FUSAGE
    4764              :                  report the whole reg as used.  Strictly speaking, the
    4765              :                  call only uses SIZE bytes at the msb end, but it doesn't
    4766              :                  seem worth generating rtl to say that.  */
    4767              :               reg = gen_rtx_REG (word_mode, REGNO (reg));
    4768              :               x = expand_shift (LSHIFT_EXPR, word_mode, reg, shift, reg, 1);
    4769              :               if (x != reg)
    4770              :                 emit_move_insn (reg, x);
    4771              :             }
    4772              : #endif
    4773              :         }
    4774              : 
    4775       215378 :       NO_DEFER_POP;
    4776              :     }
    4777              : 
    4778              :   /* Any regs containing parms remain in use through the call.  */
    4779       333073 :   for (count = 0; count < nargs; count++)
    4780              :     {
    4781       215378 :       rtx reg = argvec[count].reg;
    4782       215378 :       if (reg != 0 && GET_CODE (reg) == PARALLEL)
    4783         6754 :         use_group_regs (&call_fusage, reg);
    4784       170713 :       else if (reg != 0)
    4785              :         {
    4786       170713 :           int partial = argvec[count].partial;
    4787       170713 :           if (partial)
    4788              :             {
    4789            0 :               int nregs;
    4790            0 :               gcc_assert (partial % UNITS_PER_WORD == 0);
    4791            0 :               nregs = partial / UNITS_PER_WORD;
    4792            0 :               use_regs (&call_fusage, REGNO (reg), nregs);
    4793              :             }
    4794              :           else
    4795       170713 :             use_reg (&call_fusage, reg);
    4796              :         }
    4797              :     }
    4798              : 
    4799              :   /* Pass the function the address in which to return a structure value.  */
    4800       117695 :   if (mem_value != 0 && struct_value != 0 && ! pcc_struct_value)
    4801              :     {
    4802            0 :       emit_move_insn (struct_value,
    4803            0 :                       force_reg (Pmode,
    4804              :                                  force_operand (XEXP (mem_value, 0),
    4805              :                                                 NULL_RTX)));
    4806            0 :       if (REG_P (struct_value))
    4807            0 :         use_reg (&call_fusage, struct_value);
    4808              :     }
    4809              : 
    4810              :   /* Don't allow popping to be deferred, since then
    4811              :      cse'ing of library calls could delete a call and leave the pop.  */
    4812       117695 :   NO_DEFER_POP;
    4813       213074 :   valreg = (mem_value == 0 && outmode != VOIDmode
    4814       223157 :             ? hard_libcall_value (outmode, orgfun) : NULL_RTX);
    4815              : 
    4816              :   /* Stack must be properly aligned now.  */
    4817       235390 :   gcc_assert (multiple_p (stack_pointer_delta,
    4818              :                           PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT));
    4819              : 
    4820       117695 :   before_call = get_last_insn ();
    4821              : 
    4822       117695 :   if (flag_callgraph_info)
    4823            0 :     record_final_call (SYMBOL_REF_DECL (orgfun), UNKNOWN_LOCATION);
    4824              : 
    4825              :   /* We pass the old value of inhibit_defer_pop + 1 to emit_call_1, which
    4826              :      will set inhibit_defer_pop to that value.  */
    4827              :   /* The return type is needed to decide how many bytes the function pops.
    4828              :      Signedness plays no role in that, so for simplicity, we pretend it's
    4829              :      always signed.  We also assume that the list of arguments passed has
    4830              :      no impact, so we pretend it is unknown.  */
    4831              : 
    4832       117695 :   emit_call_1 (fun, NULL,
    4833              :                get_identifier (XSTR (orgfun, 0)),
    4834              :                build_function_type (tfom, NULL_TREE),
    4835              :                original_args_size.constant, args_size.constant,
    4836              :                struct_value_size, call_cookie, valreg,
    4837              :                old_inhibit_defer_pop + 1, call_fusage, flags, args_so_far);
    4838              : 
    4839       117695 :   rtx datum = orgfun;
    4840       117695 :   gcc_assert (GET_CODE (datum) == SYMBOL_REF);
    4841       117695 :   rtx_call_insn *last = last_call_insn ();
    4842       117695 :   add_reg_note (last, REG_CALL_DECL, datum);
    4843              : 
    4844              :   /* Right-shift returned value if necessary.  */
    4845       117695 :   if (!pcc_struct_value
    4846       117695 :       && TYPE_MODE (tfom) != BLKmode
    4847       117695 :       && targetm.calls.return_in_msb (tfom))
    4848              :     {
    4849            0 :       shift_return_value (TYPE_MODE (tfom), false, valreg);
    4850            0 :       valreg = gen_rtx_REG (TYPE_MODE (tfom), REGNO (valreg));
    4851              :     }
    4852              : 
    4853       117695 :   targetm.calls.end_call_args (args_so_far);
    4854              : 
    4855              :   /* For calls to `setjmp', etc., inform function.cc:setjmp_warnings
    4856              :      that it should complain if nonvolatile values are live.  For
    4857              :      functions that cannot return, inform flow that control does not
    4858              :      fall through.  */
    4859       117695 :   if (flags & ECF_NORETURN)
    4860              :     {
    4861              :       /* The barrier note must be emitted
    4862              :          immediately after the CALL_INSN.  Some ports emit more than
    4863              :          just a CALL_INSN above, so we must search for it here.  */
    4864            0 :       rtx_insn *last = get_last_insn ();
    4865            0 :       while (!CALL_P (last))
    4866              :         {
    4867            0 :           last = PREV_INSN (last);
    4868              :           /* There was no CALL_INSN?  */
    4869            0 :           gcc_assert (last != before_call);
    4870              :         }
    4871              : 
    4872            0 :       emit_barrier_after (last);
    4873              :     }
    4874              : 
    4875              :   /* Consider that "regular" libcalls, i.e. all of them except for LCT_THROW
    4876              :      and LCT_RETURNS_TWICE, cannot perform non-local gotos.  */
    4877       117695 :   if (flags & ECF_NOTHROW)
    4878              :     {
    4879       117695 :       rtx_insn *last = get_last_insn ();
    4880       132590 :       while (!CALL_P (last))
    4881              :         {
    4882        14895 :           last = PREV_INSN (last);
    4883              :           /* There was no CALL_INSN?  */
    4884        14895 :           gcc_assert (last != before_call);
    4885              :         }
    4886              : 
    4887       117695 :       make_reg_eh_region_note_nothrow_nononlocal (last);
    4888              :     }
    4889              : 
    4890              :   /* Now restore inhibit_defer_pop to its actual original value.  */
    4891       117695 :   OK_DEFER_POP;
    4892              : 
    4893       117695 :   pop_temp_slots ();
    4894              : 
    4895              :   /* Copy the value to the right place.  */
    4896       117695 :   if (outmode != VOIDmode && retval)
    4897              :     {
    4898       115259 :       if (mem_value)
    4899              :         {
    4900        10083 :           if (value == 0)
    4901        10083 :             value = mem_value;
    4902        10083 :           if (value != mem_value)
    4903            0 :             emit_move_insn (value, mem_value);
    4904              :         }
    4905       105176 :       else if (GET_CODE (valreg) == PARALLEL)
    4906              :         {
    4907            0 :           if (value == 0)
    4908            0 :             value = gen_reg_rtx (outmode);
    4909            0 :           emit_group_store (value, valreg, NULL_TREE, GET_MODE_SIZE (outmode));
    4910              :         }
    4911              :       else
    4912              :         {
    4913              :           /* Convert to the proper mode if a promotion has been active.  */
    4914       105176 :           if (GET_MODE (valreg) != outmode)
    4915              :             {
    4916            0 :               int unsignedp = TYPE_UNSIGNED (tfom);
    4917              : 
    4918            0 :               gcc_assert (promote_function_mode (tfom, outmode, &unsignedp,
    4919              :                                                  fndecl ? TREE_TYPE (fndecl) : fntype, 1)
    4920              :                           == GET_MODE (valreg));
    4921            0 :               valreg = convert_modes (outmode, GET_MODE (valreg), valreg, 0);
    4922              :             }
    4923              : 
    4924       105176 :           if (value != 0)
    4925          442 :             emit_move_insn (value, valreg);
    4926              :           else
    4927              :             value = valreg;
    4928              :         }
    4929              :     }
    4930              : 
    4931       117695 :   if (ACCUMULATE_OUTGOING_ARGS)
    4932              :     {
    4933              : #ifdef REG_PARM_STACK_SPACE
    4934           12 :       if (save_area)
    4935            0 :         restore_fixed_argument_area (save_area, argblock,
    4936              :                                      high_to_save, low_to_save);
    4937              : #endif
    4938              : 
    4939              :       /* If we saved any argument areas, restore them.  */
    4940           24 :       for (count = 0; count < nargs; count++)
    4941           12 :         if (argvec[count].save_area)
    4942              :           {
    4943            0 :             machine_mode save_mode = GET_MODE (argvec[count].save_area);
    4944            0 :             rtx adr = plus_constant (Pmode, argblock,
    4945              :                                      argvec[count].locate.offset.constant);
    4946            0 :             rtx stack_area = gen_rtx_MEM (save_mode,
    4947              :                                           memory_address (save_mode, adr));
    4948              : 
    4949            0 :             if (save_mode == BLKmode)
    4950            0 :               emit_block_move (stack_area,
    4951              :                                validize_mem
    4952              :                                  (copy_rtx (argvec[count].save_area)),
    4953              :                                (gen_int_mode
    4954            0 :                                 (argvec[count].locate.size.constant, Pmode)),
    4955              :                                BLOCK_OP_CALL_PARM);
    4956              :             else
    4957            0 :               emit_move_insn (stack_area, argvec[count].save_area);
    4958              :           }
    4959              : 
    4960           12 :       highest_outgoing_arg_in_use = initial_highest_arg_in_use;
    4961           12 :       stack_usage_map = initial_stack_usage_map;
    4962           12 :       stack_usage_watermark = initial_stack_usage_watermark;
    4963              :     }
    4964              : 
    4965       117695 :   free (stack_usage_map_buf);
    4966              : 
    4967       117695 :   return value;
    4968              : 
    4969              : }
    4970              : 
    4971              : 
    4972              : /* Store a single argument for a function call
    4973              :    into the register or memory area where it must be passed.
    4974              :    *ARG describes the argument value and where to pass it.
    4975              : 
    4976              :    ARGBLOCK is the address of the stack-block for all the arguments,
    4977              :    or 0 on a machine where arguments are pushed individually.
    4978              : 
    4979              :    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
    4980              :    so must be careful about how the stack is used.
    4981              : 
    4982              :    VARIABLE_SIZE nonzero says that this was a variable-sized outgoing
    4983              :    argument stack.  This is used if ACCUMULATE_OUTGOING_ARGS to indicate
    4984              :    that we need not worry about saving and restoring the stack.
    4985              : 
    4986              :    FNDECL is the declaration of the function we are calling.
    4987              : 
    4988              :    Return true if this arg should cause sibcall failure,
    4989              :    false otherwise.  */
    4990              : 
    4991              : static bool
    4992      2150774 : store_one_arg (struct arg_data *arg, rtx argblock, int flags,
    4993              :                int variable_size ATTRIBUTE_UNUSED, int reg_parm_stack_space)
    4994              : {
    4995      2150774 :   tree pval = arg->tree_value;
    4996      2150774 :   rtx reg = 0;
    4997      2150774 :   int partial = 0;
    4998      2150774 :   poly_int64 used = 0;
    4999      2150774 :   poly_int64 lower_bound = 0, upper_bound = 0;
    5000      2150774 :   bool sibcall_failure = false;
    5001              : 
    5002      2150774 :   if (TREE_CODE (pval) == ERROR_MARK)
    5003              :     return true;
    5004              : 
    5005              :   /* Push a new temporary level for any temporaries we make for
    5006              :      this argument.  */
    5007      2150774 :   push_temp_slots ();
    5008              : 
    5009      2150774 :   if (ACCUMULATE_OUTGOING_ARGS && !(flags & ECF_SIBCALL))
    5010              :     {
    5011              :       /* If this is being stored into a pre-allocated, fixed-size, stack area,
    5012              :          save any previous data at that location.  */
    5013        53895 :       if (argblock && ! variable_size && arg->stack)
    5014              :         {
    5015        53816 :           if (ARGS_GROW_DOWNWARD)
    5016              :             {
    5017              :               /* stack_slot is negative, but we want to index stack_usage_map
    5018              :                  with positive values.  */
    5019              :               if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
    5020              :                 {
    5021              :                   rtx offset = XEXP (XEXP (arg->stack_slot, 0), 1);
    5022              :                   upper_bound = -rtx_to_poly_int64 (offset) + 1;
    5023              :                 }
    5024              :               else
    5025              :                 upper_bound = 0;
    5026              : 
    5027              :               lower_bound = upper_bound - arg->locate.size.constant;
    5028              :             }
    5029              :           else
    5030              :             {
    5031        53816 :               if (GET_CODE (XEXP (arg->stack_slot, 0)) == PLUS)
    5032              :                 {
    5033        42128 :                   rtx offset = XEXP (XEXP (arg->stack_slot, 0), 1);
    5034        42128 :                   lower_bound = rtx_to_poly_int64 (offset);
    5035              :                 }
    5036              :               else
    5037              :                 lower_bound = 0;
    5038              : 
    5039        53816 :               upper_bound = lower_bound + arg->locate.size.constant;
    5040              :             }
    5041              : 
    5042        53816 :           if (stack_region_maybe_used_p (lower_bound, upper_bound,
    5043              :                                          reg_parm_stack_space))
    5044              :             {
    5045              :               /* We need to make a save area.  */
    5046            0 :               poly_uint64 size = arg->locate.size.constant * BITS_PER_UNIT;
    5047            0 :               machine_mode save_mode
    5048            0 :                 = int_mode_for_size (size, 1).else_blk ();
    5049            0 :               rtx adr = memory_address (save_mode, XEXP (arg->stack_slot, 0));
    5050            0 :               rtx stack_area = gen_rtx_MEM (save_mode, adr);
    5051              : 
    5052            0 :               if (save_mode == BLKmode)
    5053              :                 {
    5054            0 :                   arg->save_area
    5055            0 :                     = assign_temp (TREE_TYPE (arg->tree_value), 1, 1);
    5056            0 :                   preserve_temp_slots (arg->save_area);
    5057            0 :                   emit_block_move (validize_mem (copy_rtx (arg->save_area)),
    5058              :                                    stack_area,
    5059              :                                    (gen_int_mode
    5060            0 :                                     (arg->locate.size.constant, Pmode)),
    5061              :                                    BLOCK_OP_CALL_PARM);
    5062              :                 }
    5063              :               else
    5064              :                 {
    5065            0 :                   arg->save_area = gen_reg_rtx (save_mode);
    5066            0 :                   emit_move_insn (arg->save_area, stack_area);
    5067              :                 }
    5068              :             }
    5069              :         }
    5070              :     }
    5071              : 
    5072              :   /* If this isn't going to be placed on both the stack and in registers,
    5073              :      set up the register and number of words.  */
    5074      2150774 :   if (! arg->pass_on_stack)
    5075              :     {
    5076      2150774 :       if (flags & ECF_SIBCALL)
    5077        10469 :         reg = arg->tail_call_reg;
    5078              :       else
    5079      2140305 :         reg = arg->reg;
    5080      2150774 :       partial = arg->partial;
    5081              :     }
    5082              : 
    5083              :   /* Being passed entirely in a register.  We shouldn't be called in
    5084              :      this case.  */
    5085      2150774 :   gcc_assert (reg == 0 || partial != 0);
    5086              : 
    5087              :   /* If this arg needs special alignment, don't load the registers
    5088              :      here.  */
    5089      2150774 :   if (arg->n_aligned_regs != 0)
    5090            0 :     reg = 0;
    5091              : 
    5092              :   /* If this is being passed partially in a register, we can't evaluate
    5093              :      it directly into its stack slot.  Otherwise, we can.  */
    5094      2150774 :   if (arg->value == 0)
    5095              :     {
    5096              :       /* stack_arg_under_construction is nonzero if a function argument is
    5097              :          being evaluated directly into the outgoing argument list and
    5098              :          expand_call must take special action to preserve the argument list
    5099              :          if it is called recursively.
    5100              : 
    5101              :          For scalar function arguments stack_usage_map is sufficient to
    5102              :          determine which stack slots must be saved and restored.  Scalar
    5103              :          arguments in general have pass_on_stack == false.
    5104              : 
    5105              :          If this argument is initialized by a function which takes the
    5106              :          address of the argument (a C++ constructor or a C function
    5107              :          returning a BLKmode structure), then stack_usage_map is
    5108              :          insufficient and expand_call must push the stack around the
    5109              :          function call.  Such arguments have pass_on_stack == true.
    5110              : 
    5111              :          Note that it is always safe to set stack_arg_under_construction,
    5112              :          but this generates suboptimal code if set when not needed.  */
    5113              : 
    5114      2150774 :       if (arg->pass_on_stack)
    5115            0 :         stack_arg_under_construction++;
    5116              : 
    5117      4265550 :       arg->value = expand_expr (pval,
    5118              :                                 (partial
    5119      2150774 :                                  || TYPE_MODE (TREE_TYPE (pval)) != arg->mode)
    5120              :                                 ? NULL_RTX : arg->stack,
    5121              :                                 VOIDmode, EXPAND_STACK_PARM);
    5122              : 
    5123              :       /* If we are promoting object (or for any other reason) the mode
    5124              :          doesn't agree, convert the mode.  */
    5125              : 
    5126      2150774 :       if (arg->mode != TYPE_MODE (TREE_TYPE (pval)))
    5127        35998 :         arg->value = convert_modes (arg->mode, TYPE_MODE (TREE_TYPE (pval)),
    5128              :                                     arg->value, arg->unsignedp);
    5129              : 
    5130      2150774 :       if (arg->pass_on_stack)
    5131            0 :         stack_arg_under_construction--;
    5132              :     }
    5133              : 
    5134              :   /* Check for overlap with already clobbered argument area.  */
    5135      2150774 :   if ((flags & ECF_SIBCALL)
    5136        10469 :       && MEM_P (arg->value)
    5137      2161243 :       && mem_might_overlap_already_clobbered_arg_p (XEXP (arg->value, 0),
    5138          448 :                                                     arg->locate.size.constant))
    5139            4 :     sibcall_failure = true;
    5140              : 
    5141              :   /* Don't allow anything left on stack from computation
    5142              :      of argument to alloca.  */
    5143      2150774 :   if (flags & ECF_MAY_BE_ALLOCA)
    5144            0 :     do_pending_stack_adjust ();
    5145              : 
    5146      2150774 :   if (arg->value == arg->stack)
    5147              :     /* If the value is already in the stack slot, we are done.  */
    5148              :     ;
    5149      2142153 :   else if (arg->mode != BLKmode)
    5150              :     {
    5151      1871074 :       unsigned int parm_align;
    5152              : 
    5153              :       /* Argument is a scalar, not entirely passed in registers.
    5154              :          (If part is passed in registers, arg->partial says how much
    5155              :          and emit_push_insn will take care of putting it there.)
    5156              : 
    5157              :          Push it, and if its size is less than the
    5158              :          amount of space allocated to it,
    5159              :          also bump stack pointer by the additional space.
    5160              :          Note that in C the default argument promotions
    5161              :          will prevent such mismatches.  */
    5162              : 
    5163      1871074 :       poly_int64 size = (TYPE_EMPTY_P (TREE_TYPE (pval))
    5164      3742148 :                          ? 0 : GET_MODE_SIZE (arg->mode));
    5165              : 
    5166              :       /* Compute how much space the push instruction will push.
    5167              :          On many machines, pushing a byte will advance the stack
    5168              :          pointer by a halfword.  */
    5169              : #ifdef PUSH_ROUNDING
    5170      1871074 :       size = PUSH_ROUNDING (size);
    5171              : #endif
    5172      1871074 :       used = size;
    5173              : 
    5174              :       /* Compute how much space the argument should get:
    5175              :          round up to a multiple of the alignment for arguments.  */
    5176      1871074 :       if (targetm.calls.function_arg_padding (arg->mode, TREE_TYPE (pval))
    5177              :           != PAD_NONE)
    5178              :         /* At the moment we don't (need to) support ABIs for which the
    5179              :            padding isn't known at compile time.  In principle it should
    5180              :            be easy to add though.  */
    5181      3290075 :         used = force_align_up (size, PARM_BOUNDARY / BITS_PER_UNIT);
    5182              : 
    5183              :       /* Compute the alignment of the pushed argument.  */
    5184      1871074 :       parm_align = arg->locate.boundary;
    5185      1871074 :       if (targetm.calls.function_arg_padding (arg->mode, TREE_TYPE (pval))
    5186              :           == PAD_DOWNWARD)
    5187              :         {
    5188            0 :           poly_int64 pad = used - size;
    5189            0 :           unsigned int pad_align = known_alignment (pad) * BITS_PER_UNIT;
    5190            0 :           if (pad_align != 0)
    5191            0 :             parm_align = MIN (parm_align, pad_align);
    5192              :         }
    5193              : 
    5194              :       /* This isn't already where we want it on the stack, so put it there.
    5195              :          This can either be done with push or copy insns.  */
    5196      1871074 :       if (maybe_ne (used, 0)
    5197      3733421 :           && !emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval),
    5198              :                               NULL_RTX, parm_align, partial, reg, used - size,
    5199      3281352 :                               argblock, ARGS_SIZE_RTX (arg->locate.offset),
    5200              :                               reg_parm_stack_space,
    5201      3281352 :                               ARGS_SIZE_RTX (arg->locate.alignment_pad), true))
    5202              :         sibcall_failure = true;
    5203              : 
    5204              :       /* Unless this is a partially-in-register argument, the argument is now
    5205              :          in the stack.  */
    5206      1871074 :       if (partial == 0)
    5207      1871074 :         arg->value = arg->stack;
    5208              :     }
    5209              :   else
    5210              :     {
    5211              :       /* BLKmode, at least partly to be pushed.  */
    5212              : 
    5213       271079 :       unsigned int parm_align;
    5214       271079 :       poly_int64 excess;
    5215       271079 :       rtx size_rtx;
    5216              : 
    5217              :       /* Pushing a nonscalar.
    5218              :          If part is passed in registers, PARTIAL says how much
    5219              :          and emit_push_insn will take care of putting it there.  */
    5220              : 
    5221              :       /* Round its size up to a multiple
    5222              :          of the allocation unit for arguments.  */
    5223              : 
    5224       271079 :       if (arg->locate.size.var != 0)
    5225              :         {
    5226            0 :           excess = 0;
    5227            0 :           size_rtx = ARGS_SIZE_RTX (arg->locate.size);
    5228              :         }
    5229              :       else
    5230              :         {
    5231              :           /* PUSH_ROUNDING has no effect on us, because emit_push_insn
    5232              :              for BLKmode is careful to avoid it.  */
    5233       271079 :           excess = (arg->locate.size.constant
    5234       271079 :                     - arg_int_size_in_bytes (TREE_TYPE (pval))
    5235       271079 :                     + partial);
    5236       271079 :           size_rtx = expand_expr (arg_size_in_bytes (TREE_TYPE (pval)),
    5237       271079 :                                   NULL_RTX, TYPE_MODE (sizetype),
    5238              :                                   EXPAND_NORMAL);
    5239              :         }
    5240              : 
    5241       271079 :       parm_align = arg->locate.boundary;
    5242              : 
    5243              :       /* When an argument is padded down, the block is aligned to
    5244              :          PARM_BOUNDARY, but the actual argument isn't.  */
    5245       271079 :       if (targetm.calls.function_arg_padding (arg->mode, TREE_TYPE (pval))
    5246              :           == PAD_DOWNWARD)
    5247              :         {
    5248            0 :           if (arg->locate.size.var)
    5249              :             parm_align = BITS_PER_UNIT;
    5250              :           else
    5251              :             {
    5252            0 :               unsigned int excess_align
    5253            0 :                 = known_alignment (excess) * BITS_PER_UNIT;
    5254            0 :               if (excess_align != 0)
    5255            0 :                 parm_align = MIN (parm_align, excess_align);
    5256              :             }
    5257              :         }
    5258              : 
    5259       271079 :       if ((flags & ECF_SIBCALL) && MEM_P (arg->value))
    5260              :         {
    5261              :           /* emit_push_insn might not work properly if arg->value and
    5262              :              argblock + arg->locate.offset areas overlap.  */
    5263           87 :           rtx x = arg->value;
    5264           87 :           poly_int64 i = 0;
    5265              : 
    5266           87 :           if (strip_offset (XEXP (x, 0), &i)
    5267           87 :               == crtl->args.internal_arg_pointer)
    5268              :             {
    5269              :               /* arg.locate doesn't contain the pretend_args_size offset,
    5270              :                  it's part of argblock.  Ensure we don't count it in I.  */
    5271           28 :               if (STACK_GROWS_DOWNWARD)
    5272           28 :                 i -= crtl->args.pretend_args_size;
    5273              :               else
    5274              :                 i += crtl->args.pretend_args_size;
    5275              : 
    5276              :               /* expand_call should ensure this.  */
    5277           28 :               gcc_assert (!arg->locate.offset.var
    5278              :                           && arg->locate.size.var == 0);
    5279           28 :               poly_int64 size_val = rtx_to_poly_int64 (size_rtx);
    5280              : 
    5281           28 :               if (known_eq (arg->locate.offset.constant, i))
    5282              :                 {
    5283              :                   /* Even though they appear to be at the same location,
    5284              :                      if part of the outgoing argument is in registers,
    5285              :                      they aren't really at the same location.  Check for
    5286              :                      this by making sure that the incoming size is the
    5287              :                      same as the outgoing size.  */
    5288           19 :                   if (partial != 0)
    5289           87 :                     sibcall_failure = true;
    5290              :                 }
    5291           12 :               else if (maybe_in_range_p (arg->locate.offset.constant,
    5292              :                                          i, size_val))
    5293              :                 sibcall_failure = true;
    5294              :               /* Use arg->locate.size.constant instead of size_rtx
    5295              :                  because we only care about the part of the argument
    5296              :                  on the stack.  */
    5297            6 :               else if (maybe_in_range_p (i, arg->locate.offset.constant,
    5298            9 :                                          arg->locate.size.constant))
    5299           87 :                 sibcall_failure = true;
    5300              :             }
    5301              :         }
    5302              : 
    5303       271079 :       if (!CONST_INT_P (size_rtx) || INTVAL (size_rtx) != 0)
    5304       269011 :         emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
    5305              :                         parm_align, partial, reg, excess, argblock,
    5306       334153 :                         ARGS_SIZE_RTX (arg->locate.offset),
    5307              :                         reg_parm_stack_space,
    5308       334153 :                         ARGS_SIZE_RTX (arg->locate.alignment_pad), false);
    5309              :       /* If we bypass emit_push_insn because it is a zero sized argument,
    5310              :          we still might need to adjust stack if such argument requires
    5311              :          extra alignment.  See PR104558.  */
    5312         2068 :       else if ((arg->locate.alignment_pad.var
    5313         2068 :                 || maybe_ne (arg->locate.alignment_pad.constant, 0))
    5314         2069 :                && !argblock)
    5315            1 :         anti_adjust_stack (ARGS_SIZE_RTX (arg->locate.alignment_pad));
    5316              : 
    5317              :       /* Unless this is a partially-in-register argument, the argument is now
    5318              :          in the stack.
    5319              : 
    5320              :          ??? Unlike the case above, in which we want the actual
    5321              :          address of the data, so that we can load it directly into a
    5322              :          register, here we want the address of the stack slot, so that
    5323              :          it's properly aligned for word-by-word copying or something
    5324              :          like that.  It's not clear that this is always correct.  */
    5325       271079 :       if (partial == 0)
    5326       271079 :         arg->value = arg->stack_slot;
    5327              :     }
    5328              : 
    5329      2150774 :   if (arg->reg && GET_CODE (arg->reg) == PARALLEL)
    5330              :     {
    5331            0 :       tree type = TREE_TYPE (arg->tree_value);
    5332            0 :       arg->parallel_value
    5333            0 :         = emit_group_load_into_temps (arg->reg, arg->value, type,
    5334            0 :                                       int_size_in_bytes (type));
    5335              :     }
    5336              : 
    5337              :   /* Mark all slots this store used.  */
    5338      2150774 :   if (ACCUMULATE_OUTGOING_ARGS && !(flags & ECF_SIBCALL)
    5339      2204669 :       && argblock && ! variable_size && arg->stack)
    5340        53816 :     mark_stack_region_used (lower_bound, upper_bound);
    5341              : 
    5342              :   /* Once we have pushed something, pops can't safely
    5343              :      be deferred during the rest of the arguments.  */
    5344      2150774 :   NO_DEFER_POP;
    5345              : 
    5346              :   /* Free any temporary slots made in processing this argument.  */
    5347      2150774 :   pop_temp_slots ();
    5348              : 
    5349      2150774 :   return sibcall_failure;
    5350              : }
    5351              : 
    5352              : /* Nonzero if we do not know how to pass ARG solely in registers.  */
    5353              : 
    5354              : bool
    5355            0 : must_pass_in_stack_var_size (const function_arg_info &arg)
    5356              : {
    5357            0 :   if (!arg.type)
    5358              :     return false;
    5359              : 
    5360              :   /* If the type has variable size...  */
    5361            0 :   if (!poly_int_tree_p (TYPE_SIZE (arg.type)))
    5362              :     return true;
    5363              : 
    5364              :   /* If the type is marked as addressable (it is required
    5365              :      to be constructed into the stack)...  */
    5366            0 :   if (TREE_ADDRESSABLE (arg.type))
    5367            0 :     return true;
    5368              : 
    5369              :   return false;
    5370              : }
    5371              : 
    5372              : /* Another version of the TARGET_MUST_PASS_IN_STACK hook.  This one
    5373              :    takes trailing padding of a structure into account.  */
    5374              : /* ??? Should be able to merge these two by examining BLOCK_REG_PADDING.  */
    5375              : 
    5376              : bool
    5377    403722770 : must_pass_in_stack_var_size_or_pad (const function_arg_info &arg)
    5378              : {
    5379    403722770 :   if (!arg.type)
    5380              :     return false;
    5381              : 
    5382              :   /* If the type has variable size...  */
    5383    402890195 :   if (TREE_CODE (TYPE_SIZE (arg.type)) != INTEGER_CST)
    5384              :     return true;
    5385              : 
    5386              :   /* If the type is marked as addressable (it is required
    5387              :      to be constructed into the stack)...  */
    5388    402890195 :   if (TREE_ADDRESSABLE (arg.type))
    5389              :     return true;
    5390              : 
    5391    402890158 :   if (TYPE_EMPTY_P (arg.type))
    5392              :     return false;
    5393              : 
    5394              :   /* If the padding and mode of the type is such that a copy into
    5395              :      a register would put it into the wrong part of the register.  */
    5396    400869019 :   if (arg.mode == BLKmode
    5397      6482289 :       && int_size_in_bytes (arg.type) % (PARM_BOUNDARY / BITS_PER_UNIT)
    5398    401497193 :       && (targetm.calls.function_arg_padding (arg.mode, arg.type)
    5399              :           == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)))
    5400              :     return true;
    5401              : 
    5402              :   return false;
    5403              : }
    5404              : 
    5405              : /* Return true if TYPE must be passed on the stack when passed to
    5406              :    the "..." arguments of a function.  */
    5407              : 
    5408              : bool
    5409            0 : must_pass_va_arg_in_stack (tree type)
    5410              : {
    5411            0 :   function_arg_info arg (type, /*named=*/false);
    5412            0 :   return targetm.calls.must_pass_in_stack (arg);
    5413              : }
    5414              : 
    5415              : /* Return true if FIELD is the C++17 empty base field that should
    5416              :    be ignored for ABI calling convention decisions in order to
    5417              :    maintain ABI compatibility between C++14 and earlier, which doesn't
    5418              :    add this FIELD to classes with empty bases, and C++17 and later
    5419              :    which does.  */
    5420              : 
    5421              : bool
    5422            0 : cxx17_empty_base_field_p (const_tree field)
    5423              : {
    5424            0 :   return (DECL_FIELD_ABI_IGNORED (field)
    5425            0 :           && DECL_ARTIFICIAL (field)
    5426            0 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    5427            0 :           && !lookup_attribute ("no_unique_address", DECL_ATTRIBUTES (field)));
    5428              : }
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.