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

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.