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