1/* Variable tracking routines for the GNU compiler.
2 Copyright (C) 2002-2017 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
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License 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 contains the variable tracking pass. It computes where
21 variables are located (which registers or where in memory) at each position
22 in instruction stream and emits notes describing the locations.
23 Debug information (DWARF2 location lists) is finally generated from
24 these notes.
25 With this debug information, it is possible to show variables
26 even when debugging optimized code.
27
28 How does the variable tracking pass work?
29
30 First, it scans RTL code for uses, stores and clobbers (register/memory
31 references in instructions), for call insns and for stack adjustments
32 separately for each basic block and saves them to an array of micro
33 operations.
34 The micro operations of one instruction are ordered so that
35 pre-modifying stack adjustment < use < use with no var < call insn <
36 < clobber < set < post-modifying stack adjustment
37
38 Then, a forward dataflow analysis is performed to find out how locations
39 of variables change through code and to propagate the variable locations
40 along control flow graph.
41 The IN set for basic block BB is computed as a union of OUT sets of BB's
42 predecessors, the OUT set for BB is copied from the IN set for BB and
43 is changed according to micro operations in BB.
44
45 The IN and OUT sets for basic blocks consist of a current stack adjustment
46 (used for adjusting offset of variables addressed using stack pointer),
47 the table of structures describing the locations of parts of a variable
48 and for each physical register a linked list for each physical register.
49 The linked list is a list of variable parts stored in the register,
50 i.e. it is a list of triplets (reg, decl, offset) where decl is
51 REG_EXPR (reg) and offset is REG_OFFSET (reg). The linked list is used for
52 effective deleting appropriate variable parts when we set or clobber the
53 register.
54
55 There may be more than one variable part in a register. The linked lists
56 should be pretty short so it is a good data structure here.
57 For example in the following code, register allocator may assign same
58 register to variables A and B, and both of them are stored in the same
59 register in CODE:
60
61 if (cond)
62 set A;
63 else
64 set B;
65 CODE;
66 if (cond)
67 use A;
68 else
69 use B;
70
71 Finally, the NOTE_INSN_VAR_LOCATION notes describing the variable locations
72 are emitted to appropriate positions in RTL code. Each such a note describes
73 the location of one variable at the point in instruction stream where the
74 note is. There is no need to emit a note for each variable before each
75 instruction, we only emit these notes where the location of variable changes
76 (this means that we also emit notes for changes between the OUT set of the
77 previous block and the IN set of the current block).
78
79 The notes consist of two parts:
80 1. the declaration (from REG_EXPR or MEM_EXPR)
81 2. the location of a variable - it is either a simple register/memory
82 reference (for simple variables, for example int),
83 or a parallel of register/memory references (for a large variables
84 which consist of several parts, for example long long).
85
86*/
87
88#include "config.h"
89#include "system.h"
90#include "coretypes.h"
91#include "backend.h"
92#include "target.h"
93#include "rtl.h"
94#include "tree.h"
95#include "cfghooks.h"
96#include "alloc-pool.h"
97#include "tree-pass.h"
98#include "memmodel.h"
99#include "tm_p.h"
100#include "insn-config.h"
101#include "regs.h"
102#include "emit-rtl.h"
103#include "recog.h"
104#include "diagnostic.h"
105#include "varasm.h"
106#include "stor-layout.h"
107#include "cfgrtl.h"
108#include "cfganal.h"
109#include "reload.h"
110#include "calls.h"
111#include "tree-dfa.h"
112#include "tree-ssa.h"
113#include "cselib.h"
114#include "params.h"
115#include "tree-pretty-print.h"
116#include "rtl-iter.h"
117#include "fibonacci_heap.h"
118
119typedef fibonacci_heap <long, basic_block_def> bb_heap_t;
120typedef fibonacci_node <long, basic_block_def> bb_heap_node_t;
121
122/* var-tracking.c assumes that tree code with the same value as VALUE rtx code
123 has no chance to appear in REG_EXPR/MEM_EXPRs and isn't a decl.
124 Currently the value is the same as IDENTIFIER_NODE, which has such
125 a property. If this compile time assertion ever fails, make sure that
126 the new tree code that equals (int) VALUE has the same property. */
127extern char check_value_val[(int) VALUE == (int) IDENTIFIER_NODE ? 1 : -1];
128
129/* Type of micro operation. */
130enum micro_operation_type
131{
132 MO_USE, /* Use location (REG or MEM). */
133 MO_USE_NO_VAR,/* Use location which is not associated with a variable
134 or the variable is not trackable. */
135 MO_VAL_USE, /* Use location which is associated with a value. */
136 MO_VAL_LOC, /* Use location which appears in a debug insn. */
137 MO_VAL_SET, /* Set location associated with a value. */
138 MO_SET, /* Set location. */
139 MO_COPY, /* Copy the same portion of a variable from one
140 location to another. */
141 MO_CLOBBER, /* Clobber location. */
142 MO_CALL, /* Call insn. */
143 MO_ADJUST /* Adjust stack pointer. */
144
145};
146
147static const char * const ATTRIBUTE_UNUSED
148micro_operation_type_name[] = {
149 "MO_USE",
150 "MO_USE_NO_VAR",
151 "MO_VAL_USE",
152 "MO_VAL_LOC",
153 "MO_VAL_SET",
154 "MO_SET",
155 "MO_COPY",
156 "MO_CLOBBER",
157 "MO_CALL",
158 "MO_ADJUST"
159};
160
161/* Where shall the note be emitted? BEFORE or AFTER the instruction.
162 Notes emitted as AFTER_CALL are to take effect during the call,
163 rather than after the call. */
164enum emit_note_where
165{
166 EMIT_NOTE_BEFORE_INSN,
167 EMIT_NOTE_AFTER_INSN,
168 EMIT_NOTE_AFTER_CALL_INSN
169};
170
171/* Structure holding information about micro operation. */
172struct micro_operation
173{
174 /* Type of micro operation. */
175 enum micro_operation_type type;
176
177 /* The instruction which the micro operation is in, for MO_USE,
178 MO_USE_NO_VAR, MO_CALL and MO_ADJUST, or the subsequent
179 instruction or note in the original flow (before any var-tracking
180 notes are inserted, to simplify emission of notes), for MO_SET
181 and MO_CLOBBER. */
182 rtx_insn *insn;
183
184 union {
185 /* Location. For MO_SET and MO_COPY, this is the SET that
186 performs the assignment, if known, otherwise it is the target
187 of the assignment. For MO_VAL_USE and MO_VAL_SET, it is a
188 CONCAT of the VALUE and the LOC associated with it. For
189 MO_VAL_LOC, it is a CONCAT of the VALUE and the VAR_LOCATION
190 associated with it. */
191 rtx loc;
192
193 /* Stack adjustment. */
194 HOST_WIDE_INT adjust;
195 } u;
196};
197
198
199/* A declaration of a variable, or an RTL value being handled like a
200 declaration. */
201typedef void *decl_or_value;
202
203/* Return true if a decl_or_value DV is a DECL or NULL. */
204static inline bool
205dv_is_decl_p (decl_or_value dv)
206{
207 return !dv || (int) TREE_CODE ((tree) dv) != (int) VALUE;
208}
209
210/* Return true if a decl_or_value is a VALUE rtl. */
211static inline bool
212dv_is_value_p (decl_or_value dv)
213{
214 return dv && !dv_is_decl_p (dv);
215}
216
217/* Return the decl in the decl_or_value. */
218static inline tree
219dv_as_decl (decl_or_value dv)
220{
221 gcc_checking_assert (dv_is_decl_p (dv));
222 return (tree) dv;
223}
224
225/* Return the value in the decl_or_value. */
226static inline rtx
227dv_as_value (decl_or_value dv)
228{
229 gcc_checking_assert (dv_is_value_p (dv));
230 return (rtx)dv;
231}
232
233/* Return the opaque pointer in the decl_or_value. */
234static inline void *
235dv_as_opaque (decl_or_value dv)
236{
237 return dv;
238}
239
240
241/* Description of location of a part of a variable. The content of a physical
242 register is described by a chain of these structures.
243 The chains are pretty short (usually 1 or 2 elements) and thus
244 chain is the best data structure. */
245struct attrs
246{
247 /* Pointer to next member of the list. */
248 attrs *next;
249
250 /* The rtx of register. */
251 rtx loc;
252
253 /* The declaration corresponding to LOC. */
254 decl_or_value dv;
255
256 /* Offset from start of DECL. */
257 HOST_WIDE_INT offset;
258};
259
260/* Structure for chaining the locations. */
261struct location_chain
262{
263 /* Next element in the chain. */
264 location_chain *next;
265
266 /* The location (REG, MEM or VALUE). */
267 rtx loc;
268
269 /* The "value" stored in this location. */
270 rtx set_src;
271
272 /* Initialized? */
273 enum var_init_status init;
274};
275
276/* A vector of loc_exp_dep holds the active dependencies of a one-part
277 DV on VALUEs, i.e., the VALUEs expanded so as to form the current
278 location of DV. Each entry is also part of VALUE' s linked-list of
279 backlinks back to DV. */
280struct loc_exp_dep
281{
282 /* The dependent DV. */
283 decl_or_value dv;
284 /* The dependency VALUE or DECL_DEBUG. */
285 rtx value;
286 /* The next entry in VALUE's backlinks list. */
287 struct loc_exp_dep *next;
288 /* A pointer to the pointer to this entry (head or prev's next) in
289 the doubly-linked list. */
290 struct loc_exp_dep **pprev;
291};
292
293
294/* This data structure holds information about the depth of a variable
295 expansion. */
296struct expand_depth
297{
298 /* This measures the complexity of the expanded expression. It
299 grows by one for each level of expansion that adds more than one
300 operand. */
301 int complexity;
302 /* This counts the number of ENTRY_VALUE expressions in an
303 expansion. We want to minimize their use. */
304 int entryvals;
305};
306
307/* This data structure is allocated for one-part variables at the time
308 of emitting notes. */
309struct onepart_aux
310{
311 /* Doubly-linked list of dependent DVs. These are DVs whose cur_loc
312 computation used the expansion of this variable, and that ought
313 to be notified should this variable change. If the DV's cur_loc
314 expanded to NULL, all components of the loc list are regarded as
315 active, so that any changes in them give us a chance to get a
316 location. Otherwise, only components of the loc that expanded to
317 non-NULL are regarded as active dependencies. */
318 loc_exp_dep *backlinks;
319 /* This holds the LOC that was expanded into cur_loc. We need only
320 mark a one-part variable as changed if the FROM loc is removed,
321 or if it has no known location and a loc is added, or if it gets
322 a change notification from any of its active dependencies. */
323 rtx from;
324 /* The depth of the cur_loc expression. */
325 expand_depth depth;
326 /* Dependencies actively used when expand FROM into cur_loc. */
327 vec<loc_exp_dep, va_heap, vl_embed> deps;
328};
329
330/* Structure describing one part of variable. */
331struct variable_part
332{
333 /* Chain of locations of the part. */
334 location_chain *loc_chain;
335
336 /* Location which was last emitted to location list. */
337 rtx cur_loc;
338
339 union variable_aux
340 {
341 /* The offset in the variable, if !var->onepart. */
342 HOST_WIDE_INT offset;
343
344 /* Pointer to auxiliary data, if var->onepart and emit_notes. */
345 struct onepart_aux *onepaux;
346 } aux;
347};
348
349/* Maximum number of location parts. */
350#define MAX_VAR_PARTS 16
351
352/* Enumeration type used to discriminate various types of one-part
353 variables. */
354enum onepart_enum
355{
356 /* Not a one-part variable. */
357 NOT_ONEPART = 0,
358 /* A one-part DECL that is not a DEBUG_EXPR_DECL. */
359 ONEPART_VDECL = 1,
360 /* A DEBUG_EXPR_DECL. */
361 ONEPART_DEXPR = 2,
362 /* A VALUE. */
363 ONEPART_VALUE = 3
364};
365
366/* Structure describing where the variable is located. */
367struct variable
368{
369 /* The declaration of the variable, or an RTL value being handled
370 like a declaration. */
371 decl_or_value dv;
372
373 /* Reference count. */
374 int refcount;
375
376 /* Number of variable parts. */
377 char n_var_parts;
378
379 /* What type of DV this is, according to enum onepart_enum. */
380 ENUM_BITFIELD (onepart_enum) onepart : CHAR_BIT;
381
382 /* True if this variable_def struct is currently in the
383 changed_variables hash table. */
384 bool in_changed_variables;
385
386 /* The variable parts. */
387 variable_part var_part[1];
388};
389
390/* Pointer to the BB's information specific to variable tracking pass. */
391#define VTI(BB) ((variable_tracking_info *) (BB)->aux)
392
393/* Return MEM_OFFSET (MEM) as a HOST_WIDE_INT, or 0 if we can't. */
394
395static inline HOST_WIDE_INT
396int_mem_offset (const_rtx mem)
397{
398 if (MEM_OFFSET_KNOWN_P (mem))
399 return MEM_OFFSET (mem);
400 return 0;
401}
402
403#if CHECKING_P && (GCC_VERSION >= 2007)
404
405/* Access VAR's Ith part's offset, checking that it's not a one-part
406 variable. */
407#define VAR_PART_OFFSET(var, i) __extension__ \
408(*({ variable *const __v = (var); \
409 gcc_checking_assert (!__v->onepart); \
410 &__v->var_part[(i)].aux.offset; }))
411
412/* Access VAR's one-part auxiliary data, checking that it is a
413 one-part variable. */
414#define VAR_LOC_1PAUX(var) __extension__ \
415(*({ variable *const __v = (var); \
416 gcc_checking_assert (__v->onepart); \
417 &__v->var_part[0].aux.onepaux; }))
418
419#else
420#define VAR_PART_OFFSET(var, i) ((var)->var_part[(i)].aux.offset)
421#define VAR_LOC_1PAUX(var) ((var)->var_part[0].aux.onepaux)
422#endif
423
424/* These are accessor macros for the one-part auxiliary data. When
425 convenient for users, they're guarded by tests that the data was
426 allocated. */
427#define VAR_LOC_DEP_LST(var) (VAR_LOC_1PAUX (var) \
428 ? VAR_LOC_1PAUX (var)->backlinks \
429 : NULL)
430#define VAR_LOC_DEP_LSTP(var) (VAR_LOC_1PAUX (var) \
431 ? &VAR_LOC_1PAUX (var)->backlinks \
432 : NULL)
433#define VAR_LOC_FROM(var) (VAR_LOC_1PAUX (var)->from)
434#define VAR_LOC_DEPTH(var) (VAR_LOC_1PAUX (var)->depth)
435#define VAR_LOC_DEP_VEC(var) (VAR_LOC_1PAUX (var) \
436 ? &VAR_LOC_1PAUX (var)->deps \
437 : NULL)
438
439
440
441typedef unsigned int dvuid;
442
443/* Return the uid of DV. */
444
445static inline dvuid
446dv_uid (decl_or_value dv)
447{
448 if (dv_is_value_p (dv))
449 return CSELIB_VAL_PTR (dv_as_value (dv))->uid;
450 else
451 return DECL_UID (dv_as_decl (dv));
452}
453
454/* Compute the hash from the uid. */
455
456static inline hashval_t
457dv_uid2hash (dvuid uid)
458{
459 return uid;
460}
461
462/* The hash function for a mask table in a shared_htab chain. */
463
464static inline hashval_t
465dv_htab_hash (decl_or_value dv)
466{
467 return dv_uid2hash (dv_uid (dv));
468}
469
470static void variable_htab_free (void *);
471
472/* Variable hashtable helpers. */
473
474struct variable_hasher : pointer_hash <variable>
475{
476 typedef void *compare_type;
477 static inline hashval_t hash (const variable *);
478 static inline bool equal (const variable *, const void *);
479 static inline void remove (variable *);
480};
481
482/* The hash function for variable_htab, computes the hash value
483 from the declaration of variable X. */
484
485inline hashval_t
486variable_hasher::hash (const variable *v)
487{
488 return dv_htab_hash (v->dv);
489}
490
491/* Compare the declaration of variable X with declaration Y. */
492
493inline bool
494variable_hasher::equal (const variable *v, const void *y)
495{
496 decl_or_value dv = CONST_CAST2 (decl_or_value, const void *, y);
497
498 return (dv_as_opaque (v->dv) == dv_as_opaque (dv));
499}
500
501/* Free the element of VARIABLE_HTAB (its type is struct variable_def). */
502
503inline void
504variable_hasher::remove (variable *var)
505{
506 variable_htab_free (var);
507}
508
509typedef hash_table<variable_hasher> variable_table_type;
510typedef variable_table_type::iterator variable_iterator_type;
511
512/* Structure for passing some other parameters to function
513 emit_note_insn_var_location. */
514struct emit_note_data
515{
516 /* The instruction which the note will be emitted before/after. */
517 rtx_insn *insn;
518
519 /* Where the note will be emitted (before/after insn)? */
520 enum emit_note_where where;
521
522 /* The variables and values active at this point. */
523 variable_table_type *vars;
524};
525
526/* Structure holding a refcounted hash table. If refcount > 1,
527 it must be first unshared before modified. */
528struct shared_hash
529{
530 /* Reference count. */
531 int refcount;
532
533 /* Actual hash table. */
534 variable_table_type *htab;
535};
536
537/* Structure holding the IN or OUT set for a basic block. */
538struct dataflow_set
539{
540 /* Adjustment of stack offset. */
541 HOST_WIDE_INT stack_adjust;
542
543 /* Attributes for registers (lists of attrs). */
544 attrs *regs[FIRST_PSEUDO_REGISTER];
545
546 /* Variable locations. */
547 shared_hash *vars;
548
549 /* Vars that is being traversed. */
550 shared_hash *traversed_vars;
551};
552
553/* The structure (one for each basic block) containing the information
554 needed for variable tracking. */
555struct variable_tracking_info
556{
557 /* The vector of micro operations. */
558 vec<micro_operation> mos;
559
560 /* The IN and OUT set for dataflow analysis. */
561 dataflow_set in;
562 dataflow_set out;
563
564 /* The permanent-in dataflow set for this block. This is used to
565 hold values for which we had to compute entry values. ??? This
566 should probably be dynamically allocated, to avoid using more
567 memory in non-debug builds. */
568 dataflow_set *permp;
569
570 /* Has the block been visited in DFS? */
571 bool visited;
572
573 /* Has the block been flooded in VTA? */
574 bool flooded;
575
576};
577
578/* Alloc pool for struct attrs_def. */
579object_allocator<attrs> attrs_pool ("attrs pool");
580
581/* Alloc pool for struct variable_def with MAX_VAR_PARTS entries. */
582
583static pool_allocator var_pool
584 ("variable_def pool", sizeof (variable) +
585 (MAX_VAR_PARTS - 1) * sizeof (((variable *)NULL)->var_part[0]));
586
587/* Alloc pool for struct variable_def with a single var_part entry. */
588static pool_allocator valvar_pool
589 ("small variable_def pool", sizeof (variable));
590
591/* Alloc pool for struct location_chain. */
592static object_allocator<location_chain> location_chain_pool
593 ("location_chain pool");
594
595/* Alloc pool for struct shared_hash. */
596static object_allocator<shared_hash> shared_hash_pool ("shared_hash pool");
597
598/* Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables. */
599object_allocator<loc_exp_dep> loc_exp_dep_pool ("loc_exp_dep pool");
600
601/* Changed variables, notes will be emitted for them. */
602static variable_table_type *changed_variables;
603
604/* Shall notes be emitted? */
605static bool emit_notes;
606
607/* Values whose dynamic location lists have gone empty, but whose
608 cselib location lists are still usable. Use this to hold the
609 current location, the backlinks, etc, during emit_notes. */
610static variable_table_type *dropped_values;
611
612/* Empty shared hashtable. */
613static shared_hash *empty_shared_hash;
614
615/* Scratch register bitmap used by cselib_expand_value_rtx. */
616static bitmap scratch_regs = NULL;
617
618#ifdef HAVE_window_save
619struct GTY(()) parm_reg {
620 rtx outgoing;
621 rtx incoming;
622};
623
624
625/* Vector of windowed parameter registers, if any. */
626static vec<parm_reg, va_gc> *windowed_parm_regs = NULL;
627#endif
628
629/* Variable used to tell whether cselib_process_insn called our hook. */
630static bool cselib_hook_called;
631
632/* Local function prototypes. */
633static void stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
634 HOST_WIDE_INT *);
635static void insn_stack_adjust_offset_pre_post (rtx_insn *, HOST_WIDE_INT *,
636 HOST_WIDE_INT *);
637static bool vt_stack_adjustments (void);
638
639static void init_attrs_list_set (attrs **);
640static void attrs_list_clear (attrs **);
641static attrs *attrs_list_member (attrs *, decl_or_value, HOST_WIDE_INT);
642static void attrs_list_insert (attrs **, decl_or_value, HOST_WIDE_INT, rtx);
643static void attrs_list_copy (attrs **, attrs *);
644static void attrs_list_union (attrs **, attrs *);
645
646static variable **unshare_variable (dataflow_set *set, variable **slot,
647 variable *var, enum var_init_status);
648static void vars_copy (variable_table_type *, variable_table_type *);
649static tree var_debug_decl (tree);
650static void var_reg_set (dataflow_set *, rtx, enum var_init_status, rtx);
651static void var_reg_delete_and_set (dataflow_set *, rtx, bool,
652 enum var_init_status, rtx);
653static void var_reg_delete (dataflow_set *, rtx, bool);
654static void var_regno_delete (dataflow_set *, int);
655static void var_mem_set (dataflow_set *, rtx, enum var_init_status, rtx);
656static void var_mem_delete_and_set (dataflow_set *, rtx, bool,
657 enum var_init_status, rtx);
658static void var_mem_delete (dataflow_set *, rtx, bool);
659
660static void dataflow_set_init (dataflow_set *);
661static void dataflow_set_clear (dataflow_set *);
662static void dataflow_set_copy (dataflow_set *, dataflow_set *);
663static int variable_union_info_cmp_pos (const void *, const void *);
664static void dataflow_set_union (dataflow_set *, dataflow_set *);
665static location_chain *find_loc_in_1pdv (rtx, variable *,
666 variable_table_type *);
667static bool canon_value_cmp (rtx, rtx);
668static int loc_cmp (rtx, rtx);
669static bool variable_part_different_p (variable_part *, variable_part *);
670static bool onepart_variable_different_p (variable *, variable *);
671static bool variable_different_p (variable *, variable *);
672static bool dataflow_set_different (dataflow_set *, dataflow_set *);
673static void dataflow_set_destroy (dataflow_set *);
674
675static bool track_expr_p (tree, bool);
676static bool same_variable_part_p (rtx, tree, HOST_WIDE_INT);
677static void add_uses_1 (rtx *, void *);
678static void add_stores (rtx, const_rtx, void *);
679static bool compute_bb_dataflow (basic_block);
680static bool vt_find_locations (void);
681
682static void dump_attrs_list (attrs *);
683static void dump_var (variable *);
684static void dump_vars (variable_table_type *);
685static void dump_dataflow_set (dataflow_set *);
686static void dump_dataflow_sets (void);
687
688static void set_dv_changed (decl_or_value, bool);
689static void variable_was_changed (variable *, dataflow_set *);
690static variable **set_slot_part (dataflow_set *, rtx, variable **,
691 decl_or_value, HOST_WIDE_INT,
692 enum var_init_status, rtx);
693static void set_variable_part (dataflow_set *, rtx,
694 decl_or_value, HOST_WIDE_INT,
695 enum var_init_status, rtx, enum insert_option);
696static variable **clobber_slot_part (dataflow_set *, rtx,
697 variable **, HOST_WIDE_INT, rtx);
698static void clobber_variable_part (dataflow_set *, rtx,
699 decl_or_value, HOST_WIDE_INT, rtx);
700static variable **delete_slot_part (dataflow_set *, rtx, variable **,
701 HOST_WIDE_INT);
702static void delete_variable_part (dataflow_set *, rtx,
703 decl_or_value, HOST_WIDE_INT);
704static void emit_notes_in_bb (basic_block, dataflow_set *);
705static void vt_emit_notes (void);
706
707static bool vt_get_decl_and_offset (rtx, tree *, HOST_WIDE_INT *);
708static void vt_add_function_parameters (void);
709static bool vt_initialize (void);
710static void vt_finalize (void);
711
712/* Callback for stack_adjust_offset_pre_post, called via for_each_inc_dec. */
713
714static int
715stack_adjust_offset_pre_post_cb (rtx, rtx op, rtx dest, rtx src, rtx srcoff,
716 void *arg)
717{
718 if (dest != stack_pointer_rtx)
719 return 0;
720
721 switch (GET_CODE (op))
722 {
723 case PRE_INC:
724 case PRE_DEC:
725 ((HOST_WIDE_INT *)arg)[0] -= INTVAL (srcoff);
726 return 0;
727 case POST_INC:
728 case POST_DEC:
729 ((HOST_WIDE_INT *)arg)[1] -= INTVAL (srcoff);
730 return 0;
731 case PRE_MODIFY:
732 case POST_MODIFY:
733 /* We handle only adjustments by constant amount. */
734 gcc_assert (GET_CODE (src) == PLUS
735 && CONST_INT_P (XEXP (src, 1))
736 && XEXP (src, 0) == stack_pointer_rtx);
737 ((HOST_WIDE_INT *)arg)[GET_CODE (op) == POST_MODIFY]
738 -= INTVAL (XEXP (src, 1));
739 return 0;
740 default:
741 gcc_unreachable ();
742 }
743}
744
745/* Given a SET, calculate the amount of stack adjustment it contains
746 PRE- and POST-modifying stack pointer.
747 This function is similar to stack_adjust_offset. */
748
749static void
750stack_adjust_offset_pre_post (rtx pattern, HOST_WIDE_INT *pre,
751 HOST_WIDE_INT *post)
752{
753 rtx src = SET_SRC (pattern);
754 rtx dest = SET_DEST (pattern);
755 enum rtx_code code;
756
757 if (dest == stack_pointer_rtx)
758 {
759 /* (set (reg sp) (plus (reg sp) (const_int))) */
760 code = GET_CODE (src);
761 if (! (code == PLUS || code == MINUS)
762 || XEXP (src, 0) != stack_pointer_rtx
763 || !CONST_INT_P (XEXP (src, 1)))
764 return;
765
766 if (code == MINUS)
767 *post += INTVAL (XEXP (src, 1));
768 else
769 *post -= INTVAL (XEXP (src, 1));
770 return;
771 }
772 HOST_WIDE_INT res[2] = { 0, 0 };
773 for_each_inc_dec (pattern, stack_adjust_offset_pre_post_cb, res);
774 *pre += res[0];
775 *post += res[1];
776}
777
778/* Given an INSN, calculate the amount of stack adjustment it contains
779 PRE- and POST-modifying stack pointer. */
780
781static void
782insn_stack_adjust_offset_pre_post (rtx_insn *insn, HOST_WIDE_INT *pre,
783 HOST_WIDE_INT *post)
784{
785 rtx pattern;
786
787 *pre = 0;
788 *post = 0;
789
790 pattern = PATTERN (insn);
791 if (RTX_FRAME_RELATED_P (insn))
792 {
793 rtx expr = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
794 if (expr)
795 pattern = XEXP (expr, 0);
796 }
797
798 if (GET_CODE (pattern) == SET)
799 stack_adjust_offset_pre_post (pattern, pre, post);
800 else if (GET_CODE (pattern) == PARALLEL
801 || GET_CODE (pattern) == SEQUENCE)
802 {
803 int i;
804
805 /* There may be stack adjustments inside compound insns. Search
806 for them. */
807 for ( i = XVECLEN (pattern, 0) - 1; i >= 0; i--)
808 if (GET_CODE (XVECEXP (pattern, 0, i)) == SET)
809 stack_adjust_offset_pre_post (XVECEXP (pattern, 0, i), pre, post);
810 }
811}
812
813/* Compute stack adjustments for all blocks by traversing DFS tree.
814 Return true when the adjustments on all incoming edges are consistent.
815 Heavily borrowed from pre_and_rev_post_order_compute. */
816
817static bool
818vt_stack_adjustments (void)
819{
820 edge_iterator *stack;
821 int sp;
822
823 /* Initialize entry block. */
824 VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->visited = true;
825 VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->in.stack_adjust
826 = INCOMING_FRAME_SP_OFFSET;
827 VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->out.stack_adjust
828 = INCOMING_FRAME_SP_OFFSET;
829
830 /* Allocate stack for back-tracking up CFG. */
831 stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1);
832 sp = 0;
833
834 /* Push the first edge on to the stack. */
835 stack[sp++] = ei_start (ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs);
836
837 while (sp)
838 {
839 edge_iterator ei;
840 basic_block src;
841 basic_block dest;
842
843 /* Look at the edge on the top of the stack. */
844 ei = stack[sp - 1];
845 src = ei_edge (ei)->src;
846 dest = ei_edge (ei)->dest;
847
848 /* Check if the edge destination has been visited yet. */
849 if (!VTI (dest)->visited)
850 {
851 rtx_insn *insn;
852 HOST_WIDE_INT pre, post, offset;
853 VTI (dest)->visited = true;
854 VTI (dest)->in.stack_adjust = offset = VTI (src)->out.stack_adjust;
855
856 if (dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
857 for (insn = BB_HEAD (dest);
858 insn != NEXT_INSN (BB_END (dest));
859 insn = NEXT_INSN (insn))
860 if (INSN_P (insn))
861 {
862 insn_stack_adjust_offset_pre_post (insn, &pre, &post);
863 offset += pre + post;
864 }
865
866 VTI (dest)->out.stack_adjust = offset;
867
868 if (EDGE_COUNT (dest->succs) > 0)
869 /* Since the DEST node has been visited for the first
870 time, check its successors. */
871 stack[sp++] = ei_start (dest->succs);
872 }
873 else
874 {
875 /* We can end up with different stack adjustments for the exit block
876 of a shrink-wrapped function if stack_adjust_offset_pre_post
877 doesn't understand the rtx pattern used to restore the stack
878 pointer in the epilogue. For example, on s390(x), the stack
879 pointer is often restored via a load-multiple instruction
880 and so no stack_adjust offset is recorded for it. This means
881 that the stack offset at the end of the epilogue block is the
882 same as the offset before the epilogue, whereas other paths
883 to the exit block will have the correct stack_adjust.
884
885 It is safe to ignore these differences because (a) we never
886 use the stack_adjust for the exit block in this pass and
887 (b) dwarf2cfi checks whether the CFA notes in a shrink-wrapped
888 function are correct.
889
890 We must check whether the adjustments on other edges are
891 the same though. */
892 if (dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
893 && VTI (dest)->in.stack_adjust != VTI (src)->out.stack_adjust)
894 {
895 free (stack);
896 return false;
897 }
898
899 if (! ei_one_before_end_p (ei))
900 /* Go to the next edge. */
901 ei_next (&stack[sp - 1]);
902 else
903 /* Return to previous level if there are no more edges. */
904 sp--;
905 }
906 }
907
908 free (stack);
909 return true;
910}
911
912/* arg_pointer_rtx resp. frame_pointer_rtx if stack_pointer_rtx or
913 hard_frame_pointer_rtx is being mapped to it and offset for it. */
914static rtx cfa_base_rtx;
915static HOST_WIDE_INT cfa_base_offset;
916
917/* Compute a CFA-based value for an ADJUSTMENT made to stack_pointer_rtx
918 or hard_frame_pointer_rtx. */
919
920static inline rtx
921compute_cfa_pointer (HOST_WIDE_INT adjustment)
922{
923 return plus_constant (Pmode, cfa_base_rtx, adjustment + cfa_base_offset);
924}
925
926/* Adjustment for hard_frame_pointer_rtx to cfa base reg,
927 or -1 if the replacement shouldn't be done. */
928static HOST_WIDE_INT hard_frame_pointer_adjustment = -1;
929
930/* Data for adjust_mems callback. */
931
932struct adjust_mem_data
933{
934 bool store;
935 machine_mode mem_mode;
936 HOST_WIDE_INT stack_adjust;
937 auto_vec<rtx> side_effects;
938};
939
940/* Helper for adjust_mems. Return true if X is suitable for
941 transformation of wider mode arithmetics to narrower mode. */
942
943static bool
944use_narrower_mode_test (rtx x, const_rtx subreg)
945{
946 subrtx_var_iterator::array_type array;
947 FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
948 {
949 rtx x = *iter;
950 if (CONSTANT_P (x))
951 iter.skip_subrtxes ();
952 else
953 switch (GET_CODE (x))
954 {
955 case REG:
956 if (cselib_lookup (x, GET_MODE (SUBREG_REG (subreg)), 0, VOIDmode))
957 return false;
958 if (!validate_subreg (GET_MODE (subreg), GET_MODE (x), x,
959 subreg_lowpart_offset (GET_MODE (subreg),
960 GET_MODE (x))))
961 return false;
962 break;
963 case PLUS:
964 case MINUS:
965 case MULT:
966 break;
967 case ASHIFT:
968 iter.substitute (XEXP (x, 0));
969 break;
970 default:
971 return false;
972 }
973 }
974 return true;
975}
976
977/* Transform X into narrower mode MODE from wider mode WMODE. */
978
979static rtx
980use_narrower_mode (rtx x, scalar_int_mode mode, scalar_int_mode wmode)
981{
982 rtx op0, op1;
983 if (CONSTANT_P (x))
984 return lowpart_subreg (mode, x, wmode);
985 switch (GET_CODE (x))
986 {
987 case REG:
988 return lowpart_subreg (mode, x, wmode);
989 case PLUS:
990 case MINUS:
991 case MULT:
992 op0 = use_narrower_mode (XEXP (x, 0), mode, wmode);
993 op1 = use_narrower_mode (XEXP (x, 1), mode, wmode);
994 return simplify_gen_binary (GET_CODE (x), mode, op0, op1);
995 case ASHIFT:
996 op0 = use_narrower_mode (XEXP (x, 0), mode, wmode);
997 op1 = XEXP (x, 1);
998 /* Ensure shift amount is not wider than mode. */
999 if (GET_MODE (op1) == VOIDmode)
1000 op1 = lowpart_subreg (mode, op1, wmode);
1001 else if (GET_MODE_PRECISION (mode)
1002 < GET_MODE_PRECISION (as_a <scalar_int_mode> (GET_MODE (op1))))
1003 op1 = lowpart_subreg (mode, op1, GET_MODE (op1));
1004 return simplify_gen_binary (ASHIFT, mode, op0, op1);
1005 default:
1006 gcc_unreachable ();
1007 }
1008}
1009
1010/* Helper function for adjusting used MEMs. */
1011
1012static rtx
1013adjust_mems (rtx loc, const_rtx old_rtx, void *data)
1014{
1015 struct adjust_mem_data *amd = (struct adjust_mem_data *) data;
1016 rtx mem, addr = loc, tem;
1017 machine_mode mem_mode_save;
1018 bool store_save;
1019 scalar_int_mode tem_mode, tem_subreg_mode;
1020 switch (GET_CODE (loc))
1021 {
1022 case REG:
1023 /* Don't do any sp or fp replacements outside of MEM addresses
1024 on the LHS. */
1025 if (amd->mem_mode == VOIDmode && amd->store)
1026 return loc;
1027 if (loc == stack_pointer_rtx
1028 && !frame_pointer_needed
1029 && cfa_base_rtx)
1030 return compute_cfa_pointer (amd->stack_adjust);
1031 else if (loc == hard_frame_pointer_rtx
1032 && frame_pointer_needed
1033 && hard_frame_pointer_adjustment != -1
1034 && cfa_base_rtx)
1035 return compute_cfa_pointer (hard_frame_pointer_adjustment);
1036 gcc_checking_assert (loc != virtual_incoming_args_rtx);
1037 return loc;
1038 case MEM:
1039 mem = loc;
1040 if (!amd->store)
1041 {
1042 mem = targetm.delegitimize_address (mem);
1043 if (mem != loc && !MEM_P (mem))
1044 return simplify_replace_fn_rtx (mem, old_rtx, adjust_mems, data);
1045 }
1046
1047 addr = XEXP (mem, 0);
1048 mem_mode_save = amd->mem_mode;
1049 amd->mem_mode = GET_MODE (mem);
1050 store_save = amd->store;
1051 amd->store = false;
1052 addr = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
1053 amd->store = store_save;
1054 amd->mem_mode = mem_mode_save;
1055 if (mem == loc)
1056 addr = targetm.delegitimize_address (addr);
1057 if (addr != XEXP (mem, 0))
1058 mem = replace_equiv_address_nv (mem, addr);
1059 if (!amd->store)
1060 mem = avoid_constant_pool_reference (mem);
1061 return mem;
1062 case PRE_INC:
1063 case PRE_DEC:
1064 addr = gen_rtx_PLUS (GET_MODE (loc), XEXP (loc, 0),
1065 gen_int_mode (GET_CODE (loc) == PRE_INC
1066 ? GET_MODE_SIZE (amd->mem_mode)
1067 : -GET_MODE_SIZE (amd->mem_mode),
1068 GET_MODE (loc)));
1069 /* FALLTHRU */
1070 case POST_INC:
1071 case POST_DEC:
1072 if (addr == loc)
1073 addr = XEXP (loc, 0);
1074 gcc_assert (amd->mem_mode != VOIDmode && amd->mem_mode != BLKmode);
1075 addr = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
1076 tem = gen_rtx_PLUS (GET_MODE (loc), XEXP (loc, 0),
1077 gen_int_mode ((GET_CODE (loc) == PRE_INC
1078 || GET_CODE (loc) == POST_INC)
1079 ? GET_MODE_SIZE (amd->mem_mode)
1080 : -GET_MODE_SIZE (amd->mem_mode),
1081 GET_MODE (loc)));
1082 store_save = amd->store;
1083 amd->store = false;
1084 tem = simplify_replace_fn_rtx (tem, old_rtx, adjust_mems, data);
1085 amd->store = store_save;
1086 amd->side_effects.safe_push (gen_rtx_SET (XEXP (loc, 0), tem));
1087 return addr;
1088 case PRE_MODIFY:
1089 addr = XEXP (loc, 1);
1090 /* FALLTHRU */
1091 case POST_MODIFY:
1092 if (addr == loc)
1093 addr = XEXP (loc, 0);
1094 gcc_assert (amd->mem_mode != VOIDmode);
1095 addr = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
1096 store_save = amd->store;
1097 amd->store = false;
1098 tem = simplify_replace_fn_rtx (XEXP (loc, 1), old_rtx,
1099 adjust_mems, data);
1100 amd->store = store_save;
1101 amd->side_effects.safe_push (gen_rtx_SET (XEXP (loc, 0), tem));
1102 return addr;
1103 case SUBREG:
1104 /* First try without delegitimization of whole MEMs and
1105 avoid_constant_pool_reference, which is more likely to succeed. */
1106 store_save = amd->store;
1107 amd->store = true;
1108 addr = simplify_replace_fn_rtx (SUBREG_REG (loc), old_rtx, adjust_mems,
1109 data);
1110 amd->store = store_save;
1111 mem = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
1112 if (mem == SUBREG_REG (loc))
1113 {
1114 tem = loc;
1115 goto finish_subreg;
1116 }
1117 tem = simplify_gen_subreg (GET_MODE (loc), mem,
1118 GET_MODE (SUBREG_REG (loc)),
1119 SUBREG_BYTE (loc));
1120 if (tem)
1121 goto finish_subreg;
1122 tem = simplify_gen_subreg (GET_MODE (loc), addr,
1123 GET_MODE (SUBREG_REG (loc)),
1124 SUBREG_BYTE (loc));
1125 if (tem == NULL_RTX)
1126 tem = gen_rtx_raw_SUBREG (GET_MODE (loc), addr, SUBREG_BYTE (loc));
1127 finish_subreg:
1128 if (MAY_HAVE_DEBUG_BIND_INSNS
1129 && GET_CODE (tem) == SUBREG
1130 && (GET_CODE (SUBREG_REG (tem)) == PLUS
1131 || GET_CODE (SUBREG_REG (tem)) == MINUS
1132 || GET_CODE (SUBREG_REG (tem)) == MULT
1133 || GET_CODE (SUBREG_REG (tem)) == ASHIFT)
1134 && is_a <scalar_int_mode> (GET_MODE (tem), &tem_mode)
1135 && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (tem)),
1136 &tem_subreg_mode)
1137 && (GET_MODE_PRECISION (tem_mode)
1138 < GET_MODE_PRECISION (tem_subreg_mode))
1139 && subreg_lowpart_p (tem)
1140 && use_narrower_mode_test (SUBREG_REG (tem), tem))
1141 return use_narrower_mode (SUBREG_REG (tem), tem_mode, tem_subreg_mode);
1142 return tem;
1143 case ASM_OPERANDS:
1144 /* Don't do any replacements in second and following
1145 ASM_OPERANDS of inline-asm with multiple sets.
1146 ASM_OPERANDS_INPUT_VEC, ASM_OPERANDS_INPUT_CONSTRAINT_VEC
1147 and ASM_OPERANDS_LABEL_VEC need to be equal between
1148 all the ASM_OPERANDs in the insn and adjust_insn will
1149 fix this up. */
1150 if (ASM_OPERANDS_OUTPUT_IDX (loc) != 0)
1151 return loc;
1152 break;
1153 default:
1154 break;
1155 }
1156 return NULL_RTX;
1157}
1158
1159/* Helper function for replacement of uses. */
1160
1161static void
1162adjust_mem_uses (rtx *x, void *data)
1163{
1164 rtx new_x = simplify_replace_fn_rtx (*x, NULL_RTX, adjust_mems, data);
1165 if (new_x != *x)
1166 validate_change (NULL_RTX, x, new_x, true);
1167}
1168
1169/* Helper function for replacement of stores. */
1170
1171static void
1172adjust_mem_stores (rtx loc, const_rtx expr, void *data)
1173{
1174 if (MEM_P (loc))
1175 {
1176 rtx new_dest = simplify_replace_fn_rtx (SET_DEST (expr), NULL_RTX,
1177 adjust_mems, data);
1178 if (new_dest != SET_DEST (expr))
1179 {
1180 rtx xexpr = CONST_CAST_RTX (expr);
1181 validate_change (NULL_RTX, &SET_DEST (xexpr), new_dest, true);
1182 }
1183 }
1184}
1185
1186/* Simplify INSN. Remove all {PRE,POST}_{INC,DEC,MODIFY} rtxes,
1187 replace them with their value in the insn and add the side-effects
1188 as other sets to the insn. */
1189
1190static void
1191adjust_insn (basic_block bb, rtx_insn *insn)
1192{
1193 rtx set;
1194
1195#ifdef HAVE_window_save
1196 /* If the target machine has an explicit window save instruction, the
1197 transformation OUTGOING_REGNO -> INCOMING_REGNO is done there. */
1198 if (RTX_FRAME_RELATED_P (insn)
1199 && find_reg_note (insn, REG_CFA_WINDOW_SAVE, NULL_RTX))
1200 {
1201 unsigned int i, nregs = vec_safe_length (windowed_parm_regs);
1202 rtx rtl = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs * 2));
1203 parm_reg *p;
1204
1205 FOR_EACH_VEC_SAFE_ELT (windowed_parm_regs, i, p)
1206 {
1207 XVECEXP (rtl, 0, i * 2)
1208 = gen_rtx_SET (p->incoming, p->outgoing);
1209 /* Do not clobber the attached DECL, but only the REG. */
1210 XVECEXP (rtl, 0, i * 2 + 1)
1211 = gen_rtx_CLOBBER (GET_MODE (p->outgoing),
1212 gen_raw_REG (GET_MODE (p->outgoing),
1213 REGNO (p->outgoing)));
1214 }
1215
1216 validate_change (NULL_RTX, &PATTERN (insn), rtl, true);
1217 return;
1218 }
1219#endif
1220
1221 adjust_mem_data amd;
1222 amd.mem_mode = VOIDmode;
1223 amd.stack_adjust = -VTI (bb)->out.stack_adjust;
1224
1225 amd.store = true;
1226 note_stores (PATTERN (insn), adjust_mem_stores, &amd);
1227
1228 amd.store = false;
1229 if (GET_CODE (PATTERN (insn)) == PARALLEL
1230 && asm_noperands (PATTERN (insn)) > 0
1231 && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET)
1232 {
1233 rtx body, set0;
1234 int i;
1235
1236 /* inline-asm with multiple sets is tiny bit more complicated,
1237 because the 3 vectors in ASM_OPERANDS need to be shared between
1238 all ASM_OPERANDS in the instruction. adjust_mems will
1239 not touch ASM_OPERANDS other than the first one, asm_noperands
1240 test above needs to be called before that (otherwise it would fail)
1241 and afterwards this code fixes it up. */
1242 note_uses (&PATTERN (insn), adjust_mem_uses, &amd);
1243 body = PATTERN (insn);
1244 set0 = XVECEXP (body, 0, 0);
1245 gcc_checking_assert (GET_CODE (set0) == SET
1246 && GET_CODE (SET_SRC (set0)) == ASM_OPERANDS
1247 && ASM_OPERANDS_OUTPUT_IDX (SET_SRC (set0)) == 0);
1248 for (i = 1; i < XVECLEN (body, 0); i++)
1249 if (GET_CODE (XVECEXP (body, 0, i)) != SET)
1250 break;
1251 else
1252 {
1253 set = XVECEXP (body, 0, i);
1254 gcc_checking_assert (GET_CODE (SET_SRC (set)) == ASM_OPERANDS
1255 && ASM_OPERANDS_OUTPUT_IDX (SET_SRC (set))
1256 == i);
1257 if (ASM_OPERANDS_INPUT_VEC (SET_SRC (set))
1258 != ASM_OPERANDS_INPUT_VEC (SET_SRC (set0))
1259 || ASM_OPERANDS_INPUT_CONSTRAINT_VEC (SET_SRC (set))
1260 != ASM_OPERANDS_INPUT_CONSTRAINT_VEC (SET_SRC (set0))
1261 || ASM_OPERANDS_LABEL_VEC (SET_SRC (set))
1262 != ASM_OPERANDS_LABEL_VEC (SET_SRC (set0)))
1263 {
1264 rtx newsrc = shallow_copy_rtx (SET_SRC (set));
1265 ASM_OPERANDS_INPUT_VEC (newsrc)
1266 = ASM_OPERANDS_INPUT_VEC (SET_SRC (set0));
1267 ASM_OPERANDS_INPUT_CONSTRAINT_VEC (newsrc)
1268 = ASM_OPERANDS_INPUT_CONSTRAINT_VEC (SET_SRC (set0));
1269 ASM_OPERANDS_LABEL_VEC (newsrc)
1270 = ASM_OPERANDS_LABEL_VEC (SET_SRC (set0));
1271 validate_change (NULL_RTX, &SET_SRC (set), newsrc, true);
1272 }
1273 }
1274 }
1275 else
1276 note_uses (&PATTERN (insn), adjust_mem_uses, &amd);
1277
1278 /* For read-only MEMs containing some constant, prefer those
1279 constants. */
1280 set = single_set (insn);
1281 if (set && MEM_P (SET_SRC (set)) && MEM_READONLY_P (SET_SRC (set)))
1282 {
1283 rtx note = find_reg_equal_equiv_note (insn);
1284
1285 if (note && CONSTANT_P (XEXP (note, 0)))
1286 validate_change (NULL_RTX, &SET_SRC (set), XEXP (note, 0), true);
1287 }
1288
1289 if (!amd.side_effects.is_empty ())
1290 {
1291 rtx *pat, new_pat;
1292 int i, oldn;
1293
1294 pat = &PATTERN (insn);
1295 if (GET_CODE (*pat) == COND_EXEC)
1296 pat = &COND_EXEC_CODE (*pat);
1297 if (GET_CODE (*pat) == PARALLEL)
1298 oldn = XVECLEN (*pat, 0);
1299 else
1300 oldn = 1;
1301 unsigned int newn = amd.side_effects.length ();
1302 new_pat = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (oldn + newn));
1303 if (GET_CODE (*pat) == PARALLEL)
1304 for (i = 0; i < oldn; i++)
1305 XVECEXP (new_pat, 0, i) = XVECEXP (*pat, 0, i);
1306 else
1307 XVECEXP (new_pat, 0, 0) = *pat;
1308
1309 rtx effect;
1310 unsigned int j;
1311 FOR_EACH_VEC_ELT_REVERSE (amd.side_effects, j, effect)
1312 XVECEXP (new_pat, 0, j + oldn) = effect;
1313 validate_change (NULL_RTX, pat, new_pat, true);
1314 }
1315}
1316
1317/* Return the DEBUG_EXPR of a DEBUG_EXPR_DECL or the VALUE in DV. */
1318static inline rtx
1319dv_as_rtx (decl_or_value dv)
1320{
1321 tree decl;
1322
1323 if (dv_is_value_p (dv))
1324 return dv_as_value (dv);
1325
1326 decl = dv_as_decl (dv);
1327
1328 gcc_checking_assert (TREE_CODE (decl) == DEBUG_EXPR_DECL);
1329 return DECL_RTL_KNOWN_SET (decl);
1330}
1331
1332/* Return nonzero if a decl_or_value must not have more than one
1333 variable part. The returned value discriminates among various
1334 kinds of one-part DVs ccording to enum onepart_enum. */
1335static inline onepart_enum
1336dv_onepart_p (decl_or_value dv)
1337{
1338 tree decl;
1339
1340 if (!MAY_HAVE_DEBUG_BIND_INSNS)
1341 return NOT_ONEPART;
1342
1343 if (dv_is_value_p (dv))
1344 return ONEPART_VALUE;
1345
1346 decl = dv_as_decl (dv);
1347
1348 if (TREE_CODE (decl) == DEBUG_EXPR_DECL)
1349 return ONEPART_DEXPR;
1350
1351 if (target_for_debug_bind (decl) != NULL_TREE)
1352 return ONEPART_VDECL;
1353
1354 return NOT_ONEPART;
1355}
1356
1357/* Return the variable pool to be used for a dv of type ONEPART. */
1358static inline pool_allocator &
1359onepart_pool (onepart_enum onepart)
1360{
1361 return onepart ? valvar_pool : var_pool;
1362}
1363
1364/* Allocate a variable_def from the corresponding variable pool. */
1365static inline variable *
1366onepart_pool_allocate (onepart_enum onepart)
1367{
1368 return (variable*) onepart_pool (onepart).allocate ();
1369}
1370
1371/* Build a decl_or_value out of a decl. */
1372static inline decl_or_value
1373dv_from_decl (tree decl)
1374{
1375 decl_or_value dv;
1376 dv = decl;
1377 gcc_checking_assert (dv_is_decl_p (dv));
1378 return dv;
1379}
1380
1381/* Build a decl_or_value out of a value. */
1382static inline decl_or_value
1383dv_from_value (rtx value)
1384{
1385 decl_or_value dv;
1386 dv = value;
1387 gcc_checking_assert (dv_is_value_p (dv));
1388 return dv;
1389}
1390
1391/* Return a value or the decl of a debug_expr as a decl_or_value. */
1392static inline decl_or_value
1393dv_from_rtx (rtx x)
1394{
1395 decl_or_value dv;
1396
1397 switch (GET_CODE (x))
1398 {
1399 case DEBUG_EXPR:
1400 dv = dv_from_decl (DEBUG_EXPR_TREE_DECL (x));
1401 gcc_checking_assert (DECL_RTL_KNOWN_SET (DEBUG_EXPR_TREE_DECL (x)) == x);
1402 break;
1403
1404 case VALUE:
1405 dv = dv_from_value (x);
1406 break;
1407
1408 default:
1409 gcc_unreachable ();
1410 }
1411
1412 return dv;
1413}
1414
1415extern void debug_dv (decl_or_value dv);
1416
1417DEBUG_FUNCTION void
1418debug_dv (decl_or_value dv)
1419{
1420 if (dv_is_value_p (dv))
1421 debug_rtx (dv_as_value (dv));
1422 else
1423 debug_generic_stmt (dv_as_decl (dv));
1424}
1425
1426static void loc_exp_dep_clear (variable *var);
1427
1428/* Free the element of VARIABLE_HTAB (its type is struct variable_def). */
1429
1430static void
1431variable_htab_free (void *elem)
1432{
1433 int i;
1434 variable *var = (variable *) elem;
1435 location_chain *node, *next;
1436
1437 gcc_checking_assert (var->refcount > 0);
1438
1439 var->refcount--;
1440 if (var->refcount > 0)
1441 return;
1442
1443 for (i = 0; i < var->n_var_parts; i++)
1444 {
1445 for (node = var->var_part[i].loc_chain; node; node = next)
1446 {
1447 next = node->next;
1448 delete node;
1449 }
1450 var->var_part[i].loc_chain = NULL;
1451 }
1452 if (var->onepart && VAR_LOC_1PAUX (var))
1453 {
1454 loc_exp_dep_clear (var);
1455 if (VAR_LOC_DEP_LST (var))
1456 VAR_LOC_DEP_LST (var)->pprev = NULL;
1457 XDELETE (VAR_LOC_1PAUX (var));
1458 /* These may be reused across functions, so reset
1459 e.g. NO_LOC_P. */
1460 if (var->onepart == ONEPART_DEXPR)
1461 set_dv_changed (var->dv, true);
1462 }
1463 onepart_pool (var->onepart).remove (var);
1464}
1465
1466/* Initialize the set (array) SET of attrs to empty lists. */
1467
1468static void
1469init_attrs_list_set (attrs **set)
1470{
1471 int i;
1472
1473 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1474 set[i] = NULL;
1475}
1476
1477/* Make the list *LISTP empty. */
1478
1479static void
1480attrs_list_clear (attrs **listp)
1481{
1482 attrs *list, *next;
1483
1484 for (list = *listp; list; list = next)
1485 {
1486 next = list->next;
1487 delete list;
1488 }
1489 *listp = NULL;
1490}
1491
1492/* Return true if the pair of DECL and OFFSET is the member of the LIST. */
1493
1494static attrs *
1495attrs_list_member (attrs *list, decl_or_value dv, HOST_WIDE_INT offset)
1496{
1497 for (; list; list = list->next)
1498 if (dv_as_opaque (list->dv) == dv_as_opaque (dv) && list->offset == offset)
1499 return list;
1500 return NULL;
1501}
1502
1503/* Insert the triplet DECL, OFFSET, LOC to the list *LISTP. */
1504
1505static void
1506attrs_list_insert (attrs **listp, decl_or_value dv,
1507 HOST_WIDE_INT offset, rtx loc)
1508{
1509 attrs *list = new attrs;
1510 list->loc = loc;
1511 list->dv = dv;
1512 list->offset = offset;
1513 list->next = *listp;
1514 *listp = list;
1515}
1516
1517/* Copy all nodes from SRC and create a list *DSTP of the copies. */
1518
1519static void
1520attrs_list_copy (attrs **dstp, attrs *src)
1521{
1522 attrs_list_clear (dstp);
1523 for (; src; src = src->next)
1524 {
1525 attrs *n = new attrs;
1526 n->loc = src->loc;
1527 n->dv = src->dv;
1528 n->offset = src->offset;
1529 n->next = *dstp;
1530 *dstp = n;
1531 }
1532}
1533
1534/* Add all nodes from SRC which are not in *DSTP to *DSTP. */
1535
1536static void
1537attrs_list_union (attrs **dstp, attrs *src)
1538{
1539 for (; src; src = src->next)
1540 {
1541 if (!attrs_list_member (*dstp, src->dv, src->offset))
1542 attrs_list_insert (dstp, src->dv, src->offset, src->loc);
1543 }
1544}
1545
1546/* Combine nodes that are not onepart nodes from SRC and SRC2 into
1547 *DSTP. */
1548
1549static void
1550attrs_list_mpdv_union (attrs **dstp, attrs *src, attrs *src2)
1551{
1552 gcc_assert (!*dstp);
1553 for (; src; src = src->next)
1554 {
1555 if (!dv_onepart_p (src->dv))
1556 attrs_list_insert (dstp, src->dv, src->offset, src->loc);
1557 }
1558 for (src = src2; src; src = src->next)
1559 {
1560 if (!dv_onepart_p (src->dv)
1561 && !attrs_list_member (*dstp, src->dv, src->offset))
1562 attrs_list_insert (dstp, src->dv, src->offset, src->loc);
1563 }
1564}
1565
1566/* Shared hashtable support. */
1567
1568/* Return true if VARS is shared. */
1569
1570static inline bool
1571shared_hash_shared (shared_hash *vars)
1572{
1573 return vars->refcount > 1;
1574}
1575
1576/* Return the hash table for VARS. */
1577
1578static inline variable_table_type *
1579shared_hash_htab (shared_hash *vars)
1580{
1581 return vars->htab;
1582}
1583
1584/* Return true if VAR is shared, or maybe because VARS is shared. */
1585
1586static inline bool
1587shared_var_p (variable *var, shared_hash *vars)
1588{
1589 /* Don't count an entry in the changed_variables table as a duplicate. */
1590 return ((var->refcount > 1 + (int) var->in_changed_variables)
1591 || shared_hash_shared (vars));
1592}
1593
1594/* Copy variables into a new hash table. */
1595
1596static shared_hash *
1597shared_hash_unshare (shared_hash *vars)
1598{
1599 shared_hash *new_vars = new shared_hash;
1600 gcc_assert (vars->refcount > 1);
1601 new_vars->refcount = 1;
1602 new_vars->htab = new variable_table_type (vars->htab->elements () + 3);
1603 vars_copy (new_vars->htab, vars->htab);
1604 vars->refcount--;
1605 return new_vars;
1606}
1607
1608/* Increment reference counter on VARS and return it. */
1609
1610static inline shared_hash *
1611shared_hash_copy (shared_hash *vars)
1612{
1613 vars->refcount++;
1614 return vars;
1615}
1616
1617/* Decrement reference counter and destroy hash table if not shared
1618 anymore. */
1619
1620static void
1621shared_hash_destroy (shared_hash *vars)
1622{
1623 gcc_checking_assert (vars->refcount > 0);
1624 if (--vars->refcount == 0)
1625 {
1626 delete vars->htab;
1627 delete vars;
1628 }
1629}
1630
1631/* Unshare *PVARS if shared and return slot for DV. If INS is
1632 INSERT, insert it if not already present. */
1633
1634static inline variable **
1635shared_hash_find_slot_unshare_1 (shared_hash **pvars, decl_or_value dv,
1636 hashval_t dvhash, enum insert_option ins)
1637{
1638 if (shared_hash_shared (*pvars))
1639 *pvars = shared_hash_unshare (*pvars);
1640 return shared_hash_htab (*pvars)->find_slot_with_hash (dv, dvhash, ins);
1641}
1642
1643static inline variable **
1644shared_hash_find_slot_unshare (shared_hash **pvars, decl_or_value dv,
1645 enum insert_option ins)
1646{
1647 return shared_hash_find_slot_unshare_1 (pvars, dv, dv_htab_hash (dv), ins);
1648}
1649
1650/* Return slot for DV, if it is already present in the hash table.
1651 If it is not present, insert it only VARS is not shared, otherwise
1652 return NULL. */
1653
1654static inline variable **
1655shared_hash_find_slot_1 (shared_hash *vars, decl_or_value dv, hashval_t dvhash)
1656{
1657 return shared_hash_htab (vars)->find_slot_with_hash (dv, dvhash,
1658 shared_hash_shared (vars)
1659 ? NO_INSERT : INSERT);
1660}
1661
1662static inline variable **
1663shared_hash_find_slot (shared_hash *vars, decl_or_value dv)
1664{
1665 return shared_hash_find_slot_1 (vars, dv, dv_htab_hash (dv));
1666}
1667
1668/* Return slot for DV only if it is already present in the hash table. */
1669
1670static inline variable **
1671shared_hash_find_slot_noinsert_1 (shared_hash *vars, decl_or_value dv,
1672 hashval_t dvhash)
1673{
1674 return shared_hash_htab (vars)->find_slot_with_hash (dv, dvhash, NO_INSERT);
1675}
1676
1677static inline variable **
1678shared_hash_find_slot_noinsert (shared_hash *vars, decl_or_value dv)
1679{
1680 return shared_hash_find_slot_noinsert_1 (vars, dv, dv_htab_hash (dv));
1681}
1682
1683/* Return variable for DV or NULL if not already present in the hash
1684 table. */
1685
1686static inline variable *
1687shared_hash_find_1 (shared_hash *vars, decl_or_value dv, hashval_t dvhash)
1688{
1689 return shared_hash_htab (vars)->find_with_hash (dv, dvhash);
1690}
1691
1692static inline variable *
1693shared_hash_find (shared_hash *vars, decl_or_value dv)
1694{
1695 return shared_hash_find_1 (vars, dv, dv_htab_hash (dv));
1696}
1697
1698/* Return true if TVAL is better than CVAL as a canonival value. We
1699 choose lowest-numbered VALUEs, using the RTX address as a
1700 tie-breaker. The idea is to arrange them into a star topology,
1701 such that all of them are at most one step away from the canonical
1702 value, and the canonical value has backlinks to all of them, in
1703 addition to all the actual locations. We don't enforce this
1704 topology throughout the entire dataflow analysis, though.
1705 */
1706
1707static inline bool
1708canon_value_cmp (rtx tval, rtx cval)
1709{
1710 return !cval
1711 || CSELIB_VAL_PTR (tval)->uid < CSELIB_VAL_PTR (cval)->uid;
1712}
1713
1714static bool dst_can_be_shared;
1715
1716/* Return a copy of a variable VAR and insert it to dataflow set SET. */
1717
1718static variable **
1719unshare_variable (dataflow_set *set, variable **slot, variable *var,
1720 enum var_init_status initialized)
1721{
1722 variable *new_var;
1723 int i;
1724
1725 new_var = onepart_pool_allocate (var->onepart);
1726 new_var->dv = var->dv;
1727 new_var->refcount = 1;
1728 var->refcount--;
1729 new_var->n_var_parts = var->n_var_parts;
1730 new_var->onepart = var->onepart;
1731 new_var->in_changed_variables = false;
1732
1733 if (! flag_var_tracking_uninit)
1734 initialized = VAR_INIT_STATUS_INITIALIZED;
1735
1736 for (i = 0; i < var->n_var_parts; i++)
1737 {
1738 location_chain *node;
1739 location_chain **nextp;
1740
1741 if (i == 0 && var->onepart)
1742 {
1743 /* One-part auxiliary data is only used while emitting
1744 notes, so propagate it to the new variable in the active
1745 dataflow set. If we're not emitting notes, this will be
1746 a no-op. */
1747 gcc_checking_assert (!VAR_LOC_1PAUX (var) || emit_notes);
1748 VAR_LOC_1PAUX (new_var) = VAR_LOC_1PAUX (var);
1749 VAR_LOC_1PAUX (var) = NULL;
1750 }
1751 else
1752 VAR_PART_OFFSET (new_var, i) = VAR_PART_OFFSET (var, i);
1753 nextp = &new_var->var_part[i].loc_chain;
1754 for (node = var->var_part[i].loc_chain; node; node = node->next)
1755 {
1756 location_chain *new_lc;
1757
1758 new_lc = new location_chain;
1759 new_lc->next = NULL;
1760 if (node->init > initialized)
1761 new_lc->init = node->init;
1762 else
1763 new_lc->init = initialized;
1764 if (node->set_src && !(MEM_P (node->set_src)))
1765 new_lc->set_src = node->set_src;
1766 else
1767 new_lc->set_src = NULL;
1768 new_lc->loc = node->loc;
1769
1770 *nextp = new_lc;
1771 nextp = &new_lc->next;
1772 }
1773
1774 new_var->var_part[i].cur_loc = var->var_part[i].cur_loc;
1775 }
1776
1777 dst_can_be_shared = false;
1778 if (shared_hash_shared (set->vars))
1779 slot = shared_hash_find_slot_unshare (&set->vars, var->dv, NO_INSERT);
1780 else if (set->traversed_vars && set->vars != set->traversed_vars)
1781 slot = shared_hash_find_slot_noinsert (set->vars, var->dv);
1782 *slot = new_var;
1783 if (var->in_changed_variables)
1784 {
1785 variable **cslot
1786 = changed_variables->find_slot_with_hash (var->dv,
1787 dv_htab_hash (var->dv),
1788 NO_INSERT);
1789 gcc_assert (*cslot == (void *) var);
1790 var->in_changed_variables = false;
1791 variable_htab_free (var);
1792 *cslot = new_var;
1793 new_var->in_changed_variables = true;
1794 }
1795 return slot;
1796}
1797
1798/* Copy all variables from hash table SRC to hash table DST. */
1799
1800static void
1801vars_copy (variable_table_type *dst, variable_table_type *src)
1802{
1803 variable_iterator_type hi;
1804 variable *var;
1805
1806 FOR_EACH_HASH_TABLE_ELEMENT (*src, var, variable, hi)
1807 {
1808 variable **dstp;
1809 var->refcount++;
1810 dstp = dst->find_slot_with_hash (var->dv, dv_htab_hash (var->dv),
1811 INSERT);
1812 *dstp = var;
1813 }
1814}
1815
1816/* Map a decl to its main debug decl. */
1817
1818static inline tree
1819var_debug_decl (tree decl)
1820{
1821 if (decl && VAR_P (decl) && DECL_HAS_DEBUG_EXPR_P (decl))
1822 {
1823 tree debugdecl = DECL_DEBUG_EXPR (decl);
1824 if (DECL_P (debugdecl))
1825 decl = debugdecl;
1826 }
1827
1828 return decl;
1829}
1830
1831/* Set the register LOC to contain DV, OFFSET. */
1832
1833static void
1834var_reg_decl_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
1835 decl_or_value dv, HOST_WIDE_INT offset, rtx set_src,
1836 enum insert_option iopt)
1837{
1838 attrs *node;
1839 bool decl_p = dv_is_decl_p (dv);
1840
1841 if (decl_p)
1842 dv = dv_from_decl (var_debug_decl (dv_as_decl (dv)));
1843
1844 for (node = set->regs[REGNO (loc)]; node; node = node->next)
1845 if (dv_as_opaque (node->dv) == dv_as_opaque (dv)
1846 && node->offset == offset)
1847 break;
1848 if (!node)
1849 attrs_list_insert (&set->regs[REGNO (loc)], dv, offset, loc);
1850 set_variable_part (set, loc, dv, offset, initialized, set_src, iopt);
1851}
1852
1853/* Set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC). */
1854
1855static void
1856var_reg_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
1857 rtx set_src)
1858{
1859 tree decl = REG_EXPR (loc);
1860 HOST_WIDE_INT offset = REG_OFFSET (loc);
1861
1862 var_reg_decl_set (set, loc, initialized,
1863 dv_from_decl (decl), offset, set_src, INSERT);
1864}
1865
1866static enum var_init_status
1867get_init_value (dataflow_set *set, rtx loc, decl_or_value dv)
1868{
1869 variable *var;
1870 int i;
1871 enum var_init_status ret_val = VAR_INIT_STATUS_UNKNOWN;
1872
1873 if (! flag_var_tracking_uninit)
1874 return VAR_INIT_STATUS_INITIALIZED;
1875
1876 var = shared_hash_find (set->vars, dv);
1877 if (var)
1878 {
1879 for (i = 0; i < var->n_var_parts && ret_val == VAR_INIT_STATUS_UNKNOWN; i++)
1880 {
1881 location_chain *nextp;
1882 for (nextp = var->var_part[i].loc_chain; nextp; nextp = nextp->next)
1883 if (rtx_equal_p (nextp->loc, loc))
1884 {
1885 ret_val = nextp->init;
1886 break;
1887 }
1888 }
1889 }
1890
1891 return ret_val;
1892}
1893
1894/* Delete current content of register LOC in dataflow set SET and set
1895 the register to contain REG_EXPR (LOC), REG_OFFSET (LOC). If
1896 MODIFY is true, any other live copies of the same variable part are
1897 also deleted from the dataflow set, otherwise the variable part is
1898 assumed to be copied from another location holding the same
1899 part. */
1900
1901static void
1902var_reg_delete_and_set (dataflow_set *set, rtx loc, bool modify,
1903 enum var_init_status initialized, rtx set_src)
1904{
1905 tree decl = REG_EXPR (loc);
1906 HOST_WIDE_INT offset = REG_OFFSET (loc);
1907 attrs *node, *next;
1908 attrs **nextp;
1909
1910 decl = var_debug_decl (decl);
1911
1912 if (initialized == VAR_INIT_STATUS_UNKNOWN)
1913 initialized = get_init_value (set, loc, dv_from_decl (decl));
1914
1915 nextp = &set->regs[REGNO (loc)];
1916 for (node = *nextp; node; node = next)
1917 {
1918 next = node->next;
1919 if (dv_as_opaque (node->dv) != decl || node->offset != offset)
1920 {
1921 delete_variable_part (set, node->loc, node->dv, node->offset);
1922 delete node;
1923 *nextp = next;
1924 }
1925 else
1926 {
1927 node->loc = loc;
1928 nextp = &node->next;
1929 }
1930 }
1931 if (modify)
1932 clobber_variable_part (set, loc, dv_from_decl (decl), offset, set_src);
1933 var_reg_set (set, loc, initialized, set_src);
1934}
1935
1936/* Delete the association of register LOC in dataflow set SET with any
1937 variables that aren't onepart. If CLOBBER is true, also delete any
1938 other live copies of the same variable part, and delete the
1939 association with onepart dvs too. */
1940
1941static void
1942var_reg_delete (dataflow_set *set, rtx loc, bool clobber)
1943{
1944 attrs **nextp = &set->regs[REGNO (loc)];
1945 attrs *node, *next;
1946
1947 if (clobber)
1948 {
1949 tree decl = REG_EXPR (loc);
1950 HOST_WIDE_INT offset = REG_OFFSET (loc);
1951
1952 decl = var_debug_decl (decl);
1953
1954 clobber_variable_part (set, NULL, dv_from_decl (decl), offset, NULL);
1955 }
1956
1957 for (node = *nextp; node; node = next)
1958 {
1959 next = node->next;
1960 if (clobber || !dv_onepart_p (node->dv))
1961 {
1962 delete_variable_part (set, node->loc, node->dv, node->offset);
1963 delete node;
1964 *nextp = next;
1965 }
1966 else
1967 nextp = &node->next;
1968 }
1969}
1970
1971/* Delete content of register with number REGNO in dataflow set SET. */
1972
1973static void
1974var_regno_delete (dataflow_set *set, int regno)
1975{
1976 attrs **reg = &set->regs[regno];
1977 attrs *node, *next;
1978
1979 for (node = *reg; node; node = next)
1980 {
1981 next = node->next;
1982 delete_variable_part (set, node->loc, node->dv, node->offset);
1983 delete node;
1984 }
1985 *reg = NULL;
1986}
1987
1988/* Return true if I is the negated value of a power of two. */
1989static bool
1990negative_power_of_two_p (HOST_WIDE_INT i)
1991{
1992 unsigned HOST_WIDE_INT x = -(unsigned HOST_WIDE_INT)i;
1993 return pow2_or_zerop (x);
1994}
1995
1996/* Strip constant offsets and alignments off of LOC. Return the base
1997 expression. */
1998
1999static rtx
2000vt_get_canonicalize_base (rtx loc)
2001{
2002 while ((GET_CODE (loc) == PLUS
2003 || GET_CODE (loc) == AND)
2004 && GET_CODE (XEXP (loc, 1)) == CONST_INT
2005 && (GET_CODE (loc) != AND
2006 || negative_power_of_two_p (INTVAL (XEXP (loc, 1)))))
2007 loc = XEXP (loc, 0);
2008
2009 return loc;
2010}
2011
2012/* This caches canonicalized addresses for VALUEs, computed using
2013 information in the global cselib table. */
2014static hash_map<rtx, rtx> *global_get_addr_cache;
2015
2016/* This caches canonicalized addresses for VALUEs, computed using
2017 information from the global cache and information pertaining to a
2018 basic block being analyzed. */
2019static hash_map<rtx, rtx> *local_get_addr_cache;
2020
2021static rtx vt_canonicalize_addr (dataflow_set *, rtx);
2022
2023/* Return the canonical address for LOC, that must be a VALUE, using a
2024 cached global equivalence or computing it and storing it in the
2025 global cache. */
2026
2027static rtx
2028get_addr_from_global_cache (rtx const loc)
2029{
2030 rtx x;
2031
2032 gcc_checking_assert (GET_CODE (loc) == VALUE);
2033
2034 bool existed;
2035 rtx *slot = &global_get_addr_cache->get_or_insert (loc, &existed);
2036 if (existed)
2037 return *slot;
2038
2039 x = canon_rtx (get_addr (loc));
2040
2041 /* Tentative, avoiding infinite recursion. */
2042 *slot = x;
2043
2044 if (x != loc)
2045 {
2046 rtx nx = vt_canonicalize_addr (NULL, x);
2047 if (nx != x)
2048 {
2049 /* The table may have moved during recursion, recompute
2050 SLOT. */
2051 *global_get_addr_cache->get (loc) = x = nx;
2052 }
2053 }
2054
2055 return x;
2056}
2057
2058/* Return the canonical address for LOC, that must be a VALUE, using a
2059 cached local equivalence or computing it and storing it in the
2060 local cache. */
2061
2062static rtx
2063get_addr_from_local_cache (dataflow_set *set, rtx const loc)
2064{
2065 rtx x;
2066 decl_or_value dv;
2067 variable *var;
2068 location_chain *l;
2069
2070 gcc_checking_assert (GET_CODE (loc) == VALUE);
2071
2072 bool existed;
2073 rtx *slot = &local_get_addr_cache->get_or_insert (loc, &existed);
2074 if (existed)
2075 return *slot;
2076
2077 x = get_addr_from_global_cache (loc);
2078
2079 /* Tentative, avoiding infinite recursion. */
2080 *slot = x;
2081
2082 /* Recurse to cache local expansion of X, or if we need to search
2083 for a VALUE in the expansion. */
2084 if (x != loc)
2085 {
2086 rtx nx = vt_canonicalize_addr (set, x);
2087 if (nx != x)
2088 {
2089 slot = local_get_addr_cache->get (loc);
2090 *slot = x = nx;
2091 }
2092 return x;
2093 }
2094
2095 dv = dv_from_rtx (x);
2096 var = shared_hash_find (set->vars, dv);
2097 if (!var)
2098 return x;
2099
2100 /* Look for an improved equivalent expression. */
2101 for (l = var->var_part[0].loc_chain; l; l = l->next)
2102 {
2103 rtx base = vt_get_canonicalize_base (l->loc);
2104 if (GET_CODE (base) == VALUE
2105 && canon_value_cmp (base, loc))
2106 {
2107 rtx nx = vt_canonicalize_addr (set, l->loc);
2108 if (x != nx)
2109 {
2110 slot = local_get_addr_cache->get (loc);
2111 *slot = x = nx;
2112 }
2113 break;
2114 }
2115 }
2116
2117 return x;
2118}
2119
2120/* Canonicalize LOC using equivalences from SET in addition to those
2121 in the cselib static table. It expects a VALUE-based expression,
2122 and it will only substitute VALUEs with other VALUEs or
2123 function-global equivalences, so that, if two addresses have base
2124 VALUEs that are locally or globally related in ways that
2125 memrefs_conflict_p cares about, they will both canonicalize to
2126 expressions that have the same base VALUE.
2127
2128 The use of VALUEs as canonical base addresses enables the canonical
2129 RTXs to remain unchanged globally, if they resolve to a constant,
2130 or throughout a basic block otherwise, so that they can be cached
2131 and the cache needs not be invalidated when REGs, MEMs or such
2132 change. */
2133
2134static rtx
2135vt_canonicalize_addr (dataflow_set *set, rtx oloc)
2136{
2137 HOST_WIDE_INT ofst = 0;
2138 machine_mode mode = GET_MODE (oloc);
2139 rtx loc = oloc;
2140 rtx x;
2141 bool retry = true;
2142
2143 while (retry)
2144 {
2145 while (GET_CODE (loc) == PLUS
2146 && GET_CODE (XEXP (loc, 1)) == CONST_INT)
2147 {
2148 ofst += INTVAL (XEXP (loc, 1));
2149 loc = XEXP (loc, 0);
2150 }
2151
2152 /* Alignment operations can't normally be combined, so just
2153 canonicalize the base and we're done. We'll normally have
2154 only one stack alignment anyway. */
2155 if (GET_CODE (loc) == AND
2156 && GET_CODE (XEXP (loc, 1)) == CONST_INT
2157 && negative_power_of_two_p (INTVAL (XEXP (loc, 1))))
2158 {
2159 x = vt_canonicalize_addr (set, XEXP (loc, 0));
2160 if (x != XEXP (loc, 0))
2161 loc = gen_rtx_AND (mode, x, XEXP (loc, 1));
2162 retry = false;
2163 }
2164
2165 if (GET_CODE (loc) == VALUE)
2166 {
2167 if (set)
2168 loc = get_addr_from_local_cache (set, loc);
2169 else
2170 loc = get_addr_from_global_cache (loc);
2171
2172 /* Consolidate plus_constants. */
2173 while (ofst && GET_CODE (loc) == PLUS
2174 && GET_CODE (XEXP (loc, 1)) == CONST_INT)
2175 {
2176 ofst += INTVAL (XEXP (loc, 1));
2177 loc = XEXP (loc, 0);
2178 }
2179
2180 retry = false;
2181 }
2182 else
2183 {
2184 x = canon_rtx (loc);
2185 if (retry)
2186 retry = (x != loc);
2187 loc = x;
2188 }
2189 }
2190
2191 /* Add OFST back in. */
2192 if (ofst)
2193 {
2194 /* Don't build new RTL if we can help it. */
2195 if (GET_CODE (oloc) == PLUS
2196 && XEXP (oloc, 0) == loc
2197 && INTVAL (XEXP (oloc, 1)) == ofst)
2198 return oloc;
2199
2200 loc = plus_constant (mode, loc, ofst);
2201 }
2202
2203 return loc;
2204}
2205
2206/* Return true iff there's a true dependence between MLOC and LOC.
2207 MADDR must be a canonicalized version of MLOC's address. */
2208
2209static inline bool
2210vt_canon_true_dep (dataflow_set *set, rtx mloc, rtx maddr, rtx loc)
2211{
2212 if (GET_CODE (loc) != MEM)
2213 return false;
2214
2215 rtx addr = vt_canonicalize_addr (set, XEXP (loc, 0));
2216 if (!canon_true_dependence (mloc, GET_MODE (mloc), maddr, loc, addr))
2217 return false;
2218
2219 return true;
2220}
2221
2222/* Hold parameters for the hashtab traversal function
2223 drop_overlapping_mem_locs, see below. */
2224
2225struct overlapping_mems
2226{
2227 dataflow_set *set;
2228 rtx loc, addr;
2229};
2230
2231/* Remove all MEMs that overlap with COMS->LOC from the location list
2232 of a hash table entry for a onepart variable. COMS->ADDR must be a
2233 canonicalized form of COMS->LOC's address, and COMS->LOC must be
2234 canonicalized itself. */
2235
2236int
2237drop_overlapping_mem_locs (variable **slot, overlapping_mems *coms)
2238{
2239 dataflow_set *set = coms->set;
2240 rtx mloc = coms->loc, addr = coms->addr;
2241 variable *var = *slot;
2242
2243 if (var->onepart != NOT_ONEPART)
2244 {
2245 location_chain *loc, **locp;
2246 bool changed = false;
2247 rtx cur_loc;
2248
2249 gcc_assert (var->n_var_parts == 1);
2250
2251 if (shared_var_p (var, set->vars))
2252 {
2253 for (loc = var->var_part[0].loc_chain; loc; loc = loc->next)
2254 if (vt_canon_true_dep (set, mloc, addr, loc->loc))
2255 break;
2256
2257 if (!loc)
2258 return 1;
2259
2260 slot = unshare_variable (set, slot, var, VAR_INIT_STATUS_UNKNOWN);
2261 var = *slot;
2262 gcc_assert (var->n_var_parts == 1);
2263 }
2264
2265 if (VAR_LOC_1PAUX (var))
2266 cur_loc = VAR_LOC_FROM (var);
2267 else
2268 cur_loc = var->var_part[0].cur_loc;
2269
2270 for (locp = &var->var_part[0].loc_chain, loc = *locp;
2271 loc; loc = *locp)
2272 {
2273 if (!vt_canon_true_dep (set, mloc, addr, loc->loc))
2274 {
2275 locp = &loc->next;
2276 continue;
2277 }
2278
2279 *locp = loc->next;
2280 /* If we have deleted the location which was last emitted
2281 we have to emit new location so add the variable to set
2282 of changed variables. */
2283 if (cur_loc == loc->loc)
2284 {
2285 changed = true;
2286 var->var_part[0].cur_loc = NULL;
2287 if (VAR_LOC_1PAUX (var))
2288 VAR_LOC_FROM (var) = NULL;
2289 }
2290 delete loc;
2291 }
2292
2293 if (!var->var_part[0].loc_chain)
2294 {
2295 var->n_var_parts--;
2296 changed = true;
2297 }
2298 if (changed)
2299 variable_was_changed (var, set);
2300 }
2301
2302 return 1;
2303}
2304
2305/* Remove from SET all VALUE bindings to MEMs that overlap with LOC. */
2306
2307static void
2308clobber_overlapping_mems (dataflow_set *set, rtx loc)
2309{
2310 struct overlapping_mems coms;
2311
2312 gcc_checking_assert (GET_CODE (loc) == MEM);
2313
2314 coms.set = set;
2315 coms.loc = canon_rtx (loc);
2316 coms.addr = vt_canonicalize_addr (set, XEXP (loc, 0));
2317
2318 set->traversed_vars = set->vars;
2319 shared_hash_htab (set->vars)
2320 ->traverse <overlapping_mems*, drop_overlapping_mem_locs> (&coms);
2321 set->traversed_vars = NULL;
2322}
2323
2324/* Set the location of DV, OFFSET as the MEM LOC. */
2325
2326static void
2327var_mem_decl_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
2328 decl_or_value dv, HOST_WIDE_INT offset, rtx set_src,
2329 enum insert_option iopt)
2330{
2331 if (dv_is_decl_p (dv))
2332 dv = dv_from_decl (var_debug_decl (dv_as_decl (dv)));
2333
2334 set_variable_part (set, loc, dv, offset, initialized, set_src, iopt);
2335}
2336
2337/* Set the location part of variable MEM_EXPR (LOC) in dataflow set
2338 SET to LOC.
2339 Adjust the address first if it is stack pointer based. */
2340
2341static void
2342var_mem_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
2343 rtx set_src)
2344{
2345 tree decl = MEM_EXPR (loc);
2346 HOST_WIDE_INT offset = int_mem_offset (loc);
2347
2348 var_mem_decl_set (set, loc, initialized,
2349 dv_from_decl (decl), offset, set_src, INSERT);
2350}
2351
2352/* Delete and set the location part of variable MEM_EXPR (LOC) in
2353 dataflow set SET to LOC. If MODIFY is true, any other live copies
2354 of the same variable part are also deleted from the dataflow set,
2355 otherwise the variable part is assumed to be copied from another
2356 location holding the same part.
2357 Adjust the address first if it is stack pointer based. */
2358
2359static void
2360var_mem_delete_and_set (dataflow_set *set, rtx loc, bool modify,
2361 enum var_init_status initialized, rtx set_src)
2362{
2363 tree decl = MEM_EXPR (loc);
2364 HOST_WIDE_INT offset = int_mem_offset (loc);
2365
2366 clobber_overlapping_mems (set, loc);
2367 decl = var_debug_decl (decl);
2368
2369 if (initialized == VAR_INIT_STATUS_UNKNOWN)
2370 initialized = get_init_value (set, loc, dv_from_decl (decl));
2371
2372 if (modify)
2373 clobber_variable_part (set, NULL, dv_from_decl (decl), offset, set_src);
2374 var_mem_set (set, loc, initialized, set_src);
2375}
2376
2377/* Delete the location part LOC from dataflow set SET. If CLOBBER is
2378 true, also delete any other live copies of the same variable part.
2379 Adjust the address first if it is stack pointer based. */
2380
2381static void
2382var_mem_delete (dataflow_set *set, rtx loc, bool clobber)
2383{
2384 tree decl = MEM_EXPR (loc);
2385 HOST_WIDE_INT offset = int_mem_offset (loc);
2386
2387 clobber_overlapping_mems (set, loc);
2388 decl = var_debug_decl (decl);
2389 if (clobber)
2390 clobber_variable_part (set, NULL, dv_from_decl (decl), offset, NULL);
2391 delete_variable_part (set, loc, dv_from_decl (decl), offset);
2392}
2393
2394/* Return true if LOC should not be expanded for location expressions,
2395 or used in them. */
2396
2397static inline bool
2398unsuitable_loc (rtx loc)
2399{
2400 switch (GET_CODE (loc))
2401 {
2402 case PC:
2403 case SCRATCH:
2404 case CC0:
2405 case ASM_INPUT:
2406 case ASM_OPERANDS:
2407 return true;
2408
2409 default:
2410 return false;
2411 }
2412}
2413
2414/* Bind VAL to LOC in SET. If MODIFIED, detach LOC from any values
2415 bound to it. */
2416
2417static inline void
2418val_bind (dataflow_set *set, rtx val, rtx loc, bool modified)
2419{
2420 if (REG_P (loc))
2421 {
2422 if (modified)
2423 var_regno_delete (set, REGNO (loc));
2424 var_reg_decl_set (set, loc, VAR_INIT_STATUS_INITIALIZED,
2425 dv_from_value (val), 0, NULL_RTX, INSERT);
2426 }
2427 else if (MEM_P (loc))
2428 {
2429 struct elt_loc_list *l = CSELIB_VAL_PTR (val)->locs;
2430
2431 if (modified)
2432 clobber_overlapping_mems (set, loc);
2433
2434 if (l && GET_CODE (l->loc) == VALUE)
2435 l = canonical_cselib_val (CSELIB_VAL_PTR (l->loc))->locs;
2436
2437 /* If this MEM is a global constant, we don't need it in the
2438 dynamic tables. ??? We should test this before emitting the
2439 micro-op in the first place. */
2440 while (l)
2441 if (GET_CODE (l->loc) == MEM && XEXP (l->loc, 0) == XEXP (loc, 0))
2442 break;
2443 else
2444 l = l->next;
2445
2446 if (!l)
2447 var_mem_decl_set (set, loc, VAR_INIT_STATUS_INITIALIZED,
2448 dv_from_value (val), 0, NULL_RTX, INSERT);
2449 }
2450 else
2451 {
2452 /* Other kinds of equivalences are necessarily static, at least
2453 so long as we do not perform substitutions while merging
2454 expressions. */
2455 gcc_unreachable ();
2456 set_variable_part (set, loc, dv_from_value (val), 0,
2457 VAR_INIT_STATUS_INITIALIZED, NULL_RTX, INSERT);
2458 }
2459}
2460
2461/* Bind a value to a location it was just stored in. If MODIFIED
2462 holds, assume the location was modified, detaching it from any
2463 values bound to it. */
2464
2465static void
2466val_store (dataflow_set *set, rtx val, rtx loc, rtx_insn *insn,
2467 bool modified)
2468{
2469 cselib_val *v = CSELIB_VAL_PTR (val);
2470
2471 gcc_assert (cselib_preserved_value_p (v));
2472
2473 if (dump_file)
2474 {
2475 fprintf (dump_file, "%i: ", insn ? INSN_UID (insn) : 0);
2476 print_inline_rtx (dump_file, loc, 0);
2477 fprintf (dump_file, " evaluates to ");
2478 print_inline_rtx (dump_file, val, 0);
2479 if (v->locs)
2480 {
2481 struct elt_loc_list *l;
2482 for (l = v->locs; l; l = l->next)
2483 {
2484 fprintf (dump_file, "\n%i: ", INSN_UID (l->setting_insn));
2485 print_inline_rtx (dump_file, l->loc, 0);
2486 }
2487 }
2488 fprintf (dump_file, "\n");
2489 }
2490
2491 gcc_checking_assert (!unsuitable_loc (loc));
2492
2493 val_bind (set, val, loc, modified);
2494}
2495
2496/* Clear (canonical address) slots that reference X. */
2497
2498bool
2499local_get_addr_clear_given_value (rtx const &, rtx *slot, rtx x)
2500{
2501 if (vt_get_canonicalize_base (*slot) == x)
2502 *slot = NULL;
2503 return true;
2504}
2505
2506/* Reset this node, detaching all its equivalences. Return the slot
2507 in the variable hash table that holds dv, if there is one. */
2508
2509static void
2510val_reset (dataflow_set *set, decl_or_value dv)
2511{
2512 variable *var = shared_hash_find (set->vars, dv) ;
2513 location_chain *node;
2514 rtx cval;
2515
2516 if (!var || !var->n_var_parts)
2517 return;
2518
2519 gcc_assert (var->n_var_parts == 1);
2520
2521 if (var->onepart == ONEPART_VALUE)
2522 {
2523 rtx x = dv_as_value (dv);
2524
2525 /* Relationships in the global cache don't change, so reset the
2526 local cache entry only. */
2527 rtx *slot = local_get_addr_cache->get (x);
2528 if (slot)
2529 {
2530 /* If the value resolved back to itself, odds are that other
2531 values may have cached it too. These entries now refer
2532 to the old X, so detach them too. Entries that used the
2533 old X but resolved to something else remain ok as long as
2534 that something else isn't also reset. */
2535 if (*slot == x)
2536 local_get_addr_cache
2537 ->traverse<rtx, local_get_addr_clear_given_value> (x);
2538 *slot = NULL;
2539 }
2540 }
2541
2542 cval = NULL;
2543 for (node = var->var_part[0].loc_chain; node; node = node->next)
2544 if (GET_CODE (node->loc) == VALUE
2545 && canon_value_cmp (node->loc, cval))
2546 cval = node->loc;
2547
2548 for (node = var->var_part[0].loc_chain; node; node = node->next)
2549 if (GET_CODE (node->loc) == VALUE && cval != node->loc)
2550 {
2551 /* Redirect the equivalence link to the new canonical
2552 value, or simply remove it if it would point at
2553 itself. */
2554 if (cval)
2555 set_variable_part (set, cval, dv_from_value (node->loc),
2556 0, node->init, node->set_src, NO_INSERT);
2557 delete_variable_part (set, dv_as_value (dv),
2558 dv_from_value (node->loc), 0);
2559 }
2560
2561 if (cval)
2562 {
2563 decl_or_value cdv = dv_from_value (cval);
2564
2565 /* Keep the remaining values connected, accumulating links
2566 in the canonical value. */
2567 for (node = var->var_part[0].loc_chain; node; node = node->next)
2568 {
2569 if (node->loc == cval)
2570 continue;
2571 else if (GET_CODE (node->loc) == REG)
2572 var_reg_decl_set (set, node->loc, node->init, cdv, 0,
2573 node->set_src, NO_INSERT);
2574 else if (GET_CODE (node->loc) == MEM)
2575 var_mem_decl_set (set, node->loc, node->init, cdv, 0,
2576 node->set_src, NO_INSERT);
2577 else
2578 set_variable_part (set, node->loc, cdv, 0,
2579 node->init, node->set_src, NO_INSERT);
2580 }
2581 }
2582
2583 /* We remove this last, to make sure that the canonical value is not
2584 removed to the point of requiring reinsertion. */
2585 if (cval)
2586 delete_variable_part (set, dv_as_value (dv), dv_from_value (cval), 0);
2587
2588 clobber_variable_part (set, NULL, dv, 0, NULL);
2589}
2590
2591/* Find the values in a given location and map the val to another
2592 value, if it is unique, or add the location as one holding the
2593 value. */
2594
2595static void
2596val_resolve (dataflow_set *set, rtx val, rtx loc, rtx_insn *insn)
2597{
2598 decl_or_value dv = dv_from_value (val);
2599
2600 if (dump_file && (dump_flags & TDF_DETAILS))
2601 {
2602 if (insn)
2603 fprintf (dump_file, "%i: ", INSN_UID (insn));
2604 else
2605 fprintf (dump_file, "head: ");
2606 print_inline_rtx (dump_file, val, 0);
2607 fputs (" is at ", dump_file);
2608 print_inline_rtx (dump_file, loc, 0);
2609 fputc ('\n', dump_file);
2610 }
2611
2612 val_reset (set, dv);
2613
2614 gcc_checking_assert (!unsuitable_loc (loc));
2615
2616 if (REG_P (loc))
2617 {
2618 attrs *node, *found = NULL;
2619
2620 for (node = set->regs[REGNO (loc)]; node; node = node->next)
2621 if (dv_is_value_p (node->dv)
2622 && GET_MODE (dv_as_value (node->dv)) == GET_MODE (loc))
2623 {
2624 found = node;
2625
2626 /* Map incoming equivalences. ??? Wouldn't it be nice if
2627 we just started sharing the location lists? Maybe a
2628 circular list ending at the value itself or some
2629 such. */
2630 set_variable_part (set, dv_as_value (node->dv),
2631 dv_from_value (val), node->offset,
2632 VAR_INIT_STATUS_INITIALIZED, NULL_RTX, INSERT);
2633 set_variable_part (set, val, node->dv, node->offset,
2634 VAR_INIT_STATUS_INITIALIZED, NULL_RTX, INSERT);
2635 }
2636
2637 /* If we didn't find any equivalence, we need to remember that
2638 this value is held in the named register. */
2639 if (found)
2640 return;
2641 }
2642 /* ??? Attempt to find and merge equivalent MEMs or other
2643 expressions too. */
2644
2645 val_bind (set, val, loc, false);
2646}
2647
2648/* Initialize dataflow set SET to be empty.
2649 VARS_SIZE is the initial size of hash table VARS. */
2650
2651static void
2652dataflow_set_init (dataflow_set *set)
2653{
2654 init_attrs_list_set (set->regs);
2655 set->vars = shared_hash_copy (empty_shared_hash);
2656 set->stack_adjust = 0;
2657 set->traversed_vars = NULL;
2658}
2659
2660/* Delete the contents of dataflow set SET. */
2661
2662static void
2663dataflow_set_clear (dataflow_set *set)
2664{
2665 int i;
2666
2667 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
2668 attrs_list_clear (&set->regs[i]);
2669
2670 shared_hash_destroy (set->vars);
2671 set->vars = shared_hash_copy (empty_shared_hash);
2672}
2673
2674/* Copy the contents of dataflow set SRC to DST. */
2675
2676static void
2677dataflow_set_copy (dataflow_set *dst, dataflow_set *src)
2678{
2679 int i;
2680
2681 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
2682 attrs_list_copy (&dst->regs[i], src->regs[i]);
2683
2684 shared_hash_destroy (dst->vars);
2685 dst->vars = shared_hash_copy (src->vars);
2686 dst->stack_adjust = src->stack_adjust;
2687}
2688
2689/* Information for merging lists of locations for a given offset of variable.
2690 */
2691struct variable_union_info
2692{
2693 /* Node of the location chain. */
2694 location_chain *lc;
2695
2696 /* The sum of positions in the input chains. */
2697 int pos;
2698
2699 /* The position in the chain of DST dataflow set. */
2700 int pos_dst;
2701};
2702
2703/* Buffer for location list sorting and its allocated size. */
2704static struct variable_union_info *vui_vec;
2705static int vui_allocated;
2706
2707/* Compare function for qsort, order the structures by POS element. */
2708
2709static int
2710variable_union_info_cmp_pos (const void *n1, const void *n2)
2711{
2712 const struct variable_union_info *const i1 =
2713 (const struct variable_union_info *) n1;
2714 const struct variable_union_info *const i2 =
2715 ( const struct variable_union_info *) n2;
2716
2717 if (i1->pos != i2->pos)
2718 return i1->pos - i2->pos;
2719
2720 return (i1->pos_dst - i2->pos_dst);
2721}
2722
2723/* Compute union of location parts of variable *SLOT and the same variable
2724 from hash table DATA. Compute "sorted" union of the location chains
2725 for common offsets, i.e. the locations of a variable part are sorted by
2726 a priority where the priority is the sum of the positions in the 2 chains
2727 (if a location is only in one list the position in the second list is
2728 defined to be larger than the length of the chains).
2729 When we are updating the location parts the newest location is in the
2730 beginning of the chain, so when we do the described "sorted" union
2731 we keep the newest locations in the beginning. */
2732
2733static int
2734variable_union (variable *src, dataflow_set *set)
2735{
2736 variable *dst;
2737 variable **dstp;
2738 int i, j, k;
2739
2740 dstp = shared_hash_find_slot (set->vars, src->dv);
2741 if (!dstp || !*dstp)
2742 {
2743 src->refcount++;
2744
2745 dst_can_be_shared = false;
2746 if (!dstp)
2747 dstp = shared_hash_find_slot_unshare (&set->vars, src->dv, INSERT);
2748
2749 *dstp = src;
2750
2751 /* Continue traversing the hash table. */
2752 return 1;
2753 }
2754 else
2755 dst = *dstp;
2756
2757 gcc_assert (src->n_var_parts);
2758 gcc_checking_assert (src->onepart == dst->onepart);
2759
2760 /* We can combine one-part variables very efficiently, because their
2761 entries are in canonical order. */
2762 if (src->onepart)
2763 {
2764 location_chain **nodep, *dnode, *snode;
2765
2766 gcc_assert (src->n_var_parts == 1
2767 && dst->n_var_parts == 1);
2768
2769 snode = src->var_part[0].loc_chain;
2770 gcc_assert (snode);
2771
2772 restart_onepart_unshared:
2773 nodep = &dst->var_part[0].loc_chain;
2774 dnode = *nodep;
2775 gcc_assert (dnode);
2776
2777 while (snode)
2778 {
2779 int r = dnode ? loc_cmp (dnode->loc, snode->loc) : 1;
2780
2781 if (r > 0)
2782 {
2783 location_chain *nnode;
2784
2785 if (shared_var_p (dst, set->vars))
2786 {
2787 dstp = unshare_variable (set, dstp, dst,
2788 VAR_INIT_STATUS_INITIALIZED);
2789 dst = *dstp;
2790 goto restart_onepart_unshared;
2791 }
2792
2793 *nodep = nnode = new location_chain;
2794 nnode->loc = snode->loc;
2795 nnode->init = snode->init;
2796 if (!snode->set_src || MEM_P (snode->set_src))
2797 nnode->set_src = NULL;
2798 else
2799 nnode->set_src = snode->set_src;
2800 nnode->next = dnode;
2801 dnode = nnode;
2802 }
2803 else if (r == 0)
2804 gcc_checking_assert (rtx_equal_p (dnode->loc, snode->loc));
2805
2806 if (r >= 0)
2807 snode = snode->next;
2808
2809 nodep = &dnode->next;
2810 dnode = *nodep;
2811 }
2812
2813 return 1;
2814 }
2815
2816 gcc_checking_assert (!src->onepart);
2817
2818 /* Count the number of location parts, result is K. */
2819 for (i = 0, j = 0, k = 0;
2820 i < src->n_var_parts && j < dst->n_var_parts; k++)
2821 {
2822 if (VAR_PART_OFFSET (src, i) == VAR_PART_OFFSET (dst, j))
2823 {
2824 i++;
2825 j++;
2826 }
2827 else if (VAR_PART_OFFSET (src, i) < VAR_PART_OFFSET (dst, j))
2828 i++;
2829 else
2830 j++;
2831 }
2832 k += src->n_var_parts - i;
2833 k += dst->n_var_parts - j;
2834
2835 /* We track only variables whose size is <= MAX_VAR_PARTS bytes
2836 thus there are at most MAX_VAR_PARTS different offsets. */
2837 gcc_checking_assert (dst->onepart ? k == 1 : k <= MAX_VAR_PARTS);
2838
2839 if (dst->n_var_parts != k && shared_var_p (dst, set->vars))
2840 {
2841 dstp = unshare_variable (set, dstp, dst, VAR_INIT_STATUS_UNKNOWN);
2842 dst = *dstp;
2843 }
2844
2845 i = src->n_var_parts - 1;
2846 j = dst->n_var_parts - 1;
2847 dst->n_var_parts = k;
2848
2849 for (k--; k >= 0; k--)
2850 {
2851 location_chain *node, *node2;
2852
2853 if (i >= 0 && j >= 0
2854 && VAR_PART_OFFSET (src, i) == VAR_PART_OFFSET (dst, j))
2855 {
2856 /* Compute the "sorted" union of the chains, i.e. the locations which
2857 are in both chains go first, they are sorted by the sum of
2858 positions in the chains. */
2859 int dst_l, src_l;
2860 int ii, jj, n;
2861 struct variable_union_info *vui;
2862
2863 /* If DST is shared compare the location chains.
2864 If they are different we will modify the chain in DST with
2865 high probability so make a copy of DST. */
2866 if (shared_var_p (dst, set->vars))
2867 {
2868 for (node = src->var_part[i].loc_chain,
2869 node2 = dst->var_part[j].loc_chain; node && node2;
2870 node = node->next, node2 = node2->next)
2871 {
2872 if (!((REG_P (node2->loc)
2873 && REG_P (node->loc)
2874 && REGNO (node2->loc) == REGNO (node->loc))
2875 || rtx_equal_p (node2->loc, node->loc)))
2876 {
2877 if (node2->init < node->init)
2878 node2->init = node->init;
2879 break;
2880 }
2881 }
2882 if (node || node2)
2883 {
2884 dstp = unshare_variable (set, dstp, dst,
2885 VAR_INIT_STATUS_UNKNOWN);
2886 dst = (variable *)*dstp;
2887 }
2888 }
2889
2890 src_l = 0;
2891 for (node = src->var_part[i].loc_chain; node; node = node->next)
2892 src_l++;
2893 dst_l = 0;
2894 for (node = dst->var_part[j].loc_chain; node; node = node->next)
2895 dst_l++;
2896
2897 if (dst_l == 1)
2898 {
2899 /* The most common case, much simpler, no qsort is needed. */
2900 location_chain *dstnode = dst->var_part[j].loc_chain;
2901 dst->var_part[k].loc_chain = dstnode;
2902 VAR_PART_OFFSET (dst, k) = VAR_PART_OFFSET (dst, j);
2903 node2 = dstnode;
2904 for (node = src->var_part[i].loc_chain; node; node = node->next)
2905 if (!((REG_P (dstnode->loc)
2906 && REG_P (node->loc)
2907 && REGNO (dstnode->loc) == REGNO (node->loc))
2908 || rtx_equal_p (dstnode->loc, node->loc)))
2909 {
2910 location_chain *new_node;
2911
2912 /* Copy the location from SRC. */
2913 new_node = new location_chain;
2914 new_node->loc = node->loc;
2915 new_node->init = node->init;
2916 if (!node->set_src || MEM_P (node->set_src))
2917 new_node->set_src = NULL;
2918 else
2919 new_node->set_src = node->set_src;
2920 node2->next = new_node;
2921 node2 = new_node;
2922 }
2923 node2->next = NULL;
2924 }
2925 else
2926 {
2927 if (src_l + dst_l > vui_allocated)
2928 {
2929 vui_allocated = MAX (vui_allocated * 2, src_l + dst_l);
2930 vui_vec = XRESIZEVEC (struct variable_union_info, vui_vec,
2931 vui_allocated);
2932 }
2933 vui = vui_vec;
2934
2935 /* Fill in the locations from DST. */
2936 for (node = dst->var_part[j].loc_chain, jj = 0; node;
2937 node = node->next, jj++)
2938 {
2939 vui[jj].lc = node;
2940 vui[jj].pos_dst = jj;
2941
2942 /* Pos plus value larger than a sum of 2 valid positions. */
2943 vui[jj].pos = jj + src_l + dst_l;
2944 }
2945
2946 /* Fill in the locations from SRC. */
2947 n = dst_l;
2948 for (node = src->var_part[i].loc_chain, ii = 0; node;
2949 node = node->next, ii++)
2950 {
2951 /* Find location from NODE. */
2952 for (jj = 0; jj < dst_l; jj++)
2953 {
2954 if ((REG_P (vui[jj].lc->loc)
2955 && REG_P (node->loc)
2956 && REGNO (vui[jj].lc->loc) == REGNO (node->loc))
2957 || rtx_equal_p (vui[jj].lc->loc, node->loc))
2958 {
2959 vui[jj].pos = jj + ii;
2960 break;
2961 }
2962 }
2963 if (jj >= dst_l) /* The location has not been found. */
2964 {
2965 location_chain *new_node;
2966
2967 /* Copy the location from SRC. */
2968 new_node = new location_chain;
2969 new_node->loc = node->loc;
2970 new_node->init = node->init;
2971 if (!node->set_src || MEM_P (node->set_src))
2972 new_node->set_src = NULL;
2973 else
2974 new_node->set_src = node->set_src;
2975 vui[n].lc = new_node;
2976 vui[n].pos_dst = src_l + dst_l;
2977 vui[n].pos = ii + src_l + dst_l;
2978 n++;
2979 }
2980 }
2981
2982 if (dst_l == 2)
2983 {
2984 /* Special case still very common case. For dst_l == 2
2985 all entries dst_l ... n-1 are sorted, with for i >= dst_l
2986 vui[i].pos == i + src_l + dst_l. */
2987 if (vui[0].pos > vui[1].pos)
2988 {
2989 /* Order should be 1, 0, 2... */
2990 dst->var_part[k].loc_chain = vui[1].lc;
2991 vui[1].lc->next = vui[0].lc;
2992 if (n >= 3)
2993 {
2994 vui[0].lc->next = vui[2].lc;
2995 vui[n - 1].lc->next = NULL;
2996 }
2997 else
2998 vui[0].lc->next = NULL;
2999 ii = 3;
3000 }
3001 else
3002 {
3003 dst->var_part[k].loc_chain = vui[0].lc;
3004 if (n >= 3 && vui[2].pos < vui[1].pos)
3005 {
3006 /* Order should be 0, 2, 1, 3... */
3007 vui[0].lc->next = vui[2].lc;
3008 vui[2].lc->next = vui[1].lc;
3009 if (n >= 4)
3010 {
3011 vui[1].lc->next = vui[3].lc;
3012 vui[n - 1].lc->next = NULL;
3013 }
3014 else
3015 vui[1].lc->next = NULL;
3016 ii = 4;
3017 }
3018 else
3019 {
3020 /* Order should be 0, 1, 2... */
3021 ii = 1;
3022 vui[n - 1].lc->next = NULL;
3023 }
3024 }
3025 for (; ii < n; ii++)
3026 vui[ii - 1].lc->next = vui[ii].lc;
3027 }
3028 else
3029 {
3030 qsort (vui, n, sizeof (struct variable_union_info),
3031 variable_union_info_cmp_pos);
3032
3033 /* Reconnect the nodes in sorted order. */
3034 for (ii = 1; ii < n; ii++)
3035 vui[ii - 1].lc->next = vui[ii].lc;
3036 vui[n - 1].lc->next = NULL;
3037 dst->var_part[k].loc_chain = vui[0].lc;
3038 }
3039
3040 VAR_PART_OFFSET (dst, k) = VAR_PART_OFFSET (dst, j);
3041 }
3042 i--;
3043 j--;
3044 }
3045 else if ((i >= 0 && j >= 0
3046 && VAR_PART_OFFSET (src, i) < VAR_PART_OFFSET (dst, j))
3047 || i < 0)
3048 {
3049 dst->var_part[k] = dst->var_part[j];
3050 j--;
3051 }
3052 else if ((i >= 0 && j >= 0
3053 && VAR_PART_OFFSET (src, i) > VAR_PART_OFFSET (dst, j))
3054 || j < 0)
3055 {
3056 location_chain **nextp;
3057
3058 /* Copy the chain from SRC. */
3059 nextp = &dst->var_part[k].loc_chain;
3060 for (node = src->var_part[i].loc_chain; node; node = node->next)
3061 {
3062 location_chain *new_lc;
3063
3064 new_lc = new location_chain;
3065 new_lc->next = NULL;
3066 new_lc->init = node->init;
3067 if (!node->set_src || MEM_P (node->set_src))
3068 new_lc->set_src = NULL;
3069 else
3070 new_lc->set_src = node->set_src;
3071 new_lc->loc = node->loc;
3072
3073 *nextp = new_lc;
3074 nextp = &new_lc->next;
3075 }
3076
3077 VAR_PART_OFFSET (dst, k) = VAR_PART_OFFSET (src, i);
3078 i--;
3079 }
3080 dst->var_part[k].cur_loc = NULL;
3081 }
3082
3083 if (flag_var_tracking_uninit)
3084 for (i = 0; i < src->n_var_parts && i < dst->n_var_parts; i++)
3085 {
3086 location_chain *node, *node2;
3087 for (node = src->var_part[i].loc_chain; node; node = node->next)
3088 for (node2 = dst->var_part[i].loc_chain; node2; node2 = node2->next)
3089 if (rtx_equal_p (node->loc, node2->loc))
3090 {
3091 if (node->init > node2->init)
3092 node2->init = node->init;
3093 }
3094 }
3095
3096 /* Continue traversing the hash table. */
3097 return 1;
3098}
3099
3100/* Compute union of dataflow sets SRC and DST and store it to DST. */
3101
3102static void
3103dataflow_set_union (dataflow_set *dst, dataflow_set *src)
3104{
3105 int i;
3106
3107 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
3108 attrs_list_union (&dst->regs[i], src->regs[i]);
3109
3110 if (dst->vars == empty_shared_hash)
3111 {
3112 shared_hash_destroy (dst->vars);
3113 dst->vars = shared_hash_copy (src->vars);
3114 }
3115 else
3116 {
3117 variable_iterator_type hi;
3118 variable *var;
3119
3120 FOR_EACH_HASH_TABLE_ELEMENT (*shared_hash_htab (src->vars),
3121 var, variable, hi)
3122 variable_union (var, dst);
3123 }
3124}
3125
3126/* Whether the value is currently being expanded. */
3127#define VALUE_RECURSED_INTO(x) \
3128 (RTL_FLAG_CHECK2 ("VALUE_RECURSED_INTO", (x), VALUE, DEBUG_EXPR)->used)
3129
3130/* Whether no expansion was found, saving useless lookups.
3131 It must only be set when VALUE_CHANGED is clear. */
3132#define NO_LOC_P(x) \
3133 (RTL_FLAG_CHECK2 ("NO_LOC_P", (x), VALUE, DEBUG_EXPR)->return_val)
3134
3135/* Whether cur_loc in the value needs to be (re)computed. */
3136#define VALUE_CHANGED(x) \
3137 (RTL_FLAG_CHECK1 ("VALUE_CHANGED", (x), VALUE)->frame_related)
3138/* Whether cur_loc in the decl needs to be (re)computed. */
3139#define DECL_CHANGED(x) TREE_VISITED (x)
3140
3141/* Record (if NEWV) that DV needs to have its cur_loc recomputed. For
3142 user DECLs, this means they're in changed_variables. Values and
3143 debug exprs may be left with this flag set if no user variable
3144 requires them to be evaluated. */
3145
3146static inline void
3147set_dv_changed (decl_or_value dv, bool newv)
3148{
3149 switch (dv_onepart_p (dv))
3150 {
3151 case ONEPART_VALUE:
3152 if (newv)
3153 NO_LOC_P (dv_as_value (dv)) = false;
3154 VALUE_CHANGED (dv_as_value (dv)) = newv;
3155 break;
3156
3157 case ONEPART_DEXPR:
3158 if (newv)
3159 NO_LOC_P (DECL_RTL_KNOWN_SET (dv_as_decl (dv))) = false;
3160 /* Fall through. */
3161
3162 default:
3163 DECL_CHANGED (dv_as_decl (dv)) = newv;
3164 break;
3165 }
3166}
3167
3168/* Return true if DV needs to have its cur_loc recomputed. */
3169
3170static inline bool
3171dv_changed_p (decl_or_value dv)
3172{
3173 return (dv_is_value_p (dv)
3174 ? VALUE_CHANGED (dv_as_value (dv))
3175 : DECL_CHANGED (dv_as_decl (dv)));
3176}
3177
3178/* Return a location list node whose loc is rtx_equal to LOC, in the
3179 location list of a one-part variable or value VAR, or in that of
3180 any values recursively mentioned in the location lists. VARS must
3181 be in star-canonical form. */
3182
3183static location_chain *
3184find_loc_in_1pdv (rtx loc, variable *var, variable_table_type *vars)
3185{
3186 location_chain *node;
3187 enum rtx_code loc_code;
3188
3189 if (!var)
3190 return NULL;
3191
3192 gcc_checking_assert (var->onepart);
3193
3194 if (!var->n_var_parts)
3195 return NULL;
3196
3197 gcc_checking_assert (loc != dv_as_opaque (var->dv));
3198
3199 loc_code = GET_CODE (loc);
3200 for (node = var->var_part[0].loc_chain; node; node = node->next)
3201 {
3202 decl_or_value dv;
3203 variable *rvar;
3204
3205 if (GET_CODE (node->loc) != loc_code)
3206 {
3207 if (GET_CODE (node->loc) != VALUE)
3208 continue;
3209 }
3210 else if (loc == node->loc)
3211 return node;
3212 else if (loc_code != VALUE)
3213 {
3214 if (rtx_equal_p (loc, node->loc))
3215 return node;
3216 continue;
3217 }
3218
3219 /* Since we're in star-canonical form, we don't need to visit
3220 non-canonical nodes: one-part variables and non-canonical
3221 values would only point back to the canonical node. */
3222 if (dv_is_value_p (var->dv)
3223 && !canon_value_cmp (node->loc, dv_as_value (var->dv)))
3224 {
3225 /* Skip all subsequent VALUEs. */
3226 while (node->next && GET_CODE (node->next->loc) == VALUE)
3227 {
3228 node = node->next;
3229 gcc_checking_assert (!canon_value_cmp (node->loc,
3230 dv_as_value (var->dv)));
3231 if (loc == node->loc)
3232 return node;
3233 }
3234 continue;
3235 }
3236
3237 gcc_checking_assert (node == var->var_part[0].loc_chain);
3238 gcc_checking_assert (!node->next);
3239
3240 dv = dv_from_value (node->loc);
3241 rvar = vars->find_with_hash (dv, dv_htab_hash (dv));
3242 return find_loc_in_1pdv (loc, rvar, vars);
3243 }
3244
3245 /* ??? Gotta look in cselib_val locations too. */
3246
3247 return NULL;
3248}
3249
3250/* Hash table iteration argument passed to variable_merge. */
3251struct dfset_merge
3252{
3253 /* The set in which the merge is to be inserted. */
3254 dataflow_set *dst;
3255 /* The set that we're iterating in. */
3256 dataflow_set *cur;
3257 /* The set that may contain the other dv we are to merge with. */
3258 dataflow_set *src;
3259 /* Number of onepart dvs in src. */
3260 int src_onepart_cnt;
3261};
3262
3263/* Insert LOC in *DNODE, if it's not there yet. The list must be in
3264 loc_cmp order, and it is maintained as such. */
3265
3266static void
3267insert_into_intersection (location_chain **nodep, rtx loc,
3268 enum var_init_status status)
3269{
3270 location_chain *node;
3271 int r;
3272
3273 for (node = *nodep; node; nodep = &node->next, node = *nodep)
3274 if ((r = loc_cmp (node->loc, loc)) == 0)
3275 {
3276 node->init = MIN (node->init, status);
3277 return;
3278 }
3279 else if (r > 0)
3280 break;
3281
3282 node = new location_chain;
3283
3284 node->loc = loc;
3285 node->set_src = NULL;
3286 node->init = status;
3287 node->next = *nodep;
3288 *nodep = node;
3289}
3290
3291/* Insert in DEST the intersection of the locations present in both
3292 S1NODE and S2VAR, directly or indirectly. S1NODE is from a
3293 variable in DSM->cur, whereas S2VAR is from DSM->src. dvar is in
3294 DSM->dst. */
3295
3296static void
3297intersect_loc_chains (rtx val, location_chain **dest, struct dfset_merge *dsm,
3298 location_chain *s1node, variable *s2var)
3299{
3300 dataflow_set *s1set = dsm->cur;
3301 dataflow_set *s2set = dsm->src;
3302 location_chain *found;
3303
3304 if (s2var)
3305 {
3306 location_chain *s2node;
3307
3308 gcc_checking_assert (s2var->onepart);
3309
3310 if (s2var->n_var_parts)
3311 {
3312 s2node = s2var->var_part[0].loc_chain;
3313
3314 for (; s1node && s2node;
3315 s1node = s1node->next, s2node = s2node->next)
3316 if (s1node->loc != s2node->loc)
3317 break;
3318 else if (s1node->loc == val)
3319 continue;
3320 else
3321 insert_into_intersection (dest, s1node->loc,
3322 MIN (s1node->init, s2node->init));
3323 }
3324 }
3325
3326 for (; s1node; s1node = s1node->next)
3327 {
3328 if (s1node->loc == val)
3329 continue;
3330
3331 if ((found = find_loc_in_1pdv (s1node->loc, s2var,
3332 shared_hash_htab (s2set->vars))))
3333 {
3334 insert_into_intersection (dest, s1node->loc,
3335 MIN (s1node->init, found->init));
3336 continue;
3337 }
3338
3339 if (GET_CODE (s1node->loc) == VALUE
3340 && !VALUE_RECURSED_INTO (s1node->loc))
3341 {
3342 decl_or_value dv = dv_from_value (s1node->loc);
3343 variable *svar = shared_hash_find (s1set->vars, dv);
3344 if (svar)
3345 {
3346 if (svar->n_var_parts == 1)
3347 {
3348 VALUE_RECURSED_INTO (s1node->loc) = true;
3349 intersect_loc_chains (val, dest, dsm,
3350 svar->var_part[0].loc_chain,
3351 s2var);
3352 VALUE_RECURSED_INTO (s1node->loc) = false;
3353 }
3354 }
3355 }
3356
3357 /* ??? gotta look in cselib_val locations too. */
3358
3359 /* ??? if the location is equivalent to any location in src,
3360 searched recursively
3361
3362 add to dst the values needed to represent the equivalence
3363
3364 telling whether locations S is equivalent to another dv's
3365 location list:
3366
3367 for each location D in the list
3368
3369 if S and D satisfy rtx_equal_p, then it is present
3370
3371 else if D is a value, recurse without cycles
3372
3373 else if S and D have the same CODE and MODE
3374
3375 for each operand oS and the corresponding oD
3376
3377 if oS and oD are not equivalent, then S an D are not equivalent
3378
3379 else if they are RTX vectors
3380
3381 if any vector oS element is not equivalent to its respective oD,
3382 then S and D are not equivalent
3383
3384 */
3385
3386
3387 }
3388}
3389
3390/* Return -1 if X should be before Y in a location list for a 1-part
3391 variable, 1 if Y should be before X, and 0 if they're equivalent
3392 and should not appear in the list. */
3393
3394static int
3395loc_cmp (rtx x, rtx y)
3396{
3397 int i, j, r;
3398 RTX_CODE code = GET_CODE (x);
3399 const char *fmt;
3400
3401 if (x == y)
3402 return 0;
3403
3404 if (REG_P (x))
3405 {
3406 if (!REG_P (y))
3407 return -1;
3408 gcc_assert (GET_MODE (x) == GET_MODE (y));
3409 if (REGNO (x) == REGNO (y))
3410 return 0;
3411 else if (REGNO (x) < REGNO (y))
3412 return -1;
3413 else
3414 return 1;
3415 }
3416
3417 if (REG_P (y))
3418 return 1;
3419
3420 if (MEM_P (x))
3421 {
3422 if (!MEM_P (y))
3423 return -1;
3424 gcc_assert (GET_MODE (x) == GET_MODE (y));
3425 return loc_cmp (XEXP (x, 0), XEXP (y, 0));
3426 }
3427
3428 if (MEM_P (y))
3429 return 1;
3430
3431 if (GET_CODE (x) == VALUE)
3432 {
3433 if (GET_CODE (y) != VALUE)
3434 return -1;
3435 /* Don't assert the modes are the same, that is true only
3436 when not recursing. (subreg:QI (value:SI 1:1) 0)
3437 and (subreg:QI (value:DI 2:2) 0) can be compared,
3438 even when the modes are different. */
3439 if (canon_value_cmp (x, y))
3440 return -1;
3441 else
3442 return 1;
3443 }
3444
3445 if (GET_CODE (y) == VALUE)
3446 return 1;
3447
3448 /* Entry value is the least preferable kind of expression. */
3449 if (GET_CODE (x) == ENTRY_VALUE)
3450 {
3451 if (GET_CODE (y) != ENTRY_VALUE)
3452 return 1;
3453 gcc_assert (GET_MODE (x) == GET_MODE (y));
3454 return loc_cmp (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
3455 }
3456
3457 if (GET_CODE (y) == ENTRY_VALUE)
3458 return -1;
3459
3460 if (GET_CODE (x) == GET_CODE (y))
3461 /* Compare operands below. */;
3462 else if (GET_CODE (x) < GET_CODE (y))
3463 return -1;
3464 else
3465 return 1;
3466
3467 gcc_assert (GET_MODE (x) == GET_MODE (y));
3468
3469 if (GET_CODE (x) == DEBUG_EXPR)
3470 {
3471 if (DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x))
3472 < DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (y)))
3473 return -1;
3474 gcc_checking_assert (DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x))
3475 > DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (y)));
3476 return 1;
3477 }
3478
3479 fmt = GET_RTX_FORMAT (code);
3480 for (i = 0; i < GET_RTX_LENGTH (code); i++)
3481 switch (fmt[i])
3482 {
3483 case 'w':
3484 if (XWINT (x, i) == XWINT (y, i))
3485 break;
3486 else if (XWINT (x, i) < XWINT (y, i))
3487 return -1;
3488 else
3489 return 1;
3490
3491 case 'n':
3492 case 'i':
3493 if (XINT (x, i) == XINT (y, i))
3494 break;
3495 else if (XINT (x, i) < XINT (y, i))
3496 return -1;
3497 else
3498 return 1;
3499
3500 case 'V':
3501 case 'E':
3502 /* Compare the vector length first. */
3503 if (XVECLEN (x, i) == XVECLEN (y, i))
3504 /* Compare the vectors elements. */;
3505 else if (XVECLEN (x, i) < XVECLEN (y, i))
3506 return -1;
3507 else
3508 return 1;
3509
3510 for (j = 0; j < XVECLEN (x, i); j++)
3511 if ((r = loc_cmp (XVECEXP (x, i, j),
3512 XVECEXP (y, i, j))))
3513 return r;
3514 break;
3515
3516 case 'e':
3517 if ((r = loc_cmp (XEXP (x, i), XEXP (y, i))))
3518 return r;
3519 break;
3520
3521 case 'S':
3522 case 's':
3523 if (XSTR (x, i) == XSTR (y, i))
3524 break;
3525 if (!XSTR (x, i))
3526 return -1;
3527 if (!XSTR (y, i))
3528 return 1;
3529 if ((r = strcmp (XSTR (x, i), XSTR (y, i))) == 0)
3530 break;
3531 else if (r < 0)
3532 return -1;
3533 else
3534 return 1;
3535
3536 case 'u':
3537 /* These are just backpointers, so they don't matter. */
3538 break;
3539
3540 case '0':
3541 case 't':
3542 break;
3543
3544 /* It is believed that rtx's at this level will never
3545 contain anything but integers and other rtx's,
3546 except for within LABEL_REFs and SYMBOL_REFs. */
3547 default:
3548 gcc_unreachable ();
3549 }
3550 if (CONST_WIDE_INT_P (x))
3551 {
3552 /* Compare the vector length first. */
3553 if (CONST_WIDE_INT_NUNITS (x) >= CONST_WIDE_INT_NUNITS (y))
3554 return 1;
3555 else if (CONST_WIDE_INT_NUNITS (x) < CONST_WIDE_INT_NUNITS (y))
3556 return -1;
3557
3558 /* Compare the vectors elements. */;
3559 for (j = CONST_WIDE_INT_NUNITS (x) - 1; j >= 0 ; j--)
3560 {
3561 if (CONST_WIDE_INT_ELT (x, j) < CONST_WIDE_INT_ELT (y, j))
3562 return -1;
3563 if (CONST_WIDE_INT_ELT (x, j) > CONST_WIDE_INT_ELT (y, j))
3564 return 1;
3565 }
3566 }
3567
3568 return 0;
3569}
3570
3571/* Check the order of entries in one-part variables. */
3572
3573int
3574canonicalize_loc_order_check (variable **slot,
3575 dataflow_set *data ATTRIBUTE_UNUSED)
3576{
3577 variable *var = *slot;
3578 location_chain *node, *next;
3579
3580#ifdef ENABLE_RTL_CHECKING
3581 int i;
3582 for (i = 0; i < var->n_var_parts; i++)
3583 gcc_assert (var->var_part[0].cur_loc == NULL);
3584 gcc_assert (!var->in_changed_variables);
3585#endif
3586
3587 if (!var->onepart)
3588 return 1;
3589
3590 gcc_assert (var->n_var_parts == 1);
3591 node = var->var_part[0].loc_chain;
3592 gcc_assert (node);
3593
3594 while ((next = node->next))
3595 {
3596 gcc_assert (loc_cmp (node->loc, next->loc) < 0);
3597 node = next;
3598 }
3599
3600 return 1;
3601}
3602
3603/* Mark with VALUE_RECURSED_INTO values that have neighbors that are
3604 more likely to be chosen as canonical for an equivalence set.
3605 Ensure less likely values can reach more likely neighbors, making
3606 the connections bidirectional. */
3607
3608int
3609canonicalize_values_mark (variable **slot, dataflow_set *set)
3610{
3611 variable *var = *slot;
3612 decl_or_value dv = var->dv;
3613 rtx val;
3614 location_chain *node;
3615
3616 if (!dv_is_value_p (dv))
3617 return 1;
3618
3619 gcc_checking_assert (var->n_var_parts == 1);
3620
3621 val = dv_as_value (dv);
3622
3623 for (node = var->var_part[0].loc_chain; node; node = node->next)
3624 if (GET_CODE (node->loc) == VALUE)
3625 {
3626 if (canon_value_cmp (node->loc, val))
3627 VALUE_RECURSED_INTO (val) = true;
3628 else
3629 {
3630 decl_or_value odv = dv_from_value (node->loc);
3631 variable **oslot;
3632 oslot = shared_hash_find_slot_noinsert (set->vars, odv);
3633
3634 set_slot_part (set, val, oslot, odv, 0,
3635 node->init, NULL_RTX);
3636
3637 VALUE_RECURSED_INTO (node->loc) = true;
3638 }
3639 }
3640
3641 return 1;
3642}
3643
3644/* Remove redundant entries from equivalence lists in onepart
3645 variables, canonicalizing equivalence sets into star shapes. */
3646
3647int
3648canonicalize_values_star (variable **slot, dataflow_set *set)
3649{
3650 variable *var = *slot;
3651 decl_or_value dv = var->dv;
3652 location_chain *node;
3653 decl_or_value cdv;
3654 rtx val, cval;
3655 variable **cslot;
3656 bool has_value;
3657 bool has_marks;
3658
3659 if (!var->onepart)
3660 return 1;
3661
3662 gcc_checking_assert (var->n_var_parts == 1);
3663
3664 if (dv_is_value_p (dv))
3665 {
3666 cval = dv_as_value (dv);
3667 if (!VALUE_RECURSED_INTO (cval))
3668 return 1;
3669 VALUE_RECURSED_INTO (cval) = false;
3670 }
3671 else
3672 cval = NULL_RTX;
3673
3674 restart:
3675 val = cval;
3676 has_value = false;
3677 has_marks = false;
3678
3679 gcc_assert (var->n_var_parts == 1);
3680
3681 for (node = var->var_part[0].loc_chain; node; node = node->next)
3682 if (GET_CODE (node->loc) == VALUE)
3683 {
3684 has_value = true;
3685 if (VALUE_RECURSED_INTO (node->loc))
3686 has_marks = true;
3687 if (canon_value_cmp (node->loc, cval))
3688 cval = node->loc;
3689 }
3690
3691 if (!has_value)
3692 return 1;
3693
3694 if (cval == val)
3695 {
3696 if (!has_marks || dv_is_decl_p (dv))
3697 return 1;
3698
3699 /* Keep it marked so that we revisit it, either after visiting a
3700 child node, or after visiting a new parent that might be
3701 found out. */
3702 VALUE_RECURSED_INTO (val) = true;
3703
3704 for (node = var->var_part[0].loc_chain; node; node = node->next)
3705 if (GET_CODE (node->loc) == VALUE
3706 && VALUE_RECURSED_INTO (node->loc))
3707 {
3708 cval = node->loc;
3709 restart_with_cval:
3710 VALUE_RECURSED_INTO (cval) = false;
3711 dv = dv_from_value (cval);
3712 slot = shared_hash_find_slot_noinsert (set->vars, dv);
3713 if (!slot)
3714 {
3715 gcc_assert (dv_is_decl_p (var->dv));
3716 /* The canonical value was reset and dropped.
3717 Remove it. */
3718 clobber_variable_part (set, NULL, var->dv, 0, NULL);
3719 return 1;
3720 }
3721 var = *slot;
3722 gcc_assert (dv_is_value_p (var->dv));
3723 if (var->n_var_parts == 0)
3724 return 1;
3725 gcc_assert (var->n_var_parts == 1);
3726 goto restart;
3727 }
3728
3729 VALUE_RECURSED_INTO (val) = false;
3730
3731 return 1;
3732 }
3733
3734 /* Push values to the canonical one. */
3735 cdv = dv_from_value (cval);
3736 cslot = shared_hash_find_slot_noinsert (set->vars, cdv);
3737
3738 for (node = var->var_part[0].loc_chain; node; node = node->next)
3739 if (node->loc != cval)
3740 {
3741 cslot = set_slot_part (set, node->loc, cslot, cdv, 0,
3742 node->init, NULL_RTX);
3743 if (GET_CODE (node->loc) == VALUE)
3744 {
3745 decl_or_value ndv = dv_from_value (node->loc);
3746
3747 set_variable_part (set, cval, ndv, 0, node->init, NULL_RTX,
3748 NO_INSERT);
3749
3750 if (canon_value_cmp (node->loc, val))
3751 {
3752 /* If it could have been a local minimum, it's not any more,
3753 since it's now neighbor to cval, so it may have to push
3754 to it. Conversely, if it wouldn't have prevailed over
3755 val, then whatever mark it has is fine: if it was to
3756 push, it will now push to a more canonical node, but if
3757 it wasn't, then it has already pushed any values it might
3758 have to. */
3759 VALUE_RECURSED_INTO (node->loc) = true;
3760 /* Make sure we visit node->loc by ensuring we cval is
3761 visited too. */
3762 VALUE_RECURSED_INTO (cval) = true;
3763 }
3764 else if (!VALUE_RECURSED_INTO (node->loc))
3765 /* If we have no need to "recurse" into this node, it's
3766 already "canonicalized", so drop the link to the old
3767 parent. */
3768 clobber_variable_part (set, cval, ndv, 0, NULL);
3769 }
3770 else if (GET_CODE (node->loc) == REG)
3771 {
3772 attrs *list = set->regs[REGNO (node->loc)], **listp;
3773
3774 /* Change an existing attribute referring to dv so that it
3775 refers to cdv, removing any duplicate this might
3776 introduce, and checking that no previous duplicates
3777 existed, all in a single pass. */
3778
3779 while (list)
3780 {
3781 if (list->offset == 0
3782 && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
3783 || dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
3784 break;
3785
3786 list = list->next;
3787 }
3788
3789 gcc_assert (list);
3790 if (dv_as_opaque (list->dv) == dv_as_opaque (dv))
3791 {
3792 list->dv = cdv;
3793 for (listp = &list->next; (list = *listp); listp = &list->next)
3794 {
3795 if (list->offset)
3796 continue;
3797
3798 if (dv_as_opaque (list->dv) == dv_as_opaque (cdv))
3799 {
3800 *listp = list->next;
3801 delete list;
3802 list = *listp;
3803 break;
3804 }
3805
3806 gcc_assert (dv_as_opaque (list->dv) != dv_as_opaque (dv));
3807 }
3808 }
3809 else if (dv_as_opaque (list->dv) == dv_as_opaque (cdv))
3810 {
3811 for (listp = &list->next; (list = *listp); listp = &list->next)
3812 {
3813 if (list->offset)
3814 continue;
3815
3816 if (dv_as_opaque (list->dv) == dv_as_opaque (dv))
3817 {
3818 *listp = list->next;
3819 delete list;
3820 list = *listp;
3821 break;
3822 }
3823
3824 gcc_assert (dv_as_opaque (list->dv) != dv_as_opaque (cdv));
3825 }
3826 }
3827 else
3828 gcc_unreachable ();
3829
3830 if (flag_checking)
3831 while (list)
3832 {
3833 if (list->offset == 0
3834 && (dv_as_opaque (list->dv) == dv_as_opaque (dv)
3835 || dv_as_opaque (list->dv) == dv_as_opaque (cdv)))
3836 gcc_unreachable ();
3837
3838 list = list->next;
3839 }
3840 }
3841 }
3842
3843 if (val)
3844 set_slot_part (set, val, cslot, cdv, 0,
3845 VAR_INIT_STATUS_INITIALIZED, NULL_RTX);
3846
3847 slot = clobber_slot_part (set, cval, slot, 0, NULL);
3848
3849 /* Variable may have been unshared. */
3850 var = *slot;
3851 gcc_checking_assert (var->n_var_parts && var->var_part[0].loc_chain->loc == cval
3852 && var->var_part[0].loc_chain->next == NULL);
3853
3854 if (VALUE_RECURSED_INTO (cval))
3855 goto restart_with_cval;
3856
3857 return 1;
3858}
3859
3860/* Bind one-part variables to the canonical value in an equivalence
3861 set. Not doing this causes dataflow convergence failure in rare
3862 circumstances, see PR42873. Unfortunately we can't do this
3863 efficiently as part of canonicalize_values_star, since we may not
3864 have determined or even seen the canonical value of a set when we
3865 get to a variable that references another member of the set. */
3866
3867int
3868canonicalize_vars_star (variable **slot, dataflow_set *set)
3869{
3870 variable *var = *slot;
3871 decl_or_value dv = var->dv;
3872 location_chain *node;
3873 rtx cval;
3874 decl_or_value cdv;
3875 variable **cslot;
3876 variable *cvar;
3877 location_chain *cnode;
3878
3879 if (!var->onepart || var->onepart == ONEPART_VALUE)
3880 return 1;
3881
3882 gcc_assert (var->n_var_parts == 1);
3883
3884 node = var->var_part[0].loc_chain;
3885
3886 if (GET_CODE (node->loc) != VALUE)
3887 return 1;
3888
3889 gcc_assert (!node->next);
3890 cval = node->loc;
3891
3892 /* Push values to the canonical one. */
3893 cdv = dv_from_value (cval);
3894 cslot = shared_hash_find_slot_noinsert (set->vars, cdv);
3895 if (!cslot)
3896 return 1;
3897 cvar = *cslot;
3898 gcc_assert (cvar->n_var_parts == 1);
3899
3900 cnode = cvar->var_part[0].loc_chain;
3901
3902 /* CVAL is canonical if its value list contains non-VALUEs or VALUEs
3903 that are not “more canonical” than it. */
3904 if (GET_CODE (cnode->loc) != VALUE
3905 || !canon_value_cmp (cnode->loc, cval))
3906 return 1;
3907
3908 /* CVAL was found to be non-canonical. Change the variable to point
3909 to the canonical VALUE. */
3910 gcc_assert (!cnode->next);
3911 cval = cnode->loc;
3912
3913 slot = set_slot_part (set, cval, slot, dv, 0,
3914 node->init, node->set_src);
3915 clobber_slot_part (set, cval, slot, 0, node->set_src);
3916
3917 return 1;
3918}
3919
3920/* Combine variable or value in *S1SLOT (in DSM->cur) with the
3921 corresponding entry in DSM->src. Multi-part variables are combined
3922 with variable_union, whereas onepart dvs are combined with
3923 intersection. */
3924
3925static int
3926variable_merge_over_cur (variable *s1var, struct dfset_merge *dsm)
3927{
3928 dataflow_set *dst = dsm->dst;
3929 variable **dstslot;
3930 variable *s2var, *dvar = NULL;
3931 decl_or_value dv = s1var->dv;
3932 onepart_enum onepart = s1var->onepart;
3933 rtx val;
3934 hashval_t dvhash;
3935 location_chain *node, **nodep;
3936
3937 /* If the incoming onepart variable has an empty location list, then
3938 the intersection will be just as empty. For other variables,
3939 it's always union. */
3940 gcc_checking_assert (s1var->n_var_parts
3941 && s1var->var_part[0].loc_chain);
3942
3943 if (!onepart)
3944 return variable_union (s1var, dst);
3945
3946 gcc_checking_assert (s1var->n_var_parts == 1);
3947
3948 dvhash = dv_htab_hash (dv);
3949 if (dv_is_value_p (dv))
3950 val = dv_as_value (dv);
3951 else
3952 val = NULL;
3953
3954 s2var = shared_hash_find_1 (dsm->src->vars, dv, dvhash);
3955 if (!s2var)
3956 {
3957 dst_can_be_shared = false;
3958 return 1;
3959 }
3960
3961 dsm->src_onepart_cnt--;
3962 gcc_assert (s2var->var_part[0].loc_chain
3963 && s2var->onepart == onepart
3964 && s2var->n_var_parts == 1);
3965
3966 dstslot = shared_hash_find_slot_noinsert_1 (dst->vars, dv, dvhash);
3967 if (dstslot)
3968 {
3969 dvar = *dstslot;
3970 gcc_assert (dvar->refcount == 1
3971 && dvar->onepart == onepart
3972 && dvar->n_var_parts == 1);
3973 nodep = &dvar->var_part[0].loc_chain;
3974 }
3975 else
3976 {
3977 nodep = &node;
3978 node = NULL;
3979 }
3980
3981 if (!dstslot && !onepart_variable_different_p (s1var, s2var))
3982 {
3983 dstslot = shared_hash_find_slot_unshare_1 (&dst->vars, dv,
3984 dvhash, INSERT);
3985 *dstslot = dvar = s2var;
3986 dvar->refcount++;
3987 }
3988 else
3989 {
3990 dst_can_be_shared = false;
3991
3992 intersect_loc_chains (val, nodep, dsm,
3993 s1var->var_part[0].loc_chain, s2var);
3994
3995 if (!dstslot)
3996 {
3997 if (node)
3998 {
3999 dvar = onepart_pool_allocate (onepart);
4000 dvar->dv = dv;
4001 dvar->refcount = 1;
4002 dvar->n_var_parts = 1;
4003 dvar->onepart = onepart;
4004 dvar->in_changed_variables = false;
4005 dvar->var_part[0].loc_chain = node;
4006 dvar->var_part[0].cur_loc = NULL;
4007 if (onepart)
4008 VAR_LOC_1PAUX (dvar) = NULL;
4009 else
4010 VAR_PART_OFFSET (dvar, 0) = 0;
4011
4012 dstslot
4013 = shared_hash_find_slot_unshare_1 (&dst->vars, dv, dvhash,
4014 INSERT);
4015 gcc_assert (!*dstslot);
4016 *dstslot = dvar;
4017 }
4018 else
4019 return 1;
4020 }
4021 }
4022
4023 nodep = &dvar->var_part[0].loc_chain;
4024 while ((node = *nodep))
4025 {
4026 location_chain **nextp = &node->next;
4027
4028 if (GET_CODE (node->loc) == REG)
4029 {
4030 attrs *list;
4031
4032 for (list = dst->regs[REGNO (node->loc)]; list; list = list->next)
4033 if (GET_MODE (node->loc) == GET_MODE (list->loc)
4034 && dv_is_value_p (list->dv))
4035 break;
4036
4037 if (!list)
4038 attrs_list_insert (&dst->regs[REGNO (node->loc)],
4039 dv, 0, node->loc);
4040 /* If this value became canonical for another value that had
4041 this register, we want to leave it alone. */
4042 else if (dv_as_value (list->dv) != val)
4043 {
4044 dstslot = set_slot_part (dst, dv_as_value (list->dv),
4045 dstslot, dv, 0,
4046 node->init, NULL_RTX);
4047 dstslot = delete_slot_part (dst, node->loc, dstslot, 0);
4048
4049 /* Since nextp points into the removed node, we can't
4050 use it. The pointer to the next node moved to nodep.
4051 However, if the variable we're walking is unshared
4052 during our walk, we'll keep walking the location list
4053 of the previously-shared variable, in which case the
4054 node won't have been removed, and we'll want to skip
4055 it. That's why we test *nodep here. */
4056 if (*nodep != node)
4057 nextp = nodep;
4058 }
4059 }
4060 else
4061 /* Canonicalization puts registers first, so we don't have to
4062 walk it all. */
4063 break;
4064 nodep = nextp;
4065 }
4066
4067 if (dvar != *dstslot)
4068 dvar = *dstslot;
4069 nodep = &dvar->var_part[0].loc_chain;
4070
4071 if (val)
4072 {
4073 /* Mark all referenced nodes for canonicalization, and make sure
4074 we have mutual equivalence links. */
4075 VALUE_RECURSED_INTO (val) = true;
4076 for (node = *nodep; node; node = node->next)
4077 if (GET_CODE (node->loc) == VALUE)
4078 {
4079 VALUE_RECURSED_INTO (node->loc) = true;
4080 set_variable_part (dst, val, dv_from_value (node->loc), 0,
4081 node->init, NULL, INSERT);
4082 }
4083
4084 dstslot = shared_hash_find_slot_noinsert_1 (dst->vars, dv, dvhash);
4085 gcc_assert (*dstslot == dvar);
4086 canonicalize_values_star (dstslot, dst);
4087 gcc_checking_assert (dstslot
4088 == shared_hash_find_slot_noinsert_1 (dst->vars,
4089 dv, dvhash));
4090 dvar = *dstslot;
4091 }
4092 else
4093 {
4094 bool has_value = false, has_other = false;
4095
4096 /* If we have one value and anything else, we're going to
4097 canonicalize this, so make sure all values have an entry in
4098 the table and are marked for canonicalization. */
4099 for (node = *nodep; node; node = node->next)
4100 {
4101 if (GET_CODE (node->loc) == VALUE)
4102 {
4103 /* If this was marked during register canonicalization,
4104 we know we have to canonicalize values. */
4105 if (has_value)
4106 has_other = true;
4107 has_value = true;
4108 if (has_other)
4109 break;
4110 }
4111 else
4112 {
4113 has_other = true;
4114 if (has_value)
4115 break;
4116 }
4117 }
4118
4119 if (has_value && has_other)
4120 {
4121 for (node = *nodep; node; node = node->next)
4122 {
4123 if (GET_CODE (node->loc) == VALUE)
4124 {
4125 decl_or_value dv = dv_from_value (node->loc);
4126 variable **slot = NULL;
4127
4128 if (shared_hash_shared (dst->vars))
4129 slot = shared_hash_find_slot_noinsert (dst->vars, dv);
4130 if (!slot)
4131 slot = shared_hash_find_slot_unshare (&dst->vars, dv,
4132 INSERT);
4133 if (!*slot)
4134 {
4135 variable *var = onepart_pool_allocate (ONEPART_VALUE);
4136 var->dv = dv;
4137 var->refcount = 1;
4138 var->n_var_parts = 1;
4139 var->onepart = ONEPART_VALUE;
4140 var->in_changed_variables = false;
4141 var->var_part[0].loc_chain = NULL;
4142 var->var_part[0].cur_loc = NULL;
4143 VAR_LOC_1PAUX (var) = NULL;
4144 *slot = var;
4145 }
4146
4147 VALUE_RECURSED_INTO (node->loc) = true;
4148 }
4149 }
4150
4151 dstslot = shared_hash_find_slot_noinsert_1 (dst->vars, dv, dvhash);
4152 gcc_assert (*dstslot == dvar);
4153 canonicalize_values_star (dstslot, dst);
4154 gcc_checking_assert (dstslot
4155 == shared_hash_find_slot_noinsert_1 (dst->vars,
4156 dv, dvhash));
4157 dvar = *dstslot;
4158 }
4159 }
4160
4161 if (!onepart_variable_different_p (dvar, s2var))
4162 {
4163 variable_htab_free (dvar);
4164 *dstslot = dvar = s2var;
4165 dvar->refcount++;
4166 }
4167 else if (s2var != s1var && !onepart_variable_different_p (dvar, s1var))
4168 {
4169 variable_htab_free (dvar);
4170 *dstslot = dvar = s1var;
4171 dvar->refcount++;
4172 dst_can_be_shared = false;
4173 }
4174 else
4175 dst_can_be_shared = false;
4176
4177 return 1;
4178}
4179
4180/* Copy s2slot (in DSM->src) to DSM->dst if the variable is a
4181 multi-part variable. Unions of multi-part variables and
4182 intersections of one-part ones will be handled in
4183 variable_merge_over_cur(). */
4184
4185static int
4186variable_merge_over_src (variable *s2var, struct dfset_merge *dsm)
4187{
4188 dataflow_set *dst = dsm->dst;
4189 decl_or_value dv = s2var->dv;
4190
4191 if (!s2var->onepart)
4192 {
4193 variable **dstp = shared_hash_find_slot (dst->vars, dv);
4194 *dstp = s2var;
4195 s2var->refcount++;
4196 return 1;
4197 }
4198
4199 dsm->src_onepart_cnt++;
4200 return 1;
4201}
4202
4203/* Combine dataflow set information from SRC2 into DST, using PDST
4204 to carry over information across passes. */
4205
4206static void
4207dataflow_set_merge (dataflow_set *dst, dataflow_set *src2)
4208{
4209 dataflow_set