Line data Source code
1 : /* Expands front end tree to back end RTL for GCC.
2 : Copyright (C) 1987-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 : /* This file handles the generation of rtl code from tree structure
21 : at the level of the function as a whole.
22 : It creates the rtl expressions for parameters and auto variables
23 : and has full responsibility for allocating stack slots.
24 :
25 : `expand_function_start' is called at the beginning of a function,
26 : before the function body is parsed, and `expand_function_end' is
27 : called after parsing the body.
28 :
29 : Call `assign_stack_local' to allocate a stack slot for a local variable.
30 : This is usually done during the RTL generation for the function body,
31 : but it can also be done in the reload pass when a pseudo-register does
32 : not get a hard register. */
33 :
34 : #include "config.h"
35 : #include "system.h"
36 : #include "coretypes.h"
37 : #include "backend.h"
38 : #include "target.h"
39 : #include "rtl.h"
40 : #include "tree.h"
41 : #include "gimple-expr.h"
42 : #include "cfghooks.h"
43 : #include "df.h"
44 : #include "memmodel.h"
45 : #include "tm_p.h"
46 : #include "stringpool.h"
47 : #include "expmed.h"
48 : #include "optabs.h"
49 : #include "opts.h"
50 : #include "regs.h"
51 : #include "emit-rtl.h"
52 : #include "recog.h"
53 : #include "rtl-error.h"
54 : #include "hard-reg-set.h"
55 : #include "alias.h"
56 : #include "fold-const.h"
57 : #include "stor-layout.h"
58 : #include "varasm.h"
59 : #include "except.h"
60 : #include "dojump.h"
61 : #include "explow.h"
62 : #include "calls.h"
63 : #include "expr.h"
64 : #include "optabs-tree.h"
65 : #include "output.h"
66 : #include "langhooks.h"
67 : #include "common/common-target.h"
68 : #include "gimplify.h"
69 : #include "tree-pass.h"
70 : #include "cfgrtl.h"
71 : #include "cfganal.h"
72 : #include "cfgbuild.h"
73 : #include "cfgcleanup.h"
74 : #include "cfgexpand.h"
75 : #include "shrink-wrap.h"
76 : #include "toplev.h"
77 : #include "rtl-iter.h"
78 : #include "tree-dfa.h"
79 : #include "tree-ssa.h"
80 : #include "stringpool.h"
81 : #include "attribs.h"
82 : #include "gimple.h"
83 : #include "options.h"
84 : #include "function-abi.h"
85 : #include "value-range.h"
86 : #include "gimple-range.h"
87 : #include "insn-attr.h"
88 : #include "hierarchical_discriminator.h"
89 :
90 : /* So we can assign to cfun in this file. */
91 : #undef cfun
92 :
93 : #ifndef STACK_ALIGNMENT_NEEDED
94 : #define STACK_ALIGNMENT_NEEDED 1
95 : #endif
96 :
97 : #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
98 :
99 : /* Round a value to the lowest integer less than it that is a multiple of
100 : the required alignment. Avoid using division in case the value is
101 : negative. Assume the alignment is a power of two. */
102 : #define FLOOR_ROUND(VALUE,ALIGN) ((VALUE) & ~((ALIGN) - 1))
103 :
104 : /* Similar, but round to the next highest integer that meets the
105 : alignment. */
106 : #define CEIL_ROUND(VALUE,ALIGN) (((VALUE) + (ALIGN) - 1) & ~((ALIGN)- 1))
107 :
108 : /* Nonzero once virtual register instantiation has been done.
109 : assign_stack_local uses frame_pointer_rtx when this is nonzero.
110 : calls.cc:emit_library_call_value_1 uses it to set up
111 : post-instantiation libcalls. */
112 : int virtuals_instantiated;
113 :
114 : /* Assign unique numbers to labels generated for profiling, debugging, etc. */
115 : static GTY(()) int funcdef_no;
116 :
117 : /* These variables hold pointers to functions to create and destroy
118 : target specific, per-function data structures. */
119 : struct machine_function * (*init_machine_status) (void);
120 :
121 : /* The currently compiled function. */
122 : struct function *cfun = 0;
123 :
124 : /* These hashes record the prologue and epilogue insns. */
125 :
126 : struct insn_cache_hasher : ggc_cache_ptr_hash<rtx_def>
127 : {
128 1151466356 : static hashval_t hash (rtx x) { return htab_hash_pointer (x); }
129 : static bool equal (rtx a, rtx b) { return a == b; }
130 : };
131 :
132 : static GTY((cache))
133 : hash_table<insn_cache_hasher> *prologue_insn_hash;
134 : static GTY((cache))
135 : hash_table<insn_cache_hasher> *epilogue_insn_hash;
136 :
137 :
138 : hash_table<used_type_hasher> *types_used_by_vars_hash = NULL;
139 : vec<tree, va_gc> *types_used_by_cur_var_decl;
140 :
141 : /* Forward declarations. */
142 :
143 : static class temp_slot *find_temp_slot_from_address (rtx);
144 : static void pad_to_arg_alignment (struct args_size *, int, struct args_size *);
145 : static void pad_below (struct args_size *, machine_mode, tree);
146 : static void reorder_blocks_1 (rtx_insn *, tree, vec<tree> *);
147 : static int all_blocks (tree, tree *);
148 : static tree *get_block_vector (tree, int *);
149 : extern tree debug_find_var_in_block_tree (tree, tree);
150 : /* We always define `record_insns' even if it's not used so that we
151 : can always export `prologue_epilogue_contains'. */
152 : static void record_insns (rtx_insn *, rtx, hash_table<insn_cache_hasher> **)
153 : ATTRIBUTE_UNUSED;
154 : static bool contains (const rtx_insn *, hash_table<insn_cache_hasher> *);
155 : static void prepare_function_start (void);
156 : static void do_clobber_return_reg (rtx, void *);
157 : static void do_use_return_reg (rtx, void *);
158 : static rtx assign_stack_local_aligned (machine_mode, poly_int64,
159 : unsigned int);
160 :
161 :
162 : /* Stack of nested functions. */
163 : /* Keep track of the cfun stack. */
164 :
165 : static vec<function *> function_context_stack;
166 :
167 : /* Save the current context for compilation of a nested function.
168 : This is called from language-specific code. */
169 :
170 : void
171 89834812 : push_function_context (void)
172 : {
173 89834812 : if (cfun == 0)
174 22 : allocate_struct_function (NULL, false);
175 :
176 89834812 : function_context_stack.safe_push (cfun);
177 89834812 : set_cfun (NULL);
178 89834812 : }
179 :
180 : /* Restore the last saved context, at the end of a nested function.
181 : This function is called from language-specific code. */
182 :
183 : void
184 89834791 : pop_function_context (void)
185 : {
186 89834791 : struct function *p = function_context_stack.pop ();
187 89834791 : set_cfun (p);
188 89834791 : current_function_decl = p->decl;
189 :
190 : /* Reset variables that have known state during rtx generation. */
191 89834791 : virtuals_instantiated = 0;
192 89834791 : generating_concat_p = 1;
193 89834791 : }
194 :
195 : /* Clear out all parts of the state in F that can safely be discarded
196 : after the function has been parsed, but not compiled, to let
197 : garbage collection reclaim the memory. */
198 :
199 : void
200 1698297 : free_after_parsing (struct function *f)
201 : {
202 1698297 : f->language = 0;
203 1698297 : }
204 :
205 : /* Clear out all parts of the state in F that can safely be discarded
206 : after the function has been compiled, to let garbage collection
207 : reclaim the memory. */
208 :
209 : void
210 1703744 : free_after_compilation (struct function *f)
211 : {
212 1703744 : prologue_insn_hash = NULL;
213 1703744 : epilogue_insn_hash = NULL;
214 :
215 1703744 : free (crtl->emit.regno_pointer_align);
216 :
217 1703744 : memset (crtl, 0, sizeof (struct rtl_data));
218 1703744 : f->eh = NULL;
219 1703744 : f->machine = NULL;
220 1703744 : f->cfg = NULL;
221 1703744 : f->curr_properties &= ~PROP_cfg;
222 1703883 : delete f->cond_uids;
223 1703744 : free_copyid_allocator (f);
224 :
225 1703744 : regno_reg_rtx = NULL;
226 1703744 : }
227 :
228 : /* Return size needed for stack frame based on slots so far allocated.
229 : This size counts from zero. It is not rounded to PREFERRED_STACK_BOUNDARY;
230 : the caller may have to do that. */
231 :
232 : poly_int64
233 149036729 : get_frame_size (void)
234 : {
235 149036729 : if (FRAME_GROWS_DOWNWARD)
236 149036729 : return -frame_offset;
237 : else
238 : return frame_offset;
239 : }
240 :
241 : /* Issue an error message and return TRUE if frame OFFSET overflows in
242 : the signed target pointer arithmetics for function FUNC. Otherwise
243 : return FALSE. */
244 :
245 : bool
246 3964630 : frame_offset_overflow (poly_int64 offset, tree func)
247 : {
248 3964630 : poly_uint64 size = FRAME_GROWS_DOWNWARD ? -offset : offset;
249 3964630 : unsigned HOST_WIDE_INT limit
250 3964630 : = ((HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (Pmode) - 1))
251 : /* Leave room for the fixed part of the frame. */
252 3964630 : - 64 * UNITS_PER_WORD);
253 :
254 7929260 : if (!coeffs_in_range_p (size, 0U, limit))
255 : {
256 0 : unsigned HOST_WIDE_INT hwisize;
257 0 : if (size.is_constant (&hwisize))
258 0 : error_at (DECL_SOURCE_LOCATION (func),
259 : "total size of local objects %wu exceeds maximum %wu",
260 : hwisize, limit);
261 : else
262 : error_at (DECL_SOURCE_LOCATION (func),
263 : "total size of local objects exceeds maximum %wu",
264 : limit);
265 0 : return true;
266 : }
267 :
268 : return false;
269 : }
270 :
271 : /* Return the minimum spill slot alignment for a register of mode MODE. */
272 :
273 : unsigned int
274 1408878 : spill_slot_alignment (machine_mode mode ATTRIBUTE_UNUSED)
275 : {
276 1408878 : return STACK_SLOT_ALIGNMENT (NULL_TREE, mode, GET_MODE_ALIGNMENT (mode));
277 : }
278 :
279 : /* Return stack slot alignment in bits for TYPE and MODE. */
280 :
281 : static unsigned int
282 154721 : get_stack_local_alignment (tree type, machine_mode mode)
283 : {
284 154721 : unsigned int alignment;
285 :
286 154721 : if (mode == BLKmode)
287 22316 : alignment = BIGGEST_ALIGNMENT;
288 : else
289 132405 : alignment = GET_MODE_ALIGNMENT (mode);
290 :
291 : /* Allow the frond-end to (possibly) increase the alignment of this
292 : stack slot. */
293 154721 : if (! type)
294 56379 : type = lang_hooks.types.type_for_mode (mode, 0);
295 :
296 154721 : return STACK_SLOT_ALIGNMENT (type, mode, alignment);
297 : }
298 :
299 : /* Determine whether it is possible to fit a stack slot of size SIZE and
300 : alignment ALIGNMENT into an area in the stack frame that starts at
301 : frame offset START and has a length of LENGTH. If so, store the frame
302 : offset to be used for the stack slot in *POFFSET and return true;
303 : return false otherwise. This function will extend the frame size when
304 : given a start/length pair that lies at the end of the frame. */
305 :
306 : static bool
307 2365826 : try_fit_stack_local (poly_int64 start, poly_int64 length,
308 : poly_int64 size, unsigned int alignment,
309 : poly_int64 *poffset)
310 : {
311 2365826 : poly_int64 this_frame_offset;
312 2365826 : int frame_off, frame_alignment, frame_phase;
313 :
314 : /* Calculate how many bytes the start of local variables is off from
315 : stack alignment. */
316 2365826 : frame_alignment = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
317 2365826 : frame_off = targetm.starting_frame_offset () % frame_alignment;
318 2365826 : frame_phase = frame_off ? frame_alignment - frame_off : 0;
319 :
320 : /* Round the frame offset to the specified alignment. */
321 :
322 2365826 : if (FRAME_GROWS_DOWNWARD)
323 2365826 : this_frame_offset
324 2365826 : = (aligned_lower_bound (start + length - size - frame_phase, alignment)
325 2365826 : + frame_phase);
326 : else
327 : this_frame_offset
328 : = aligned_upper_bound (start - frame_phase, alignment) + frame_phase;
329 :
330 : /* See if it fits. If this space is at the edge of the frame,
331 : consider extending the frame to make it fit. Our caller relies on
332 : this when allocating a new slot. */
333 2365826 : if (maybe_lt (this_frame_offset, start))
334 : {
335 488251 : if (known_eq (frame_offset, start))
336 364267 : frame_offset = this_frame_offset;
337 : else
338 : return false;
339 : }
340 1877575 : else if (maybe_gt (this_frame_offset + size, start + length))
341 : {
342 0 : if (known_eq (frame_offset, start + length))
343 0 : frame_offset = this_frame_offset + size;
344 : else
345 : return false;
346 : }
347 :
348 2241842 : *poffset = this_frame_offset;
349 2241842 : return true;
350 : }
351 :
352 : /* Create a new frame_space structure describing free space in the stack
353 : frame beginning at START and ending at END, and chain it into the
354 : function's frame_space_list. */
355 :
356 : static void
357 392146 : add_frame_space (poly_int64 start, poly_int64 end)
358 : {
359 392146 : class frame_space *space = ggc_alloc<frame_space> ();
360 392146 : space->next = crtl->frame_space_list;
361 392146 : crtl->frame_space_list = space;
362 392146 : space->start = start;
363 392146 : space->length = end - start;
364 392146 : }
365 :
366 : /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
367 : with machine mode MODE.
368 :
369 : ALIGN controls the amount of alignment for the address of the slot:
370 : 0 means according to MODE,
371 : -1 means use BIGGEST_ALIGNMENT and round size to multiple of that,
372 : -2 means use BITS_PER_UNIT,
373 : positive specifies alignment boundary in bits.
374 :
375 : KIND has ASLK_REDUCE_ALIGN bit set if it is OK to reduce
376 : alignment and ASLK_RECORD_PAD bit set if we should remember
377 : extra space we allocated for alignment purposes. When we are
378 : called from assign_stack_temp_for_type, it is not set so we don't
379 : track the same stack slot in two independent lists.
380 :
381 : We do not round to stack_boundary here. */
382 :
383 : rtx
384 2241842 : assign_stack_local_1 (machine_mode mode, poly_int64 size,
385 : int align, int kind)
386 : {
387 2241842 : rtx x, addr;
388 2241842 : poly_int64 bigend_correction = 0;
389 2241842 : poly_int64 slot_offset = 0, old_frame_offset;
390 2241842 : unsigned int alignment, alignment_in_bits;
391 :
392 2241842 : if (align == 0)
393 : {
394 7017 : alignment = get_stack_local_alignment (NULL, mode);
395 7017 : alignment /= BITS_PER_UNIT;
396 : }
397 2234825 : else if (align == -1)
398 : {
399 947 : alignment = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
400 947 : size = aligned_upper_bound (size, alignment);
401 : }
402 2233878 : else if (align == -2)
403 : alignment = 1; /* BITS_PER_UNIT / BITS_PER_UNIT */
404 : else
405 2233878 : alignment = align / BITS_PER_UNIT;
406 :
407 2241842 : alignment_in_bits = alignment * BITS_PER_UNIT;
408 :
409 : /* Ignore alignment if it exceeds MAX_SUPPORTED_STACK_ALIGNMENT. */
410 2241842 : if (alignment_in_bits > MAX_SUPPORTED_STACK_ALIGNMENT)
411 : {
412 0 : alignment_in_bits = MAX_SUPPORTED_STACK_ALIGNMENT;
413 0 : alignment = MAX_SUPPORTED_STACK_ALIGNMENT / BITS_PER_UNIT;
414 : }
415 :
416 2241842 : if (SUPPORTS_STACK_ALIGNMENT)
417 : {
418 2241842 : if (crtl->stack_alignment_estimated < alignment_in_bits)
419 : {
420 4404 : if (!crtl->stack_realign_processed)
421 4381 : crtl->stack_alignment_estimated = alignment_in_bits;
422 : else
423 : {
424 : /* If stack is realigned and stack alignment value
425 : hasn't been finalized, it is OK not to increase
426 : stack_alignment_estimated. The bigger alignment
427 : requirement is recorded in stack_alignment_needed
428 : below. */
429 23 : gcc_assert (!crtl->stack_realign_finalized);
430 23 : if (!crtl->stack_realign_needed)
431 : {
432 : /* It is OK to reduce the alignment as long as the
433 : requested size is 0 or the estimated stack
434 : alignment >= mode alignment. */
435 23 : gcc_assert ((kind & ASLK_REDUCE_ALIGN)
436 : || known_eq (size, 0)
437 : || (crtl->stack_alignment_estimated
438 : >= GET_MODE_ALIGNMENT (mode)));
439 23 : alignment_in_bits = crtl->stack_alignment_estimated;
440 23 : alignment = alignment_in_bits / BITS_PER_UNIT;
441 : }
442 : }
443 : }
444 : }
445 :
446 2241842 : if (crtl->stack_alignment_needed < alignment_in_bits)
447 18467 : crtl->stack_alignment_needed = alignment_in_bits;
448 2241842 : if (crtl->max_used_stack_slot_alignment < alignment_in_bits)
449 290933 : crtl->max_used_stack_slot_alignment = alignment_in_bits;
450 :
451 2241842 : if (mode != BLKmode || maybe_ne (size, 0))
452 : {
453 1447040 : if (kind & ASLK_RECORD_PAD)
454 : {
455 : class frame_space **psp;
456 :
457 1487209 : for (psp = &crtl->frame_space_list; *psp; psp = &(*psp)->next)
458 : {
459 185943 : class frame_space *space = *psp;
460 185943 : if (!try_fit_stack_local (space->start, space->length, size,
461 : alignment, &slot_offset))
462 123984 : continue;
463 61959 : *psp = space->next;
464 61959 : if (known_gt (slot_offset, space->start))
465 25925 : add_frame_space (space->start, slot_offset);
466 61959 : if (known_lt (slot_offset + size, space->start + space->length))
467 10748 : add_frame_space (slot_offset + size,
468 10748 : space->start + space->length);
469 61959 : goto found_space;
470 : }
471 : }
472 : }
473 : else if (!STACK_ALIGNMENT_NEEDED)
474 : {
475 : slot_offset = frame_offset;
476 : goto found_space;
477 : }
478 :
479 2179883 : old_frame_offset = frame_offset;
480 :
481 2179883 : if (FRAME_GROWS_DOWNWARD)
482 : {
483 2179883 : frame_offset -= size;
484 2179883 : try_fit_stack_local (frame_offset, size, size, alignment, &slot_offset);
485 :
486 2179883 : if (kind & ASLK_RECORD_PAD)
487 : {
488 2096068 : if (known_gt (slot_offset, frame_offset))
489 0 : add_frame_space (frame_offset, slot_offset);
490 2096068 : if (known_lt (slot_offset + size, old_frame_offset))
491 355473 : add_frame_space (slot_offset + size, old_frame_offset);
492 : }
493 : }
494 : else
495 : {
496 : frame_offset += size;
497 : try_fit_stack_local (old_frame_offset, size, size, alignment, &slot_offset);
498 :
499 : if (kind & ASLK_RECORD_PAD)
500 : {
501 : if (known_gt (slot_offset, old_frame_offset))
502 : add_frame_space (old_frame_offset, slot_offset);
503 : if (known_lt (slot_offset + size, frame_offset))
504 : add_frame_space (slot_offset + size, frame_offset);
505 : }
506 : }
507 :
508 2241842 : found_space:
509 : /* On a big-endian machine, if we are allocating more space than we will use,
510 : use the least significant bytes of those that are allocated. */
511 2241842 : if (mode != BLKmode)
512 : {
513 : /* The slot size can sometimes be smaller than the mode size;
514 : e.g. the rs6000 port allocates slots with a vector mode
515 : that have the size of only one element. However, the slot
516 : size must always be ordered wrt to the mode size, in the
517 : same way as for a subreg. */
518 674899 : gcc_checking_assert (ordered_p (GET_MODE_SIZE (mode), size));
519 : if (BYTES_BIG_ENDIAN && maybe_lt (GET_MODE_SIZE (mode), size))
520 : bigend_correction = size - GET_MODE_SIZE (mode);
521 : }
522 :
523 : /* If we have already instantiated virtual registers, return the actual
524 : address relative to the frame pointer. */
525 2241842 : if (virtuals_instantiated)
526 1843277 : addr = plus_constant (Pmode, frame_pointer_rtx,
527 : trunc_int_for_mode
528 1553159 : (slot_offset + bigend_correction
529 1843277 : + targetm.starting_frame_offset (), Pmode));
530 : else
531 720975 : addr = plus_constant (Pmode, virtual_stack_vars_rtx,
532 : trunc_int_for_mode
533 : (slot_offset + bigend_correction,
534 688683 : Pmode));
535 :
536 2241842 : x = gen_rtx_MEM (mode, addr);
537 2241842 : set_mem_align (x, alignment_in_bits);
538 2241842 : MEM_NOTRAP_P (x) = 1;
539 :
540 2241842 : vec_safe_push (stack_slot_list, x);
541 :
542 2241842 : if (frame_offset_overflow (frame_offset, current_function_decl))
543 0 : frame_offset = 0;
544 :
545 2241842 : return x;
546 : }
547 :
548 : /* Wrap up assign_stack_local_1 with last parameter as false. */
549 :
550 : rtx
551 2158027 : assign_stack_local (machine_mode mode, poly_int64 size, int align)
552 : {
553 2158027 : return assign_stack_local_1 (mode, size, align, ASLK_RECORD_PAD);
554 : }
555 :
556 : /* Like assign_stack_local, but preserve requested over-alignment by
557 : overallocating a BLKmode slot and aligning an address within it. */
558 :
559 : static rtx
560 5795 : assign_stack_local_aligned (machine_mode mode, poly_int64 size,
561 : unsigned int align)
562 : {
563 5795 : if (targetm.calls.overaligned_stack_slot_required ()
564 5795 : && align > MAX_SUPPORTED_STACK_ALIGNMENT)
565 : {
566 0 : if (!size.is_constant ())
567 : return assign_stack_local (mode, size, MAX_SUPPORTED_STACK_ALIGNMENT);
568 :
569 0 : rtx allocsize = gen_int_mode (size, Pmode);
570 0 : get_dynamic_stack_size (&allocsize, 0, align, NULL);
571 :
572 0 : if (!CONST_INT_P (allocsize))
573 0 : return assign_stack_local (mode, size, MAX_SUPPORTED_STACK_ALIGNMENT);
574 :
575 0 : rtx slot = assign_stack_local (BLKmode, UINTVAL (allocsize),
576 : MAX_SUPPORTED_STACK_ALIGNMENT);
577 0 : rtx addr = align_dynamic_address (XEXP (slot, 0), align);
578 0 : mark_reg_pointer (addr, align);
579 0 : slot = gen_rtx_MEM (mode, addr);
580 0 : MEM_NOTRAP_P (slot) = 1;
581 0 : return slot;
582 : }
583 5795 : return assign_stack_local (mode, size, align);
584 : }
585 :
586 : /* In order to evaluate some expressions, such as function calls returning
587 : structures in memory, we need to temporarily allocate stack locations.
588 : We record each allocated temporary in the following structure.
589 :
590 : Associated with each temporary slot is a nesting level. When we pop up
591 : one level, all temporaries associated with the previous level are freed.
592 : Normally, all temporaries are freed after the execution of the statement
593 : in which they were created. However, if we are inside a ({...}) grouping,
594 : the result may be in a temporary and hence must be preserved. If the
595 : result could be in a temporary, we preserve it if we can determine which
596 : one it is in. If we cannot determine which temporary may contain the
597 : result, all temporaries are preserved. A temporary is preserved by
598 : pretending it was allocated at the previous nesting level. */
599 :
600 : class GTY(()) temp_slot {
601 : public:
602 : /* Points to next temporary slot. */
603 : class temp_slot *next;
604 : /* Points to previous temporary slot. */
605 : class temp_slot *prev;
606 : /* The rtx to used to reference the slot. */
607 : rtx slot;
608 : /* The size, in units, of the slot. */
609 : poly_int64 size;
610 : /* The type of the object in the slot, or zero if it doesn't correspond
611 : to a type. We use this to determine whether a slot can be reused.
612 : It can be reused if objects of the type of the new slot will always
613 : conflict with objects of the type of the old slot. */
614 : tree type;
615 : /* The alignment (in bits) of the slot. */
616 : unsigned int align;
617 : /* True if this temporary is currently in use. */
618 : bool in_use;
619 : /* Nesting level at which this slot is being used. */
620 : int level;
621 : /* The offset of the slot from the frame_pointer, including extra space
622 : for alignment. This info is for combine_temp_slots. */
623 : poly_int64 base_offset;
624 : /* The size of the slot, including extra space for alignment. This
625 : info is for combine_temp_slots. */
626 : poly_int64 full_size;
627 : };
628 :
629 : /* Entry for the below hash table. */
630 : struct GTY((for_user)) temp_slot_address_entry {
631 : hashval_t hash;
632 : rtx address;
633 : class temp_slot *temp_slot;
634 : };
635 :
636 : struct temp_address_hasher : ggc_ptr_hash<temp_slot_address_entry>
637 : {
638 : static hashval_t hash (temp_slot_address_entry *);
639 : static bool equal (temp_slot_address_entry *, temp_slot_address_entry *);
640 : };
641 :
642 : /* A table of addresses that represent a stack slot. The table is a mapping
643 : from address RTXen to a temp slot. */
644 : static GTY(()) hash_table<temp_address_hasher> *temp_slot_address_table;
645 : static size_t n_temp_slots_in_use;
646 :
647 : /* Removes temporary slot TEMP from LIST. */
648 :
649 : static void
650 212978 : cut_slot_from_list (class temp_slot *temp, class temp_slot **list)
651 : {
652 0 : if (temp->next)
653 27710 : temp->next->prev = temp->prev;
654 212978 : if (temp->prev)
655 7896 : temp->prev->next = temp->next;
656 : else
657 205082 : *list = temp->next;
658 :
659 212978 : temp->prev = temp->next = NULL;
660 697 : }
661 :
662 : /* Inserts temporary slot TEMP to LIST. */
663 :
664 : static void
665 296717 : insert_slot_to_list (class temp_slot *temp, class temp_slot **list)
666 : {
667 296717 : temp->next = *list;
668 0 : if (*list)
669 80035 : (*list)->prev = temp;
670 296717 : temp->prev = NULL;
671 296717 : *list = temp;
672 0 : }
673 :
674 : /* Returns the list of used temp slots at LEVEL. */
675 :
676 : static class temp_slot **
677 66060527 : temp_slots_at_level (int level)
678 : {
679 130704456 : if (level >= (int) vec_safe_length (used_temp_slots))
680 1898624 : vec_safe_grow_cleared (used_temp_slots, level + 1, true);
681 :
682 66060527 : return &(*used_temp_slots)[level];
683 : }
684 :
685 : /* Returns the maximal temporary slot level. */
686 :
687 : static int
688 1329282 : max_slot_level (void)
689 : {
690 0 : if (!used_temp_slots)
691 : return -1;
692 :
693 1273981 : return used_temp_slots->length () - 1;
694 : }
695 :
696 : /* Moves temporary slot TEMP to LEVEL. */
697 :
698 : static void
699 1232 : move_slot_to_level (class temp_slot *temp, int level)
700 : {
701 1232 : cut_slot_from_list (temp, temp_slots_at_level (temp->level));
702 1232 : insert_slot_to_list (temp, temp_slots_at_level (level));
703 1232 : temp->level = level;
704 1232 : }
705 :
706 : /* Make temporary slot TEMP available. */
707 :
708 : static void
709 147160 : make_slot_available (class temp_slot *temp)
710 : {
711 147160 : cut_slot_from_list (temp, temp_slots_at_level (temp->level));
712 147160 : insert_slot_to_list (temp, &avail_temp_slots);
713 147160 : temp->in_use = false;
714 147160 : temp->level = -1;
715 147160 : n_temp_slots_in_use--;
716 147160 : }
717 :
718 : /* Compute the hash value for an address -> temp slot mapping.
719 : The value is cached on the mapping entry. */
720 : static hashval_t
721 8846913 : temp_slot_address_compute_hash (struct temp_slot_address_entry *t)
722 : {
723 8846913 : int do_not_record = 0;
724 8846913 : return hash_rtx (t->address, GET_MODE (t->address),
725 8846913 : &do_not_record, NULL, false);
726 : }
727 :
728 : /* Return the hash value for an address -> temp slot mapping. */
729 : hashval_t
730 30903 : temp_address_hasher::hash (temp_slot_address_entry *t)
731 : {
732 30903 : return t->hash;
733 : }
734 :
735 : /* Compare two address -> temp slot mapping entries. */
736 : bool
737 31670 : temp_address_hasher::equal (temp_slot_address_entry *t1,
738 : temp_slot_address_entry *t2)
739 : {
740 31670 : return exp_equiv_p (t1->address, t2->address, 0, true);
741 : }
742 :
743 : /* Add ADDRESS as an alias of TEMP_SLOT to the addess -> temp slot mapping. */
744 : static void
745 147742 : insert_temp_slot_address (rtx address, class temp_slot *temp_slot)
746 : {
747 147742 : struct temp_slot_address_entry *t = ggc_alloc<temp_slot_address_entry> ();
748 147742 : t->address = copy_rtx (address);
749 147742 : t->temp_slot = temp_slot;
750 147742 : t->hash = temp_slot_address_compute_hash (t);
751 147742 : *temp_slot_address_table->find_slot_with_hash (t, t->hash, INSERT) = t;
752 147742 : }
753 :
754 : /* Remove an address -> temp slot mapping entry if the temp slot is
755 : not in use anymore. Callback for remove_unused_temp_slot_addresses. */
756 : int
757 1042 : remove_unused_temp_slot_addresses_1 (temp_slot_address_entry **slot, void *)
758 : {
759 1042 : const struct temp_slot_address_entry *t = *slot;
760 1042 : if (! t->temp_slot->in_use)
761 598 : temp_slot_address_table->clear_slot (slot);
762 1042 : return 1;
763 : }
764 :
765 : /* Remove all mappings of addresses to unused temp slots. */
766 : static void
767 139732 : remove_unused_temp_slot_addresses (void)
768 : {
769 : /* Use quicker clearing if there aren't any active temp slots. */
770 139732 : if (n_temp_slots_in_use)
771 428 : temp_slot_address_table->traverse
772 1470 : <void *, remove_unused_temp_slot_addresses_1> (NULL);
773 : else
774 139304 : temp_slot_address_table->empty ();
775 139732 : }
776 :
777 : /* Find the temp slot corresponding to the object at address X. */
778 :
779 : static class temp_slot *
780 8699171 : find_temp_slot_from_address (rtx x)
781 : {
782 8699171 : class temp_slot *p;
783 8699171 : struct temp_slot_address_entry tmp, *t;
784 :
785 : /* First try the easy way:
786 : See if X exists in the address -> temp slot mapping. */
787 8699171 : tmp.address = x;
788 8699171 : tmp.temp_slot = NULL;
789 8699171 : tmp.hash = temp_slot_address_compute_hash (&tmp);
790 8699171 : t = temp_slot_address_table->find_with_hash (&tmp, tmp.hash);
791 8699171 : if (t)
792 1264 : return t->temp_slot;
793 :
794 : /* If we have a sum involving a register, see if it points to a temp
795 : slot. */
796 1522872 : if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0))
797 9877352 : && (p = find_temp_slot_from_address (XEXP (x, 0))) != 0)
798 : return p;
799 1522872 : else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 1))
800 8909940 : && (p = find_temp_slot_from_address (XEXP (x, 1))) != 0)
801 : return p;
802 :
803 : /* Last resort: Address is a virtual stack var address. */
804 8697907 : poly_int64 offset;
805 8697907 : if (strip_offset (x, &offset) == virtual_stack_vars_rtx)
806 : {
807 1329282 : int i;
808 5798372 : for (i = max_slot_level (); i >= 0; i--)
809 3196637 : for (p = *temp_slots_at_level (i); p; p = p->next)
810 3056 : if (known_in_range_p (offset, p->base_offset, p->full_size))
811 : return p;
812 : }
813 :
814 : return NULL;
815 : }
816 :
817 : /* Allocate a temporary stack slot and record it for possible later
818 : reuse.
819 :
820 : MODE is the machine mode to be given to the returned rtx.
821 :
822 : SIZE is the size in units of the space required. We do no rounding here
823 : since assign_stack_local will do any required rounding.
824 :
825 : TYPE is the type that will be used for the stack slot. */
826 :
827 : rtx
828 147704 : assign_stack_temp_for_type (machine_mode mode, poly_int64 size, tree type)
829 : {
830 147704 : unsigned int align;
831 147704 : class temp_slot *p, *best_p = 0, *selected = NULL, **pp;
832 147704 : rtx slot;
833 :
834 147704 : gcc_assert (known_size_p (size));
835 :
836 147704 : align = get_stack_local_alignment (type, mode);
837 :
838 : /* Try to find an available, already-allocated temporary of the proper
839 : mode which meets the size and alignment requirements. Choose the
840 : smallest one with the closest alignment.
841 :
842 : If assign_stack_temp is called outside of the tree->rtl expansion,
843 : we cannot reuse the stack slots (that may still refer to
844 : VIRTUAL_STACK_VARS_REGNUM). */
845 147704 : if (!virtuals_instantiated)
846 : {
847 11107683 : for (p = avail_temp_slots; p; p = p->next)
848 : {
849 11010637 : if (p->align >= align
850 10450989 : && known_ge (p->size, size)
851 10434051 : && GET_MODE (p->slot) == mode
852 10297346 : && objects_must_conflict_p (p->type, type)
853 11074754 : && (best_p == 0
854 228 : || (known_eq (best_p->size, p->size)
855 126 : ? best_p->align > p->align
856 102 : : known_ge (best_p->size, p->size))))
857 : {
858 63971 : if (p->align == align && known_eq (p->size, size))
859 : {
860 50658 : selected = p;
861 50658 : cut_slot_from_list (selected, &avail_temp_slots);
862 50658 : best_p = 0;
863 50658 : break;
864 : }
865 : best_p = p;
866 : }
867 : }
868 : }
869 :
870 : /* Make our best, if any, the one to use. */
871 147704 : if (best_p)
872 : {
873 13231 : selected = best_p;
874 13231 : cut_slot_from_list (selected, &avail_temp_slots);
875 :
876 : /* If there are enough aligned bytes left over, make them into a new
877 : temp_slot so that the extra bytes don't get wasted. Do this only
878 : for BLKmode slots, so that we can be sure of the alignment. */
879 13231 : if (GET_MODE (best_p->slot) == BLKmode)
880 : {
881 10910 : int alignment = best_p->align / BITS_PER_UNIT;
882 10910 : poly_int64 rounded_size = aligned_upper_bound (size, alignment);
883 :
884 10910 : if (known_ge (best_p->size - rounded_size, alignment))
885 : {
886 621 : p = ggc_alloc<temp_slot> ();
887 621 : p->in_use = false;
888 621 : p->size = best_p->size - rounded_size;
889 621 : p->base_offset = best_p->base_offset + rounded_size;
890 621 : p->full_size = best_p->full_size - rounded_size;
891 621 : p->slot = adjust_address_nv (best_p->slot, BLKmode, rounded_size);
892 621 : p->align = best_p->align;
893 621 : p->type = best_p->type;
894 621 : insert_slot_to_list (p, &avail_temp_slots);
895 :
896 621 : vec_safe_push (stack_slot_list, p->slot);
897 :
898 621 : best_p->size = rounded_size;
899 621 : best_p->full_size = rounded_size;
900 : }
901 : }
902 : }
903 :
904 : /* If we still didn't find one, make a new temporary. */
905 145383 : if (selected == 0)
906 : {
907 83815 : poly_int64 frame_offset_old = frame_offset;
908 :
909 83815 : p = ggc_alloc<temp_slot> ();
910 :
911 : /* We are passing an explicit alignment request to assign_stack_local.
912 : One side effect of that is assign_stack_local will not round SIZE
913 : to ensure the frame offset remains suitably aligned.
914 :
915 : So for requests which depended on the rounding of SIZE, we go ahead
916 : and round it now. We also make sure ALIGNMENT is at least
917 : BIGGEST_ALIGNMENT. */
918 93685 : gcc_assert (mode != BLKmode || align == BIGGEST_ALIGNMENT);
919 83815 : p->slot = assign_stack_local_1 (mode,
920 : (mode == BLKmode
921 9963 : ? aligned_upper_bound (size,
922 : (int) align
923 : / BITS_PER_UNIT)
924 : : size),
925 : align, 0);
926 :
927 83815 : p->align = align;
928 :
929 : /* The following slot size computation is necessary because we don't
930 : know the actual size of the temporary slot until assign_stack_local
931 : has performed all the frame alignment and size rounding for the
932 : requested temporary. Note that extra space added for alignment
933 : can be either above or below this stack slot depending on which
934 : way the frame grows. We include the extra space if and only if it
935 : is above this slot. */
936 83815 : if (FRAME_GROWS_DOWNWARD)
937 83815 : p->size = frame_offset_old - frame_offset;
938 : else
939 : p->size = size;
940 :
941 : /* Now define the fields used by combine_temp_slots. */
942 83815 : if (FRAME_GROWS_DOWNWARD)
943 : {
944 83815 : p->base_offset = frame_offset;
945 83815 : p->full_size = frame_offset_old - frame_offset;
946 : }
947 : else
948 : {
949 : p->base_offset = frame_offset_old;
950 : p->full_size = frame_offset - frame_offset_old;
951 : }
952 :
953 83815 : selected = p;
954 : }
955 :
956 147704 : p = selected;
957 147704 : p->in_use = true;
958 147704 : p->type = type;
959 147704 : p->level = temp_slot_level;
960 147704 : n_temp_slots_in_use++;
961 :
962 147704 : pp = temp_slots_at_level (p->level);
963 147704 : insert_slot_to_list (p, pp);
964 147704 : insert_temp_slot_address (XEXP (p->slot, 0), p);
965 :
966 : /* Create a new MEM rtx to avoid clobbering MEM flags of old slots. */
967 147704 : slot = gen_rtx_MEM (mode, XEXP (p->slot, 0));
968 147704 : vec_safe_push (stack_slot_list, slot);
969 :
970 : /* If we know the alias set for the memory that will be used, use
971 : it. If there's no TYPE, then we don't know anything about the
972 : alias set for the memory. */
973 147704 : set_mem_alias_set (slot, type ? get_alias_set (type) : 0);
974 147704 : set_mem_align (slot, align);
975 :
976 : /* If a type is specified, set the relevant flags. */
977 147704 : if (type != 0)
978 98342 : MEM_VOLATILE_P (slot) = TYPE_VOLATILE (type);
979 147704 : MEM_NOTRAP_P (slot) = 1;
980 :
981 147704 : return slot;
982 : }
983 :
984 : /* Allocate a temporary stack slot and record it for possible later
985 : reuse. First two arguments are same as in preceding function. */
986 :
987 : rtx
988 49362 : assign_stack_temp (machine_mode mode, poly_int64 size)
989 : {
990 49362 : return assign_stack_temp_for_type (mode, size, NULL_TREE);
991 : }
992 :
993 : /* Assign a temporary.
994 : If TYPE_OR_DECL is a decl, then we are doing it on behalf of the decl
995 : and so that should be used in error messages. In either case, we
996 : allocate of the given type.
997 : MEMORY_REQUIRED is 1 if the result must be addressable stack memory;
998 : it is 0 if a register is OK.
999 : DONT_PROMOTE is 1 if we should not promote values in register
1000 : to wider modes. */
1001 :
1002 : rtx
1003 1002286 : assign_temp (tree type_or_decl, int memory_required,
1004 : int dont_promote ATTRIBUTE_UNUSED)
1005 : {
1006 1002286 : tree type, decl;
1007 1002286 : machine_mode mode;
1008 : #ifdef PROMOTE_MODE
1009 1002286 : int unsignedp;
1010 : #endif
1011 :
1012 1002286 : if (DECL_P (type_or_decl))
1013 0 : decl = type_or_decl, type = TREE_TYPE (decl);
1014 : else
1015 : decl = NULL, type = type_or_decl;
1016 :
1017 1002286 : mode = TYPE_MODE (type);
1018 : #ifdef PROMOTE_MODE
1019 1002286 : unsignedp = TYPE_UNSIGNED (type);
1020 : #endif
1021 :
1022 : /* Allocating temporaries of TREE_ADDRESSABLE type must be done in the front
1023 : end. See also create_tmp_var for the gimplification-time check. */
1024 1002286 : gcc_assert (!TREE_ADDRESSABLE (type) && COMPLETE_TYPE_P (type));
1025 :
1026 1002286 : if (mode == BLKmode || memory_required)
1027 : {
1028 92751 : poly_int64 size;
1029 92751 : rtx tmp;
1030 :
1031 : /* Unfortunately, we don't yet know how to allocate variable-sized
1032 : temporaries. However, sometimes we can find a fixed upper limit on
1033 : the size, so try that instead. */
1034 92751 : if (!poly_int_tree_p (TYPE_SIZE_UNIT (type), &size))
1035 0 : size = max_int_size_in_bytes (type);
1036 :
1037 : /* Zero sized arrays are a GNU C extension. Set size to 1 to avoid
1038 : problems with allocating the stack space. */
1039 92751 : if (known_eq (size, 0))
1040 0 : size = 1;
1041 :
1042 : /* The size of the temporary may be too large to fit into an integer. */
1043 : /* ??? Not sure this should happen except for user silliness, so limit
1044 : this to things that aren't compiler-generated temporaries. The
1045 : rest of the time we'll die in assign_stack_temp_for_type. */
1046 92751 : if (decl
1047 0 : && !known_size_p (size)
1048 92751 : && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST)
1049 : {
1050 0 : error ("size of variable %q+D is too large", decl);
1051 0 : size = 1;
1052 : }
1053 :
1054 92751 : tmp = assign_stack_temp_for_type (mode, size, type);
1055 92751 : return tmp;
1056 : }
1057 :
1058 : #ifdef PROMOTE_MODE
1059 909535 : if (! dont_promote)
1060 0 : mode = promote_mode (type, mode, &unsignedp);
1061 : #endif
1062 :
1063 909535 : return gen_reg_rtx (mode);
1064 : }
1065 :
1066 : /* Combine temporary stack slots which are adjacent on the stack.
1067 :
1068 : This allows for better use of already allocated stack space. This is only
1069 : done for BLKmode slots because we can be sure that we won't have alignment
1070 : problems in this case. */
1071 :
1072 : static void
1073 139732 : combine_temp_slots (void)
1074 : {
1075 139732 : class temp_slot *p, *q, *next, *next_q;
1076 139732 : int num_slots;
1077 :
1078 : /* We can't combine slots, because the information about which slot
1079 : is in which alias set will be lost. */
1080 139732 : if (flag_strict_aliasing)
1081 : return;
1082 :
1083 : /* If there are a lot of temp slots, don't do anything unless
1084 : high levels of optimization. */
1085 96810 : if (! flag_expensive_optimizations)
1086 428125 : for (p = avail_temp_slots, num_slots = 0; p; p = p->next, num_slots++)
1087 418975 : if (num_slots > 100 || (num_slots > 10 && optimize == 0))
1088 : return;
1089 :
1090 269182 : for (p = avail_temp_slots; p; p = next)
1091 : {
1092 184900 : int delete_p = 0;
1093 :
1094 184900 : next = p->next;
1095 :
1096 184900 : if (GET_MODE (p->slot) != BLKmode)
1097 161256 : continue;
1098 :
1099 29446 : for (q = p->next; q; q = next_q)
1100 : {
1101 5812 : int delete_q = 0;
1102 :
1103 5812 : next_q = q->next;
1104 :
1105 5812 : if (GET_MODE (q->slot) != BLKmode)
1106 5052 : continue;
1107 :
1108 760 : if (known_eq (p->base_offset + p->full_size, q->base_offset))
1109 : {
1110 : /* Q comes after P; combine Q into P. */
1111 687 : p->size += q->size;
1112 29446 : p->full_size += q->full_size;
1113 : delete_q = 1;
1114 : }
1115 73 : else if (known_eq (q->base_offset + q->full_size, p->base_offset))
1116 : {
1117 : /* P comes after Q; combine P into Q. */
1118 10 : q->size += p->size;
1119 10 : q->full_size += p->full_size;
1120 : delete_p = 1;
1121 : break;
1122 : }
1123 687 : if (delete_q)
1124 1374 : cut_slot_from_list (q, &avail_temp_slots);
1125 : }
1126 :
1127 : /* Either delete P or advance past it. */
1128 23644 : if (delete_p)
1129 20 : cut_slot_from_list (p, &avail_temp_slots);
1130 : }
1131 : }
1132 :
1133 : /* Indicate that NEW_RTX is an alternate way of referring to the temp
1134 : slot that previously was known by OLD_RTX. */
1135 :
1136 : void
1137 16379772 : update_temp_slot_address (rtx old_rtx, rtx new_rtx)
1138 : {
1139 17205659 : class temp_slot *p;
1140 :
1141 17205659 : if (rtx_equal_p (old_rtx, new_rtx))
1142 : return;
1143 :
1144 4886193 : p = find_temp_slot_from_address (old_rtx);
1145 :
1146 : /* If we didn't find one, see if both OLD_RTX is a PLUS. If so, and
1147 : NEW_RTX is a register, see if one operand of the PLUS is a
1148 : temporary location. If so, NEW_RTX points into it. Otherwise,
1149 : if both OLD_RTX and NEW_RTX are a PLUS and if there is a register
1150 : in common between them. If so, try a recursive call on those
1151 : values. */
1152 4886193 : if (p == 0)
1153 : {
1154 4886155 : if (GET_CODE (old_rtx) != PLUS)
1155 : return;
1156 :
1157 907215 : if (REG_P (new_rtx))
1158 : {
1159 290204 : update_temp_slot_address (XEXP (old_rtx, 0), new_rtx);
1160 290204 : update_temp_slot_address (XEXP (old_rtx, 1), new_rtx);
1161 290204 : return;
1162 : }
1163 617011 : else if (GET_CODE (new_rtx) != PLUS)
1164 : return;
1165 :
1166 617011 : if (rtx_equal_p (XEXP (old_rtx, 0), XEXP (new_rtx, 0)))
1167 319155 : update_temp_slot_address (XEXP (old_rtx, 1), XEXP (new_rtx, 1));
1168 297856 : else if (rtx_equal_p (XEXP (old_rtx, 1), XEXP (new_rtx, 0)))
1169 0 : update_temp_slot_address (XEXP (old_rtx, 0), XEXP (new_rtx, 1));
1170 297856 : else if (rtx_equal_p (XEXP (old_rtx, 0), XEXP (new_rtx, 1)))
1171 32242 : update_temp_slot_address (XEXP (old_rtx, 1), XEXP (new_rtx, 0));
1172 265614 : else if (rtx_equal_p (XEXP (old_rtx, 1), XEXP (new_rtx, 1)))
1173 184286 : update_temp_slot_address (XEXP (old_rtx, 0), XEXP (new_rtx, 0));
1174 :
1175 : return;
1176 : }
1177 :
1178 : /* Otherwise add an alias for the temp's address. */
1179 38 : insert_temp_slot_address (new_rtx, p);
1180 : }
1181 :
1182 : /* If X could be a reference to a temporary slot, mark that slot as
1183 : belonging to the to one level higher than the current level. If X
1184 : matched one of our slots, just mark that one. Otherwise, we can't
1185 : easily predict which it is, so upgrade all of them.
1186 :
1187 : This is called when an ({...}) construct occurs and a statement
1188 : returns a value in memory. */
1189 :
1190 : void
1191 23975484 : preserve_temp_slots (rtx x)
1192 : {
1193 23975484 : class temp_slot *p = 0, *next;
1194 :
1195 23975484 : if (x == 0)
1196 : return;
1197 :
1198 : /* If X is a register that is being used as a pointer, see if we have
1199 : a temporary slot we know it points to. */
1200 10697453 : if (REG_P (x) && REG_POINTER (x))
1201 1748206 : p = find_temp_slot_from_address (x);
1202 :
1203 : /* If X is not in memory or is at a constant address, it cannot be in
1204 : a temporary slot. */
1205 10697453 : if (p == 0 && (!MEM_P (x) || CONSTANT_P (XEXP (x, 0))))
1206 : return;
1207 :
1208 : /* First see if we can find a match. */
1209 673294 : if (p == 0)
1210 673294 : p = find_temp_slot_from_address (XEXP (x, 0));
1211 :
1212 673294 : if (p != 0)
1213 : {
1214 1226 : if (p->level == temp_slot_level)
1215 1226 : move_slot_to_level (p, temp_slot_level - 1);
1216 1226 : return;
1217 : }
1218 :
1219 : /* Otherwise, preserve all non-kept slots at this level. */
1220 672074 : for (p = *temp_slots_at_level (temp_slot_level); p; p = next)
1221 : {
1222 6 : next = p->next;
1223 6 : move_slot_to_level (p, temp_slot_level - 1);
1224 : }
1225 : }
1226 :
1227 : /* Free all temporaries used so far. This is normally called at the
1228 : end of generating code for a statement. */
1229 :
1230 : void
1231 61896022 : free_temp_slots (void)
1232 : {
1233 61896022 : class temp_slot *p, *next;
1234 61896022 : bool some_available = false;
1235 :
1236 62043182 : for (p = *temp_slots_at_level (temp_slot_level); p; p = next)
1237 : {
1238 147160 : next = p->next;
1239 147160 : make_slot_available (p);
1240 147160 : some_available = true;
1241 : }
1242 :
1243 61896022 : if (some_available)
1244 : {
1245 139732 : remove_unused_temp_slot_addresses ();
1246 139732 : combine_temp_slots ();
1247 : }
1248 61896022 : }
1249 :
1250 : /* Push deeper into the nesting level for stack temporaries. */
1251 :
1252 : void
1253 30303311 : push_temp_slots (void)
1254 : {
1255 30303311 : temp_slot_level++;
1256 30303311 : }
1257 :
1258 : /* Pop a temporary nesting level. All slots in use in the current level
1259 : are freed. */
1260 :
1261 : void
1262 30303309 : pop_temp_slots (void)
1263 : {
1264 30303309 : free_temp_slots ();
1265 30303309 : temp_slot_level--;
1266 30303309 : }
1267 :
1268 : /* Initialize temporary slots. */
1269 :
1270 : void
1271 3186104 : init_temp_slots (void)
1272 : {
1273 : /* We have not allocated any temporaries yet. */
1274 3186104 : avail_temp_slots = 0;
1275 3186104 : vec_alloc (used_temp_slots, 0);
1276 3186104 : temp_slot_level = 0;
1277 3186104 : n_temp_slots_in_use = 0;
1278 :
1279 : /* Set up the table to map addresses to temp slots. */
1280 3186104 : if (! temp_slot_address_table)
1281 211764 : temp_slot_address_table = hash_table<temp_address_hasher>::create_ggc (32);
1282 : else
1283 2974340 : temp_slot_address_table->empty ();
1284 3186104 : }
1285 :
1286 : /* Functions and data structures to keep track of the values hard regs
1287 : had at the start of the function. */
1288 :
1289 : /* Private type used by get_hard_reg_initial_reg, get_hard_reg_initial_val,
1290 : and has_hard_reg_initial_val.. */
1291 : struct GTY(()) initial_value_pair {
1292 : rtx hard_reg;
1293 : rtx pseudo;
1294 : };
1295 : /* ??? This could be a VEC but there is currently no way to define an
1296 : opaque VEC type. This could be worked around by defining struct
1297 : initial_value_pair in function.h. */
1298 : struct GTY(()) initial_value_struct {
1299 : int num_entries;
1300 : int max_entries;
1301 : initial_value_pair * GTY ((length ("%h.num_entries"))) entries;
1302 : };
1303 :
1304 : /* If a pseudo represents an initial hard reg (or expression), return
1305 : it, else return NULL_RTX. */
1306 :
1307 : rtx
1308 0 : get_hard_reg_initial_reg (rtx reg)
1309 : {
1310 0 : struct initial_value_struct *ivs = crtl->hard_reg_initial_vals;
1311 0 : int i;
1312 :
1313 0 : if (ivs == 0)
1314 : return NULL_RTX;
1315 :
1316 0 : for (i = 0; i < ivs->num_entries; i++)
1317 0 : if (rtx_equal_p (ivs->entries[i].pseudo, reg))
1318 0 : return ivs->entries[i].hard_reg;
1319 :
1320 : return NULL_RTX;
1321 : }
1322 :
1323 : /* Make sure that there's a pseudo register of mode MODE that stores the
1324 : initial value of hard register REGNO. Return an rtx for such a pseudo. */
1325 :
1326 : rtx
1327 0 : get_hard_reg_initial_val (machine_mode mode, unsigned int regno)
1328 : {
1329 0 : struct initial_value_struct *ivs;
1330 0 : rtx rv;
1331 :
1332 0 : rv = has_hard_reg_initial_val (mode, regno);
1333 0 : if (rv)
1334 : return rv;
1335 :
1336 0 : ivs = crtl->hard_reg_initial_vals;
1337 0 : if (ivs == 0)
1338 : {
1339 0 : ivs = ggc_alloc<initial_value_struct> ();
1340 0 : ivs->num_entries = 0;
1341 0 : ivs->max_entries = 5;
1342 0 : ivs->entries = ggc_vec_alloc<initial_value_pair> (5);
1343 0 : crtl->hard_reg_initial_vals = ivs;
1344 : }
1345 :
1346 0 : if (ivs->num_entries >= ivs->max_entries)
1347 : {
1348 0 : ivs->max_entries += 5;
1349 0 : ivs->entries = GGC_RESIZEVEC (initial_value_pair, ivs->entries,
1350 : ivs->max_entries);
1351 : }
1352 :
1353 0 : ivs->entries[ivs->num_entries].hard_reg = gen_rtx_REG (mode, regno);
1354 0 : ivs->entries[ivs->num_entries].pseudo = gen_reg_rtx (mode);
1355 :
1356 0 : return ivs->entries[ivs->num_entries++].pseudo;
1357 : }
1358 :
1359 : /* See if get_hard_reg_initial_val has been used to create a pseudo
1360 : for the initial value of hard register REGNO in mode MODE. Return
1361 : the associated pseudo if so, otherwise return NULL. */
1362 :
1363 : rtx
1364 0 : has_hard_reg_initial_val (machine_mode mode, unsigned int regno)
1365 : {
1366 0 : struct initial_value_struct *ivs;
1367 0 : int i;
1368 :
1369 0 : ivs = crtl->hard_reg_initial_vals;
1370 0 : if (ivs != 0)
1371 0 : for (i = 0; i < ivs->num_entries; i++)
1372 0 : if (GET_MODE (ivs->entries[i].hard_reg) == mode
1373 0 : && REGNO (ivs->entries[i].hard_reg) == regno)
1374 0 : return ivs->entries[i].pseudo;
1375 :
1376 : return NULL_RTX;
1377 : }
1378 :
1379 : void
1380 1482261 : emit_initial_value_sets (void)
1381 : {
1382 1482261 : struct initial_value_struct *ivs = crtl->hard_reg_initial_vals;
1383 1482261 : int i;
1384 1482261 : rtx_insn *seq;
1385 :
1386 1482261 : if (ivs == 0)
1387 : return;
1388 :
1389 0 : start_sequence ();
1390 0 : for (i = 0; i < ivs->num_entries; i++)
1391 0 : emit_move_insn (ivs->entries[i].pseudo, ivs->entries[i].hard_reg);
1392 0 : seq = end_sequence ();
1393 :
1394 0 : emit_insn_at_entry (seq);
1395 : }
1396 :
1397 : /* Return the hardreg-pseudoreg initial values pair entry I and
1398 : TRUE if I is a valid entry, or FALSE if I is not a valid entry. */
1399 : bool
1400 0 : initial_value_entry (int i, rtx *hreg, rtx *preg)
1401 : {
1402 0 : struct initial_value_struct *ivs = crtl->hard_reg_initial_vals;
1403 0 : if (!ivs || i >= ivs->num_entries)
1404 : return false;
1405 :
1406 0 : *hreg = ivs->entries[i].hard_reg;
1407 0 : *preg = ivs->entries[i].pseudo;
1408 0 : return true;
1409 : }
1410 :
1411 : /* These routines are responsible for converting virtual register references
1412 : to the actual hard register references once RTL generation is complete.
1413 :
1414 : The following four variables are used for communication between the
1415 : routines. They contain the offsets of the virtual registers from their
1416 : respective hard registers. */
1417 :
1418 : static poly_int64 in_arg_offset;
1419 : static poly_int64 var_offset;
1420 : static poly_int64 dynamic_offset;
1421 : static poly_int64 out_arg_offset;
1422 : static poly_int64 cfa_offset;
1423 :
1424 : /* In most machines, the stack pointer register is equivalent to the bottom
1425 : of the stack. */
1426 :
1427 : #ifndef STACK_POINTER_OFFSET
1428 : #define STACK_POINTER_OFFSET 0
1429 : #endif
1430 :
1431 : #if defined (REG_PARM_STACK_SPACE) && !defined (INCOMING_REG_PARM_STACK_SPACE)
1432 : #define INCOMING_REG_PARM_STACK_SPACE REG_PARM_STACK_SPACE
1433 : #endif
1434 :
1435 : /* If not defined, pick an appropriate default for the offset of dynamically
1436 : allocated memory depending on the value of ACCUMULATE_OUTGOING_ARGS,
1437 : INCOMING_REG_PARM_STACK_SPACE, and OUTGOING_REG_PARM_STACK_SPACE. */
1438 :
1439 : #ifndef STACK_DYNAMIC_OFFSET
1440 :
1441 : /* The bottom of the stack points to the actual arguments. If
1442 : REG_PARM_STACK_SPACE is defined, this includes the space for the register
1443 : parameters. However, if OUTGOING_REG_PARM_STACK space is not defined,
1444 : stack space for register parameters is not pushed by the caller, but
1445 : rather part of the fixed stack areas and hence not included in
1446 : `crtl->outgoing_args_size'. Nevertheless, we must allow
1447 : for it when allocating stack dynamic objects. */
1448 :
1449 : #ifdef INCOMING_REG_PARM_STACK_SPACE
1450 : #define STACK_DYNAMIC_OFFSET(FNDECL) \
1451 : ((ACCUMULATE_OUTGOING_ARGS \
1452 : ? (crtl->outgoing_args_size \
1453 : + (OUTGOING_REG_PARM_STACK_SPACE ((!(FNDECL) ? NULL_TREE : TREE_TYPE (FNDECL))) ? 0 \
1454 : : INCOMING_REG_PARM_STACK_SPACE (FNDECL))) \
1455 : : 0) + (STACK_POINTER_OFFSET))
1456 : #else
1457 : #define STACK_DYNAMIC_OFFSET(FNDECL) \
1458 : ((ACCUMULATE_OUTGOING_ARGS ? crtl->outgoing_args_size : poly_int64 (0)) \
1459 : + (STACK_POINTER_OFFSET))
1460 : #endif
1461 : #endif
1462 :
1463 :
1464 : /* Given a piece of RTX and a pointer to a HOST_WIDE_INT, if the RTX
1465 : is a virtual register, return the equivalent hard register and set the
1466 : offset indirectly through the pointer. Otherwise, return 0. */
1467 :
1468 : static rtx
1469 364325543 : instantiate_new_reg (rtx x, poly_int64 *poffset)
1470 : {
1471 364325543 : rtx new_rtx;
1472 364325543 : poly_int64 offset;
1473 :
1474 364325543 : if (x == virtual_incoming_args_rtx)
1475 : {
1476 3753999 : if (stack_realign_drap)
1477 : {
1478 : /* Replace virtual_incoming_args_rtx with internal arg
1479 : pointer if DRAP is used to realign stack. */
1480 16469 : new_rtx = crtl->args.internal_arg_pointer;
1481 16469 : offset = 0;
1482 : }
1483 : else
1484 3737530 : new_rtx = arg_pointer_rtx, offset = in_arg_offset;
1485 : }
1486 360571544 : else if (x == virtual_stack_vars_rtx)
1487 18281530 : new_rtx = frame_pointer_rtx, offset = var_offset;
1488 342290014 : else if (x == virtual_stack_dynamic_rtx)
1489 52597 : new_rtx = stack_pointer_rtx, offset = dynamic_offset;
1490 342237417 : else if (x == virtual_outgoing_args_rtx)
1491 1568831 : new_rtx = stack_pointer_rtx, offset = out_arg_offset;
1492 340668586 : else if (x == virtual_cfa_rtx)
1493 : {
1494 : #ifdef FRAME_POINTER_CFA_OFFSET
1495 : new_rtx = frame_pointer_rtx;
1496 : #else
1497 1814 : new_rtx = arg_pointer_rtx;
1498 : #endif
1499 1814 : offset = cfa_offset;
1500 : }
1501 340666772 : else if (x == virtual_preferred_stack_boundary_rtx)
1502 : {
1503 111688 : new_rtx = GEN_INT (crtl->preferred_stack_boundary / BITS_PER_UNIT);
1504 111688 : offset = 0;
1505 : }
1506 : else
1507 : return NULL_RTX;
1508 :
1509 23770459 : *poffset = offset;
1510 23770459 : return new_rtx;
1511 : }
1512 :
1513 : /* A subroutine of instantiate_virtual_regs. Instantiate any virtual
1514 : registers present inside of *LOC. The expression is simplified,
1515 : as much as possible, but is not to be considered "valid" in any sense
1516 : implied by the target. Return true if any change is made. */
1517 :
1518 : static bool
1519 206230132 : instantiate_virtual_regs_in_rtx (rtx *loc)
1520 : {
1521 206230132 : if (!*loc)
1522 : return false;
1523 93155916 : bool changed = false;
1524 93155916 : subrtx_ptr_iterator::array_type array;
1525 348138725 : FOR_EACH_SUBRTX_PTR (iter, array, loc, NONCONST)
1526 : {
1527 254982809 : rtx *loc = *iter;
1528 254982809 : if (rtx x = *loc)
1529 : {
1530 231343164 : rtx new_rtx;
1531 231343164 : poly_int64 offset;
1532 231343164 : switch (GET_CODE (x))
1533 : {
1534 35548461 : case REG:
1535 35548461 : new_rtx = instantiate_new_reg (x, &offset);
1536 35548461 : if (new_rtx)
1537 : {
1538 1658058 : *loc = plus_constant (GET_MODE (x), new_rtx, offset);
1539 1658058 : changed = true;
1540 : }
1541 35548461 : iter.skip_subrtxes ();
1542 35548461 : break;
1543 :
1544 27961534 : case PLUS:
1545 27961534 : new_rtx = instantiate_new_reg (XEXP (x, 0), &offset);
1546 27961534 : if (new_rtx)
1547 : {
1548 19018157 : XEXP (x, 0) = new_rtx;
1549 19018157 : *loc = plus_constant (GET_MODE (x), x, offset, true);
1550 19018157 : changed = true;
1551 19018157 : iter.skip_subrtxes ();
1552 19018157 : break;
1553 : }
1554 :
1555 : /* FIXME -- from old code */
1556 : /* If we have (plus (subreg (virtual-reg)) (const_int)), we know
1557 : we can commute the PLUS and SUBREG because pointers into the
1558 : frame are well-behaved. */
1559 : break;
1560 :
1561 : default:
1562 : break;
1563 : }
1564 : }
1565 : }
1566 93155916 : return changed;
1567 93155916 : }
1568 :
1569 : /* A subroutine of instantiate_virtual_regs_in_insn. Return true if X
1570 : matches the predicate for insn CODE operand OPERAND. */
1571 :
1572 : static bool
1573 29861530 : safe_insn_predicate (int code, int operand, rtx x)
1574 : {
1575 29861530 : return code < 0 || insn_operand_matches ((enum insn_code) code, operand, x);
1576 : }
1577 :
1578 : /* A subroutine of instantiate_virtual_regs. Instantiate any virtual
1579 : registers present inside of insn. The result will be a valid insn. */
1580 :
1581 : static void
1582 92967088 : instantiate_virtual_regs_in_insn (rtx_insn *insn)
1583 : {
1584 92967088 : poly_int64 offset;
1585 92967088 : int insn_code, i;
1586 92967088 : bool any_change = false;
1587 92967088 : rtx set, new_rtx, x;
1588 92967088 : rtx_insn *seq;
1589 :
1590 : /* There are some special cases to be handled first. */
1591 92967088 : set = single_set (insn);
1592 92967088 : if (set)
1593 : {
1594 : /* We're allowed to assign to a virtual register. This is interpreted
1595 : to mean that the underlying register gets assigned the inverse
1596 : transformation. This is used, for example, in the handling of
1597 : non-local gotos. */
1598 88744010 : new_rtx = instantiate_new_reg (SET_DEST (set), &offset);
1599 88744010 : if (new_rtx)
1600 : {
1601 0 : start_sequence ();
1602 :
1603 0 : instantiate_virtual_regs_in_rtx (&SET_SRC (set));
1604 0 : x = simplify_gen_binary (PLUS, GET_MODE (new_rtx), SET_SRC (set),
1605 0 : gen_int_mode (-offset, GET_MODE (new_rtx)));
1606 0 : x = force_operand (x, new_rtx);
1607 0 : if (x != new_rtx)
1608 0 : emit_move_insn (new_rtx, x);
1609 :
1610 0 : seq = end_sequence ();
1611 :
1612 0 : emit_insn_before (seq, insn);
1613 0 : delete_insn (insn);
1614 18666 : return;
1615 : }
1616 :
1617 : /* Handle a straight copy from a virtual register by generating a
1618 : new add insn. The difference between this and falling through
1619 : to the generic case is avoiding a new pseudo and eliminating a
1620 : move insn in the initial rtl stream. */
1621 88744010 : new_rtx = instantiate_new_reg (SET_SRC (set), &offset);
1622 88744010 : if (new_rtx
1623 321830 : && maybe_ne (offset, 0)
1624 3841 : && REG_P (SET_DEST (set))
1625 88747851 : && REGNO (SET_DEST (set)) > LAST_VIRTUAL_REGISTER)
1626 : {
1627 3841 : start_sequence ();
1628 :
1629 3841 : x = expand_simple_binop (GET_MODE (SET_DEST (set)), PLUS, new_rtx,
1630 : gen_int_mode (offset,
1631 3841 : GET_MODE (SET_DEST (set))),
1632 : SET_DEST (set), 1, OPTAB_LIB_WIDEN);
1633 3841 : if (x != SET_DEST (set))
1634 0 : emit_move_insn (SET_DEST (set), x);
1635 :
1636 3841 : seq = end_sequence ();
1637 :
1638 3841 : emit_insn_before (seq, insn);
1639 3841 : delete_insn (insn);
1640 3841 : return;
1641 : }
1642 :
1643 88740169 : extract_insn (insn);
1644 88740169 : insn_code = INSN_CODE (insn);
1645 :
1646 : /* Handle a plus involving a virtual register by determining if the
1647 : operands remain valid if they're modified in place. */
1648 88740169 : poly_int64 delta;
1649 88740169 : if (GET_CODE (SET_SRC (set)) == PLUS
1650 10078314 : && recog_data.n_operands >= 3
1651 10013049 : && recog_data.operand_loc[1] == &XEXP (SET_SRC (set), 0)
1652 10012462 : && recog_data.operand_loc[2] == &XEXP (SET_SRC (set), 1)
1653 10012462 : && poly_int_rtx_p (recog_data.operand[2], &delta)
1654 96644601 : && (new_rtx = instantiate_new_reg (recog_data.operand[1], &offset)))
1655 : {
1656 2357982 : offset += delta;
1657 :
1658 : /* If the sum is zero, then replace with a plain move. */
1659 2357982 : if (known_eq (offset, 0)
1660 14825 : && REG_P (SET_DEST (set))
1661 2372807 : && REGNO (SET_DEST (set)) > LAST_VIRTUAL_REGISTER)
1662 : {
1663 14825 : start_sequence ();
1664 14825 : emit_move_insn (SET_DEST (set), new_rtx);
1665 14825 : seq = end_sequence ();
1666 :
1667 14825 : emit_insn_before (seq, insn);
1668 14825 : delete_insn (insn);
1669 14825 : return;
1670 : }
1671 :
1672 2343157 : x = gen_int_mode (offset, recog_data.operand_mode[2]);
1673 :
1674 : /* Using validate_change and apply_change_group here leaves
1675 : recog_data in an invalid state. Since we know exactly what
1676 : we want to check, do those two by hand. */
1677 2343157 : if (safe_insn_predicate (insn_code, 1, new_rtx)
1678 2343157 : && safe_insn_predicate (insn_code, 2, x))
1679 : {
1680 2315235 : *recog_data.operand_loc[1] = recog_data.operand[1] = new_rtx;
1681 2315235 : *recog_data.operand_loc[2] = recog_data.operand[2] = x;
1682 2315235 : any_change = true;
1683 :
1684 : /* Fall through into the regular operand fixup loop in
1685 : order to take care of operands other than 1 and 2. */
1686 : }
1687 : }
1688 : }
1689 : else
1690 : {
1691 4223078 : extract_insn (insn);
1692 4223078 : insn_code = INSN_CODE (insn);
1693 : }
1694 :
1695 : /* In the general case, we expect virtual registers to appear only in
1696 : operands, and then only as either bare registers or inside memories. */
1697 294458866 : for (i = 0; i < recog_data.n_operands; ++i)
1698 : {
1699 201510444 : x = recog_data.operand[i];
1700 201510444 : switch (GET_CODE (x))
1701 : {
1702 29098909 : case MEM:
1703 29098909 : {
1704 29098909 : rtx addr = XEXP (x, 0);
1705 :
1706 29098909 : if (!instantiate_virtual_regs_in_rtx (&addr))
1707 16704556 : continue;
1708 :
1709 12394353 : start_sequence ();
1710 12394353 : x = replace_equiv_address (x, addr, true);
1711 : /* It may happen that the address with the virtual reg
1712 : was valid (e.g. based on the virtual stack reg, which might
1713 : be acceptable to the predicates with all offsets), whereas
1714 : the address now isn't anymore, for instance when the address
1715 : is still offsetted, but the base reg isn't virtual-stack-reg
1716 : anymore. Below we would do a force_reg on the whole operand,
1717 : but this insn might actually only accept memory. Hence,
1718 : before doing that last resort, try to reload the address into
1719 : a register, so this operand stays a MEM. */
1720 12394353 : if (!safe_insn_predicate (insn_code, i, x))
1721 : {
1722 0 : addr = force_reg (GET_MODE (addr), addr);
1723 0 : x = replace_equiv_address (x, addr, true);
1724 : }
1725 12394353 : seq = end_sequence ();
1726 12394353 : if (seq)
1727 0 : emit_insn_before (seq, insn);
1728 : }
1729 12394353 : break;
1730 :
1731 112701970 : case REG:
1732 112701970 : new_rtx = instantiate_new_reg (x, &offset);
1733 112701970 : if (new_rtx == NULL)
1734 112287544 : continue;
1735 414426 : if (known_eq (offset, 0))
1736 : x = new_rtx;
1737 : else
1738 : {
1739 0 : start_sequence ();
1740 :
1741 : /* Careful, special mode predicates may have stuff in
1742 : insn_data[insn_code].operand[i].mode that isn't useful
1743 : to us for computing a new value. */
1744 : /* ??? Recognize address_operand and/or "p" constraints
1745 : to see if (plus new offset) is a valid before we put
1746 : this through expand_simple_binop. */
1747 0 : x = expand_simple_binop (GET_MODE (x), PLUS, new_rtx,
1748 0 : gen_int_mode (offset, GET_MODE (x)),
1749 : NULL_RTX, 1, OPTAB_LIB_WIDEN);
1750 0 : seq = end_sequence ();
1751 0 : emit_insn_before (seq, insn);
1752 : }
1753 : break;
1754 :
1755 2721126 : case SUBREG:
1756 2721126 : new_rtx = instantiate_new_reg (SUBREG_REG (x), &offset);
1757 2721126 : if (new_rtx == NULL)
1758 2721120 : continue;
1759 6 : start_sequence ();
1760 6 : if (maybe_ne (offset, 0))
1761 0 : new_rtx = expand_simple_binop
1762 0 : (GET_MODE (new_rtx), PLUS, new_rtx,
1763 0 : gen_int_mode (offset, GET_MODE (new_rtx)),
1764 : NULL_RTX, 1, OPTAB_LIB_WIDEN);
1765 12 : x = force_subreg (recog_data.operand_mode[i], new_rtx,
1766 6 : GET_MODE (new_rtx), SUBREG_BYTE (x));
1767 6 : gcc_assert (x);
1768 6 : seq = end_sequence ();
1769 6 : emit_insn_before (seq, insn);
1770 6 : break;
1771 :
1772 56988439 : default:
1773 56988439 : continue;
1774 56988439 : }
1775 :
1776 : /* At this point, X contains the new value for the operand.
1777 : Validate the new value vs the insn predicate. Note that
1778 : asm insns will have insn_code -1 here. */
1779 12808785 : if (!safe_insn_predicate (insn_code, i, x))
1780 : {
1781 55844 : start_sequence ();
1782 55844 : if (REG_P (x))
1783 : {
1784 0 : gcc_assert (REGNO (x) <= LAST_VIRTUAL_REGISTER);
1785 0 : x = copy_to_reg (x);
1786 : }
1787 : else
1788 55844 : x = force_reg (insn_data[insn_code].operand[i].mode, x);
1789 55844 : seq = end_sequence ();
1790 55844 : if (seq)
1791 55844 : emit_insn_before (seq, insn);
1792 : }
1793 :
1794 12808785 : *recog_data.operand_loc[i] = recog_data.operand[i] = x;
1795 12808785 : any_change = true;
1796 : }
1797 :
1798 92948422 : if (any_change)
1799 : {
1800 : /* Propagate operand changes into the duplicates. */
1801 15036024 : for (i = 0; i < recog_data.n_dups; ++i)
1802 86589 : *recog_data.dup_loc[i]
1803 86589 : = copy_rtx (recog_data.operand[(unsigned)recog_data.dup_num[i]]);
1804 :
1805 : /* Force re-recognition of the instruction for validation. */
1806 14949435 : INSN_CODE (insn) = -1;
1807 : }
1808 :
1809 92948422 : if (asm_noperands (PATTERN (insn)) >= 0)
1810 : {
1811 108209 : if (!check_asm_operands (PATTERN (insn)))
1812 : {
1813 23 : error_for_asm (insn, "impossible constraint in %<asm%>");
1814 : /* For asm goto, instead of fixing up all the edges
1815 : just clear the template and clear input and output operands
1816 : and strip away clobbers. */
1817 23 : if (JUMP_P (insn))
1818 : {
1819 14 : rtx asm_op = extract_asm_operands (PATTERN (insn));
1820 14 : PATTERN (insn) = asm_op;
1821 14 : PUT_MODE (asm_op, VOIDmode);
1822 14 : ASM_OPERANDS_TEMPLATE (asm_op) = ggc_strdup ("");
1823 14 : ASM_OPERANDS_OUTPUT_CONSTRAINT (asm_op) = "";
1824 14 : ASM_OPERANDS_OUTPUT_IDX (asm_op) = 0;
1825 14 : ASM_OPERANDS_INPUT_VEC (asm_op) = rtvec_alloc (0);
1826 14 : ASM_OPERANDS_INPUT_CONSTRAINT_VEC (asm_op) = rtvec_alloc (0);
1827 : }
1828 : else
1829 9 : delete_insn (insn);
1830 : }
1831 : }
1832 : else
1833 : {
1834 92840213 : if (recog_memoized (insn) < 0)
1835 0 : fatal_insn_not_found (insn);
1836 : }
1837 : }
1838 :
1839 : /* Subroutine of instantiate_decls. Given RTL representing a decl,
1840 : do any instantiation required. */
1841 :
1842 : void
1843 9615552 : instantiate_decl_rtl (rtx x)
1844 : {
1845 9621456 : rtx addr;
1846 :
1847 9621456 : if (x == 0)
1848 : return;
1849 :
1850 : /* If this is a CONCAT, recurse for the pieces. */
1851 9621456 : if (GET_CODE (x) == CONCAT)
1852 : {
1853 5904 : instantiate_decl_rtl (XEXP (x, 0));
1854 5904 : instantiate_decl_rtl (XEXP (x, 1));
1855 5904 : return;
1856 : }
1857 :
1858 : /* If this is not a MEM, no need to do anything. Similarly if the
1859 : address is a constant or a register that is not a virtual register. */
1860 9615552 : if (!MEM_P (x))
1861 : return;
1862 :
1863 3224547 : addr = XEXP (x, 0);
1864 3224547 : if (CONSTANT_P (addr)
1865 3224547 : || (REG_P (addr)
1866 303414 : && !VIRTUAL_REGISTER_P (addr)))
1867 : return;
1868 :
1869 3002935 : instantiate_virtual_regs_in_rtx (&XEXP (x, 0));
1870 : }
1871 :
1872 : /* Helper for instantiate_decls called via walk_tree: Process all decls
1873 : in the given DECL_VALUE_EXPR. */
1874 :
1875 : static tree
1876 1288337 : instantiate_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
1877 : {
1878 1288337 : tree t = *tp;
1879 1288337 : if (! EXPR_P (t))
1880 : {
1881 691121 : *walk_subtrees = 0;
1882 691121 : if (DECL_P (t))
1883 : {
1884 583281 : if (DECL_RTL_SET_P (t))
1885 171372 : instantiate_decl_rtl (DECL_RTL (t));
1886 136041 : if (TREE_CODE (t) == PARM_DECL && DECL_NAMELESS (t)
1887 695158 : && DECL_INCOMING_RTL (t))
1888 111877 : instantiate_decl_rtl (DECL_INCOMING_RTL (t));
1889 357070 : if ((VAR_P (t) || TREE_CODE (t) == RESULT_DECL)
1890 590691 : && DECL_HAS_VALUE_EXPR_P (t))
1891 : {
1892 7683 : tree v = DECL_VALUE_EXPR (t);
1893 7683 : walk_tree (&v, instantiate_expr, NULL, NULL);
1894 : }
1895 : }
1896 : }
1897 1288337 : return NULL;
1898 : }
1899 :
1900 : /* Subroutine of instantiate_decls: Process all decls in the given
1901 : BLOCK node and all its subblocks. */
1902 :
1903 : static void
1904 16379197 : instantiate_decls_1 (tree let)
1905 : {
1906 16379197 : tree t;
1907 :
1908 35471789 : for (t = BLOCK_VARS (let); t; t = DECL_CHAIN (t))
1909 : {
1910 19092592 : if (DECL_RTL_SET_P (t))
1911 2276923 : instantiate_decl_rtl (DECL_RTL (t));
1912 19092592 : if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
1913 : {
1914 303400 : tree v = DECL_VALUE_EXPR (t);
1915 303400 : walk_tree (&v, instantiate_expr, NULL, NULL);
1916 : }
1917 : }
1918 :
1919 : /* Process all subblocks. */
1920 31276916 : for (t = BLOCK_SUBBLOCKS (let); t; t = BLOCK_CHAIN (t))
1921 14897719 : instantiate_decls_1 (t);
1922 16379197 : }
1923 :
1924 : /* Scan all decls in FNDECL (both variables and parameters) and instantiate
1925 : all virtual registers in their DECL_RTL's. */
1926 :
1927 : static void
1928 1481478 : instantiate_decls (tree fndecl)
1929 : {
1930 1481478 : tree decl;
1931 1481478 : unsigned ix;
1932 :
1933 : /* Process all parameters of the function. */
1934 4597202 : for (decl = DECL_ARGUMENTS (fndecl); decl; decl = DECL_CHAIN (decl))
1935 : {
1936 3115724 : instantiate_decl_rtl (DECL_RTL (decl));
1937 3115724 : instantiate_decl_rtl (DECL_INCOMING_RTL (decl));
1938 3115724 : if (DECL_HAS_VALUE_EXPR_P (decl))
1939 : {
1940 127 : tree v = DECL_VALUE_EXPR (decl);
1941 127 : walk_tree (&v, instantiate_expr, NULL, NULL);
1942 : }
1943 : }
1944 :
1945 1481478 : if ((decl = DECL_RESULT (fndecl))
1946 1481478 : && TREE_CODE (decl) == RESULT_DECL)
1947 : {
1948 1481478 : if (DECL_RTL_SET_P (decl))
1949 789046 : instantiate_decl_rtl (DECL_RTL (decl));
1950 1481478 : if (DECL_HAS_VALUE_EXPR_P (decl))
1951 : {
1952 69596 : tree v = DECL_VALUE_EXPR (decl);
1953 69596 : walk_tree (&v, instantiate_expr, NULL, NULL);
1954 : }
1955 : }
1956 :
1957 : /* Process the saved static chain if it exists. */
1958 1481478 : decl = DECL_STRUCT_FUNCTION (fndecl)->static_chain_decl;
1959 1481478 : if (decl && DECL_HAS_VALUE_EXPR_P (decl))
1960 3950 : instantiate_decl_rtl (DECL_RTL (DECL_VALUE_EXPR (decl)));
1961 :
1962 : /* Now process all variables defined in the function or its subblocks. */
1963 1481478 : if (DECL_INITIAL (fndecl))
1964 1481478 : instantiate_decls_1 (DECL_INITIAL (fndecl));
1965 :
1966 2787785 : FOR_EACH_LOCAL_DECL (cfun, ix, decl)
1967 65382 : if (DECL_RTL_SET_P (decl))
1968 25032 : instantiate_decl_rtl (DECL_RTL (decl));
1969 1481478 : vec_free (cfun->local_decls);
1970 1481478 : }
1971 :
1972 : /* Return the value of STACK_DYNAMIC_OFFSET for the current function.
1973 : This is done through a function wrapper so that the macro sees a
1974 : predictable set of included files. */
1975 :
1976 : poly_int64
1977 1481478 : get_stack_dynamic_offset ()
1978 : {
1979 1481478 : return STACK_DYNAMIC_OFFSET (current_function_decl);
1980 : }
1981 :
1982 : /* Pass through the INSNS of function FNDECL and convert virtual register
1983 : references to hard register references. */
1984 :
1985 : static void
1986 1481478 : instantiate_virtual_regs (void)
1987 : {
1988 1481478 : rtx_insn *insn;
1989 :
1990 : /* Compute the offsets to use for this function. */
1991 1481478 : in_arg_offset = FIRST_PARM_OFFSET (current_function_decl);
1992 1481478 : var_offset = targetm.starting_frame_offset ();
1993 1481478 : dynamic_offset = get_stack_dynamic_offset ();
1994 1481478 : out_arg_offset = STACK_POINTER_OFFSET;
1995 : #ifdef FRAME_POINTER_CFA_OFFSET
1996 : cfa_offset = FRAME_POINTER_CFA_OFFSET (current_function_decl);
1997 : #else
1998 1481478 : cfa_offset = ARG_POINTER_CFA_OFFSET (current_function_decl);
1999 : #endif
2000 :
2001 : /* Initialize recognition, indicating that volatile is OK. */
2002 1481478 : init_recog ();
2003 :
2004 : /* Scan through all the insns, instantiating every virtual register still
2005 : present. */
2006 173073508 : for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2007 171592030 : if (INSN_P (insn))
2008 : {
2009 : /* These patterns in the instruction stream can never be recognized.
2010 : Fortunately, they shouldn't contain virtual registers either. */
2011 154709407 : if (GET_CODE (PATTERN (insn)) == USE
2012 141875189 : || GET_CODE (PATTERN (insn)) == CLOBBER
2013 141703306 : || GET_CODE (PATTERN (insn)) == ASM_INPUT
2014 284338994 : || DEBUG_MARKER_INSN_P (insn))
2015 12071835 : continue;
2016 130565737 : else if (DEBUG_BIND_INSN_P (insn))
2017 37598649 : instantiate_virtual_regs_in_rtx (INSN_VAR_LOCATION_PTR (insn));
2018 : else
2019 92967088 : instantiate_virtual_regs_in_insn (insn);
2020 :
2021 130565737 : if (insn->deleted ())
2022 18675 : continue;
2023 :
2024 130547062 : instantiate_virtual_regs_in_rtx (®_NOTES (insn));
2025 :
2026 : /* Instantiate any virtual registers in CALL_INSN_FUNCTION_USAGE. */
2027 130547062 : if (CALL_P (insn))
2028 5982577 : instantiate_virtual_regs_in_rtx (&CALL_INSN_FUNCTION_USAGE (insn));
2029 : }
2030 :
2031 : /* Instantiate the virtual registers in the DECLs for debugging purposes. */
2032 1481478 : instantiate_decls (current_function_decl);
2033 :
2034 1481478 : targetm.instantiate_decls ();
2035 :
2036 : /* Indicate that, from now on, assign_stack_local should use
2037 : frame_pointer_rtx. */
2038 1481478 : virtuals_instantiated = 1;
2039 1481478 : }
2040 :
2041 : namespace {
2042 :
2043 : const pass_data pass_data_instantiate_virtual_regs =
2044 : {
2045 : RTL_PASS, /* type */
2046 : "vregs", /* name */
2047 : OPTGROUP_NONE, /* optinfo_flags */
2048 : TV_NONE, /* tv_id */
2049 : 0, /* properties_required */
2050 : 0, /* properties_provided */
2051 : 0, /* properties_destroyed */
2052 : 0, /* todo_flags_start */
2053 : 0, /* todo_flags_finish */
2054 : };
2055 :
2056 : class pass_instantiate_virtual_regs : public rtl_opt_pass
2057 : {
2058 : public:
2059 288767 : pass_instantiate_virtual_regs (gcc::context *ctxt)
2060 577534 : : rtl_opt_pass (pass_data_instantiate_virtual_regs, ctxt)
2061 : {}
2062 :
2063 : /* opt_pass methods: */
2064 1481478 : unsigned int execute (function *) final override
2065 : {
2066 1481478 : instantiate_virtual_regs ();
2067 1481478 : return 0;
2068 : }
2069 :
2070 : }; // class pass_instantiate_virtual_regs
2071 :
2072 : } // anon namespace
2073 :
2074 : rtl_opt_pass *
2075 288767 : make_pass_instantiate_virtual_regs (gcc::context *ctxt)
2076 : {
2077 288767 : return new pass_instantiate_virtual_regs (ctxt);
2078 : }
2079 :
2080 :
2081 : /* Return true if EXP is an aggregate type (or a value with aggregate type).
2082 : This means a type for which function calls must pass an address to the
2083 : function or get an address back from the function.
2084 : EXP may be a type node or an expression (whose type is tested). */
2085 :
2086 : bool
2087 146878179 : aggregate_value_p (const_tree exp, const_tree fntype)
2088 : {
2089 146891424 : const_tree type = (TYPE_P (exp)) ? exp : TREE_TYPE (exp);
2090 146891424 : int i, regno, nregs;
2091 146891424 : rtx reg;
2092 :
2093 146891424 : if (fntype)
2094 146573642 : switch (TREE_CODE (fntype))
2095 : {
2096 11726479 : case CALL_EXPR:
2097 11726479 : {
2098 11726479 : tree fndecl = get_callee_fndecl (fntype);
2099 11726479 : if (fndecl)
2100 10798521 : fntype = TREE_TYPE (fndecl);
2101 927958 : else if (CALL_EXPR_FN (fntype))
2102 323836 : fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (fntype)));
2103 : else
2104 : /* For internal functions, assume nothing needs to be
2105 : returned in memory. */
2106 : return false;
2107 : }
2108 : break;
2109 124977743 : case FUNCTION_DECL:
2110 124977743 : fntype = TREE_TYPE (fntype);
2111 124977743 : break;
2112 : case FUNCTION_TYPE:
2113 : case METHOD_TYPE:
2114 : break;
2115 : case IDENTIFIER_NODE:
2116 330990 : fntype = NULL_TREE;
2117 : break;
2118 0 : default:
2119 : /* We don't expect other tree types here. */
2120 0 : gcc_unreachable ();
2121 : }
2122 :
2123 146287302 : if (VOID_TYPE_P (type))
2124 : return false;
2125 :
2126 107399838 : if (error_operand_p (fntype))
2127 : return false;
2128 :
2129 : /* If a record should be passed the same as its first (and only) member
2130 : don't pass it as an aggregate. */
2131 107399837 : if (TREE_CODE (type) == RECORD_TYPE && TYPE_TRANSPARENT_AGGR (type))
2132 13245 : return aggregate_value_p (first_field (type), fntype);
2133 :
2134 : /* If the front end has decided that this needs to be passed by
2135 : reference, do so. */
2136 107386495 : if ((TREE_CODE (exp) == PARM_DECL || TREE_CODE (exp) == RESULT_DECL)
2137 195766949 : && DECL_BY_REFERENCE (exp))
2138 : return true;
2139 :
2140 : /* Function types that are TREE_ADDRESSABLE force return in memory. */
2141 107234311 : if (fntype && TREE_ADDRESSABLE (fntype))
2142 : return true;
2143 :
2144 : /* Types that are TREE_ADDRESSABLE must be constructed in memory,
2145 : and thus can't be returned in registers. */
2146 107234311 : if (TREE_ADDRESSABLE (type))
2147 : return true;
2148 :
2149 105917760 : if (TYPE_EMPTY_P (type))
2150 : return false;
2151 :
2152 105119783 : if (flag_pcc_struct_return && AGGREGATE_TYPE_P (type))
2153 : return true;
2154 :
2155 104367855 : if (targetm.calls.return_in_memory (type, fntype))
2156 : return true;
2157 :
2158 : /* Make sure we have suitable call-clobbered regs to return
2159 : the value in; if not, we must return it in memory. */
2160 98775381 : reg = hard_function_value (type, 0, fntype, 0);
2161 :
2162 : /* If we have something other than a REG (e.g. a PARALLEL), then assume
2163 : it is OK. */
2164 98775381 : if (!REG_P (reg))
2165 : return false;
2166 :
2167 : /* Use the default ABI if the type of the function isn't known.
2168 : The scheme for handling interoperability between different ABIs
2169 : requires us to be able to tell when we're calling a function with
2170 : a nondefault ABI. */
2171 97898760 : const predefined_function_abi &abi = (fntype
2172 97898760 : ? fntype_abi (fntype)
2173 284992 : : default_function_abi);
2174 97898760 : regno = REGNO (reg);
2175 97898760 : nregs = hard_regno_nregs (regno, TYPE_MODE (type));
2176 198595970 : for (i = 0; i < nregs; i++)
2177 100697210 : if (!fixed_regs[regno + i] && !abi.clobbers_full_reg_p (regno + i))
2178 : return true;
2179 :
2180 : return false;
2181 : }
2182 :
2183 : /* Return true if we should assign DECL a pseudo register; false if it
2184 : should live on the local stack. */
2185 :
2186 : bool
2187 162958472 : use_register_for_decl (const_tree decl)
2188 : {
2189 162958472 : if (TREE_CODE (decl) == SSA_NAME)
2190 : {
2191 : /* We often try to use the SSA_NAME, instead of its underlying
2192 : decl, to get type information and guide decisions, to avoid
2193 : differences of behavior between anonymous and named
2194 : variables, but in this one case we have to go for the actual
2195 : variable if there is one. The main reason is that, at least
2196 : at -O0, we want to place user variables on the stack, but we
2197 : don't mind using pseudos for anonymous or ignored temps.
2198 : Should we take the SSA_NAME, we'd conclude all SSA_NAMEs
2199 : should go in pseudos, whereas their corresponding variables
2200 : might have to go on the stack. So, disregarding the decl
2201 : here would negatively impact debug info at -O0, enable
2202 : coalescing between SSA_NAMEs that ought to get different
2203 : stack/pseudo assignments, and get the incoming argument
2204 : processing thoroughly confused by PARM_DECLs expected to live
2205 : in stack slots but assigned to pseudos. */
2206 144650716 : if (!SSA_NAME_VAR (decl))
2207 99698698 : return TYPE_MODE (TREE_TYPE (decl)) != BLKmode
2208 99698698 : && !(flag_float_store && FLOAT_TYPE_P (TREE_TYPE (decl)));
2209 :
2210 : decl = SSA_NAME_VAR (decl);
2211 : }
2212 :
2213 : /* Honor volatile. */
2214 63259774 : if (TREE_SIDE_EFFECTS (decl))
2215 : return false;
2216 :
2217 : /* Honor addressability. */
2218 63141620 : if (TREE_ADDRESSABLE (decl))
2219 : return false;
2220 :
2221 : /* RESULT_DECLs are a bit special in that they're assigned without
2222 : regard to use_register_for_decl, but we generally only store in
2223 : them. If we coalesce their SSA NAMEs, we'd better return a
2224 : result that matches the assignment in expand_function_start. */
2225 58887684 : if (TREE_CODE (decl) == RESULT_DECL)
2226 : {
2227 : /* If it's not an aggregate, we're going to use a REG or a
2228 : PARALLEL containing a REG. */
2229 3100572 : if (!aggregate_value_p (decl, current_function_decl))
2230 : return true;
2231 :
2232 : /* If expand_function_start determines the return value, we'll
2233 : use MEM if it's not by reference. */
2234 31795 : if (cfun->returns_pcc_struct
2235 63590 : || (targetm.calls.struct_value_rtx
2236 31795 : (TREE_TYPE (current_function_decl), 1)))
2237 0 : return DECL_BY_REFERENCE (decl);
2238 :
2239 : /* Otherwise, we're taking an extra all.function_result_decl
2240 : argument. It's set up in assign_parms_augmented_arg_list,
2241 : under the (negated) conditions above, and then it's used to
2242 : set up the RESULT_DECL rtl in assign_params, after looping
2243 : over all parameters. Now, if the RESULT_DECL is not by
2244 : reference, we'll use a MEM either way. */
2245 31795 : if (!DECL_BY_REFERENCE (decl))
2246 : return false;
2247 :
2248 : /* Otherwise, if RESULT_DECL is DECL_BY_REFERENCE, it will take
2249 : the function_result_decl's assignment. Since it's a pointer,
2250 : we can short-circuit a number of the tests below, and we must
2251 : duplicate them because we don't have the function_result_decl
2252 : to test. */
2253 31795 : if (!targetm.calls.allocate_stack_slots_for_args ())
2254 : return true;
2255 : /* We don't set DECL_IGNORED_P for the function_result_decl. */
2256 31795 : if (optimize)
2257 : return true;
2258 : /* Needed for [[musttail]] which can operate even at -O0 */
2259 3796 : if (cfun->tail_call_marked)
2260 : return true;
2261 : /* We don't set DECL_REGISTER for the function_result_decl. */
2262 : return false;
2263 : }
2264 :
2265 : /* Only register-like things go in registers. */
2266 55787112 : if (DECL_MODE (decl) == BLKmode)
2267 : return false;
2268 :
2269 : /* If -ffloat-store specified, don't put explicit float variables
2270 : into registers. */
2271 : /* ??? This should be checked after DECL_ARTIFICIAL, but tree-ssa
2272 : propagates values across these stores, and it probably shouldn't. */
2273 54017068 : if (flag_float_store && FLOAT_TYPE_P (TREE_TYPE (decl)))
2274 : return false;
2275 :
2276 54015264 : if (!targetm.calls.allocate_stack_slots_for_args ())
2277 : return true;
2278 :
2279 : /* If we're not interested in tracking debugging information for
2280 : this decl, then we can certainly put it in a register. */
2281 54014948 : if (DECL_IGNORED_P (decl))
2282 : return true;
2283 :
2284 36546263 : if (optimize)
2285 : return true;
2286 :
2287 : /* Thunks force a tail call even at -O0 so we need to avoid creating a
2288 : dangling reference in case the parameter is passed by reference. */
2289 7262240 : if (TREE_CODE (decl) == PARM_DECL && cfun->tail_call_marked)
2290 : return true;
2291 :
2292 7261575 : if (!DECL_REGISTER (decl))
2293 : return false;
2294 :
2295 : /* When not optimizing, disregard register keyword for types that
2296 : could have methods, otherwise the methods won't be callable from
2297 : the debugger. */
2298 11290 : if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
2299 : return false;
2300 :
2301 : return true;
2302 : }
2303 :
2304 : /* Structures to communicate between the subroutines of assign_parms.
2305 : The first holds data persistent across all parameters, the second
2306 : is cleared out for each parameter. */
2307 :
2308 : struct assign_parm_data_all
2309 : {
2310 : /* When INIT_CUMULATIVE_ARGS gets revamped, allocating CUMULATIVE_ARGS
2311 : should become a job of the target or otherwise encapsulated. */
2312 : CUMULATIVE_ARGS args_so_far_v;
2313 : cumulative_args_t args_so_far;
2314 : struct args_size stack_args_size;
2315 : tree function_result_decl;
2316 : tree orig_fnargs;
2317 : rtx_insn *first_conversion_insn;
2318 : rtx_insn *last_conversion_insn;
2319 : HOST_WIDE_INT pretend_args_size;
2320 : HOST_WIDE_INT extra_pretend_bytes;
2321 : int reg_parm_stack_space;
2322 : };
2323 :
2324 18368608 : struct assign_parm_data_one
2325 : {
2326 : tree nominal_type;
2327 : function_arg_info arg;
2328 : rtx entry_parm;
2329 : rtx stack_parm;
2330 : machine_mode nominal_mode;
2331 : machine_mode passed_mode;
2332 : struct locate_and_pad_arg_data locate;
2333 : int partial;
2334 : };
2335 :
2336 : /* A subroutine of assign_parms. Initialize ALL. */
2337 :
2338 : static void
2339 4382650 : assign_parms_initialize_all (struct assign_parm_data_all *all)
2340 : {
2341 4382650 : tree fntype ATTRIBUTE_UNUSED;
2342 :
2343 4382650 : memset (all, 0, sizeof (*all));
2344 :
2345 4382650 : fntype = TREE_TYPE (current_function_decl);
2346 :
2347 : #ifdef INIT_CUMULATIVE_INCOMING_ARGS
2348 : INIT_CUMULATIVE_INCOMING_ARGS (all->args_so_far_v, fntype, NULL_RTX);
2349 : #else
2350 4382650 : INIT_CUMULATIVE_ARGS (all->args_so_far_v, fntype, NULL_RTX,
2351 : current_function_decl, -1);
2352 : #endif
2353 4382650 : all->args_so_far = pack_cumulative_args (&all->args_so_far_v);
2354 :
2355 : #ifdef INCOMING_REG_PARM_STACK_SPACE
2356 4382650 : all->reg_parm_stack_space
2357 4382650 : = INCOMING_REG_PARM_STACK_SPACE (current_function_decl);
2358 : #endif
2359 4382650 : }
2360 :
2361 : /* If ARGS contains entries with complex types, split the entry into two
2362 : entries of the component type. Return a new list of substitutions are
2363 : needed, else the old list. */
2364 :
2365 : static void
2366 0 : split_complex_args (vec<tree> *args)
2367 : {
2368 0 : unsigned i;
2369 0 : tree p;
2370 :
2371 0 : FOR_EACH_VEC_ELT (*args, i, p)
2372 : {
2373 0 : tree type = TREE_TYPE (p);
2374 0 : if (TREE_CODE (type) == COMPLEX_TYPE
2375 0 : && targetm.calls.split_complex_arg (type))
2376 : {
2377 0 : tree decl;
2378 0 : tree subtype = TREE_TYPE (type);
2379 0 : bool addressable = TREE_ADDRESSABLE (p);
2380 :
2381 : /* Rewrite the PARM_DECL's type with its component. */
2382 0 : p = copy_node (p);
2383 0 : TREE_TYPE (p) = subtype;
2384 0 : DECL_ARG_TYPE (p) = TREE_TYPE (DECL_ARG_TYPE (p));
2385 0 : SET_DECL_MODE (p, VOIDmode);
2386 0 : DECL_SIZE (p) = NULL;
2387 0 : DECL_SIZE_UNIT (p) = NULL;
2388 : /* If this arg must go in memory, put it in a pseudo here.
2389 : We can't allow it to go in memory as per normal parms,
2390 : because the usual place might not have the imag part
2391 : adjacent to the real part. */
2392 0 : DECL_ARTIFICIAL (p) = addressable;
2393 0 : DECL_IGNORED_P (p) = addressable;
2394 0 : TREE_ADDRESSABLE (p) = 0;
2395 0 : layout_decl (p, 0);
2396 0 : (*args)[i] = p;
2397 :
2398 : /* Build a second synthetic decl. */
2399 0 : decl = build_decl (EXPR_LOCATION (p),
2400 : PARM_DECL, NULL_TREE, subtype);
2401 0 : DECL_ARG_TYPE (decl) = DECL_ARG_TYPE (p);
2402 0 : DECL_ARTIFICIAL (decl) = addressable;
2403 0 : DECL_IGNORED_P (decl) = addressable;
2404 0 : layout_decl (decl, 0);
2405 0 : args->safe_insert (++i, decl);
2406 : }
2407 : }
2408 0 : }
2409 :
2410 : /* A subroutine of assign_parms. Adjust the parameter list to incorporate
2411 : the hidden struct return argument, and (abi willing) complex args.
2412 : Return the new parameter list. */
2413 :
2414 : static vec<tree>
2415 4382650 : assign_parms_augmented_arg_list (struct assign_parm_data_all *all)
2416 : {
2417 4382650 : tree fndecl = current_function_decl;
2418 4382650 : tree fntype = TREE_TYPE (fndecl);
2419 4382650 : vec<tree> fnargs = vNULL;
2420 4382650 : tree arg;
2421 :
2422 13371240 : for (arg = DECL_ARGUMENTS (fndecl); arg; arg = DECL_CHAIN (arg))
2423 8988590 : fnargs.safe_push (arg);
2424 :
2425 4382650 : all->orig_fnargs = DECL_ARGUMENTS (fndecl);
2426 :
2427 : /* If struct value address is treated as the first argument, make it so. */
2428 4382650 : if (aggregate_value_p (DECL_RESULT (fndecl), fndecl)
2429 195714 : && ! cfun->returns_pcc_struct
2430 4578364 : && targetm.calls.struct_value_rtx (TREE_TYPE (fndecl), 1) == 0)
2431 : {
2432 195714 : tree type = build_pointer_type (TREE_TYPE (fntype));
2433 195714 : tree decl;
2434 :
2435 195714 : decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
2436 : PARM_DECL, get_identifier (".result_ptr"), type);
2437 195714 : DECL_ARG_TYPE (decl) = type;
2438 195714 : DECL_ARTIFICIAL (decl) = 1;
2439 195714 : DECL_NAMELESS (decl) = 1;
2440 195714 : TREE_CONSTANT (decl) = 1;
2441 : /* We don't set DECL_IGNORED_P or DECL_REGISTER here. If this
2442 : changes, the end of the RESULT_DECL handling block in
2443 : use_register_for_decl must be adjusted to match. */
2444 :
2445 195714 : DECL_CHAIN (decl) = all->orig_fnargs;
2446 195714 : all->orig_fnargs = decl;
2447 195714 : fnargs.safe_insert (0, decl);
2448 :
2449 195714 : all->function_result_decl = decl;
2450 : }
2451 :
2452 : /* If the target wants to split complex arguments into scalars, do so. */
2453 4382650 : if (targetm.calls.split_complex_arg)
2454 0 : split_complex_args (&fnargs);
2455 :
2456 4382650 : return fnargs;
2457 : }
2458 :
2459 : /* A subroutine of assign_parms. Examine PARM and pull out type and mode
2460 : data for the parameter. Incorporate ABI specifics such as pass-by-
2461 : reference and type promotion. */
2462 :
2463 : static void
2464 9184304 : assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm,
2465 : struct assign_parm_data_one *data)
2466 : {
2467 9184304 : int unsignedp;
2468 :
2469 9184304 : *data = assign_parm_data_one ();
2470 :
2471 : /* NAMED_ARG is a misnomer. We really mean 'non-variadic'. */
2472 9184304 : if (!cfun->stdarg)
2473 9102677 : data->arg.named = 1; /* No variadic parms. */
2474 81627 : else if (DECL_CHAIN (parm))
2475 38834 : data->arg.named = 1; /* Not the last non-variadic parm. */
2476 42793 : else if (targetm.calls.strict_argument_naming (all->args_so_far))
2477 42793 : data->arg.named = 1; /* Only variadic ones are unnamed. */
2478 : else
2479 0 : data->arg.named = 0; /* Treat as variadic. */
2480 :
2481 9184304 : data->nominal_type = TREE_TYPE (parm);
2482 9184304 : data->arg.type = DECL_ARG_TYPE (parm);
2483 :
2484 : /* Look out for errors propagating this far. Also, if the parameter's
2485 : type is void then its value doesn't matter. */
2486 9184304 : if (TREE_TYPE (parm) == error_mark_node
2487 : /* This can happen after weird syntax errors
2488 : or if an enum type is defined among the parms. */
2489 9184219 : || TREE_CODE (parm) != PARM_DECL
2490 9184219 : || data->arg.type == NULL
2491 18368523 : || VOID_TYPE_P (data->nominal_type))
2492 : {
2493 85 : data->nominal_type = data->arg.type = void_type_node;
2494 85 : data->nominal_mode = data->passed_mode = data->arg.mode = VOIDmode;
2495 85 : return;
2496 : }
2497 :
2498 : /* Find mode of arg as it is passed, and mode of arg as it should be
2499 : during execution of this function. */
2500 9184219 : data->passed_mode = data->arg.mode = TYPE_MODE (data->arg.type);
2501 9184219 : data->nominal_mode = TYPE_MODE (data->nominal_type);
2502 :
2503 : /* If the parm is to be passed as a transparent union or record, use the
2504 : type of the first field for the tests below. We have already verified
2505 : that the modes are the same. */
2506 9184219 : if (RECORD_OR_UNION_TYPE_P (data->arg.type)
2507 9184219 : && TYPE_TRANSPARENT_AGGR (data->arg.type))
2508 1536 : data->arg.type = TREE_TYPE (first_field (data->arg.type));
2509 :
2510 : /* See if this arg was passed by invisible reference. */
2511 9184219 : if (apply_pass_by_reference_rules (&all->args_so_far_v, data->arg))
2512 : {
2513 9932 : data->nominal_type = data->arg.type;
2514 9932 : data->passed_mode = data->nominal_mode = data->arg.mode;
2515 : }
2516 :
2517 : /* Find mode as it is passed by the ABI. */
2518 9184219 : unsignedp = TYPE_UNSIGNED (data->arg.type);
2519 9184219 : data->arg.mode
2520 9184219 : = promote_function_mode (data->arg.type, data->arg.mode, &unsignedp,
2521 9184219 : TREE_TYPE (current_function_decl), 0);
2522 : }
2523 :
2524 : /* A subroutine of assign_parms. Invoke setup_incoming_varargs. */
2525 :
2526 : static void
2527 21489 : assign_parms_setup_varargs (struct assign_parm_data_all *all,
2528 : struct assign_parm_data_one *data, bool no_rtl)
2529 : {
2530 21489 : int varargs_pretend_bytes = 0;
2531 :
2532 21489 : function_arg_info last_named_arg = data->arg;
2533 21489 : last_named_arg.named = true;
2534 21489 : targetm.calls.setup_incoming_varargs (all->args_so_far, last_named_arg,
2535 : &varargs_pretend_bytes, no_rtl);
2536 :
2537 : /* If the back-end has requested extra stack space, record how much is
2538 : needed. Do not change pretend_args_size otherwise since it may be
2539 : nonzero from an earlier partial argument. */
2540 21489 : if (varargs_pretend_bytes > 0)
2541 0 : all->pretend_args_size = varargs_pretend_bytes;
2542 21489 : }
2543 :
2544 : /* A subroutine of assign_parms. Set DATA->ENTRY_PARM corresponding to
2545 : the incoming location of the current parameter. */
2546 :
2547 : static void
2548 3185899 : assign_parm_find_entry_rtl (struct assign_parm_data_all *all,
2549 : struct assign_parm_data_one *data)
2550 : {
2551 3185899 : HOST_WIDE_INT pretend_bytes = 0;
2552 3185899 : rtx entry_parm;
2553 3185899 : bool in_regs;
2554 :
2555 3185899 : if (data->arg.mode == VOIDmode)
2556 : {
2557 0 : data->entry_parm = data->stack_parm = const0_rtx;
2558 0 : return;
2559 : }
2560 :
2561 3185899 : targetm.calls.warn_parameter_passing_abi (all->args_so_far,
2562 : data->arg.type);
2563 :
2564 6371798 : entry_parm = targetm.calls.function_incoming_arg (all->args_so_far,
2565 3185899 : data->arg);
2566 3185899 : if (entry_parm == 0)
2567 1071379 : data->arg.mode = data->passed_mode;
2568 :
2569 : /* Determine parm's home in the stack, in case it arrives in the stack
2570 : or we should pretend it did. Compute the stack position and rtx where
2571 : the argument arrives and its size.
2572 :
2573 : There is one complexity here: If this was a parameter that would
2574 : have been passed in registers, but wasn't only because it is
2575 : __builtin_va_alist, we want locate_and_pad_parm to treat it as if
2576 : it came in a register so that REG_PARM_STACK_SPACE isn't skipped.
2577 : In this case, we call FUNCTION_ARG with NAMED set to 1 instead of 0
2578 : as it was the previous time. */
2579 1071379 : in_regs = (entry_parm != 0);
2580 : #ifdef STACK_PARMS_IN_REG_PARM_AREA
2581 : in_regs = true;
2582 : #endif
2583 1071379 : if (!in_regs && !data->arg.named)
2584 : {
2585 0 : if (targetm.calls.pretend_outgoing_varargs_named (all->args_so_far))
2586 : {
2587 0 : rtx tem;
2588 0 : function_arg_info named_arg = data->arg;
2589 0 : named_arg.named = true;
2590 0 : tem = targetm.calls.function_incoming_arg (all->args_so_far,
2591 : named_arg);
2592 0 : in_regs = tem != NULL;
2593 : }
2594 : }
2595 :
2596 : /* If this parameter was passed both in registers and in the stack, use
2597 : the copy on the stack. */
2598 3185899 : if (targetm.calls.must_pass_in_stack (data->arg))
2599 : entry_parm = 0;
2600 :
2601 3185899 : if (entry_parm)
2602 : {
2603 2114520 : int partial;
2604 :
2605 2114520 : partial = targetm.calls.arg_partial_bytes (all->args_so_far, data->arg);
2606 2114520 : data->partial = partial;
2607 :
2608 : /* The caller might already have allocated stack space for the
2609 : register parameters. */
2610 2114520 : if (partial != 0 && all->reg_parm_stack_space == 0)
2611 : {
2612 : /* Part of this argument is passed in registers and part
2613 : is passed on the stack. Ask the prologue code to extend
2614 : the stack part so that we can recreate the full value.
2615 :
2616 : PRETEND_BYTES is the size of the registers we need to store.
2617 : CURRENT_FUNCTION_PRETEND_ARGS_SIZE is the amount of extra
2618 : stack space that the prologue should allocate.
2619 :
2620 : Internally, gcc assumes that the argument pointer is aligned
2621 : to STACK_BOUNDARY bits. This is used both for alignment
2622 : optimizations (see init_emit) and to locate arguments that are
2623 : aligned to more than PARM_BOUNDARY bits. We must preserve this
2624 : invariant by rounding CURRENT_FUNCTION_PRETEND_ARGS_SIZE up to
2625 : a stack boundary. */
2626 :
2627 : /* We assume at most one partial arg, and it must be the first
2628 : argument on the stack. */
2629 0 : gcc_assert (!all->extra_pretend_bytes && !all->pretend_args_size);
2630 :
2631 0 : pretend_bytes = partial;
2632 0 : all->pretend_args_size = CEIL_ROUND (pretend_bytes, STACK_BYTES);
2633 :
2634 : /* We want to align relative to the actual stack pointer, so
2635 : don't include this in the stack size until later. */
2636 0 : all->extra_pretend_bytes = all->pretend_args_size;
2637 : }
2638 : }
2639 :
2640 3185899 : locate_and_pad_parm (data->arg.mode, data->arg.type, in_regs,
2641 : all->reg_parm_stack_space,
2642 : entry_parm ? data->partial : 0, current_function_decl,
2643 : &all->stack_args_size, &data->locate);
2644 :
2645 : /* Update parm_stack_boundary if this parameter is passed in the
2646 : stack. */
2647 3185899 : if (!in_regs && crtl->parm_stack_boundary < data->locate.boundary)
2648 198053 : crtl->parm_stack_boundary = data->locate.boundary;
2649 :
2650 : /* Adjust offsets to include the pretend args. */
2651 3185899 : pretend_bytes = all->extra_pretend_bytes - pretend_bytes;
2652 3185899 : data->locate.slot_offset.constant += pretend_bytes;
2653 3185899 : data->locate.offset.constant += pretend_bytes;
2654 :
2655 3185899 : data->entry_parm = entry_parm;
2656 : }
2657 :
2658 : /* A subroutine of assign_parms. If there is actually space on the stack
2659 : for this parm, count it in stack_args_size and return true. */
2660 :
2661 : static bool
2662 3185899 : assign_parm_is_stack_parm (struct assign_parm_data_all *all,
2663 : struct assign_parm_data_one *data)
2664 : {
2665 : /* Trivially true if we've no incoming register. */
2666 3185899 : if (data->entry_parm == NULL)
2667 : ;
2668 : /* Also true if we're partially in registers and partially not,
2669 : since we've arranged to drop the entire argument on the stack. */
2670 2114520 : else if (data->partial != 0)
2671 : ;
2672 : /* Also true if the target says that it's passed in both registers
2673 : and on the stack. */
2674 2114520 : else if (GET_CODE (data->entry_parm) == PARALLEL
2675 53579 : && XEXP (XVECEXP (data->entry_parm, 0, 0), 0) == NULL_RTX)
2676 : ;
2677 : /* Also true if the target says that there's stack allocated for
2678 : all register parameters. */
2679 2114520 : else if (all->reg_parm_stack_space > 0)
2680 : ;
2681 : /* Otherwise, no, this parameter has no ABI defined stack slot. */
2682 : else
2683 : return false;
2684 :
2685 1181652 : all->stack_args_size.constant += data->locate.size.constant;
2686 1181652 : if (data->locate.size.var)
2687 0 : ADD_PARM_SIZE (all->stack_args_size, data->locate.size.var);
2688 :
2689 : return true;
2690 : }
2691 :
2692 : /* A subroutine of assign_parms. Given that this parameter is allocated
2693 : stack space by the ABI, find it. */
2694 :
2695 : static void
2696 1181652 : assign_parm_find_stack_rtl (tree parm, struct assign_parm_data_one *data)
2697 : {
2698 1181652 : rtx offset_rtx, stack_parm;
2699 1181652 : unsigned int align, boundary;
2700 :
2701 : /* If we're passing this arg using a reg, make its stack home the
2702 : aligned stack slot. */
2703 1181652 : if (data->entry_parm)
2704 110273 : offset_rtx = ARGS_SIZE_RTX (data->locate.slot_offset);
2705 : else
2706 1314350 : offset_rtx = ARGS_SIZE_RTX (data->locate.offset);
2707 :
2708 1181652 : stack_parm = crtl->args.internal_arg_pointer;
2709 1181652 : if (offset_rtx != const0_rtx)
2710 1093189 : stack_parm = gen_rtx_PLUS (Pmode, stack_parm, offset_rtx);
2711 1181652 : stack_parm = gen_rtx_MEM (data->arg.mode, stack_parm);
2712 :
2713 1181652 : if (!data->arg.pass_by_reference)
2714 : {
2715 1176726 : set_mem_attributes (stack_parm, parm, 1);
2716 : /* set_mem_attributes could set MEM_SIZE to the passed mode's size,
2717 : while promoted mode's size is needed. */
2718 1176726 : if (data->arg.mode != BLKmode
2719 1176726 : && data->arg.mode != DECL_MODE (parm))
2720 : {
2721 0 : set_mem_size (stack_parm, GET_MODE_SIZE (data->arg.mode));
2722 0 : if (MEM_EXPR (stack_parm) && MEM_OFFSET_KNOWN_P (stack_parm))
2723 : {
2724 0 : poly_int64 offset = subreg_lowpart_offset (DECL_MODE (parm),
2725 0 : data->arg.mode);
2726 0 : if (maybe_ne (offset, 0))
2727 0 : set_mem_offset (stack_parm, MEM_OFFSET (stack_parm) - offset);
2728 : }
2729 : }
2730 : }
2731 :
2732 1181652 : boundary = data->locate.boundary;
2733 1181652 : align = BITS_PER_UNIT;
2734 :
2735 : /* If we're padding upward, we know that the alignment of the slot
2736 : is TARGET_FUNCTION_ARG_BOUNDARY. If we're using slot_offset, we're
2737 : intentionally forcing upward padding. Otherwise we have to come
2738 : up with a guess at the alignment based on OFFSET_RTX. */
2739 1181652 : poly_int64 offset;
2740 1181652 : if (data->locate.where_pad == PAD_NONE || data->entry_parm)
2741 : align = boundary;
2742 1071379 : else if (data->locate.where_pad == PAD_UPWARD)
2743 : {
2744 1071379 : align = boundary;
2745 : /* If the argument offset is actually more aligned than the nominal
2746 : stack slot boundary, take advantage of that excess alignment.
2747 : Don't make any assumptions if STACK_POINTER_OFFSET is in use. */
2748 1071379 : if (poly_int_rtx_p (offset_rtx, &offset)
2749 : && known_eq (STACK_POINTER_OFFSET, 0))
2750 : {
2751 1071379 : unsigned int offset_align = known_alignment (offset) * BITS_PER_UNIT;
2752 1199965 : if (offset_align == 0 || offset_align > STACK_BOUNDARY)
2753 590520 : offset_align = STACK_BOUNDARY;
2754 1071379 : align = MAX (align, offset_align);
2755 : }
2756 : }
2757 0 : else if (poly_int_rtx_p (offset_rtx, &offset))
2758 : {
2759 0 : align = least_bit_hwi (boundary);
2760 0 : unsigned int offset_align = known_alignment (offset) * BITS_PER_UNIT;
2761 0 : if (offset_align != 0)
2762 0 : align = MIN (align, offset_align);
2763 : }
2764 1181652 : set_mem_align (stack_parm, align);
2765 :
2766 1181652 : if (data->entry_parm)
2767 110273 : set_reg_attrs_for_parm (data->entry_parm, stack_parm);
2768 :
2769 1181652 : data->stack_parm = stack_parm;
2770 1181652 : }
2771 :
2772 : /* A subroutine of assign_parms. Adjust DATA->ENTRY_RTL such that it's
2773 : always valid and contiguous. */
2774 :
2775 : static void
2776 1181652 : assign_parm_adjust_entry_rtl (struct assign_parm_data_one *data)
2777 : {
2778 1181652 : rtx entry_parm = data->entry_parm;
2779 1181652 : rtx stack_parm = data->stack_parm;
2780 :
2781 : /* If this parm was passed part in regs and part in memory, pretend it
2782 : arrived entirely in memory by pushing the register-part onto the stack.
2783 : In the special case of a DImode or DFmode that is split, we could put
2784 : it together in a pseudoreg directly, but for now that's not worth
2785 : bothering with. */
2786 1181652 : if (data->partial != 0)
2787 : {
2788 : /* Handle calls that pass values in multiple non-contiguous
2789 : locations. The Irix 6 ABI has examples of this. */
2790 0 : if (GET_CODE (entry_parm) == PARALLEL)
2791 0 : emit_group_store (validize_mem (copy_rtx (stack_parm)), entry_parm,
2792 0 : data->arg.type, int_size_in_bytes (data->arg.type));
2793 : else
2794 : {
2795 0 : gcc_assert (data->partial % UNITS_PER_WORD == 0);
2796 0 : move_block_from_reg (REGNO (entry_parm),
2797 : validize_mem (copy_rtx (stack_parm)),
2798 : data->partial / UNITS_PER_WORD);
2799 : }
2800 :
2801 : entry_parm = stack_parm;
2802 : }
2803 :
2804 : /* If we didn't decide this parm came in a register, by default it came
2805 : on the stack. */
2806 1181652 : else if (entry_parm == NULL)
2807 : entry_parm = stack_parm;
2808 :
2809 : /* When an argument is passed in multiple locations, we can't make use
2810 : of this information, but we can save some copying if the whole argument
2811 : is passed in a single register. */
2812 110273 : else if (GET_CODE (entry_parm) == PARALLEL
2813 0 : && data->nominal_mode != BLKmode
2814 0 : && data->passed_mode != BLKmode)
2815 : {
2816 0 : size_t i, len = XVECLEN (entry_parm, 0);
2817 :
2818 0 : for (i = 0; i < len; i++)
2819 0 : if (XEXP (XVECEXP (entry_parm, 0, i), 0) != NULL_RTX
2820 0 : && REG_P (XEXP (XVECEXP (entry_parm, 0, i), 0))
2821 0 : && (GET_MODE (XEXP (XVECEXP (entry_parm, 0, i), 0))
2822 0 : == data->passed_mode)
2823 0 : && INTVAL (XEXP (XVECEXP (entry_parm, 0, i), 1)) == 0)
2824 : {
2825 : entry_parm = XEXP (XVECEXP (entry_parm, 0, i), 0);
2826 : break;
2827 : }
2828 : }
2829 :
2830 1181652 : data->entry_parm = entry_parm;
2831 1181652 : }
2832 :
2833 : /* A subroutine of assign_parms. Reconstitute any values which were
2834 : passed in multiple registers and would fit in a single register. */
2835 :
2836 : static void
2837 3111777 : assign_parm_remove_parallels (struct assign_parm_data_one *data)
2838 : {
2839 3111777 : rtx entry_parm = data->entry_parm;
2840 :
2841 : /* Convert the PARALLEL to a REG of the same mode as the parallel.
2842 : This can be done with register operations rather than on the
2843 : stack, even if we will store the reconstituted parameter on the
2844 : stack later. */
2845 3111777 : if (GET_CODE (entry_parm) == PARALLEL && GET_MODE (entry_parm) != BLKmode)
2846 : {
2847 49761 : rtx parmreg = gen_reg_rtx (GET_MODE (entry_parm));
2848 49761 : emit_group_store (parmreg, entry_parm, data->arg.type,
2849 99522 : GET_MODE_SIZE (GET_MODE (entry_parm)));
2850 49761 : entry_parm = parmreg;
2851 : }
2852 :
2853 3111777 : data->entry_parm = entry_parm;
2854 3111777 : }
2855 :
2856 : /* A subroutine of assign_parms. Adjust DATA->STACK_RTL such that it's
2857 : always valid and properly aligned. */
2858 :
2859 : static void
2860 3185899 : assign_parm_adjust_stack_rtl (tree parm, struct assign_parm_data_one *data)
2861 : {
2862 3185899 : rtx stack_parm = data->stack_parm;
2863 :
2864 : /* If we can't trust the parm stack slot to be aligned enough for its
2865 : ultimate type, don't use that slot after entry. We'll make another
2866 : stack slot, if we need one. */
2867 3185899 : if (stack_parm
2868 3185899 : && ((GET_MODE_ALIGNMENT (data->nominal_mode) > MEM_ALIGN (stack_parm)
2869 24915 : && ((optab_handler (movmisalign_optab, data->nominal_mode)
2870 : != CODE_FOR_nothing)
2871 49822 : || targetm.slow_unaligned_access (data->nominal_mode,
2872 24911 : MEM_ALIGN (stack_parm))))
2873 1180249 : || (data->nominal_type
2874 2360498 : && TYPE_ALIGN (data->nominal_type) > MEM_ALIGN (stack_parm)
2875 4505 : && ((MEM_ALIGN (stack_parm)
2876 4505 : < MIN (BIGGEST_ALIGNMENT, MAX_SUPPORTED_STACK_ALIGNMENT))
2877 : /* If its address is taken, make a local copy whose
2878 : maximum alignment is MAX_SUPPORTED_STACK_ALIGNMENT.
2879 : */
2880 4 : || (TREE_ADDRESSABLE (parm)
2881 : && (MEM_ALIGN (stack_parm)
2882 : < MAX_SUPPORTED_STACK_ALIGNMENT))))))
2883 : stack_parm = NULL;
2884 :
2885 : /* If parm was passed in memory, and we need to convert it on entry,
2886 : don't store it back in that same slot. */
2887 3181393 : else if (data->entry_parm == stack_parm
2888 1065474 : && data->nominal_mode != BLKmode
2889 996806 : && data->nominal_mode != data->passed_mode)
2890 : stack_parm = NULL;
2891 :
2892 : /* If stack protection is in effect for this function, don't leave any
2893 : pointers in their passed stack slots. */
2894 3181393 : else if (crtl->stack_protect_guard
2895 224 : && (flag_stack_protect == SPCT_FLAG_ALL
2896 163 : || data->arg.pass_by_reference
2897 163 : || POINTER_TYPE_P (data->nominal_type)))
2898 4670 : stack_parm = NULL;
2899 :
2900 3185899 : data->stack_parm = stack_parm;
2901 3185899 : }
2902 :
2903 : /* A subroutine of assign_parms. Return true if the current parameter
2904 : should be stored as a BLKmode in the current frame. */
2905 :
2906 : static bool
2907 3185899 : assign_parm_setup_block_p (struct assign_parm_data_one *data)
2908 : {
2909 0 : if (data->nominal_mode == BLKmode)
2910 : return true;
2911 3111777 : if (GET_MODE (data->entry_parm) == BLKmode)
2912 0 : return true;
2913 :
2914 : #ifdef BLOCK_REG_PADDING
2915 : /* Only assign_parm_setup_block knows how to deal with register arguments
2916 : that are padded at the least significant end. */
2917 : if (REG_P (data->entry_parm)
2918 : && known_lt (GET_MODE_SIZE (data->arg.mode), UNITS_PER_WORD)
2919 : && (BLOCK_REG_PADDING (data->passed_mode, data->arg.type, 1)
2920 : == (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)))
2921 : return true;
2922 : #endif
2923 :
2924 : return false;
2925 : }
2926 :
2927 : /* A subroutine of assign_parms. Arrange for the parameter to be
2928 : present and valid in DATA->STACK_RTL. */
2929 :
2930 : static void
2931 74122 : assign_parm_setup_block (struct assign_parm_data_all *all,
2932 : tree parm, struct assign_parm_data_one *data)
2933 : {
2934 74122 : rtx entry_parm = data->entry_parm;
2935 74122 : rtx stack_parm = data->stack_parm;
2936 74122 : rtx target_reg = NULL_RTX;
2937 74122 : bool in_conversion_seq = false;
2938 74122 : HOST_WIDE_INT size;
2939 74122 : HOST_WIDE_INT size_stored;
2940 :
2941 74122 : if (GET_CODE (entry_parm) == PARALLEL)
2942 3818 : entry_parm = emit_group_move_into_temps (entry_parm);
2943 :
2944 : /* If we want the parameter in a pseudo, don't use a stack slot. */
2945 74122 : if (is_gimple_reg (parm) && use_register_for_decl (parm))
2946 : {
2947 0 : tree def = ssa_default_def (cfun, parm);
2948 0 : gcc_assert (def);
2949 0 : machine_mode mode = promote_ssa_mode (def, NULL);
2950 0 : rtx reg = gen_reg_rtx (mode);
2951 0 : if (GET_CODE (reg) != CONCAT)
2952 : stack_parm = reg;
2953 : else
2954 : {
2955 0 : target_reg = reg;
2956 : /* Avoid allocating a stack slot, if there isn't one
2957 : preallocated by the ABI. It might seem like we should
2958 : always prefer a pseudo, but converting between
2959 : floating-point and integer modes goes through the stack
2960 : on various machines, so it's better to use the reserved
2961 : stack slot than to risk wasting it and allocating more
2962 : for the conversion. */
2963 0 : if (stack_parm == NULL_RTX)
2964 : {
2965 0 : int save = generating_concat_p;
2966 0 : generating_concat_p = 0;
2967 0 : stack_parm = gen_reg_rtx (mode);
2968 0 : generating_concat_p = save;
2969 : }
2970 : }
2971 0 : data->stack_parm = NULL;
2972 : }
2973 :
2974 74122 : size = int_size_in_bytes (data->arg.type);
2975 86748 : size_stored = CEIL_ROUND (size, UNITS_PER_WORD);
2976 74122 : if (stack_parm == 0)
2977 : {
2978 5457 : HOST_WIDE_INT parm_align
2979 : = ((STRICT_ALIGNMENT || BITS_PER_WORD <= MAX_SUPPORTED_STACK_ALIGNMENT)
2980 5669 : ? MAX (DECL_ALIGN (parm), BITS_PER_WORD) : DECL_ALIGN (parm));
2981 :
2982 5457 : SET_DECL_ALIGN (parm, parm_align);
2983 5457 : stack_parm
2984 5457 : = assign_stack_local_aligned (BLKmode, size_stored, DECL_ALIGN (parm));
2985 10914 : if (known_eq (GET_MODE_SIZE (GET_MODE (entry_parm)), size))
2986 77 : PUT_MODE (stack_parm, GET_MODE (entry_parm));
2987 5457 : set_mem_attributes (stack_parm, parm, 1);
2988 : }
2989 :
2990 : /* If a BLKmode arrives in registers, copy it to a stack slot. Handle
2991 : calls that pass values in multiple non-contiguous locations. */
2992 74122 : if (REG_P (entry_parm) || GET_CODE (entry_parm) == PARALLEL)
2993 : {
2994 5154 : rtx mem;
2995 :
2996 : /* Note that we will be storing an integral number of words.
2997 : So we have to be careful to ensure that we allocate an
2998 : integral number of words. We do this above when we call
2999 : assign_stack_local if space was not allocated in the argument
3000 : list. If it was, this will not work if PARM_BOUNDARY is not
3001 : a multiple of BITS_PER_WORD. It isn't clear how to fix this
3002 : if it becomes a problem. Exception is when BLKmode arrives
3003 : with arguments not conforming to word_mode. */
3004 :
3005 5154 : if (data->stack_parm == 0)
3006 : ;
3007 5154 : else if (GET_CODE (entry_parm) == PARALLEL)
3008 : ;
3009 : else
3010 5154 : gcc_assert (!size || !(PARM_BOUNDARY % BITS_PER_WORD));
3011 :
3012 5154 : mem = validize_mem (copy_rtx (stack_parm));
3013 :
3014 : /* Handle values in multiple non-contiguous locations. */
3015 5154 : if (GET_CODE (entry_parm) == PARALLEL && !MEM_P (mem))
3016 0 : emit_group_store (mem, entry_parm, data->arg.type, size);
3017 5154 : else if (GET_CODE (entry_parm) == PARALLEL)
3018 : {
3019 3818 : push_to_sequence2 (all->first_conversion_insn,
3020 : all->last_conversion_insn);
3021 3818 : emit_group_store (mem, entry_parm, data->arg.type, size);
3022 3818 : all->first_conversion_insn = get_insns ();
3023 3818 : all->last_conversion_insn = get_last_insn ();
3024 3818 : end_sequence ();
3025 3818 : in_conversion_seq = true;
3026 : }
3027 :
3028 1336 : else if (size == 0)
3029 : ;
3030 :
3031 : /* If SIZE is that of a mode no bigger than a word, just use
3032 : that mode's store operation. */
3033 1320 : else if (size <= UNITS_PER_WORD)
3034 : {
3035 1316 : unsigned int bits = size * BITS_PER_UNIT;
3036 1316 : machine_mode mode = int_mode_for_size (bits, 0).else_blk ();
3037 :
3038 1316 : if (mode != BLKmode
3039 : #ifdef BLOCK_REG_PADDING
3040 : && (size == UNITS_PER_WORD
3041 : || (BLOCK_REG_PADDING (mode, data->arg.type, 1)
3042 : != (BYTES_BIG_ENDIAN ? PAD_UPWARD : PAD_DOWNWARD)))
3043 : #endif
3044 : )
3045 : {
3046 102 : rtx reg;
3047 :
3048 : /* We are really truncating a word_mode value containing
3049 : SIZE bytes into a value of mode MODE. If such an
3050 : operation requires no actual instructions, we can refer
3051 : to the value directly in mode MODE, otherwise we must
3052 : start with the register in word_mode and explicitly
3053 : convert it. */
3054 102 : if (mode == word_mode
3055 102 : || TRULY_NOOP_TRUNCATION_MODES_P (mode, word_mode))
3056 102 : reg = gen_rtx_REG (mode, REGNO (entry_parm));
3057 : else
3058 : {
3059 0 : reg = gen_rtx_REG (word_mode, REGNO (entry_parm));
3060 0 : reg = convert_to_mode (mode, copy_to_reg (reg), 1);
3061 : }
3062 :
3063 : /* We use adjust_address to get a new MEM with the mode
3064 : changed. adjust_address is better than change_address
3065 : for this purpose because adjust_address does not lose
3066 : the MEM_EXPR associated with the MEM.
3067 :
3068 : If the MEM_EXPR is lost, then optimizations like DSE
3069 : assume the MEM escapes and thus is not subject to DSE. */
3070 102 : emit_move_insn (adjust_address (mem, mode, 0), reg);
3071 : }
3072 :
3073 : #ifdef BLOCK_REG_PADDING
3074 : /* Storing the register in memory as a full word, as
3075 : move_block_from_reg below would do, and then using the
3076 : MEM in a smaller mode, has the effect of shifting right
3077 : if BYTES_BIG_ENDIAN. If we're bypassing memory, the
3078 : shifting must be explicit. */
3079 : else if (!MEM_P (mem))
3080 : {
3081 : rtx x;
3082 :
3083 : /* If the assert below fails, we should have taken the
3084 : mode != BLKmode path above, unless we have downward
3085 : padding of smaller-than-word arguments on a machine
3086 : with little-endian bytes, which would likely require
3087 : additional changes to work correctly. */
3088 : gcc_checking_assert (BYTES_BIG_ENDIAN
3089 : && (BLOCK_REG_PADDING (mode,
3090 : data->arg.type, 1)
3091 : == PAD_UPWARD));
3092 :
3093 : int by = (UNITS_PER_WORD - size) * BITS_PER_UNIT;
3094 :
3095 : x = gen_rtx_REG (word_mode, REGNO (entry_parm));
3096 : x = expand_shift (RSHIFT_EXPR, word_mode, x, by,
3097 : NULL_RTX, 1);
3098 : x = force_reg (word_mode, x);
3099 : x = gen_lowpart_SUBREG (GET_MODE (mem), x);
3100 :
3101 : emit_move_insn (mem, x);
3102 : }
3103 : #endif
3104 :
3105 : /* Blocks smaller than a word on a BYTES_BIG_ENDIAN
3106 : machine must be aligned to the left before storing
3107 : to memory. Note that the previous test doesn't
3108 : handle all cases (e.g. SIZE == 3). */
3109 1214 : else if (size != UNITS_PER_WORD
3110 : #ifdef BLOCK_REG_PADDING
3111 : && (BLOCK_REG_PADDING (mode, data->arg.type, 1)
3112 : == PAD_DOWNWARD)
3113 : #else
3114 : && BYTES_BIG_ENDIAN
3115 : #endif
3116 : )
3117 : {
3118 : rtx tem, x;
3119 : int by = (UNITS_PER_WORD - size) * BITS_PER_UNIT;
3120 : rtx reg = gen_rtx_REG (word_mode, REGNO (entry_parm));
3121 :
3122 : x = expand_shift (LSHIFT_EXPR, word_mode, reg, by, NULL_RTX, 1);
3123 : tem = change_address (mem, word_mode, 0);
3124 : emit_move_insn (tem, x);
3125 : }
3126 : else
3127 2428 : move_block_from_reg (REGNO (entry_parm), mem,
3128 1214 : size_stored / UNITS_PER_WORD);
3129 : }
3130 2 : else if (!MEM_P (mem))
3131 : {
3132 0 : gcc_checking_assert (size > UNITS_PER_WORD);
3133 : #ifdef BLOCK_REG_PADDING
3134 : gcc_checking_assert (BLOCK_REG_PADDING (GET_MODE (mem),
3135 : data->arg.type, 0)
3136 : == PAD_UPWARD);
3137 : #endif
3138 0 : emit_move_insn (mem, entry_parm);
3139 : }
3140 : else
3141 2 : move_block_from_reg (REGNO (entry_parm), mem,
3142 2 : size_stored / UNITS_PER_WORD);
3143 : }
3144 68968 : else if (data->stack_parm == 0 && !TYPE_EMPTY_P (data->arg.type))
3145 : {
3146 207 : push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn);
3147 207 : emit_block_move (stack_parm, data->entry_parm, GEN_INT (size),
3148 : BLOCK_OP_NORMAL);
3149 207 : all->first_conversion_insn = get_insns ();
3150 207 : all->last_conversion_insn = get_last_insn ();
3151 207 : end_sequence ();
3152 207 : in_conversion_seq = true;
3153 : }
3154 :
3155 74122 : if (target_reg)
3156 : {
3157 0 : if (!in_conversion_seq)
3158 0 : emit_move_insn (target_reg, stack_parm);
3159 : else
3160 : {
3161 0 : push_to_sequence2 (all->first_conversion_insn,
3162 : all->last_conversion_insn);
3163 0 : emit_move_insn (target_reg, stack_parm);
3164 0 : all->first_conversion_insn = get_insns ();
3165 0 : all->last_conversion_insn = get_last_insn ();
3166 0 : end_sequence ();
3167 : }
3168 : stack_parm = target_reg;
3169 : }
3170 :
3171 74122 : data->stack_parm = stack_parm;
3172 74122 : set_parm_rtl (parm, stack_parm);
3173 74122 : }
3174 :
3175 : /* A subroutine of assign_parms. Allocate a pseudo to hold the current
3176 : parameter. Get it there. Perform all ABI specified conversions. */
3177 :
3178 : static void
3179 2292228 : assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm,
3180 : struct assign_parm_data_one *data)
3181 : {
3182 2292228 : rtx parmreg, validated_mem;
3183 2292228 : rtx equiv_stack_parm;
3184 2292228 : machine_mode promoted_nominal_mode;
3185 2292228 : int unsignedp = TYPE_UNSIGNED (TREE_TYPE (parm));
3186 2292228 : bool did_conversion = false;
3187 2292228 : bool need_conversion, moved;
3188 2292228 : enum insn_code icode;
3189 2292228 : rtx rtl;
3190 :
3191 : /* Store the parm in a pseudoregister during the function, but we may
3192 : need to do it in a wider mode. Using 2 here makes the result
3193 : consistent with promote_decl_mode and thus expand_expr_real_1. */
3194 2292228 : promoted_nominal_mode
3195 4584456 : = promote_function_mode (data->nominal_type, data->nominal_mode, &unsignedp,
3196 2292228 : TREE_TYPE (current_function_decl), 2);
3197 :
3198 2292228 : parmreg = gen_reg_rtx (promoted_nominal_mode);
3199 2292228 : if (!DECL_ARTIFICIAL (parm))
3200 2066659 : mark_user_reg (parmreg);
3201 :
3202 : /* If this was an item that we received a pointer to,
3203 : set rtl appropriately. */
3204 2292228 : if (data->arg.pass_by_reference)
3205 : {
3206 4962 : rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (data->arg.type)), parmreg);
3207 4962 : set_mem_attributes (rtl, parm, 1);
3208 : }
3209 : else
3210 : rtl = parmreg;
3211 :
3212 2292228 : assign_parm_remove_parallels (data);
3213 :
3214 : /* Copy the value into the register, thus bridging between
3215 : assign_parm_find_data_types and expand_expr_real_1. */
3216 :
3217 2292228 : equiv_stack_parm = data->stack_parm;
3218 2292228 : validated_mem = validize_mem (copy_rtx (data->entry_parm));
3219 :
3220 2292228 : need_conversion = (data->nominal_mode != data->passed_mode
3221 2292228 : || promoted_nominal_mode != data->arg.mode);
3222 4171 : moved = false;
3223 :
3224 : if (need_conversion
3225 4171 : && GET_MODE_CLASS (data->nominal_mode) == MODE_INT
3226 3660 : && data->nominal_mode == data->passed_mode
3227 0 : && data->nominal_mode == GET_MODE (data->entry_parm))
3228 : {
3229 : /* ENTRY_PARM has been converted to PROMOTED_MODE, its
3230 : mode, by the caller. We now have to convert it to
3231 : NOMINAL_MODE, if different. However, PARMREG may be in
3232 : a different mode than NOMINAL_MODE if it is being stored
3233 : promoted.
3234 :
3235 : If ENTRY_PARM is a hard register, it might be in a register
3236 : not valid for operating in its mode (e.g., an odd-numbered
3237 : register for a DFmode). In that case, moves are the only
3238 : thing valid, so we can't do a convert from there. This
3239 : occurs when the calling sequence allow such misaligned
3240 : usages.
3241 :
3242 : In addition, the conversion may involve a call, which could
3243 : clobber parameters which haven't been copied to pseudo
3244 : registers yet.
3245 :
3246 : First, we try to emit an insn which performs the necessary
3247 : conversion. We verify that this insn does not clobber any
3248 : hard registers. */
3249 :
3250 0 : rtx op0, op1;
3251 :
3252 0 : icode = can_extend_p (promoted_nominal_mode, data->passed_mode,
3253 : unsignedp);
3254 :
3255 0 : op0 = parmreg;
3256 0 : op1 = validated_mem;
3257 0 : if (icode != CODE_FOR_nothing
3258 0 : && insn_operand_matches (icode, 0, op0)
3259 0 : && insn_operand_matches (icode, 1, op1))
3260 : {
3261 0 : enum rtx_code code = unsignedp ? ZERO_EXTEND : SIGN_EXTEND;
3262 0 : rtx_insn *insn, *insns;
3263 0 : rtx t = op1;
3264 0 : HARD_REG_SET hardregs;
3265 :
3266 0 : start_sequence ();
3267 : /* If op1 is a hard register that is likely spilled, first
3268 : force it into a pseudo, otherwise combiner might extend
3269 : its lifetime too much. */
3270 0 : if (GET_CODE (t) == SUBREG)
3271 0 : t = SUBREG_REG (t);
3272 0 : if (REG_P (t)
3273 0 : && HARD_REGISTER_P (t)
3274 0 : && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (t))
3275 0 : && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (t))))
3276 : {
3277 0 : t = gen_reg_rtx (GET_MODE (op1));
3278 0 : emit_move_insn (t, op1);
3279 : }
3280 : else
3281 : t = op1;
3282 0 : rtx_insn *pat = gen_extend_insn (op0, t, promoted_nominal_mode,
3283 : data->passed_mode, unsignedp);
3284 0 : emit_insn (pat);
3285 0 : insns = get_insns ();
3286 :
3287 0 : moved = true;
3288 0 : CLEAR_HARD_REG_SET (hardregs);
3289 0 : for (insn = insns; insn && moved; insn = NEXT_INSN (insn))
3290 : {
3291 0 : if (INSN_P (insn))
3292 0 : note_stores (insn, record_hard_reg_sets, &hardregs);
3293 0 : if (!hard_reg_set_empty_p (hardregs))
3294 0 : moved = false;
3295 : }
3296 :
3297 0 : end_sequence ();
3298 :
3299 0 : if (moved)
3300 : {
3301 0 : emit_insn (insns);
3302 0 : if (equiv_stack_parm != NULL_RTX)
3303 0 : equiv_stack_parm = gen_rtx_fmt_e (code, GET_MODE (parmreg),
3304 : equiv_stack_parm);
3305 : }
3306 : }
3307 : }
3308 :
3309 0 : if (moved)
3310 : /* Nothing to do. */
3311 : ;
3312 2292228 : else if (need_conversion)
3313 : {
3314 : /* We did not have an insn to convert directly, or the sequence
3315 : generated appeared unsafe. We must first copy the parm to a
3316 : pseudo reg, and save the conversion until after all
3317 : parameters have been moved. */
3318 :
3319 4171 : int save_tree_used;
3320 4171 : rtx tempreg = gen_reg_rtx (GET_MODE (data->entry_parm));
3321 :
3322 4171 : emit_move_insn (tempreg, validated_mem);
3323 :
3324 4171 : push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn);
3325 4171 : tempreg = convert_to_mode (data->nominal_mode, tempreg, unsignedp);
3326 :
3327 4171 : if (partial_subreg_p (tempreg)
3328 3660 : && GET_MODE (tempreg) == data->nominal_mode
3329 3660 : && REG_P (SUBREG_REG (tempreg))
3330 3660 : && data->nominal_mode == data->passed_mode
3331 3660 : && GET_MODE (SUBREG_REG (tempreg)) == GET_MODE (data->entry_parm))
3332 : {
3333 : /* The argument is already sign/zero extended, so note it
3334 : into the subreg. */
3335 0 : SUBREG_PROMOTED_VAR_P (tempreg) = 1;
3336 0 : SUBREG_PROMOTED_SET (tempreg, unsignedp);
3337 : }
3338 :
3339 : /* TREE_USED gets set erroneously during expand_assignment. */
3340 4171 : save_tree_used = TREE_USED (parm);
3341 4171 : SET_DECL_RTL (parm, rtl);
3342 4171 : expand_assignment (parm, make_tree (data->nominal_type, tempreg), false);
3343 4171 : SET_DECL_RTL (parm, NULL_RTX);
3344 4171 : TREE_USED (parm) = save_tree_used;
3345 4171 : all->first_conversion_insn = get_insns ();
3346 4171 : all->last_conversion_insn = get_last_insn ();
3347 4171 : end_sequence ();
3348 :
3349 4171 : did_conversion = true;
3350 : }
3351 2288057 : else if (MEM_P (data->entry_parm)
3352 823856 : && GET_MODE_ALIGNMENT (promoted_nominal_mode)
3353 823914 : > MEM_ALIGN (data->entry_parm)
3354 2311962 : && (((icode = optab_handler (movmisalign_optab,
3355 : promoted_nominal_mode))
3356 : != CODE_FOR_nothing)
3357 23901 : || targetm.slow_unaligned_access (promoted_nominal_mode,
3358 23959 : MEM_ALIGN (data->entry_parm))))
3359 : {
3360 4 : if (icode != CODE_FOR_nothing)
3361 4 : emit_insn (GEN_FCN (icode) (parmreg, validated_mem));
3362 : else
3363 0 : rtl = parmreg = extract_bit_field (validated_mem,
3364 0 : GET_MODE_BITSIZE (promoted_nominal_mode), 0,
3365 : unsignedp, parmreg,
3366 : promoted_nominal_mode, VOIDmode, false, NULL);
3367 : }
3368 : else
3369 2288053 : emit_move_insn (parmreg, validated_mem);
3370 :
3371 : /* If we were passed a pointer but the actual value can live in a register,
3372 : retrieve it and use it directly. Note that we cannot use nominal_mode,
3373 : because it will have been set to Pmode above, we must use the actual mode
3374 : of the parameter instead. */
3375 2292228 : if (data->arg.pass_by_reference && TYPE_MODE (TREE_TYPE (parm)) != BLKmode)
3376 : {
3377 : /* Use a stack slot for debugging purposes if possible. */
3378 711 : if (use_register_for_decl (parm))
3379 : {
3380 373 : parmreg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (parm)));
3381 373 : mark_user_reg (parmreg);
3382 : }
3383 : else
3384 : {
3385 338 : int align = STACK_SLOT_ALIGNMENT (TREE_TYPE (parm),
3386 : TYPE_MODE (TREE_TYPE (parm)),
3387 : TYPE_ALIGN (TREE_TYPE (parm)));
3388 338 : parmreg = assign_stack_local_aligned (TYPE_MODE (TREE_TYPE (parm)),
3389 338 : GET_MODE_SIZE (
3390 338 : TYPE_MODE (TREE_TYPE (parm))),
3391 : align);
3392 338 : set_mem_attributes (parmreg, parm, 1);
3393 : }
3394 :
3395 : /* We need to preserve an address based on VIRTUAL_STACK_VARS_REGNUM for
3396 : the debug info in case it is not legitimate. */
3397 711 : if (GET_MODE (parmreg) != GET_MODE (rtl))
3398 : {
3399 0 : rtx tempreg = gen_reg_rtx (GET_MODE (rtl));
3400 0 : int unsigned_p = TYPE_UNSIGNED (TREE_TYPE (parm));
3401 :
3402 0 : push_to_sequence2 (all->first_conversion_insn,
3403 : all->last_conversion_insn);
3404 0 : emit_move_insn (tempreg, rtl);
3405 0 : tempreg = convert_to_mode (GET_MODE (parmreg), tempreg, unsigned_p);
3406 0 : emit_move_insn (MEM_P (parmreg) ? copy_rtx (parmreg) : parmreg,
3407 : tempreg);
3408 0 : all->first_conversion_insn = get_insns ();
3409 0 : all->last_conversion_insn = get_last_insn ();
3410 0 : end_sequence ();
3411 :
3412 0 : did_conversion = true;
3413 : }
3414 : else
3415 711 : emit_move_insn (MEM_P (parmreg) ? copy_rtx (parmreg) : parmreg, rtl);
3416 :
3417 711 : rtl = parmreg;
3418 :
3419 : /* STACK_PARM is the pointer, not the parm, and PARMREG is
3420 : now the parm. */
3421 711 : data->stack_parm = NULL;
3422 : }
3423 :
3424 2292228 : set_parm_rtl (parm, rtl);
3425 :
3426 : /* Mark the register as eliminable if we did no conversion and it was
3427 : copied from memory at a fixed offset, and the arg pointer was not
3428 : copied to a pseudo-reg. If the arg pointer is a pseudo reg or the
3429 : offset formed an invalid address, such memory-equivalences as we
3430 : make here would screw up life analysis for it. */
3431 2292228 : if (data->nominal_mode == data->passed_mode
3432 2288057 : && !did_conversion
3433 2288057 : && data->stack_parm != 0
3434 879406 : && MEM_P (data->stack_parm)
3435 879406 : && data->locate.offset.var == 0
3436 3171634 : && reg_mentioned_p (virtual_incoming_args_rtx,
3437 879406 : XEXP (data->stack_parm, 0)))
3438 : {
3439 879406 : rtx_insn *linsn = get_last_insn ();
3440 879406 : rtx_insn *sinsn;
3441 879406 : rtx set;
3442 :
3443 : /* Mark complex types separately. */
3444 879406 : if (GET_CODE (parmreg) == CONCAT)
3445 : {
3446 1164 : scalar_mode submode = GET_MODE_INNER (GET_MODE (parmreg));
3447 1164 : int regnor = REGNO (XEXP (parmreg, 0));
3448 1164 : int regnoi = REGNO (XEXP (parmreg, 1));
3449 1164 : rtx stackr = adjust_address_nv (data->stack_parm, submode, 0);
3450 2328 : rtx stacki = adjust_address_nv (data->stack_parm, submode,
3451 : GET_MODE_SIZE (submode));
3452 :
3453 : /* Scan backwards for the set of the real and
3454 : imaginary parts. */
3455 6064 : for (sinsn = linsn; sinsn != 0;
3456 4900 : sinsn = prev_nonnote_insn (sinsn))
3457 : {
3458 4900 : set = single_set (sinsn);
3459 4900 : if (set == 0)
3460 0 : continue;
3461 :
3462 4900 : if (SET_DEST (set) == regno_reg_rtx [regnoi])
3463 1164 : set_unique_reg_note (sinsn, REG_EQUIV, stacki);
3464 3736 : else if (SET_DEST (set) == regno_reg_rtx [regnor])
3465 1164 : set_unique_reg_note (sinsn, REG_EQUIV, stackr);
3466 : }
3467 : }
3468 : else
3469 878242 : set_dst_reg_note (linsn, REG_EQUIV, equiv_stack_parm, parmreg);
3470 : }
3471 :
3472 : /* For pointer data type, suggest pointer register. */
3473 2292228 : if (POINTER_TYPE_P (TREE_TYPE (parm)))
3474 939983 : mark_reg_pointer (parmreg,
3475 939983 : TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
3476 2292228 : }
3477 :
3478 : /* A subroutine of assign_parms. Allocate stack space to hold the current
3479 : parameter. Get it there. Perform all ABI specified conversions. */
3480 :
3481 : static void
3482 819549 : assign_parm_setup_stack (struct assign_parm_data_all *all, tree parm,
3483 : struct assign_parm_data_one *data)
3484 : {
3485 : /* Value must be stored in the stack slot STACK_PARM during function
3486 : execution. */
3487 819549 : bool to_conversion = false;
3488 :
3489 819549 : assign_parm_remove_parallels (data);
3490 :
3491 819549 : if (data->arg.mode != data->nominal_mode)
3492 : {
3493 : /* Conversion is required. */
3494 835 : rtx tempreg = gen_reg_rtx (GET_MODE (data->entry_parm));
3495 :
3496 835 : emit_move_insn (tempreg, validize_mem (copy_rtx (data->entry_parm)));
3497 :
3498 : /* Some ABIs require scalar floating point modes to be passed
3499 : in a wider scalar integer mode. We need to explicitly
3500 : truncate to an integer mode of the correct precision before
3501 : using a SUBREG to reinterpret as a floating point value. */
3502 835 : if (SCALAR_FLOAT_MODE_P (data->nominal_mode)
3503 101 : && SCALAR_INT_MODE_P (data->arg.mode)
3504 835 : && known_lt (GET_MODE_SIZE (data->nominal_mode),
3505 : GET_MODE_SIZE (data->arg.mode)))
3506 0 : tempreg = convert_wider_int_to_float (data->nominal_mode,
3507 : data->arg.mode, tempreg);
3508 :
3509 835 : push_to_sequence2 (all->first_conversion_insn, all->last_conversion_insn);
3510 835 : to_conversion = true;
3511 :
3512 2505 : data->entry_parm = convert_to_mode (data->nominal_mode, tempreg,
3513 835 : TYPE_UNSIGNED (TREE_TYPE (parm)));
3514 :
3515 835 : if (data->stack_parm)
3516 : {
3517 0 : poly_int64 offset
3518 0 : = subreg_lowpart_offset (data->nominal_mode,
3519 0 : GET_MODE (data->stack_parm));
3520 : /* ??? This may need a big-endian conversion on sparc64. */
3521 0 : data->stack_parm
3522 0 : = adjust_address (data->stack_parm, data->nominal_mode, 0);
3523 0 : if (maybe_ne (offset, 0) && MEM_OFFSET_KNOWN_P (data->stack_parm))
3524 0 : set_mem_offset (data->stack_parm,
3525 0 : MEM_OFFSET (data->stack_parm) + offset);
3526 : }
3527 : }
3528 :
3529 819549 : if (data->entry_parm != data->stack_parm)
3530 : {
3531 642381 : rtx src, dest;
3532 :
3533 642381 : if (data->stack_parm == 0)
3534 : {
3535 592597 : int align = STACK_SLOT_ALIGNMENT (data->arg.type,
3536 : GET_MODE (data->entry_parm),
3537 : TYPE_ALIGN (data->arg.type));
3538 592597 : if (align < (int)GET_MODE_ALIGNMENT (GET_MODE (data->entry_parm))
3539 595155 : && ((optab_handler (movmisalign_optab,
3540 2558 : GET_MODE (data->entry_parm))
3541 : != CODE_FOR_nothing)
3542 2558 : || targetm.slow_unaligned_access (GET_MODE (data->entry_parm),
3543 : align)))
3544 0 : align = GET_MODE_ALIGNMENT (GET_MODE (data->entry_parm));
3545 592597 : data->stack_parm
3546 592597 : = assign_stack_local (GET_MODE (data->entry_parm),
3547 1185194 : GET_MODE_SIZE (GET_MODE (data->entry_parm)),
3548 : align);
3549 592597 : align = MEM_ALIGN (data->stack_parm);
3550 592597 : set_mem_attributes (data->stack_parm, parm, 1);
3551 592597 : set_mem_align (data->stack_parm, align);
3552 : }
3553 :
3554 642381 : dest = validize_mem (copy_rtx (data->stack_parm));
3555 642381 : src = validize_mem (copy_rtx (data->entry_parm));
3556 :
3557 642381 : if (TYPE_EMPTY_P (data->arg.type))
3558 : /* Empty types don't really need to be copied. */;
3559 640975 : else if (MEM_P (src))
3560 : {
3561 : /* Use a block move to handle potentially misaligned entry_parm. */
3562 61 : if (!to_conversion)
3563 61 : push_to_sequence2 (all->first_conversion_insn,
3564 : all->last_conversion_insn);
3565 61 : to_conversion = true;
3566 :
3567 61 : emit_block_move (dest, src,
3568 61 : GEN_INT (int_size_in_bytes (data->arg.type)),
3569 : BLOCK_OP_NORMAL);
3570 : }
3571 : else
3572 : {
3573 640914 : if (!REG_P (src))
3574 1531 : src = force_reg (GET_MODE (src), src);
3575 640914 : emit_move_insn (dest, src);
3576 : }
3577 : }
3578 :
3579 819549 : if (to_conversion)
3580 : {
3581 896 : all->first_conversion_insn = get_insns ();
3582 896 : all->last_conversion_insn = get_last_insn ();
3583 896 : end_sequence ();
3584 : }
3585 :
3586 819549 : set_parm_rtl (parm, data->stack_parm);
3587 819549 : }
3588 :
3589 : /* A subroutine of assign_parms. If the ABI splits complex arguments, then
3590 : undo the frobbing that we did in assign_parms_augmented_arg_list. */
3591 :
3592 : static void
3593 0 : assign_parms_unsplit_complex (struct assign_parm_data_all *all,
3594 : vec<tree> fnargs)
3595 : {
3596 0 : tree parm;
3597 0 : tree orig_fnargs = all->orig_fnargs;
3598 0 : unsigned i = 0;
3599 :
3600 0 : for (parm = orig_fnargs; parm; parm = TREE_CHAIN (parm), ++i)
3601 : {
3602 0 : if (TREE_CODE (TREE_TYPE (parm)) == COMPLEX_TYPE
3603 0 : && targetm.calls.split_complex_arg (TREE_TYPE (parm)))
3604 : {
3605 0 : rtx tmp, real, imag;
3606 0 : scalar_mode inner = GET_MODE_INNER (DECL_MODE (parm));
3607 :
3608 0 : real = DECL_RTL (fnargs[i]);
3609 0 : imag = DECL_RTL (fnargs[i + 1]);
3610 0 : if (inner != GET_MODE (real))
3611 : {
3612 0 : real = gen_lowpart_SUBREG (inner, real);
3613 0 : imag = gen_lowpart_SUBREG (inner, imag);
3614 : }
3615 :
3616 0 : if (TREE_ADDRESSABLE (parm))
3617 : {
3618 0 : rtx rmem, imem;
3619 0 : HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (parm));
3620 0 : int align = STACK_SLOT_ALIGNMENT (TREE_TYPE (parm),
3621 : DECL_MODE (parm),
3622 : TYPE_ALIGN (TREE_TYPE (parm)));
3623 :
3624 : /* split_complex_arg put the real and imag parts in
3625 : pseudos. Move them to memory. */
3626 0 : tmp = assign_stack_local (DECL_MODE (parm), size, align);
3627 0 : set_mem_attributes (tmp, parm, 1);
3628 0 : rmem = adjust_address_nv (tmp, inner, 0);
3629 0 : imem = adjust_address_nv (tmp, inner, GET_MODE_SIZE (inner));
3630 0 : push_to_sequence2 (all->first_conversion_insn,
3631 : all->last_conversion_insn);
3632 0 : emit_move_insn (rmem, real);
3633 0 : emit_move_insn (imem, imag);
3634 0 : all->first_conversion_insn = get_insns ();
3635 0 : all->last_conversion_insn = get_last_insn ();
3636 0 : end_sequence ();
3637 : }
3638 : else
3639 0 : tmp = gen_rtx_CONCAT (DECL_MODE (parm), real, imag);
3640 0 : set_parm_rtl (parm, tmp);
3641 :
3642 0 : real = DECL_INCOMING_RTL (fnargs[i]);
3643 0 : imag = DECL_INCOMING_RTL (fnargs[i + 1]);
3644 0 : if (inner != GET_MODE (real))
3645 : {
3646 0 : real = gen_lowpart_SUBREG (inner, real);
3647 0 : imag = gen_lowpart_SUBREG (inner, imag);
3648 : }
3649 0 : tmp = gen_rtx_CONCAT (DECL_MODE (parm), real, imag);
3650 0 : set_decl_incoming_rtl (parm, tmp, false);
3651 0 : i++;
3652 : }
3653 : }
3654 0 : }
3655 :
3656 : /* Assign RTL expressions to the function's parameters. This may involve
3657 : copying them into registers and using those registers as the DECL_RTL. */
3658 :
3659 : static void
3660 1482262 : assign_parms (tree fndecl)
3661 : {
3662 1482262 : struct assign_parm_data_all all;
3663 1482262 : tree parm;
3664 1482262 : vec<tree> fnargs;
3665 1482262 : unsigned i;
3666 :
3667 1482262 : crtl->args.internal_arg_pointer
3668 1482262 : = targetm.calls.internal_arg_pointer ();
3669 :
3670 1482262 : assign_parms_initialize_all (&all);
3671 1482262 : fnargs = assign_parms_augmented_arg_list (&all);
3672 :
3673 1482262 : if (TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (fndecl))
3674 1482262 : && fnargs.is_empty ())
3675 : {
3676 97 : struct assign_parm_data_one data = {};
3677 97 : assign_parms_setup_varargs (&all, &data, false);
3678 : }
3679 :
3680 4668161 : FOR_EACH_VEC_ELT (fnargs, i, parm)
3681 : {
3682 3185899 : struct assign_parm_data_one data;
3683 :
3684 : /* Extract the type of PARM; adjust it according to ABI. */
3685 3185899 : assign_parm_find_data_types (&all, parm, &data);
3686 :
3687 : /* Early out for errors and void parameters. */
3688 3185899 : if (data.passed_mode == VOIDmode)
3689 : {
3690 0 : SET_DECL_RTL (parm, const0_rtx);
3691 0 : DECL_INCOMING_RTL (parm) = DECL_RTL (parm);
3692 0 : continue;
3693 : }
3694 :
3695 : /* Estimate stack alignment from parameter alignment. */
3696 3185899 : if (SUPPORTS_STACK_ALIGNMENT)
3697 : {
3698 3185899 : unsigned int align
3699 6371798 : = targetm.calls.function_arg_boundary (data.arg.mode,
3700 3185899 : data.arg.type);
3701 3185899 : align = MINIMUM_ALIGNMENT (data.arg.type, data.arg.mode, align);
3702 3185899 : if (TYPE_ALIGN (data.nominal_type) > align)
3703 4734 : align = MINIMUM_ALIGNMENT (data.nominal_type,
3704 : TYPE_MODE (data.nominal_type),
3705 : TYPE_ALIGN (data.nominal_type));
3706 3185899 : if (crtl->stack_alignment_estimated < align)
3707 : {
3708 358625 : gcc_assert (!crtl->stack_realign_processed);
3709 358625 : crtl->stack_alignment_estimated = align;
3710 : }
3711 : }
3712 :
3713 : /* Find out where the parameter arrives in this function. */
3714 3185899 : assign_parm_find_entry_rtl (&all, &data);
3715 :
3716 : /* Find out where stack space for this parameter might be. */
3717 3185899 : if (assign_parm_is_stack_parm (&all, &data))
3718 : {
3719 1181652 : assign_parm_find_stack_rtl (parm, &data);
3720 1181652 : assign_parm_adjust_entry_rtl (&data);
3721 : /* For arguments that occupy no space in the parameter
3722 : passing area, have non-zero size and have address taken,
3723 : force creation of a stack slot so that they have distinct
3724 : address from other parameters. */
3725 1181652 : if (TYPE_EMPTY_P (data.arg.type)
3726 6628 : && TREE_ADDRESSABLE (parm)
3727 1565 : && data.entry_parm == data.stack_parm
3728 1565 : && MEM_P (data.entry_parm)
3729 1183217 : && int_size_in_bytes (data.arg.type))
3730 1399 : data.stack_parm = NULL_RTX;
3731 : }
3732 : /* Record permanently how this parm was passed. */
3733 3185899 : if (data.arg.pass_by_reference)
3734 : {
3735 4962 : rtx incoming_rtl
3736 4962 : = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (data.arg.type)),
3737 : data.entry_parm);
3738 4962 : set_decl_incoming_rtl (parm, incoming_rtl, true);
3739 : }
3740 : else
3741 3180937 : set_decl_incoming_rtl (parm, data.entry_parm, false);
3742 :
3743 3185899 : assign_parm_adjust_stack_rtl (parm, &data);
3744 :
3745 3185899 : if (assign_parm_setup_block_p (&data))
3746 74122 : assign_parm_setup_block (&all, parm, &data);
3747 3111777 : else if (data.arg.pass_by_reference || use_register_for_decl (parm))
3748 2292228 : assign_parm_setup_reg (&all, parm, &data);
3749 : else
3750 819549 : assign_parm_setup_stack (&all, parm, &data);
3751 :
3752 3185899 : if (cfun->stdarg && !DECL_CHAIN (parm))
3753 21392 : assign_parms_setup_varargs (&all, &data, false);
3754 :
3755 : /* Update info on where next arg arrives in registers. */
3756 3185899 : targetm.calls.function_arg_advance (all.args_so_far, data.arg);
3757 : }
3758 :
3759 1482262 : if (targetm.calls.split_complex_arg)
3760 0 : assign_parms_unsplit_complex (&all, fnargs);
3761 :
3762 1482262 : fnargs.release ();
3763 :
3764 : /* Output all parameter conversion instructions (possibly including calls)
3765 : now that all parameters have been copied out of hard registers. */
3766 1482262 : emit_insn (all.first_conversion_insn);
3767 :
3768 1482262 : do_pending_stack_adjust ();
3769 :
3770 : /* Estimate reload stack alignment from scalar return mode. */
3771 1482262 : if (SUPPORTS_STACK_ALIGNMENT)
3772 : {
3773 1482262 : if (DECL_RESULT (fndecl))
3774 : {
3775 1482262 : tree type = TREE_TYPE (DECL_RESULT (fndecl));
3776 1482262 : machine_mode mode = TYPE_MODE (type);
3777 :
3778 1482262 : if (mode != BLKmode
3779 1431234 : && mode != VOIDmode
3780 738218 : && !AGGREGATE_TYPE_P (type))
3781 : {
3782 676592 : unsigned int align = GET_MODE_ALIGNMENT (mode);
3783 676592 : if (crtl->stack_alignment_estimated < align)
3784 : {
3785 10 : gcc_assert (!crtl->stack_realign_processed);
3786 10 : crtl->stack_alignment_estimated = align;
3787 : }
3788 : }
3789 : }
3790 : }
3791 :
3792 : /* If we are receiving a struct value address as the first argument, set up
3793 : the RTL for the function result. As this might require code to convert
3794 : the transmitted address to Pmode, we do this here to ensure that possible
3795 : preliminary conversions of the address have been emitted already. */
3796 1482262 : if (all.function_result_decl)
3797 : {
3798 69603 : tree result = DECL_RESULT (current_function_decl);
3799 69603 : rtx addr = DECL_RTL (all.function_result_decl);
3800 69603 : rtx x;
3801 :
3802 69603 : if (DECL_BY_REFERENCE (result))
3803 : {
3804 8891 : SET_DECL_VALUE_EXPR (result, all.function_result_decl);
3805 8891 : x = addr;
3806 : }
3807 : else
3808 : {
3809 60712 : SET_DECL_VALUE_EXPR (result,
3810 : build1 (INDIRECT_REF, TREE_TYPE (result),
3811 : all.function_result_decl));
3812 60712 : addr = convert_memory_address (Pmode, addr);
3813 60712 : x = gen_rtx_MEM (DECL_MODE (result), addr);
3814 60712 : set_mem_attributes (x, result, 1);
3815 : }
3816 :
3817 69603 : DECL_HAS_VALUE_EXPR_P (result) = 1;
3818 :
3819 69603 : set_parm_rtl (result, x);
3820 : }
3821 :
3822 : /* We have aligned all the args, so add space for the pretend args. */
3823 1482262 : crtl->args.pretend_args_size = all.pretend_args_size;
3824 1482262 : all.stack_args_size.constant += all.extra_pretend_bytes;
3825 1482262 : crtl->args.size = all.stack_args_size.constant;
3826 :
3827 : /* Adjust function incoming argument size for alignment and
3828 : minimum length. */
3829 :
3830 1482262 : crtl->args.size = upper_bound (crtl->args.size, all.reg_parm_stack_space);
3831 2964524 : crtl->args.size = aligned_upper_bound (crtl->args.size,
3832 1482262 : PARM_BOUNDARY / BITS_PER_UNIT);
3833 :
3834 1482262 : if (ARGS_GROW_DOWNWARD)
3835 : {
3836 : crtl->args.arg_offset_rtx
3837 : = (all.stack_args_size.var == 0
3838 : ? gen_int_mode (-all.stack_args_size.constant, Pmode)
3839 : : expand_expr (size_diffop (all.stack_args_size.var,
3840 : size_int (-all.stack_args_size.constant)),
3841 : NULL_RTX, VOIDmode, EXPAND_NORMAL));
3842 : }
3843 : else
3844 1608907 : crtl->args.arg_offset_rtx = ARGS_SIZE_RTX (all.stack_args_size);
3845 :
3846 : /* See how many bytes, if any, of its args a function should try to pop
3847 : on return. */
3848 :
3849 1482262 : crtl->args.pops_args = targetm.calls.return_pops_args (fndecl,
3850 1482262 : TREE_TYPE (fndecl),
3851 : crtl->args.size);
3852 :
3853 : /* For stdarg.h function, save info about
3854 : regs and stack space used by the named args. */
3855 :
3856 1482262 : crtl->args.info = all.args_so_far_v;
3857 :
3858 : /* Set the rtx used for the function return value. Put this in its
3859 : own variable so any optimizers that need this information don't have
3860 : to include tree.h. Do this here so it gets done when an inlined
3861 : function gets output. */
3862 :
3863 1482262 : crtl->return_rtx
3864 1482262 : = (DECL_RTL_SET_P (DECL_RESULT (fndecl))
3865 2271508 : ? DECL_RTL (DECL_RESULT (fndecl)) : NULL_RTX);
3866 :
3867 : /* If scalar return value was computed in a pseudo-reg, or was a named
3868 : return value that got dumped to the stack, copy that to the hard
3869 : return register. */
3870 1482262 : if (DECL_RTL_SET_P (DECL_RESULT (fndecl)))
3871 : {
3872 789246 : tree decl_result = DECL_RESULT (fndecl);
3873 789246 : rtx decl_rtl = DECL_RTL (decl_result);
3874 :
3875 789246 : if (REG_P (decl_rtl)
3876 789246 : ? REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER
3877 67422 : : DECL_REGISTER (decl_result))
3878 : {
3879 726639 : rtx real_decl_rtl;
3880 :
3881 : /* Unless the psABI says not to. */
3882 726639 : if (TYPE_EMPTY_P (TREE_TYPE (decl_result)))
3883 : real_decl_rtl = NULL_RTX;
3884 : else
3885 : {
3886 721959 : real_decl_rtl
3887 721959 : = targetm.calls.function_value (TREE_TYPE (decl_result),
3888 : fndecl, true);
3889 721959 : REG_FUNCTION_VALUE_P (real_decl_rtl) = 1;
3890 : }
3891 : /* The delay slot scheduler assumes that crtl->return_rtx
3892 : holds the hard register containing the return value, not a
3893 : temporary pseudo. */
3894 726639 : crtl->return_rtx = real_decl_rtl;
3895 : }
3896 : }
3897 1482262 : }
3898 :
3899 : /* Gimplify the parameter list for current_function_decl. This involves
3900 : evaluating SAVE_EXPRs of variable sized parameters and generating code
3901 : to implement callee-copies reference parameters. Returns a sequence of
3902 : statements to add to the beginning of the function. */
3903 :
3904 : gimple_seq
3905 2900388 : gimplify_parameters (gimple_seq *cleanup)
3906 : {
3907 2900388 : struct assign_parm_data_all all;
3908 2900388 : tree parm;
3909 2900388 : gimple_seq stmts = NULL;
3910 2900388 : vec<tree> fnargs;
3911 2900388 : unsigned i;
3912 :
3913 2900388 : assign_parms_initialize_all (&all);
3914 2900388 : fnargs = assign_parms_augmented_arg_list (&all);
3915 :
3916 8898793 : FOR_EACH_VEC_ELT (fnargs, i, parm)
3917 : {
3918 5998405 : struct assign_parm_data_one data;
3919 :
3920 : /* Extract the type of PARM; adjust it according to ABI. */
3921 5998405 : assign_parm_find_data_types (&all, parm, &data);
3922 :
3923 : /* Early out for errors and void parameters. */
3924 5998405 : if (data.passed_mode == VOIDmode || DECL_SIZE (parm) == NULL)
3925 87 : continue;
3926 :
3927 : /* Update info on where next arg arrives in registers. */
3928 5998318 : targetm.calls.function_arg_advance (all.args_so_far, data.arg);
3929 :
3930 : /* ??? Once upon a time variable_size stuffed parameter list
3931 : SAVE_EXPRs (amongst others) onto a pending sizes list. This
3932 : turned out to be less than manageable in the gimple world.
3933 : Now we have to hunt them down ourselves. */
3934 5998318 : gimplify_type_sizes (TREE_TYPE (parm), &stmts);
3935 :
3936 5998318 : if (TREE_CODE (DECL_SIZE_UNIT (parm)) != INTEGER_CST)
3937 : {
3938 41 : gimplify_one_sizepos (&DECL_SIZE (parm), &stmts);
3939 41 : gimplify_one_sizepos (&DECL_SIZE_UNIT (parm), &stmts);
3940 : }
3941 :
3942 5998318 : if (data.arg.pass_by_reference)
3943 : {
3944 4970 : tree type = TREE_TYPE (data.arg.type);
3945 4970 : function_arg_info orig_arg (type, data.arg.named);
3946 4970 : if (reference_callee_copied (&all.args_so_far_v, orig_arg))
3947 : {
3948 0 : tree local, t;
3949 :
3950 : /* For constant-sized objects, this is trivial; for
3951 : variable-sized objects, we have to play games. */
3952 0 : if (TREE_CODE (DECL_SIZE_UNIT (parm)) == INTEGER_CST
3953 0 : && !(flag_stack_check == GENERIC_STACK_CHECK
3954 0 : && compare_tree_int (DECL_SIZE_UNIT (parm),
3955 : STACK_CHECK_MAX_VAR_SIZE) > 0))
3956 : {
3957 0 : local = create_tmp_var (type, get_name (parm));
3958 0 : DECL_IGNORED_P (local) = 0;
3959 : /* If PARM was addressable, move that flag over
3960 : to the local copy, as its address will be taken,
3961 : not the PARMs. Keep the parms address taken
3962 : as we'll query that flag during gimplification. */
3963 0 : if (TREE_ADDRESSABLE (parm))
3964 0 : TREE_ADDRESSABLE (local) = 1;
3965 0 : if (DECL_NOT_GIMPLE_REG_P (parm))
3966 0 : DECL_NOT_GIMPLE_REG_P (local) = 1;
3967 :
3968 0 : if (!is_gimple_reg (local)
3969 0 : && flag_stack_reuse != SR_NONE)
3970 : {
3971 0 : tree clobber = build_clobber (type);
3972 0 : gimple *clobber_stmt;
3973 0 : clobber_stmt = gimple_build_assign (local, clobber);
3974 0 : gimple_seq_add_stmt (cleanup, clobber_stmt);
3975 : }
3976 : }
3977 : else
3978 : {
3979 0 : tree ptr_type, addr;
3980 :
3981 0 : ptr_type = build_pointer_type (type);
3982 0 : addr = create_tmp_reg (ptr_type, get_name (parm));
3983 0 : DECL_IGNORED_P (addr) = 0;
3984 0 : local = build_fold_indirect_ref (addr);
3985 :
3986 0 : t = build_alloca_call_expr (DECL_SIZE_UNIT (parm),
3987 0 : DECL_ALIGN (parm),
3988 : max_int_size_in_bytes (type));
3989 : /* The call has been built for a variable-sized object. */
3990 0 : CALL_ALLOCA_FOR_VAR_P (t) = 1;
3991 0 : t = fold_convert (ptr_type, t);
3992 0 : t = build2 (MODIFY_EXPR, TREE_TYPE (addr), addr, t);
3993 0 : gimplify_and_add (t, &stmts);
3994 : }
3995 :
3996 0 : gimplify_assign (local, parm, &stmts);
3997 :
3998 0 : SET_DECL_VALUE_EXPR (parm, local);
3999 0 : DECL_HAS_VALUE_EXPR_P (parm) = 1;
4000 : }
4001 : }
4002 : }
4003 :
4004 2900388 : fnargs.release ();
4005 :
4006 2900388 : return stmts;
4007 : }
4008 :
4009 : /* Compute the size and offset from the start of the stacked arguments for a
4010 : parm passed in mode PASSED_MODE and with type TYPE.
4011 :
4012 : INITIAL_OFFSET_PTR points to the current offset into the stacked
4013 : arguments.
4014 :
4015 : The starting offset and size for this parm are returned in
4016 : LOCATE->OFFSET and LOCATE->SIZE, respectively. When IN_REGS is
4017 : nonzero, the offset is that of stack slot, which is returned in
4018 : LOCATE->SLOT_OFFSET. LOCATE->ALIGNMENT_PAD is the amount of
4019 : padding required from the initial offset ptr to the stack slot.
4020 :
4021 : IN_REGS is nonzero if the argument will be passed in registers. It will
4022 : never be set if REG_PARM_STACK_SPACE is not defined.
4023 :
4024 : REG_PARM_STACK_SPACE is the number of bytes of stack space reserved
4025 : for arguments which are passed in registers.
4026 :
4027 : FNDECL is the function in which the argument was defined.
4028 :
4029 : There are two types of rounding that are done. The first, controlled by
4030 : TARGET_FUNCTION_ARG_BOUNDARY, forces the offset from the start of the
4031 : argument list to be aligned to the specific boundary (in bits). This
4032 : rounding affects the initial and starting offsets, but not the argument
4033 : size.
4034 :
4035 : The second, controlled by TARGET_FUNCTION_ARG_PADDING and PARM_BOUNDARY,
4036 : optionally rounds the size of the parm to PARM_BOUNDARY. The
4037 : initial offset is not affected by this rounding, while the size always
4038 : is and the starting offset may be. */
4039 :
4040 : /* LOCATE->OFFSET will be negative for ARGS_GROW_DOWNWARD case;
4041 : INITIAL_OFFSET_PTR is positive because locate_and_pad_parm's
4042 : callers pass in the total size of args so far as
4043 : INITIAL_OFFSET_PTR. LOCATE->SIZE is always positive. */
4044 :
4045 : void
4046 5439523 : locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
4047 : int reg_parm_stack_space, int partial,
4048 : tree fndecl ATTRIBUTE_UNUSED,
4049 : struct args_size *initial_offset_ptr,
4050 : struct locate_and_pad_arg_data *locate)
4051 : {
4052 5439523 : tree sizetree;
4053 5439523 : pad_direction where_pad;
4054 5439523 : unsigned int boundary, round_boundary;
4055 5439523 : int part_size_in_regs;
4056 :
4057 : /* If we have found a stack parm before we reach the end of the
4058 : area reserved for registers, skip that area. */
4059 5439523 : if (! in_regs)
4060 : {
4061 3258902 : if (reg_parm_stack_space > 0)
4062 : {
4063 83759 : if (initial_offset_ptr->var
4064 83759 : || !ordered_p (initial_offset_ptr->constant,
4065 : reg_parm_stack_space))
4066 : {
4067 0 : initial_offset_ptr->var
4068 0 : = size_binop (MAX_EXPR, ARGS_SIZE_TREE (*initial_offset_ptr),
4069 : ssize_int (reg_parm_stack_space));
4070 0 : initial_offset_ptr->constant = 0;
4071 : }
4072 : else
4073 83759 : initial_offset_ptr->constant
4074 83759 : = ordered_max (initial_offset_ptr->constant,
4075 : reg_parm_stack_space);
4076 : }
4077 : }
4078 :
4079 5439523 : part_size_in_regs = (reg_parm_stack_space == 0 ? partial : 0);
4080 :
4081 5439523 : sizetree = (type
4082 5439523 : ? arg_size_in_bytes (type)
4083 37967 : : size_int (GET_MODE_SIZE (passed_mode)));
4084 5439523 : where_pad = targetm.calls.function_arg_padding (passed_mode, type);
4085 5439523 : boundary = targetm.calls.function_arg_boundary (passed_mode, type);
4086 5439523 : round_boundary = targetm.calls.function_arg_round_boundary (passed_mode,
4087 : type);
4088 5439523 : locate->where_pad = where_pad;
4089 :
4090 : /* Alignment can't exceed MAX_SUPPORTED_STACK_ALIGNMENT. */
4091 5439523 : if (boundary > MAX_SUPPORTED_STACK_ALIGNMENT)
4092 : boundary = MAX_SUPPORTED_STACK_ALIGNMENT;
4093 :
4094 5439523 : locate->boundary = boundary;
4095 :
4096 5439523 : if (SUPPORTS_STACK_ALIGNMENT)
4097 : {
4098 : /* stack_alignment_estimated can't change after stack has been
4099 : realigned. */
4100 5439523 : if (crtl->stack_alignment_estimated < boundary)
4101 : {
4102 5076 : if (!crtl->stack_realign_processed)
4103 5076 : crtl->stack_alignment_estimated = boundary;
4104 : else
4105 : {
4106 : /* If stack is realigned and stack alignment value
4107 : hasn't been finalized, it is OK not to increase
4108 : stack_alignment_estimated. The bigger alignment
4109 : requirement is recorded in stack_alignment_needed
4110 : below. */
4111 0 : gcc_assert (!crtl->stack_realign_finalized
4112 : && crtl->stack_realign_needed);
4113 : }
4114 : }
4115 : }
4116 :
4117 5439523 : if (ARGS_GROW_DOWNWARD)
4118 : {
4119 : locate->slot_offset.constant = -initial_offset_ptr->constant;
4120 : if (initial_offset_ptr->var)
4121 : locate->slot_offset.var = size_binop (MINUS_EXPR, ssize_int (0),
4122 : initial_offset_ptr->var);
4123 :
4124 : {
4125 : tree s2 = sizetree;
4126 : if (where_pad != PAD_NONE
4127 : && (!tree_fits_uhwi_p (sizetree)
4128 : || (tree_to_uhwi (sizetree) * BITS_PER_UNIT) % round_boundary))
4129 : s2 = round_up (s2, round_boundary / BITS_PER_UNIT);
4130 : SUB_PARM_SIZE (locate->slot_offset, s2);
4131 : }
4132 :
4133 : locate->slot_offset.constant += part_size_in_regs;
4134 :
4135 : if (!in_regs || reg_parm_stack_space > 0)
4136 : pad_to_arg_alignment (&locate->slot_offset, boundary,
4137 : &locate->alignment_pad);
4138 :
4139 : locate->size.constant = (-initial_offset_ptr->constant
4140 : - locate->slot_offset.constant);
4141 : if (initial_offset_ptr->var)
4142 : locate->size.var = size_binop (MINUS_EXPR,
4143 : size_binop (MINUS_EXPR,
4144 : ssize_int (0),
4145 : initial_offset_ptr->var),
4146 : locate->slot_offset.var);
4147 :
4148 : /* Pad_below needs the pre-rounded size to know how much to pad
4149 : below. */
4150 : locate->offset = locate->slot_offset;
4151 : if (where_pad == PAD_DOWNWARD)
4152 : pad_below (&locate->offset, passed_mode, sizetree);
4153 :
4154 : }
4155 : else
4156 : {
4157 5439523 : if (!in_regs || reg_parm_stack_space > 0)
4158 3435276 : pad_to_arg_alignment (initial_offset_ptr, boundary,
4159 : &locate->alignment_pad);
4160 5439523 : locate->slot_offset = *initial_offset_ptr;
4161 :
4162 : #ifdef PUSH_ROUNDING
4163 5439523 : if (passed_mode != BLKmode)
4164 5094360 : sizetree = size_int (PUSH_ROUNDING (TREE_INT_CST_LOW (sizetree)));
4165 : #endif
4166 :
4167 : /* Pad_below needs the pre-rounded size to know how much to pad below
4168 : so this must be done before rounding up. */
4169 5439523 : locate->offset = locate->slot_offset;
4170 5439523 : if (where_pad == PAD_DOWNWARD)
4171 0 : pad_below (&locate->offset, passed_mode, sizetree);
4172 :
4173 5439523 : if (where_pad != PAD_NONE
4174 5439523 : && (!tree_fits_uhwi_p (sizetree)
4175 5439523 : || (tree_to_uhwi (sizetree) * BITS_PER_UNIT) % round_boundary))
4176 18560 : sizetree = round_up (sizetree, round_boundary / BITS_PER_UNIT);
4177 :
4178 5439523 : ADD_PARM_SIZE (locate->size, sizetree);
4179 :
4180 5439523 : locate->size.constant -= part_size_in_regs;
4181 : }
4182 :
4183 5439523 : locate->offset.constant
4184 5439523 : += targetm.calls.function_arg_offset (passed_mode, type);
4185 5439523 : }
4186 :
4187 : /* Round the stack offset in *OFFSET_PTR up to a multiple of BOUNDARY.
4188 : BOUNDARY is measured in bits, but must be a multiple of a storage unit. */
4189 :
4190 : static void
4191 3435276 : pad_to_arg_alignment (struct args_size *offset_ptr, int boundary,
4192 : struct args_size *alignment_pad)
4193 : {
4194 3435276 : tree save_var = NULL_TREE;
4195 3435276 : poly_int64 save_constant = 0;
4196 3435276 : int boundary_in_bytes = boundary / BITS_PER_UNIT;
4197 3435276 : poly_int64 sp_offset = STACK_POINTER_OFFSET;
4198 :
4199 : #ifdef SPARC_STACK_BOUNDARY_HACK
4200 : /* ??? The SPARC port may claim a STACK_BOUNDARY higher than
4201 : the real alignment of %sp. However, when it does this, the
4202 : alignment of %sp+STACK_POINTER_OFFSET is STACK_BOUNDARY. */
4203 : if (SPARC_STACK_BOUNDARY_HACK)
4204 : sp_offset = 0;
4205 : #endif
4206 :
4207 5198136 : if (boundary > PARM_BOUNDARY)
4208 : {
4209 140465 : save_var = offset_ptr->var;
4210 140465 : save_constant = offset_ptr->constant;
4211 : }
4212 :
4213 3435276 : alignment_pad->var = NULL_TREE;
4214 3435276 : alignment_pad->constant = 0;
4215 :
4216 3435276 : if (boundary > BITS_PER_UNIT)
4217 : {
4218 3435276 : int misalign;
4219 3435276 : if (offset_ptr->var
4220 3435276 : || !known_misalignment (offset_ptr->constant + sp_offset,
4221 : boundary_in_bytes, &misalign))
4222 : {
4223 0 : tree sp_offset_tree = ssize_int (sp_offset);
4224 0 : tree offset = size_binop (PLUS_EXPR,
4225 : ARGS_SIZE_TREE (*offset_ptr),
4226 : sp_offset_tree);
4227 0 : tree rounded;
4228 0 : if (ARGS_GROW_DOWNWARD)
4229 : rounded = round_down (offset, boundary / BITS_PER_UNIT);
4230 : else
4231 0 : rounded = round_up (offset, boundary / BITS_PER_UNIT);
4232 :
4233 0 : offset_ptr->var = size_binop (MINUS_EXPR, rounded, sp_offset_tree);
4234 : /* ARGS_SIZE_TREE includes constant term. */
4235 0 : offset_ptr->constant = 0;
4236 0 : if (boundary > PARM_BOUNDARY)
4237 0 : alignment_pad->var = size_binop (MINUS_EXPR, offset_ptr->var,
4238 : save_var);
4239 : }
4240 : else
4241 : {
4242 3435276 : if (ARGS_GROW_DOWNWARD)
4243 : offset_ptr->constant -= misalign;
4244 : else
4245 3435276 : offset_ptr->constant += -misalign & (boundary_in_bytes - 1);
4246 :
4247 3435276 : if (boundary > PARM_BOUNDARY)
4248 140465 : alignment_pad->constant = offset_ptr->constant - save_constant;
4249 : }
4250 : }
4251 3435276 : }
4252 :
4253 : static void
4254 0 : pad_below (struct args_size *offset_ptr, machine_mode passed_mode, tree sizetree)
4255 : {
4256 0 : unsigned int align = PARM_BOUNDARY / BITS_PER_UNIT;
4257 0 : int misalign;
4258 0 : if (passed_mode != BLKmode
4259 0 : && known_misalignment (GET_MODE_SIZE (passed_mode), align, &misalign))
4260 0 : offset_ptr->constant += -misalign & (align - 1);
4261 : else
4262 : {
4263 0 : if (TREE_CODE (sizetree) != INTEGER_CST
4264 0 : || (TREE_INT_CST_LOW (sizetree) & (align - 1)) != 0)
4265 : {
4266 : /* Round the size up to multiple of PARM_BOUNDARY bits. */
4267 0 : tree s2 = round_up (sizetree, align);
4268 : /* Add it in. */
4269 0 : ADD_PARM_SIZE (*offset_ptr, s2);
4270 0 : SUB_PARM_SIZE (*offset_ptr, sizetree);
4271 : }
4272 : }
4273 0 : }
4274 :
4275 :
4276 : /* True if register REGNO was alive at a place where `setjmp' was
4277 : called and was set more than once or is an argument. Such regs may
4278 : be clobbered by `longjmp'. */
4279 :
4280 : static bool
4281 44 : regno_clobbered_at_setjmp (bitmap setjmp_crosses, int regno)
4282 : {
4283 : /* There appear to be cases where some local vars never reach the
4284 : backend but have bogus regnos. */
4285 44 : if (regno >= max_reg_num ())
4286 : return false;
4287 :
4288 44 : return ((REG_N_SETS (regno) > 1
4289 42 : || REGNO_REG_SET_P (df_get_live_out (ENTRY_BLOCK_PTR_FOR_FN (cfun)),
4290 : regno))
4291 44 : && REGNO_REG_SET_P (setjmp_crosses, regno));
4292 : }
4293 :
4294 : /* Walk the tree of blocks describing the binding levels within a
4295 : function and warn about variables the might be killed by setjmp or
4296 : vfork. This is done after calling flow_analysis before register
4297 : allocation since that will clobber the pseudo-regs to hard
4298 : regs. */
4299 :
4300 : static void
4301 83 : setjmp_vars_warning (bitmap setjmp_crosses, tree block)
4302 : {
4303 83 : tree decl, sub;
4304 :
4305 212 : for (decl = BLOCK_VARS (block); decl; decl = DECL_CHAIN (decl))
4306 : {
4307 129 : if (VAR_P (decl)
4308 129 : && DECL_RTL_SET_P (decl)
4309 35 : && REG_P (DECL_RTL (decl))
4310 147 : && regno_clobbered_at_setjmp (setjmp_crosses, REGNO (DECL_RTL (decl))))
4311 1 : warning (OPT_Wclobbered, "variable %q+D might be clobbered by"
4312 : " %<longjmp%> or %<vfork%>", decl);
4313 : }
4314 :
4315 142 : for (sub = BLOCK_SUBBLOCKS (block); sub; sub = BLOCK_CHAIN (sub))
4316 59 : setjmp_vars_warning (setjmp_crosses, sub);
4317 83 : }
4318 :
4319 : /* Do the appropriate part of setjmp_vars_warning
4320 : but for arguments instead of local variables. */
4321 :
4322 : static void
4323 24 : setjmp_args_warning (bitmap setjmp_crosses)
4324 : {
4325 24 : tree decl;
4326 24 : for (decl = DECL_ARGUMENTS (current_function_decl);
4327 50 : decl; decl = DECL_CHAIN (decl))
4328 26 : if (DECL_RTL (decl) != 0
4329 26 : && REG_P (DECL_RTL (decl))
4330 52 : && regno_clobbered_at_setjmp (setjmp_crosses, REGNO (DECL_RTL (decl))))
4331 0 : warning (OPT_Wclobbered,
4332 : "argument %q+D might be clobbered by %<longjmp%> or %<vfork%>",
4333 : decl);
4334 24 : }
4335 :
4336 : /* Generate warning messages for variables live across setjmp. */
4337 :
4338 : void
4339 135488 : generate_setjmp_warnings (void)
4340 : {
4341 135488 : bitmap setjmp_crosses = regstat_get_setjmp_crosses ();
4342 :
4343 135488 : if (n_basic_blocks_for_fn (cfun) == NUM_FIXED_BLOCKS
4344 135488 : || bitmap_empty_p (setjmp_crosses))
4345 : return;
4346 :
4347 24 : setjmp_vars_warning (setjmp_crosses, DECL_INITIAL (current_function_decl));
4348 24 : setjmp_args_warning (setjmp_crosses);
4349 : }
4350 :
4351 :
4352 : /* Reverse the order of elements in the fragment chain T of blocks,
4353 : and return the new head of the chain (old last element).
4354 : In addition to that clear BLOCK_SAME_RANGE flags when needed
4355 : and adjust BLOCK_SUPERCONTEXT from the super fragment to
4356 : its super fragment origin. */
4357 :
4358 : static tree
4359 5607429 : block_fragments_nreverse (tree t)
4360 : {
4361 5607429 : tree prev = 0, block, next, prev_super = 0;
4362 5607429 : tree super = BLOCK_SUPERCONTEXT (t);
4363 5607429 : if (BLOCK_FRAGMENT_ORIGIN (super))
4364 4641952 : super = BLOCK_FRAGMENT_ORIGIN (super);
4365 16641212 : for (block = t; block; block = next)
4366 : {
4367 11033783 : next = BLOCK_FRAGMENT_CHAIN (block);
4368 11033783 : BLOCK_FRAGMENT_CHAIN (block) = prev;
4369 5426354 : if ((prev && !BLOCK_SAME_RANGE (prev))
4370 14151636 : || (BLOCK_FRAGMENT_CHAIN (BLOCK_SUPERCONTEXT (block))
4371 : != prev_super))
4372 3176511 : BLOCK_SAME_RANGE (block) = 0;
4373 11033783 : prev_super = BLOCK_SUPERCONTEXT (block);
4374 11033783 : BLOCK_SUPERCONTEXT (block) = super;
4375 11033783 : prev = block;
4376 : }
4377 5607429 : t = BLOCK_FRAGMENT_ORIGIN (t);
4378 5607429 : if (BLOCK_FRAGMENT_CHAIN (BLOCK_SUPERCONTEXT (t))
4379 : != prev_super)
4380 1799996 : BLOCK_SAME_RANGE (t) = 0;
4381 5607429 : BLOCK_SUPERCONTEXT (t) = super;
4382 5607429 : return prev;
4383 : }
4384 :
4385 : /* Reverse the order of elements in the chain T of blocks,
4386 : and return the new head of the chain (old last element).
4387 : Also do the same on subblocks and reverse the order of elements
4388 : in BLOCK_FRAGMENT_CHAIN as well. */
4389 :
4390 : static tree
4391 23776812 : blocks_nreverse_all (tree t)
4392 : {
4393 23776812 : tree prev = 0, block, next;
4394 46979837 : for (block = t; block; block = next)
4395 : {
4396 23203025 : next = BLOCK_CHAIN (block);
4397 23203025 : BLOCK_CHAIN (block) = prev;
4398 23203025 : if (BLOCK_FRAGMENT_CHAIN (block)
4399 23203025 : && BLOCK_FRAGMENT_ORIGIN (block) == NULL_TREE)
4400 : {
4401 11214858 : BLOCK_FRAGMENT_CHAIN (block)
4402 5607429 : = block_fragments_nreverse (BLOCK_FRAGMENT_CHAIN (block));
4403 5607429 : if (!BLOCK_SAME_RANGE (BLOCK_FRAGMENT_CHAIN (block)))
4404 2662772 : BLOCK_SAME_RANGE (block) = 0;
4405 : }
4406 23203025 : BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block));
4407 23203025 : prev = block;
4408 : }
4409 23776812 : return prev;
4410 : }
4411 :
4412 :
4413 : /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},
4414 : and create duplicate blocks. */
4415 : /* ??? Need an option to either create block fragments or to create
4416 : abstract origin duplicates of a source block. It really depends
4417 : on what optimization has been performed. */
4418 :
4419 : void
4420 573787 : reorder_blocks (void)
4421 : {
4422 573787 : tree block = DECL_INITIAL (current_function_decl);
4423 :
4424 573787 : if (block == NULL_TREE)
4425 0 : return;
4426 :
4427 573787 : auto_vec<tree, 10> block_stack;
4428 :
4429 : /* Reset the TREE_ASM_WRITTEN bit for all blocks. */
4430 573787 : clear_block_marks (block);
4431 :
4432 : /* Prune the old trees away, so that they don't get in the way. */
4433 573787 : BLOCK_SUBBLOCKS (block) = NULL_TREE;
4434 573787 : BLOCK_CHAIN (block) = NULL_TREE;
4435 :
4436 : /* Recreate the block tree from the note nesting. */
4437 573787 : reorder_blocks_1 (get_insns (), block, &block_stack);
4438 573787 : BLOCK_SUBBLOCKS (block) = blocks_nreverse_all (BLOCK_SUBBLOCKS (block));
4439 573787 : }
4440 :
4441 : /* Helper function for reorder_blocks. Reset TREE_ASM_WRITTEN. */
4442 :
4443 : void
4444 24513276 : clear_block_marks (tree block)
4445 : {
4446 45552911 : while (block)
4447 : {
4448 21039635 : TREE_ASM_WRITTEN (block) = 0;
4449 21039635 : clear_block_marks (BLOCK_SUBBLOCKS (block));
4450 21039635 : block = BLOCK_CHAIN (block);
4451 : }
4452 24513276 : }
4453 :
4454 : static void
4455 573787 : reorder_blocks_1 (rtx_insn *insns, tree current_block,
4456 : vec<tree> *p_block_stack)
4457 : {
4458 573787 : rtx_insn *insn;
4459 573787 : tree prev_beg = NULL_TREE, prev_end = NULL_TREE;
4460 :
4461 192163845 : for (insn = insns; insn; insn = NEXT_INSN (insn))
4462 : {
4463 191590058 : if (NOTE_P (insn))
4464 : {
4465 138997198 : if (NOTE_KIND (insn) == NOTE_INSN_BLOCK_BEG)
4466 : {
4467 23203025 : tree block = NOTE_BLOCK (insn);
4468 23203025 : tree origin;
4469 :
4470 23203025 : gcc_assert (BLOCK_FRAGMENT_ORIGIN (block) == NULL_TREE);
4471 23203025 : origin = block;
4472 :
4473 23203025 : if (prev_end)
4474 1440167 : BLOCK_SAME_RANGE (prev_end) = 0;
4475 23203025 : prev_end = NULL_TREE;
4476 :
4477 : /* If we have seen this block before, that means it now
4478 : spans multiple address regions. Create a new fragment. */
4479 23203025 : if (TREE_ASM_WRITTEN (block))
4480 : {
4481 11033783 : tree new_block = copy_node (block);
4482 :
4483 11033783 : BLOCK_SAME_RANGE (new_block) = 0;
4484 11033783 : BLOCK_FRAGMENT_ORIGIN (new_block) = origin;
4485 11033783 : BLOCK_FRAGMENT_CHAIN (new_block)
4486 11033783 : = BLOCK_FRAGMENT_CHAIN (origin);
4487 11033783 : BLOCK_FRAGMENT_CHAIN (origin) = new_block;
4488 :
4489 11033783 : NOTE_BLOCK (insn) = new_block;
4490 11033783 : block = new_block;
4491 : }
4492 :
4493 23203025 : if (prev_beg == current_block && prev_beg)
4494 15165613 : BLOCK_SAME_RANGE (block) = 1;
4495 :
4496 23203025 : prev_beg = origin;
4497 :
4498 23203025 : BLOCK_SUBBLOCKS (block) = 0;
4499 23203025 : TREE_ASM_WRITTEN (block) = 1;
4500 : /* When there's only one block for the entire function,
4501 : current_block == block and we mustn't do this, it
4502 : will cause infinite recursion. */
4503 23203025 : if (block != current_block)
4504 : {
4505 23203025 : tree super;
4506 23203025 : if (block != origin)
4507 11033783 : gcc_assert (BLOCK_SUPERCONTEXT (origin) == current_block
4508 : || BLOCK_FRAGMENT_ORIGIN (BLOCK_SUPERCONTEXT
4509 : (origin))
4510 : == current_block);
4511 23203025 : if (p_block_stack->is_empty ())
4512 : super = current_block;
4513 : else
4514 : {
4515 20884455 : super = p_block_stack->last ();
4516 32108383 : gcc_assert (super == current_block
4517 : || BLOCK_FRAGMENT_ORIGIN (super)
4518 : == current_block);
4519 : }
4520 23203025 : BLOCK_SUPERCONTEXT (block) = super;
4521 23203025 : BLOCK_CHAIN (block) = BLOCK_SUBBLOCKS (current_block);
4522 23203025 : BLOCK_SUBBLOCKS (current_block) = block;
4523 23203025 : current_block = origin;
4524 : }
4525 23203025 : p_block_stack->safe_push (block);
4526 : }
4527 115794173 : else if (NOTE_KIND (insn) == NOTE_INSN_BLOCK_END)
4528 : {
4529 23203025 : NOTE_BLOCK (insn) = p_block_stack->pop ();
4530 23203025 : current_block = BLOCK_SUPERCONTEXT (current_block);
4531 23203025 : if (BLOCK_FRAGMENT_ORIGIN (current_block))
4532 3732682 : current_block = BLOCK_FRAGMENT_ORIGIN (current_block);
4533 23203025 : prev_beg = NULL_TREE;
4534 38368638 : prev_end = BLOCK_SAME_RANGE (NOTE_BLOCK (insn))
4535 23203025 : ? NOTE_BLOCK (insn) : NULL_TREE;
4536 : }
4537 : }
4538 : else
4539 : {
4540 52592860 : prev_beg = NULL_TREE;
4541 52592860 : if (prev_end)
4542 747993 : BLOCK_SAME_RANGE (prev_end) = 0;
4543 : prev_end = NULL_TREE;
4544 : }
4545 : }
4546 573787 : }
4547 :
4548 : /* Reverse the order of elements in the chain T of blocks,
4549 : and return the new head of the chain (old last element). */
4550 :
4551 : tree
4552 31770753 : blocks_nreverse (tree t)
4553 : {
4554 31770753 : tree prev = 0, block, next;
4555 56012700 : for (block = t; block; block = next)
4556 : {
4557 24241947 : next = BLOCK_CHAIN (block);
4558 24241947 : BLOCK_CHAIN (block) = prev;
4559 24241947 : prev = block;
4560 : }
4561 31770753 : return prev;
4562 : }
4563 :
4564 : /* Concatenate two chains of blocks (chained through BLOCK_CHAIN)
4565 : by modifying the last node in chain 1 to point to chain 2. */
4566 :
4567 : tree
4568 82945955 : block_chainon (tree op1, tree op2)
4569 : {
4570 82945955 : tree t1;
4571 :
4572 82945955 : if (!op1)
4573 : return op2;
4574 4125135 : if (!op2)
4575 : return op1;
4576 :
4577 25703895 : for (t1 = op1; BLOCK_CHAIN (t1); t1 = BLOCK_CHAIN (t1))
4578 21578760 : continue;
4579 4125135 : BLOCK_CHAIN (t1) = op2;
4580 :
4581 : #ifdef ENABLE_TREE_CHECKING
4582 4125135 : {
4583 4125135 : tree t2;
4584 8266452 : for (t2 = op2; t2; t2 = BLOCK_CHAIN (t2))
4585 4141317 : gcc_assert (t2 != t1);
4586 : }
4587 : #endif
4588 :
4589 : return op1;
4590 21578760 : }
4591 :
4592 : /* Count the subblocks of the list starting with BLOCK. If VECTOR is
4593 : non-NULL, list them all into VECTOR, in a depth-first preorder
4594 : traversal of the block tree. Also clear TREE_ASM_WRITTEN in all
4595 : blocks. */
4596 :
4597 : static int
4598 124261436 : all_blocks (tree block, tree *vector)
4599 : {
4600 124261436 : int n_blocks = 0;
4601 :
4602 244198766 : while (block)
4603 : {
4604 119937330 : TREE_ASM_WRITTEN (block) = 0;
4605 :
4606 : /* Record this block. */
4607 119937330 : if (vector)
4608 59968665 : vector[n_blocks] = block;
4609 :
4610 119937330 : ++n_blocks;
4611 :
4612 : /* Record the subblocks, and their subblocks... */
4613 179905995 : n_blocks += all_blocks (BLOCK_SUBBLOCKS (block),
4614 59968665 : vector ? vector + n_blocks : 0);
4615 119937330 : block = BLOCK_CHAIN (block);
4616 : }
4617 :
4618 124261436 : return n_blocks;
4619 : }
4620 :
4621 : /* Return a vector containing all the blocks rooted at BLOCK. The
4622 : number of elements in the vector is stored in N_BLOCKS_P. The
4623 : vector is dynamically allocated; it is the caller's responsibility
4624 : to call `free' on the pointer returned. */
4625 :
4626 : static tree *
4627 2162053 : get_block_vector (tree block, int *n_blocks_p)
4628 : {
4629 2162053 : tree *block_vector;
4630 :
4631 2162053 : *n_blocks_p = all_blocks (block, NULL);
4632 2162053 : block_vector = XNEWVEC (tree, *n_blocks_p);
4633 2162053 : all_blocks (block, block_vector);
4634 :
4635 2162053 : return block_vector;
4636 : }
4637 :
4638 : static GTY(()) int next_block_index = 2;
4639 :
4640 : /* Set BLOCK_NUMBER for all the blocks in FN. */
4641 :
4642 : void
4643 2162053 : number_blocks (tree fn)
4644 : {
4645 2162053 : int i;
4646 2162053 : int n_blocks;
4647 2162053 : tree *block_vector;
4648 :
4649 2162053 : block_vector = get_block_vector (DECL_INITIAL (fn), &n_blocks);
4650 :
4651 : /* The top-level BLOCK isn't numbered at all. */
4652 62130718 : for (i = 1; i < n_blocks; ++i)
4653 : /* We number the blocks from two. */
4654 57806612 : BLOCK_NUMBER (block_vector[i]) = next_block_index++;
4655 :
4656 2162053 : free (block_vector);
4657 :
4658 2162053 : return;
4659 : }
4660 :
4661 : /* If VAR is present in a subblock of BLOCK, return the subblock. */
4662 :
4663 : DEBUG_FUNCTION tree
4664 0 : debug_find_var_in_block_tree (tree var, tree block)
4665 : {
4666 0 : tree t;
4667 :
4668 0 : for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
4669 0 : if (t == var)
4670 : return block;
4671 :
4672 0 : for (t = BLOCK_SUBBLOCKS (block); t; t = TREE_CHAIN (t))
4673 : {
4674 0 : tree ret = debug_find_var_in_block_tree (var, t);
4675 0 : if (ret)
4676 : return ret;
4677 : }
4678 :
4679 : return NULL_TREE;
4680 : }
4681 :
4682 : /* Keep track of whether we're in a dummy function context. If we are,
4683 : we don't want to invoke the set_current_function hook, because we'll
4684 : get into trouble if the hook calls target_reinit () recursively or
4685 : when the initial initialization is not yet complete. */
4686 :
4687 : static bool in_dummy_function;
4688 :
4689 : /* Invoke the target hook when setting cfun. Update the optimization options
4690 : if the function uses different options than the default. */
4691 :
4692 : static void
4693 774160408 : invoke_set_current_function_hook (tree fndecl)
4694 : {
4695 774160408 : if (!in_dummy_function)
4696 : {
4697 773728402 : tree opts = ((fndecl)
4698 773728402 : ? DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
4699 773728402 : : optimization_default_node);
4700 :
4701 773728402 : if (!opts)
4702 357923445 : opts = optimization_default_node;
4703 :
4704 : /* Change optimization options if needed. */
4705 773728402 : if (optimization_current_node != opts)
4706 : {
4707 3240838 : optimization_current_node = opts;
4708 3240838 : cl_optimization_restore (&global_options, &global_options_set,
4709 3240838 : TREE_OPTIMIZATION (opts));
4710 : }
4711 :
4712 773728402 : targetm.set_current_function (fndecl);
4713 773728402 : this_fn_optabs = this_target_optabs;
4714 :
4715 : /* Initialize global alignment variables after op. */
4716 773728402 : parse_alignment_opts ();
4717 :
4718 773728402 : if (opts != optimization_default_node)
4719 : {
4720 1655614 : init_tree_optimization_optabs (opts);
4721 1655614 : if (TREE_OPTIMIZATION_OPTABS (opts))
4722 112137 : this_fn_optabs = (struct target_optabs *)
4723 112137 : TREE_OPTIMIZATION_OPTABS (opts);
4724 : }
4725 : }
4726 774160408 : }
4727 :
4728 : /* Set cfun to NEW_CFUN and switch to the optimization and target options
4729 : associated with NEW_FNDECL.
4730 :
4731 : FORCE says whether we should do the switch even if NEW_CFUN is the current
4732 : function, e.g. because there has been a change in optimization or target
4733 : options. */
4734 :
4735 : static void
4736 1829246891 : set_function_decl (function *new_cfun, tree new_fndecl, bool force)
4737 : {
4738 1829246891 : if (cfun != new_cfun || force)
4739 : {
4740 577368840 : cfun = new_cfun;
4741 577368840 : invoke_set_current_function_hook (new_fndecl);
4742 577368840 : redirect_edge_var_map_empty ();
4743 : }
4744 1829246891 : }
4745 :
4746 : /* cfun should never be set directly; use this function. */
4747 :
4748 : void
4749 1103233224 : set_cfun (struct function *new_cfun, bool force)
4750 : {
4751 1103233224 : set_function_decl (new_cfun, new_cfun ? new_cfun->decl : NULL_TREE, force);
4752 1103233224 : }
4753 :
4754 : /* Initialized with NOGC, making this poisonous to the garbage collector. */
4755 :
4756 : static vec<function *> cfun_stack;
4757 :
4758 : /* Push the current cfun onto the stack, then switch to function NEW_CFUN
4759 : and FUNCTION_DECL NEW_FNDECL. FORCE is as for set_function_decl. */
4760 :
4761 : static void
4762 726013667 : push_function_decl (function *new_cfun, tree new_fndecl, bool force)
4763 : {
4764 726013667 : gcc_assert ((!cfun && !current_function_decl)
4765 : || (cfun && current_function_decl == cfun->decl));
4766 726013667 : cfun_stack.safe_push (cfun);
4767 726013667 : current_function_decl = new_fndecl;
4768 726013667 : set_function_decl (new_cfun, new_fndecl, force);
4769 726013667 : }
4770 :
4771 : /* Push the current cfun onto the stack and switch to function declaration
4772 : NEW_FNDECL, which might or might not have a function body. FORCE is as for
4773 : set_function_decl. */
4774 :
4775 : void
4776 0 : push_function_decl (tree new_fndecl, bool force)
4777 : {
4778 0 : force |= current_function_decl != new_fndecl;
4779 0 : push_function_decl (DECL_STRUCT_FUNCTION (new_fndecl), new_fndecl, force);
4780 0 : }
4781 :
4782 : /* Push the current cfun onto the stack, and set cfun to new_cfun. Also set
4783 : current_function_decl accordingly. */
4784 :
4785 : void
4786 726013667 : push_cfun (struct function *new_cfun)
4787 : {
4788 726013667 : push_function_decl (new_cfun, new_cfun ? new_cfun->decl : NULL_TREE, false);
4789 726013667 : }
4790 :
4791 : /* A common subroutine for pop_cfun and pop_function_decl. FORCE is as
4792 : for set_function_decl. */
4793 :
4794 : static void
4795 726879634 : pop_cfun_1 (bool force)
4796 : {
4797 726879634 : struct function *new_cfun = cfun_stack.pop ();
4798 : /* When in_dummy_function, we do have a cfun but current_function_decl is
4799 : NULL. We also allow pushing NULL cfun and subsequently changing
4800 : current_function_decl to something else and have both restored by
4801 : pop_cfun. */
4802 726879634 : gcc_checking_assert (in_dummy_function
4803 : || !cfun
4804 : || current_function_decl == cfun->decl);
4805 726879634 : set_cfun (new_cfun, force);
4806 726879634 : current_function_decl = new_cfun ? new_cfun->decl : NULL_TREE;
4807 726879634 : }
4808 :
4809 : /* Pop cfun from the stack. Also set current_function_decl accordingly. */
4810 :
4811 : void
4812 726879634 : pop_cfun (void)
4813 : {
4814 726879634 : pop_cfun_1 (false);
4815 726879634 : }
4816 :
4817 : /* Undo push_function_decl. */
4818 :
4819 : void
4820 0 : pop_function_decl (void)
4821 : {
4822 : /* If the previous cfun was null, the options should be reset to the
4823 : global set. Checking the current cfun against the new (popped) cfun
4824 : wouldn't catch this if the current function decl has no function
4825 : struct. */
4826 0 : pop_cfun_1 (!cfun_stack.last ());
4827 0 : }
4828 :
4829 : /* Return value of funcdef and increase it. */
4830 : int
4831 196575548 : get_next_funcdef_no (void)
4832 : {
4833 196575548 : return funcdef_no++;
4834 : }
4835 :
4836 : /* Return value of funcdef. */
4837 : int
4838 0 : get_last_funcdef_no (void)
4839 : {
4840 0 : return funcdef_no;
4841 : }
4842 :
4843 : /* Allocate and initialize the stack usage info data structure for the
4844 : current function. */
4845 : static void
4846 690 : allocate_stack_usage_info (void)
4847 : {
4848 690 : gcc_assert (!cfun->su);
4849 690 : cfun->su = ggc_cleared_alloc<stack_usage> ();
4850 690 : cfun->su->static_stack_size = -1;
4851 690 : }
4852 :
4853 : /* Allocate a function structure for FNDECL and set its contents
4854 : to the defaults. Set cfun to the newly-allocated object.
4855 : Some of the helper functions invoked during initialization assume
4856 : that cfun has already been set. Therefore, assign the new object
4857 : directly into cfun and invoke the back end hook explicitly at the
4858 : very end, rather than initializing a temporary and calling set_cfun
4859 : on it.
4860 :
4861 : ABSTRACT_P is true if this is a function that will never be seen by
4862 : the middle-end. Such functions are front-end concepts (like C++
4863 : function templates) that do not correspond directly to functions
4864 : placed in object files. */
4865 :
4866 : void
4867 196791568 : allocate_struct_function (tree fndecl, bool abstract_p)
4868 : {
4869 196791568 : tree fntype = fndecl ? TREE_TYPE (fndecl) : NULL_TREE;
4870 :
4871 196791568 : cfun = ggc_cleared_alloc<function> ();
4872 :
4873 196791568 : init_eh_for_function ();
4874 :
4875 196791568 : if (init_machine_status)
4876 196791568 : cfun->machine = (*init_machine_status) ();
4877 :
4878 : #ifdef OVERRIDE_ABI_FORMAT
4879 196791568 : OVERRIDE_ABI_FORMAT (fndecl);
4880 : #endif
4881 :
4882 196791568 : if (fndecl != NULL_TREE)
4883 : {
4884 196575548 : DECL_STRUCT_FUNCTION (fndecl) = cfun;
4885 196575548 : cfun->decl = fndecl;
4886 196575548 : current_function_funcdef_no = get_next_funcdef_no ();
4887 : }
4888 :
4889 196791568 : invoke_set_current_function_hook (fndecl);
4890 :
4891 196791568 : if (fndecl != NULL_TREE)
4892 : {
4893 196575548 : tree result = DECL_RESULT (fndecl);
4894 :
4895 196575548 : if (!abstract_p)
4896 : {
4897 : /* Now that we have activated any function-specific attributes
4898 : that might affect layout, particularly vector modes, relayout
4899 : each of the parameters and the result. */
4900 102643340 : relayout_decl (result);
4901 310754894 : for (tree parm = DECL_ARGUMENTS (fndecl); parm;
4902 208111554 : parm = DECL_CHAIN (parm))
4903 208111554 : relayout_decl (parm);
4904 :
4905 : /* Similarly relayout the function decl. */
4906 102643340 : targetm.target_option.relayout_function (fndecl);
4907 : }
4908 :
4909 102643340 : if (!abstract_p && aggregate_value_p (result, fndecl))
4910 : {
4911 : #ifdef PCC_STATIC_STRUCT_RETURN
4912 : cfun->returns_pcc_struct = 1;
4913 : #endif
4914 2773316 : cfun->returns_struct = 1;
4915 : }
4916 :
4917 196575548 : cfun->stdarg = stdarg_p (fntype);
4918 :
4919 : /* Assume all registers in stdarg functions need to be saved. */
4920 196575548 : cfun->va_list_gpr_size = VA_LIST_MAX_GPR_SIZE;
4921 196575548 : cfun->va_list_fpr_size = VA_LIST_MAX_FPR_SIZE;
4922 :
4923 : /* ??? This could be set on a per-function basis by the front-end
4924 : but is this worth the hassle? */
4925 196575548 : cfun->can_throw_non_call_exceptions = flag_non_call_exceptions;
4926 196575548 : cfun->can_delete_dead_exceptions = flag_delete_dead_exceptions;
4927 :
4928 196575548 : if (!profile_flag && !flag_instrument_function_entry_exit)
4929 196575103 : DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl) = 1;
4930 :
4931 196575548 : if (flag_callgraph_info)
4932 1 : allocate_stack_usage_info ();
4933 : }
4934 :
4935 : /* Don't enable begin stmt markers if var-tracking at assignments is
4936 : disabled. The markers make little sense without the variable
4937 : binding annotations among them. */
4938 393583136 : cfun->debug_nonbind_markers = lang_hooks.emits_begin_stmt
4939 196791568 : && MAY_HAVE_DEBUG_MARKER_STMTS;
4940 196791568 : }
4941 :
4942 : /* This is like allocate_struct_function, but pushes a new cfun for FNDECL
4943 : instead of just setting it. */
4944 :
4945 : void
4946 865992 : push_struct_function (tree fndecl, bool abstract_p)
4947 : {
4948 : /* When in_dummy_function we might be in the middle of a pop_cfun and
4949 : current_function_decl and cfun may not match. */
4950 865992 : gcc_assert (in_dummy_function
4951 : || (!cfun && !current_function_decl)
4952 : || (cfun && current_function_decl == cfun->decl));
4953 865992 : cfun_stack.safe_push (cfun);
4954 865992 : current_function_decl = fndecl;
4955 865992 : allocate_struct_function (fndecl, abstract_p);
4956 865992 : }
4957 :
4958 : /* Reset crtl and other non-struct-function variables to defaults as
4959 : appropriate for emitting rtl at the start of a function. */
4960 :
4961 : static void
4962 1703805 : prepare_function_start (void)
4963 : {
4964 1703805 : gcc_assert (!get_last_insn ());
4965 :
4966 1703805 : if (in_dummy_function)
4967 215998 : crtl->abi = &default_function_abi;
4968 : else
4969 1487807 : crtl->abi = &fndecl_abi (cfun->decl).base_abi ();
4970 :
4971 1703805 : init_temp_slots ();
4972 1703805 : init_emit ();
4973 1703805 : init_varasm_status ();
4974 1703805 : init_expr ();
4975 1703805 : default_rtl_profile ();
4976 :
4977 1703805 : if (flag_stack_usage_info && !flag_callgraph_info)
4978 689 : allocate_stack_usage_info ();
4979 :
4980 1703805 : cse_not_expected = ! optimize;
4981 :
4982 : /* Caller save not needed yet. */
4983 1703805 : caller_save_needed = 0;
4984 :
4985 : /* We haven't done register allocation yet. */
4986 1703805 : reg_renumber = 0;
4987 :
4988 : /* Indicate that we have not instantiated virtual registers yet. */
4989 1703805 : virtuals_instantiated = 0;
4990 :
4991 : /* Indicate that we want CONCATs now. */
4992 1703805 : generating_concat_p = 1;
4993 :
4994 : /* Indicate we have no need of a frame pointer yet. */
4995 1703805 : frame_pointer_needed = 0;
4996 :
4997 : /* Reset the cache of the "extended" flag in the target's
4998 : _BitInt info struct. */
4999 1703805 : bitint_extended = -1;
5000 1703805 : }
5001 :
5002 : void
5003 216003 : push_dummy_function (bool with_decl)
5004 : {
5005 216003 : tree fn_decl, fn_type, fn_result_decl;
5006 :
5007 216003 : gcc_assert (!in_dummy_function);
5008 216003 : in_dummy_function = true;
5009 :
5010 216003 : if (with_decl)
5011 : {
5012 5 : fn_type = build_function_type_list (void_type_node, NULL_TREE);
5013 5 : fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, NULL_TREE,
5014 : fn_type);
5015 5 : fn_result_decl = build_decl (UNKNOWN_LOCATION, RESULT_DECL,
5016 : NULL_TREE, void_type_node);
5017 5 : DECL_RESULT (fn_decl) = fn_result_decl;
5018 5 : DECL_ARTIFICIAL (fn_decl) = 1;
5019 5 : tree fn_name = get_identifier (" ");
5020 5 : SET_DECL_ASSEMBLER_NAME (fn_decl, fn_name);
5021 : }
5022 : else
5023 : fn_decl = NULL_TREE;
5024 :
5025 216003 : push_struct_function (fn_decl);
5026 216003 : }
5027 :
5028 : /* Initialize the rtl expansion mechanism so that we can do simple things
5029 : like generate sequences. This is used to provide a context during global
5030 : initialization of some passes. You must call expand_dummy_function_end
5031 : to exit this context. */
5032 :
5033 : void
5034 215998 : init_dummy_function_start (void)
5035 : {
5036 215998 : push_dummy_function (false);
5037 215998 : prepare_function_start ();
5038 215998 : }
5039 :
5040 : /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node)
5041 : and initialize static variables for generating RTL for the statements
5042 : of the function. */
5043 :
5044 : void
5045 1487807 : init_function_start (tree subr)
5046 : {
5047 : /* Initialize backend, if needed. */
5048 1487807 : initialize_rtl ();
5049 :
5050 1487807 : prepare_function_start ();
5051 1487807 : decide_function_section (subr);
5052 :
5053 : /* Warn if this value is an aggregate type,
5054 : regardless of which calling convention we are using for it. */
5055 1487807 : if (AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr))))
5056 108521 : warning_at (DECL_SOURCE_LOCATION (DECL_RESULT (subr)),
5057 108521 : OPT_Waggregate_return, "function returns an aggregate");
5058 1487807 : }
5059 :
5060 : /* Expand code to verify the stack_protect_guard. This is invoked at
5061 : the end of a function to be protected. */
5062 :
5063 : void
5064 322 : stack_protect_epilogue (void)
5065 : {
5066 322 : tree guard_decl = crtl->stack_protect_guard_decl;
5067 322 : rtx_code_label *label = gen_label_rtx ();
5068 322 : rtx x, y;
5069 322 : rtx_insn *seq = NULL;
5070 :
5071 322 : x = expand_normal (crtl->stack_protect_guard);
5072 :
5073 322 : if (targetm.have_stack_protect_combined_test () && guard_decl)
5074 : {
5075 0 : gcc_assert (DECL_P (guard_decl));
5076 0 : y = DECL_RTL (guard_decl);
5077 : /* Allow the target to compute address of Y and compare it with X without
5078 : leaking Y into a register. This combined address + compare pattern
5079 : allows the target to prevent spilling of any intermediate results by
5080 : splitting it after register allocator. */
5081 0 : seq = targetm.gen_stack_protect_combined_test (x, y, label);
5082 : }
5083 : else
5084 : {
5085 322 : if (guard_decl)
5086 322 : y = expand_normal (guard_decl);
5087 : else
5088 0 : y = const0_rtx;
5089 :
5090 : /* Allow the target to compare Y with X without leaking either into
5091 : a register. */
5092 322 : if (targetm.have_stack_protect_test ())
5093 322 : seq = targetm.gen_stack_protect_test (x, y, label);
5094 : }
5095 :
5096 322 : if (seq)
5097 322 : emit_insn (seq);
5098 : else
5099 0 : emit_cmp_and_jump_insns (x, y, EQ, NULL_RTX, ptr_mode, 1, label);
5100 :
5101 : /* The noreturn predictor has been moved to the tree level. The rtl-level
5102 : predictors estimate this branch about 20%, which isn't enough to get
5103 : things moved out of line. Since this is the only extant case of adding
5104 : a noreturn function at the rtl level, it doesn't seem worth doing ought
5105 : except adding the prediction by hand. */
5106 322 : rtx_insn *tmp = get_last_insn ();
5107 322 : if (JUMP_P (tmp))
5108 322 : predict_insn_def (tmp, PRED_NORETURN, TAKEN);
5109 :
5110 322 : expand_call (targetm.stack_protect_fail (), NULL_RTX, /*ignore=*/true);
5111 322 : free_temp_slots ();
5112 322 : emit_label (label);
5113 322 : }
5114 :
5115 : /* Start the RTL for a new function, and set variables used for
5116 : emitting RTL.
5117 : SUBR is the FUNCTION_DECL node.
5118 : PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with
5119 : the function's parameters, which must be run at any return statement. */
5120 :
5121 : bool currently_expanding_function_start;
5122 : void
5123 1482262 : expand_function_start (tree subr)
5124 : {
5125 1482262 : currently_expanding_function_start = true;
5126 :
5127 : /* Make sure volatile mem refs aren't considered
5128 : valid operands of arithmetic insns. */
5129 1482262 : init_recog_no_volatile ();
5130 :
5131 1482262 : crtl->profile
5132 2964524 : = (profile_flag
5133 1482582 : && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr));
5134 :
5135 1482262 : crtl->limit_stack
5136 1482262 : = (stack_limit_rtx != NULL_RTX && ! DECL_NO_LIMIT_STACK (subr));
5137 :
5138 : /* Make the label for return statements to jump to. Do not special
5139 : case machines with special return instructions -- they will be
5140 : handled later during jump, ifcvt, or epilogue creation. */
5141 1482262 : return_label = gen_label_rtx ();
5142 :
5143 : /* Initialize rtx used to return the value. */
5144 : /* Do this before assign_parms so that we copy the struct value address
5145 : before any library calls that assign parms might generate. */
5146 :
5147 : /* Decide whether to return the value in memory or in a register. */
5148 1482262 : tree res = DECL_RESULT (subr);
5149 1482262 : if (aggregate_value_p (res, subr))
5150 : {
5151 : /* Returning something that won't go in a register. */
5152 69603 : rtx value_address = 0;
5153 :
5154 : #ifdef PCC_STATIC_STRUCT_RETURN
5155 : if (cfun->returns_pcc_struct)
5156 : {
5157 : int size = int_size_in_bytes (TREE_TYPE (res));
5158 : value_address = assemble_static_space (size);
5159 : }
5160 : else
5161 : #endif
5162 69603 : {
5163 69603 : rtx sv = targetm.calls.struct_value_rtx (TREE_TYPE (subr), 2);
5164 : /* Expect to be passed the address of a place to store the value.
5165 : If it is passed as an argument, assign_parms will take care of
5166 : it. */
5167 69603 : if (sv)
5168 : {
5169 0 : value_address = gen_reg_rtx (Pmode);
5170 0 : emit_move_insn (value_address, sv);
5171 : }
5172 : }
5173 0 : if (value_address)
5174 : {
5175 0 : rtx x = value_address;
5176 0 : if (!DECL_BY_REFERENCE (res))
5177 : {
5178 0 : x = gen_rtx_MEM (DECL_MODE (res), x);
5179 0 : set_mem_attributes (x, res, 1);
5180 : }
5181 0 : set_parm_rtl (res, x);
5182 : }
5183 : }
5184 1412659 : else if (DECL_MODE (res) == VOIDmode)
5185 : /* If return mode is void, this decl rtl should not be used. */
5186 693016 : set_parm_rtl (res, NULL_RTX);
5187 : else
5188 : {
5189 : /* Compute the return values into a pseudo reg, which we will copy
5190 : into the true return register after the cleanups are done. */
5191 719643 : tree return_type = TREE_TYPE (res);
5192 :
5193 : /* If we may coalesce this result, make sure it has the expected mode
5194 : in case it was promoted. But we need not bother about BLKmode. */
5195 719643 : machine_mode promoted_mode
5196 533921 : = flag_tree_coalesce_vars && is_gimple_reg (res)
5197 1216394 : ? promote_ssa_mode (ssa_default_def (cfun, res), NULL)
5198 : : BLKmode;
5199 :
5200 496751 : if (promoted_mode != BLKmode)
5201 496750 : set_parm_rtl (res, gen_reg_rtx (promoted_mode));
5202 222893 : else if (TYPE_MODE (return_type) != BLKmode
5203 222893 : && targetm.calls.return_in_msb (return_type))
5204 : /* expand_function_end will insert the appropriate padding in
5205 : this case. Use the return value's natural (unpadded) mode
5206 : within the function proper. */
5207 0 : set_parm_rtl (res, gen_reg_rtx (TYPE_MODE (return_type)));
5208 : else
5209 : {
5210 : /* In order to figure out what mode to use for the pseudo, we
5211 : figure out what the mode of the eventual return register will
5212 : actually be, and use that. */
5213 222893 : rtx hard_reg = hard_function_value (return_type, subr, 0, 1);
5214 :
5215 : /* Structures that are returned in registers are not
5216 : aggregate_value_p, so we may see a PARALLEL or a REG. */
5217 222893 : if (REG_P (hard_reg))
5218 219854 : set_parm_rtl (res, gen_reg_rtx (GET_MODE (hard_reg)));
5219 : else
5220 : {
5221 3039 : gcc_assert (GET_CODE (hard_reg) == PARALLEL);
5222 3039 : set_parm_rtl (res, gen_group_rtx (hard_reg));
5223 : }
5224 : }
5225 :
5226 : /* Set DECL_REGISTER flag so that expand_function_end will copy the
5227 : result to the real return register(s). */
5228 719643 : DECL_REGISTER (res) = 1;
5229 : }
5230 :
5231 : /* Initialize rtx for parameters and local variables.
5232 : In some cases this requires emitting insns. */
5233 1482262 : assign_parms (subr);
5234 :
5235 : /* If function gets a static chain arg, store it. */
5236 1482262 : if (cfun->static_chain_decl)
5237 : {
5238 19378 : tree parm = cfun->static_chain_decl;
5239 19378 : rtx local, chain;
5240 19378 : rtx_insn *insn;
5241 19378 : int unsignedp;
5242 :
5243 19378 : local = gen_reg_rtx (promote_decl_mode (parm, &unsignedp));
5244 19378 : chain = targetm.calls.static_chain (current_function_decl, true);
5245 :
5246 19378 : set_decl_incoming_rtl (parm, chain, false);
5247 19378 : set_parm_rtl (parm, local);
5248 19378 : mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
5249 :
5250 19378 : if (GET_MODE (local) != GET_MODE (chain))
5251 : {
5252 1 : convert_move (local, chain, unsignedp);
5253 1 : insn = get_last_insn ();
5254 : }
5255 : else
5256 19377 : insn = emit_move_insn (local, chain);
5257 :
5258 : /* Mark the register as eliminable, similar to parameters. */
5259 19378 : if (MEM_P (chain)
5260 19378 : && reg_mentioned_p (arg_pointer_rtx, XEXP (chain, 0)))
5261 0 : set_dst_reg_note (insn, REG_EQUIV, chain, local);
5262 :
5263 : /* If we aren't optimizing, save the static chain onto the stack. */
5264 19378 : if (!optimize)
5265 : {
5266 3951 : tree saved_static_chain_decl
5267 3951 : = build_decl (DECL_SOURCE_LOCATION (parm), VAR_DECL,
5268 3951 : DECL_NAME (parm), TREE_TYPE (parm));
5269 3951 : rtx saved_static_chain_rtx
5270 7902 : = assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0);
5271 3951 : SET_DECL_RTL (saved_static_chain_decl, saved_static_chain_rtx);
5272 3951 : emit_move_insn (saved_static_chain_rtx, chain);
5273 3951 : SET_DECL_VALUE_EXPR (parm, saved_static_chain_decl);
5274 3951 : DECL_HAS_VALUE_EXPR_P (parm) = 1;
5275 : }
5276 : }
5277 :
5278 : /* The following was moved from init_function_start.
5279 : The move was supposed to make sdb output more accurate. */
5280 : /* Indicate the beginning of the function body,
5281 : as opposed to parm setup. */
5282 1482262 : emit_note (NOTE_INSN_FUNCTION_BEG);
5283 :
5284 1482262 : gcc_assert (NOTE_P (get_last_insn ()));
5285 :
5286 1482262 : function_beg_insn = parm_birth_insn = get_last_insn ();
5287 :
5288 : /* If the function receives a non-local goto, then store the
5289 : bits we need to restore the frame pointer. */
5290 1482262 : if (cfun->nonlocal_goto_save_area)
5291 : {
5292 393 : tree t_save;
5293 393 : rtx r_save;
5294 :
5295 393 : tree var = TREE_OPERAND (cfun->nonlocal_goto_save_area, 0);
5296 393 : gcc_assert (DECL_RTL_SET_P (var));
5297 :
5298 393 : t_save = build4 (ARRAY_REF,
5299 393 : TREE_TYPE (TREE_TYPE (cfun->nonlocal_goto_save_area)),
5300 : cfun->nonlocal_goto_save_area,
5301 : integer_zero_node, NULL_TREE, NULL_TREE);
5302 393 : r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
5303 393 : gcc_assert (GET_MODE (r_save) == Pmode);
5304 :
5305 393 : emit_move_insn (r_save, hard_frame_pointer_rtx);
5306 393 : update_nonlocal_goto_save_area ();
5307 : }
5308 :
5309 1482262 : if (crtl->profile)
5310 : {
5311 : #ifdef PROFILE_HOOK
5312 : PROFILE_HOOK (current_function_funcdef_no);
5313 : #endif
5314 : }
5315 :
5316 : /* If we are doing generic stack checking, the probe should go here. */
5317 1482262 : if (flag_stack_check == GENERIC_STACK_CHECK)
5318 48 : stack_check_probe_note = emit_note (NOTE_INSN_DELETED);
5319 :
5320 1482262 : currently_expanding_function_start = false;
5321 1482262 : }
5322 :
5323 : void
5324 216003 : pop_dummy_function (void)
5325 : {
5326 216003 : pop_cfun ();
5327 216003 : in_dummy_function = false;
5328 216003 : }
5329 :
5330 : /* Undo the effects of init_dummy_function_start. */
5331 : void
5332 215998 : expand_dummy_function_end (void)
5333 : {
5334 215998 : gcc_assert (in_dummy_function);
5335 :
5336 : /* End any sequences that failed to be closed due to syntax errors. */
5337 215998 : while (in_sequence_p ())
5338 0 : end_sequence ();
5339 :
5340 : /* Outside function body, can't compute type's actual size
5341 : until next function's body starts. */
5342 :
5343 215998 : free_after_parsing (cfun);
5344 215998 : free_after_compilation (cfun);
5345 215998 : pop_dummy_function ();
5346 215998 : }
5347 :
5348 : /* Helper for diddle_return_value. */
5349 :
5350 : void
5351 20212155 : diddle_return_value_1 (void (*doit) (rtx, void *), void *arg, rtx outgoing)
5352 : {
5353 20212155 : if (! outgoing)
5354 : return;
5355 :
5356 10547171 : if (REG_P (outgoing))
5357 10491903 : (*doit) (outgoing, arg);
5358 55268 : else if (GET_CODE (outgoing) == PARALLEL)
5359 : {
5360 : int i;
5361 :
5362 129937 : for (i = 0; i < XVECLEN (outgoing, 0); i++)
5363 : {
5364 77048 : rtx x = XEXP (XVECEXP (outgoing, 0, i), 0);
5365 :
5366 77048 : if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
5367 77048 : (*doit) (x, arg);
5368 : }
5369 : }
5370 : }
5371 :
5372 : /* Call DOIT for each hard register used as a return value from
5373 : the current function. */
5374 :
5375 : void
5376 20212155 : diddle_return_value (void (*doit) (rtx, void *), void *arg)
5377 : {
5378 20212155 : diddle_return_value_1 (doit, arg, crtl->return_rtx);
5379 20212155 : }
5380 :
5381 : static void
5382 12651 : do_clobber_return_reg (rtx reg, void *arg ATTRIBUTE_UNUSED)
5383 : {
5384 5172 : emit_clobber (reg);
5385 7479 : }
5386 :
5387 : void
5388 626296 : clobber_return_register (void)
5389 : {
5390 626296 : diddle_return_value (do_clobber_return_reg, NULL);
5391 :
5392 : /* In case we do use pseudo to return value, clobber it too. */
5393 626296 : if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl)))
5394 : {
5395 7512 : tree decl_result = DECL_RESULT (current_function_decl);
5396 7512 : rtx decl_rtl = DECL_RTL (decl_result);
5397 7512 : if (REG_P (decl_rtl) && REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER)
5398 : {
5399 7479 : do_clobber_return_reg (decl_rtl, NULL);
5400 : }
5401 : }
5402 626296 : }
5403 :
5404 : static void
5405 786215 : do_use_return_reg (rtx reg, void *arg ATTRIBUTE_UNUSED)
5406 : {
5407 786215 : emit_use (reg);
5408 786215 : }
5409 :
5410 : static void
5411 1482261 : use_return_register (void)
5412 : {
5413 0 : diddle_return_value (do_use_return_reg, NULL);
5414 0 : }
5415 :
5416 : /* Generate RTL for the end of the current function. */
5417 :
5418 : void
5419 1482261 : expand_function_end (void)
5420 : {
5421 : /* If arg_pointer_save_area was referenced only from a nested
5422 : function, we will not have initialized it yet. Do that now. */
5423 1482261 : if (arg_pointer_save_area && ! crtl->arg_pointer_save_area_init)
5424 0 : get_arg_pointer_save_area ();
5425 :
5426 : /* If we are doing generic stack checking and this function makes calls,
5427 : do a stack probe at the start of the function to ensure we have enough
5428 : space for another stack frame. */
5429 1482261 : if (flag_stack_check == GENERIC_STACK_CHECK)
5430 : {
5431 48 : rtx_insn *insn, *seq;
5432 :
5433 638 : for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
5434 622 : if (CALL_P (insn))
5435 : {
5436 32 : rtx max_frame_size = GEN_INT (STACK_CHECK_MAX_FRAME_SIZE);
5437 32 : start_sequence ();
5438 32 : if (STACK_CHECK_MOVING_SP)
5439 32 : anti_adjust_stack_and_probe (max_frame_size, true);
5440 : else
5441 : probe_stack_range (STACK_OLD_CHECK_PROTECT, max_frame_size);
5442 32 : seq = end_sequence ();
5443 32 : set_insn_locations (seq, prologue_location);
5444 32 : emit_insn_before (seq, stack_check_probe_note);
5445 32 : break;
5446 : }
5447 : }
5448 :
5449 : /* End any sequences that failed to be closed due to syntax errors. */
5450 1482261 : while (in_sequence_p ())
5451 0 : end_sequence ();
5452 :
5453 1482261 : clear_pending_stack_adjust ();
5454 1482261 : do_pending_stack_adjust ();
5455 :
5456 : /* Output a linenumber for the end of the function.
5457 : SDB depended on this. */
5458 1482261 : set_curr_insn_location (input_location);
5459 :
5460 : /* Before the return label (if any), clobber the return
5461 : registers so that they are not propagated live to the rest of
5462 : the function. This can only happen with functions that drop
5463 : through; if there had been a return statement, there would
5464 : have either been a return rtx, or a jump to the return label.
5465 :
5466 : We delay actual code generation after the current_function_value_rtx
5467 : is computed. */
5468 1482261 : rtx_insn *clobber_after = get_last_insn ();
5469 :
5470 : /* Output the label for the actual return from the function. */
5471 1482261 : emit_label (return_label);
5472 :
5473 1482261 : if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ)
5474 : {
5475 : /* Let except.cc know where it should emit the call to unregister
5476 : the function context for sjlj exceptions. */
5477 0 : if (flag_exceptions)
5478 0 : sjlj_emit_function_exit_after (get_last_insn ());
5479 : }
5480 :
5481 : /* If this is an implementation of throw, do what's necessary to
5482 : communicate between __builtin_eh_return and the epilogue. */
5483 1482261 : expand_eh_return ();
5484 :
5485 : /* If stack protection is enabled for this function, check the guard. */
5486 1482261 : if (crtl->stack_protect_guard
5487 290 : && targetm.stack_protect_runtime_enabled_p ()
5488 1482550 : && naked_return_label == NULL_RTX)
5489 289 : stack_protect_epilogue ();
5490 :
5491 : /* If scalar return value was computed in a pseudo-reg, or was a named
5492 : return value that got dumped to the stack, copy that to the hard
5493 : return register. */
5494 1482261 : if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl)))
5495 : {
5496 789245 : tree decl_result = DECL_RESULT (current_function_decl);
5497 789245 : rtx decl_rtl = DECL_RTL (decl_result);
5498 :
5499 789245 : if ((REG_P (decl_rtl)
5500 789245 : ? REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER
5501 67422 : : DECL_REGISTER (decl_result))
5502 : /* Unless the psABI says not to. */
5503 789245 : && !TYPE_EMPTY_P (TREE_TYPE (decl_result)))
5504 : {
5505 721959 : rtx real_decl_rtl = crtl->return_rtx;
5506 721959 : complex_mode cmode;
5507 :
5508 : /* This should be set in assign_parms. */
5509 721959 : gcc_assert (REG_FUNCTION_VALUE_P (real_decl_rtl));
5510 :
5511 : /* If this is a BLKmode structure being returned in registers,
5512 : then use the mode computed in expand_return. Note that if
5513 : decl_rtl is memory, then its mode may have been changed,
5514 : but that crtl->return_rtx has not. */
5515 721959 : if (GET_MODE (real_decl_rtl) == BLKmode)
5516 2705 : PUT_MODE (real_decl_rtl, GET_MODE (decl_rtl));
5517 :
5518 : /* If a non-BLKmode return value should be padded at the least
5519 : significant end of the register, shift it left by the appropriate
5520 : amount. BLKmode results are handled using the group load/store
5521 : machinery. */
5522 721959 : if (TYPE_MODE (TREE_TYPE (decl_result)) != BLKmode
5523 719251 : && REG_P (real_decl_rtl)
5524 1438563 : && targetm.calls.return_in_msb (TREE_TYPE (decl_result)))
5525 : {
5526 0 : emit_move_insn (gen_rtx_REG (GET_MODE (decl_rtl),
5527 : REGNO (real_decl_rtl)),
5528 : decl_rtl);
5529 0 : shift_return_value (GET_MODE (decl_rtl), true, real_decl_rtl);
5530 : }
5531 721959 : else if (GET_CODE (real_decl_rtl) == PARALLEL)
5532 : {
5533 : /* If expand_function_start has created a PARALLEL for decl_rtl,
5534 : move the result to the real return registers. Otherwise, do
5535 : a group load from decl_rtl for a named return. */
5536 4128 : if (GET_CODE (decl_rtl) == PARALLEL)
5537 3039 : emit_group_move (real_decl_rtl, decl_rtl);
5538 : else
5539 1089 : emit_group_load (real_decl_rtl, decl_rtl,
5540 1089 : TREE_TYPE (decl_result),
5541 1089 : int_size_in_bytes (TREE_TYPE (decl_result)));
5542 : }
5543 : /* In the case of complex integer modes smaller than a word, we'll
5544 : need to generate some non-trivial bitfield insertions. Do that
5545 : on a pseudo and not the hard register. */
5546 717831 : else if (GET_CODE (decl_rtl) == CONCAT
5547 687 : && is_complex_int_mode (GET_MODE (decl_rtl), &cmode)
5548 717955 : && GET_MODE_BITSIZE (cmode) <= BITS_PER_WORD)
5549 : {
5550 86 : int old_generating_concat_p;
5551 86 : rtx tmp;
5552 :
5553 86 : old_generating_concat_p = generating_concat_p;
5554 86 : generating_concat_p = 0;
5555 86 : tmp = gen_reg_rtx (GET_MODE (decl_rtl));
5556 86 : generating_concat_p = old_generating_concat_p;
5557 :
5558 86 : emit_move_insn (tmp, decl_rtl);
5559 86 : emit_move_insn (real_decl_rtl, tmp);
5560 : }
5561 : /* If a named return value dumped decl_return to memory, then
5562 : we may need to re-do the PROMOTE_MODE signed/unsigned
5563 : extension. */
5564 717745 : else if (GET_MODE (real_decl_rtl) != GET_MODE (decl_rtl))
5565 : {
5566 0 : int unsignedp = TYPE_UNSIGNED (TREE_TYPE (decl_result));
5567 0 : promote_function_mode (TREE_TYPE (decl_result),
5568 : GET_MODE (decl_rtl), &unsignedp,
5569 0 : TREE_TYPE (current_function_decl), 1);
5570 :
5571 0 : convert_move (real_decl_rtl, decl_rtl, unsignedp);
5572 : }
5573 : else
5574 717745 : emit_move_insn (real_decl_rtl, decl_rtl);
5575 : }
5576 : }
5577 :
5578 : /* If returning a structure, arrange to return the address of the value
5579 : in a place where debuggers expect to find it.
5580 :
5581 : If returning a structure PCC style,
5582 : the caller also depends on this value.
5583 : And cfun->returns_pcc_struct is not necessarily set. */
5584 1482261 : if ((cfun->returns_struct || cfun->returns_pcc_struct)
5585 69398 : && !targetm.calls.omit_struct_return_reg)
5586 : {
5587 69398 : rtx value_address = DECL_RTL (DECL_RESULT (current_function_decl));
5588 69398 : tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
5589 69398 : rtx outgoing;
5590 :
5591 69398 : if (DECL_BY_REFERENCE (DECL_RESULT (current_function_decl)))
5592 8891 : type = TREE_TYPE (type);
5593 : else
5594 60507 : value_address = XEXP (value_address, 0);
5595 :
5596 69398 : outgoing = targetm.calls.function_value (build_pointer_type (type),
5597 : current_function_decl, true);
5598 :
5599 : /* Mark this as a function return value so integrate will delete the
5600 : assignment and USE below when inlining this function. */
5601 69398 : REG_FUNCTION_VALUE_P (outgoing) = 1;
5602 :
5603 : /* The address may be ptr_mode and OUTGOING may be Pmode. */
5604 69398 : scalar_int_mode mode = as_a <scalar_int_mode> (GET_MODE (outgoing));
5605 69398 : value_address = convert_memory_address (mode, value_address);
5606 :
5607 69398 : emit_move_insn (outgoing, value_address);
5608 :
5609 : /* Show return register used to hold result (in this case the address
5610 : of the result. */
5611 69398 : crtl->return_rtx = outgoing;
5612 : }
5613 :
5614 : /* Emit the actual code to clobber return register. Don't emit
5615 : it if clobber_after is a barrier, then the previous basic block
5616 : certainly doesn't fall thru into the exit block. */
5617 1482261 : if (!BARRIER_P (clobber_after))
5618 : {
5619 557153 : start_sequence ();
5620 557153 : clobber_return_register ();
5621 557153 : rtx_insn *seq = end_sequence ();
5622 :
5623 557153 : emit_insn_after (seq, clobber_after);
5624 : }
5625 :
5626 : /* Output the label for the naked return from the function. */
5627 1482261 : if (naked_return_label)
5628 379 : emit_label (naked_return_label);
5629 :
5630 : /* @@@ This is a kludge. We want to ensure that instructions that
5631 : may trap are not moved into the epilogue by scheduling, because
5632 : we don't always emit unwind information for the epilogue. */
5633 1482261 : if (cfun->can_throw_non_call_exceptions
5634 1482261 : && targetm_common.except_unwind_info (&global_options) != UI_SJLJ)
5635 262983 : emit_insn (gen_blockage ());
5636 :
5637 : /* If stack protection is enabled for this function, check the guard. */
5638 1482261 : if (crtl->stack_protect_guard
5639 290 : && targetm.stack_protect_runtime_enabled_p ()
5640 1482550 : && naked_return_label)
5641 0 : stack_protect_epilogue ();
5642 :
5643 : /* If we had calls to alloca, and this machine needs
5644 : an accurate stack pointer to exit the function,
5645 : insert some code to save and restore the stack pointer. */
5646 1482261 : if (! EXIT_IGNORE_STACK
5647 : && cfun->calls_alloca)
5648 : {
5649 : rtx tem = 0;
5650 :
5651 : start_sequence ();
5652 : emit_stack_save (SAVE_FUNCTION, &tem);
5653 : rtx_insn *seq = end_sequence ();
5654 : emit_insn_before (seq, parm_birth_insn);
5655 :
5656 : emit_stack_restore (SAVE_FUNCTION, tem);
5657 : }
5658 :
5659 : /* ??? This should no longer be necessary since stupid is no longer with
5660 : us, but there are some parts of the compiler (eg reload_combine, and
5661 : sh mach_dep_reorg) that still try and compute their own lifetime info
5662 : instead of using the general framework. */
5663 1482261 : use_return_register ();
5664 1482261 : }
5665 :
5666 : rtx
5667 0 : get_arg_pointer_save_area (void)
5668 : {
5669 0 : rtx ret = arg_pointer_save_area;
5670 :
5671 0 : if (! ret)
5672 : {
5673 0 : ret = assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0);
5674 0 : arg_pointer_save_area = ret;
5675 : }
5676 :
5677 0 : if (! crtl->arg_pointer_save_area_init)
5678 : {
5679 : /* Save the arg pointer at the beginning of the function. The
5680 : generated stack slot may not be a valid memory address, so we
5681 : have to check it and fix it if necessary. */
5682 0 : start_sequence ();
5683 0 : emit_move_insn (validize_mem (copy_rtx (ret)),
5684 : crtl->args.internal_arg_pointer);
5685 0 : rtx_insn *seq = end_sequence ();
5686 :
5687 0 : push_topmost_sequence ();
5688 0 : emit_insn_after (seq, entry_of_function ());
5689 0 : pop_topmost_sequence ();
5690 :
5691 0 : crtl->arg_pointer_save_area_init = true;
5692 : }
5693 :
5694 0 : return ret;
5695 : }
5696 :
5697 :
5698 : /* If debugging dumps are requested, dump information about how the
5699 : target handled -fstack-check=clash for the prologue.
5700 :
5701 : PROBES describes what if any probes were emitted.
5702 :
5703 : RESIDUALS indicates if the prologue had any residual allocation
5704 : (i.e. total allocation was not a multiple of PROBE_INTERVAL). */
5705 :
5706 : void
5707 126 : dump_stack_clash_frame_info (enum stack_clash_probes probes, bool residuals)
5708 : {
5709 126 : if (!dump_file)
5710 : return;
5711 :
5712 17 : switch (probes)
5713 : {
5714 1 : case NO_PROBE_NO_FRAME:
5715 1 : fprintf (dump_file,
5716 : "Stack clash no probe no stack adjustment in prologue.\n");
5717 1 : break;
5718 11 : case NO_PROBE_SMALL_FRAME:
5719 11 : fprintf (dump_file,
5720 : "Stack clash no probe small stack adjustment in prologue.\n");
5721 11 : break;
5722 3 : case PROBE_INLINE:
5723 3 : fprintf (dump_file, "Stack clash inline probes in prologue.\n");
5724 3 : break;
5725 2 : case PROBE_LOOP:
5726 2 : fprintf (dump_file, "Stack clash probe loop in prologue.\n");
5727 2 : break;
5728 : }
5729 :
5730 17 : if (residuals)
5731 16 : fprintf (dump_file, "Stack clash residual allocation in prologue.\n");
5732 : else
5733 1 : fprintf (dump_file, "Stack clash no residual allocation in prologue.\n");
5734 :
5735 17 : if (frame_pointer_needed)
5736 0 : fprintf (dump_file, "Stack clash frame pointer needed.\n");
5737 : else
5738 17 : fprintf (dump_file, "Stack clash no frame pointer needed.\n");
5739 :
5740 17 : if (TREE_THIS_VOLATILE (cfun->decl))
5741 1 : fprintf (dump_file,
5742 : "Stack clash noreturn prologue, assuming no implicit"
5743 : " probes in caller.\n");
5744 : else
5745 16 : fprintf (dump_file,
5746 : "Stack clash not noreturn prologue.\n");
5747 : }
5748 :
5749 : /* Add a list of INSNS to the hash HASHP, possibly allocating HASHP
5750 : for the first time. */
5751 :
5752 : static void
5753 3685833 : record_insns (rtx_insn *insns, rtx end, hash_table<insn_cache_hasher> **hashp)
5754 : {
5755 3685833 : rtx_insn *tmp;
5756 3685833 : hash_table<insn_cache_hasher> *hash = *hashp;
5757 :
5758 3685833 : if (hash == NULL)
5759 2962968 : *hashp = hash = hash_table<insn_cache_hasher>::create_ggc (17);
5760 :
5761 14281115 : for (tmp = insns; tmp != end; tmp = NEXT_INSN (tmp))
5762 : {
5763 10595282 : rtx *slot = hash->find_slot (tmp, INSERT);
5764 10595282 : gcc_assert (*slot == NULL);
5765 10595282 : *slot = tmp;
5766 : }
5767 3685833 : }
5768 :
5769 : /* INSN has been duplicated or replaced by as COPY, perhaps by duplicating a
5770 : basic block, splitting or peepholes. If INSN is a prologue or epilogue
5771 : insn, then record COPY as well. */
5772 :
5773 : void
5774 3869835 : maybe_copy_prologue_epilogue_insn (rtx insn, rtx copy)
5775 : {
5776 3869835 : hash_table<insn_cache_hasher> *hash;
5777 3869835 : rtx *slot;
5778 :
5779 3869835 : hash = epilogue_insn_hash;
5780 3869835 : if (!hash || !hash->find (insn))
5781 : {
5782 3356960 : hash = prologue_insn_hash;
5783 3356960 : if (!hash || !hash->find (insn))
5784 3281696 : return;
5785 : }
5786 :
5787 588139 : slot = hash->find_slot (copy, INSERT);
5788 588139 : gcc_assert (*slot == NULL);
5789 588139 : *slot = copy;
5790 : }
5791 :
5792 : /* Determine if any INSNs in HASH are, or are part of, INSN. Because
5793 : we can be running after reorg, SEQUENCE rtl is possible. */
5794 :
5795 : static bool
5796 285581969 : contains (const rtx_insn *insn, hash_table<insn_cache_hasher> *hash)
5797 : {
5798 285581969 : if (hash == NULL)
5799 : return false;
5800 :
5801 285527117 : if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
5802 : {
5803 0 : rtx_sequence *seq = as_a <rtx_sequence *> (PATTERN (insn));
5804 0 : int i;
5805 0 : for (i = seq->len () - 1; i >= 0; i--)
5806 0 : if (hash->find (seq->element (i)))
5807 : return true;
5808 : return false;
5809 : }
5810 :
5811 285527117 : return hash->find (const_cast<rtx_insn *> (insn)) != NULL;
5812 : }
5813 :
5814 : bool
5815 108844807 : prologue_contains (const rtx_insn *insn)
5816 : {
5817 108844807 : return contains (insn, prologue_insn_hash);
5818 : }
5819 :
5820 : bool
5821 108844807 : epilogue_contains (const rtx_insn *insn)
5822 : {
5823 108844807 : return contains (insn, epilogue_insn_hash);
5824 : }
5825 :
5826 : bool
5827 4385 : prologue_epilogue_contains (const rtx_insn *insn)
5828 : {
5829 4385 : if (contains (insn, prologue_insn_hash))
5830 : return true;
5831 4195 : if (contains (insn, epilogue_insn_hash))
5832 : return true;
5833 : return false;
5834 : }
5835 :
5836 : void
5837 166473 : record_prologue_seq (rtx_insn *seq)
5838 : {
5839 166473 : record_insns (seq, NULL, &prologue_insn_hash);
5840 166473 : }
5841 :
5842 : void
5843 148615 : record_epilogue_seq (rtx_insn *seq)
5844 : {
5845 148615 : record_insns (seq, NULL, &epilogue_insn_hash);
5846 148615 : }
5847 :
5848 : /* Set JUMP_LABEL for a return insn. */
5849 :
5850 : void
5851 1526681 : set_return_jump_label (rtx_insn *returnjump)
5852 : {
5853 1526681 : rtx pat = PATTERN (returnjump);
5854 1526681 : if (GET_CODE (pat) == PARALLEL)
5855 27239 : pat = XVECEXP (pat, 0, 0);
5856 1526681 : if (ANY_RETURN_P (pat))
5857 1526681 : JUMP_LABEL (returnjump) = pat;
5858 : else
5859 0 : JUMP_LABEL (returnjump) = ret_rtx;
5860 1526681 : }
5861 :
5862 : /* Return a sequence to be used as the split prologue for the current
5863 : function, or NULL. */
5864 :
5865 : static rtx_insn *
5866 1526209 : make_split_prologue_seq (void)
5867 : {
5868 1526209 : if (!flag_split_stack
5869 1526209 : || lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (cfun->decl)))
5870 1266166 : return NULL;
5871 :
5872 260043 : start_sequence ();
5873 260043 : emit_insn (targetm.gen_split_stack_prologue ());
5874 260043 : rtx_insn *seq = end_sequence ();
5875 :
5876 260043 : record_insns (seq, NULL, &prologue_insn_hash);
5877 260043 : set_insn_locations (seq, prologue_location);
5878 :
5879 260043 : return seq;
5880 : }
5881 :
5882 : /* Return a sequence to be used as the prologue for the current function,
5883 : or NULL. */
5884 :
5885 : static rtx_insn *
5886 1526209 : make_prologue_seq (void)
5887 : {
5888 1526209 : if (!targetm.have_prologue ())
5889 : return NULL;
5890 :
5891 1526209 : start_sequence ();
5892 1526209 : rtx_insn *seq = targetm.gen_prologue ();
5893 1526209 : emit_insn (seq);
5894 :
5895 : /* Insert an explicit USE for the frame pointer
5896 : if the profiling is on and the frame pointer is required. */
5897 1526209 : if (crtl->profile && frame_pointer_needed)
5898 279 : emit_use (hard_frame_pointer_rtx);
5899 :
5900 : /* Retain a map of the prologue insns. */
5901 1526209 : record_insns (seq, NULL, &prologue_insn_hash);
5902 1526209 : emit_note (NOTE_INSN_PROLOGUE_END);
5903 :
5904 : /* Ensure that instructions are not moved into the prologue when
5905 : profiling is on. The call to the profiling routine can be
5906 : emitted within the live range of a call-clobbered register. */
5907 1526209 : if (!targetm.profile_before_prologue () && crtl->profile)
5908 12 : emit_insn (gen_blockage ());
5909 :
5910 1526209 : seq = end_sequence ();
5911 1526209 : set_insn_locations (seq, prologue_location);
5912 :
5913 1526209 : return seq;
5914 : }
5915 :
5916 : /* Emit a sequence of insns to zero the call-used registers before RET
5917 : according to ZERO_REGS_TYPE. */
5918 :
5919 : static void
5920 177 : gen_call_used_regs_seq (rtx_insn *ret, unsigned int zero_regs_type)
5921 : {
5922 177 : bool only_gpr = true;
5923 177 : bool only_used = true;
5924 177 : bool only_arg = true;
5925 :
5926 : /* No need to zero call-used-regs in main (). */
5927 177 : if (MAIN_NAME_P (DECL_NAME (current_function_decl)))
5928 46 : return;
5929 :
5930 : /* No need to zero call-used-regs if __builtin_eh_return is called
5931 : since it isn't a normal function return. */
5932 135 : if (crtl->calls_eh_return)
5933 : return;
5934 :
5935 : /* If only_gpr is true, only zero call-used registers that are
5936 : general-purpose registers; if only_used is true, only zero
5937 : call-used registers that are used in the current function;
5938 : if only_arg is true, only zero call-used registers that pass
5939 : parameters defined by the flatform's calling conversion. */
5940 :
5941 135 : using namespace zero_regs_flags;
5942 :
5943 135 : only_gpr = zero_regs_type & ONLY_GPR;
5944 135 : only_used = zero_regs_type & ONLY_USED;
5945 135 : only_arg = zero_regs_type & ONLY_ARG;
5946 :
5947 135 : if ((zero_regs_type & LEAFY_MODE) && leaf_function_p ())
5948 : only_used = true;
5949 :
5950 : /* For each of the hard registers, we should zero it if:
5951 : 1. it is a call-used register;
5952 : and 2. it is not a fixed register;
5953 : and 3. it is not live at the return of the routine;
5954 : and 4. it is general registor if only_gpr is true;
5955 : and 5. it is used in the routine if only_used is true;
5956 : and 6. it is a register that passes parameter if only_arg is true. */
5957 :
5958 : /* First, prepare the data flow information. */
5959 135 : basic_block bb = BLOCK_FOR_INSN (ret);
5960 135 : auto_bitmap live_out;
5961 135 : bitmap_copy (live_out, df_get_live_out (bb));
5962 135 : df_simulate_initialize_backwards (bb, live_out);
5963 135 : df_simulate_one_insn_backwards (bb, ret, live_out);
5964 :
5965 135 : HARD_REG_SET selected_hardregs;
5966 135 : HARD_REG_SET all_call_used_regs;
5967 540 : CLEAR_HARD_REG_SET (selected_hardregs);
5968 12555 : CLEAR_HARD_REG_SET (all_call_used_regs);
5969 12555 : for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
5970 : {
5971 12420 : if (!crtl->abi->clobbers_full_reg_p (regno))
5972 1215 : continue;
5973 11205 : if (fixed_regs[regno])
5974 5614 : continue;
5975 5591 : if (REGNO_REG_SET_P (live_out, regno))
5976 124 : continue;
5977 : #ifdef LEAF_REG_REMAP
5978 : if (crtl->uses_only_leaf_regs && LEAF_REG_REMAP (regno) < 0)
5979 : continue;
5980 : #endif
5981 : /* This is a call used register that is dead at return. */
5982 5467 : SET_HARD_REG_BIT (all_call_used_regs, regno);
5983 :
5984 7387 : if (only_gpr
5985 5467 : && !TEST_HARD_REG_BIT (reg_class_contents[GENERAL_REGS], regno))
5986 1920 : continue;
5987 3547 : if (only_used && !df_regs_ever_live_p (regno))
5988 1806 : continue;
5989 1741 : if (only_arg && !FUNCTION_ARG_REGNO_P (regno))
5990 364 : continue;
5991 :
5992 : /* Now this is a register that we might want to zero. */
5993 1377 : SET_HARD_REG_BIT (selected_hardregs, regno);
5994 : }
5995 :
5996 135 : if (hard_reg_set_empty_p (selected_hardregs))
5997 4 : return;
5998 :
5999 : /* Now that we have a hard register set that needs to be zeroed, pass it to
6000 : target to generate zeroing sequence. */
6001 131 : HARD_REG_SET zeroed_hardregs;
6002 131 : start_sequence ();
6003 131 : zeroed_hardregs = targetm.calls.zero_call_used_regs (selected_hardregs);
6004 :
6005 : /* For most targets, the returned set of registers is a subset of
6006 : selected_hardregs, however, for some of the targets (for example MIPS),
6007 : clearing some registers that are in selected_hardregs requires clearing
6008 : other call used registers that are not in the selected_hardregs, under
6009 : such situation, the returned set of registers must be a subset of
6010 : all call used registers. */
6011 262 : gcc_assert (hard_reg_set_subset_p (zeroed_hardregs, all_call_used_regs));
6012 :
6013 131 : rtx_insn *seq = end_sequence ();
6014 131 : if (seq)
6015 : {
6016 : /* Emit the memory blockage and register clobber asm volatile before
6017 : the whole sequence. */
6018 131 : start_sequence ();
6019 131 : expand_asm_reg_clobber_mem_blockage (zeroed_hardregs);
6020 131 : rtx_insn *seq_barrier = end_sequence ();
6021 :
6022 131 : emit_insn_before (seq_barrier, ret);
6023 131 : emit_insn_before (seq, ret);
6024 :
6025 : /* Update the data flow information. */
6026 131 : crtl->must_be_zero_on_return |= zeroed_hardregs;
6027 131 : df_update_exit_block_uses ();
6028 : }
6029 135 : }
6030 :
6031 :
6032 : /* Return a sequence to be used as the epilogue for the current function,
6033 : or NULL. */
6034 :
6035 : static rtx_insn *
6036 1526209 : make_epilogue_seq (void)
6037 : {
6038 1526209 : if (!targetm.have_epilogue ())
6039 : return NULL;
6040 :
6041 1526209 : start_sequence ();
6042 1526209 : emit_note (NOTE_INSN_EPILOGUE_BEG);
6043 1526209 : rtx_insn *seq = targetm.gen_epilogue ();
6044 1526209 : if (seq)
6045 1526209 : emit_jump_insn (seq);
6046 :
6047 : /* Retain a map of the epilogue insns. */
6048 1526209 : record_insns (seq, NULL, &epilogue_insn_hash);
6049 1526209 : set_insn_locations (seq, epilogue_location);
6050 :
6051 1526209 : seq = get_insns ();
6052 1526209 : rtx_insn *returnjump = get_last_insn ();
6053 1526209 : end_sequence ();
6054 :
6055 1526209 : if (JUMP_P (returnjump))
6056 1526135 : set_return_jump_label (returnjump);
6057 :
6058 : return seq;
6059 : }
6060 :
6061 :
6062 : /* Generate the prologue and epilogue RTL if the machine supports it. Thread
6063 : this into place with notes indicating where the prologue ends and where
6064 : the epilogue begins. Update the basic block information when possible.
6065 :
6066 : Notes on epilogue placement:
6067 : There are several kinds of edges to the exit block:
6068 : * a single fallthru edge from LAST_BB
6069 : * possibly, edges from blocks containing sibcalls
6070 : * possibly, fake edges from infinite loops
6071 :
6072 : The epilogue is always emitted on the fallthru edge from the last basic
6073 : block in the function, LAST_BB, into the exit block.
6074 :
6075 : If LAST_BB is empty except for a label, it is the target of every
6076 : other basic block in the function that ends in a return. If a
6077 : target has a return or simple_return pattern (possibly with
6078 : conditional variants), these basic blocks can be changed so that a
6079 : return insn is emitted into them, and their target is adjusted to
6080 : the real exit block.
6081 :
6082 : Notes on shrink wrapping: We implement a fairly conservative
6083 : version of shrink-wrapping rather than the textbook one. We only
6084 : generate a single prologue and a single epilogue. This is
6085 : sufficient to catch a number of interesting cases involving early
6086 : exits.
6087 :
6088 : First, we identify the blocks that require the prologue to occur before
6089 : them. These are the ones that modify a call-saved register, or reference
6090 : any of the stack or frame pointer registers. To simplify things, we then
6091 : mark everything reachable from these blocks as also requiring a prologue.
6092 : This takes care of loops automatically, and avoids the need to examine
6093 : whether MEMs reference the frame, since it is sufficient to check for
6094 : occurrences of the stack or frame pointer.
6095 :
6096 : We then compute the set of blocks for which the need for a prologue
6097 : is anticipatable (borrowing terminology from the shrink-wrapping
6098 : description in Muchnick's book). These are the blocks which either
6099 : require a prologue themselves, or those that have only successors
6100 : where the prologue is anticipatable. The prologue needs to be
6101 : inserted on all edges from BB1->BB2 where BB2 is in ANTIC and BB1
6102 : is not. For the moment, we ensure that only one such edge exists.
6103 :
6104 : The epilogue is placed as described above, but we make a
6105 : distinction between inserting return and simple_return patterns
6106 : when modifying other blocks that end in a return. Blocks that end
6107 : in a sibcall omit the sibcall_epilogue if the block is not in
6108 : ANTIC. */
6109 :
6110 : void
6111 1481484 : thread_prologue_and_epilogue_insns (void)
6112 : {
6113 1481484 : df_analyze ();
6114 :
6115 : /* Can't deal with multiple successors of the entry block at the
6116 : moment. Function should always have at least one entry
6117 : point. */
6118 1481484 : gcc_assert (single_succ_p (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
6119 :
6120 1481484 : edge entry_edge = single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun));
6121 1481484 : edge orig_entry_edge = entry_edge;
6122 :
6123 1481484 : rtx_insn *split_prologue_seq = make_split_prologue_seq ();
6124 1481484 : rtx_insn *prologue_seq = make_prologue_seq ();
6125 1481484 : rtx_insn *epilogue_seq = make_epilogue_seq ();
6126 :
6127 : /* Try to perform a kind of shrink-wrapping, making sure the
6128 : prologue/epilogue is emitted only around those parts of the
6129 : function that require it. */
6130 1481484 : try_shrink_wrapping (&entry_edge, prologue_seq);
6131 :
6132 : /* If the target can handle splitting the prologue/epilogue into separate
6133 : components, try to shrink-wrap these components separately. */
6134 1481484 : try_shrink_wrapping_separate (entry_edge->dest);
6135 :
6136 : /* If that did anything for any component we now need the generate the
6137 : "main" prologue again. Because some targets require some of these
6138 : to be called in a specific order (i386 requires the split prologue
6139 : to be first, for example), we create all three sequences again here.
6140 : If this does not work for some target, that target should not enable
6141 : separate shrink-wrapping. */
6142 1481484 : if (crtl->shrink_wrapped_separate)
6143 : {
6144 44725 : split_prologue_seq = make_split_prologue_seq ();
6145 44725 : prologue_seq = make_prologue_seq ();
6146 44725 : epilogue_seq = make_epilogue_seq ();
6147 : }
6148 :
6149 1481484 : rtl_profile_for_bb (EXIT_BLOCK_PTR_FOR_FN (cfun));
6150 :
6151 : /* A small fib -- epilogue is not yet completed, but we wish to re-use
6152 : this marker for the splits of EH_RETURN patterns, and nothing else
6153 : uses the flag in the meantime. */
6154 1481484 : epilogue_completed = 1;
6155 :
6156 : /* Find non-fallthru edges that end with EH_RETURN instructions. On
6157 : some targets, these get split to a special version of the epilogue
6158 : code. In order to be able to properly annotate these with unwind
6159 : info, try to split them now. If we get a valid split, drop an
6160 : EPILOGUE_BEG note and mark the insns as epilogue insns. */
6161 1481484 : edge e;
6162 1481484 : edge_iterator ei;
6163 3016796 : FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
6164 : {
6165 1535312 : rtx_insn *prev, *last, *trial;
6166 :
6167 1535312 : if (e->flags & EDGE_FALLTHRU)
6168 1351694 : continue;
6169 183618 : last = BB_END (e->src);
6170 183618 : if (!eh_returnjump_p (last))
6171 183589 : continue;
6172 :
6173 29 : prev = PREV_INSN (last);
6174 29 : trial = try_split (PATTERN (last), last, 1);
6175 29 : if (trial == last)
6176 0 : continue;
6177 :
6178 29 : record_insns (NEXT_INSN (prev), NEXT_INSN (trial), &epilogue_insn_hash);
6179 29 : emit_note_after (NOTE_INSN_EPILOGUE_BEG, prev);
6180 : }
6181 :
6182 1481484 : edge exit_fallthru_edge = find_fallthru_edge (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds);
6183 :
6184 1481484 : if (exit_fallthru_edge)
6185 : {
6186 1351694 : if (epilogue_seq)
6187 : {
6188 1351694 : insert_insn_on_edge (epilogue_seq, exit_fallthru_edge);
6189 1351694 : commit_edge_insertions ();
6190 :
6191 : /* The epilogue insns we inserted may cause the exit edge to no longer
6192 : be fallthru. */
6193 2783593 : FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
6194 : {
6195 1431899 : if (((e->flags & EDGE_FALLTHRU) != 0)
6196 1431899 : && returnjump_p (BB_END (e->src)))
6197 0 : e->flags &= ~EDGE_FALLTHRU;
6198 : }
6199 :
6200 1351694 : find_sub_basic_blocks (BLOCK_FOR_INSN (epilogue_seq));
6201 : }
6202 0 : else if (next_active_insn (BB_END (exit_fallthru_edge->src)))
6203 : {
6204 : /* We have a fall-through edge to the exit block, the source is not
6205 : at the end of the function, and there will be an assembler epilogue
6206 : at the end of the function.
6207 : We can't use force_nonfallthru here, because that would try to
6208 : use return. Inserting a jump 'by hand' is extremely messy, so
6209 : we take advantage of cfg_layout_finalize using
6210 : fixup_fallthru_exit_predecessor. */
6211 0 : cfg_layout_initialize (0);
6212 0 : basic_block cur_bb;
6213 0 : FOR_EACH_BB_FN (cur_bb, cfun)
6214 0 : if (cur_bb->index >= NUM_FIXED_BLOCKS
6215 0 : && cur_bb->next_bb->index >= NUM_FIXED_BLOCKS)
6216 0 : cur_bb->aux = cur_bb->next_bb;
6217 0 : cfg_layout_finalize ();
6218 : }
6219 : }
6220 :
6221 : /* Insert the prologue. */
6222 :
6223 1481484 : rtl_profile_for_bb (ENTRY_BLOCK_PTR_FOR_FN (cfun));
6224 :
6225 1481484 : if (split_prologue_seq || prologue_seq)
6226 : {
6227 1481484 : rtx_insn *split_prologue_insn = split_prologue_seq;
6228 1481484 : if (split_prologue_seq)
6229 : {
6230 260039 : while (split_prologue_insn && !NONDEBUG_INSN_P (split_prologue_insn))
6231 0 : split_prologue_insn = NEXT_INSN (split_prologue_insn);
6232 260039 : insert_insn_on_edge (split_prologue_seq, orig_entry_edge);
6233 : }
6234 :
6235 1481484 : rtx_insn *prologue_insn = prologue_seq;
6236 1481484 : if (prologue_seq)
6237 : {
6238 1871969 : while (prologue_insn && !NONDEBUG_INSN_P (prologue_insn))
6239 390485 : prologue_insn = NEXT_INSN (prologue_insn);
6240 1481484 : insert_insn_on_edge (prologue_seq, entry_edge);
6241 : }
6242 :
6243 1481484 : commit_edge_insertions ();
6244 :
6245 : /* Look for basic blocks within the prologue insns. */
6246 1481484 : if (split_prologue_insn
6247 1481484 : && BLOCK_FOR_INSN (split_prologue_insn) == NULL)
6248 : split_prologue_insn = NULL;
6249 1481484 : if (prologue_insn
6250 1481484 : && BLOCK_FOR_INSN (prologue_insn) == NULL)
6251 : prologue_insn = NULL;
6252 1481484 : if (split_prologue_insn || prologue_insn)
6253 : {
6254 1114648 : auto_sbitmap blocks (last_basic_block_for_fn (cfun));
6255 1114648 : bitmap_clear (blocks);
6256 1114648 : if (split_prologue_insn)
6257 260039 : bitmap_set_bit (blocks,
6258 260039 : BLOCK_FOR_INSN (split_prologue_insn)->index);
6259 1114648 : if (prologue_insn)
6260 1090999 : bitmap_set_bit (blocks, BLOCK_FOR_INSN (prologue_insn)->index);
6261 1114648 : find_many_sub_basic_blocks (blocks);
6262 1114648 : }
6263 : }
6264 :
6265 1481484 : default_rtl_profile ();
6266 :
6267 : /* Emit sibling epilogues before any sibling call sites. */
6268 1481484 : for (ei = ei_start (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds);
6269 3016796 : (e = ei_safe_edge (ei));
6270 1535312 : ei_next (&ei))
6271 : {
6272 : /* Skip those already handled, the ones that run without prologue. */
6273 1535312 : if (e->flags & EDGE_IGNORE)
6274 : {
6275 4820 : e->flags &= ~EDGE_IGNORE;
6276 4820 : continue;
6277 : }
6278 :
6279 1530492 : rtx_insn *insn = BB_END (e->src);
6280 :
6281 1530492 : if (!(CALL_P (insn) && SIBLING_CALL_P (insn)))
6282 1406072 : continue;
6283 :
6284 124420 : rtx_insn *ep_seq;
6285 124420 : if (targetm.emit_epilogue_for_sibcall)
6286 : {
6287 0 : start_sequence ();
6288 0 : targetm.emit_epilogue_for_sibcall (as_a<rtx_call_insn *> (insn));
6289 0 : ep_seq = end_sequence ();
6290 : }
6291 : else
6292 124420 : ep_seq = targetm.gen_sibcall_epilogue ();
6293 124420 : if (ep_seq)
6294 : {
6295 58255 : start_sequence ();
6296 58255 : emit_note (NOTE_INSN_EPILOGUE_BEG);
6297 58255 : emit_insn (ep_seq);
6298 58255 : rtx_insn *seq = end_sequence ();
6299 :
6300 : /* Retain a map of the epilogue insns. Used in life analysis to
6301 : avoid getting rid of sibcall epilogue insns. Do this before we
6302 : actually emit the sequence. */
6303 58255 : record_insns (seq, NULL, &epilogue_insn_hash);
6304 58255 : set_insn_locations (seq, epilogue_location);
6305 :
6306 58255 : emit_insn_before (seq, insn);
6307 :
6308 58255 : find_sub_basic_blocks (BLOCK_FOR_INSN (insn));
6309 : }
6310 : }
6311 :
6312 1481484 : if (epilogue_seq)
6313 : {
6314 : rtx_insn *insn, *next;
6315 :
6316 : /* Similarly, move any line notes that appear after the epilogue.
6317 : There is no need, however, to be quite so anal about the existence
6318 : of such a note. Also possibly move
6319 : NOTE_INSN_FUNCTION_BEG notes, as those can be relevant for debug
6320 : info generation. */
6321 11575323 : for (insn = epilogue_seq; insn; insn = next)
6322 : {
6323 10093839 : next = NEXT_INSN (insn);
6324 10093839 : if (NOTE_P (insn)
6325 3119078 : && (NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG))
6326 0 : reorder_insns (insn, insn, PREV_INSN (epilogue_seq));
6327 : }
6328 : }
6329 :
6330 : /* Threading the prologue and epilogue changes the artificial refs in the
6331 : entry and exit blocks, and may invalidate DF info for tail calls.
6332 : This is also needed for [[musttail]] conversion even when not
6333 : optimizing. */
6334 1481484 : if (optimize
6335 435206 : || cfun->tail_call_marked
6336 435038 : || flag_optimize_sibling_calls
6337 434997 : || flag_ipa_icf_functions
6338 434940 : || in_lto_p)
6339 1054933 : df_update_entry_exit_and_calls ();
6340 : else
6341 : {
6342 426551 : df_update_entry_block_defs ();
6343 426551 : df_update_exit_block_uses ();
6344 : }
6345 1481484 : }
6346 :
6347 : /* Reposition the prologue-end and epilogue-begin notes after
6348 : instruction scheduling. */
6349 :
6350 : void
6351 966053 : reposition_prologue_and_epilogue_notes (void)
6352 : {
6353 966053 : if (!targetm.have_prologue ()
6354 0 : && !targetm.have_epilogue ()
6355 0 : && !targetm.have_sibcall_epilogue ()
6356 966053 : && !targetm.emit_epilogue_for_sibcall)
6357 : return;
6358 :
6359 : /* Since the hash table is created on demand, the fact that it is
6360 : non-null is a signal that it is non-empty. */
6361 966053 : if (prologue_insn_hash != NULL)
6362 : {
6363 966053 : size_t len = prologue_insn_hash->elements ();
6364 966053 : rtx_insn *insn, *last = NULL, *note = NULL;
6365 :
6366 : /* Scan from the beginning until we reach the last prologue insn. */
6367 : /* ??? While we do have the CFG intact, there are two problems:
6368 : (1) The prologue can contain loops (typically probing the stack),
6369 : which means that the end of the prologue isn't in the first bb.
6370 : (2) Sometimes the PROLOGUE_END note gets pushed into the next bb. */
6371 68595222 : for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
6372 : {
6373 68059837 : if (NOTE_P (insn))
6374 : {
6375 12783981 : if (NOTE_KIND (insn) == NOTE_INSN_PROLOGUE_END)
6376 67629169 : note = insn;
6377 : }
6378 55275856 : else if (contains (insn, prologue_insn_hash))
6379 : {
6380 3457131 : last = insn;
6381 3457131 : if (--len == 0)
6382 : break;
6383 : }
6384 : }
6385 :
6386 966053 : if (last)
6387 : {
6388 628079 : if (note == NULL)
6389 : {
6390 : /* Scan forward looking for the PROLOGUE_END note. It should
6391 : be right at the beginning of the block, possibly with other
6392 : insn notes that got moved there. */
6393 1392 : for (note = NEXT_INSN (last); ; note = NEXT_INSN (note))
6394 : {
6395 1392 : if (NOTE_P (note)
6396 1282 : && NOTE_KIND (note) == NOTE_INSN_PROLOGUE_END)
6397 : break;
6398 : }
6399 : }
6400 :
6401 : /* Avoid placing note between CODE_LABEL and BASIC_BLOCK note. */
6402 628079 : if (LABEL_P (last))
6403 229 : last = NEXT_INSN (last);
6404 628079 : reorder_insns (note, note, last);
6405 : }
6406 : }
6407 :
6408 966053 : if (epilogue_insn_hash != NULL)
6409 : {
6410 966053 : edge_iterator ei;
6411 966053 : edge e;
6412 :
6413 2195103 : FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
6414 : {
6415 1229050 : rtx_insn *insn, *first = NULL, *note = NULL;
6416 1229050 : basic_block bb = e->src;
6417 :
6418 : /* Scan from the beginning until we reach the first epilogue insn. */
6419 16742402 : FOR_BB_INSNS (bb, insn)
6420 : {
6421 16592452 : if (NOTE_P (insn))
6422 : {
6423 3939676 : if (NOTE_KIND (insn) == NOTE_INSN_EPILOGUE_BEG)
6424 : {
6425 1079100 : note = insn;
6426 1079100 : if (first != NULL)
6427 : break;
6428 : }
6429 : }
6430 12652776 : else if (first == NULL && contains (insn, epilogue_insn_hash))
6431 : {
6432 1079104 : first = insn;
6433 1079104 : if (note != NULL)
6434 : break;
6435 : }
6436 : }
6437 :
6438 1229050 : if (note)
6439 : {
6440 : /* If the function has a single basic block, and no real
6441 : epilogue insns (e.g. sibcall with no cleanup), the
6442 : epilogue note can get scheduled before the prologue
6443 : note. If we have frame related prologue insns, having
6444 : them scanned during the epilogue will result in a crash.
6445 : In this case re-order the epilogue note to just before
6446 : the last insn in the block. */
6447 1079100 : if (first == NULL)
6448 0 : first = BB_END (bb);
6449 :
6450 1079100 : if (PREV_INSN (first) != note)
6451 30866 : reorder_insns (note, note, PREV_INSN (first));
6452 : }
6453 : }
6454 : }
6455 : }
6456 :
6457 : /* Returns the name of function declared by FNDECL. */
6458 : const char *
6459 119781 : fndecl_name (tree fndecl)
6460 : {
6461 119781 : if (fndecl == NULL)
6462 : return "(nofn)";
6463 119766 : return lang_hooks.decl_printable_name (fndecl, 1);
6464 : }
6465 :
6466 : /* Returns the name of function FN. */
6467 : const char *
6468 119728 : function_name (const function *fn)
6469 : {
6470 119728 : tree fndecl = (fn == NULL) ? NULL : fn->decl;
6471 119728 : return fndecl_name (fndecl);
6472 : }
6473 :
6474 : /* Returns the name of the current function. */
6475 : const char *
6476 8724 : current_function_name (void)
6477 : {
6478 8724 : return function_name (cfun);
6479 : }
6480 :
6481 :
6482 : static void
6483 0 : rest_of_handle_check_leaf_regs (void)
6484 : {
6485 : #ifdef LEAF_REGISTERS
6486 : crtl->uses_only_leaf_regs
6487 : = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
6488 : #endif
6489 0 : }
6490 :
6491 : /* Insert a TYPE into the used types hash table of CFUN. */
6492 :
6493 : static void
6494 56226209 : used_types_insert_helper (tree type, struct function *func)
6495 : {
6496 56226209 : if (type != NULL && func != NULL)
6497 : {
6498 56226209 : if (func->used_types_hash == NULL)
6499 17144157 : func->used_types_hash = hash_set<tree>::create_ggc (37);
6500 :
6501 56226209 : func->used_types_hash->add (type);
6502 : }
6503 56226209 : }
6504 :
6505 : /* Given a type, insert it into the used hash table in cfun. */
6506 : void
6507 206008728 : used_types_insert (tree t)
6508 : {
6509 215496346 : while (POINTER_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
6510 9709797 : if (TYPE_NAME (t))
6511 : break;
6512 : else
6513 9487618 : t = TREE_TYPE (t);
6514 206008728 : if (TREE_CODE (t) == ERROR_MARK)
6515 : return;
6516 206008723 : if (TYPE_NAME (t) == NULL_TREE
6517 206008723 : || TYPE_NAME (t) == TYPE_NAME (TYPE_MAIN_VARIANT (t)))
6518 75541997 : t = TYPE_MAIN_VARIANT (t);
6519 206008723 : if (debug_info_level > DINFO_LEVEL_NONE)
6520 : {
6521 81635766 : if (cfun)
6522 56226209 : used_types_insert_helper (t, cfun);
6523 : else
6524 : {
6525 : /* So this might be a type referenced by a global variable.
6526 : Record that type so that we can later decide to emit its
6527 : debug information. */
6528 25409557 : vec_safe_push (types_used_by_cur_var_decl, t);
6529 : }
6530 : }
6531 : }
6532 :
6533 : /* Helper to Hash a struct types_used_by_vars_entry. */
6534 :
6535 : static hashval_t
6536 166127833 : hash_types_used_by_vars_entry (const struct types_used_by_vars_entry *entry)
6537 : {
6538 166127833 : gcc_assert (entry && entry->var_decl && entry->type);
6539 :
6540 166127833 : return iterative_hash_object (entry->type,
6541 : iterative_hash_object (entry->var_decl, 0));
6542 : }
6543 :
6544 : /* Hash function of the types_used_by_vars_entry hash table. */
6545 :
6546 : hashval_t
6547 166127833 : used_type_hasher::hash (types_used_by_vars_entry *entry)
6548 : {
6549 166127833 : return hash_types_used_by_vars_entry (entry);
6550 : }
6551 :
6552 : /*Equality function of the types_used_by_vars_entry hash table. */
6553 :
6554 : bool
6555 180764498 : used_type_hasher::equal (types_used_by_vars_entry *e1,
6556 : types_used_by_vars_entry *e2)
6557 : {
6558 180764498 : return (e1->var_decl == e2->var_decl && e1->type == e2->type);
6559 : }
6560 :
6561 : /* Inserts an entry into the types_used_by_vars_hash hash table. */
6562 :
6563 : void
6564 25338434 : types_used_by_var_decl_insert (tree type, tree var_decl)
6565 : {
6566 25338434 : if (type != NULL && var_decl != NULL)
6567 : {
6568 25338434 : types_used_by_vars_entry **slot;
6569 25338434 : struct types_used_by_vars_entry e;
6570 25338434 : e.var_decl = var_decl;
6571 25338434 : e.type = type;
6572 25338434 : if (types_used_by_vars_hash == NULL)
6573 14660 : types_used_by_vars_hash
6574 14660 : = hash_table<used_type_hasher>::create_ggc (37);
6575 :
6576 25338434 : slot = types_used_by_vars_hash->find_slot (&e, INSERT);
6577 25338434 : if (*slot == NULL)
6578 : {
6579 7542444 : struct types_used_by_vars_entry *entry;
6580 7542444 : entry = ggc_alloc<types_used_by_vars_entry> ();
6581 7542444 : entry->type = type;
6582 7542444 : entry->var_decl = var_decl;
6583 7542444 : *slot = entry;
6584 : }
6585 : }
6586 25338434 : }
6587 :
6588 : namespace {
6589 :
6590 : const pass_data pass_data_leaf_regs =
6591 : {
6592 : RTL_PASS, /* type */
6593 : "*leaf_regs", /* name */
6594 : OPTGROUP_NONE, /* optinfo_flags */
6595 : TV_NONE, /* tv_id */
6596 : 0, /* properties_required */
6597 : 0, /* properties_provided */
6598 : 0, /* properties_destroyed */
6599 : 0, /* todo_flags_start */
6600 : 0, /* todo_flags_finish */
6601 : };
6602 :
6603 : class pass_leaf_regs : public rtl_opt_pass
6604 : {
6605 : public:
6606 288767 : pass_leaf_regs (gcc::context *ctxt)
6607 577534 : : rtl_opt_pass (pass_data_leaf_regs, ctxt)
6608 : {}
6609 :
6610 : /* opt_pass methods: */
6611 1481484 : unsigned int execute (function *) final override
6612 : {
6613 1481484 : rest_of_handle_check_leaf_regs ();
6614 1481484 : return 0;
6615 : }
6616 :
6617 : }; // class pass_leaf_regs
6618 :
6619 : } // anon namespace
6620 :
6621 : rtl_opt_pass *
6622 288767 : make_pass_leaf_regs (gcc::context *ctxt)
6623 : {
6624 288767 : return new pass_leaf_regs (ctxt);
6625 : }
6626 :
6627 : static void
6628 1481484 : rest_of_handle_thread_prologue_and_epilogue (function *fun)
6629 : {
6630 : /* prepare_shrink_wrap is sensitive to the block structure of the control
6631 : flow graph, so clean it up first. */
6632 1481484 : if (cfun->tail_call_marked || optimize)
6633 1046446 : cleanup_cfg (0);
6634 :
6635 : /* On some machines, the prologue and epilogue code, or parts thereof,
6636 : can be represented as RTL. Doing so lets us schedule insns between
6637 : it and the rest of the code and also allows delayed branch
6638 : scheduling to operate in the epilogue. */
6639 1481484 : thread_prologue_and_epilogue_insns ();
6640 :
6641 : /* Some non-cold blocks may now be only reachable from cold blocks.
6642 : Fix that up. */
6643 1481484 : fixup_partitions ();
6644 :
6645 : /* After prologue and epilogue generation, the judgement on whether
6646 : one memory access onto stack frame may trap or not could change,
6647 : since we get more exact stack information by now. So try to
6648 : remove any EH edges here, see PR90259. */
6649 1481484 : if (fun->can_throw_non_call_exceptions)
6650 262980 : purge_all_dead_edges ();
6651 :
6652 : /* Shrink-wrapping can result in unreachable edges in the epilogue,
6653 : see PR57320. */
6654 1916690 : cleanup_cfg (optimize ? CLEANUP_EXPENSIVE : 0);
6655 :
6656 : /* The stack usage info is finalized during prologue expansion. */
6657 1481484 : if (flag_stack_usage_info || flag_callgraph_info)
6658 356 : output_stack_usage ();
6659 1481484 : }
6660 :
6661 : /* Record a final call to CALLEE at LOCATION. */
6662 :
6663 : void
6664 0 : record_final_call (tree callee, location_t location)
6665 : {
6666 0 : struct callinfo_callee datum = { location, callee };
6667 0 : vec_safe_push (cfun->su->callees, datum);
6668 0 : }
6669 :
6670 : /* Record a dynamic allocation made for DECL_OR_EXP. */
6671 :
6672 : void
6673 0 : record_dynamic_alloc (tree decl_or_exp)
6674 : {
6675 0 : struct callinfo_dalloc datum;
6676 :
6677 0 : if (DECL_P (decl_or_exp))
6678 : {
6679 0 : datum.location = DECL_SOURCE_LOCATION (decl_or_exp);
6680 0 : const char *name = lang_hooks.decl_printable_name (decl_or_exp, 2);
6681 0 : const char *dot = strrchr (name, '.');
6682 0 : if (dot)
6683 0 : name = dot + 1;
6684 0 : datum.name = ggc_strdup (name);
6685 : }
6686 : else
6687 : {
6688 0 : datum.location = EXPR_LOCATION (decl_or_exp);
6689 0 : datum.name = NULL;
6690 : }
6691 :
6692 0 : vec_safe_push (cfun->su->dallocs, datum);
6693 0 : }
6694 :
6695 : namespace {
6696 :
6697 : const pass_data pass_data_thread_prologue_and_epilogue =
6698 : {
6699 : RTL_PASS, /* type */
6700 : "pro_and_epilogue", /* name */
6701 : OPTGROUP_NONE, /* optinfo_flags */
6702 : TV_THREAD_PROLOGUE_AND_EPILOGUE, /* tv_id */
6703 : 0, /* properties_required */
6704 : 0, /* properties_provided */
6705 : 0, /* properties_destroyed */
6706 : 0, /* todo_flags_start */
6707 : ( TODO_df_verify | TODO_df_finish ), /* todo_flags_finish */
6708 : };
6709 :
6710 : class pass_thread_prologue_and_epilogue : public rtl_opt_pass
6711 : {
6712 : public:
6713 288767 : pass_thread_prologue_and_epilogue (gcc::context *ctxt)
6714 577534 : : rtl_opt_pass (pass_data_thread_prologue_and_epilogue, ctxt)
6715 : {}
6716 :
6717 : /* opt_pass methods: */
6718 1481491 : bool gate (function *) final override
6719 : {
6720 1481491 : return !targetm.use_late_prologue_epilogue ();
6721 : }
6722 :
6723 1481484 : unsigned int execute (function * fun) final override
6724 : {
6725 1481484 : rest_of_handle_thread_prologue_and_epilogue (fun);
6726 1481484 : return 0;
6727 : }
6728 :
6729 : }; // class pass_thread_prologue_and_epilogue
6730 :
6731 : const pass_data pass_data_late_thread_prologue_and_epilogue =
6732 : {
6733 : RTL_PASS, /* type */
6734 : "late_pro_and_epilogue", /* name */
6735 : OPTGROUP_NONE, /* optinfo_flags */
6736 : TV_THREAD_PROLOGUE_AND_EPILOGUE, /* tv_id */
6737 : 0, /* properties_required */
6738 : 0, /* properties_provided */
6739 : 0, /* properties_destroyed */
6740 : 0, /* todo_flags_start */
6741 : ( TODO_df_verify | TODO_df_finish ), /* todo_flags_finish */
6742 : };
6743 :
6744 : class pass_late_thread_prologue_and_epilogue : public rtl_opt_pass
6745 : {
6746 : public:
6747 288767 : pass_late_thread_prologue_and_epilogue (gcc::context *ctxt)
6748 577534 : : rtl_opt_pass (pass_data_late_thread_prologue_and_epilogue, ctxt)
6749 : {}
6750 :
6751 : /* opt_pass methods: */
6752 1481491 : bool gate (function *) final override
6753 : {
6754 1481491 : return targetm.use_late_prologue_epilogue ();
6755 : }
6756 :
6757 0 : unsigned int execute (function *fn) final override
6758 : {
6759 : /* It's not currently possible to have both delay slots and
6760 : late prologue/epilogue, since the latter has to run before
6761 : the former, and the former won't honor whatever restrictions
6762 : the latter is trying to enforce. */
6763 0 : gcc_assert (!DELAY_SLOTS);
6764 0 : rest_of_handle_thread_prologue_and_epilogue (fn);
6765 0 : return 0;
6766 : }
6767 : }; // class pass_late_thread_prologue_and_epilogue
6768 :
6769 : } // anon namespace
6770 :
6771 : rtl_opt_pass *
6772 288767 : make_pass_thread_prologue_and_epilogue (gcc::context *ctxt)
6773 : {
6774 288767 : return new pass_thread_prologue_and_epilogue (ctxt);
6775 : }
6776 :
6777 : rtl_opt_pass *
6778 288767 : make_pass_late_thread_prologue_and_epilogue (gcc::context *ctxt)
6779 : {
6780 288767 : return new pass_late_thread_prologue_and_epilogue (ctxt);
6781 : }
6782 :
6783 : namespace {
6784 :
6785 : const pass_data pass_data_zero_call_used_regs =
6786 : {
6787 : RTL_PASS, /* type */
6788 : "zero_call_used_regs", /* name */
6789 : OPTGROUP_NONE, /* optinfo_flags */
6790 : TV_NONE, /* tv_id */
6791 : 0, /* properties_required */
6792 : 0, /* properties_provided */
6793 : 0, /* properties_destroyed */
6794 : 0, /* todo_flags_start */
6795 : 0, /* todo_flags_finish */
6796 : };
6797 :
6798 : class pass_zero_call_used_regs: public rtl_opt_pass
6799 : {
6800 : public:
6801 288767 : pass_zero_call_used_regs (gcc::context *ctxt)
6802 577534 : : rtl_opt_pass (pass_data_zero_call_used_regs, ctxt)
6803 : {}
6804 :
6805 : /* opt_pass methods: */
6806 : unsigned int execute (function *) final override;
6807 :
6808 : }; // class pass_zero_call_used_regs
6809 :
6810 : unsigned int
6811 1481484 : pass_zero_call_used_regs::execute (function *fun)
6812 : {
6813 1481484 : using namespace zero_regs_flags;
6814 1481484 : unsigned int zero_regs_type = UNSET;
6815 :
6816 1481484 : tree attr_zero_regs = lookup_attribute ("zero_call_used_regs",
6817 1481484 : DECL_ATTRIBUTES (fun->decl));
6818 :
6819 : /* Get the type of zero_call_used_regs from function attribute.
6820 : We have filtered out invalid attribute values already at this point. */
6821 1481484 : if (attr_zero_regs)
6822 : {
6823 : /* The TREE_VALUE of an attribute is a TREE_LIST whose TREE_VALUE
6824 : is the attribute argument's value. */
6825 88 : attr_zero_regs = TREE_VALUE (attr_zero_regs);
6826 88 : gcc_assert (TREE_CODE (attr_zero_regs) == TREE_LIST);
6827 88 : attr_zero_regs = TREE_VALUE (attr_zero_regs);
6828 88 : gcc_assert (TREE_CODE (attr_zero_regs) == STRING_CST);
6829 :
6830 496 : for (unsigned int i = 0; zero_call_used_regs_opts[i].name != NULL; ++i)
6831 496 : if (strcmp (TREE_STRING_POINTER (attr_zero_regs),
6832 496 : zero_call_used_regs_opts[i].name) == 0)
6833 : {
6834 88 : zero_regs_type = zero_call_used_regs_opts[i].flag;
6835 88 : break;
6836 : }
6837 : }
6838 :
6839 88 : if (!zero_regs_type)
6840 1481396 : zero_regs_type = flag_zero_call_used_regs;
6841 :
6842 : /* No need to zero call-used-regs when no user request is present. */
6843 1481484 : if (!(zero_regs_type & ENABLED))
6844 : return 0;
6845 :
6846 183 : edge_iterator ei;
6847 183 : edge e;
6848 :
6849 : /* This pass needs data flow information. */
6850 183 : df_analyze ();
6851 :
6852 : /* Iterate over the function's return instructions and insert any
6853 : register zeroing required by the -fzero-call-used-regs command-line
6854 : option or the "zero_call_used_regs" function attribute. */
6855 367 : FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
6856 : {
6857 184 : rtx_insn *insn = BB_END (e->src);
6858 184 : if (JUMP_P (insn) && ANY_RETURN_P (JUMP_LABEL (insn)))
6859 177 : gen_call_used_regs_seq (insn, zero_regs_type);
6860 : }
6861 :
6862 : return 0;
6863 : }
6864 :
6865 : } // anon namespace
6866 :
6867 : rtl_opt_pass *
6868 288767 : make_pass_zero_call_used_regs (gcc::context *ctxt)
6869 : {
6870 288767 : return new pass_zero_call_used_regs (ctxt);
6871 : }
6872 :
6873 : /* If CONSTRAINT is a matching constraint, then return its number.
6874 : Otherwise, return -1. */
6875 :
6876 : static int
6877 43653 : matching_constraint_num (const char *constraint)
6878 : {
6879 43653 : if (*constraint == '%')
6880 1140 : constraint++;
6881 :
6882 43653 : if (IN_RANGE (*constraint, '0', '9'))
6883 31908 : return strtoul (constraint, NULL, 10);
6884 :
6885 : return -1;
6886 : }
6887 :
6888 : /* This mini-pass fixes fall-out from SSA in asm statements that have
6889 : in-out constraints. Say you start with
6890 :
6891 : orig = inout;
6892 : asm ("": "+mr" (inout));
6893 : use (orig);
6894 :
6895 : which is transformed very early to use explicit output and match operands:
6896 :
6897 : orig = inout;
6898 : asm ("": "=mr" (inout) : "0" (inout));
6899 : use (orig);
6900 :
6901 : Or, after SSA and copyprop,
6902 :
6903 : asm ("": "=mr" (inout_2) : "0" (inout_1));
6904 : use (inout_1);
6905 :
6906 : Clearly inout_2 and inout_1 can't be coalesced easily anymore, as
6907 : they represent two separate values, so they will get different pseudo
6908 : registers during expansion. Then, since the two operands need to match
6909 : per the constraints, but use different pseudo registers, reload can
6910 : only register a reload for these operands. But reloads can only be
6911 : satisfied by hardregs, not by memory, so we need a register for this
6912 : reload, just because we are presented with non-matching operands.
6913 : So, even though we allow memory for this operand, no memory can be
6914 : used for it, just because the two operands don't match. This can
6915 : cause reload failures on register-starved targets.
6916 :
6917 : So it's a symptom of reload not being able to use memory for reloads
6918 : or, alternatively it's also a symptom of both operands not coming into
6919 : reload as matching (in which case the pseudo could go to memory just
6920 : fine, as the alternative allows it, and no reload would be necessary).
6921 : We fix the latter problem here, by transforming
6922 :
6923 : asm ("": "=mr" (inout_2) : "0" (inout_1));
6924 :
6925 : back to
6926 :
6927 : inout_2 = inout_1;
6928 : asm ("": "=mr" (inout_2) : "0" (inout_2)); */
6929 :
6930 : static void
6931 34696 : match_asm_constraints_1 (rtx_insn *insn, rtx *p_sets, int noutputs)
6932 : {
6933 34696 : int i;
6934 34696 : bool changed = false;
6935 34696 : rtx op = SET_SRC (p_sets[0]);
6936 34696 : int ninputs = ASM_OPERANDS_INPUT_LENGTH (op);
6937 34696 : rtvec inputs = ASM_OPERANDS_INPUT_VEC (op);
6938 34696 : bool *output_matched = XALLOCAVEC (bool, noutputs);
6939 :
6940 34696 : memset (output_matched, 0, noutputs * sizeof (bool));
6941 77420 : for (i = 0; i < ninputs; i++)
6942 : {
6943 42724 : rtx input, output;
6944 42724 : rtx_insn *insns;
6945 42724 : const char *constraint = ASM_OPERANDS_INPUT_CONSTRAINT (op, i);
6946 42724 : int match, j;
6947 :
6948 42724 : match = matching_constraint_num (constraint);
6949 42724 : if (match < 0)
6950 11741 : continue;
6951 :
6952 30983 : gcc_assert (match < noutputs);
6953 30983 : output = SET_DEST (p_sets[match]);
6954 30983 : input = RTVEC_ELT (inputs, i);
6955 : /* Only do the transformation for pseudos. */
6956 31956 : if (! REG_P (output)
6957 30806 : || rtx_equal_p (output, input)
6958 30149 : || !(REG_P (input) || SUBREG_P (input)
6959 3160 : || MEM_P (input) || CONSTANT_P (input))
6960 61131 : || !general_operand (input, GET_MODE (output)))
6961 973 : continue;
6962 :
6963 : /* We can't do anything if the output is also used as input,
6964 : as we're going to overwrite it. */
6965 81916 : for (j = 0; j < ninputs; j++)
6966 51906 : if (reg_overlap_mentioned_p (output, RTVEC_ELT (inputs, j)))
6967 : break;
6968 30010 : if (j != ninputs)
6969 0 : continue;
6970 :
6971 : /* Avoid changing the same input several times. For
6972 : asm ("" : "=mr" (out1), "=mr" (out2) : "0" (in), "1" (in));
6973 : only change it once (to out1), rather than changing it
6974 : first to out1 and afterwards to out2. */
6975 30010 : if (i > 0)
6976 : {
6977 39998 : for (j = 0; j < noutputs; j++)
6978 32665 : if (output_matched[j] && input == SET_DEST (p_sets[j]))
6979 : break;
6980 7404 : if (j != noutputs)
6981 71 : continue;
6982 : }
6983 29939 : output_matched[match] = true;
6984 :
6985 29939 : start_sequence ();
6986 29939 : emit_move_insn (output, copy_rtx (input));
6987 29939 : insns = end_sequence ();
6988 29939 : emit_insn_before (insns, insn);
6989 :
6990 29939 : constraint = ASM_OPERANDS_OUTPUT_CONSTRAINT(SET_SRC(p_sets[match]));
6991 29939 : bool early_clobber_p = strchr (constraint, '&') != NULL;
6992 :
6993 : /* Now replace all mentions of the input with output. We can't
6994 : just replace the occurrence in inputs[i], as the register might
6995 : also be used in some other input (or even in an address of an
6996 : output), which would mean possibly increasing the number of
6997 : inputs by one (namely 'output' in addition), which might pose
6998 : a too complicated problem for reload to solve. E.g. this situation:
6999 :
7000 : asm ("" : "=r" (output), "=m" (input) : "0" (input))
7001 :
7002 : Here 'input' is used in two occurrences as input (once for the
7003 : input operand, once for the address in the second output operand).
7004 : If we would replace only the occurrence of the input operand (to
7005 : make the matching) we would be left with this:
7006 :
7007 : output = input
7008 : asm ("" : "=r" (output), "=m" (input) : "0" (output))
7009 :
7010 : Now we suddenly have two different input values (containing the same
7011 : value, but different pseudos) where we formerly had only one.
7012 : With more complicated asms this might lead to reload failures
7013 : which wouldn't have happen without this pass. So, iterate over
7014 : all operands and replace all occurrences of the register used.
7015 :
7016 : However, if one or more of the 'input' uses have a non-matching
7017 : constraint and the matched output operand is an early clobber
7018 : operand, then do not replace the input operand, since by definition
7019 : it conflicts with the output operand and cannot share the same
7020 : register. See PR89313 for details. */
7021 :
7022 146957 : for (j = 0; j < noutputs; j++)
7023 117018 : if (!rtx_equal_p (SET_DEST (p_sets[j]), input)
7024 117018 : && reg_overlap_mentioned_p (input, SET_DEST (p_sets[j])))
7025 635 : SET_DEST (p_sets[j]) = replace_rtx (SET_DEST (p_sets[j]),
7026 : input, output);
7027 81557 : for (j = 0; j < ninputs; j++)
7028 51618 : if (reg_overlap_mentioned_p (input, RTVEC_ELT (inputs, j)))
7029 : {
7030 28146 : if (!early_clobber_p
7031 29075 : || match == matching_constraint_num
7032 929 : (ASM_OPERANDS_INPUT_CONSTRAINT (op, j)))
7033 28142 : RTVEC_ELT (inputs, j) = replace_rtx (RTVEC_ELT (inputs, j),
7034 : input, output);
7035 : }
7036 :
7037 : changed = true;
7038 : }
7039 :
7040 34696 : if (changed)
7041 22951 : df_insn_rescan (insn);
7042 34696 : }
7043 :
7044 : /* It is expected and desired that optimizations coalesce multiple pseudos into
7045 : one whenever possible. However, in case of hard register constraints we may
7046 : have to undo this and introduce copies since otherwise we could constraint a
7047 : single pseudo to different hard registers. For example, during register
7048 : allocation the following insn would be unsatisfiable since pseudo 60 is
7049 : constrained to hard register r5 and r6 at the same time.
7050 :
7051 : (insn 7 5 0 2 (asm_operands/v ("foo") ("") 0 [
7052 : (reg:DI 60) repeated x2
7053 : ]
7054 : [
7055 : (asm_input:DI ("{r5}") t.c:4)
7056 : (asm_input:DI ("{r6}") t.c:4)
7057 : ]
7058 : [] t.c:4) "t.c":4:3 -1
7059 : (expr_list:REG_DEAD (reg:DI 60)
7060 : (nil)))
7061 :
7062 : Therefore, introduce a copy of pseudo 60 and transform it into
7063 :
7064 : (insn 10 5 7 2 (set (reg:DI 62)
7065 : (reg:DI 60)) "t.c":4:3 1503 {*movdi_64}
7066 : (nil))
7067 : (insn 7 10 11 2 (asm_operands/v ("foo") ("") 0 [
7068 : (reg:DI 60)
7069 : (reg:DI 62)
7070 : ]
7071 : [
7072 : (asm_input:DI ("{r5}") t.c:4)
7073 : (asm_input:DI ("{r6}") t.c:4)
7074 : ]
7075 : [] t.c:4) "t.c":4:3 -1
7076 : (expr_list:REG_DEAD (reg:DI 62)
7077 : (expr_list:REG_DEAD (reg:DI 60)
7078 : (nil))))
7079 :
7080 : Now, LRA can assign pseudo 60 to r5, and pseudo 62 to r6.
7081 :
7082 : TODO: The current implementation is conservative and we could do a bit
7083 : better in case of alternatives. For example
7084 :
7085 : (insn 7 5 0 2 (asm_operands/v ("foo") ("") 0 [
7086 : (reg:DI 60) repeated x2
7087 : ]
7088 : [
7089 : (asm_input:DI ("r,{r5}") t.c:4)
7090 : (asm_input:DI ("{r6},r") t.c:4)
7091 : ]
7092 : [] t.c:4) "t.c":4:3 -1
7093 : (expr_list:REG_DEAD (reg:DI 60)
7094 : (nil)))
7095 :
7096 : For this insn we wouldn't need to come up with a copy of pseudo 60 since in
7097 : each alternative pseudo 60 is constrained exactly one time. */
7098 :
7099 : static void
7100 3579776 : match_asm_constraints_2 (rtx_insn *insn, rtx pat)
7101 : {
7102 3579776 : rtx op;
7103 3579776 : if (GET_CODE (pat) == SET && GET_CODE (SET_SRC (pat)) == ASM_OPERANDS)
7104 : op = SET_SRC (pat);
7105 3503390 : else if (GET_CODE (pat) == ASM_OPERANDS)
7106 : op = pat;
7107 : else
7108 3430907 : return;
7109 148869 : int ninputs = ASM_OPERANDS_INPUT_LENGTH (op);
7110 148869 : rtvec inputs = ASM_OPERANDS_INPUT_VEC (op);
7111 148869 : bool changed = false;
7112 148869 : auto_bitmap constrained_regs;
7113 :
7114 269329 : for (int i = 0; i < ninputs; ++i)
7115 : {
7116 120460 : rtx input = RTVEC_ELT (inputs, i);
7117 120460 : const char *constraint = ASM_OPERANDS_INPUT_CONSTRAINT (op, i);
7118 23525 : if ((!REG_P (input) && !SUBREG_P (input))
7119 97052 : || (REG_P (input) && HARD_REGISTER_P (input))
7120 216432 : || strchr (constraint, '{') == nullptr)
7121 120412 : continue;
7122 48 : int regno;
7123 48 : if (SUBREG_P (input))
7124 : {
7125 0 : if (REG_P (SUBREG_REG (input)))
7126 0 : regno = REGNO (SUBREG_REG (input));
7127 : else
7128 0 : continue;
7129 : }
7130 : else
7131 48 : regno = REGNO (input);
7132 : /* Keep the first usage of a constrained pseudo as is and only
7133 : introduce copies for subsequent usages. */
7134 48 : if (! bitmap_bit_p (constrained_regs, regno))
7135 : {
7136 48 : bitmap_set_bit (constrained_regs, regno);
7137 48 : continue;
7138 : }
7139 0 : rtx tmp = gen_reg_rtx (GET_MODE (input));
7140 0 : start_sequence ();
7141 0 : emit_move_insn (tmp, input);
7142 0 : rtx_insn *insns = get_insns ();
7143 0 : end_sequence ();
7144 0 : emit_insn_before (insns, insn);
7145 0 : RTVEC_ELT (inputs, i) = tmp;
7146 0 : changed = true;
7147 : }
7148 :
7149 148869 : if (changed)
7150 0 : df_insn_rescan (insn);
7151 148869 : }
7152 :
7153 : /* Add the decl D to the local_decls list of FUN. */
7154 :
7155 : void
7156 37918787 : add_local_decl (struct function *fun, tree d)
7157 : {
7158 37918787 : gcc_assert (VAR_P (d));
7159 37918787 : vec_safe_push (fun->local_decls, d);
7160 37918787 : }
7161 :
7162 : namespace {
7163 :
7164 : const pass_data pass_data_match_asm_constraints =
7165 : {
7166 : RTL_PASS, /* type */
7167 : "asmcons", /* name */
7168 : OPTGROUP_NONE, /* optinfo_flags */
7169 : TV_NONE, /* tv_id */
7170 : 0, /* properties_required */
7171 : 0, /* properties_provided */
7172 : 0, /* properties_destroyed */
7173 : 0, /* todo_flags_start */
7174 : 0, /* todo_flags_finish */
7175 : };
7176 :
7177 : class pass_match_asm_constraints : public rtl_opt_pass
7178 : {
7179 : public:
7180 288767 : pass_match_asm_constraints (gcc::context *ctxt)
7181 577534 : : rtl_opt_pass (pass_data_match_asm_constraints, ctxt)
7182 : {}
7183 :
7184 : /* opt_pass methods: */
7185 : unsigned int execute (function *) final override;
7186 :
7187 : }; // class pass_match_asm_constraints
7188 :
7189 : unsigned
7190 1481482 : pass_match_asm_constraints::execute (function *fun)
7191 : {
7192 1481482 : basic_block bb;
7193 1481482 : rtx_insn *insn;
7194 1481482 : rtx pat, *p_sets;
7195 1481482 : int noutputs;
7196 :
7197 1481482 : if (!crtl->has_asm_statement)
7198 : return 0;
7199 :
7200 34453 : df_set_flags (DF_DEFER_INSN_RESCAN);
7201 333141 : FOR_EACH_BB_FN (bb, fun)
7202 : {
7203 3952497 : FOR_BB_INSNS (bb, insn)
7204 : {
7205 3653809 : if (!INSN_P (insn))
7206 654618 : continue;
7207 :
7208 2999191 : pat = PATTERN (insn);
7209 :
7210 2999191 : if (GET_CODE (pat) == PARALLEL)
7211 1483297 : for (int i = XVECLEN (pat, 0) - 1; i >= 0; --i)
7212 1031941 : match_asm_constraints_2 (insn, XVECEXP (pat, 0, i));
7213 : else
7214 2547835 : match_asm_constraints_2 (insn, pat);
7215 :
7216 2999191 : if (GET_CODE (pat) == PARALLEL)
7217 451356 : p_sets = &XVECEXP (pat, 0, 0), noutputs = XVECLEN (pat, 0);
7218 2547835 : else if (GET_CODE (pat) == SET)
7219 1729739 : p_sets = &PATTERN (insn), noutputs = 1;
7220 : else
7221 818096 : continue;
7222 :
7223 2181095 : if (GET_CODE (*p_sets) == SET
7224 2104818 : && GET_CODE (SET_SRC (*p_sets)) == ASM_OPERANDS)
7225 34696 : match_asm_constraints_1 (insn, p_sets, noutputs);
7226 : }
7227 : }
7228 :
7229 : return TODO_df_finish;
7230 : }
7231 :
7232 : } // anon namespace
7233 :
7234 : rtl_opt_pass *
7235 288767 : make_pass_match_asm_constraints (gcc::context *ctxt)
7236 : {
7237 288767 : return new pass_match_asm_constraints (ctxt);
7238 : }
7239 :
7240 :
7241 : #include "gt-function.h"
|