LCOV - code coverage report
Current view: top level - gcc - var-tracking.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 91.8 % 4746 4355
Test Date: 2026-09-19 16:22:48 Functions: 98.3 % 179 176
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Variable tracking routines for the GNU compiler.
       2              :    Copyright (C) 2002-2026 Free Software Foundation, Inc.
       3              : 
       4              :    This file is part of GCC.
       5              : 
       6              :    GCC is free software; you can redistribute it and/or modify it
       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 "ira.h"
     111              : #include "lra.h"
     112              : #include "calls.h"
     113              : #include "tree-dfa.h"
     114              : #include "tree-ssa.h"
     115              : #include "cselib.h"
     116              : #include "tree-pretty-print.h"
     117              : #include "rtl-iter.h"
     118              : #include "fibonacci_heap.h"
     119              : #include "print-rtl.h"
     120              : #include "function-abi.h"
     121              : #include "mux-utils.h"
     122              : 
     123              : typedef fibonacci_heap <long, basic_block_def> bb_heap_t;
     124              : 
     125              : /* var-tracking.cc assumes that tree code with the same value as VALUE rtx code
     126              :    has no chance to appear in REG_EXPR/MEM_EXPRs and isn't a decl.
     127              :    Currently the value is the same as IDENTIFIER_NODE, which has such
     128              :    a property.  If this compile time assertion ever fails, make sure that
     129              :    the new tree code that equals (int) VALUE has the same property.  */
     130              : extern char check_value_val[(int) VALUE == (int) IDENTIFIER_NODE ? 1 : -1];
     131              : 
     132              : /* Type of micro operation.  */
     133              : enum micro_operation_type
     134              : {
     135              :   MO_USE,       /* Use location (REG or MEM).  */
     136              :   MO_USE_NO_VAR,/* Use location which is not associated with a variable
     137              :                    or the variable is not trackable.  */
     138              :   MO_VAL_USE,   /* Use location which is associated with a value.  */
     139              :   MO_VAL_LOC,   /* Use location which appears in a debug insn.  */
     140              :   MO_VAL_SET,   /* Set location associated with a value.  */
     141              :   MO_SET,       /* Set location.  */
     142              :   MO_COPY,      /* Copy the same portion of a variable from one
     143              :                    location to another.  */
     144              :   MO_CLOBBER,   /* Clobber location.  */
     145              :   MO_CALL,      /* Call insn.  */
     146              :   MO_ADJUST     /* Adjust stack pointer.  */
     147              : 
     148              : };
     149              : 
     150              : static const char * const ATTRIBUTE_UNUSED
     151              : micro_operation_type_name[] = {
     152              :   "MO_USE",
     153              :   "MO_USE_NO_VAR",
     154              :   "MO_VAL_USE",
     155              :   "MO_VAL_LOC",
     156              :   "MO_VAL_SET",
     157              :   "MO_SET",
     158              :   "MO_COPY",
     159              :   "MO_CLOBBER",
     160              :   "MO_CALL",
     161              :   "MO_ADJUST"
     162              : };
     163              : 
     164              : /* Where shall the note be emitted?  BEFORE or AFTER the instruction.
     165              :    Notes emitted as AFTER_CALL are to take effect during the call,
     166              :    rather than after the call.  */
     167              : enum emit_note_where
     168              : {
     169              :   EMIT_NOTE_BEFORE_INSN,
     170              :   EMIT_NOTE_AFTER_INSN,
     171              :   EMIT_NOTE_AFTER_CALL_INSN
     172              : };
     173              : 
     174              : /* Structure holding information about micro operation.  */
     175              : struct micro_operation
     176              : {
     177              :   /* Type of micro operation.  */
     178              :   enum micro_operation_type type;
     179              : 
     180              :   /* The instruction which the micro operation is in, for MO_USE,
     181              :      MO_USE_NO_VAR, MO_CALL and MO_ADJUST, or the subsequent
     182              :      instruction or note in the original flow (before any var-tracking
     183              :      notes are inserted, to simplify emission of notes), for MO_SET
     184              :      and MO_CLOBBER.  */
     185              :   rtx_insn *insn;
     186              : 
     187              :   union {
     188              :     /* Location.  For MO_SET and MO_COPY, this is the SET that
     189              :        performs the assignment, if known, otherwise it is the target
     190              :        of the assignment.  For MO_VAL_USE and MO_VAL_SET, it is a
     191              :        CONCAT of the VALUE and the LOC associated with it.  For
     192              :        MO_VAL_LOC, it is a CONCAT of the VALUE and the VAR_LOCATION
     193              :        associated with it.  */
     194              :     rtx loc;
     195              : 
     196              :     /* Stack adjustment.  */
     197              :     HOST_WIDE_INT adjust;
     198              :   } u;
     199              : };
     200              : 
     201              : 
     202              : /* A declaration of a variable, or an RTL value being handled like a
     203              :    declaration by pointer_mux.  */
     204              : typedef pointer_mux<tree_node, rtx_def> decl_or_value;
     205              : 
     206              : /* Return true if a decl_or_value DV is a DECL or NULL.  */
     207              : static inline bool
     208  49674713773 : dv_is_decl_p (decl_or_value dv)
     209              : {
     210  41183168211 :   return dv.is_first ();
     211              : }
     212              : 
     213              : /* Return true if a decl_or_value is a VALUE rtl.  */
     214              : static inline bool
     215  41254125155 : dv_is_value_p (decl_or_value dv)
     216              : {
     217  41254125155 :   return dv && !dv_is_decl_p (dv);
     218              : }
     219              : 
     220              : /* Return the decl in the decl_or_value.  */
     221              : static inline tree
     222   7979537850 : dv_as_decl (decl_or_value dv)
     223              : {
     224   7979537850 :   gcc_checking_assert (dv_is_decl_p (dv));
     225   7979537850 :   return dv.known_first ();
     226              : }
     227              : 
     228              : /* Return the value in the decl_or_value.  */
     229              : static inline rtx
     230  15997687403 : dv_as_value (decl_or_value dv)
     231              : {
     232  15997687403 :   gcc_checking_assert (dv_is_value_p (dv));
     233  15997687403 :   return dv.known_second ();
     234              : }
     235              : 
     236              : 
     237              : /* Description of location of a part of a variable.  The content of a physical
     238              :    register is described by a chain of these structures.
     239              :    The chains are pretty short (usually 1 or 2 elements) and thus
     240              :    chain is the best data structure.  */
     241              : struct attrs
     242              : {
     243              :   /* Pointer to next member of the list.  */
     244              :   attrs *next;
     245              : 
     246              :   /* The rtx of register.  */
     247              :   rtx loc;
     248              : 
     249              :   /* The declaration corresponding to LOC.  */
     250              :   decl_or_value dv;
     251              : 
     252              :   /* Offset from start of DECL.  */
     253              :   HOST_WIDE_INT offset;
     254              : };
     255              : 
     256              : /* Structure for chaining the locations.  */
     257              : struct location_chain
     258              : {
     259              :   /* Next element in the chain.  */
     260              :   location_chain *next;
     261              : 
     262              :   /* The location (REG, MEM or VALUE).  */
     263              :   rtx loc;
     264              : 
     265              :   /* The "value" stored in this location.  */
     266              :   rtx set_src;
     267              : 
     268              :   /* Initialized? */
     269              :   enum var_init_status init;
     270              : };
     271              : 
     272              : /* A vector of loc_exp_dep holds the active dependencies of a one-part
     273              :    DV on VALUEs, i.e., the VALUEs expanded so as to form the current
     274              :    location of DV.  Each entry is also part of VALUE' s linked-list of
     275              :    backlinks back to DV.  */
     276              : struct loc_exp_dep
     277              : {
     278              :   /* The dependent DV.  */
     279              :   decl_or_value dv;
     280              :   /* The dependency VALUE or DECL_DEBUG.  */
     281              :   rtx value;
     282              :   /* The next entry in VALUE's backlinks list.  */
     283              :   struct loc_exp_dep *next;
     284              :   /* A pointer to the pointer to this entry (head or prev's next) in
     285              :      the doubly-linked list.  */
     286              :   struct loc_exp_dep **pprev;
     287              : };
     288              : 
     289              : 
     290              : /* This data structure holds information about the depth of a variable
     291              :    expansion.  */
     292              : struct expand_depth
     293              : {
     294              :   /* This measures the complexity of the expanded expression.  It
     295              :      grows by one for each level of expansion that adds more than one
     296              :      operand.  */
     297              :   int complexity;
     298              :   /* This counts the number of ENTRY_VALUE expressions in an
     299              :      expansion.  We want to minimize their use.  */
     300              :   int entryvals;
     301              : };
     302              : 
     303              : /* Type for dependencies actively used when expand FROM into cur_loc.  */
     304              : typedef vec<loc_exp_dep, va_heap, vl_embed> deps_vec;
     305              : 
     306              : /* This data structure is allocated for one-part variables at the time
     307              :    of emitting notes.  */
     308              : struct onepart_aux
     309              : {
     310              :   /* Doubly-linked list of dependent DVs.  These are DVs whose cur_loc
     311              :      computation used the expansion of this variable, and that ought
     312              :      to be notified should this variable change.  If the DV's cur_loc
     313              :      expanded to NULL, all components of the loc list are regarded as
     314              :      active, so that any changes in them give us a chance to get a
     315              :      location.  Otherwise, only components of the loc that expanded to
     316              :      non-NULL are regarded as active dependencies.  */
     317              :   loc_exp_dep *backlinks;
     318              :   /* This holds the LOC that was expanded into cur_loc.  We need only
     319              :      mark a one-part variable as changed if the FROM loc is removed,
     320              :      or if it has no known location and a loc is added, or if it gets
     321              :      a change notification from any of its active dependencies.  */
     322              :   rtx from;
     323              :   /* The depth of the cur_loc expression.  */
     324              :   expand_depth depth;
     325              :   /* Dependencies actively used when expand FROM into cur_loc.  */
     326              :   deps_vec deps;
     327              : };
     328              : 
     329              : /* Structure describing one part of variable.  */
     330              : struct variable_part
     331              : {
     332              :   /* Chain of locations of the part.  */
     333              :   location_chain *loc_chain;
     334              : 
     335              :   /* Location which was last emitted to location list.  */
     336              :   rtx cur_loc;
     337              : 
     338              :   union variable_aux
     339              :   {
     340              :     /* The offset in the variable, if !var->onepart.  */
     341              :     HOST_WIDE_INT offset;
     342              : 
     343              :     /* Pointer to auxiliary data, if var->onepart and emit_notes.  */
     344              :     struct onepart_aux *onepaux;
     345              :   } aux;
     346              : };
     347              : 
     348              : /* Maximum number of location parts.  */
     349              : #define MAX_VAR_PARTS 16
     350              : 
     351              : /* Enumeration type used to discriminate various types of one-part
     352              :    variables.  */
     353              : enum onepart_enum
     354              : {
     355              :   /* Not a one-part variable.  */
     356              :   NOT_ONEPART = 0,
     357              :   /* A one-part DECL that is not a DEBUG_EXPR_DECL.  */
     358              :   ONEPART_VDECL = 1,
     359              :   /* A DEBUG_EXPR_DECL.  */
     360              :   ONEPART_DEXPR = 2,
     361              :   /* A VALUE.  */
     362              :   ONEPART_VALUE = 3
     363              : };
     364              : 
     365              : /* Structure describing where the variable is located.  */
     366              : struct variable
     367              : {
     368              :   /* The declaration of the variable, or an RTL value being handled
     369              :      like a declaration.  */
     370              :   decl_or_value dv;
     371              : 
     372              :   /* Reference count.  */
     373              :   int refcount;
     374              : 
     375              :   /* Number of variable parts.  */
     376              :   char n_var_parts;
     377              : 
     378              :   /* What type of DV this is, according to enum onepart_enum.  */
     379              :   enum onepart_enum onepart : CHAR_BIT;
     380              : 
     381              :   /* True if this variable_def struct is currently in the
     382              :      changed_variables hash table.  */
     383              :   bool in_changed_variables;
     384              : 
     385              :   /* The variable parts.  */
     386              :   variable_part var_part[1];
     387              : };
     388              : 
     389              : /* Pointer to the BB's information specific to variable tracking pass.  */
     390              : #define VTI(BB) ((variable_tracking_info *) (BB)->aux)
     391              : 
     392              : /* Return MEM_OFFSET (MEM) as a HOST_WIDE_INT, or 0 if we can't.  */
     393              : 
     394              : static inline HOST_WIDE_INT
     395     21560914 : int_mem_offset (const_rtx mem)
     396              : {
     397     21560914 :   HOST_WIDE_INT offset;
     398     21560916 :   if (MEM_OFFSET_KNOWN_P (mem) && MEM_OFFSET (mem).is_constant (&offset))
     399     18546908 :     return offset;
     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_dep_vec (var)
     436              : 
     437              : /* Implements the VAR_LOC_DEP_VEC above as a function to work around
     438              :    a bogus -Wnonnull (PR c/95554). */
     439              : 
     440              : static inline deps_vec*
     441    727173663 : var_loc_dep_vec (variable *var)
     442              : {
     443    727173663 :   return VAR_LOC_1PAUX (var) ? &VAR_LOC_1PAUX (var)->deps : NULL;
     444              : }
     445              : 
     446              : 
     447              : typedef unsigned int dvuid;
     448              : 
     449              : /* Return the uid of DV.  */
     450              : 
     451              : static inline dvuid
     452  21778630833 : dv_uid (decl_or_value dv)
     453              : {
     454  21778630833 :   if (dv_is_value_p (dv))
     455  14620299183 :     return CSELIB_VAL_UID (dv_as_value (dv));
     456              :   else
     457   7158331650 :     return DECL_UID (dv_as_decl (dv));
     458              : }
     459              : 
     460              : /* Compute the hash from the uid.  */
     461              : 
     462              : static inline hashval_t
     463              : dv_uid2hash (dvuid uid)
     464              : {
     465              :   return uid;
     466              : }
     467              : 
     468              : /* The hash function for a mask table in a shared_htab chain.  */
     469              : 
     470              : static inline hashval_t
     471  21778630833 : dv_htab_hash (decl_or_value dv)
     472              : {
     473  21778630833 :   return dv_uid2hash (dv_uid (dv));
     474              : }
     475              : 
     476              : static void variable_htab_free (void *);
     477              : 
     478              : /* Variable hashtable helpers.  */
     479              : 
     480              : struct variable_hasher : pointer_hash <variable>
     481              : {
     482              :   typedef decl_or_value compare_type;
     483              :   static inline hashval_t hash (const variable *);
     484              :   static inline bool equal (const variable *, const decl_or_value);
     485              :   static inline void remove (variable *);
     486              : };
     487              : 
     488              : /* The hash function for variable_htab, computes the hash value
     489              :    from the declaration of variable X.  */
     490              : 
     491              : inline hashval_t
     492  18117326226 : variable_hasher::hash (const variable *v)
     493              : {
     494  18117326226 :   return dv_htab_hash (v->dv);
     495              : }
     496              : 
     497              : /* Compare the declaration of variable X with declaration Y.  */
     498              : 
     499              : inline bool
     500  21210927885 : variable_hasher::equal (const variable *v, const decl_or_value y)
     501              : {
     502  21210927885 :   return v->dv == y;
     503              : }
     504              : 
     505              : /* Free the element of VARIABLE_HTAB (its type is struct variable_def).  */
     506              : 
     507              : inline void
     508   1167034547 : variable_hasher::remove (variable *var)
     509              : {
     510   1167034547 :   variable_htab_free (var);
     511              : }
     512              : 
     513              : typedef hash_table<variable_hasher> variable_table_type;
     514              : typedef variable_table_type::iterator variable_iterator_type;
     515              : 
     516              : /* Structure for passing some other parameters to function
     517              :    emit_note_insn_var_location.  */
     518              : struct emit_note_data
     519              : {
     520              :   /* The instruction which the note will be emitted before/after.  */
     521              :   rtx_insn *insn;
     522              : 
     523              :   /* Where the note will be emitted (before/after insn)?  */
     524              :   enum emit_note_where where;
     525              : 
     526              :   /* The variables and values active at this point.  */
     527              :   variable_table_type *vars;
     528              : };
     529              : 
     530              : /* Structure holding a refcounted hash table.  If refcount > 1,
     531              :    it must be first unshared before modified.  */
     532              : struct shared_hash
     533              : {
     534              :   /* Reference count.  */
     535              :   int refcount;
     536              : 
     537              :   /* Actual hash table.  */
     538              :   variable_table_type *htab;
     539              : };
     540              : 
     541              : /* Structure holding the IN or OUT set for a basic block.  */
     542              : struct dataflow_set
     543              : {
     544              :   /* Adjustment of stack offset.  */
     545              :   HOST_WIDE_INT stack_adjust;
     546              : 
     547              :   /* Attributes for registers (lists of attrs).  */
     548              :   attrs *regs[FIRST_PSEUDO_REGISTER];
     549              : 
     550              :   /* Variable locations.  */
     551              :   shared_hash *vars;
     552              : 
     553              :   /* Vars that is being traversed.  */
     554              :   shared_hash *traversed_vars;
     555              : };
     556              : 
     557              : /* The structure (one for each basic block) containing the information
     558              :    needed for variable tracking.  */
     559              : struct variable_tracking_info
     560              : {
     561              :   /* The vector of micro operations.  */
     562              :   vec<micro_operation> mos;
     563              : 
     564              :   /* The IN and OUT set for dataflow analysis.  */
     565              :   dataflow_set in;
     566              :   dataflow_set out;
     567              : 
     568              :   /* The permanent-in dataflow set for this block.  This is used to
     569              :      hold values for which we had to compute entry values.  ??? This
     570              :      should probably be dynamically allocated, to avoid using more
     571              :      memory in non-debug builds.  */
     572              :   dataflow_set *permp;
     573              : 
     574              :   /* Has the block been visited in DFS?  */
     575              :   bool visited;
     576              : 
     577              :   /* Has the block been flooded in VTA?  */
     578              :   bool flooded;
     579              : 
     580              : };
     581              : 
     582              : /* Alloc pool for struct attrs_def.  */
     583              : object_allocator<attrs> attrs_pool ("attrs pool");
     584              : 
     585              : /* Alloc pool for struct variable_def with MAX_VAR_PARTS entries.  */
     586              : 
     587              : static pool_allocator var_pool
     588              :   ("variable_def pool", sizeof (variable) +
     589              :    (MAX_VAR_PARTS - 1) * sizeof (((variable *)NULL)->var_part[0]));
     590              : 
     591              : /* Alloc pool for struct variable_def with a single var_part entry.  */
     592              : static pool_allocator valvar_pool
     593              :   ("small variable_def pool", sizeof (variable));
     594              : 
     595              : /* Alloc pool for struct location_chain.  */
     596              : static object_allocator<location_chain> location_chain_pool
     597              :   ("location_chain pool");
     598              : 
     599              : /* Alloc pool for struct shared_hash.  */
     600              : static object_allocator<shared_hash> shared_hash_pool ("shared_hash pool");
     601              : 
     602              : /* Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables.  */
     603              : object_allocator<loc_exp_dep> loc_exp_dep_pool ("loc_exp_dep pool");
     604              : 
     605              : /* Changed variables, notes will be emitted for them.  */
     606              : static variable_table_type *changed_variables;
     607              : 
     608              : /* Shall notes be emitted?  */
     609              : static bool emit_notes;
     610              : 
     611              : /* Values whose dynamic location lists have gone empty, but whose
     612              :    cselib location lists are still usable.  Use this to hold the
     613              :    current location, the backlinks, etc, during emit_notes.  */
     614              : static variable_table_type *dropped_values;
     615              : 
     616              : /* Empty shared hashtable.  */
     617              : static shared_hash *empty_shared_hash;
     618              : 
     619              : /* Scratch register bitmap used by cselib_expand_value_rtx.  */
     620              : static bitmap scratch_regs = NULL;
     621              : 
     622              : #ifdef HAVE_window_save
     623              : struct GTY(()) parm_reg {
     624              :   rtx outgoing;
     625              :   rtx incoming;
     626              : };
     627              : 
     628              : 
     629              : /* Vector of windowed parameter registers, if any.  */
     630              : static vec<parm_reg, va_gc> *windowed_parm_regs = NULL;
     631              : #endif
     632              : 
     633              : /* Variable used to tell whether cselib_process_insn called our hook.  */
     634              : static bool cselib_hook_called;
     635              : 
     636              : /* Local function prototypes.  */
     637              : static void stack_adjust_offset_pre_post (rtx, HOST_WIDE_INT *,
     638              :                                           HOST_WIDE_INT *);
     639              : static void insn_stack_adjust_offset_pre_post (rtx_insn *, HOST_WIDE_INT *,
     640              :                                                HOST_WIDE_INT *);
     641              : static bool vt_stack_adjustments (void);
     642              : 
     643              : static void init_attrs_list_set (attrs **);
     644              : static void attrs_list_clear (attrs **);
     645              : static attrs *attrs_list_member (attrs *, decl_or_value, HOST_WIDE_INT);
     646              : static void attrs_list_insert (attrs **, decl_or_value, HOST_WIDE_INT, rtx);
     647              : static void attrs_list_copy (attrs **, attrs *);
     648              : static void attrs_list_union (attrs **, attrs *);
     649              : 
     650              : static variable **unshare_variable (dataflow_set *set, variable **slot,
     651              :                                         variable *var, enum var_init_status);
     652              : static void vars_copy (variable_table_type *, variable_table_type *);
     653              : static tree var_debug_decl (tree);
     654              : static void var_reg_set (dataflow_set *, rtx, enum var_init_status, rtx);
     655              : static void var_reg_delete_and_set (dataflow_set *, rtx, bool,
     656              :                                     enum var_init_status, rtx);
     657              : static void var_reg_delete (dataflow_set *, rtx, bool);
     658              : static void var_regno_delete (dataflow_set *, int);
     659              : static void var_mem_set (dataflow_set *, rtx, enum var_init_status, rtx);
     660              : static void var_mem_delete_and_set (dataflow_set *, rtx, bool,
     661              :                                     enum var_init_status, rtx);
     662              : static void var_mem_delete (dataflow_set *, rtx, bool);
     663              : 
     664              : static void dataflow_set_init (dataflow_set *);
     665              : static void dataflow_set_clear (dataflow_set *);
     666              : static void dataflow_set_copy (dataflow_set *, dataflow_set *);
     667              : static int variable_union_info_cmp_pos (const void *, const void *);
     668              : static void dataflow_set_union (dataflow_set *, dataflow_set *);
     669              : static location_chain *find_loc_in_1pdv (rtx, variable *,
     670              :                                          variable_table_type *);
     671              : static bool canon_value_cmp (rtx, rtx);
     672              : static int loc_cmp (rtx, rtx);
     673              : static bool variable_part_different_p (variable_part *, variable_part *);
     674              : static bool onepart_variable_different_p (variable *, variable *);
     675              : static bool variable_different_p (variable *, variable *);
     676              : static bool dataflow_set_different (dataflow_set *, dataflow_set *);
     677              : static void dataflow_set_destroy (dataflow_set *);
     678              : 
     679              : static bool track_expr_p (tree, bool);
     680              : static void add_uses_1 (rtx *, void *);
     681              : static void add_stores (rtx, const_rtx, void *);
     682              : static bool compute_bb_dataflow (basic_block);
     683              : static bool vt_find_locations (void);
     684              : 
     685              : static void dump_attrs_list (attrs *);
     686              : static void dump_var (variable *);
     687              : static void dump_vars (variable_table_type *);
     688              : static void dump_dataflow_set (dataflow_set *);
     689              : static void dump_dataflow_sets (void);
     690              : 
     691              : static void set_dv_changed (decl_or_value, bool);
     692              : static void variable_was_changed (variable *, dataflow_set *);
     693              : static variable **set_slot_part (dataflow_set *, rtx, variable **,
     694              :                                  decl_or_value, HOST_WIDE_INT,
     695              :                                  enum var_init_status, rtx);
     696              : static void set_variable_part (dataflow_set *, rtx,
     697              :                                decl_or_value, HOST_WIDE_INT,
     698              :                                enum var_init_status, rtx, enum insert_option);
     699              : static variable **clobber_slot_part (dataflow_set *, rtx,
     700              :                                      variable **, HOST_WIDE_INT, rtx);
     701              : static void clobber_variable_part (dataflow_set *, rtx,
     702              :                                    decl_or_value, HOST_WIDE_INT, rtx);
     703              : static variable **delete_slot_part (dataflow_set *, rtx, variable **,
     704              :                                     HOST_WIDE_INT);
     705              : static void delete_variable_part (dataflow_set *, rtx,
     706              :                                   decl_or_value, HOST_WIDE_INT);
     707              : static void emit_notes_in_bb (basic_block, dataflow_set *);
     708              : static void vt_emit_notes (void);
     709              : 
     710              : static void vt_add_function_parameters (void);
     711              : static bool vt_initialize (void);
     712              : static void vt_finalize (void);
     713              : 
     714              : /* Callback for stack_adjust_offset_pre_post, called via for_each_inc_dec.  */
     715              : 
     716              : static int
     717      5370888 : stack_adjust_offset_pre_post_cb (rtx, rtx op, rtx dest, rtx src, rtx srcoff,
     718              :                                  void *arg)
     719              : {
     720      5370888 :   if (dest != stack_pointer_rtx)
     721              :     return 0;
     722              : 
     723      5370888 :   switch (GET_CODE (op))
     724              :     {
     725      3886580 :     case PRE_INC:
     726      3886580 :     case PRE_DEC:
     727      3886580 :       ((HOST_WIDE_INT *)arg)[0] -= INTVAL (srcoff);
     728      3886580 :       return 0;
     729      1470814 :     case POST_INC:
     730      1470814 :     case POST_DEC:
     731      1470814 :       ((HOST_WIDE_INT *)arg)[1] -= INTVAL (srcoff);
     732      1470814 :       return 0;
     733        13494 :     case PRE_MODIFY:
     734        13494 :     case POST_MODIFY:
     735              :       /* We handle only adjustments by constant amount.  */
     736        13494 :       gcc_assert (GET_CODE (src) == PLUS
     737              :                   && CONST_INT_P (XEXP (src, 1))
     738              :                   && XEXP (src, 0) == stack_pointer_rtx);
     739        13494 :       ((HOST_WIDE_INT *)arg)[GET_CODE (op) == POST_MODIFY]
     740        13494 :         -= INTVAL (XEXP (src, 1));
     741        13494 :       return 0;
     742            0 :     default:
     743            0 :       gcc_unreachable ();
     744              :     }
     745              : }
     746              : 
     747              : /* Given a SET, calculate the amount of stack adjustment it contains
     748              :    PRE- and POST-modifying stack pointer.
     749              :    This function is similar to stack_adjust_offset.  */
     750              : 
     751              : static void
     752     69122856 : stack_adjust_offset_pre_post (rtx pattern, HOST_WIDE_INT *pre,
     753              :                               HOST_WIDE_INT *post)
     754              : {
     755     69122856 :   rtx src = SET_SRC (pattern);
     756     69122856 :   rtx dest = SET_DEST (pattern);
     757     69122856 :   enum rtx_code code;
     758              : 
     759     69122856 :   if (dest == stack_pointer_rtx)
     760              :     {
     761              :       /* (set (reg sp) (plus (reg sp) (const_int))) */
     762      3260259 :       code = GET_CODE (src);
     763      3260259 :       if (! (code == PLUS || code == MINUS)
     764      3259765 :           || XEXP (src, 0) != stack_pointer_rtx
     765      3259765 :           || !CONST_INT_P (XEXP (src, 1)))
     766      3260259 :         return;
     767              : 
     768      3259645 :       if (code == MINUS)
     769            6 :         *post += INTVAL (XEXP (src, 1));
     770              :       else
     771      3259639 :         *post -= INTVAL (XEXP (src, 1));
     772      3259645 :       return;
     773              :     }
     774     65862597 :   HOST_WIDE_INT res[2] = { 0, 0 };
     775     65862597 :   for_each_inc_dec (pattern, stack_adjust_offset_pre_post_cb, res);
     776     65862597 :   *pre += res[0];
     777     65862597 :   *post += res[1];
     778              : }
     779              : 
     780              : /* Given an INSN, calculate the amount of stack adjustment it contains
     781              :    PRE- and POST-modifying stack pointer.  */
     782              : 
     783              : static void
     784    172753141 : insn_stack_adjust_offset_pre_post (rtx_insn *insn, HOST_WIDE_INT *pre,
     785              :                                    HOST_WIDE_INT *post)
     786              : {
     787    172753141 :   rtx pattern;
     788              : 
     789    172753141 :   *pre = 0;
     790    172753141 :   *post = 0;
     791              : 
     792    172753141 :   pattern = PATTERN (insn);
     793    172753141 :   if (RTX_FRAME_RELATED_P (insn))
     794              :     {
     795      4538424 :       rtx expr = find_reg_note (insn, REG_FRAME_RELATED_EXPR, NULL_RTX);
     796      4538424 :       if (expr)
     797           32 :         pattern = XEXP (expr, 0);
     798              :     }
     799              : 
     800    172753141 :   if (GET_CODE (pattern) == SET)
     801     59788492 :     stack_adjust_offset_pre_post (pattern, pre, post);
     802    112964649 :   else if (GET_CODE (pattern) == PARALLEL
     803    104051472 :            || GET_CODE (pattern) == SEQUENCE)
     804              :     {
     805      8913177 :       int i;
     806              : 
     807              :       /* There may be stack adjustments inside compound insns.  Search
     808              :          for them.  */
     809     28431058 :       for ( i = XVECLEN (pattern, 0) - 1; i >= 0; i--)
     810     19517881 :         if (GET_CODE (XVECEXP (pattern, 0, i)) == SET)
     811      9334364 :           stack_adjust_offset_pre_post (XVECEXP (pattern, 0, i), pre, post);
     812              :     }
     813    172753141 : }
     814              : 
     815              : /* Compute stack adjustments for all blocks by traversing DFS tree.
     816              :    Return true when the adjustments on all incoming edges are consistent.
     817              :    Heavily borrowed from pre_and_rev_post_order_compute.  */
     818              : 
     819              : static bool
     820       486107 : vt_stack_adjustments (void)
     821              : {
     822       486107 :   edge_iterator *stack;
     823       486107 :   int sp;
     824              : 
     825              :   /* Initialize entry block.  */
     826       486107 :   VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->visited = true;
     827       486107 :   VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->in.stack_adjust
     828       486107 :     = INCOMING_FRAME_SP_OFFSET;
     829       486107 :   VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->out.stack_adjust
     830       486107 :     = INCOMING_FRAME_SP_OFFSET;
     831              : 
     832              :   /* Allocate stack for back-tracking up CFG.  */
     833       486107 :   stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1);
     834       486107 :   sp = 0;
     835              : 
     836              :   /* Push the first edge on to the stack.  */
     837       486107 :   stack[sp++] = ei_start (ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs);
     838              : 
     839     17450638 :   while (sp)
     840              :     {
     841     16964596 :       edge_iterator ei;
     842     16964596 :       basic_block src;
     843     16964596 :       basic_block dest;
     844              : 
     845              :       /* Look at the edge on the top of the stack.  */
     846     16964596 :       ei = stack[sp - 1];
     847     16964596 :       src = ei_edge (ei)->src;
     848     16964596 :       dest = ei_edge (ei)->dest;
     849              : 
     850              :       /* Check if the edge destination has been visited yet.  */
     851     16964596 :       if (!VTI (dest)->visited)
     852              :         {
     853      6971702 :           rtx_insn *insn;
     854      6971702 :           HOST_WIDE_INT pre, post, offset;
     855      6971702 :           VTI (dest)->visited = true;
     856      6971702 :           VTI (dest)->in.stack_adjust = offset = VTI (src)->out.stack_adjust;
     857              : 
     858      6971702 :           if (dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
     859    107422170 :             for (insn = BB_HEAD (dest);
     860    107422170 :                  insn != NEXT_INSN (BB_END (dest));
     861    100926854 :                  insn = NEXT_INSN (insn))
     862    100926854 :               if (INSN_P (insn))
     863              :                 {
     864     86380486 :                   insn_stack_adjust_offset_pre_post (insn, &pre, &post);
     865     86380486 :                   offset += pre + post;
     866              :                 }
     867              : 
     868      6971702 :           VTI (dest)->out.stack_adjust = offset;
     869              : 
     870     13182508 :           if (EDGE_COUNT (dest->succs) > 0)
     871              :             /* Since the DEST node has been visited for the first
     872              :                time, check its successors.  */
     873      6210806 :             stack[sp++] = ei_start (dest->succs);
     874              :         }
     875              :       else
     876              :         {
     877              :           /* We can end up with different stack adjustments for the exit block
     878              :              of a shrink-wrapped function if stack_adjust_offset_pre_post
     879              :              doesn't understand the rtx pattern used to restore the stack
     880              :              pointer in the epilogue.  For example, on s390(x), the stack
     881              :              pointer is often restored via a load-multiple instruction
     882              :              and so no stack_adjust offset is recorded for it.  This means
     883              :              that the stack offset at the end of the epilogue block is the
     884              :              same as the offset before the epilogue, whereas other paths
     885              :              to the exit block will have the correct stack_adjust.
     886              : 
     887              :              It is safe to ignore these differences because (a) we never
     888              :              use the stack_adjust for the exit block in this pass and
     889              :              (b) dwarf2cfi checks whether the CFA notes in a shrink-wrapped
     890              :              function are correct.
     891              : 
     892              :              We must check whether the adjustments on other edges are
     893              :              the same though.  */
     894      9992894 :           if (dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
     895      9376474 :               && VTI (dest)->in.stack_adjust != VTI (src)->out.stack_adjust)
     896              :             {
     897           65 :               free (stack);
     898           65 :               return false;
     899              :             }
     900              : 
     901      9992829 :           if (! ei_one_before_end_p (ei))
     902              :             /* Go to the next edge.  */
     903      3296318 :             ei_next (&stack[sp - 1]);
     904              :           else
     905              :             /* Return to previous level if there are no more edges.  */
     906      6696511 :             sp--;
     907              :         }
     908              :     }
     909              : 
     910       486042 :   free (stack);
     911       486042 :   return true;
     912              : }
     913              : 
     914              : /* arg_pointer_rtx resp. frame_pointer_rtx if stack_pointer_rtx or
     915              :    hard_frame_pointer_rtx is being mapped to it and offset for it.  */
     916              : static rtx cfa_base_rtx;
     917              : static HOST_WIDE_INT cfa_base_offset;
     918              : 
     919              : /* Compute a CFA-based value for an ADJUSTMENT made to stack_pointer_rtx
     920              :    or hard_frame_pointer_rtx.  */
     921              : 
     922              : static inline rtx
     923     20915949 : compute_cfa_pointer (poly_int64 adjustment)
     924              : {
     925     29609379 :   return plus_constant (Pmode, cfa_base_rtx, adjustment + cfa_base_offset);
     926              : }
     927              : 
     928              : /* Adjustment for hard_frame_pointer_rtx to cfa base reg,
     929              :    or -1 if the replacement shouldn't be done.  */
     930              : static poly_int64 hard_frame_pointer_adjustment = -1;
     931              : 
     932              : /* Data for adjust_mems callback.  */
     933              : 
     934    287139705 : class adjust_mem_data
     935              : {
     936              : public:
     937              :   bool store;
     938              :   machine_mode mem_mode;
     939              :   HOST_WIDE_INT stack_adjust;
     940              :   auto_vec<rtx> side_effects;
     941              : };
     942              : 
     943              : /* Helper for adjust_mems.  Return true if X is suitable for
     944              :    transformation of wider mode arithmetics to narrower mode.  */
     945              : 
     946              : static bool
     947         5713 : use_narrower_mode_test (rtx x, const_rtx subreg)
     948              : {
     949         5713 :   subrtx_var_iterator::array_type array;
     950        11447 :   FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
     951              :     {
     952        11426 :       rtx x = *iter;
     953        11426 :       if (CONSTANT_P (x))
     954           13 :         iter.skip_subrtxes ();
     955              :       else
     956        11413 :         switch (GET_CODE (x))
     957              :           {
     958           20 :           case REG:
     959           20 :             if (cselib_lookup (x, GET_MODE (SUBREG_REG (subreg)), 0, VOIDmode))
     960         5692 :               return false;
     961            8 :             if (!validate_subreg (GET_MODE (subreg), GET_MODE (x), x,
     962            8 :                                   subreg_lowpart_offset (GET_MODE (subreg),
     963            8 :                                                          GET_MODE (x))))
     964              :               return false;
     965              :             break;
     966              :           case PLUS:
     967              :           case MINUS:
     968              :           case MULT:
     969              :             break;
     970         5713 :           case ASHIFT:
     971         5713 :             if (GET_MODE (XEXP (x, 1)) != VOIDmode)
     972              :               {
     973         5325 :                 enum machine_mode mode = GET_MODE (subreg);
     974         5325 :                 rtx op1 = XEXP (x, 1);
     975         5325 :                 enum machine_mode op1_mode = GET_MODE (op1);
     976         5325 :                 if (GET_MODE_PRECISION (as_a <scalar_int_mode> (mode))
     977         5325 :                     < GET_MODE_PRECISION (as_a <scalar_int_mode> (op1_mode)))
     978              :                   {
     979           34 :                     poly_uint64 byte = subreg_lowpart_offset (mode, op1_mode);
     980           34 :                     if (GET_CODE (op1) == SUBREG || GET_CODE (op1) == CONCAT)
     981              :                       {
     982            0 :                         if (!simplify_subreg (mode, op1, op1_mode, byte))
     983            0 :                           return false;
     984              :                       }
     985           34 :                     else if (!validate_subreg (mode, op1_mode, op1, byte))
     986              :                       return false;
     987              :                   }
     988              :               }
     989         5713 :             iter.substitute (XEXP (x, 0));
     990         5713 :             break;
     991              :           default:
     992              :             return false;
     993              :           }
     994              :     }
     995           21 :   return true;
     996         5713 : }
     997              : 
     998              : /* Transform X into narrower mode MODE from wider mode WMODE.  */
     999              : 
    1000              : static rtx
    1001           42 : use_narrower_mode (rtx x, scalar_int_mode mode, scalar_int_mode wmode)
    1002              : {
    1003           42 :   rtx op0, op1;
    1004           42 :   if (CONSTANT_P (x))
    1005           13 :     return lowpart_subreg (mode, x, wmode);
    1006           29 :   switch (GET_CODE (x))
    1007              :     {
    1008            8 :     case REG:
    1009            8 :       return lowpart_subreg (mode, x, wmode);
    1010            0 :     case PLUS:
    1011            0 :     case MINUS:
    1012            0 :     case MULT:
    1013            0 :       op0 = use_narrower_mode (XEXP (x, 0), mode, wmode);
    1014            0 :       op1 = use_narrower_mode (XEXP (x, 1), mode, wmode);
    1015            0 :       return simplify_gen_binary (GET_CODE (x), mode, op0, op1);
    1016           21 :     case ASHIFT:
    1017           21 :       op0 = use_narrower_mode (XEXP (x, 0), mode, wmode);
    1018           21 :       op1 = XEXP (x, 1);
    1019              :       /* Ensure shift amount is not wider than mode.  */
    1020           21 :       if (GET_MODE (op1) == VOIDmode)
    1021            0 :         op1 = lowpart_subreg (mode, op1, wmode);
    1022           21 :       else if (GET_MODE_PRECISION (mode)
    1023           21 :                < GET_MODE_PRECISION (as_a <scalar_int_mode> (GET_MODE (op1))))
    1024           12 :         op1 = lowpart_subreg (mode, op1, GET_MODE (op1));
    1025           21 :       return simplify_gen_binary (ASHIFT, mode, op0, op1);
    1026            0 :     default:
    1027            0 :       gcc_unreachable ();
    1028              :     }
    1029              : }
    1030              : 
    1031              : /* Helper function for adjusting used MEMs.  */
    1032              : 
    1033              : static rtx
    1034    319738824 : adjust_mems (rtx loc, const_rtx old_rtx, void *data)
    1035              : {
    1036    319738824 :   class adjust_mem_data *amd = (class adjust_mem_data *) data;
    1037    319738824 :   rtx mem, addr = loc, tem;
    1038    319738824 :   machine_mode mem_mode_save;
    1039    319738824 :   bool store_save;
    1040    319738824 :   scalar_int_mode tem_mode, tem_subreg_mode;
    1041    319738824 :   poly_int64 size;
    1042    319738824 :   switch (GET_CODE (loc))
    1043              :     {
    1044     66675602 :     case REG:
    1045              :       /* Don't do any sp or fp replacements outside of MEM addresses
    1046              :          on the LHS.  */
    1047     66675602 :       if (amd->mem_mode == VOIDmode && amd->store)
    1048              :         return loc;
    1049     66643528 :       if (loc == stack_pointer_rtx
    1050     21158207 :           && !frame_pointer_needed
    1051     19052976 :           && cfa_base_rtx)
    1052     19052879 :         return compute_cfa_pointer (amd->stack_adjust);
    1053     47590649 :       else if (loc == hard_frame_pointer_rtx
    1054      2122974 :                && frame_pointer_needed
    1055      2122685 :                && maybe_ne (hard_frame_pointer_adjustment, -1)
    1056     49453719 :                && cfa_base_rtx)
    1057      1863070 :         return compute_cfa_pointer (hard_frame_pointer_adjustment);
    1058     45727579 :       gcc_checking_assert (loc != virtual_incoming_args_rtx);
    1059              :       return loc;
    1060     23716694 :     case MEM:
    1061     23716694 :       mem = loc;
    1062     23716694 :       if (!amd->store)
    1063              :         {
    1064     14134596 :           mem = targetm.delegitimize_address (mem);
    1065     14134596 :           if (mem != loc && !MEM_P (mem))
    1066       117815 :             return simplify_replace_fn_rtx (mem, old_rtx, adjust_mems, data);
    1067              :         }
    1068              : 
    1069     23598879 :       addr = XEXP (mem, 0);
    1070     23598879 :       mem_mode_save = amd->mem_mode;
    1071     23598879 :       amd->mem_mode = GET_MODE (mem);
    1072     23598879 :       store_save = amd->store;
    1073     23598879 :       amd->store = false;
    1074     23598879 :       addr = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
    1075     23598879 :       amd->store = store_save;
    1076     23598879 :       amd->mem_mode = mem_mode_save;
    1077     23598879 :       if (mem == loc)
    1078     23553493 :         addr = targetm.delegitimize_address (addr);
    1079     23598879 :       if (addr != XEXP (mem, 0))
    1080     12839905 :         mem = replace_equiv_address_nv (mem, addr);
    1081     23598879 :       if (!amd->store)
    1082     14016781 :         mem = avoid_constant_pool_reference (mem);
    1083              :       return mem;
    1084      2406561 :     case PRE_INC:
    1085      2406561 :     case PRE_DEC:
    1086      4813122 :       size = GET_MODE_SIZE (amd->mem_mode);
    1087      4813122 :       addr = plus_constant (GET_MODE (loc), XEXP (loc, 0),
    1088      2406561 :                             GET_CODE (loc) == PRE_INC ? size : -size);
    1089              :       /* FALLTHRU */
    1090      3230863 :     case POST_INC:
    1091      3230863 :     case POST_DEC:
    1092      3230863 :       if (addr == loc)
    1093       824302 :         addr = XEXP (loc, 0);
    1094      3230863 :       gcc_assert (amd->mem_mode != VOIDmode && amd->mem_mode != BLKmode);
    1095      3230863 :       addr = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
    1096      6461726 :       size = GET_MODE_SIZE (amd->mem_mode);
    1097      3230863 :       tem = plus_constant (GET_MODE (loc), XEXP (loc, 0),
    1098      3230863 :                            (GET_CODE (loc) == PRE_INC
    1099      3230863 :                             || GET_CODE (loc) == POST_INC) ? size : -size);
    1100      3230863 :       store_save = amd->store;
    1101      3230863 :       amd->store = false;
    1102      3230863 :       tem = simplify_replace_fn_rtx (tem, old_rtx, adjust_mems, data);
    1103      3230863 :       amd->store = store_save;
    1104      3230863 :       amd->side_effects.safe_push (gen_rtx_SET (XEXP (loc, 0), tem));
    1105      3230863 :       return addr;
    1106        12555 :     case PRE_MODIFY:
    1107        12555 :       addr = XEXP (loc, 1);
    1108              :       /* FALLTHRU */
    1109        12555 :     case POST_MODIFY:
    1110        12555 :       if (addr == loc)
    1111            0 :         addr = XEXP (loc, 0);
    1112        12555 :       gcc_assert (amd->mem_mode != VOIDmode);
    1113        12555 :       addr = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
    1114        12555 :       store_save = amd->store;
    1115        12555 :       amd->store = false;
    1116        12555 :       tem = simplify_replace_fn_rtx (XEXP (loc, 1), old_rtx,
    1117              :                                      adjust_mems, data);
    1118        12555 :       amd->store = store_save;
    1119        12555 :       amd->side_effects.safe_push (gen_rtx_SET (XEXP (loc, 0), tem));
    1120        12555 :       return addr;
    1121        84331 :     case SUBREG:
    1122              :       /* First try without delegitimization of whole MEMs and
    1123              :          avoid_constant_pool_reference, which is more likely to succeed.  */
    1124        84331 :       store_save = amd->store;
    1125        84331 :       amd->store = true;
    1126        84331 :       addr = simplify_replace_fn_rtx (SUBREG_REG (loc), old_rtx, adjust_mems,
    1127              :                                       data);
    1128        84331 :       amd->store = store_save;
    1129        84331 :       mem = simplify_replace_fn_rtx (addr, old_rtx, adjust_mems, data);
    1130        84331 :       if (mem == SUBREG_REG (loc))
    1131              :         {
    1132        83629 :           tem = loc;
    1133        83629 :           goto finish_subreg;
    1134              :         }
    1135         1404 :       tem = simplify_gen_subreg (GET_MODE (loc), mem,
    1136          702 :                                  GET_MODE (SUBREG_REG (loc)),
    1137          702 :                                  SUBREG_BYTE (loc));
    1138          702 :       if (tem)
    1139          701 :         goto finish_subreg;
    1140            2 :       tem = simplify_gen_subreg (GET_MODE (loc), addr,
    1141            1 :                                  GET_MODE (SUBREG_REG (loc)),
    1142            1 :                                  SUBREG_BYTE (loc));
    1143            1 :       if (tem == NULL_RTX)
    1144            1 :         tem = gen_rtx_raw_SUBREG (GET_MODE (loc), addr, SUBREG_BYTE (loc));
    1145            0 :     finish_subreg:
    1146        84331 :       if (MAY_HAVE_DEBUG_BIND_INSNS
    1147        84331 :           && GET_CODE (tem) == SUBREG
    1148        84331 :           && (GET_CODE (SUBREG_REG (tem)) == PLUS
    1149        84331 :               || GET_CODE (SUBREG_REG (tem)) == MINUS
    1150              :               || GET_CODE (SUBREG_REG (tem)) == MULT
    1151              :               || GET_CODE (SUBREG_REG (tem)) == ASHIFT)
    1152         6542 :           && is_a <scalar_int_mode> (GET_MODE (tem), &tem_mode)
    1153         6511 :           && is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (tem)),
    1154              :                                      &tem_subreg_mode)
    1155         6413 :           && (GET_MODE_PRECISION (tem_mode)
    1156         6413 :               < GET_MODE_PRECISION (tem_subreg_mode))
    1157         5737 :           && subreg_lowpart_p (tem)
    1158        90044 :           && use_narrower_mode_test (SUBREG_REG (tem), tem))
    1159           21 :         return use_narrower_mode (SUBREG_REG (tem), tem_mode, tem_subreg_mode);
    1160              :       return tem;
    1161        13640 :     case ASM_OPERANDS:
    1162              :       /* Don't do any replacements in second and following
    1163              :          ASM_OPERANDS of inline-asm with multiple sets.
    1164              :          ASM_OPERANDS_INPUT_VEC, ASM_OPERANDS_INPUT_CONSTRAINT_VEC
    1165              :          and ASM_OPERANDS_LABEL_VEC need to be equal between
    1166              :          all the ASM_OPERANDs in the insn and adjust_insn will
    1167              :          fix this up.  */
    1168        13640 :       if (ASM_OPERANDS_OUTPUT_IDX (loc) != 0)
    1169         4958 :         return loc;
    1170              :       break;
    1171              :     default:
    1172              :       break;
    1173              :     }
    1174              :   return NULL_RTX;
    1175              : }
    1176              : 
    1177              : /* Helper function for replacement of uses.  */
    1178              : 
    1179              : static void
    1180    105828870 : adjust_mem_uses (rtx *x, void *data)
    1181              : {
    1182    105828870 :   rtx new_x = simplify_replace_fn_rtx (*x, NULL_RTX, adjust_mems, data);
    1183    105828870 :   if (new_x != *x)
    1184     12452104 :     validate_change (NULL_RTX, x, new_x, true);
    1185    105828870 : }
    1186              : 
    1187              : /* Helper function for replacement of stores.  */
    1188              : 
    1189              : static void
    1190     45195736 : adjust_mem_stores (rtx loc, const_rtx expr, void *data)
    1191              : {
    1192     45195736 :   if (MEM_P (loc))
    1193              :     {
    1194      9572607 :       rtx new_dest = simplify_replace_fn_rtx (SET_DEST (expr), NULL_RTX,
    1195              :                                               adjust_mems, data);
    1196      9572607 :       if (new_dest != SET_DEST (expr))
    1197              :         {
    1198      6714872 :           rtx xexpr = const_cast<rtx> (expr);
    1199      6714872 :           validate_change (NULL_RTX, &SET_DEST (xexpr), new_dest, true);
    1200              :         }
    1201              :     }
    1202     45195736 : }
    1203              : 
    1204              : /* Simplify INSN.  Remove all {PRE,POST}_{INC,DEC,MODIFY} rtxes,
    1205              :    replace them with their value in the insn and add the side-effects
    1206              :    as other sets to the insn.  */
    1207              : 
    1208              : static void
    1209     95704618 : adjust_insn (basic_block bb, rtx_insn *insn)
    1210              : {
    1211     95704618 :   rtx set;
    1212              : 
    1213              : #ifdef HAVE_window_save
    1214              :   /* If the target machine has an explicit window save instruction, the
    1215              :      transformation OUTGOING_REGNO -> INCOMING_REGNO is done there.  */
    1216              :   if (RTX_FRAME_RELATED_P (insn)
    1217              :       && find_reg_note (insn, REG_CFA_WINDOW_SAVE, NULL_RTX))
    1218              :     {
    1219              :       unsigned int i, nregs = vec_safe_length (windowed_parm_regs);
    1220              :       rtx rtl = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs * 2));
    1221              :       parm_reg *p;
    1222              : 
    1223              :       FOR_EACH_VEC_SAFE_ELT (windowed_parm_regs, i, p)
    1224              :         {
    1225              :           XVECEXP (rtl, 0, i * 2)
    1226              :             = gen_rtx_SET (p->incoming, p->outgoing);
    1227              :           /* Do not clobber the attached DECL, but only the REG.  */
    1228              :           XVECEXP (rtl, 0, i * 2 + 1)
    1229              :             = gen_rtx_CLOBBER (GET_MODE (p->outgoing),
    1230              :                                gen_raw_REG (GET_MODE (p->outgoing),
    1231              :                                             REGNO (p->outgoing)));
    1232              :         }
    1233              : 
    1234              :       validate_change (NULL_RTX, &PATTERN (insn), rtl, true);
    1235              :       return;
    1236              :     }
    1237              : #endif
    1238              : 
    1239     95704618 :   adjust_mem_data amd;
    1240     95704618 :   amd.mem_mode = VOIDmode;
    1241     95704618 :   amd.stack_adjust = -VTI (bb)->out.stack_adjust;
    1242              : 
    1243     95704618 :   amd.store = true;
    1244     95704618 :   note_stores (insn, adjust_mem_stores, &amd);
    1245              : 
    1246     95704618 :   amd.store = false;
    1247     95704618 :   if (GET_CODE (PATTERN (insn)) == PARALLEL
    1248      5135261 :       && asm_noperands (PATTERN (insn)) > 0
    1249     95715961 :       && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET)
    1250              :     {
    1251         8682 :       rtx body, set0;
    1252         8682 :       int i;
    1253              : 
    1254              :       /* inline-asm with multiple sets is tiny bit more complicated,
    1255              :          because the 3 vectors in ASM_OPERANDS need to be shared between
    1256              :          all ASM_OPERANDS in the instruction.  adjust_mems will
    1257              :          not touch ASM_OPERANDS other than the first one, asm_noperands
    1258              :          test above needs to be called before that (otherwise it would fail)
    1259              :          and afterwards this code fixes it up.  */
    1260         8682 :       note_uses (&PATTERN (insn), adjust_mem_uses, &amd);
    1261         8682 :       body = PATTERN (insn);
    1262         8682 :       set0 = XVECEXP (body, 0, 0);
    1263         8682 :       gcc_checking_assert (GET_CODE (set0) == SET
    1264              :                            && GET_CODE (SET_SRC (set0)) == ASM_OPERANDS
    1265              :                            && ASM_OPERANDS_OUTPUT_IDX (SET_SRC (set0)) == 0);
    1266        13640 :       for (i = 1; i < XVECLEN (body, 0); i++)
    1267        13640 :         if (GET_CODE (XVECEXP (body, 0, i)) != SET)
    1268              :           break;
    1269              :         else
    1270              :           {
    1271         4958 :             set = XVECEXP (body, 0, i);
    1272         4958 :             gcc_checking_assert (GET_CODE (SET_SRC (set)) == ASM_OPERANDS
    1273              :                                  && ASM_OPERANDS_OUTPUT_IDX (SET_SRC (set))
    1274              :                                     == i);
    1275         4958 :             if (ASM_OPERANDS_INPUT_VEC (SET_SRC (set))
    1276         4958 :                 != ASM_OPERANDS_INPUT_VEC (SET_SRC (set0))
    1277         4643 :                 || ASM_OPERANDS_INPUT_CONSTRAINT_VEC (SET_SRC (set))
    1278         4643 :                    != ASM_OPERANDS_INPUT_CONSTRAINT_VEC (SET_SRC (set0))
    1279         4643 :                 || ASM_OPERANDS_LABEL_VEC (SET_SRC (set))
    1280         4643 :                    != ASM_OPERANDS_LABEL_VEC (SET_SRC (set0)))
    1281              :               {
    1282          315 :                 rtx newsrc = shallow_copy_rtx (SET_SRC (set));
    1283          315 :                 ASM_OPERANDS_INPUT_VEC (newsrc)
    1284          315 :                   = ASM_OPERANDS_INPUT_VEC (SET_SRC (set0));
    1285          315 :                 ASM_OPERANDS_INPUT_CONSTRAINT_VEC (newsrc)
    1286          315 :                   = ASM_OPERANDS_INPUT_CONSTRAINT_VEC (SET_SRC (set0));
    1287          315 :                 ASM_OPERANDS_LABEL_VEC (newsrc)
    1288          315 :                   = ASM_OPERANDS_LABEL_VEC (SET_SRC (set0));
    1289          315 :                 validate_change (NULL_RTX, &SET_SRC (set), newsrc, true);
    1290              :               }
    1291              :           }
    1292              :     }
    1293              :   else
    1294     95695936 :     note_uses (&PATTERN (insn), adjust_mem_uses, &amd);
    1295              : 
    1296              :   /* For read-only MEMs containing some constant, prefer those
    1297              :      constants.  */
    1298     95704618 :   set = single_set (insn);
    1299     95704618 :   if (set && MEM_P (SET_SRC (set)) && MEM_READONLY_P (SET_SRC (set)))
    1300              :     {
    1301        34699 :       rtx note = find_reg_equal_equiv_note (insn);
    1302              : 
    1303        34699 :       if (note && CONSTANT_P (XEXP (note, 0)))
    1304            0 :         validate_change (NULL_RTX, &SET_SRC (set), XEXP (note, 0), true);
    1305              :     }
    1306              : 
    1307     98948036 :   if (!amd.side_effects.is_empty ())
    1308              :     {
    1309      3243418 :       rtx *pat, new_pat;
    1310      3243418 :       int i, oldn;
    1311              : 
    1312      3243418 :       pat = &PATTERN (insn);
    1313      3243418 :       if (GET_CODE (*pat) == COND_EXEC)
    1314            0 :         pat = &COND_EXEC_CODE (*pat);
    1315      3243418 :       if (GET_CODE (*pat) == PARALLEL)
    1316        17187 :         oldn = XVECLEN (*pat, 0);
    1317              :       else
    1318              :         oldn = 1;
    1319      3243418 :       unsigned int newn = amd.side_effects.length ();
    1320      3243418 :       new_pat = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (oldn + newn));
    1321      3243418 :       if (GET_CODE (*pat) == PARALLEL)
    1322        51561 :         for (i = 0; i < oldn; i++)
    1323        34374 :           XVECEXP (new_pat, 0, i) = XVECEXP (*pat, 0, i);
    1324              :       else
    1325      3226231 :         XVECEXP (new_pat, 0, 0) = *pat;
    1326              : 
    1327      3243418 :       rtx effect;
    1328      3243418 :       unsigned int j;
    1329      9730254 :       FOR_EACH_VEC_ELT_REVERSE (amd.side_effects, j, effect)
    1330      3243418 :         XVECEXP (new_pat, 0, j + oldn) = effect;
    1331      3243418 :       validate_change (NULL_RTX, pat, new_pat, true);
    1332              :     }
    1333     95704618 : }
    1334              : 
    1335              : /* Return the DEBUG_EXPR of a DEBUG_EXPR_DECL or the VALUE in DV.  */
    1336              : static inline rtx
    1337     13156538 : dv_as_rtx (decl_or_value dv)
    1338              : {
    1339     13156538 :   tree decl;
    1340              : 
    1341     13156538 :   if (dv_is_value_p (dv))
    1342     10433004 :     return dv_as_value (dv);
    1343              : 
    1344      2723534 :   decl = dv_as_decl (dv);
    1345              : 
    1346      2723534 :   gcc_checking_assert (TREE_CODE (decl) == DEBUG_EXPR_DECL);
    1347      2723534 :   return DECL_RTL_KNOWN_SET (decl);
    1348              : }
    1349              : 
    1350              : /* Return nonzero if a decl_or_value must not have more than one
    1351              :    variable part.  The returned value discriminates among various
    1352              :    kinds of one-part DVs ccording to enum onepart_enum.  */
    1353              : static inline onepart_enum
    1354    649086324 : dv_onepart_p (decl_or_value dv)
    1355              : {
    1356    649086324 :   tree decl;
    1357              : 
    1358    649086324 :   if (!MAY_HAVE_DEBUG_BIND_INSNS)
    1359              :     return NOT_ONEPART;
    1360              : 
    1361    649085976 :   if (dv_is_value_p (dv))
    1362              :     return ONEPART_VALUE;
    1363              : 
    1364    237795121 :   decl = dv_as_decl (dv);
    1365              : 
    1366    237795121 :   if (TREE_CODE (decl) == DEBUG_EXPR_DECL)
    1367              :     return ONEPART_DEXPR;
    1368              : 
    1369    205528007 :   if (target_for_debug_bind (decl) != NULL_TREE)
    1370    198787359 :     return ONEPART_VDECL;
    1371              : 
    1372              :   return NOT_ONEPART;
    1373              : }
    1374              : 
    1375              : /* Return the variable pool to be used for a dv of type ONEPART.  */
    1376              : static inline pool_allocator &
    1377    599868834 : onepart_pool (onepart_enum onepart)
    1378              : {
    1379    599868834 :   return onepart ? valvar_pool : var_pool;
    1380              : }
    1381              : 
    1382              : /* Allocate a variable_def from the corresponding variable pool.  */
    1383              : static inline variable *
    1384    299934417 : onepart_pool_allocate (onepart_enum onepart)
    1385              : {
    1386    284605313 :   return (variable*) onepart_pool (onepart).allocate ();
    1387              : }
    1388              : 
    1389              : /* Build a decl_or_value out of a decl.  */
    1390              : static inline decl_or_value
    1391    199904640 : dv_from_decl (tree decl)
    1392              : {
    1393    199904640 :   decl_or_value dv = decl;
    1394    199904640 :   gcc_checking_assert (dv_is_decl_p (dv));
    1395    199904640 :   return dv;
    1396              : }
    1397              : 
    1398              : /* Build a decl_or_value out of a value.  */
    1399              : static inline decl_or_value
    1400   1220722557 : dv_from_value (rtx value)
    1401              : {
    1402   1220722557 :   decl_or_value dv = value;
    1403   1220722557 :   gcc_checking_assert (dv_is_value_p (dv));
    1404   1220722557 :   return dv;
    1405              : }
    1406              : 
    1407              : /* Return a value or the decl of a debug_expr as a decl_or_value.  */
    1408              : static inline decl_or_value
    1409    435611621 : dv_from_rtx (rtx x)
    1410              : {
    1411    435611621 :   decl_or_value dv;
    1412              : 
    1413    435611621 :   switch (GET_CODE (x))
    1414              :     {
    1415     34039252 :     case DEBUG_EXPR:
    1416     34039252 :       dv = dv_from_decl (DEBUG_EXPR_TREE_DECL (x));
    1417     34039252 :       gcc_checking_assert (DECL_RTL_KNOWN_SET (DEBUG_EXPR_TREE_DECL (x)) == x);
    1418              :       break;
    1419              : 
    1420    401572369 :     case VALUE:
    1421    401572369 :       dv = dv_from_value (x);
    1422    401572369 :       break;
    1423              : 
    1424            0 :     default:
    1425            0 :       gcc_unreachable ();
    1426              :     }
    1427              : 
    1428    435611621 :   return dv;
    1429              : }
    1430              : 
    1431              : extern void debug_dv (decl_or_value dv);
    1432              : 
    1433              : DEBUG_FUNCTION void
    1434            0 : debug_dv (decl_or_value dv)
    1435              : {
    1436            0 :   if (dv_is_value_p (dv))
    1437            0 :     debug_rtx (dv_as_value (dv));
    1438              :   else
    1439            0 :     debug_generic_stmt (dv_as_decl (dv));
    1440            0 : }
    1441              : 
    1442              : static void loc_exp_dep_clear (variable *var);
    1443              : 
    1444              : /* Free the element of VARIABLE_HTAB (its type is struct variable_def).  */
    1445              : 
    1446              : static void
    1447   1323369530 : variable_htab_free (void *elem)
    1448              : {
    1449   1323369530 :   int i;
    1450   1323369530 :   variable *var = (variable *) elem;
    1451   1323369530 :   location_chain *node, *next;
    1452              : 
    1453   1323369530 :   gcc_checking_assert (var->refcount > 0);
    1454              : 
    1455   1323369530 :   var->refcount--;
    1456   1323369530 :   if (var->refcount > 0)
    1457              :     return;
    1458              : 
    1459    436605536 :   for (i = 0; i < var->n_var_parts; i++)
    1460              :     {
    1461    327717901 :       for (node = var->var_part[i].loc_chain; node; node = next)
    1462              :         {
    1463    191046782 :           next = node->next;
    1464    191046782 :           delete node;
    1465              :         }
    1466    136671119 :       var->var_part[i].loc_chain = NULL;
    1467              :     }
    1468    299934417 :   if (var->onepart && VAR_LOC_1PAUX (var))
    1469              :     {
    1470     44615375 :       loc_exp_dep_clear (var);
    1471     44615375 :       if (VAR_LOC_DEP_LST (var))
    1472      2355536 :         VAR_LOC_DEP_LST (var)->pprev = NULL;
    1473     44615375 :       XDELETE (VAR_LOC_1PAUX (var));
    1474              :       /* These may be reused across functions, so reset
    1475              :          e.g. NO_LOC_P.  */
    1476     44615375 :       if (var->onepart == ONEPART_DEXPR)
    1477      2851584 :         set_dv_changed (var->dv, true);
    1478              :     }
    1479    301633891 :   onepart_pool (var->onepart).remove (var);
    1480              : }
    1481              : 
    1482              : /* Initialize the set (array) SET of attrs to empty lists.  */
    1483              : 
    1484              : static void
    1485     31659545 : init_attrs_list_set (attrs **set)
    1486              : {
    1487     31659545 :   int i;
    1488              : 
    1489   3007656775 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    1490   2975997230 :     set[i] = NULL;
    1491            0 : }
    1492              : 
    1493              : /* Make the list *LISTP empty.  */
    1494              : 
    1495              : static void
    1496   9353088172 : attrs_list_clear (attrs **listp)
    1497              : {
    1498   9353088172 :   attrs *list, *next;
    1499              : 
    1500   9579001661 :   for (list = *listp; list; list = next)
    1501              :     {
    1502    225913489 :       next = list->next;
    1503    225913489 :       delete list;
    1504              :     }
    1505   9353088172 :   *listp = NULL;
    1506   9353088172 : }
    1507              : 
    1508              : /* Return true if the pair of DECL and OFFSET is the member of the LIST.  */
    1509              : 
    1510              : static attrs *
    1511       951591 : attrs_list_member (attrs *list, decl_or_value dv, HOST_WIDE_INT offset)
    1512              : {
    1513      1068568 :   for (; list; list = list->next)
    1514       934963 :     if (list->dv == dv && list->offset == offset)
    1515              :       return list;
    1516              :   return NULL;
    1517              : }
    1518              : 
    1519              : /* Insert the triplet DECL, OFFSET, LOC to the list *LISTP.  */
    1520              : 
    1521              : static void
    1522     87502253 : attrs_list_insert (attrs **listp, decl_or_value dv,
    1523              :                    HOST_WIDE_INT offset, rtx loc)
    1524              : {
    1525     87502253 :   attrs *list = new attrs;
    1526     87502253 :   list->loc = loc;
    1527     87502253 :   list->dv = dv;
    1528     87502253 :   list->offset = offset;
    1529     87502253 :   list->next = *listp;
    1530     87502253 :   *listp = list;
    1531     87502253 : }
    1532              : 
    1533              : /* Copy all nodes from SRC and create a list *DSTP of the copies.  */
    1534              : 
    1535              : static void
    1536   3373689798 : attrs_list_copy (attrs **dstp, attrs *src)
    1537              : {
    1538   3373689798 :   attrs_list_clear (dstp);
    1539   6942525949 :   for (; src; src = src->next)
    1540              :     {
    1541    195146353 :       attrs *n = new attrs;
    1542    195146353 :       n->loc = src->loc;
    1543    195146353 :       n->dv = src->dv;
    1544    195146353 :       n->offset = src->offset;
    1545    195146353 :       n->next = *dstp;
    1546    195146353 :       *dstp = n;
    1547              :     }
    1548   3373689798 : }
    1549              : 
    1550              : /* Add all nodes from SRC which are not in *DSTP to *DSTP.  */
    1551              : 
    1552              : static void
    1553         9964 : attrs_list_union (attrs **dstp, attrs *src)
    1554              : {
    1555        10167 :   for (; src; src = src->next)
    1556              :     {
    1557          406 :       if (!attrs_list_member (*dstp, src->dv, src->offset))
    1558          177 :         attrs_list_insert (dstp, src->dv, src->offset, src->loc);
    1559              :     }
    1560         9964 : }
    1561              : 
    1562              : /* Combine nodes that are not onepart nodes from SRC and SRC2 into
    1563              :    *DSTP.  */
    1564              : 
    1565              : static void
    1566    411248120 : attrs_list_mpdv_union (attrs **dstp, attrs *src, attrs *src2)
    1567              : {
    1568    411248120 :   gcc_assert (!*dstp);
    1569    440044357 :   for (; src; src = src->next)
    1570              :     {
    1571     28796237 :       if (!dv_onepart_p (src->dv))
    1572      1677409 :         attrs_list_insert (dstp, src->dv, src->offset, src->loc);
    1573              :     }
    1574    443789314 :   for (src = src2; src; src = src->next)
    1575              :     {
    1576     32541194 :       if (!dv_onepart_p (src->dv)
    1577     33492582 :           && !attrs_list_member (*dstp, src->dv, src->offset))
    1578       133428 :         attrs_list_insert (dstp, src->dv, src->offset, src->loc);
    1579              :     }
    1580    411248120 : }
    1581              : 
    1582              : /* Shared hashtable support.  */
    1583              : 
    1584              : /* Return true if VARS is shared.  */
    1585              : 
    1586              : static inline bool
    1587   1021708195 : shared_hash_shared (shared_hash *vars)
    1588              : {
    1589   1021708195 :   return vars->refcount > 1;
    1590              : }
    1591              : 
    1592              : /* Return the hash table for VARS.  */
    1593              : 
    1594              : static inline variable_table_type *
    1595   2144180868 : shared_hash_htab (shared_hash *vars)
    1596              : {
    1597   2144180868 :   return vars->htab;
    1598              : }
    1599              : 
    1600              : /* Return true if VAR is shared, or maybe because VARS is shared.  */
    1601              : 
    1602              : static inline bool
    1603   1819266395 : shared_var_p (variable *var, shared_hash *vars)
    1604              : {
    1605              :   /* Don't count an entry in the changed_variables table as a duplicate.  */
    1606   1819266395 :   return ((var->refcount > 1 + (int) var->in_changed_variables)
    1607    492266470 :           || shared_hash_shared (vars));
    1608              : }
    1609              : 
    1610              : /* Copy variables into a new hash table.  */
    1611              : 
    1612              : static shared_hash *
    1613     16954784 : shared_hash_unshare (shared_hash *vars)
    1614              : {
    1615     16954784 :   shared_hash *new_vars = new shared_hash;
    1616     16954784 :   gcc_assert (vars->refcount > 1);
    1617     16954784 :   new_vars->refcount = 1;
    1618     16954784 :   new_vars->htab = new variable_table_type (vars->htab->elements () + 3);
    1619     16954784 :   vars_copy (new_vars->htab, vars->htab);
    1620     16954784 :   vars->refcount--;
    1621     16954784 :   return new_vars;
    1622              : }
    1623              : 
    1624              : /* Increment reference counter on VARS and return it.  */
    1625              : 
    1626              : static inline shared_hash *
    1627     99508573 : shared_hash_copy (shared_hash *vars)
    1628              : {
    1629     99508573 :   vars->refcount++;
    1630     99508573 :   return vars;
    1631              : }
    1632              : 
    1633              : /* Decrement reference counter and destroy hash table if not shared
    1634              :    anymore.  */
    1635              : 
    1636              : static void
    1637    103883553 : shared_hash_destroy (shared_hash *vars)
    1638              : {
    1639    103883553 :   gcc_checking_assert (vars->refcount > 0);
    1640    103883553 :   if (--vars->refcount == 0)
    1641              :     {
    1642     21329764 :       delete vars->htab;
    1643     21329764 :       delete vars;
    1644              :     }
    1645    103883553 : }
    1646              : 
    1647              : /* Unshare *PVARS if shared and return slot for DV.  If INS is
    1648              :    INSERT, insert it if not already present.  */
    1649              : 
    1650              : static inline variable **
    1651    148489880 : shared_hash_find_slot_unshare_1 (shared_hash **pvars, decl_or_value dv,
    1652              :                                  hashval_t dvhash, enum insert_option ins)
    1653              : {
    1654    148489880 :   if (shared_hash_shared (*pvars))
    1655     16954784 :     *pvars = shared_hash_unshare (*pvars);
    1656    148489880 :   return shared_hash_htab (*pvars)->find_slot_with_hash (dv, dvhash, ins);
    1657              : }
    1658              : 
    1659              : static inline variable **
    1660     16993958 : shared_hash_find_slot_unshare (shared_hash **pvars, decl_or_value dv,
    1661              :                                enum insert_option ins)
    1662              : {
    1663     16993958 :   return shared_hash_find_slot_unshare_1 (pvars, dv, dv_htab_hash (dv), ins);
    1664              : }
    1665              : 
    1666              : /* Return slot for DV, if it is already present in the hash table.
    1667              :    If it is not present, insert it only VARS is not shared, otherwise
    1668              :    return NULL.  */
    1669              : 
    1670              : static inline variable **
    1671    234505288 : shared_hash_find_slot_1 (shared_hash *vars, decl_or_value dv, hashval_t dvhash)
    1672              : {
    1673    234505288 :   return shared_hash_htab (vars)->find_slot_with_hash (dv, dvhash,
    1674    234505288 :                                                        shared_hash_shared (vars)
    1675    234505288 :                                                        ? NO_INSERT : INSERT);
    1676              : }
    1677              : 
    1678              : static inline variable **
    1679    234505288 : shared_hash_find_slot (shared_hash *vars, decl_or_value dv)
    1680              : {
    1681    234505288 :   return shared_hash_find_slot_1 (vars, dv, dv_htab_hash (dv));
    1682              : }
    1683              : 
    1684              : /* Return slot for DV only if it is already present in the hash table.  */
    1685              : 
    1686              : static inline variable **
    1687   1051687887 : shared_hash_find_slot_noinsert_1 (shared_hash *vars, decl_or_value dv,
    1688              :                                   hashval_t dvhash)
    1689              : {
    1690   1051687887 :   return shared_hash_htab (vars)->find_slot_with_hash (dv, dvhash, NO_INSERT);
    1691              : }
    1692              : 
    1693              : static inline variable **
    1694    722505997 : shared_hash_find_slot_noinsert (shared_hash *vars, decl_or_value dv)
    1695              : {
    1696    722505997 :   return shared_hash_find_slot_noinsert_1 (vars, dv, dv_htab_hash (dv));
    1697              : }
    1698              : 
    1699              : /* Return variable for DV or NULL if not already present in the hash
    1700              :    table.  */
    1701              : 
    1702              : static inline variable *
    1703    235232840 : shared_hash_find_1 (shared_hash *vars, decl_or_value dv, hashval_t dvhash)
    1704              : {
    1705    470465680 :   return shared_hash_htab (vars)->find_with_hash (dv, dvhash);
    1706              : }
    1707              : 
    1708              : static inline variable *
    1709     56780791 : shared_hash_find (shared_hash *vars, decl_or_value dv)
    1710              : {
    1711     56780791 :   return shared_hash_find_1 (vars, dv, dv_htab_hash (dv));
    1712              : }
    1713              : 
    1714              : /* Return true if TVAL is better than CVAL as a canonical value.  We
    1715              :    choose lowest-numbered VALUEs, using the RTX address as a
    1716              :    tie-breaker.  The idea is to arrange them into a star topology,
    1717              :    such that all of them are at most one step away from the canonical
    1718              :    value, and the canonical value has backlinks to all of them, in
    1719              :    addition to all the actual locations.  We don't enforce this
    1720              :    topology throughout the entire dataflow analysis, though.
    1721              :  */
    1722              : 
    1723              : static inline bool
    1724   3509422303 : canon_value_cmp (rtx tval, rtx cval)
    1725              : {
    1726   3509422303 :   return !cval || CSELIB_VAL_UID (tval) < CSELIB_VAL_UID (cval);
    1727              : }
    1728              : 
    1729              : static bool dst_can_be_shared;
    1730              : 
    1731              : /* Return a copy of a variable VAR and insert it to dataflow set SET.  */
    1732              : 
    1733              : static variable **
    1734     60525509 : unshare_variable (dataflow_set *set, variable **slot, variable *var,
    1735              :                   enum var_init_status initialized)
    1736              : {
    1737     60525509 :   variable *new_var;
    1738     60525509 :   int i;
    1739              : 
    1740     60525509 :   new_var = onepart_pool_allocate (var->onepart);
    1741     60525509 :   new_var->dv = var->dv;
    1742     60525509 :   new_var->refcount = 1;
    1743     60525509 :   var->refcount--;
    1744     60525509 :   new_var->n_var_parts = var->n_var_parts;
    1745     60525509 :   new_var->onepart = var->onepart;
    1746     60525509 :   new_var->in_changed_variables = false;
    1747              : 
    1748     60525509 :   if (! flag_var_tracking_uninit)
    1749     60525509 :     initialized = VAR_INIT_STATUS_INITIALIZED;
    1750              : 
    1751    121439609 :   for (i = 0; i < var->n_var_parts; i++)
    1752              :     {
    1753     60914100 :       location_chain *node;
    1754     60914100 :       location_chain **nextp;
    1755              : 
    1756     60914100 :       if (i == 0 && var->onepart)
    1757              :         {
    1758              :           /* One-part auxiliary data is only used while emitting
    1759              :              notes, so propagate it to the new variable in the active
    1760              :              dataflow set.  If we're not emitting notes, this will be
    1761              :              a no-op.  */
    1762     59669879 :           gcc_checking_assert (!VAR_LOC_1PAUX (var) || emit_notes);
    1763     59669879 :           VAR_LOC_1PAUX (new_var) = VAR_LOC_1PAUX (var);
    1764     59669879 :           VAR_LOC_1PAUX (var) = NULL;
    1765     59669879 :         }
    1766              :       else
    1767      1244221 :         VAR_PART_OFFSET (new_var, i) = VAR_PART_OFFSET (var, i);
    1768     60914100 :       nextp = &new_var->var_part[i].loc_chain;
    1769    150717515 :       for (node = var->var_part[i].loc_chain; node; node = node->next)
    1770              :         {
    1771     89803415 :           location_chain *new_lc;
    1772              : 
    1773     89803415 :           new_lc = new location_chain;
    1774     89803415 :           new_lc->next = NULL;
    1775     89803415 :           if (node->init > initialized)
    1776              :             new_lc->init = node->init;
    1777              :           else
    1778     89803415 :             new_lc->init = initialized;
    1779     89803415 :           if (node->set_src && !(MEM_P (node->set_src)))
    1780        84477 :             new_lc->set_src = node->set_src;
    1781              :           else
    1782     89718938 :             new_lc->set_src = NULL;
    1783     89803415 :           new_lc->loc = node->loc;
    1784              : 
    1785     89803415 :           *nextp = new_lc;
    1786     89803415 :           nextp = &new_lc->next;
    1787              :         }
    1788              : 
    1789     60914100 :       new_var->var_part[i].cur_loc = var->var_part[i].cur_loc;
    1790              :     }
    1791              : 
    1792     60525509 :   dst_can_be_shared = false;
    1793     60525509 :   if (shared_hash_shared (set->vars))
    1794      5171218 :     slot = shared_hash_find_slot_unshare (&set->vars, var->dv, NO_INSERT);
    1795     55354291 :   else if (set->traversed_vars && set->vars != set->traversed_vars)
    1796       217262 :     slot = shared_hash_find_slot_noinsert (set->vars, var->dv);
    1797     60525509 :   *slot = new_var;
    1798     60525509 :   if (var->in_changed_variables)
    1799              :     {
    1800            0 :       variable **cslot
    1801            0 :         = changed_variables->find_slot_with_hash (var->dv,
    1802              :                                                   dv_htab_hash (var->dv),
    1803              :                                                   NO_INSERT);
    1804            0 :       gcc_assert (*cslot == (void *) var);
    1805            0 :       var->in_changed_variables = false;
    1806            0 :       variable_htab_free (var);
    1807            0 :       *cslot = new_var;
    1808            0 :       new_var->in_changed_variables = true;
    1809              :     }
    1810     60525509 :   return slot;
    1811              : }
    1812              : 
    1813              : /* Copy all variables from hash table SRC to hash table DST.  */
    1814              : 
    1815              : static void
    1816     16954784 : vars_copy (variable_table_type *dst, variable_table_type *src)
    1817              : {
    1818     16954784 :   variable_iterator_type hi;
    1819     16954784 :   variable *var;
    1820              : 
    1821    671994621 :   FOR_EACH_HASH_TABLE_ELEMENT (*src, var, variable, hi)
    1822              :     {
    1823    655039837 :       variable **dstp;
    1824    655039837 :       var->refcount++;
    1825    655039837 :       dstp = dst->find_slot_with_hash (var->dv, dv_htab_hash (var->dv), INSERT);
    1826    655039837 :       *dstp = var;
    1827              :     }
    1828     16954784 : }
    1829              : 
    1830              : /* Map a decl to its main debug decl.  */
    1831              : 
    1832              : static inline tree
    1833     74930604 : var_debug_decl (tree decl)
    1834              : {
    1835     74930604 :   if (decl && VAR_P (decl) && DECL_HAS_DEBUG_EXPR_P (decl))
    1836              :     {
    1837      2524996 :       tree debugdecl = DECL_DEBUG_EXPR (decl);
    1838      2524996 :       if (DECL_P (debugdecl))
    1839     74930604 :         decl = debugdecl;
    1840              :     }
    1841              : 
    1842     74930604 :   return decl;
    1843              : }
    1844              : 
    1845              : /* Set the register LOC to contain DV, OFFSET.  */
    1846              : 
    1847              : static void
    1848     67902227 : var_reg_decl_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
    1849              :                   decl_or_value dv, HOST_WIDE_INT offset, rtx set_src,
    1850              :                   enum insert_option iopt)
    1851              : {
    1852     67902227 :   attrs *node;
    1853     67902227 :   bool decl_p = dv_is_decl_p (dv);
    1854              : 
    1855     67902227 :   if (decl_p)
    1856      1650186 :     dv = dv_from_decl (var_debug_decl (dv_as_decl (dv)));
    1857              : 
    1858     71216090 :   for (node = set->regs[REGNO (loc)]; node; node = node->next)
    1859      4584609 :     if (node->dv == dv && node->offset == offset)
    1860              :       break;
    1861     67902227 :   if (!node)
    1862     66631481 :     attrs_list_insert (&set->regs[REGNO (loc)], dv, offset, loc);
    1863     67902227 :   set_variable_part (set, loc, dv, offset, initialized, set_src, iopt);
    1864     67902227 : }
    1865              : 
    1866              : /* Return true if we should track a location that is OFFSET bytes from
    1867              :    a variable.  Store the constant offset in *OFFSET_OUT if so.  */
    1868              : 
    1869              : static bool
    1870     18160707 : track_offset_p (poly_int64 offset, HOST_WIDE_INT *offset_out)
    1871              : {
    1872     18160707 :   HOST_WIDE_INT const_offset;
    1873     16289163 :   if (!offset.is_constant (&const_offset)
    1874     18160707 :       || !IN_RANGE (const_offset, 0, MAX_VAR_PARTS - 1))
    1875              :     return false;
    1876     18160399 :   *offset_out = const_offset;
    1877            0 :   return true;
    1878              : }
    1879              : 
    1880              : /* Return the offset of a register that track_offset_p says we
    1881              :    should track.  */
    1882              : 
    1883              : static HOST_WIDE_INT
    1884      2090817 : get_tracked_reg_offset (rtx loc)
    1885              : {
    1886      2090817 :   HOST_WIDE_INT offset;
    1887      2090817 :   if (!track_offset_p (REG_OFFSET (loc), &offset))
    1888            0 :     gcc_unreachable ();
    1889      2090817 :   return offset;
    1890              : }
    1891              : 
    1892              : /* Set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC).  */
    1893              : 
    1894              : static void
    1895      1650186 : var_reg_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
    1896              :              rtx set_src)
    1897              : {
    1898      1650186 :   tree decl = REG_EXPR (loc);
    1899      1650186 :   HOST_WIDE_INT offset = get_tracked_reg_offset (loc);
    1900              : 
    1901      1650186 :   var_reg_decl_set (set, loc, initialized,
    1902              :                     dv_from_decl (decl), offset, set_src, INSERT);
    1903      1650186 : }
    1904              : 
    1905              : static enum var_init_status
    1906        62850 : get_init_value (dataflow_set *set, rtx loc, decl_or_value dv)
    1907              : {
    1908        62850 :   variable *var;
    1909        62850 :   int i;
    1910        62850 :   enum var_init_status ret_val = VAR_INIT_STATUS_UNKNOWN;
    1911              : 
    1912        62850 :   if (! flag_var_tracking_uninit)
    1913              :     return VAR_INIT_STATUS_INITIALIZED;
    1914              : 
    1915            0 :   var = shared_hash_find (set->vars, dv);
    1916            0 :   if (var)
    1917              :     {
    1918            0 :       for (i = 0; i < var->n_var_parts && ret_val == VAR_INIT_STATUS_UNKNOWN; i++)
    1919              :         {
    1920            0 :           location_chain *nextp;
    1921            0 :           for (nextp = var->var_part[i].loc_chain; nextp; nextp = nextp->next)
    1922            0 :             if (rtx_equal_p (nextp->loc, loc))
    1923              :               {
    1924            0 :                 ret_val = nextp->init;
    1925            0 :                 break;
    1926              :               }
    1927              :         }
    1928              :     }
    1929              : 
    1930              :   return ret_val;
    1931              : }
    1932              : 
    1933              : /* Delete current content of register LOC in dataflow set SET and set
    1934              :    the register to contain REG_EXPR (LOC), REG_OFFSET (LOC).  If
    1935              :    MODIFY is true, any other live copies of the same variable part are
    1936              :    also deleted from the dataflow set, otherwise the variable part is
    1937              :    assumed to be copied from another location holding the same
    1938              :    part.  */
    1939              : 
    1940              : static void
    1941       396046 : var_reg_delete_and_set (dataflow_set *set, rtx loc, bool modify,
    1942              :                         enum var_init_status initialized, rtx set_src)
    1943              : {
    1944       396046 :   tree decl = REG_EXPR (loc);
    1945       396046 :   HOST_WIDE_INT offset = get_tracked_reg_offset (loc);
    1946       396046 :   attrs *node, *next;
    1947       396046 :   attrs **nextp;
    1948              : 
    1949       396046 :   decl = var_debug_decl (decl);
    1950              : 
    1951       396046 :   if (initialized == VAR_INIT_STATUS_UNKNOWN)
    1952            0 :     initialized = get_init_value (set, loc, dv_from_decl (decl));
    1953              : 
    1954       396046 :   nextp = &set->regs[REGNO (loc)];
    1955       623368 :   for (node = *nextp; node; node = next)
    1956              :     {
    1957       227322 :       next = node->next;
    1958       227322 :       if (node->dv != decl || node->offset != offset)
    1959              :         {
    1960       202062 :           delete_variable_part (set, node->loc, node->dv, node->offset);
    1961       202062 :           delete node;
    1962       202062 :           *nextp = next;
    1963              :         }
    1964              :       else
    1965              :         {
    1966        25260 :           node->loc = loc;
    1967        25260 :           nextp = &node->next;
    1968              :         }
    1969              :     }
    1970       396046 :   if (modify)
    1971       268509 :     clobber_variable_part (set, loc, dv_from_decl (decl), offset, set_src);
    1972       396046 :   var_reg_set (set, loc, initialized, set_src);
    1973       396046 : }
    1974              : 
    1975              : /* Delete the association of register LOC in dataflow set SET with any
    1976              :    variables that aren't onepart.  If CLOBBER is true, also delete any
    1977              :    other live copies of the same variable part, and delete the
    1978              :    association with onepart dvs too.  */
    1979              : 
    1980              : static void
    1981     63932262 : var_reg_delete (dataflow_set *set, rtx loc, bool clobber)
    1982              : {
    1983     63932262 :   attrs **nextp = &set->regs[REGNO (loc)];
    1984     63932262 :   attrs *node, *next;
    1985              : 
    1986     63932262 :   HOST_WIDE_INT offset;
    1987     63932262 :   if (clobber && track_offset_p (REG_OFFSET (loc), &offset))
    1988              :     {
    1989     14198038 :       tree decl = REG_EXPR (loc);
    1990              : 
    1991     14198038 :       decl = var_debug_decl (decl);
    1992              : 
    1993     14198038 :       clobber_variable_part (set, NULL, dv_from_decl (decl), offset, NULL);
    1994              :     }
    1995              : 
    1996    117723174 :   for (node = *nextp; node; node = next)
    1997              :     {
    1998     53790912 :       next = node->next;
    1999     53790912 :       if (clobber || !dv_onepart_p (node->dv))
    2000              :         {
    2001      3387721 :           delete_variable_part (set, node->loc, node->dv, node->offset);
    2002      3387721 :           delete node;
    2003      3387721 :           *nextp = next;
    2004              :         }
    2005              :       else
    2006     50403191 :         nextp = &node->next;
    2007              :     }
    2008     63932262 : }
    2009              : 
    2010              : /* Delete content of register with number REGNO in dataflow set SET.  */
    2011              : 
    2012              : static void
    2013    662868906 : var_regno_delete (dataflow_set *set, int regno)
    2014              : {
    2015    662868906 :   attrs **reg = &set->regs[regno];
    2016    662868906 :   attrs *node, *next;
    2017              : 
    2018    715315570 :   for (node = *reg; node; node = next)
    2019              :     {
    2020     52446664 :       next = node->next;
    2021     52446664 :       delete_variable_part (set, node->loc, node->dv, node->offset);
    2022     52446664 :       delete node;
    2023              :     }
    2024    662868906 :   *reg = NULL;
    2025    662868906 : }
    2026              : 
    2027              : /* Return true if I is the negated value of a power of two.  */
    2028              : static bool
    2029       213410 : negative_power_of_two_p (HOST_WIDE_INT i)
    2030              : {
    2031       213410 :   unsigned HOST_WIDE_INT x = -(unsigned HOST_WIDE_INT)i;
    2032       213410 :   return pow2_or_zerop (x);
    2033              : }
    2034              : 
    2035              : /* Strip constant offsets and alignments off of LOC.  Return the base
    2036              :    expression.  */
    2037              : 
    2038              : static rtx
    2039     10911874 : vt_get_canonicalize_base (rtx loc)
    2040              : {
    2041     10911874 :   while ((GET_CODE (loc) == PLUS
    2042     10911874 :           || GET_CODE (loc) == AND)
    2043            0 :          && GET_CODE (XEXP (loc, 1)) == CONST_INT
    2044     10911874 :          && (GET_CODE (loc) != AND
    2045            0 :              || negative_power_of_two_p (INTVAL (XEXP (loc, 1)))))
    2046            0 :     loc = XEXP (loc, 0);
    2047              : 
    2048     10911874 :   return loc;
    2049              : }
    2050              : 
    2051              : /* This caches canonicalized addresses for VALUEs, computed using
    2052              :    information in the global cselib table.  */
    2053              : static hash_map<rtx, rtx> *global_get_addr_cache;
    2054              : 
    2055              : /* This caches canonicalized addresses for VALUEs, computed using
    2056              :    information from the global cache and information pertaining to a
    2057              :    basic block being analyzed.  */
    2058              : static hash_map<rtx, rtx> *local_get_addr_cache;
    2059              : 
    2060              : static rtx vt_canonicalize_addr (dataflow_set *, rtx);
    2061              : 
    2062              : /* Return the canonical address for LOC, that must be a VALUE, using a
    2063              :    cached global equivalence or computing it and storing it in the
    2064              :    global cache.  */
    2065              : 
    2066              : static rtx
    2067    104238910 : get_addr_from_global_cache (rtx const loc)
    2068              : {
    2069    104238910 :   rtx x;
    2070              : 
    2071    104238910 :   gcc_checking_assert (GET_CODE (loc) == VALUE);
    2072              : 
    2073    104238910 :   bool existed;
    2074    104238910 :   rtx *slot = &global_get_addr_cache->get_or_insert (loc, &existed);
    2075    104238910 :   if (existed)
    2076     94044356 :     return *slot;
    2077              : 
    2078     10194554 :   x = canon_rtx (get_addr (loc));
    2079              : 
    2080              :   /* Tentative, avoiding infinite recursion.  */
    2081     10194554 :   *slot = x;
    2082              : 
    2083     10194554 :   if (x != loc)
    2084              :     {
    2085      8385566 :       rtx nx = vt_canonicalize_addr (NULL, x);
    2086      8385566 :       if (nx != x)
    2087              :         {
    2088              :           /* The table may have moved during recursion, recompute
    2089              :              SLOT.  */
    2090      4864609 :           *global_get_addr_cache->get (loc) = x = nx;
    2091              :         }
    2092              :     }
    2093              : 
    2094              :   return x;
    2095              : }
    2096              : 
    2097              : /* Return the canonical address for LOC, that must be a VALUE, using a
    2098              :    cached local equivalence or computing it and storing it in the
    2099              :    local cache.  */
    2100              : 
    2101              : static rtx
    2102    620491309 : get_addr_from_local_cache (dataflow_set *set, rtx const loc)
    2103              : {
    2104    620491309 :   rtx x;
    2105    620491309 :   decl_or_value dv;
    2106    620491309 :   variable *var;
    2107    620491309 :   location_chain *l;
    2108              : 
    2109    620491309 :   gcc_checking_assert (GET_CODE (loc) == VALUE);
    2110              : 
    2111    620491309 :   bool existed;
    2112    620491309 :   rtx *slot = &local_get_addr_cache->get_or_insert (loc, &existed);
    2113    620491309 :   if (existed)
    2114    523211679 :     return *slot;
    2115              : 
    2116     97279630 :   x = get_addr_from_global_cache (loc);
    2117              : 
    2118              :   /* Tentative, avoiding infinite recursion.  */
    2119     97279630 :   *slot = x;
    2120              : 
    2121              :   /* Recurse to cache local expansion of X, or if we need to search
    2122              :      for a VALUE in the expansion.  */
    2123     97279630 :   if (x != loc)
    2124              :     {
    2125     89005601 :       rtx nx = vt_canonicalize_addr (set, x);
    2126     89005601 :       if (nx != x)
    2127              :         {
    2128      7956307 :           slot = local_get_addr_cache->get (loc);
    2129      7956307 :           *slot = x = nx;
    2130              :         }
    2131              :       return x;
    2132              :     }
    2133              : 
    2134      8274029 :   dv = dv_from_rtx (x);
    2135      8274029 :   var = shared_hash_find (set->vars, dv);
    2136      8274029 :   if (!var)
    2137              :     return x;
    2138              : 
    2139              :   /* Look for an improved equivalent expression.  */
    2140     14614416 :   for (l = var->var_part[0].loc_chain; l; l = l->next)
    2141              :     {
    2142     10911874 :       rtx base = vt_get_canonicalize_base (l->loc);
    2143     10911874 :       if (GET_CODE (base) == VALUE
    2144     10911874 :           && canon_value_cmp (base, loc))
    2145              :         {
    2146      3707776 :           rtx nx = vt_canonicalize_addr (set, l->loc);
    2147      3707776 :           if (x != nx)
    2148              :             {
    2149      3707776 :               slot = local_get_addr_cache->get (loc);
    2150      3707776 :               *slot = x = nx;
    2151              :             }
    2152              :           break;
    2153              :         }
    2154              :     }
    2155              : 
    2156              :   return x;
    2157              : }
    2158              : 
    2159              : /* Canonicalize LOC using equivalences from SET in addition to those
    2160              :    in the cselib static table.  It expects a VALUE-based expression,
    2161              :    and it will only substitute VALUEs with other VALUEs or
    2162              :    function-global equivalences, so that, if two addresses have base
    2163              :    VALUEs that are locally or globally related in ways that
    2164              :    memrefs_conflict_p cares about, they will both canonicalize to
    2165              :    expressions that have the same base VALUE.
    2166              : 
    2167              :    The use of VALUEs as canonical base addresses enables the canonical
    2168              :    RTXs to remain unchanged globally, if they resolve to a constant,
    2169              :    or throughout a basic block otherwise, so that they can be cached
    2170              :    and the cache needs not be invalidated when REGs, MEMs or such
    2171              :    change.  */
    2172              : 
    2173              : static rtx
    2174    706302660 : vt_canonicalize_addr (dataflow_set *set, rtx oloc)
    2175              : {
    2176    706302660 :   poly_int64 ofst = 0, term;
    2177    706302660 :   machine_mode mode = GET_MODE (oloc);
    2178    706302660 :   rtx loc = oloc;
    2179    706302660 :   rtx x;
    2180    706302660 :   bool retry = true;
    2181              : 
    2182   1412391913 :   while (retry)
    2183              :     {
    2184    794557156 :       while (GET_CODE (loc) == PLUS
    2185    794557156 :              && poly_int_rtx_p (XEXP (loc, 1), &term))
    2186              :         {
    2187     88254496 :           ofst += term;
    2188     88254496 :           loc = XEXP (loc, 0);
    2189              :         }
    2190              : 
    2191              :       /* Alignment operations can't normally be combined, so just
    2192              :          canonicalize the base and we're done.  We'll normally have
    2193              :          only one stack alignment anyway.  */
    2194    706302660 :       if (GET_CODE (loc) == AND
    2195       213435 :           && GET_CODE (XEXP (loc, 1)) == CONST_INT
    2196    706516070 :           && negative_power_of_two_p (INTVAL (XEXP (loc, 1))))
    2197              :         {
    2198       213407 :           x = vt_canonicalize_addr (set, XEXP (loc, 0));
    2199       213407 :           if (x != XEXP (loc, 0))
    2200        19042 :             loc = gen_rtx_AND (mode, x, XEXP (loc, 1));
    2201              :           retry = false;
    2202              :         }
    2203              : 
    2204    706302660 :       if (GET_CODE (loc) == VALUE)
    2205              :         {
    2206    627450589 :           if (set)
    2207    620491309 :             loc = get_addr_from_local_cache (set, loc);
    2208              :           else
    2209      6959280 :             loc = get_addr_from_global_cache (loc);
    2210              : 
    2211              :           /* Consolidate plus_constants.  */
    2212    636606354 :           while (maybe_ne (ofst, 0)
    2213     27772674 :                  && GET_CODE (loc) == PLUS
    2214    733861927 :                  && poly_int_rtx_p (XEXP (loc, 1), &term))
    2215              :             {
    2216      9155765 :               ofst += term;
    2217      9155765 :               loc = XEXP (loc, 0);
    2218              :             }
    2219              : 
    2220              :           retry = false;
    2221              :         }
    2222              :       else
    2223              :         {
    2224     78852071 :           x = canon_rtx (loc);
    2225     78852071 :           if (retry)
    2226     78638664 :             retry = (x != loc);
    2227     78638664 :           loc = x;
    2228              :         }
    2229              :     }
    2230              : 
    2231              :   /* Add OFST back in.  */
    2232    706302660 :   if (maybe_ne (ofst, 0))
    2233              :     {
    2234              :       /* Don't build new RTL if we can help it.  */
    2235     88215994 :       if (strip_offset (oloc, &term) == loc && known_eq (term, ofst))
    2236              :         return oloc;
    2237              : 
    2238     12753767 :       loc = plus_constant (mode, loc, ofst);
    2239              :     }
    2240              : 
    2241              :   return loc;
    2242              : }
    2243              : 
    2244              : /* Return true iff there's a true dependence between MLOC and LOC.
    2245              :    MADDR must be a canonicalized version of MLOC's address.  */
    2246              : 
    2247              : static inline bool
    2248   1487104158 : vt_canon_true_dep (dataflow_set *set, rtx mloc, rtx maddr, rtx loc)
    2249              : {
    2250   1487104158 :   if (GET_CODE (loc) != MEM)
    2251              :     return false;
    2252              : 
    2253    585364535 :   rtx addr = vt_canonicalize_addr (set, XEXP (loc, 0));
    2254    585364535 :   if (!canon_true_dependence (mloc, GET_MODE (mloc), maddr, loc, addr))
    2255              :     return false;
    2256              : 
    2257              :   return true;
    2258              : }
    2259              : 
    2260              : /* Hold parameters for the hashtab traversal function
    2261              :    drop_overlapping_mem_locs, see below.  */
    2262              : 
    2263              : struct overlapping_mems
    2264              : {
    2265              :   dataflow_set *set;
    2266              :   rtx loc, addr;
    2267              : };
    2268              : 
    2269              : /* Remove all MEMs that overlap with COMS->LOC from the location list
    2270              :    of a hash table entry for a onepart variable.  COMS->ADDR must be a
    2271              :    canonicalized form of COMS->LOC's address, and COMS->LOC must be
    2272              :    canonicalized itself.  */
    2273              : 
    2274              : int
    2275   1206674265 : drop_overlapping_mem_locs (variable **slot, overlapping_mems *coms)
    2276              : {
    2277   1206674265 :   dataflow_set *set = coms->set;
    2278   1206674265 :   rtx mloc = coms->loc, addr = coms->addr;
    2279   1206674265 :   variable *var = *slot;
    2280              : 
    2281   1206674265 :   if (var->onepart != NOT_ONEPART)
    2282              :     {
    2283   1201809179 :       location_chain *loc, **locp;
    2284   1201809179 :       bool changed = false;
    2285   1201809179 :       rtx cur_loc;
    2286              : 
    2287   1201809179 :       gcc_assert (var->n_var_parts == 1);
    2288              : 
    2289   1201809179 :       if (shared_var_p (var, set->vars))
    2290              :         {
    2291   2058278935 :           for (loc = var->var_part[0].loc_chain; loc; loc = loc->next)
    2292   1105121008 :             if (vt_canon_true_dep (set, mloc, addr, loc->loc))
    2293              :               break;
    2294              : 
    2295    958143569 :           if (!loc)
    2296              :             return 1;
    2297              : 
    2298      4985642 :           slot = unshare_variable (set, slot, var, VAR_INIT_STATUS_UNKNOWN);
    2299      4985642 :           var = *slot;
    2300      4985642 :           gcc_assert (var->n_var_parts == 1);
    2301              :         }
    2302              : 
    2303    248651252 :       if (VAR_LOC_1PAUX (var))
    2304     39344311 :         cur_loc = VAR_LOC_FROM (var);
    2305              :       else
    2306    209306941 :         cur_loc = var->var_part[0].cur_loc;
    2307              : 
    2308    248651252 :       for (locp = &var->var_part[0].loc_chain, loc = *locp;
    2309    630634402 :            loc; loc = *locp)
    2310              :         {
    2311    381983150 :           if (!vt_canon_true_dep (set, mloc, addr, loc->loc))
    2312              :             {
    2313    372282858 :               locp = &loc->next;
    2314    372282858 :               continue;
    2315              :             }
    2316              : 
    2317      9700292 :           *locp = loc->next;
    2318              :           /* If we have deleted the location which was last emitted
    2319              :              we have to emit new location so add the variable to set
    2320              :              of changed variables.  */
    2321      9700292 :           if (cur_loc == loc->loc)
    2322              :             {
    2323       494139 :               changed = true;
    2324       494139 :               var->var_part[0].cur_loc = NULL;
    2325       494139 :               if (VAR_LOC_1PAUX (var))
    2326       494139 :                 VAR_LOC_FROM (var) = NULL;
    2327              :             }
    2328      9700292 :           delete loc;
    2329              :         }
    2330              : 
    2331    248651252 :       if (!var->var_part[0].loc_chain)
    2332              :         {
    2333      4863790 :           var->n_var_parts--;
    2334      4863790 :           changed = true;
    2335              :         }
    2336    248651252 :       if (changed)
    2337      4938336 :         variable_was_changed (var, set);
    2338              :     }
    2339              : 
    2340              :   return 1;
    2341              : }
    2342              : 
    2343              : /* Remove from SET all VALUE bindings to MEMs that overlap with LOC.  */
    2344              : 
    2345              : static void
    2346     19625775 : clobber_overlapping_mems (dataflow_set *set, rtx loc)
    2347              : {
    2348     19625775 :   struct overlapping_mems coms;
    2349              : 
    2350     19625775 :   gcc_checking_assert (GET_CODE (loc) == MEM);
    2351              : 
    2352     19625775 :   coms.set = set;
    2353     19625775 :   coms.loc = canon_rtx (loc);
    2354     19625775 :   coms.addr = vt_canonicalize_addr (set, XEXP (loc, 0));
    2355              : 
    2356     19625775 :   set->traversed_vars = set->vars;
    2357     19625775 :   shared_hash_htab (set->vars)
    2358   1226300040 :     ->traverse <overlapping_mems*, drop_overlapping_mem_locs> (&coms);
    2359     19625775 :   set->traversed_vars = NULL;
    2360     19625775 : }
    2361              : 
    2362              : /* Set the location of DV, OFFSET as the MEM LOC.  */
    2363              : 
    2364              : static void
    2365     40045899 : var_mem_decl_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
    2366              :                   decl_or_value dv, HOST_WIDE_INT offset, rtx set_src,
    2367              :                   enum insert_option iopt)
    2368              : {
    2369     40045899 :   if (dv_is_decl_p (dv))
    2370        70659 :     dv = dv_from_decl (var_debug_decl (dv_as_decl (dv)));
    2371              : 
    2372     40045899 :   set_variable_part (set, loc, dv, offset, initialized, set_src, iopt);
    2373     40045899 : }
    2374              : 
    2375              : /* Set the location part of variable MEM_EXPR (LOC) in dataflow set
    2376              :    SET to LOC.
    2377              :    Adjust the address first if it is stack pointer based.  */
    2378              : 
    2379              : static void
    2380        70659 : var_mem_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
    2381              :              rtx set_src)
    2382              : {
    2383        70659 :   tree decl = MEM_EXPR (loc);
    2384        70659 :   HOST_WIDE_INT offset = int_mem_offset (loc);
    2385              : 
    2386        70659 :   var_mem_decl_set (set, loc, initialized,
    2387              :                     dv_from_decl (decl), offset, set_src, INSERT);
    2388        70659 : }
    2389              : 
    2390              : /* Delete and set the location part of variable MEM_EXPR (LOC) in
    2391              :    dataflow set SET to LOC.  If MODIFY is true, any other live copies
    2392              :    of the same variable part are also deleted from the dataflow set,
    2393              :    otherwise the variable part is assumed to be copied from another
    2394              :    location holding the same part.
    2395              :    Adjust the address first if it is stack pointer based.  */
    2396              : 
    2397              : static void
    2398        10493 : var_mem_delete_and_set (dataflow_set *set, rtx loc, bool modify,
    2399              :                         enum var_init_status initialized, rtx set_src)
    2400              : {
    2401        10493 :   tree decl = MEM_EXPR (loc);
    2402        10493 :   HOST_WIDE_INT offset = int_mem_offset (loc);
    2403              : 
    2404        10493 :   clobber_overlapping_mems (set, loc);
    2405        10493 :   decl = var_debug_decl (decl);
    2406              : 
    2407        10493 :   if (initialized == VAR_INIT_STATUS_UNKNOWN)
    2408            0 :     initialized = get_init_value (set, loc, dv_from_decl (decl));
    2409              : 
    2410        10493 :   if (modify)
    2411         4761 :     clobber_variable_part (set, NULL, dv_from_decl (decl), offset, set_src);
    2412        10493 :   var_mem_set (set, loc, initialized, set_src);
    2413        10493 : }
    2414              : 
    2415              : /* Delete the location part LOC from dataflow set SET.  If CLOBBER is
    2416              :    true, also delete any other live copies of the same variable part.
    2417              :    Adjust the address first if it is stack pointer based.  */
    2418              : 
    2419              : static void
    2420            6 : var_mem_delete (dataflow_set *set, rtx loc, bool clobber)
    2421              : {
    2422            6 :   tree decl = MEM_EXPR (loc);
    2423            6 :   HOST_WIDE_INT offset = int_mem_offset (loc);
    2424              : 
    2425            6 :   clobber_overlapping_mems (set, loc);
    2426            6 :   decl = var_debug_decl (decl);
    2427            6 :   if (clobber)
    2428            6 :     clobber_variable_part (set, NULL, dv_from_decl (decl), offset, NULL);
    2429            6 :   delete_variable_part (set, loc, dv_from_decl (decl), offset);
    2430            6 : }
    2431              : 
    2432              : /* Return true if LOC should not be expanded for location expressions,
    2433              :    or used in them.  */
    2434              : 
    2435              : static inline bool
    2436    281628896 : unsuitable_loc (rtx loc)
    2437              : {
    2438     18798892 :   switch (GET_CODE (loc))
    2439              :     {
    2440              :     case PC:
    2441              :     case SCRATCH:
    2442              :     case ASM_INPUT:
    2443              :     case ASM_OPERANDS:
    2444              :       return true;
    2445              : 
    2446    257357011 :     default:
    2447    257357011 :       return false;
    2448              :     }
    2449              : }
    2450              : 
    2451              : /* Bind VAL to LOC in SET.  If MODIFIED, detach LOC from any values
    2452              :    bound to it.  */
    2453              : 
    2454              : static inline void
    2455    105552448 : val_bind (dataflow_set *set, rtx val, rtx loc, bool modified)
    2456              : {
    2457    105552448 :   if (REG_P (loc))
    2458              :     {
    2459     65577208 :       if (modified)
    2460     54673517 :         var_regno_delete (set, REGNO (loc));
    2461     65577208 :       var_reg_decl_set (set, loc, VAR_INIT_STATUS_INITIALIZED,
    2462              :                         dv_from_value (val), 0, NULL_RTX, INSERT);
    2463              :     }
    2464     39975240 :   else if (MEM_P (loc))
    2465              :     {
    2466     39975240 :       struct elt_loc_list *l = CSELIB_VAL_PTR (val)->locs;
    2467              : 
    2468     39975240 :       if (modified)
    2469     19615276 :         clobber_overlapping_mems (set, loc);
    2470              : 
    2471     39975240 :       if (l && GET_CODE (l->loc) == VALUE)
    2472      1050125 :         l = canonical_cselib_val (CSELIB_VAL_PTR (l->loc))->locs;
    2473              : 
    2474              :       /* If this MEM is a global constant, we don't need it in the
    2475              :          dynamic tables.  ??? We should test this before emitting the
    2476              :          micro-op in the first place.  */
    2477     50300766 :       while (l)
    2478     10325526 :         if (GET_CODE (l->loc) == MEM && XEXP (l->loc, 0) == XEXP (loc, 0))
    2479              :           break;
    2480              :         else
    2481     10325526 :           l = l->next;
    2482              : 
    2483     39975240 :       if (!l)
    2484     39975240 :         var_mem_decl_set (set, loc, VAR_INIT_STATUS_INITIALIZED,
    2485              :                           dv_from_value (val), 0, NULL_RTX, INSERT);
    2486              :     }
    2487              :   else
    2488              :     {
    2489              :       /* Other kinds of equivalences are necessarily static, at least
    2490              :          so long as we do not perform substitutions while merging
    2491              :          expressions.  */
    2492            0 :       gcc_unreachable ();
    2493              :       set_variable_part (set, loc, dv_from_value (val), 0,
    2494              :                          VAR_INIT_STATUS_INITIALIZED, NULL_RTX, INSERT);
    2495              :     }
    2496    105552448 : }
    2497              : 
    2498              : /* Bind a value to a location it was just stored in.  If MODIFIED
    2499              :    holds, assume the location was modified, detaching it from any
    2500              :    values bound to it.  */
    2501              : 
    2502              : static void
    2503     74288793 : val_store (dataflow_set *set, rtx val, rtx loc, rtx_insn *insn,
    2504              :            bool modified)
    2505              : {
    2506     74288793 :   cselib_val *v = CSELIB_VAL_PTR (val);
    2507              : 
    2508     74288793 :   gcc_assert (cselib_preserved_value_p (v));
    2509              : 
    2510     74288793 :   if (dump_file)
    2511              :     {
    2512          442 :       fprintf (dump_file, "%i: ", insn ? INSN_UID (insn) : 0);
    2513          442 :       print_inline_rtx (dump_file, loc, 0);
    2514          442 :       fprintf (dump_file, " evaluates to ");
    2515          442 :       print_inline_rtx (dump_file, val, 0);
    2516          442 :       if (v->locs)
    2517              :         {
    2518              :           struct elt_loc_list *l;
    2519          778 :           for (l = v->locs; l; l = l->next)
    2520              :             {
    2521          434 :               fprintf (dump_file, "\n%i: ",
    2522          434 :                        l->setting_insn ? INSN_UID (l->setting_insn) : -1);
    2523          434 :               print_inline_rtx (dump_file, l->loc, 0);
    2524              :             }
    2525              :         }
    2526          442 :       fprintf (dump_file, "\n");
    2527              :     }
    2528              : 
    2529     74288793 :   gcc_checking_assert (!unsuitable_loc (loc));
    2530              : 
    2531     74288793 :   val_bind (set, val, loc, modified);
    2532     74288793 : }
    2533              : 
    2534              : /* Clear (canonical address) slots that reference X.  */
    2535              : 
    2536              : bool
    2537            0 : local_get_addr_clear_given_value (rtx const &, rtx *slot, rtx x)
    2538              : {
    2539            0 :   if (vt_get_canonicalize_base (*slot) == x)
    2540            0 :     *slot = NULL;
    2541            0 :   return true;
    2542              : }
    2543              : 
    2544              : /* Reset this node, detaching all its equivalences.  Return the slot
    2545              :    in the variable hash table that holds dv, if there is one.  */
    2546              : 
    2547              : static void
    2548     42095029 : val_reset (dataflow_set *set, decl_or_value dv)
    2549              : {
    2550     42095029 :   variable *var = shared_hash_find (set->vars, dv) ;
    2551     42095029 :   location_chain *node;
    2552     42095029 :   rtx cval;
    2553              : 
    2554     42095029 :   if (!var || !var->n_var_parts)
    2555              :     return;
    2556              : 
    2557            0 :   gcc_assert (var->n_var_parts == 1);
    2558              : 
    2559            0 :   if (var->onepart == ONEPART_VALUE)
    2560              :     {
    2561            0 :       rtx x = dv_as_value (dv);
    2562              : 
    2563              :       /* Relationships in the global cache don't change, so reset the
    2564              :          local cache entry only.  */
    2565            0 :       rtx *slot = local_get_addr_cache->get (x);
    2566            0 :       if (slot)
    2567              :         {
    2568              :           /* If the value resolved back to itself, odds are that other
    2569              :              values may have cached it too.  These entries now refer
    2570              :              to the old X, so detach them too.  Entries that used the
    2571              :              old X but resolved to something else remain ok as long as
    2572              :              that something else isn't also reset.  */
    2573            0 :           if (*slot == x)
    2574            0 :             local_get_addr_cache
    2575            0 :               ->traverse<rtx, local_get_addr_clear_given_value> (x);
    2576            0 :           *slot = NULL;
    2577              :         }
    2578              :     }
    2579              : 
    2580            0 :   cval = NULL;
    2581            0 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    2582            0 :     if (GET_CODE (node->loc) == VALUE
    2583            0 :         && canon_value_cmp (node->loc, cval))
    2584              :       cval = node->loc;
    2585              : 
    2586            0 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    2587            0 :     if (GET_CODE (node->loc) == VALUE && cval != node->loc)
    2588              :       {
    2589              :         /* Redirect the equivalence link to the new canonical
    2590              :            value, or simply remove it if it would point at
    2591              :            itself.  */
    2592            0 :         if (cval)
    2593            0 :           set_variable_part (set, cval, dv_from_value (node->loc),
    2594              :                              0, node->init, node->set_src, NO_INSERT);
    2595            0 :         delete_variable_part (set, dv_as_value (dv),
    2596              :                               dv_from_value (node->loc), 0);
    2597              :       }
    2598              : 
    2599            0 :   if (cval)
    2600              :     {
    2601            0 :       decl_or_value cdv = dv_from_value (cval);
    2602              : 
    2603              :       /* Keep the remaining values connected, accumulating links
    2604              :          in the canonical value.  */
    2605            0 :       for (node = var->var_part[0].loc_chain; node; node = node->next)
    2606              :         {
    2607            0 :           if (node->loc == cval)
    2608            0 :             continue;
    2609            0 :           else if (GET_CODE (node->loc) == REG)
    2610            0 :             var_reg_decl_set (set, node->loc, node->init, cdv, 0,
    2611              :                               node->set_src, NO_INSERT);
    2612            0 :           else if (GET_CODE (node->loc) == MEM)
    2613            0 :             var_mem_decl_set (set, node->loc, node->init, cdv, 0,
    2614              :                               node->set_src, NO_INSERT);
    2615              :           else
    2616            0 :             set_variable_part (set, node->loc, cdv, 0,
    2617              :                                node->init, node->set_src, NO_INSERT);
    2618              :         }
    2619              :     }
    2620              : 
    2621              :   /* We remove this last, to make sure that the canonical value is not
    2622              :      removed to the point of requiring reinsertion.  */
    2623            0 :   if (cval)
    2624            0 :     delete_variable_part (set, dv_as_value (dv), dv_from_value (cval), 0);
    2625              : 
    2626            0 :   clobber_variable_part (set, NULL, dv, 0, NULL);
    2627              : }
    2628              : 
    2629              : /* Find the values in a given location and map the val to another
    2630              :    value, if it is unique, or add the location as one holding the
    2631              :    value.  */
    2632              : 
    2633              : static void
    2634     41808457 : val_resolve (dataflow_set *set, rtx val, rtx loc, rtx_insn *insn)
    2635              : {
    2636     41808457 :   decl_or_value dv = dv_from_value (val);
    2637              : 
    2638     41808457 :   if (dump_file && (dump_flags & TDF_DETAILS))
    2639              :     {
    2640            6 :       if (insn)
    2641            6 :         fprintf (dump_file, "%i: ", INSN_UID (insn));
    2642              :       else
    2643            0 :         fprintf (dump_file, "head: ");
    2644            6 :       print_inline_rtx (dump_file, val, 0);
    2645            6 :       fputs (" is at ", dump_file);
    2646            6 :       print_inline_rtx (dump_file, loc, 0);
    2647            6 :       fputc ('\n', dump_file);
    2648              :     }
    2649              : 
    2650     41808457 :   val_reset (set, dv);
    2651              : 
    2652     41808457 :   gcc_checking_assert (!unsuitable_loc (loc));
    2653              : 
    2654     41808457 :   if (REG_P (loc))
    2655              :     {
    2656     21448493 :       attrs *node, *found = NULL;
    2657              : 
    2658     34992353 :       for (node = set->regs[REGNO (loc)]; node; node = node->next)
    2659     27087720 :         if (dv_is_value_p (node->dv)
    2660     13091256 :             && GET_MODE (dv_as_value (node->dv)) == GET_MODE (loc))
    2661              :           {
    2662     10544802 :             found = node;
    2663              : 
    2664              :             /* Map incoming equivalences.  ??? Wouldn't it be nice if
    2665              :              we just started sharing the location lists?  Maybe a
    2666              :              circular list ending at the value itself or some
    2667              :              such.  */
    2668     10544802 :             set_variable_part (set, dv_as_value (node->dv),
    2669              :                                dv_from_value (val), node->offset,
    2670              :                                VAR_INIT_STATUS_INITIALIZED, NULL_RTX, INSERT);
    2671     10544802 :             set_variable_part (set, val, node->dv, node->offset,
    2672              :                                VAR_INIT_STATUS_INITIALIZED, NULL_RTX, INSERT);
    2673              :           }
    2674              : 
    2675              :       /* If we didn't find any equivalence, we need to remember that
    2676              :          this value is held in the named register.  */
    2677     21448493 :       if (found)
    2678     10544802 :         return;
    2679              :     }
    2680              :   /* ??? Attempt to find and merge equivalent MEMs or other
    2681              :      expressions too.  */
    2682              : 
    2683     31263655 :   val_bind (set, val, loc, false);
    2684              : }
    2685              : 
    2686              : /* Initialize dataflow set SET to be empty.
    2687              :    VARS_SIZE is the initial size of hash table VARS.  */
    2688              : 
    2689              : static void
    2690     31659545 : dataflow_set_init (dataflow_set *set)
    2691              : {
    2692     31659545 :   init_attrs_list_set (set->regs);
    2693     31659545 :   set->vars = shared_hash_copy (empty_shared_hash);
    2694     31659545 :   set->stack_adjust = 0;
    2695     31659545 :   set->traversed_vars = NULL;
    2696     31659545 : }
    2697              : 
    2698              : /* Delete the contents of dataflow set SET.  */
    2699              : 
    2700              : static void
    2701     31951076 : dataflow_set_clear (dataflow_set *set)
    2702              : {
    2703     31951076 :   int i;
    2704              : 
    2705   3035352220 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    2706   3003401144 :     attrs_list_clear (&set->regs[i]);
    2707              : 
    2708     31951076 :   shared_hash_destroy (set->vars);
    2709     31951076 :   set->vars = shared_hash_copy (empty_shared_hash);
    2710     31951076 : }
    2711              : 
    2712              : /* Copy the contents of dataflow set SRC to DST.  */
    2713              : 
    2714              : static void
    2715     35890317 : dataflow_set_copy (dataflow_set *dst, dataflow_set *src)
    2716              : {
    2717     35890317 :   int i;
    2718              : 
    2719   3409580115 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    2720   3373689798 :     attrs_list_copy (&dst->regs[i], src->regs[i]);
    2721              : 
    2722     35890317 :   shared_hash_destroy (dst->vars);
    2723     35890317 :   dst->vars = shared_hash_copy (src->vars);
    2724     35890317 :   dst->stack_adjust = src->stack_adjust;
    2725     35890317 : }
    2726              : 
    2727              : /* Information for merging lists of locations for a given offset of variable.
    2728              :  */
    2729              : struct variable_union_info
    2730              : {
    2731              :   /* Node of the location chain.  */
    2732              :   location_chain *lc;
    2733              : 
    2734              :   /* The sum of positions in the input chains.  */
    2735              :   int pos;
    2736              : 
    2737              :   /* The position in the chain of DST dataflow set.  */
    2738              :   int pos_dst;
    2739              : };
    2740              : 
    2741              : /* Buffer for location list sorting and its allocated size.  */
    2742              : static struct variable_union_info *vui_vec;
    2743              : static int vui_allocated;
    2744              : 
    2745              : /* Compare function for qsort, order the structures by POS element.  */
    2746              : 
    2747              : static int
    2748       233430 : variable_union_info_cmp_pos (const void *n1, const void *n2)
    2749              : {
    2750       233430 :   const struct variable_union_info *const i1 =
    2751              :     (const struct variable_union_info *) n1;
    2752       233430 :   const struct variable_union_info *const i2 =
    2753              :     ( const struct variable_union_info *) n2;
    2754              : 
    2755       233430 :   if (i1->pos != i2->pos)
    2756       228716 :     return i1->pos - i2->pos;
    2757              : 
    2758         4714 :   return (i1->pos_dst - i2->pos_dst);
    2759              : }
    2760              : 
    2761              : /* Compute union of location parts of variable *SLOT and the same variable
    2762              :    from hash table DATA.  Compute "sorted" union of the location chains
    2763              :    for common offsets, i.e. the locations of a variable part are sorted by
    2764              :    a priority where the priority is the sum of the positions in the 2 chains
    2765              :    (if a location is only in one list the position in the second list is
    2766              :    defined to be larger than the length of the chains).
    2767              :    When we are updating the location parts the newest location is in the
    2768              :    beginning of the chain, so when we do the described "sorted" union
    2769              :    we keep the newest locations in the beginning.  */
    2770              : 
    2771              : static int
    2772      2016672 : variable_union (variable *src, dataflow_set *set)
    2773              : {
    2774      2016672 :   variable *dst;
    2775      2016672 :   variable **dstp;
    2776      2016672 :   int i, j, k;
    2777              : 
    2778      2016672 :   dstp = shared_hash_find_slot (set->vars, src->dv);
    2779      2016672 :   if (!dstp || !*dstp)
    2780              :     {
    2781      1090831 :       src->refcount++;
    2782              : 
    2783      1090831 :       dst_can_be_shared = false;
    2784      1090831 :       if (!dstp)
    2785            1 :         dstp = shared_hash_find_slot_unshare (&set->vars, src->dv, INSERT);
    2786              : 
    2787      1090831 :       *dstp = src;
    2788              : 
    2789              :       /* Continue traversing the hash table.  */
    2790      1090831 :       return 1;
    2791              :     }
    2792              :   else
    2793       925841 :     dst = *dstp;
    2794              : 
    2795       925841 :   gcc_assert (src->n_var_parts);
    2796       925841 :   gcc_checking_assert (src->onepart == dst->onepart);
    2797              : 
    2798              :   /* We can combine one-part variables very efficiently, because their
    2799              :      entries are in canonical order.  */
    2800       925841 :   if (src->onepart)
    2801              :     {
    2802            0 :       location_chain **nodep, *dnode, *snode;
    2803              : 
    2804            0 :       gcc_assert (src->n_var_parts == 1
    2805              :                   && dst->n_var_parts == 1);
    2806              : 
    2807            0 :       snode = src->var_part[0].loc_chain;
    2808            0 :       gcc_assert (snode);
    2809              : 
    2810            0 :     restart_onepart_unshared:
    2811            0 :       nodep = &dst->var_part[0].loc_chain;
    2812            0 :       dnode = *nodep;
    2813            0 :       gcc_assert (dnode);
    2814              : 
    2815            0 :       while (snode)
    2816              :         {
    2817            0 :           int r = dnode ? loc_cmp (dnode->loc, snode->loc) : 1;
    2818              : 
    2819            0 :           if (r > 0)
    2820              :             {
    2821            0 :               location_chain *nnode;
    2822              : 
    2823            0 :               if (shared_var_p (dst, set->vars))
    2824              :                 {
    2825            0 :                   dstp = unshare_variable (set, dstp, dst,
    2826              :                                            VAR_INIT_STATUS_INITIALIZED);
    2827            0 :                   dst = *dstp;
    2828            0 :                   goto restart_onepart_unshared;
    2829              :                 }
    2830              : 
    2831            0 :               *nodep = nnode = new location_chain;
    2832            0 :               nnode->loc = snode->loc;
    2833            0 :               nnode->init = snode->init;
    2834            0 :               if (!snode->set_src || MEM_P (snode->set_src))
    2835            0 :                 nnode->set_src = NULL;
    2836              :               else
    2837            0 :                 nnode->set_src = snode->set_src;
    2838            0 :               nnode->next = dnode;
    2839            0 :               dnode = nnode;
    2840              :             }
    2841            0 :           else if (r == 0)
    2842            0 :             gcc_checking_assert (rtx_equal_p (dnode->loc, snode->loc));
    2843              : 
    2844            0 :           if (r >= 0)
    2845            0 :             snode = snode->next;
    2846              : 
    2847            0 :           nodep = &dnode->next;
    2848            0 :           dnode = *nodep;
    2849              :         }
    2850              : 
    2851              :       return 1;
    2852              :     }
    2853              : 
    2854              :   gcc_checking_assert (!src->onepart);
    2855              : 
    2856              :   /* Count the number of location parts, result is K.  */
    2857      1288918 :   for (i = 0, j = 0, k = 0;
    2858      2214759 :        i < src->n_var_parts && j < dst->n_var_parts; k++)
    2859              :     {
    2860      1288918 :       if (VAR_PART_OFFSET (src, i) == VAR_PART_OFFSET (dst, j))
    2861              :         {
    2862      1253197 :           i++;
    2863      1253197 :           j++;
    2864              :         }
    2865        35721 :       else if (VAR_PART_OFFSET (src, i) < VAR_PART_OFFSET (dst, j))
    2866        26974 :         i++;
    2867              :       else
    2868         8747 :         j++;
    2869              :     }
    2870       925841 :   k += src->n_var_parts - i;
    2871       925841 :   k += dst->n_var_parts - j;
    2872              : 
    2873              :   /* We track only variables whose size is <= MAX_VAR_PARTS bytes
    2874              :      thus there are at most MAX_VAR_PARTS different offsets.  */
    2875       925841 :   gcc_checking_assert (dst->onepart ? k == 1 : k <= MAX_VAR_PARTS);
    2876              : 
    2877       925841 :   if (dst->n_var_parts != k && shared_var_p (dst, set->vars))
    2878              :     {
    2879        52510 :       dstp = unshare_variable (set, dstp, dst, VAR_INIT_STATUS_UNKNOWN);
    2880        52510 :       dst = *dstp;
    2881              :     }
    2882              : 
    2883       925841 :   i = src->n_var_parts - 1;
    2884       925841 :   j = dst->n_var_parts - 1;
    2885       925841 :   dst->n_var_parts = k;
    2886              : 
    2887      2248306 :   for (k--; k >= 0; k--)
    2888              :     {
    2889      1322465 :       location_chain *node, *node2;
    2890              : 
    2891      1322465 :       if (i >= 0 && j >= 0
    2892      1322465 :           && VAR_PART_OFFSET (src, i) == VAR_PART_OFFSET (dst, j))
    2893              :         {
    2894              :           /* Compute the "sorted" union of the chains, i.e. the locations which
    2895              :              are in both chains go first, they are sorted by the sum of
    2896              :              positions in the chains.  */
    2897      1253197 :           int dst_l, src_l;
    2898      1253197 :           int ii, jj, n;
    2899      1253197 :           struct variable_union_info *vui;
    2900              : 
    2901              :           /* If DST is shared compare the location chains.
    2902              :              If they are different we will modify the chain in DST with
    2903              :              high probability so make a copy of DST.  */
    2904      1253197 :           if (shared_var_p (dst, set->vars))
    2905              :             {
    2906      1169675 :               for (node = src->var_part[i].loc_chain,
    2907      2460953 :                    node2 = dst->var_part[j].loc_chain; node && node2;
    2908      1291278 :                    node = node->next, node2 = node2->next)
    2909              :                 {
    2910      1899714 :                   if (!((REG_P (node2->loc)
    2911       755061 :                          && REG_P (node->loc)
    2912       752985 :                          && REGNO (node2->loc) == REGNO (node->loc))
    2913       581996 :                         || rtx_equal_p (node2->loc, node->loc)))
    2914              :                     {
    2915        26440 :                       if (node2->init < node->init)
    2916            0 :                         node2->init = node->init;
    2917              :                       break;
    2918              :                     }
    2919              :                 }
    2920      1169675 :               if (node || node2)
    2921              :                 {
    2922        80656 :                   dstp = unshare_variable (set, dstp, dst,
    2923              :                                            VAR_INIT_STATUS_UNKNOWN);
    2924        80656 :                   dst = (variable *)*dstp;
    2925              :                 }
    2926              :             }
    2927              : 
    2928      1253197 :           src_l = 0;
    2929      2766432 :           for (node = src->var_part[i].loc_chain; node; node = node->next)
    2930      1513235 :             src_l++;
    2931      1253197 :           dst_l = 0;
    2932      2694892 :           for (node = dst->var_part[j].loc_chain; node; node = node->next)
    2933      1441695 :             dst_l++;
    2934              : 
    2935      1253197 :           if (dst_l == 1)
    2936              :             {
    2937              :               /* The most common case, much simpler, no qsort is needed.  */
    2938      1085453 :               location_chain *dstnode = dst->var_part[j].loc_chain;
    2939      1085453 :               dst->var_part[k].loc_chain = dstnode;
    2940      1085453 :               VAR_PART_OFFSET (dst, k) = VAR_PART_OFFSET (dst, j);
    2941      1085453 :               node2 = dstnode;
    2942      2245541 :               for (node = src->var_part[i].loc_chain; node; node = node->next)
    2943      1595933 :                 if (!((REG_P (dstnode->loc)
    2944       781356 :                        && REG_P (node->loc)
    2945       779609 :                        && REGNO (dstnode->loc) == REGNO (node->loc))
    2946       435845 :                       || rtx_equal_p (dstnode->loc, node->loc)))
    2947              :                   {
    2948        84936 :                     location_chain *new_node;
    2949              : 
    2950              :                     /* Copy the location from SRC.  */
    2951        84936 :                     new_node = new location_chain;
    2952        84936 :                     new_node->loc = node->loc;
    2953        84936 :                     new_node->init = node->init;
    2954        84936 :                     if (!node->set_src || MEM_P (node->set_src))
    2955        81990 :                       new_node->set_src = NULL;
    2956              :                     else
    2957         2946 :                       new_node->set_src = node->set_src;
    2958        84936 :                     node2->next = new_node;
    2959        84936 :                     node2 = new_node;
    2960              :                   }
    2961      1085453 :               node2->next = NULL;
    2962              :             }
    2963              :           else
    2964              :             {
    2965       167744 :               if (src_l + dst_l > vui_allocated)
    2966              :                 {
    2967        11212 :                   vui_allocated = MAX (vui_allocated * 2, src_l + dst_l);
    2968        11212 :                   vui_vec = XRESIZEVEC (struct variable_union_info, vui_vec,
    2969              :                                         vui_allocated);
    2970              :                 }
    2971       167744 :               vui = vui_vec;
    2972              : 
    2973              :               /* Fill in the locations from DST.  */
    2974       523986 :               for (node = dst->var_part[j].loc_chain, jj = 0; node;
    2975       356242 :                    node = node->next, jj++)
    2976              :                 {
    2977       356242 :                   vui[jj].lc = node;
    2978       356242 :                   vui[jj].pos_dst = jj;
    2979              : 
    2980              :                   /* Pos plus value larger than a sum of 2 valid positions.  */
    2981       356242 :                   vui[jj].pos = jj + src_l + dst_l;
    2982              :                 }
    2983              : 
    2984              :               /* Fill in the locations from SRC.  */
    2985       167744 :               n = dst_l;
    2986       520891 :               for (node = src->var_part[i].loc_chain, ii = 0; node;
    2987       353147 :                    node = node->next, ii++)
    2988              :                 {
    2989              :                   /* Find location from NODE.  */
    2990       582115 :                   for (jj = 0; jj < dst_l; jj++)
    2991              :                     {
    2992       565108 :                       if ((REG_P (vui[jj].lc->loc)
    2993       156617 :                            && REG_P (node->loc)
    2994       129554 :                            && REGNO (vui[jj].lc->loc) == REGNO (node->loc))
    2995       627982 :                           || rtx_equal_p (vui[jj].lc->loc, node->loc))
    2996              :                         {
    2997       336140 :                           vui[jj].pos = jj + ii;
    2998       336140 :                           break;
    2999              :                         }
    3000              :                     }
    3001       353147 :                   if (jj >= dst_l)   /* The location has not been found.  */
    3002              :                     {
    3003        17007 :                       location_chain *new_node;
    3004              : 
    3005              :                       /* Copy the location from SRC.  */
    3006        17007 :                       new_node = new location_chain;
    3007        17007 :                       new_node->loc = node->loc;
    3008        17007 :                       new_node->init = node->init;
    3009        17007 :                       if (!node->set_src || MEM_P (node->set_src))
    3010        14160 :                         new_node->set_src = NULL;
    3011              :                       else
    3012         2847 :                         new_node->set_src = node->set_src;
    3013        17007 :                       vui[n].lc = new_node;
    3014        17007 :                       vui[n].pos_dst = src_l + dst_l;
    3015        17007 :                       vui[n].pos = ii + src_l + dst_l;
    3016        17007 :                       n++;
    3017              :                     }
    3018              :                 }
    3019              : 
    3020       167744 :               if (dst_l == 2)
    3021              :                 {
    3022              :                   /* Special case still very common case.  For dst_l == 2
    3023              :                      all entries dst_l ... n-1 are sorted, with for i >= dst_l
    3024              :                      vui[i].pos == i + src_l + dst_l.  */
    3025       147458 :                   if (vui[0].pos > vui[1].pos)
    3026              :                     {
    3027              :                       /* Order should be 1, 0, 2... */
    3028         4689 :                       dst->var_part[k].loc_chain = vui[1].lc;
    3029         4689 :                       vui[1].lc->next = vui[0].lc;
    3030         4689 :                       if (n >= 3)
    3031              :                         {
    3032          422 :                           vui[0].lc->next = vui[2].lc;
    3033          422 :                           vui[n - 1].lc->next = NULL;
    3034              :                         }
    3035              :                       else
    3036         4267 :                         vui[0].lc->next = NULL;
    3037       147458 :                       ii = 3;
    3038              :                     }
    3039              :                   else
    3040              :                     {
    3041       142769 :                       dst->var_part[k].loc_chain = vui[0].lc;
    3042       142769 :                       if (n >= 3 && vui[2].pos < vui[1].pos)
    3043              :                         {
    3044              :                           /* Order should be 0, 2, 1, 3... */
    3045          572 :                           vui[0].lc->next = vui[2].lc;
    3046          572 :                           vui[2].lc->next = vui[1].lc;
    3047          572 :                           if (n >= 4)
    3048              :                             {
    3049           17 :                               vui[1].lc->next = vui[3].lc;
    3050           17 :                               vui[n - 1].lc->next = NULL;
    3051              :                             }
    3052              :                           else
    3053          555 :                             vui[1].lc->next = NULL;
    3054              :                           ii = 4;
    3055              :                         }
    3056              :                       else
    3057              :                         {
    3058              :                           /* Order should be 0, 1, 2... */
    3059       142197 :                           ii = 1;
    3060       142197 :                           vui[n - 1].lc->next = NULL;
    3061              :                         }
    3062              :                     }
    3063       304995 :                   for (; ii < n; ii++)
    3064       157537 :                     vui[ii - 1].lc->next = vui[ii].lc;
    3065              :                 }
    3066              :               else
    3067              :                 {
    3068        20286 :                   qsort (vui, n, sizeof (struct variable_union_info),
    3069              :                          variable_union_info_cmp_pos);
    3070              : 
    3071              :                   /* Reconnect the nodes in sorted order.  */
    3072        82268 :                   for (ii = 1; ii < n; ii++)
    3073        41696 :                     vui[ii - 1].lc->next = vui[ii].lc;
    3074        20286 :                   vui[n - 1].lc->next = NULL;
    3075        20286 :                   dst->var_part[k].loc_chain = vui[0].lc;
    3076              :                 }
    3077              : 
    3078       167744 :               VAR_PART_OFFSET (dst, k) = VAR_PART_OFFSET (dst, j);
    3079              :             }
    3080      1253197 :           i--;
    3081      1253197 :           j--;
    3082              :         }
    3083        69268 :       else if ((i >= 0 && j >= 0
    3084        33547 :                 && VAR_PART_OFFSET (src, i) < VAR_PART_OFFSET (dst, j))
    3085        94804 :                || i < 0)
    3086              :         {
    3087        16758 :           dst->var_part[k] = dst->var_part[j];
    3088        16758 :           j--;
    3089              :         }
    3090        52510 :       else if ((i >= 0 && j >= 0
    3091        25536 :                 && VAR_PART_OFFSET (src, i) > VAR_PART_OFFSET (dst, j))
    3092        52510 :                || j < 0)
    3093              :         {
    3094        52510 :           location_chain **nextp;
    3095              : 
    3096              :           /* Copy the chain from SRC.  */
    3097        52510 :           nextp = &dst->var_part[k].loc_chain;
    3098       112436 :           for (node = src->var_part[i].loc_chain; node; node = node->next)
    3099              :             {
    3100        59926 :               location_chain *new_lc;
    3101              : 
    3102        59926 :               new_lc = new location_chain;
    3103        59926 :               new_lc->next = NULL;
    3104        59926 :               new_lc->init = node->init;
    3105        59926 :               if (!node->set_src || MEM_P (node->set_src))
    3106        58012 :                 new_lc->set_src = NULL;
    3107              :               else
    3108         1914 :                 new_lc->set_src = node->set_src;
    3109        59926 :               new_lc->loc = node->loc;
    3110              : 
    3111        59926 :               *nextp = new_lc;
    3112        59926 :               nextp = &new_lc->next;
    3113              :             }
    3114              : 
    3115        52510 :           VAR_PART_OFFSET (dst, k) = VAR_PART_OFFSET (src, i);
    3116        52510 :           i--;
    3117              :         }
    3118      1322465 :       dst->var_part[k].cur_loc = NULL;
    3119              :     }
    3120              : 
    3121       925841 :   if (flag_var_tracking_uninit)
    3122            0 :     for (i = 0; i < src->n_var_parts && i < dst->n_var_parts; i++)
    3123              :       {
    3124            0 :         location_chain *node, *node2;
    3125            0 :         for (node = src->var_part[i].loc_chain; node; node = node->next)
    3126            0 :           for (node2 = dst->var_part[i].loc_chain; node2; node2 = node2->next)
    3127            0 :             if (rtx_equal_p (node->loc, node2->loc))
    3128              :               {
    3129            0 :                 if (node->init > node2->init)
    3130            0 :                   node2->init = node->init;
    3131              :               }
    3132              :       }
    3133              : 
    3134              :   /* Continue traversing the hash table.  */
    3135              :   return 1;
    3136              : }
    3137              : 
    3138              : /* Compute union of dataflow sets SRC and DST and store it to DST.  */
    3139              : 
    3140              : static void
    3141          106 : dataflow_set_union (dataflow_set *dst, dataflow_set *src)
    3142              : {
    3143          106 :   int i;
    3144              : 
    3145        10070 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    3146         9964 :     attrs_list_union (&dst->regs[i], src->regs[i]);
    3147              : 
    3148          106 :   if (dst->vars == empty_shared_hash)
    3149              :     {
    3150           88 :       shared_hash_destroy (dst->vars);
    3151           88 :       dst->vars = shared_hash_copy (src->vars);
    3152              :     }
    3153              :   else
    3154              :     {
    3155           18 :       variable_iterator_type hi;
    3156           18 :       variable *var;
    3157              : 
    3158           66 :       FOR_EACH_HASH_TABLE_ELEMENT (*shared_hash_htab (src->vars),
    3159              :                                    var, variable, hi)
    3160           30 :         variable_union (var, dst);
    3161              :     }
    3162          106 : }
    3163              : 
    3164              : /* Whether the value is currently being expanded.  */
    3165              : #define VALUE_RECURSED_INTO(x) \
    3166              :   (RTL_FLAG_CHECK2 ("VALUE_RECURSED_INTO", (x), VALUE, DEBUG_EXPR)->used)
    3167              : 
    3168              : /* Whether no expansion was found, saving useless lookups.
    3169              :    It must only be set when VALUE_CHANGED is clear.  */
    3170              : #define NO_LOC_P(x) \
    3171              :   (RTL_FLAG_CHECK2 ("NO_LOC_P", (x), VALUE, DEBUG_EXPR)->return_val)
    3172              : 
    3173              : /* Whether cur_loc in the value needs to be (re)computed.  */
    3174              : #define VALUE_CHANGED(x) \
    3175              :   (RTL_FLAG_CHECK1 ("VALUE_CHANGED", (x), VALUE)->frame_related)
    3176              : /* Whether cur_loc in the decl needs to be (re)computed.  */
    3177              : #define DECL_CHANGED(x) TREE_VISITED (x)
    3178              : 
    3179              : /* Record (if NEWV) that DV needs to have its cur_loc recomputed.  For
    3180              :    user DECLs, this means they're in changed_variables.  Values and
    3181              :    debug exprs may be left with this flag set if no user variable
    3182              :    requires them to be evaluated.  */
    3183              : 
    3184              : static inline void
    3185    336253960 : set_dv_changed (decl_or_value dv, bool newv)
    3186              : {
    3187    336253960 :   switch (dv_onepart_p (dv))
    3188              :     {
    3189    175056806 :     case ONEPART_VALUE:
    3190    175056806 :       if (newv)
    3191    141418711 :         NO_LOC_P (dv_as_value (dv)) = false;
    3192    175056806 :       VALUE_CHANGED (dv_as_value (dv)) = newv;
    3193    175056806 :       break;
    3194              : 
    3195     21910295 :     case ONEPART_DEXPR:
    3196     21910295 :       if (newv)
    3197     16061157 :         NO_LOC_P (DECL_RTL_KNOWN_SET (dv_as_decl (dv))) = false;
    3198              :       /* Fall through.  */
    3199              : 
    3200    161197154 :     default:
    3201    161197154 :       DECL_CHANGED (dv_as_decl (dv)) = newv;
    3202    161197154 :       break;
    3203              :     }
    3204    336253960 : }
    3205              : 
    3206              : /* Return true if DV needs to have its cur_loc recomputed.  */
    3207              : 
    3208              : static inline bool
    3209    163226046 : dv_changed_p (decl_or_value dv)
    3210              : {
    3211    163226046 :   return (dv_is_value_p (dv)
    3212     86922800 :           ? VALUE_CHANGED (dv_as_value (dv))
    3213     76303246 :           : DECL_CHANGED (dv_as_decl (dv)));
    3214              : }
    3215              : 
    3216              : /* Return a location list node whose loc is rtx_equal to LOC, in the
    3217              :    location list of a one-part variable or value VAR, or in that of
    3218              :    any values recursively mentioned in the location lists.  VARS must
    3219              :    be in star-canonical form.  */
    3220              : 
    3221              : static location_chain *
    3222     15492314 : find_loc_in_1pdv (rtx loc, variable *var, variable_table_type *vars)
    3223              : {
    3224     21167388 :   location_chain *node;
    3225     21167388 :   enum rtx_code loc_code;
    3226              : 
    3227     21167388 :   if (!var)
    3228              :     return NULL;
    3229              : 
    3230     20374839 :   gcc_checking_assert (var->onepart);
    3231              : 
    3232     20374839 :   if (!var->n_var_parts)
    3233              :     return NULL;
    3234              : 
    3235     20374839 :   gcc_checking_assert (var->dv != loc);
    3236              : 
    3237     20374839 :   loc_code = GET_CODE (loc);
    3238     39178769 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    3239              :     {
    3240     30457233 :       decl_or_value dv;
    3241     30457233 :       variable *rvar;
    3242              : 
    3243     30457233 :       if (GET_CODE (node->loc) != loc_code)
    3244              :         {
    3245     17012653 :           if (GET_CODE (node->loc) != VALUE)
    3246     18803930 :             continue;
    3247              :         }
    3248     13444580 :       else if (loc == node->loc)
    3249      5978229 :         return node;
    3250      8841546 :       else if (loc_code != VALUE)
    3251              :         {
    3252      2770615 :           if (rtx_equal_p (loc, node->loc))
    3253              :             return node;
    3254      2154673 :           continue;
    3255              :         }
    3256              : 
    3257              :       /* Since we're in star-canonical form, we don't need to visit
    3258              :          non-canonical nodes: one-part variables and non-canonical
    3259              :          values would only point back to the canonical node.  */
    3260      9732297 :       if (dv_is_value_p (var->dv)
    3261      4991178 :           && !canon_value_cmp (node->loc, dv_as_value (var->dv)))
    3262              :         {
    3263              :           /* Skip all subsequent VALUEs.  */
    3264     17431742 :           while (node->next && GET_CODE (node->next->loc) == VALUE)
    3265              :             {
    3266     14133772 :               node = node->next;
    3267     14133772 :               gcc_checking_assert (!canon_value_cmp (node->loc,
    3268              :                                                      dv_as_value (var->dv)));
    3269     14133772 :               if (loc == node->loc)
    3270              :                 return node;
    3271              :             }
    3272      3297970 :           continue;
    3273              :         }
    3274              : 
    3275      5675074 :       gcc_checking_assert (node == var->var_part[0].loc_chain);
    3276      5675074 :       gcc_checking_assert (!node->next);
    3277              : 
    3278      5675074 :       dv = dv_from_value (node->loc);
    3279      5675074 :       rvar = vars->find_with_hash (dv, dv_htab_hash (dv));
    3280      5675074 :       return find_loc_in_1pdv (loc, rvar, vars);
    3281              :     }
    3282              : 
    3283              :   /* ??? Gotta look in cselib_val locations too.  */
    3284              : 
    3285              :   return NULL;
    3286              : }
    3287              : 
    3288              : /* Hash table iteration argument passed to variable_merge.  */
    3289              : struct dfset_merge
    3290              : {
    3291              :   /* The set in which the merge is to be inserted.  */
    3292              :   dataflow_set *dst;
    3293              :   /* The set that we're iterating in.  */
    3294              :   dataflow_set *cur;
    3295              :   /* The set that may contain the other dv we are to merge with.  */
    3296              :   dataflow_set *src;
    3297              :   /* Number of onepart dvs in src.  */
    3298              :   int src_onepart_cnt;
    3299              : };
    3300              : 
    3301              : /* Insert LOC in *DNODE, if it's not there yet.  The list must be in
    3302              :    loc_cmp order, and it is maintained as such.  */
    3303              : 
    3304              : static void
    3305     42739604 : insert_into_intersection (location_chain **nodep, rtx loc,
    3306              :                           enum var_init_status status)
    3307              : {
    3308     42739604 :   location_chain *node;
    3309     42739604 :   int r;
    3310              : 
    3311    320771757 :   for (node = *nodep; node; nodep = &node->next, node = *nodep)
    3312    308665352 :     if ((r = loc_cmp (node->loc, loc)) == 0)
    3313              :       {
    3314     24316555 :         node->init = MIN (node->init, status);
    3315     24316555 :         return;
    3316              :       }
    3317    284348797 :     else if (r > 0)
    3318              :       break;
    3319              : 
    3320     18423049 :   node = new location_chain;
    3321              : 
    3322     18423049 :   node->loc = loc;
    3323     18423049 :   node->set_src = NULL;
    3324     18423049 :   node->init = status;
    3325     18423049 :   node->next = *nodep;
    3326     18423049 :   *nodep = node;
    3327              : }
    3328              : 
    3329              : /* Insert in DEST the intersection of the locations present in both
    3330              :    S1NODE and S2VAR, directly or indirectly.  S1NODE is from a
    3331              :    variable in DSM->cur, whereas S2VAR is from DSM->src.  dvar is in
    3332              :    DSM->dst.  */
    3333              : 
    3334              : static void
    3335     37969115 : intersect_loc_chains (rtx val, location_chain **dest, struct dfset_merge *dsm,
    3336              :                       location_chain *s1node, variable *s2var)
    3337              : {
    3338     37969115 :   dataflow_set *s1set = dsm->cur;
    3339     37969115 :   dataflow_set *s2set = dsm->src;
    3340     37969115 :   location_chain *found;
    3341              : 
    3342     37969115 :   if (s2var)
    3343              :     {
    3344     37969115 :       location_chain *s2node;
    3345              : 
    3346     37969115 :       gcc_checking_assert (s2var->onepart);
    3347              : 
    3348     37969115 :       if (s2var->n_var_parts)
    3349              :         {
    3350     37969115 :           s2node = s2var->var_part[0].loc_chain;
    3351              : 
    3352     74730490 :           for (; s1node && s2node;
    3353     36761375 :                s1node = s1node->next, s2node = s2node->next)
    3354     49115021 :             if (s1node->loc != s2node->loc)
    3355              :               break;
    3356     36761375 :             else if (s1node->loc == val)
    3357            0 :               continue;
    3358              :             else
    3359     36761375 :               insert_into_intersection (dest, s1node->loc,
    3360     36761375 :                                         MIN (s1node->init, s2node->init));
    3361              :         }
    3362              :     }
    3363              : 
    3364     56366059 :   for (; s1node; s1node = s1node->next)
    3365              :     {
    3366     18396944 :       if (s1node->loc == val)
    3367      2904630 :         continue;
    3368              : 
    3369     15492314 :       if ((found = find_loc_in_1pdv (s1node->loc, s2var,
    3370              :                                      shared_hash_htab (s2set->vars))))
    3371              :         {
    3372      5978229 :           insert_into_intersection (dest, s1node->loc,
    3373      5978229 :                                     MIN (s1node->init, found->init));
    3374      5978229 :           continue;
    3375              :         }
    3376              : 
    3377      9514085 :       if (GET_CODE (s1node->loc) == VALUE
    3378      9514085 :           && !VALUE_RECURSED_INTO (s1node->loc))
    3379              :         {
    3380      5656629 :           decl_or_value dv = dv_from_value (s1node->loc);
    3381      5656629 :           variable *svar = shared_hash_find (s1set->vars, dv);
    3382      5656629 :           if (svar)
    3383              :             {
    3384      5071881 :               if (svar->n_var_parts == 1)
    3385              :                 {
    3386      5071881 :                   VALUE_RECURSED_INTO (s1node->loc) = true;
    3387      5071881 :                   intersect_loc_chains (val, dest, dsm,
    3388              :                                         svar->var_part[0].loc_chain,
    3389              :                                         s2var);
    3390      5071881 :                   VALUE_RECURSED_INTO (s1node->loc) = false;
    3391              :                 }
    3392              :             }
    3393              :         }
    3394              : 
    3395              :       /* ??? gotta look in cselib_val locations too.  */
    3396              : 
    3397              :       /* ??? if the location is equivalent to any location in src,
    3398              :          searched recursively
    3399              : 
    3400              :            add to dst the values needed to represent the equivalence
    3401              : 
    3402              :      telling whether locations S is equivalent to another dv's
    3403              :      location list:
    3404              : 
    3405              :        for each location D in the list
    3406              : 
    3407              :          if S and D satisfy rtx_equal_p, then it is present
    3408              : 
    3409              :          else if D is a value, recurse without cycles
    3410              : 
    3411              :          else if S and D have the same CODE and MODE
    3412              : 
    3413              :            for each operand oS and the corresponding oD
    3414              : 
    3415              :              if oS and oD are not equivalent, then S an D are not equivalent
    3416              : 
    3417              :              else if they are RTX vectors
    3418              : 
    3419              :                if any vector oS element is not equivalent to its respective oD,
    3420              :                then S and D are not equivalent
    3421              : 
    3422              :    */
    3423              : 
    3424              : 
    3425              :     }
    3426     37969115 : }
    3427              : 
    3428              : /* Return -1 if X should be before Y in a location list for a 1-part
    3429              :    variable, 1 if Y should be before X, and 0 if they're equivalent
    3430              :    and should not appear in the list.  */
    3431              : 
    3432              : static int
    3433    536980952 : loc_cmp (rtx x, rtx y)
    3434              : {
    3435    553602434 :   int i, j, r;
    3436    553602434 :   RTX_CODE code = GET_CODE (x);
    3437    553602434 :   const char *fmt;
    3438              : 
    3439    553602434 :   if (x == y)
    3440              :     return 0;
    3441              : 
    3442    426171849 :   if (REG_P (x))
    3443              :     {
    3444     50663852 :       if (!REG_P (y))
    3445              :         return -1;
    3446      4121640 :       gcc_assert (GET_MODE (x) == GET_MODE (y));
    3447      4121640 :       if (REGNO (x) == REGNO (y))
    3448              :         return 0;
    3449      3970074 :       else if (REGNO (x) < REGNO (y))
    3450              :         return -1;
    3451              :       else
    3452       830701 :         return 1;
    3453              :     }
    3454              : 
    3455    375507997 :   if (REG_P (y))
    3456              :     return 1;
    3457              : 
    3458    369502507 :   if (MEM_P (x))
    3459              :     {
    3460     29758619 :       if (!MEM_P (y))
    3461              :         return -1;
    3462     16621482 :       gcc_assert (GET_MODE (x) == GET_MODE (y));
    3463     16621482 :       return loc_cmp (XEXP (x, 0), XEXP (y, 0));
    3464              :     }
    3465              : 
    3466    339743888 :   if (MEM_P (y))
    3467              :     return 1;
    3468              : 
    3469    337702706 :   if (GET_CODE (x) == VALUE)
    3470              :     {
    3471    337350760 :       if (GET_CODE (y) != VALUE)
    3472              :         return -1;
    3473              :       /* Don't assert the modes are the same, that is true only
    3474              :          when not recursing.  (subreg:QI (value:SI 1:1) 0)
    3475              :          and (subreg:QI (value:DI 2:2) 0) can be compared,
    3476              :          even when the modes are different.  */
    3477    336878383 :       if (canon_value_cmp (x, y))
    3478              :         return -1;
    3479              :       else
    3480      7831622 :         return 1;
    3481              :     }
    3482              : 
    3483       351946 :   if (GET_CODE (y) == VALUE)
    3484              :     return 1;
    3485              : 
    3486              :   /* Entry value is the least preferable kind of expression.  */
    3487        90942 :   if (GET_CODE (x) == ENTRY_VALUE)
    3488              :     {
    3489            0 :       if (GET_CODE (y) != ENTRY_VALUE)
    3490              :         return 1;
    3491            0 :       gcc_assert (GET_MODE (x) == GET_MODE (y));
    3492            0 :       return loc_cmp (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
    3493              :     }
    3494              : 
    3495        90942 :   if (GET_CODE (y) == ENTRY_VALUE)
    3496              :     return -1;
    3497              : 
    3498        90942 :   if (GET_CODE (x) == GET_CODE (y))
    3499              :     /* Compare operands below.  */;
    3500         8776 :   else if (GET_CODE (x) < GET_CODE (y))
    3501              :     return -1;
    3502              :   else
    3503         6606 :     return 1;
    3504              : 
    3505        82166 :   gcc_assert (GET_MODE (x) == GET_MODE (y));
    3506              : 
    3507        82166 :   if (GET_CODE (x) == DEBUG_EXPR)
    3508              :     {
    3509            0 :       if (DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x))
    3510            0 :           < DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (y)))
    3511              :         return -1;
    3512            0 :       gcc_checking_assert (DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x))
    3513              :                            > DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (y)));
    3514              :       return 1;
    3515              :     }
    3516              : 
    3517        82166 :   fmt = GET_RTX_FORMAT (code);
    3518        95700 :   for (i = 0; i < GET_RTX_LENGTH (code); i++)
    3519        89006 :     switch (fmt[i])
    3520              :       {
    3521        71555 :       case 'w':
    3522        71555 :         if (XWINT (x, i) == XWINT (y, i))
    3523              :           break;
    3524        71381 :         else if (XWINT (x, i) < XWINT (y, i))
    3525              :           return -1;
    3526              :         else
    3527        41185 :           return 1;
    3528              : 
    3529            0 :       case 'n':
    3530            0 :       case 'i':
    3531            0 :         if (XINT (x, i) == XINT (y, i))
    3532              :           break;
    3533            0 :         else if (XINT (x, i) < XINT (y, i))
    3534              :           return -1;
    3535              :         else
    3536            0 :           return 1;
    3537              : 
    3538            0 :       case 'L':
    3539            0 :         if (XLOC (x, i) == XLOC (y, i))
    3540              :           break;
    3541            0 :         else if (XLOC (x, i) < XLOC (y, i))
    3542              :           return -1;
    3543              :         else
    3544            0 :           return 1;
    3545              : 
    3546            0 :       case 'p':
    3547        13534 :         r = compare_sizes_for_sort (SUBREG_BYTE (x), SUBREG_BYTE (y));
    3548            0 :         if (r != 0)
    3549              :           return r;
    3550              :         break;
    3551              : 
    3552            0 :       case 'V':
    3553            0 :       case 'E':
    3554              :         /* Compare the vector length first.  */
    3555            0 :         if (XVECLEN (x, i) == XVECLEN (y, i))
    3556              :           /* Compare the vectors elements.  */;
    3557            0 :         else if (XVECLEN (x, i) < XVECLEN (y, i))
    3558              :           return -1;
    3559              :         else
    3560            0 :           return 1;
    3561              : 
    3562            0 :         for (j = 0; j < XVECLEN (x, i); j++)
    3563            0 :           if ((r = loc_cmp (XVECEXP (x, i, j),
    3564            0 :                             XVECEXP (y, i, j))))
    3565              :             return r;
    3566              :         break;
    3567              : 
    3568            0 :       case 'e':
    3569            0 :         if ((r = loc_cmp (XEXP (x, i), XEXP (y, i))))
    3570              :           return r;
    3571              :         break;
    3572              : 
    3573        10771 :       case 'S':
    3574        10771 :       case 's':
    3575        10771 :         if (XSTR (x, i) == XSTR (y, i))
    3576              :           break;
    3577         4091 :         if (!XSTR (x, i))
    3578              :           return -1;
    3579         4091 :         if (!XSTR (y, i))
    3580              :           return 1;
    3581         4091 :         if ((r = strcmp (XSTR (x, i), XSTR (y, i))) == 0)
    3582              :           break;
    3583         4091 :         else if (r < 0)
    3584              :           return -1;
    3585              :         else
    3586         2294 :           return 1;
    3587              : 
    3588              :       case 'u':
    3589              :         /* These are just backpointers, so they don't matter.  */
    3590              :         break;
    3591              : 
    3592              :       case '0':
    3593              :       case 't':
    3594              :         break;
    3595              : 
    3596              :         /* It is believed that rtx's at this level will never
    3597              :            contain anything but integers and other rtx's,
    3598              :            except for within LABEL_REFs and SYMBOL_REFs.  */
    3599            0 :       default:
    3600            0 :         gcc_unreachable ();
    3601              :       }
    3602         6694 :   if (CONST_WIDE_INT_P (x))
    3603              :     {
    3604              :       /* Compare the vector length first.  */
    3605           14 :       if (CONST_WIDE_INT_NUNITS (x) >= CONST_WIDE_INT_NUNITS (y))
    3606              :         return 1;
    3607            0 :       else if (CONST_WIDE_INT_NUNITS (x) < CONST_WIDE_INT_NUNITS (y))
    3608            0 :         return -1;
    3609              : 
    3610              :       /* Compare the vectors elements.  */;
    3611              :       for (j = CONST_WIDE_INT_NUNITS (x) - 1; j >= 0 ; j--)
    3612              :         {
    3613              :           if (CONST_WIDE_INT_ELT (x, j) < CONST_WIDE_INT_ELT (y, j))
    3614              :             return -1;
    3615              :           if (CONST_WIDE_INT_ELT (x, j) > CONST_WIDE_INT_ELT (y, j))
    3616              :             return 1;
    3617              :         }
    3618              :     }
    3619              : 
    3620              :   return 0;
    3621              : }
    3622              : 
    3623              : /* Check the order of entries in one-part variables.   */
    3624              : 
    3625              : int
    3626    533144480 : canonicalize_loc_order_check (variable **slot,
    3627              :                               dataflow_set *data ATTRIBUTE_UNUSED)
    3628              : {
    3629    533144480 :   variable *var = *slot;
    3630    533144480 :   location_chain *node, *next;
    3631              : 
    3632              : #ifdef ENABLE_RTL_CHECKING
    3633              :   int i;
    3634              :   for (i = 0; i < var->n_var_parts; i++)
    3635              :     gcc_assert (var->var_part[0].cur_loc == NULL);
    3636              :   gcc_assert (!var->in_changed_variables);
    3637              : #endif
    3638              : 
    3639    533144480 :   if (!var->onepart)
    3640              :     return 1;
    3641              : 
    3642    530442858 :   gcc_assert (var->n_var_parts == 1);
    3643    530442858 :   node = var->var_part[0].loc_chain;
    3644    530442858 :   gcc_assert (node);
    3645              : 
    3646    626439112 :   while ((next = node->next))
    3647              :     {
    3648     95996254 :       gcc_assert (loc_cmp (node->loc, next->loc) < 0);
    3649              :       node = next;
    3650              :     }
    3651              : 
    3652              :   return 1;
    3653              : }
    3654              : 
    3655              : /* Mark with VALUE_RECURSED_INTO values that have neighbors that are
    3656              :    more likely to be chosen as canonical for an equivalence set.
    3657              :    Ensure less likely values can reach more likely neighbors, making
    3658              :    the connections bidirectional.  */
    3659              : 
    3660              : int
    3661    423021370 : canonicalize_values_mark (variable **slot, dataflow_set *set)
    3662              : {
    3663    423021370 :   variable *var = *slot;
    3664    423021370 :   decl_or_value dv = var->dv;
    3665    423021370 :   rtx val;
    3666    423021370 :   location_chain *node;
    3667              : 
    3668    423021370 :   if (!dv_is_value_p (dv))
    3669              :     return 1;
    3670              : 
    3671    252256988 :   gcc_checking_assert (var->n_var_parts == 1);
    3672              : 
    3673    252256988 :   val = dv_as_value (dv);
    3674              : 
    3675    583847611 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    3676    331590623 :     if (GET_CODE (node->loc) == VALUE)
    3677              :       {
    3678    141566350 :         if (canon_value_cmp (node->loc, val))
    3679     70783175 :           VALUE_RECURSED_INTO (val) = true;
    3680              :         else
    3681              :           {
    3682     70783175 :             decl_or_value odv = dv_from_value (node->loc);
    3683     70783175 :             variable **oslot;
    3684     70783175 :             oslot = shared_hash_find_slot_noinsert (set->vars, odv);
    3685              : 
    3686     70783175 :             set_slot_part (set, val, oslot, odv, 0,
    3687              :                            node->init, NULL_RTX);
    3688              : 
    3689     70783175 :             VALUE_RECURSED_INTO (node->loc) = true;
    3690              :           }
    3691              :       }
    3692              : 
    3693              :   return 1;
    3694              : }
    3695              : 
    3696              : /* Remove redundant entries from equivalence lists in onepart
    3697              :    variables, canonicalizing equivalence sets into star shapes.  */
    3698              : 
    3699              : int
    3700    619483680 : canonicalize_values_star (variable **slot, dataflow_set *set)
    3701              : {
    3702    619483680 :   variable *var = *slot;
    3703    619483680 :   decl_or_value dv = var->dv;
    3704    619483680 :   location_chain *node;
    3705    619483680 :   decl_or_value cdv;
    3706    619483680 :   rtx val, cval;
    3707    619483680 :   variable **cslot;
    3708    619483680 :   bool has_value;
    3709    619483680 :   bool has_marks;
    3710              : 
    3711    619483680 :   if (!var->onepart)
    3712              :     return 1;
    3713              : 
    3714    616782058 :   gcc_checking_assert (var->n_var_parts == 1);
    3715              : 
    3716    616782058 :   if (dv_is_value_p (dv))
    3717              :     {
    3718    401163445 :       cval = dv_as_value (dv);
    3719    401163445 :       if (!VALUE_RECURSED_INTO (cval))
    3720              :         return 1;
    3721    155809092 :       VALUE_RECURSED_INTO (cval) = false;
    3722              :     }
    3723              :   else
    3724    371427705 :     cval = NULL_RTX;
    3725              : 
    3726    371427705 :  restart:
    3727    445827941 :   val = cval;
    3728    445827941 :   has_value = false;
    3729    445827941 :   has_marks = false;
    3730              : 
    3731    445827941 :   gcc_assert (var->n_var_parts == 1);
    3732              : 
    3733   1998459449 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    3734   1552631508 :     if (GET_CODE (node->loc) == VALUE)
    3735              :       {
    3736   1426803188 :         has_value = true;
    3737   1426803188 :         if (VALUE_RECURSED_INTO (node->loc))
    3738    346006881 :           has_marks = true;
    3739   1426803188 :         if (canon_value_cmp (node->loc, cval))
    3740    300497550 :           cval = node->loc;
    3741              :       }
    3742              : 
    3743    445827941 :   if (!has_value)
    3744              :     return 1;
    3745              : 
    3746    363977505 :   if (cval == val)
    3747              :     {
    3748     63479955 :       if (!has_marks || dv_is_decl_p (dv))
    3749              :         return 1;
    3750              : 
    3751              :       /* Keep it marked so that we revisit it, either after visiting a
    3752              :          child node, or after visiting a new parent that might be
    3753              :          found out.  */
    3754     24379110 :       VALUE_RECURSED_INTO (val) = true;
    3755              : 
    3756    312461495 :       for (node = var->var_part[0].loc_chain; node; node = node->next)
    3757    312461495 :         if (GET_CODE (node->loc) == VALUE
    3758    312461495 :             && VALUE_RECURSED_INTO (node->loc))
    3759              :           {
    3760              :             cval = node->loc;
    3761     74400236 :           restart_with_cval:
    3762     74400236 :             VALUE_RECURSED_INTO (cval) = false;
    3763     74400236 :             dv = dv_from_value (cval);
    3764     74400236 :             slot = shared_hash_find_slot_noinsert (set->vars, dv);
    3765     74400236 :             if (!slot)
    3766              :               {
    3767            0 :                 gcc_assert (dv_is_decl_p (var->dv));
    3768              :                 /* The canonical value was reset and dropped.
    3769              :                    Remove it.  */
    3770            0 :                 clobber_variable_part (set, NULL, var->dv, 0, NULL);
    3771            0 :                 return 1;
    3772              :               }
    3773     74400236 :             var = *slot;
    3774     74400236 :             gcc_assert (dv_is_value_p (var->dv));
    3775     74400236 :             if (var->n_var_parts == 0)
    3776              :               return 1;
    3777     74400236 :             gcc_assert (var->n_var_parts == 1);
    3778     74400236 :             goto restart;
    3779              :           }
    3780              : 
    3781            0 :       VALUE_RECURSED_INTO (val) = false;
    3782              : 
    3783            0 :       return 1;
    3784              :     }
    3785              : 
    3786              :   /* Push values to the canonical one.  */
    3787    300497550 :   cdv = dv_from_value (cval);
    3788    300497550 :   cslot = shared_hash_find_slot_noinsert (set->vars, cdv);
    3789              : 
    3790    602861795 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    3791    302364245 :     if (node->loc != cval)
    3792              :       {
    3793      1866695 :         cslot = set_slot_part (set, node->loc, cslot, cdv, 0,
    3794              :                                node->init, NULL_RTX);
    3795      1866695 :         if (GET_CODE (node->loc) == VALUE)
    3796              :           {
    3797       144056 :             decl_or_value ndv = dv_from_value (node->loc);
    3798              : 
    3799       144056 :             set_variable_part (set, cval, ndv, 0, node->init, NULL_RTX,
    3800              :                                NO_INSERT);
    3801              : 
    3802       144056 :             if (canon_value_cmp (node->loc, val))
    3803              :               {
    3804              :                 /* If it could have been a local minimum, it's not any more,
    3805              :                    since it's now neighbor to cval, so it may have to push
    3806              :                    to it.  Conversely, if it wouldn't have prevailed over
    3807              :                    val, then whatever mark it has is fine: if it was to
    3808              :                    push, it will now push to a more canonical node, but if
    3809              :                    it wasn't, then it has already pushed any values it might
    3810              :                    have to.  */
    3811        76879 :                 VALUE_RECURSED_INTO (node->loc) = true;
    3812              :                 /* Make sure we visit node->loc by ensuring we cval is
    3813              :                    visited too.  */
    3814        76879 :                 VALUE_RECURSED_INTO (cval) = true;
    3815              :               }
    3816        67177 :             else if (!VALUE_RECURSED_INTO (node->loc))
    3817              :               /* If we have no need to "recurse" into this node, it's
    3818              :                  already "canonicalized", so drop the link to the old
    3819              :                  parent.  */
    3820        28526 :               clobber_variable_part (set, cval, ndv, 0, NULL);
    3821              :           }
    3822      1722639 :         else if (GET_CODE (node->loc) == REG)
    3823              :           {
    3824       938250 :             attrs *list = set->regs[REGNO (node->loc)], **listp;
    3825              : 
    3826              :             /* Change an existing attribute referring to dv so that it
    3827              :                refers to cdv, removing any duplicate this might
    3828              :                introduce, and checking that no previous duplicates
    3829              :                existed, all in a single pass.  */
    3830              : 
    3831       950493 :             while (list)
    3832              :               {
    3833       950493 :                 if (list->offset == 0 && (list->dv == dv || list->dv == cdv))
    3834              :                   break;
    3835              : 
    3836        12243 :                 list = list->next;
    3837              :               }
    3838              : 
    3839            0 :             gcc_assert (list);
    3840       938250 :             if (list->dv == dv)
    3841              :               {
    3842       938250 :                 list->dv = cdv;
    3843       943080 :                 for (listp = &list->next; (list = *listp); listp = &list->next)
    3844              :                   {
    3845         4830 :                     if (list->offset)
    3846          481 :                       continue;
    3847              : 
    3848         4349 :                     if (list->dv == cdv)
    3849              :                       {
    3850            0 :                         *listp = list->next;
    3851            0 :                         delete list;
    3852            0 :                         list = *listp;
    3853            0 :                         break;
    3854              :                       }
    3855              : 
    3856         4349 :                     gcc_assert (list->dv != dv);
    3857              :                   }
    3858              :               }
    3859            0 :             else if (list->dv == cdv)
    3860              :               {
    3861            0 :                 for (listp = &list->next; (list = *listp); listp = &list->next)
    3862              :                   {
    3863            0 :                     if (list->offset)
    3864            0 :                       continue;
    3865              : 
    3866            0 :                     if (list->dv == dv)
    3867              :                       {
    3868            0 :                         *listp = list->next;
    3869            0 :                         delete list;
    3870            0 :                         list = *listp;
    3871            0 :                         break;
    3872              :                       }
    3873              : 
    3874            0 :                     gcc_assert (list->dv != cdv);
    3875              :                   }
    3876              :               }
    3877              :             else
    3878            0 :               gcc_unreachable ();
    3879              : 
    3880       938250 :             if (flag_checking)
    3881       938250 :               while (list)
    3882              :                 {
    3883            0 :                   if (list->offset == 0 && (list->dv == dv || list->dv == cdv))
    3884            0 :                     gcc_unreachable ();
    3885              : 
    3886            0 :                   list = list->next;
    3887              :                 }
    3888              :           }
    3889              :       }
    3890              : 
    3891    300497550 :   if (val)
    3892    119449550 :     set_slot_part (set, val, cslot, cdv, 0,
    3893              :                    VAR_INIT_STATUS_INITIALIZED, NULL_RTX);
    3894              : 
    3895    300497550 :   slot = clobber_slot_part (set, cval, slot, 0, NULL);
    3896              : 
    3897              :   /* Variable may have been unshared.  */
    3898    300497550 :   var = *slot;
    3899    300497550 :   gcc_checking_assert (var->n_var_parts && var->var_part[0].loc_chain->loc == cval
    3900              :                        && var->var_part[0].loc_chain->next == NULL);
    3901              : 
    3902    300497550 :   if (VALUE_RECURSED_INTO (cval))
    3903     50021126 :     goto restart_with_cval;
    3904              : 
    3905              :   return 1;
    3906              : }
    3907              : 
    3908              : /* Bind one-part variables to the canonical value in an equivalence
    3909              :    set.  Not doing this causes dataflow convergence failure in rare
    3910              :    circumstances, see PR42873.  Unfortunately we can't do this
    3911              :    efficiently as part of canonicalize_values_star, since we may not
    3912              :    have determined or even seen the canonical value of a set when we
    3913              :    get to a variable that references another member of the set.  */
    3914              : 
    3915              : int
    3916    110123200 : canonicalize_vars_star (variable **slot, dataflow_set *set)
    3917              : {
    3918    110123200 :   variable *var = *slot;
    3919    110123200 :   decl_or_value dv = var->dv;
    3920    110123200 :   location_chain *node;
    3921    110123200 :   rtx cval;
    3922    110123200 :   decl_or_value cdv;
    3923    110123200 :   variable **cslot;
    3924    110123200 :   variable *cvar;
    3925    110123200 :   location_chain *cnode;
    3926              : 
    3927    110123200 :   if (!var->onepart || var->onepart == ONEPART_VALUE)
    3928              :     return 1;
    3929              : 
    3930     46848777 :   gcc_assert (var->n_var_parts == 1);
    3931              : 
    3932     46848777 :   node = var->var_part[0].loc_chain;
    3933              : 
    3934     46848777 :   if (GET_CODE (node->loc) != VALUE)
    3935              :     return 1;
    3936              : 
    3937     39330107 :   gcc_assert (!node->next);
    3938     39330107 :   cval = node->loc;
    3939              : 
    3940              :   /* Push values to the canonical one.  */
    3941     39330107 :   cdv = dv_from_value (cval);
    3942     39330107 :   cslot = shared_hash_find_slot_noinsert (set->vars, cdv);
    3943     39330107 :   if (!cslot)
    3944              :     return 1;
    3945     13613535 :   cvar = *cslot;
    3946     13613535 :   gcc_assert (cvar->n_var_parts == 1);
    3947              : 
    3948     13613535 :   cnode = cvar->var_part[0].loc_chain;
    3949              : 
    3950              :   /* CVAL is canonical if its value list contains non-VALUEs or VALUEs
    3951              :      that are not “more canonical” than it.  */
    3952     13613535 :   if (GET_CODE (cnode->loc) != VALUE
    3953     13613535 :       || !canon_value_cmp (cnode->loc, cval))
    3954              :     return 1;
    3955              : 
    3956              :   /* CVAL was found to be non-canonical.  Change the variable to point
    3957              :      to the canonical VALUE.  */
    3958       522996 :   gcc_assert (!cnode->next);
    3959       522996 :   cval = cnode->loc;
    3960              : 
    3961       522996 :   slot = set_slot_part (set, cval, slot, dv, 0,
    3962              :                         node->init, node->set_src);
    3963       522996 :   clobber_slot_part (set, cval, slot, 0, node->set_src);
    3964              : 
    3965       522996 :   return 1;
    3966              : }
    3967              : 
    3968              : /* Combine variable or value in *S1SLOT (in DSM->cur) with the
    3969              :    corresponding entry in DSM->src.  Multi-part variables are combined
    3970              :    with variable_union, whereas onepart dvs are combined with
    3971              :    intersection.  */
    3972              : 
    3973              : static int
    3974    179846856 : variable_merge_over_cur (variable *s1var, struct dfset_merge *dsm)
    3975              : {
    3976    179846856 :   dataflow_set *dst = dsm->dst;
    3977    179846856 :   variable **dstslot;
    3978    179846856 :   variable *s2var, *dvar = NULL;
    3979    179846856 :   decl_or_value dv = s1var->dv;
    3980    179846856 :   onepart_enum onepart = s1var->onepart;
    3981    179846856 :   rtx val;
    3982    179846856 :   hashval_t dvhash;
    3983    179846856 :   location_chain *node, **nodep;
    3984              : 
    3985              :   /* If the incoming onepart variable has an empty location list, then
    3986              :      the intersection will be just as empty.  For other variables,
    3987              :      it's always union.  */
    3988    179846856 :   gcc_checking_assert (s1var->n_var_parts
    3989              :                        && s1var->var_part[0].loc_chain);
    3990              : 
    3991    179846856 :   if (!onepart)
    3992      1394807 :     return variable_union (s1var, dst);
    3993              : 
    3994    178452049 :   gcc_checking_assert (s1var->n_var_parts == 1);
    3995              : 
    3996    178452049 :   dvhash = dv_htab_hash (dv);
    3997    178452049 :   if (dv_is_value_p (dv))
    3998    104688170 :     val = dv_as_value (dv);
    3999              :   else
    4000              :     val = NULL;
    4001              : 
    4002    178452049 :   s2var = shared_hash_find_1 (dsm->src->vars, dv, dvhash);
    4003    178452049 :   if (!s2var)
    4004              :     {
    4005     21948379 :       dst_can_be_shared = false;
    4006     21948379 :       return 1;
    4007              :     }
    4008              : 
    4009    156503670 :   dsm->src_onepart_cnt--;
    4010    156503670 :   gcc_assert (s2var->var_part[0].loc_chain
    4011              :               && s2var->onepart == onepart
    4012              :               && s2var->n_var_parts == 1);
    4013              : 
    4014    156503670 :   dstslot = shared_hash_find_slot_noinsert_1 (dst->vars, dv, dvhash);
    4015    156503670 :   if (dstslot)
    4016              :     {
    4017     22910498 :       dvar = *dstslot;
    4018     22910498 :       gcc_assert (dvar->refcount == 1
    4019              :                   && dvar->onepart == onepart
    4020              :                   && dvar->n_var_parts == 1);
    4021     22910498 :       nodep = &dvar->var_part[0].loc_chain;
    4022              :     }
    4023              :   else
    4024              :     {
    4025    133593172 :       nodep = &node;
    4026    133593172 :       node = NULL;
    4027              :     }
    4028              : 
    4029    156503670 :   if (!dstslot && !onepart_variable_different_p (s1var, s2var))
    4030              :     {
    4031    123606436 :       dstslot = shared_hash_find_slot_unshare_1 (&dst->vars, dv,
    4032              :                                                  dvhash, INSERT);
    4033    123606436 :       *dstslot = dvar = s2var;
    4034    123606436 :       dvar->refcount++;
    4035              :     }
    4036              :   else
    4037              :     {
    4038     32897234 :       dst_can_be_shared = false;
    4039              : 
    4040     32897234 :       intersect_loc_chains (val, nodep, dsm,
    4041              :                             s1var->var_part[0].loc_chain, s2var);
    4042              : 
    4043     32897234 :       if (!dstslot)
    4044              :         {
    4045      9986736 :           if (node)
    4046              :             {
    4047      7889486 :               dvar = onepart_pool_allocate (onepart);
    4048      7889486 :               dvar->dv = dv;
    4049      7889486 :               dvar->refcount = 1;
    4050      7889486 :               dvar->n_var_parts = 1;
    4051      7889486 :               dvar->onepart = onepart;
    4052      7889486 :               dvar->in_changed_variables = false;
    4053      7889486 :               dvar->var_part[0].loc_chain = node;
    4054      7889486 :               dvar->var_part[0].cur_loc = NULL;
    4055      7889486 :               if (onepart)
    4056      7889486 :                 VAR_LOC_1PAUX (dvar) = NULL;
    4057              :               else
    4058              :                 VAR_PART_OFFSET (dvar, 0) = 0;
    4059              : 
    4060      7889486 :               dstslot
    4061      7889486 :                 = shared_hash_find_slot_unshare_1 (&dst->vars, dv, dvhash,
    4062              :                                                    INSERT);
    4063      7889486 :               gcc_assert (!*dstslot);
    4064      7889486 :               *dstslot = dvar;
    4065              :             }
    4066              :           else
    4067              :             return 1;
    4068              :         }
    4069              :     }
    4070              : 
    4071    154406420 :   nodep = &dvar->var_part[0].loc_chain;
    4072    172243649 :   while ((node = *nodep))
    4073              :     {
    4074    161460547 :       location_chain **nextp = &node->next;
    4075              : 
    4076    161460547 :       if (GET_CODE (node->loc) == REG)
    4077              :         {
    4078     17837229 :           attrs *list;
    4079              : 
    4080     18691664 :           for (list = dst->regs[REGNO (node->loc)]; list; list = list->next)
    4081       897569 :             if (GET_MODE (node->loc) == GET_MODE (list->loc)
    4082      1330540 :                 && dv_is_value_p (list->dv))
    4083              :               break;
    4084              : 
    4085     17837229 :           if (!list)
    4086     17794095 :             attrs_list_insert (&dst->regs[REGNO (node->loc)],
    4087              :                                dv, 0, node->loc);
    4088              :           /* If this value became canonical for another value that had
    4089              :              this register, we want to leave it alone.  */
    4090        43134 :           else if (dv_as_value (list->dv) != val)
    4091              :             {
    4092        27656 :               dstslot = set_slot_part (dst, dv_as_value (list->dv),
    4093              :                                        dstslot, dv, 0,
    4094              :                                        node->init, NULL_RTX);
    4095        27656 :               dstslot = delete_slot_part (dst, node->loc, dstslot, 0);
    4096              : 
    4097              :               /* Since nextp points into the removed node, we can't
    4098              :                  use it.  The pointer to the next node moved to nodep.
    4099              :                  However, if the variable we're walking is unshared
    4100              :                  during our walk, we'll keep walking the location list
    4101              :                  of the previously-shared variable, in which case the
    4102              :                  node won't have been removed, and we'll want to skip
    4103              :                  it.  That's why we test *nodep here.  */
    4104        27656 :               if (*nodep != node)
    4105        27656 :                 nextp = nodep;
    4106              :             }
    4107              :         }
    4108              :       else
    4109              :         /* Canonicalization puts registers first, so we don't have to
    4110              :            walk it all.  */
    4111              :         break;
    4112     17837229 :       nodep = nextp;
    4113              :     }
    4114              : 
    4115    154406420 :   if (dvar != *dstslot)
    4116              :     dvar = *dstslot;
    4117    154406420 :   nodep = &dvar->var_part[0].loc_chain;
    4118              : 
    4119    154406420 :   if (val)
    4120              :     {
    4121              :       /* Mark all referenced nodes for canonicalization, and make sure
    4122              :          we have mutual equivalence links.  */
    4123     86314520 :       VALUE_RECURSED_INTO (val) = true;
    4124    195385918 :       for (node = *nodep; node; node = node->next)
    4125    109071398 :         if (GET_CODE (node->loc) == VALUE)
    4126              :           {
    4127     48600394 :             VALUE_RECURSED_INTO (node->loc) = true;
    4128     48600394 :             set_variable_part (dst, val, dv_from_value (node->loc), 0,
    4129              :                                node->init, NULL, INSERT);
    4130              :           }
    4131              : 
    4132     86314520 :       dstslot = shared_hash_find_slot_noinsert_1 (dst->vars, dv, dvhash);
    4133     86314520 :       gcc_assert (*dstslot == dvar);
    4134     86314520 :       canonicalize_values_star (dstslot, dst);
    4135     86314520 :       gcc_checking_assert (dstslot
    4136              :                            == shared_hash_find_slot_noinsert_1 (dst->vars,
    4137              :                                                                 dv, dvhash));
    4138     86314520 :       dvar = *dstslot;
    4139              :     }
    4140              :   else
    4141              :     {
    4142     68091900 :       bool has_value = false, has_other = false;
    4143              : 
    4144              :       /* If we have one value and anything else, we're going to
    4145              :          canonicalize this, so make sure all values have an entry in
    4146              :          the table and are marked for canonicalization.  */
    4147    136243288 :       for (node = *nodep; node; node = node->next)
    4148              :         {
    4149     68175978 :           if (GET_CODE (node->loc) == VALUE)
    4150              :             {
    4151              :               /* If this was marked during register canonicalization,
    4152              :                  we know we have to canonicalize values.  */
    4153     56010434 :               if (has_value)
    4154              :                 has_other = true;
    4155     56003271 :               has_value = true;
    4156     56003271 :               if (has_other)
    4157              :                 break;
    4158              :             }
    4159              :           else
    4160              :             {
    4161     12165544 :               has_other = true;
    4162     12165544 :               if (has_value)
    4163              :                 break;
    4164              :             }
    4165              :         }
    4166              : 
    4167     68091900 :       if (has_value && has_other)
    4168              :         {
    4169        81955 :           for (node = *nodep; node; node = node->next)
    4170              :             {
    4171        57365 :               if (GET_CODE (node->loc) == VALUE)
    4172              :                 {
    4173        39174 :                   decl_or_value dv = dv_from_value (node->loc);
    4174        39174 :                   variable **slot = NULL;
    4175              : 
    4176        39174 :                   if (shared_hash_shared (dst->vars))
    4177            0 :                     slot = shared_hash_find_slot_noinsert (dst->vars, dv);
    4178            0 :                   if (!slot)
    4179        39174 :                     slot = shared_hash_find_slot_unshare (&dst->vars, dv,
    4180              :                                                           INSERT);
    4181        39174 :                   if (!*slot)
    4182              :                     {
    4183        17481 :                       variable *var = onepart_pool_allocate (ONEPART_VALUE);
    4184        17481 :                       var->dv = dv;
    4185        17481 :                       var->refcount = 1;
    4186        17481 :                       var->n_var_parts = 1;
    4187        17481 :                       var->onepart = ONEPART_VALUE;
    4188        17481 :                       var->in_changed_variables = false;
    4189        17481 :                       var->var_part[0].loc_chain = NULL;
    4190        17481 :                       var->var_part[0].cur_loc = NULL;
    4191        17481 :                       VAR_LOC_1PAUX (var) = NULL;
    4192        17481 :                       *slot = var;
    4193              :                     }
    4194              : 
    4195        39174 :                   VALUE_RECURSED_INTO (node->loc) = true;
    4196              :                 }
    4197              :             }
    4198              : 
    4199        24590 :           dstslot = shared_hash_find_slot_noinsert_1 (dst->vars, dv, dvhash);
    4200        24590 :           gcc_assert (*dstslot == dvar);
    4201        24590 :           canonicalize_values_star (dstslot, dst);
    4202        24590 :           gcc_checking_assert (dstslot
    4203              :                                == shared_hash_find_slot_noinsert_1 (dst->vars,
    4204              :                                                                     dv, dvhash));
    4205        24590 :           dvar = *dstslot;
    4206              :         }
    4207              :     }
    4208              : 
    4209    154406420 :   if (!onepart_variable_different_p (dvar, s2var))
    4210              :     {
    4211    148098376 :       variable_htab_free (dvar);
    4212    148098376 :       *dstslot = dvar = s2var;
    4213    148098376 :       dvar->refcount++;
    4214              :     }
    4215      6308044 :   else if (s2var != s1var && !onepart_variable_different_p (dvar, s1var))
    4216              :     {
    4217      4329855 :       variable_htab_free (dvar);
    4218      4329855 :       *dstslot = dvar = s1var;
    4219      4329855 :       dvar->refcount++;
    4220      4329855 :       dst_can_be_shared = false;
    4221              :     }
    4222              :   else
    4223      1978189 :     dst_can_be_shared = false;
    4224              : 
    4225              :   return 1;
    4226              : }
    4227              : 
    4228              : /* Copy s2slot (in DSM->src) to DSM->dst if the variable is a
    4229              :    multi-part variable.  Unions of multi-part variables and
    4230              :    intersections of one-part ones will be handled in
    4231              :    variable_merge_over_cur().  */
    4232              : 
    4233              : static int
    4234    209178279 : variable_merge_over_src (variable *s2var, struct dfset_merge *dsm)
    4235              : {
    4236    209178279 :   dataflow_set *dst = dsm->dst;
    4237    209178279 :   decl_or_value dv = s2var->dv;
    4238              : 
    4239    209178279 :   if (!s2var->onepart)
    4240              :     {
    4241       995614 :       variable **dstp = shared_hash_find_slot (dst->vars, dv);
    4242       995614 :       *dstp = s2var;
    4243       995614 :       s2var->refcount++;
    4244       995614 :       return 1;
    4245              :     }
    4246              : 
    4247    208182665 :   dsm->src_onepart_cnt++;
    4248    208182665 :   return 1;
    4249              : }
    4250              : 
    4251              : /* Combine dataflow set information from SRC2 into DST, using PDST
    4252              :    to carry over information across passes.  */
    4253              : 
    4254              : static void
    4255      4374980 : dataflow_set_merge (dataflow_set *dst, dataflow_set *src2)
    4256              : {
    4257      4374980 :   dataflow_set cur = *dst;
    4258      4374980 :   dataflow_set *src1 = &cur;
    4259      4374980 :   struct dfset_merge dsm;
    4260      4374980 :   int i;
    4261      4374980 :   size_t src1_elems, src2_elems;
    4262      4374980 :   variable_iterator_type hi;
    4263      4374980 :   variable *var;
    4264              : 
    4265      4374980 :   src1_elems = shared_hash_htab (src1->vars)->elements ();
    4266      4374980 :   src2_elems = shared_hash_htab (src2->vars)->elements ();
    4267      4374980 :   dataflow_set_init (dst);
    4268      4374980 :   dst->stack_adjust = cur.stack_adjust;
    4269      4374980 :   shared_hash_destroy (dst->vars);
    4270      4374980 :   dst->vars = new shared_hash;
    4271      4374980 :   dst->vars->refcount = 1;
    4272      4374980 :   dst->vars->htab = new variable_table_type (MAX (src1_elems, src2_elems));
    4273              : 
    4274    415623100 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    4275    411248120 :     attrs_list_mpdv_union (&dst->regs[i], src1->regs[i], src2->regs[i]);
    4276              : 
    4277      4374980 :   dsm.dst = dst;
    4278      4374980 :   dsm.src = src2;
    4279      4374980 :   dsm.cur = src1;
    4280      4374980 :   dsm.src_onepart_cnt = 0;
    4281              : 
    4282    213553259 :   FOR_EACH_HASH_TABLE_ELEMENT (*shared_hash_htab (dsm.src->vars),
    4283              :                                var, variable, hi)
    4284    209178279 :     variable_merge_over_src (var, &dsm);
    4285    184221836 :   FOR_EACH_HASH_TABLE_ELEMENT (*shared_hash_htab (dsm.cur->vars),
    4286              :                                var, variable, hi)
    4287    179846856 :     variable_merge_over_cur (var, &dsm);
    4288              : 
    4289      4374980 :   if (dsm.src_onepart_cnt)
    4290      4012819 :     dst_can_be_shared = false;
    4291              : 
    4292      4374980 :   dataflow_set_destroy (src1);
    4293      4374980 : }
    4294              : 
    4295              : /* Mark register equivalences.  */
    4296              : 
    4297              : static void
    4298      9464930 : dataflow_set_equiv_regs (dataflow_set *set)
    4299              : {
    4300      9464930 :   int i;
    4301      9464930 :   attrs *list, **listp;
    4302              : 
    4303    899168350 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    4304              :     {
    4305    889703420 :       rtx canon[NUM_MACHINE_MODES];
    4306              : 
    4307              :       /* If the list is empty or one entry, no need to canonicalize
    4308              :          anything.  */
    4309    889703420 :       if (set->regs[i] == NULL || set->regs[i]->next == NULL)
    4310    886877104 :         continue;
    4311              : 
    4312      2826316 :       memset (canon, 0, sizeof (canon));
    4313              : 
    4314      8621276 :       for (list = set->regs[i]; list; list = list->next)
    4315     11100999 :         if (list->offset == 0 && dv_is_value_p (list->dv))
    4316              :           {
    4317      4615431 :             rtx val = dv_as_value (list->dv);
    4318      4615431 :             rtx *cvalp = &canon[(int)GET_MODE (val)];
    4319      4615431 :             rtx cval = *cvalp;
    4320              : 
    4321      4615431 :             if (canon_value_cmp (val, cval))
    4322      4615431 :               *cvalp = val;
    4323              :           }
    4324              : 
    4325      8621276 :       for (list = set->regs[i]; list; list = list->next)
    4326      5794960 :         if (list->offset == 0 && dv_onepart_p (list->dv))
    4327              :           {
    4328      4615431 :             rtx cval = canon[(int)GET_MODE (list->loc)];
    4329              : 
    4330      4615431 :             if (!cval)
    4331            0 :               continue;
    4332              : 
    4333      4615431 :             if (dv_is_value_p (list->dv))
    4334              :               {
    4335      4615431 :                 rtx val = dv_as_value (list->dv);
    4336              : 
    4337      4615431 :                 if (val == cval)
    4338      4615431 :                   continue;
    4339              : 
    4340            0 :                 VALUE_RECURSED_INTO (val) = true;
    4341            0 :                 set_variable_part (set, val, dv_from_value (cval), 0,
    4342              :                                    VAR_INIT_STATUS_INITIALIZED,
    4343              :                                    NULL, NO_INSERT);
    4344              :               }
    4345              : 
    4346            0 :             VALUE_RECURSED_INTO (cval) = true;
    4347            0 :             set_variable_part (set, cval, list->dv, 0,
    4348              :                                VAR_INIT_STATUS_INITIALIZED, NULL, NO_INSERT);
    4349              :           }
    4350              : 
    4351     14416236 :       for (listp = &set->regs[i]; (list = *listp);
    4352      5794960 :            listp = list ? &list->next : listp)
    4353      5794960 :         if (list->offset == 0 && dv_onepart_p (list->dv))
    4354              :           {
    4355      4615431 :             rtx cval = canon[(int)GET_MODE (list->loc)];
    4356      4615431 :             variable **slot;
    4357              : 
    4358      4615431 :             if (!cval)
    4359            0 :               continue;
    4360              : 
    4361      4615431 :             if (dv_is_value_p (list->dv))
    4362              :               {
    4363      4615431 :                 rtx val = dv_as_value (list->dv);
    4364      4615431 :                 if (!VALUE_RECURSED_INTO (val))
    4365      4615431 :                   continue;
    4366              :               }
    4367              : 
    4368            0 :             slot = shared_hash_find_slot_noinsert (set->vars, list->dv);
    4369            0 :             canonicalize_values_star (slot, set);
    4370            0 :             if (*listp != list)
    4371              :               list = NULL;
    4372              :           }
    4373              :     }
    4374      9464930 : }
    4375              : 
    4376              : /* Remove any redundant values in the location list of VAR, which must
    4377              :    be unshared and 1-part.  */
    4378              : 
    4379              : static void
    4380       662087 : remove_duplicate_values (variable *var)
    4381              : {
    4382       662087 :   location_chain *node, **nodep;
    4383              : 
    4384       662087 :   gcc_assert (var->onepart);
    4385       662087 :   gcc_assert (var->n_var_parts == 1);
    4386       662087 :   gcc_assert (var->refcount == 1);
    4387              : 
    4388      1367204 :   for (nodep = &var->var_part[0].loc_chain; (node = *nodep); )
    4389              :     {
    4390       705117 :       if (GET_CODE (node->loc) == VALUE)
    4391              :         {
    4392       674833 :           if (VALUE_RECURSED_INTO (node->loc))
    4393              :             {
    4394              :               /* Remove duplicate value node.  */
    4395            0 :               *nodep = node->next;
    4396            0 :               delete node;
    4397            0 :               continue;
    4398              :             }
    4399              :           else
    4400       674833 :             VALUE_RECURSED_INTO (node->loc) = true;
    4401              :         }
    4402       705117 :       nodep = &node->next;
    4403              :     }
    4404              : 
    4405      1367204 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    4406       705117 :     if (GET_CODE (node->loc) == VALUE)
    4407              :       {
    4408       674833 :         gcc_assert (VALUE_RECURSED_INTO (node->loc));
    4409       674833 :         VALUE_RECURSED_INTO (node->loc) = false;
    4410              :       }
    4411       662087 : }
    4412              : 
    4413              : 
    4414              : /* Hash table iteration argument passed to variable_post_merge.  */
    4415              : struct dfset_post_merge
    4416              : {
    4417              :   /* The new input set for the current block.  */
    4418              :   dataflow_set *set;
    4419              :   /* Pointer to the permanent input set for the current block, or
    4420              :      NULL.  */
    4421              :   dataflow_set **permp;
    4422              : };
    4423              : 
    4424              : /* Create values for incoming expressions associated with one-part
    4425              :    variables that don't have value numbers for them.  */
    4426              : 
    4427              : int
    4428    109501365 : variable_post_merge_new_vals (variable **slot, dfset_post_merge *dfpm)
    4429              : {
    4430    109501365 :   dataflow_set *set = dfpm->set;
    4431    109501365 :   variable *var = *slot;
    4432    109501365 :   location_chain *node;
    4433              : 
    4434    109501365 :   if (!var->onepart || !var->n_var_parts)
    4435              :     return 1;
    4436              : 
    4437    108818879 :   gcc_assert (var->n_var_parts == 1);
    4438              : 
    4439    108818879 :   if (dv_is_decl_p (var->dv))
    4440              :     {
    4441              :       bool check_dupes = false;
    4442              : 
    4443     46848777 :     restart:
    4444     93743358 :       for (node = var->var_part[0].loc_chain; node; node = node->next)
    4445              :         {
    4446     46894581 :           if (GET_CODE (node->loc) == VALUE)
    4447     38668020 :             gcc_assert (!VALUE_RECURSED_INTO (node->loc));
    4448      8226561 :           else if (GET_CODE (node->loc) == REG)
    4449              :             {
    4450       674833 :               attrs *att, **attp, **curp = NULL;
    4451              : 
    4452       674833 :               if (var->refcount != 1)
    4453              :                 {
    4454            0 :                   slot = unshare_variable (set, slot, var,
    4455              :                                            VAR_INIT_STATUS_INITIALIZED);
    4456            0 :                   var = *slot;
    4457            0 :                   goto restart;
    4458              :                 }
    4459              : 
    4460      1440834 :               for (attp = &set->regs[REGNO (node->loc)]; (att = *attp);
    4461       766001 :                    attp = &att->next)
    4462       766001 :                 if (att->offset == 0
    4463       764989 :                     && GET_MODE (att->loc) == GET_MODE (node->loc))
    4464              :                   {
    4465       764501 :                     if (dv_is_value_p (att->dv))
    4466              :                       {
    4467            0 :                         rtx cval = dv_as_value (att->dv);
    4468            0 :                         node->loc = cval;
    4469            0 :                         check_dupes = true;
    4470            0 :                         break;
    4471              :                       }
    4472       764501 :                     else if (att->dv == var->dv)
    4473       766001 :                       curp = attp;
    4474              :                   }
    4475              : 
    4476       674833 :               if (!curp)
    4477              :                 {
    4478              :                   curp = attp;
    4479            0 :                   while (*curp)
    4480            0 :                     if ((*curp)->offset == 0
    4481            0 :                         && GET_MODE ((*curp)->loc) == GET_MODE (node->loc)
    4482            0 :                         && (*curp)->dv == var->dv)
    4483              :                       break;
    4484              :                     else
    4485            0 :                       curp = &(*curp)->next;
    4486            0 :                   gcc_assert (*curp);
    4487              :                 }
    4488              : 
    4489       674833 :               if (!att)
    4490              :                 {
    4491       674833 :                   decl_or_value cdv;
    4492       674833 :                   rtx cval;
    4493              : 
    4494       674833 :                   if (!*dfpm->permp)
    4495              :                     {
    4496       278085 :                       *dfpm->permp = XNEW (dataflow_set);
    4497       278085 :                       dataflow_set_init (*dfpm->permp);
    4498              :                     }
    4499              : 
    4500       674833 :                   for (att = (*dfpm->permp)->regs[REGNO (node->loc)];
    4501       674921 :                        att; att = att->next)
    4502       286660 :                     if (GET_MODE (att->loc) == GET_MODE (node->loc))
    4503              :                       {
    4504       286572 :                         gcc_assert (att->offset == 0
    4505              :                                     && dv_is_value_p (att->dv));
    4506       286572 :                         val_reset (set, att->dv);
    4507       286572 :                         break;
    4508              :                       }
    4509              : 
    4510       674833 :                   if (att)
    4511              :                     {
    4512       286572 :                       cdv = att->dv;
    4513       286572 :                       cval = dv_as_value (cdv);
    4514              :                     }
    4515              :                   else
    4516              :                     {
    4517              :                       /* Create a unique value to hold this register,
    4518              :                          that ought to be found and reused in
    4519              :                          subsequent rounds.  */
    4520       388261 :                       cselib_val *v;
    4521       388261 :                       gcc_assert (!cselib_lookup (node->loc,
    4522              :                                                   GET_MODE (node->loc), 0,
    4523              :                                                   VOIDmode));
    4524       388261 :                       v = cselib_lookup (node->loc, GET_MODE (node->loc), 1,
    4525              :                                          VOIDmode);
    4526       388261 :                       cselib_preserve_value (v);
    4527       388261 :                       cselib_invalidate_rtx (node->loc);
    4528       388261 :                       cval = v->val_rtx;
    4529       388261 :                       cdv = dv_from_value (cval);
    4530       388261 :                       if (dump_file)
    4531            0 :                         fprintf (dump_file,
    4532              :                                  "Created new value %u:%u for reg %i\n",
    4533            0 :                                  CSELIB_VAL_UID (v->val_rtx), v->hash,
    4534            0 :                                  REGNO (node->loc));
    4535              :                     }
    4536              : 
    4537       674833 :                   var_reg_decl_set (*dfpm->permp, node->loc,
    4538              :                                     VAR_INIT_STATUS_INITIALIZED,
    4539              :                                     cdv, 0, NULL, INSERT);
    4540              : 
    4541       674833 :                   node->loc = cval;
    4542       674833 :                   check_dupes = true;
    4543              :                 }
    4544              : 
    4545              :               /* Remove attribute referring to the decl, which now
    4546              :                  uses the value for the register, already existing or
    4547              :                  to be added when we bring perm in.  */
    4548       674833 :               att = *curp;
    4549       674833 :               *curp = att->next;
    4550       674833 :               delete att;
    4551              :             }
    4552              :         }
    4553              : 
    4554     46848777 :       if (check_dupes)
    4555       662087 :         remove_duplicate_values (var);
    4556              :     }
    4557              : 
    4558              :   return 1;
    4559              : }
    4560              : 
    4561              : /* Reset values in the permanent set that are not associated with the
    4562              :    chosen expression.  */
    4563              : 
    4564              : int
    4565       621835 : variable_post_merge_perm_vals (variable **pslot, dfset_post_merge *dfpm)
    4566              : {
    4567       621835 :   dataflow_set *set = dfpm->set;
    4568       621835 :   variable *pvar = *pslot, *var;
    4569       621835 :   location_chain *pnode;
    4570       621835 :   decl_or_value dv;
    4571       621835 :   attrs *att;
    4572              : 
    4573      1243670 :   gcc_assert (dv_is_value_p (pvar->dv)
    4574              :               && pvar->n_var_parts == 1);
    4575       621835 :   pnode = pvar->var_part[0].loc_chain;
    4576       621835 :   gcc_assert (pnode
    4577              :               && !pnode->next
    4578              :               && REG_P (pnode->loc));
    4579              : 
    4580       621835 :   dv = pvar->dv;
    4581              : 
    4582       621835 :   var = shared_hash_find (set->vars, dv);
    4583       621835 :   if (var)
    4584              :     {
    4585              :       /* Although variable_post_merge_new_vals may have made decls
    4586              :          non-star-canonical, values that pre-existed in canonical form
    4587              :          remain canonical, and newly-created values reference a single
    4588              :          REG, so they are canonical as well.  Since VAR has the
    4589              :          location list for a VALUE, using find_loc_in_1pdv for it is
    4590              :          fine, since VALUEs don't map back to DECLs.  */
    4591            0 :       if (find_loc_in_1pdv (pnode->loc, var, shared_hash_htab (set->vars)))
    4592              :         return 1;
    4593            0 :       val_reset (set, dv);
    4594              :     }
    4595              : 
    4596       625751 :   for (att = set->regs[REGNO (pnode->loc)]; att; att = att->next)
    4597         3916 :     if (att->offset == 0
    4598         3123 :         && GET_MODE (att->loc) == GET_MODE (pnode->loc)
    4599         7039 :         && dv_is_value_p (att->dv))
    4600              :       break;
    4601              : 
    4602              :   /* If there is a value associated with this register already, create
    4603              :      an equivalence.  */
    4604       621835 :   if (att && dv_as_value (att->dv) != dv_as_value (dv))
    4605              :     {
    4606            0 :       rtx cval = dv_as_value (att->dv);
    4607            0 :       set_variable_part (set, cval, dv, 0, pnode->init, NULL, INSERT);
    4608            0 :       set_variable_part (set, dv_as_value (dv), att->dv, 0, pnode->init,
    4609              :                          NULL, INSERT);
    4610              :     }
    4611       621835 :   else if (!att)
    4612              :     {
    4613       621835 :       attrs_list_insert (&set->regs[REGNO (pnode->loc)],
    4614              :                          dv, 0, pnode->loc);
    4615       621835 :       variable_union (pvar, set);
    4616              :     }
    4617              : 
    4618              :   return 1;
    4619              : }
    4620              : 
    4621              : /* Just checking stuff and registering register attributes for
    4622              :    now.  */
    4623              : 
    4624              : static void
    4625      2830679 : dataflow_post_merge_adjust (dataflow_set *set, dataflow_set **permp)
    4626              : {
    4627      2830679 :   struct dfset_post_merge dfpm;
    4628              : 
    4629      2830679 :   dfpm.set = set;
    4630      2830679 :   dfpm.permp = permp;
    4631              : 
    4632      2830679 :   shared_hash_htab (set->vars)
    4633    112332044 :     ->traverse <dfset_post_merge*, variable_post_merge_new_vals> (&dfpm);
    4634      2830679 :   if (*permp)
    4635       444790 :     shared_hash_htab ((*permp)->vars)
    4636      1066625 :       ->traverse <dfset_post_merge*, variable_post_merge_perm_vals> (&dfpm);
    4637      2830679 :   shared_hash_htab (set->vars)
    4638    535975249 :     ->traverse <dataflow_set *, canonicalize_values_star> (set);
    4639      2830679 :   shared_hash_htab (set->vars)
    4640    112953879 :     ->traverse <dataflow_set *, canonicalize_vars_star> (set);
    4641      2830679 : }
    4642              : 
    4643              : /* Return a node whose loc is a MEM that refers to EXPR in the
    4644              :    location list of a one-part variable or value VAR, or in that of
    4645              :    any values recursively mentioned in the location lists.  */
    4646              : 
    4647              : static location_chain *
    4648    114823067 : find_mem_expr_in_1pdv (tree expr, rtx val, variable_table_type *vars)
    4649              : {
    4650    114823067 :   location_chain *node;
    4651    114823067 :   decl_or_value dv;
    4652    114823067 :   variable *var;
    4653    114823067 :   location_chain *where = NULL;
    4654              : 
    4655    114823067 :   if (!val)
    4656              :     return NULL;
    4657              : 
    4658    114823067 :   gcc_assert (GET_CODE (val) == VALUE
    4659              :               && !VALUE_RECURSED_INTO (val));
    4660              : 
    4661    114823067 :   dv = dv_from_value (val);
    4662    114823067 :   var = vars->find_with_hash (dv, dv_htab_hash (dv));
    4663              : 
    4664    114823067 :   if (!var)
    4665              :     return NULL;
    4666              : 
    4667     52206554 :   gcc_assert (var->onepart);
    4668              : 
    4669     52206554 :   if (!var->n_var_parts)
    4670              :     return NULL;
    4671              : 
    4672     52206554 :   VALUE_RECURSED_INTO (val) = true;
    4673              : 
    4674    126930280 :   for (node = var->var_part[0].loc_chain; node; node = node->next)
    4675     75702621 :     if (MEM_P (node->loc)
    4676     15892834 :         && MEM_EXPR (node->loc) == expr
    4677     76679987 :         && int_mem_offset (node->loc) == 0)
    4678              :       {
    4679              :         where = node;
    4680              :         break;
    4681              :       }
    4682     74725255 :     else if (GET_CODE (node->loc) == VALUE
    4683     46471865 :              && !VALUE_RECURSED_INTO (node->loc)
    4684     97961951 :              && (where = find_mem_expr_in_1pdv (expr, node->loc, vars)))
    4685              :       break;
    4686              : 
    4687     52206554 :   VALUE_RECURSED_INTO (val) = false;
    4688              : 
    4689     52206554 :   return where;
    4690              : }
    4691              : 
    4692              : /* Return TRUE if the value of MEM may vary across a call.  */
    4693              : 
    4694              : static bool
    4695     99870053 : mem_dies_at_call (rtx mem)
    4696              : {
    4697     99870053 :   tree expr = MEM_EXPR (mem);
    4698     99870053 :   tree decl;
    4699              : 
    4700     99870053 :   if (!expr)
    4701              :     return true;
    4702              : 
    4703     90598183 :   decl = get_base_address (expr);
    4704              : 
    4705     90598183 :   if (!decl)
    4706              :     return true;
    4707              : 
    4708     90598183 :   if (!DECL_P (decl))
    4709              :     return true;
    4710              : 
    4711     82591273 :   return (may_be_aliased (decl)
    4712     82591273 :           || (!TREE_READONLY (decl) && is_global_var (decl)));
    4713              : }
    4714              : 
    4715              : /* Remove all MEMs from the location list of a hash table entry for a
    4716              :    one-part variable, except those whose MEM attributes map back to
    4717              :    the variable itself, directly or within a VALUE.  */
    4718              : 
    4719              : int
    4720    314863062 : dataflow_set_preserve_mem_locs (variable **slot, dataflow_set *set)
    4721              : {
    4722    314863062 :   variable *var = *slot;
    4723              : 
    4724    314863062 :   if (var->onepart == ONEPART_VDECL || var->onepart == ONEPART_DEXPR)
    4725              :     {
    4726    151155648 :       tree decl = dv_as_decl (var->dv);
    4727    151155648 :       location_chain *loc, **locp;
    4728    151155648 :       bool changed = false;
    4729              : 
    4730    151155648 :       if (!var->n_var_parts)
    4731              :         return 1;
    4732              : 
    4733    151155648 :       gcc_assert (var->n_var_parts == 1);
    4734              : 
    4735    151155648 :       if (shared_var_p (var, set->vars))
    4736              :         {
    4737    192398851 :           for (loc = var->var_part[0].loc_chain; loc; loc = loc->next)
    4738              :             {
    4739              :               /* We want to remove dying MEMs that don't refer to DECL.  */
    4740     96447286 :               if (GET_CODE (loc->loc) == MEM
    4741      2228829 :                   && (MEM_EXPR (loc->loc) != decl
    4742      1994249 :                       || int_mem_offset (loc->loc) != 0)
    4743     96681866 :                   && mem_dies_at_call (loc->loc))
    4744              :                 break;
    4745              :               /* We want to move here MEMs that do refer to DECL.  */
    4746     96441389 :               else if (GET_CODE (loc->loc) == VALUE
    4747     96441389 :                        && find_mem_expr_in_1pdv (decl, loc->loc,
    4748              :                                                  shared_hash_htab (set->vars)))
    4749              :                 break;
    4750              :             }
    4751              : 
    4752     96444887 :           if (!loc)
    4753              :             return 1;
    4754              : 
    4755       493322 :           slot = unshare_variable (set, slot, var, VAR_INIT_STATUS_UNKNOWN);
    4756       493322 :           var = *slot;
    4757       493322 :           gcc_assert (var->n_var_parts == 1);
    4758              :         }
    4759              : 
    4760     55204083 :       for (locp = &var->var_part[0].loc_chain, loc = *locp;
    4761    110408659 :            loc; loc = *locp)
    4762              :         {
    4763     55204576 :           rtx old_loc = loc->loc;
    4764     55204576 :           if (GET_CODE (old_loc) == VALUE)
    4765              :             {
    4766     12817108 :               location_chain *mem_node
    4767     12817108 :                 = find_mem_expr_in_1pdv (decl, loc->loc,
    4768              :                                          shared_hash_htab (set->vars));
    4769              : 
    4770              :               /* ??? This picks up only one out of multiple MEMs that
    4771              :                  refer to the same variable.  Do we ever need to be
    4772              :                  concerned about dealing with more than one, or, given
    4773              :                  that they should all map to the same variable
    4774              :                  location, their addresses will have been merged and
    4775              :                  they will be regarded as equivalent?  */
    4776     12817108 :               if (mem_node)
    4777              :                 {
    4778       489941 :                   loc->loc = mem_node->loc;
    4779       489941 :                   loc->set_src = mem_node->set_src;
    4780       979882 :                   loc->init = MIN (loc->init, mem_node->init);
    4781              :                 }
    4782              :             }
    4783              : 
    4784    110403243 :           if (GET_CODE (loc->loc) != MEM
    4785       541291 :               || (MEM_EXPR (loc->loc) == decl
    4786       534556 :                   && int_mem_offset (loc->loc) == 0)
    4787     55211311 :               || !mem_dies_at_call (loc->loc))
    4788              :             {
    4789     55198667 :               if (old_loc != loc->loc && emit_notes)
    4790              :                 {
    4791       242840 :                   if (old_loc == var->var_part[0].cur_loc)
    4792              :                     {
    4793            0 :                       changed = true;
    4794            0 :                       var->var_part[0].cur_loc = NULL;
    4795              :                     }
    4796              :                 }
    4797     55198667 :               locp = &loc->next;
    4798     55198667 :               continue;
    4799              :             }
    4800              : 
    4801         5909 :           if (emit_notes)
    4802              :             {
    4803         2671 :               if (old_loc == var->var_part[0].cur_loc)
    4804              :                 {
    4805            0 :                   changed = true;
    4806            0 :                   var->var_part[0].cur_loc = NULL;
    4807              :                 }
    4808              :             }
    4809         5909 :           *locp = loc->next;
    4810         5909 :           delete loc;
    4811              :         }
    4812              : 
    4813     55204083 :       if (!var->var_part[0].loc_chain)
    4814              :         {
    4815         5432 :           var->n_var_parts--;
    4816         5432 :           changed = true;
    4817              :         }
    4818     55204083 :       if (changed)
    4819         5432 :         variable_was_changed (var, set);
    4820              :     }
    4821              : 
    4822              :   return 1;
    4823              : }
    4824              : 
    4825              : /* Remove all MEMs from the location list of a hash table entry for a
    4826              :    onepart variable.  */
    4827              : 
    4828              : int
    4829    314857630 : dataflow_set_remove_mem_locs (variable **slot, dataflow_set *set)
    4830              : {
    4831    314857630 :   variable *var = *slot;
    4832              : 
    4833    314857630 :   if (var->onepart != NOT_ONEPART)
    4834              :     {
    4835    313565517 :       location_chain *loc, **locp;
    4836    313565517 :       bool changed = false;
    4837    313565517 :       rtx cur_loc;
    4838              : 
    4839    313565517 :       gcc_assert (var->n_var_parts == 1);
    4840              : 
    4841    313565517 :       if (shared_var_p (var, set->vars))
    4842              :         {
    4843    477798095 :           for (loc = var->var_part[0].loc_chain; loc; loc = loc->next)
    4844    256067019 :             if (GET_CODE (loc->loc) == MEM
    4845    256067019 :                 && mem_dies_at_call (loc->loc))
    4846              :               break;
    4847              : 
    4848    227688479 :           if (!loc)
    4849              :             return 1;
    4850              : 
    4851      5957403 :           slot = unshare_variable (set, slot, var, VAR_INIT_STATUS_UNKNOWN);
    4852      5957403 :           var = *slot;
    4853      5957403 :           gcc_assert (var->n_var_parts == 1);
    4854              :         }
    4855              : 
    4856     91834441 :       if (VAR_LOC_1PAUX (var))
    4857     30450760 :         cur_loc = VAR_LOC_FROM (var);
    4858              :       else
    4859     61383681 :         cur_loc = var->var_part[0].cur_loc;
    4860              : 
    4861     91834441 :       for (locp = &var->var_part[0].loc_chain, loc = *locp;
    4862    202339680 :            loc; loc = *locp)
    4863              :         {
    4864    202116003 :           if (GET_CODE (loc->loc) != MEM
    4865    110505239 :               || !mem_dies_at_call (loc->loc))
    4866              :             {
    4867     91610764 :               locp = &loc->next;
    4868     91610764 :               continue;
    4869              :             }
    4870              : 
    4871     18894475 :           *locp = loc->next;
    4872              :           /* If we have deleted the location which was last emitted
    4873              :              we have to emit new location so add the variable to set
    4874              :              of changed variables.  */
    4875     18894475 :           if (cur_loc == loc->loc)
    4876              :             {
    4877       342510 :               changed = true;
    4878       342510 :               var->var_part[0].cur_loc = NULL;
    4879       342510 :               if (VAR_LOC_1PAUX (var))
    4880       342510 :                 VAR_LOC_FROM (var) = NULL;
    4881              :             }
    4882     18894475 :           delete loc;
    4883              :         }
    4884              : 
    4885     91834441 :       if (!var->var_part[0].loc_chain)
    4886              :         {
    4887     12502788 :           var->n_var_parts--;
    4888     12502788 :           changed = true;
    4889              :         }
    4890     91834441 :       if (changed)
    4891     12530677 :         variable_was_changed (var, set);
    4892              :     }
    4893              : 
    4894              :   return 1;
    4895              : }
    4896              : 
    4897              : /* Remove all variable-location information about call-clobbered
    4898              :    registers, as well as associations between MEMs and VALUEs.  */
    4899              : 
    4900              : static void
    4901      7131635 : dataflow_set_clear_at_call (dataflow_set *set, rtx_insn *call_insn)
    4902              : {
    4903      7131635 :   unsigned int r;
    4904      7131635 :   hard_reg_set_iterator hrsi;
    4905              : 
    4906      7131635 :   HARD_REG_SET callee_clobbers
    4907      7131635 :     = insn_callee_abi (call_insn).full_reg_clobbers ();
    4908              : 
    4909    615319076 :   EXECUTE_IF_SET_IN_HARD_REG_SET (callee_clobbers, 0, r, hrsi)
    4910    608187441 :     var_regno_delete (set, r);
    4911              : 
    4912      7131635 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
    4913              :     {
    4914      7131551 :       set->traversed_vars = set->vars;
    4915      7131551 :       shared_hash_htab (set->vars)
    4916    321994613 :         ->traverse <dataflow_set *, dataflow_set_preserve_mem_locs> (set);
    4917      7131551 :       set->traversed_vars = set->vars;
    4918      7131551 :       shared_hash_htab (set->vars)
    4919    321989181 :         ->traverse <dataflow_set *, dataflow_set_remove_mem_locs> (set);
    4920      7131551 :       set->traversed_vars = NULL;
    4921              :     }
    4922      7131635 : }
    4923              : 
    4924              : static bool
    4925       680986 : variable_part_different_p (variable_part *vp1, variable_part *vp2)
    4926              : {
    4927       680986 :   location_chain *lc1, *lc2;
    4928              : 
    4929      1481249 :   for (lc1 = vp1->loc_chain; lc1; lc1 = lc1->next)
    4930              :     {
    4931      1071658 :       for (lc2 = vp2->loc_chain; lc2; lc2 = lc2->next)
    4932              :         {
    4933      1024622 :           if (REG_P (lc1->loc) && REG_P (lc2->loc))
    4934              :             {
    4935       737021 :               if (REGNO (lc1->loc) == REGNO (lc2->loc))
    4936              :                 break;
    4937              :             }
    4938       389382 :           if (rtx_equal_p (lc1->loc, lc2->loc))
    4939              :             break;
    4940              :         }
    4941       800263 :       if (!lc2)
    4942              :         return true;
    4943              :     }
    4944              :   return false;
    4945              : }
    4946              : 
    4947              : /* Return true if one-part variables VAR1 and VAR2 are different.
    4948              :    They must be in canonical order.  */
    4949              : 
    4950              : static bool
    4951    334055120 : onepart_variable_different_p (variable *var1, variable *var2)
    4952              : {
    4953    334055120 :   location_chain *lc1, *lc2;
    4954              : 
    4955    334055120 :   if (var1 == var2)
    4956              :     return false;
    4957              : 
    4958     91447357 :   gcc_assert (var1->n_var_parts == 1
    4959              :               && var2->n_var_parts == 1);
    4960              : 
    4961     91447357 :   lc1 = var1->var_part[0].loc_chain;
    4962     91447357 :   lc2 = var2->var_part[0].loc_chain;
    4963              : 
    4964     91447357 :   gcc_assert (lc1 && lc2);
    4965              : 
    4966    194703650 :   while (lc1 && lc2)
    4967              :     {
    4968    121378305 :       if (loc_cmp (lc1->loc, lc2->loc))
    4969              :         return true;
    4970    103256293 :       lc1 = lc1->next;
    4971    103256293 :       lc2 = lc2->next;
    4972              :     }
    4973              : 
    4974     73325345 :   return lc1 != lc2;
    4975              : }
    4976              : 
    4977              : /* Return true if one-part variables VAR1 and VAR2 are different.
    4978              :    They must be in canonical order.  */
    4979              : 
    4980              : static void
    4981            0 : dump_onepart_variable_differences (variable *var1, variable *var2)
    4982              : {
    4983            0 :   location_chain *lc1, *lc2;
    4984              : 
    4985            0 :   gcc_assert (var1 != var2);
    4986            0 :   gcc_assert (dump_file);
    4987            0 :   gcc_assert (var1->dv == var2->dv);
    4988            0 :   gcc_assert (var1->n_var_parts == 1
    4989              :               && var2->n_var_parts == 1);
    4990              : 
    4991            0 :   lc1 = var1->var_part[0].loc_chain;
    4992            0 :   lc2 = var2->var_part[0].loc_chain;
    4993              : 
    4994            0 :   gcc_assert (lc1 && lc2);
    4995              : 
    4996            0 :   while (lc1 && lc2)
    4997              :     {
    4998            0 :       switch (loc_cmp (lc1->loc, lc2->loc))
    4999              :         {
    5000            0 :         case -1:
    5001            0 :           fprintf (dump_file, "removed: ");
    5002            0 :           print_rtl_single (dump_file, lc1->loc);
    5003            0 :           lc1 = lc1->next;
    5004            0 :           continue;
    5005            0 :         case 0:
    5006            0 :           break;
    5007            0 :         case 1:
    5008            0 :           fprintf (dump_file, "added: ");
    5009            0 :           print_rtl_single (dump_file, lc2->loc);
    5010            0 :           lc2 = lc2->next;
    5011            0 :           continue;
    5012            0 :         default:
    5013            0 :           gcc_unreachable ();
    5014              :         }
    5015            0 :       lc1 = lc1->next;
    5016            0 :       lc2 = lc2->next;
    5017              :     }
    5018              : 
    5019            0 :   while (lc1)
    5020              :     {
    5021            0 :       fprintf (dump_file, "removed: ");
    5022            0 :       print_rtl_single (dump_file, lc1->loc);
    5023            0 :       lc1 = lc1->next;
    5024              :     }
    5025              : 
    5026            0 :   while (lc2)
    5027              :     {
    5028            0 :       fprintf (dump_file, "added: ");
    5029            0 :       print_rtl_single (dump_file, lc2->loc);
    5030            0 :       lc2 = lc2->next;
    5031              :     }
    5032            0 : }
    5033              : 
    5034              : /* Return true if variables VAR1 and VAR2 are different.  */
    5035              : 
    5036              : static bool
    5037    280140931 : variable_different_p (variable *var1, variable *var2)
    5038              : {
    5039    280140931 :   int i;
    5040              : 
    5041    280140931 :   if (var1 == var2)
    5042              :     return false;
    5043              : 
    5044     40049744 :   if (var1->onepart != var2->onepart)
    5045              :     return true;
    5046              : 
    5047     40049744 :   if (var1->n_var_parts != var2->n_var_parts)
    5048              :     return true;
    5049              : 
    5050     40004817 :   if (var1->onepart && var1->n_var_parts)
    5051              :     {
    5052     39747484 :       gcc_checking_assert (var1->dv == var2->dv && var1->n_var_parts == 1);
    5053              :       /* One-part values have locations in a canonical order.  */
    5054     39747484 :       return onepart_variable_different_p (var1, var2);
    5055              :     }
    5056              : 
    5057       559685 :   for (i = 0; i < var1->n_var_parts; i++)
    5058              :     {
    5059       352660 :       if (VAR_PART_OFFSET (var1, i) != VAR_PART_OFFSET (var2, i))
    5060              :         return true;
    5061       349388 :       if (variable_part_different_p (&var1->var_part[i], &var2->var_part[i]))
    5062              :         return true;
    5063       331598 :       if (variable_part_different_p (&var2->var_part[i], &var1->var_part[i]))
    5064              :         return true;
    5065              :     }
    5066              :   return false;
    5067              : }
    5068              : 
    5069              : /* Return true if dataflow sets OLD_SET and NEW_SET differ.  */
    5070              : 
    5071              : static bool
    5072      9465017 : dataflow_set_different (dataflow_set *old_set, dataflow_set *new_set)
    5073              : {
    5074      9465017 :   variable_iterator_type hi;
    5075      9465017 :   variable *var1;
    5076      9465017 :   bool diffound = false;
    5077      9465017 :   bool details = (dump_file && (dump_flags & TDF_DETAILS));
    5078              : 
    5079              : #define RETRUE                                  \
    5080              :   do                                            \
    5081              :     {                                           \
    5082              :       if (!details)                             \
    5083              :         return true;                            \
    5084              :       else                                      \
    5085              :         diffound = true;                        \
    5086              :     }                                           \
    5087              :   while (0)
    5088              : 
    5089      9465017 :   if (old_set->vars == new_set->vars)
    5090              :     return false;
    5091              : 
    5092      9459146 :   if (shared_hash_htab (old_set->vars)->elements ()
    5093      9459146 :       != shared_hash_htab (new_set->vars)->elements ())
    5094      8912320 :     RETRUE;
    5095              : 
    5096     19991017 :   FOR_EACH_HASH_TABLE_ELEMENT (*shared_hash_htab (old_set->vars),
    5097              :                                var1, variable, hi)
    5098              :     {
    5099     19603623 :       variable_table_type *htab = shared_hash_htab (new_set->vars);
    5100     19603623 :       variable *var2 = htab->find_with_hash (var1->dv, dv_htab_hash (var1->dv));
    5101              : 
    5102     19603623 :       if (!var2)
    5103              :         {
    5104        36070 :           if (dump_file && (dump_flags & TDF_DETAILS))
    5105              :             {
    5106            0 :               fprintf (dump_file, "dataflow difference found: removal of:\n");
    5107            0 :               dump_var (var1);
    5108              :             }
    5109        36070 :           RETRUE;
    5110              :         }
    5111     19567553 :       else if (variable_different_p (var1, var2))
    5112              :         {
    5113       123363 :           if (details)
    5114              :             {
    5115            0 :               fprintf (dump_file, "dataflow difference found: "
    5116              :                        "old and new follow:\n");
    5117            0 :               dump_var (var1);
    5118            0 :               if (dv_onepart_p (var1->dv))
    5119            0 :                 dump_onepart_variable_differences (var1, var2);
    5120            0 :               dump_var (var2);
    5121              :             }
    5122            0 :           RETRUE;
    5123              :         }
    5124              :     }
    5125              : 
    5126              :   /* There's no need to traverse the second hashtab unless we want to
    5127              :      print the details.  If both have the same number of elements and
    5128              :      the second one had all entries found in the first one, then the
    5129              :      second can't have any extra entries.  */
    5130       387394 :   if (!details)
    5131              :     return diffound;
    5132              : 
    5133            4 :   FOR_EACH_HASH_TABLE_ELEMENT (*shared_hash_htab (new_set->vars),
    5134              :                                var1, variable, hi)
    5135              :     {
    5136            3 :       variable_table_type *htab = shared_hash_htab (old_set->vars);
    5137            3 :       variable *var2 = htab->find_with_hash (var1->dv, dv_htab_hash (var1->dv));
    5138            3 :       if (!var2)
    5139              :         {
    5140            3 :           if (details)
    5141              :             {
    5142            3 :               fprintf (dump_file, "dataflow difference found: addition of:\n");
    5143            3 :               dump_var (var1);
    5144              :             }
    5145            3 :           RETRUE;
    5146              :         }
    5147              :     }
    5148              : 
    5149              : #undef RETRUE
    5150              : 
    5151              :   return diffound;
    5152              : }
    5153              : 
    5154              : /* Free the contents of dataflow set SET.  */
    5155              : 
    5156              : static void
    5157     31659545 : dataflow_set_destroy (dataflow_set *set)
    5158              : {
    5159     31659545 :   int i;
    5160              : 
    5161   3007656775 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    5162   2975997230 :     attrs_list_clear (&set->regs[i]);
    5163              : 
    5164     31659545 :   shared_hash_destroy (set->vars);
    5165     31659545 :   set->vars = NULL;
    5166     31659545 : }
    5167              : 
    5168              : /* Return true if T is a tracked parameter with non-degenerate record type.  */
    5169              : 
    5170              : static bool
    5171      4176644 : tracked_record_parameter_p (tree t)
    5172              : {
    5173      4176644 :   if (TREE_CODE (t) != PARM_DECL)
    5174              :     return false;
    5175              : 
    5176       350907 :   if (DECL_MODE (t) == BLKmode)
    5177              :     return false;
    5178              : 
    5179       168177 :   tree type = TREE_TYPE (t);
    5180       168177 :   if (TREE_CODE (type) != RECORD_TYPE)
    5181              :     return false;
    5182              : 
    5183       167975 :   if (TYPE_FIELDS (type) == NULL_TREE
    5184       167975 :       || DECL_CHAIN (TYPE_FIELDS (type)) == NULL_TREE)
    5185         1245 :     return false;
    5186              : 
    5187              :   return true;
    5188              : }
    5189              : 
    5190              : /* Shall EXPR be tracked?  */
    5191              : 
    5192              : static bool
    5193     84653942 : track_expr_p (tree expr, bool need_rtl)
    5194              : {
    5195     84653942 :   rtx decl_rtl;
    5196     84653942 :   tree realdecl;
    5197              : 
    5198     84653942 :   if (TREE_CODE (expr) == DEBUG_EXPR_DECL)
    5199      3648080 :     return DECL_RTL_SET_P (expr);
    5200              : 
    5201              :   /* If EXPR is not a parameter or a variable do not track it.  */
    5202     81005862 :   if (!VAR_P (expr) && TREE_CODE (expr) != PARM_DECL)
    5203              :     return 0;
    5204              : 
    5205              :   /* It also must have a name...  */
    5206     50372604 :   if (!DECL_NAME (expr) && need_rtl)
    5207              :     return 0;
    5208              : 
    5209              :   /* ... and a RTL assigned to it.  */
    5210     48961670 :   decl_rtl = DECL_RTL_IF_SET (expr);
    5211     48961670 :   if (!decl_rtl && need_rtl)
    5212              :     return 0;
    5213              : 
    5214              :   /* If this expression is really a debug alias of some other declaration, we
    5215              :      don't need to track this expression if the ultimate declaration is
    5216              :      ignored.  */
    5217     48746970 :   realdecl = expr;
    5218     48746970 :   if (VAR_P (realdecl) && DECL_HAS_DEBUG_EXPR_P (realdecl))
    5219              :     {
    5220      3672221 :       realdecl = DECL_DEBUG_EXPR (realdecl);
    5221      3672221 :       if (!DECL_P (realdecl))
    5222              :         {
    5223      3672221 :           if (handled_component_p (realdecl)
    5224       470558 :               || (TREE_CODE (realdecl) == MEM_REF
    5225       470558 :                   && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR))
    5226              :             {
    5227      3672221 :               HOST_WIDE_INT bitsize, bitpos;
    5228      3672221 :               bool reverse;
    5229      3672221 :               tree innerdecl
    5230      3672221 :                 = get_ref_base_and_extent_hwi (realdecl, &bitpos,
    5231              :                                                &bitsize, &reverse);
    5232      3672221 :               if (!innerdecl
    5233      3672221 :                   || !DECL_P (innerdecl)
    5234      3672221 :                   || DECL_IGNORED_P (innerdecl)
    5235              :                   /* Do not track declarations for parts of tracked record
    5236              :                      parameters since we want to track them as a whole.  */
    5237      3671747 :                   || tracked_record_parameter_p (innerdecl)
    5238      3597016 :                   || TREE_STATIC (innerdecl)
    5239      3597014 :                   || bitsize == 0
    5240      7269235 :                   || bitpos + bitsize > 256)
    5241       234919 :                 return 0;
    5242              :               else
    5243      3437302 :                 realdecl = expr;
    5244              :             }
    5245              :           else
    5246              :             return 0;
    5247              :         }
    5248              :     }
    5249              : 
    5250              :   /* Do not track EXPR if REALDECL it should be ignored for debugging
    5251              :      purposes.  */
    5252     48512051 :   if (DECL_IGNORED_P (realdecl))
    5253              :     return 0;
    5254              : 
    5255              :   /* Do not track global variables until we are able to emit correct location
    5256              :      list for them.  */
    5257     39334107 :   if (TREE_STATIC (realdecl))
    5258              :     return 0;
    5259              : 
    5260              :   /* When the EXPR is a DECL for alias of some variable (see example)
    5261              :      the TREE_STATIC flag is not used.  Disable tracking all DECLs whose
    5262              :      DECL_RTL contains SYMBOL_REF.
    5263              : 
    5264              :      Example:
    5265              :      extern char **_dl_argv_internal __attribute__ ((alias ("_dl_argv")));
    5266              :      char **_dl_argv;
    5267              :   */
    5268      5523326 :   if (decl_rtl && MEM_P (decl_rtl)
    5269     39643365 :       && contains_symbol_ref_p (XEXP (decl_rtl, 0)))
    5270              :     return 0;
    5271              : 
    5272              :   /* If RTX is a memory it should not be very large (because it would be
    5273              :      an array or struct).  */
    5274     39248395 :   if (decl_rtl && MEM_P (decl_rtl))
    5275              :     {
    5276              :       /* Do not track structures and arrays.  */
    5277       356306 :       if ((GET_MODE (decl_rtl) == BLKmode
    5278        53097 :            || AGGREGATE_TYPE_P (TREE_TYPE (realdecl)))
    5279       380148 :           && !tracked_record_parameter_p (realdecl))
    5280              :         return 0;
    5281        43570 :       if (MEM_SIZE_KNOWN_P (decl_rtl)
    5282        43570 :           && maybe_gt (MEM_SIZE (decl_rtl), MAX_VAR_PARTS))
    5283              :         return 0;
    5284              :     }
    5285              : 
    5286     38935146 :   DECL_CHANGED (expr) = 0;
    5287     38935146 :   DECL_CHANGED (realdecl) = 0;
    5288     38935146 :   return 1;
    5289              : }
    5290              : 
    5291              : /* Determine whether a given LOC refers to the same variable part as
    5292              :    EXPR+OFFSET.  */
    5293              : 
    5294              : static bool
    5295       177785 : same_variable_part_p (rtx loc, tree expr, poly_int64 offset)
    5296              : {
    5297       177785 :   tree expr2;
    5298       177785 :   poly_int64 offset2;
    5299              : 
    5300       177785 :   if (! DECL_P (expr))
    5301              :     return false;
    5302              : 
    5303       177785 :   if (REG_P (loc))
    5304              :     {
    5305        92625 :       expr2 = REG_EXPR (loc);
    5306        92625 :       offset2 = REG_OFFSET (loc);
    5307              :     }
    5308        85160 :   else if (MEM_P (loc))
    5309              :     {
    5310        78045 :       expr2 = MEM_EXPR (loc);
    5311        78045 :       offset2 = int_mem_offset (loc);
    5312              :     }
    5313              :   else
    5314              :     return false;
    5315              : 
    5316       170670 :   if (! expr2 || ! DECL_P (expr2))
    5317              :     return false;
    5318              : 
    5319       124819 :   expr = var_debug_decl (expr);
    5320       124819 :   expr2 = var_debug_decl (expr2);
    5321              : 
    5322       124819 :   return (expr == expr2 && known_eq (offset, offset2));
    5323              : }
    5324              : 
    5325              : /* LOC is a REG or MEM that we would like to track if possible.
    5326              :    If EXPR is null, we don't know what expression LOC refers to,
    5327              :    otherwise it refers to EXPR + OFFSET.  STORE_REG_P is true if
    5328              :    LOC is an lvalue register.
    5329              : 
    5330              :    Return true if EXPR is nonnull and if LOC, or some lowpart of it,
    5331              :    is something we can track.  When returning true, store the mode of
    5332              :    the lowpart we can track in *MODE_OUT (if nonnull) and its offset
    5333              :    from EXPR in *OFFSET_OUT (if nonnull).  */
    5334              : 
    5335              : static bool
    5336     43650803 : track_loc_p (rtx loc, tree expr, poly_int64 offset, bool store_reg_p,
    5337              :              machine_mode *mode_out, HOST_WIDE_INT *offset_out)
    5338              : {
    5339     43650803 :   machine_mode mode;
    5340              : 
    5341     43650803 :   if (expr == NULL || !track_expr_p (expr, true))
    5342              :     return false;
    5343              : 
    5344              :   /* If REG was a paradoxical subreg, its REG_ATTRS will describe the
    5345              :      whole subreg, but only the old inner part is really relevant.  */
    5346      1824561 :   mode = GET_MODE (loc);
    5347      1824561 :   if (REG_P (loc) && !HARD_REGISTER_NUM_P (ORIGINAL_REGNO (loc)))
    5348              :     {
    5349       726101 :       machine_mode pseudo_mode;
    5350              : 
    5351       726101 :       pseudo_mode = PSEUDO_REGNO_MODE (ORIGINAL_REGNO (loc));
    5352       726101 :       if (paradoxical_subreg_p (mode, pseudo_mode))
    5353              :         {
    5354          631 :           offset += byte_lowpart_offset (pseudo_mode, mode);
    5355          631 :           mode = pseudo_mode;
    5356              :         }
    5357              :     }
    5358              : 
    5359              :   /* If LOC is a paradoxical lowpart of EXPR, refer to EXPR itself.
    5360              :      Do the same if we are storing to a register and EXPR occupies
    5361              :      the whole of register LOC; in that case, the whole of EXPR is
    5362              :      being changed.  We exclude complex modes from the second case
    5363              :      because the real and imaginary parts are represented as separate
    5364              :      pseudo registers, even if the whole complex value fits into one
    5365              :      hard register.  */
    5366      1824561 :   if ((paradoxical_subreg_p (mode, DECL_MODE (expr))
    5367      1823711 :        || (store_reg_p
    5368            0 :            && !COMPLEX_MODE_P (DECL_MODE (expr))
    5369            0 :            && hard_regno_nregs (REGNO (loc), DECL_MODE (expr)) == 1))
    5370      3648272 :       && known_eq (offset + byte_lowpart_offset (DECL_MODE (expr), mode), 0))
    5371              :     {
    5372          850 :       mode = DECL_MODE (expr);
    5373          850 :       offset = 0;
    5374              :     }
    5375              : 
    5376      1824561 :   HOST_WIDE_INT const_offset;
    5377      1824561 :   if (!track_offset_p (offset, &const_offset))
    5378              :     return false;
    5379              : 
    5380      1824561 :   if (mode_out)
    5381      1824561 :     *mode_out = mode;
    5382      1824561 :   if (offset_out)
    5383       963700 :     *offset_out = const_offset;
    5384              :   return true;
    5385              : }
    5386              : 
    5387              : /* Return the MODE lowpart of LOC, or null if LOC is not something we
    5388              :    want to track.  When returning nonnull, make sure that the attributes
    5389              :    on the returned value are updated.  */
    5390              : 
    5391              : static rtx
    5392      2793549 : var_lowpart (machine_mode mode, rtx loc)
    5393              : {
    5394      2793549 :   unsigned int regno;
    5395              : 
    5396      2793549 :   if (GET_MODE (loc) == mode)
    5397              :     return loc;
    5398              : 
    5399         6903 :   if (!REG_P (loc) && !MEM_P (loc))
    5400              :     return NULL;
    5401              : 
    5402         2316 :   poly_uint64 offset = byte_lowpart_offset (mode, GET_MODE (loc));
    5403              : 
    5404         2316 :   if (MEM_P (loc))
    5405            5 :     return adjust_address_nv (loc, mode, offset);
    5406              : 
    5407         2311 :   poly_uint64 reg_offset = subreg_lowpart_offset (mode, GET_MODE (loc));
    5408         2311 :   regno = REGNO (loc) + subreg_regno_offset (REGNO (loc), GET_MODE (loc),
    5409              :                                              reg_offset, mode);
    5410         2311 :   return gen_rtx_REG_offset (loc, mode, regno, offset);
    5411              : }
    5412              : 
    5413              : /* Carry information about uses and stores while walking rtx.  */
    5414              : 
    5415              : struct count_use_info
    5416              : {
    5417              :   /* The insn where the RTX is.  */
    5418              :   rtx_insn *insn;
    5419              : 
    5420              :   /* The basic block where insn is.  */
    5421              :   basic_block bb;
    5422              : 
    5423              :   /* The array of n_sets sets in the insn, as determined by cselib.  */
    5424              :   struct cselib_set *sets;
    5425              :   int n_sets;
    5426              : 
    5427              :   /* True if we're counting stores, false otherwise.  */
    5428              :   bool store_p;
    5429              : };
    5430              : 
    5431              : /* Find a VALUE corresponding to X.   */
    5432              : 
    5433              : static inline cselib_val *
    5434    187797735 : find_use_val (rtx x, machine_mode mode, struct count_use_info *cui)
    5435              : {
    5436    187797735 :   int i;
    5437              : 
    5438    187797735 :   if (cui->sets)
    5439              :     {
    5440              :       /* This is called after uses are set up and before stores are
    5441              :          processed by cselib, so it's safe to look up srcs, but not
    5442              :          dsts.  So we look up expressions that appear in srcs or in
    5443              :          dest expressions, but we search the sets array for dests of
    5444              :          stores.  */
    5445    187797488 :       if (cui->store_p)
    5446              :         {
    5447              :           /* Some targets represent memset and memcpy patterns
    5448              :              by (set (mem:BLK ...) (reg:[QHSD]I ...)) or
    5449              :              (set (mem:BLK ...) (const_int ...)) or
    5450              :              (set (mem:BLK ...) (mem:BLK ...)).  Don't return anything
    5451              :              in that case, otherwise we end up with mode mismatches.  */
    5452     81383044 :           if (mode == BLKmode && MEM_P (x))
    5453              :             return NULL;
    5454     92352604 :           for (i = 0; i < cui->n_sets; i++)
    5455     87615811 :             if (cui->sets[i].dest == x)
    5456     75826958 :               return cui->sets[i].src_elt;
    5457              :         }
    5458              :       else
    5459    106414444 :         return cselib_lookup (x, mode, 0, VOIDmode);
    5460              :     }
    5461              : 
    5462              :   return NULL;
    5463              : }
    5464              : 
    5465              : /* Replace all registers and addresses in an expression with VALUE
    5466              :    expressions that map back to them, unless the expression is a
    5467              :    register.  If no mapping is or can be performed, returns NULL.  */
    5468              : 
    5469              : static rtx
    5470     54513216 : replace_expr_with_values (rtx loc)
    5471              : {
    5472     54513216 :   if (REG_P (loc) || GET_CODE (loc) == ENTRY_VALUE)
    5473              :     return NULL;
    5474     17838809 :   else if (MEM_P (loc))
    5475              :     {
    5476     17838809 :       cselib_val *addr = cselib_lookup (XEXP (loc, 0),
    5477     17838809 :                                         get_address_mode (loc), 0,
    5478     17838809 :                                         GET_MODE (loc));
    5479     17838809 :       if (addr)
    5480     17838809 :         return replace_equiv_address_nv (loc, addr->val_rtx);
    5481              :       else
    5482              :         return NULL;
    5483              :     }
    5484              :   else
    5485            0 :     return cselib_subst_to_values (loc, VOIDmode);
    5486              : }
    5487              : 
    5488              : /* Return true if X contains a DEBUG_EXPR.  */
    5489              : 
    5490              : static bool
    5491        35528 : rtx_debug_expr_p (const_rtx x)
    5492              : {
    5493        35528 :   subrtx_iterator::array_type array;
    5494       131908 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    5495        96380 :     if (GET_CODE (*iter) == DEBUG_EXPR)
    5496            0 :       return true;
    5497        35528 :   return false;
    5498        35528 : }
    5499              : 
    5500              : /* Determine what kind of micro operation to choose for a USE.  Return
    5501              :    MO_CLOBBER if no micro operation is to be generated.  */
    5502              : 
    5503              : static enum micro_operation_type
    5504    395043082 : use_type (rtx loc, struct count_use_info *cui, machine_mode *modep)
    5505              : {
    5506    395043082 :   tree expr;
    5507              : 
    5508    395043082 :   if (cui && cui->sets)
    5509              :     {
    5510    317496381 :       if (GET_CODE (loc) == VAR_LOCATION)
    5511              :         {
    5512     41003139 :           if (track_expr_p (PAT_VAR_LOCATION_DECL (loc), false))
    5513              :             {
    5514     40433678 :               rtx ploc = PAT_VAR_LOCATION_LOC (loc);
    5515     40433678 :               if (! VAR_LOC_UNKNOWN_P (ploc))
    5516              :                 {
    5517     21965839 :                   cselib_val *val = cselib_lookup (ploc, GET_MODE (loc), 1,
    5518              :                                                    VOIDmode);
    5519              : 
    5520              :                   /* ??? flag_float_store and volatile mems are never
    5521              :                      given values, but we could in theory use them for
    5522              :                      locations.  */
    5523              :                   gcc_assert (val || 1);
    5524              :                 }
    5525              :               return MO_VAL_LOC;
    5526              :             }
    5527              :           else
    5528              :             return MO_CLOBBER;
    5529              :         }
    5530              : 
    5531    276493242 :       if (REG_P (loc) || MEM_P (loc))
    5532              :         {
    5533    115175876 :           if (modep)
    5534    115175876 :             *modep = GET_MODE (loc);
    5535    115175876 :           if (cui->store_p)
    5536              :             {
    5537     43576202 :               if (REG_P (loc)
    5538     43576202 :                   || (find_use_val (loc, GET_MODE (loc), cui)
    5539      8727962 :                       && cselib_lookup (XEXP (loc, 0),
    5540     52304164 :                                         get_address_mode (loc), 0,
    5541      8727962 :                                         GET_MODE (loc))))
    5542              :                 return MO_VAL_SET;
    5543              :             }
    5544              :           else
    5545              :             {
    5546     71599674 :               cselib_val *val = find_use_val (loc, GET_MODE (loc), cui);
    5547              : 
    5548     71599674 :               if (val && !cselib_preserved_value_p (val))
    5549              :                 return MO_VAL_USE;
    5550              :             }
    5551              :         }
    5552              :     }
    5553              : 
    5554    295292428 :   if (REG_P (loc))
    5555              :     {
    5556     96877728 :       gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER);
    5557              : 
    5558     96877728 :       if (loc == cfa_base_rtx)
    5559              :         return MO_CLOBBER;
    5560     75957366 :       expr = REG_EXPR (loc);
    5561              : 
    5562     39848983 :       if (!expr)
    5563              :         return MO_USE_NO_VAR;
    5564     39753201 :       else if (target_for_debug_bind (var_debug_decl (expr)))
    5565              :         return MO_CLOBBER;
    5566     25121016 :       else if (track_loc_p (loc, expr, REG_OFFSET (loc),
    5567              :                             false, modep, NULL))
    5568              :         return MO_USE;
    5569              :       else
    5570     24295685 :         return MO_USE_NO_VAR;
    5571              :     }
    5572    198414700 :   else if (MEM_P (loc))
    5573              :     {
    5574     24567244 :       expr = MEM_EXPR (loc);
    5575              : 
    5576     24567244 :       if (!expr)
    5577              :         return MO_CLOBBER;
    5578     18406218 :       else if (target_for_debug_bind (var_debug_decl (expr)))
    5579              :         return MO_CLOBBER;
    5580     17582293 :       else if (track_loc_p (loc, expr, int_mem_offset (loc),
    5581              :                             false, modep, NULL)
    5582              :                /* Multi-part variables shouldn't refer to one-part
    5583              :                   variable names such as VALUEs (never happens) or
    5584              :                   DEBUG_EXPRs (only happens in the presence of debug
    5585              :                   insns).  */
    5586     17546763 :                && (!MAY_HAVE_DEBUG_BIND_INSNS
    5587        35528 :                    || !rtx_debug_expr_p (XEXP (loc, 0))))
    5588              :         return MO_USE;
    5589              :       else
    5590     17511233 :         return MO_CLOBBER;
    5591              :     }
    5592              : 
    5593              :   return MO_CLOBBER;
    5594              : }
    5595              : 
    5596              : /* Log to OUT information about micro-operation MOPT involving X in
    5597              :    INSN of BB.  */
    5598              : 
    5599              : static inline void
    5600           16 : log_op_type (rtx x, basic_block bb, rtx_insn *insn,
    5601              :              enum micro_operation_type mopt, FILE *out)
    5602              : {
    5603           16 :   fprintf (out, "bb %i op %i insn %i %s ",
    5604           16 :            bb->index, VTI (bb)->mos.length (),
    5605           16 :            INSN_UID (insn), micro_operation_type_name[mopt]);
    5606           16 :   print_inline_rtx (out, x, 2);
    5607           16 :   fputc ('\n', out);
    5608           16 : }
    5609              : 
    5610              : /* Tell whether the CONCAT used to holds a VALUE and its location
    5611              :    needs value resolution, i.e., an attempt of mapping the location
    5612              :    back to other incoming values.  */
    5613              : #define VAL_NEEDS_RESOLUTION(x) \
    5614              :   (RTL_FLAG_CHECK1 ("VAL_NEEDS_RESOLUTION", (x), CONCAT)->volatil)
    5615              : /* Whether the location in the CONCAT is a tracked expression, that
    5616              :    should also be handled like a MO_USE.  */
    5617              : #define VAL_HOLDS_TRACK_EXPR(x) \
    5618              :   (RTL_FLAG_CHECK1 ("VAL_HOLDS_TRACK_EXPR", (x), CONCAT)->used)
    5619              : /* Whether the location in the CONCAT should be handled like a MO_COPY
    5620              :    as well.  */
    5621              : #define VAL_EXPR_IS_COPIED(x) \
    5622              :   (RTL_FLAG_CHECK1 ("VAL_EXPR_IS_COPIED", (x), CONCAT)->jump)
    5623              : /* Whether the location in the CONCAT should be handled like a
    5624              :    MO_CLOBBER as well.  */
    5625              : #define VAL_EXPR_IS_CLOBBERED(x) \
    5626              :   (RTL_FLAG_CHECK1 ("VAL_EXPR_IS_CLOBBERED", (x), CONCAT)->unchanging)
    5627              : 
    5628              : /* All preserved VALUEs.  */
    5629              : static vec<rtx> preserved_values;
    5630              : 
    5631              : /* Ensure VAL is preserved and remember it in a vector for vt_emit_notes.  */
    5632              : 
    5633              : static void
    5634     42995876 : preserve_value (cselib_val *val)
    5635              : {
    5636     42995876 :   cselib_preserve_value (val);
    5637     42995876 :   preserved_values.safe_push (val->val_rtx);
    5638     42995876 : }
    5639              : 
    5640              : /* Helper function for MO_VAL_LOC handling.  Return non-zero if
    5641              :    any rtxes not suitable for CONST use not replaced by VALUEs
    5642              :    are discovered.  */
    5643              : 
    5644              : static bool
    5645        48673 : non_suitable_const (const_rtx x)
    5646              : {
    5647        48673 :   subrtx_iterator::array_type array;
    5648       243365 :   FOR_EACH_SUBRTX (iter, array, x, ALL)
    5649              :     {
    5650       194692 :       const_rtx x = *iter;
    5651       194692 :       switch (GET_CODE (x))
    5652              :         {
    5653              :         case REG:
    5654              :         case DEBUG_EXPR:
    5655              :         case PC:
    5656              :         case SCRATCH:
    5657              :         case ASM_INPUT:
    5658              :         case ASM_OPERANDS:
    5659            0 :           return true;
    5660            0 :         case MEM:
    5661            0 :           if (!MEM_READONLY_P (x))
    5662              :             return true;
    5663              :           break;
    5664              :         default:
    5665              :           break;
    5666              :         }
    5667              :     }
    5668        48673 :   return false;
    5669        48673 : }
    5670              : 
    5671              : /* Add uses (register and memory references) LOC which will be tracked
    5672              :    to VTI (bb)->mos.  */
    5673              : 
    5674              : static void
    5675    269058815 : add_uses (rtx loc, struct count_use_info *cui)
    5676              : {
    5677    269058815 :   machine_mode mode = VOIDmode;
    5678    269058815 :   enum micro_operation_type type = use_type (loc, cui, &mode);
    5679              : 
    5680    269058815 :   if (type != MO_CLOBBER)
    5681              :     {
    5682     77440393 :       basic_block bb = cui->bb;
    5683     77440393 :       micro_operation mo;
    5684              : 
    5685     77440393 :       mo.type = type;
    5686     77440393 :       mo.u.loc = type == MO_USE ? var_lowpart (mode, loc) : loc;
    5687     77440393 :       mo.insn = cui->insn;
    5688              : 
    5689     77440393 :       if (type == MO_VAL_LOC)
    5690              :         {
    5691     40433678 :           rtx oloc = loc;
    5692     40433678 :           rtx vloc = PAT_VAR_LOCATION_LOC (oloc);
    5693     40433678 :           cselib_val *val;
    5694              : 
    5695     40433678 :           gcc_assert (cui->sets);
    5696              : 
    5697     40433678 :           if (MEM_P (vloc)
    5698      1204965 :               && !REG_P (XEXP (vloc, 0))
    5699      1134581 :               && !MEM_P (XEXP (vloc, 0)))
    5700              :             {
    5701      1128638 :               rtx mloc = vloc;
    5702      1128638 :               machine_mode address_mode = get_address_mode (mloc);
    5703      1128638 :               cselib_val *val
    5704      2257276 :                 = cselib_lookup (XEXP (mloc, 0), address_mode, 0,
    5705      1128638 :                                  GET_MODE (mloc));
    5706              : 
    5707      1128638 :               if (val && !cselib_preserved_value_p (val))
    5708       265971 :                 preserve_value (val);
    5709              :             }
    5710              : 
    5711     40433678 :           if (CONSTANT_P (vloc)
    5712     40433678 :               && (GET_CODE (vloc) != CONST || non_suitable_const (vloc)))
    5713              :             /* For constants don't look up any value.  */;
    5714     18467839 :           else if (!VAR_LOC_UNKNOWN_P (vloc) && !unsuitable_loc (vloc)
    5715     56065623 :                    && (val = find_use_val (vloc, GET_MODE (oloc), cui)))
    5716              :             {
    5717     18797317 :               machine_mode mode2;
    5718     18797317 :               enum micro_operation_type type2;
    5719     18797317 :               rtx nloc = NULL;
    5720     18797317 :               bool resolvable = REG_P (vloc) || MEM_P (vloc);
    5721              : 
    5722     18797317 :               if (resolvable)
    5723      6267984 :                 nloc = replace_expr_with_values (vloc);
    5724              : 
    5725      6267984 :               if (nloc)
    5726              :                 {
    5727      1203560 :                   oloc = shallow_copy_rtx (oloc);
    5728      1203560 :                   PAT_VAR_LOCATION_LOC (oloc) = nloc;
    5729              :                 }
    5730              : 
    5731     18797317 :               oloc = gen_rtx_CONCAT (mode, val->val_rtx, oloc);
    5732              : 
    5733     18797317 :               type2 = use_type (vloc, 0, &mode2);
    5734              : 
    5735     18797317 :               gcc_assert (type2 == MO_USE || type2 == MO_USE_NO_VAR
    5736              :                           || type2 == MO_CLOBBER);
    5737              : 
    5738     18797317 :               if (type2 == MO_CLOBBER
    5739     18797317 :                   && !cselib_preserved_value_p (val))
    5740              :                 {
    5741      5179025 :                   VAL_NEEDS_RESOLUTION (oloc) = resolvable;
    5742      5179025 :                   preserve_value (val);
    5743              :                 }
    5744              :             }
    5745     18469414 :           else if (!VAR_LOC_UNKNOWN_P (vloc))
    5746              :             {
    5747         1575 :               oloc = shallow_copy_rtx (oloc);
    5748         1575 :               PAT_VAR_LOCATION_LOC (oloc) = gen_rtx_UNKNOWN_VAR_LOC ();
    5749              :             }
    5750              : 
    5751     40433678 :           mo.u.loc = oloc;
    5752              :         }
    5753     37006715 :       else if (type == MO_VAL_USE)
    5754              :         {
    5755     16015878 :           machine_mode mode2 = VOIDmode;
    5756     16015878 :           enum micro_operation_type type2;
    5757     16015878 :           cselib_val *val = find_use_val (loc, GET_MODE (loc), cui);
    5758     16015878 :           rtx vloc, oloc = loc, nloc;
    5759              : 
    5760     16015878 :           gcc_assert (cui->sets);
    5761              : 
    5762     16015878 :           if (MEM_P (oloc)
    5763      7907287 :               && !REG_P (XEXP (oloc, 0))
    5764      6818196 :               && !MEM_P (XEXP (oloc, 0)))
    5765              :             {
    5766      6816907 :               rtx mloc = oloc;
    5767      6816907 :               machine_mode address_mode = get_address_mode (mloc);
    5768      6816907 :               cselib_val *val
    5769     13633814 :                 = cselib_lookup (XEXP (mloc, 0), address_mode, 0,
    5770      6816907 :                                  GET_MODE (mloc));
    5771              : 
    5772      6816907 :               if (val && !cselib_preserved_value_p (val))
    5773      2623570 :                 preserve_value (val);
    5774              :             }
    5775              : 
    5776     16015878 :           type2 = use_type (loc, 0, &mode2);
    5777              : 
    5778     16015878 :           gcc_assert (type2 == MO_USE || type2 == MO_USE_NO_VAR
    5779              :                       || type2 == MO_CLOBBER);
    5780              : 
    5781     16015878 :           if (type2 == MO_USE)
    5782       252666 :             vloc = var_lowpart (mode2, loc);
    5783              :           else
    5784              :             vloc = oloc;
    5785              : 
    5786              :           /* The loc of a MO_VAL_USE may have two forms:
    5787              : 
    5788              :              (concat val src): val is at src, a value-based
    5789              :              representation.
    5790              : 
    5791              :              (concat (concat val use) src): same as above, with use as
    5792              :              the MO_USE tracked value, if it differs from src.
    5793              : 
    5794              :           */
    5795              : 
    5796     16015878 :           gcc_checking_assert (REG_P (loc) || MEM_P (loc));
    5797     16015878 :           nloc = replace_expr_with_values (loc);
    5798     16015878 :           if (!nloc)
    5799      8108591 :             nloc = oloc;
    5800              : 
    5801     16015878 :           if (vloc != nloc)
    5802      7907530 :             oloc = gen_rtx_CONCAT (mode2, val->val_rtx, vloc);
    5803              :           else
    5804      8108348 :             oloc = val->val_rtx;
    5805              : 
    5806     16015878 :           mo.u.loc = gen_rtx_CONCAT (mode, oloc, nloc);
    5807              : 
    5808     16015878 :           if (type2 == MO_USE)
    5809       252666 :             VAL_HOLDS_TRACK_EXPR (mo.u.loc) = 1;
    5810     16015878 :           if (!cselib_preserved_value_p (val))
    5811              :             {
    5812     16015878 :               VAL_NEEDS_RESOLUTION (mo.u.loc) = 1;
    5813     16015878 :               preserve_value (val);
    5814              :             }
    5815              :         }
    5816              :       else
    5817     20990837 :         gcc_assert (type == MO_USE || type == MO_USE_NO_VAR);
    5818              : 
    5819     77440393 :       if (dump_file && (dump_flags & TDF_DETAILS))
    5820            4 :         log_op_type (mo.u.loc, cui->bb, cui->insn, mo.type, dump_file);
    5821     77440393 :       VTI (bb)->mos.safe_push (mo);
    5822              :     }
    5823    269058815 : }
    5824              : 
    5825              : /* Helper function for finding all uses of REG/MEM in X in insn INSN.  */
    5826              : 
    5827              : static void
    5828     97123640 : add_uses_1 (rtx *x, void *cui)
    5829              : {
    5830     97123640 :   subrtx_var_iterator::array_type array;
    5831    366182455 :   FOR_EACH_SUBRTX_VAR (iter, array, *x, NONCONST)
    5832    269058815 :     add_uses (*iter, (struct count_use_info *) cui);
    5833     97123640 : }
    5834              : 
    5835              : /* This is the value used during expansion of locations.  We want it
    5836              :    to be unbounded, so that variables expanded deep in a recursion
    5837              :    nest are fully evaluated, so that their values are cached
    5838              :    correctly.  We avoid recursion cycles through other means, and we
    5839              :    don't unshare RTL, so excess complexity is not a problem.  */
    5840              : #define EXPR_DEPTH (INT_MAX)
    5841              : /* We use this to keep too-complex expressions from being emitted as
    5842              :    location notes, and then to debug information.  Users can trade
    5843              :    compile time for ridiculously complex expressions, although they're
    5844              :    seldom useful, and they may often have to be discarded as not
    5845              :    representable anyway.  */
    5846              : #define EXPR_USE_DEPTH (param_max_vartrack_expr_depth)
    5847              : 
    5848              : /* Attempt to reverse the EXPR operation in the debug info and record
    5849              :    it in the cselib table.  Say for reg1 = reg2 + 6 even when reg2 is
    5850              :    no longer live we can express its value as VAL - 6.  */
    5851              : 
    5852              : static void
    5853     32229354 : reverse_op (rtx val, const_rtx expr, rtx_insn *insn)
    5854              : {
    5855     32229354 :   rtx src, arg, ret;
    5856     32229354 :   cselib_val *v;
    5857     32229354 :   struct elt_loc_list *l;
    5858     32229354 :   enum rtx_code code;
    5859     32229354 :   int count;
    5860              : 
    5861     32229354 :   if (GET_CODE (expr) != SET)
    5862              :     return;
    5863              : 
    5864     32229354 :   if (!REG_P (SET_DEST (expr)) || GET_MODE (val) != GET_MODE (SET_DEST (expr)))
    5865              :     return;
    5866              : 
    5867     23483796 :   src = SET_SRC (expr);
    5868     23483796 :   switch (GET_CODE (src))
    5869              :     {
    5870      4316691 :     case PLUS:
    5871      4316691 :     case MINUS:
    5872      4316691 :     case XOR:
    5873      4316691 :     case NOT:
    5874      4316691 :     case NEG:
    5875      4316691 :       if (!REG_P (XEXP (src, 0)))
    5876              :         return;
    5877              :       break;
    5878       280293 :     case SIGN_EXTEND:
    5879       280293 :     case ZERO_EXTEND:
    5880       280293 :       if (!REG_P (XEXP (src, 0)) && !MEM_P (XEXP (src, 0)))
    5881              :         return;
    5882              :       break;
    5883              :     default:
    5884              :       return;
    5885              :     }
    5886              : 
    5887      4345819 :   if (!SCALAR_INT_MODE_P (GET_MODE (src)) || XEXP (src, 0) == cfa_base_rtx)
    5888              :     return;
    5889              : 
    5890      2970615 :   v = cselib_lookup (XEXP (src, 0), GET_MODE (XEXP (src, 0)), 0, VOIDmode);
    5891      2970615 :   if (!v || !cselib_preserved_value_p (v))
    5892              :     return;
    5893              : 
    5894              :   /* Use canonical V to avoid creating multiple redundant expressions
    5895              :      for different VALUES equivalent to V.  */
    5896      2970613 :   v = canonical_cselib_val (v);
    5897              : 
    5898              :   /* Adding a reverse op isn't useful if V already has an always valid
    5899              :      location.  Ignore ENTRY_VALUE, while it is always constant, we should
    5900              :      prefer non-ENTRY_VALUE locations whenever possible.  */
    5901      8179898 :   for (l = v->locs, count = 0; l; l = l->next, count++)
    5902      5243272 :     if (CONSTANT_P (l->loc)
    5903      5243272 :         && (GET_CODE (l->loc) != CONST || !references_value_p (l->loc)))
    5904              :       return;
    5905              :     /* Avoid creating too large locs lists.  */
    5906      5210239 :     else if (count == param_max_vartrack_reverse_op_size)
    5907              :       return;
    5908              : 
    5909      2936626 :   switch (GET_CODE (src))
    5910              :     {
    5911        48732 :     case NOT:
    5912        48732 :     case NEG:
    5913        48732 :       if (GET_MODE (v->val_rtx) != GET_MODE (val))
    5914              :         return;
    5915        48732 :       ret = gen_rtx_fmt_e (GET_CODE (src), GET_MODE (val), val);
    5916        48732 :       break;
    5917       245523 :     case SIGN_EXTEND:
    5918       245523 :     case ZERO_EXTEND:
    5919       245523 :       ret = gen_lowpart_SUBREG (GET_MODE (v->val_rtx), val);
    5920       245523 :       break;
    5921        46685 :     case XOR:
    5922        46685 :       code = XOR;
    5923        46685 :       goto binary;
    5924      2348710 :     case PLUS:
    5925      2348710 :       code = MINUS;
    5926      2348710 :       goto binary;
    5927       246976 :     case MINUS:
    5928       246976 :       code = PLUS;
    5929       246976 :       goto binary;
    5930      2642371 :     binary:
    5931      2642371 :       if (GET_MODE (v->val_rtx) != GET_MODE (val))
    5932              :         return;
    5933      2642371 :       arg = XEXP (src, 1);
    5934      2642371 :       if (!CONST_INT_P (arg) && GET_CODE (arg) != SYMBOL_REF)
    5935              :         {
    5936       723327 :           arg = cselib_expand_value_rtx (arg, scratch_regs, 5);
    5937       723327 :           if (arg == NULL_RTX)
    5938              :             return;
    5939       723327 :           if (!CONST_INT_P (arg) && GET_CODE (arg) != SYMBOL_REF)
    5940              :             return;
    5941              :         }
    5942      1924931 :       ret = simplify_gen_binary (code, GET_MODE (val), val, arg);
    5943      1924931 :       break;
    5944            0 :     default:
    5945            0 :       gcc_unreachable ();
    5946              :     }
    5947              : 
    5948      2219186 :   cselib_add_permanent_equiv (v, ret, insn);
    5949              : }
    5950              : 
    5951              : /* Add stores (register and memory references) LOC which will be tracked
    5952              :    to VTI (bb)->mos.  EXPR is the RTL expression containing the store.
    5953              :    CUIP->insn is instruction which the LOC is part of.  */
    5954              : 
    5955              : static void
    5956     48439154 : add_stores (rtx loc, const_rtx expr, void *cuip)
    5957              : {
    5958     48439154 :   machine_mode mode = VOIDmode, mode2;
    5959     48439154 :   struct count_use_info *cui = (struct count_use_info *)cuip;
    5960     48439154 :   basic_block bb = cui->bb;
    5961     48439154 :   micro_operation mo;
    5962     48439154 :   rtx oloc = loc, nloc, src = NULL;
    5963     48439154 :   enum micro_operation_type type = use_type (loc, cui, &mode);
    5964     48439154 :   bool track_p = false;
    5965     48439154 :   cselib_val *v;
    5966     48439154 :   bool resolve, preserve;
    5967              : 
    5968     48439154 :   if (type == MO_CLOBBER)
    5969     10021632 :     return;
    5970              : 
    5971     42731983 :   mode2 = mode;
    5972              : 
    5973     42731983 :   if (REG_P (loc))
    5974              :     {
    5975     34004018 :       gcc_assert (loc != cfa_base_rtx);
    5976      4723439 :       if ((GET_CODE (expr) == CLOBBER && type != MO_VAL_SET)
    5977     34003953 :           || !(track_p = use_type (loc, NULL, &mode2) == MO_USE)
    5978     34182522 :           || GET_CODE (expr) == CLOBBER)
    5979              :         {
    5980     33826104 :           mo.type = MO_CLOBBER;
    5981     33826104 :           mo.u.loc = loc;
    5982     33826104 :           if (GET_CODE (expr) == SET
    5983     29102665 :               && (SET_DEST (expr) == loc
    5984        30590 :                   || (GET_CODE (SET_DEST (expr)) == STRICT_LOW_PART
    5985        17497 :                       && XEXP (SET_DEST (expr), 0) == loc))
    5986     29089572 :               && !unsuitable_loc (SET_SRC (expr))
    5987     62905231 :               && find_use_val (loc, mode, cui))
    5988              :             {
    5989     27711988 :               gcc_checking_assert (type == MO_VAL_SET);
    5990     27711988 :               mo.u.loc = gen_rtx_SET (loc, SET_SRC (expr));
    5991              :             }
    5992              :         }
    5993              :       else
    5994              :         {
    5995       177914 :           if (GET_CODE (expr) == SET
    5996       177914 :               && SET_DEST (expr) == loc
    5997       177760 :               && GET_CODE (SET_SRC (expr)) != ASM_OPERANDS)
    5998       177758 :             src = var_lowpart (mode2, SET_SRC (expr));
    5999       177914 :           loc = var_lowpart (mode2, loc);
    6000              : 
    6001       177914 :           if (src == NULL)
    6002              :             {
    6003         4732 :               mo.type = MO_SET;
    6004         4732 :               mo.u.loc = loc;
    6005              :             }
    6006              :           else
    6007              :             {
    6008       173182 :               rtx xexpr = gen_rtx_SET (loc, src);
    6009       173182 :               if (same_variable_part_p (src, REG_EXPR (loc), REG_OFFSET (loc)))
    6010              :                 {
    6011              :                   /* If this is an instruction copying (part of) a parameter
    6012              :                      passed by invisible reference to its register location,
    6013              :                      pretend it's a SET so that the initial memory location
    6014              :                      is discarded, as the parameter register can be reused
    6015              :                      for other purposes and we do not track locations based
    6016              :                      on generic registers.  */
    6017        66253 :                   if (MEM_P (src)
    6018         9940 :                       && REG_EXPR (loc)
    6019         9940 :                       && TREE_CODE (REG_EXPR (loc)) == PARM_DECL
    6020         9938 :                       && DECL_MODE (REG_EXPR (loc)) != BLKmode
    6021         9938 :                       && MEM_P (DECL_INCOMING_RTL (REG_EXPR (loc)))
    6022        66253 :                       && XEXP (DECL_INCOMING_RTL (REG_EXPR (loc)), 0)
    6023         9608 :                          != arg_pointer_rtx)
    6024         6248 :                     mo.type = MO_SET;
    6025              :                   else
    6026        60005 :                     mo.type = MO_COPY;
    6027              :                 }
    6028              :               else
    6029       106929 :                 mo.type = MO_SET;
    6030       173182 :               mo.u.loc = xexpr;
    6031              :             }
    6032              :         }
    6033     34004018 :       mo.insn = cui->insn;
    6034              :     }
    6035      8727965 :   else if (MEM_P (loc)
    6036      8727965 :            && ((track_p = use_type (loc, NULL, &mode2) == MO_USE)
    6037      8723348 :                || cui->sets))
    6038              :     {
    6039      8727965 :       if (MEM_P (loc) && type == MO_VAL_SET
    6040      8727962 :           && !REG_P (XEXP (loc, 0))
    6041      8105185 :           && !MEM_P (XEXP (loc, 0)))
    6042              :         {
    6043      8105185 :           rtx mloc = loc;
    6044      8105185 :           machine_mode address_mode = get_address_mode (mloc);
    6045     16210370 :           cselib_val *val = cselib_lookup (XEXP (mloc, 0),
    6046              :                                            address_mode, 0,
    6047      8105185 :                                            GET_MODE (mloc));
    6048              : 
    6049      8105185 :           if (val && !cselib_preserved_value_p (val))
    6050      3297652 :             preserve_value (val);
    6051              :         }
    6052              : 
    6053      8727965 :       if (GET_CODE (expr) == CLOBBER || !track_p)
    6054              :         {
    6055      8723351 :           mo.type = MO_CLOBBER;
    6056      8723351 :           mo.u.loc = track_p ? var_lowpart (mode2, loc) : loc;
    6057              :         }
    6058              :       else
    6059              :         {
    6060         4614 :           if (GET_CODE (expr) == SET
    6061         4614 :               && SET_DEST (expr) == loc
    6062         4614 :               && GET_CODE (SET_SRC (expr)) != ASM_OPERANDS)
    6063         4614 :             src = var_lowpart (mode2, SET_SRC (expr));
    6064         4614 :           loc = var_lowpart (mode2, loc);
    6065              : 
    6066         4614 :           if (src == NULL)
    6067              :             {
    6068           11 :               mo.type = MO_SET;
    6069           11 :               mo.u.loc = loc;
    6070              :             }
    6071              :           else
    6072              :             {
    6073         4603 :               rtx xexpr = gen_rtx_SET (loc, src);
    6074         4603 :               if (same_variable_part_p (SET_SRC (xexpr),
    6075         4603 :                                         MEM_EXPR (loc),
    6076         4603 :                                         int_mem_offset (loc)))
    6077              :                 mo.type = MO_COPY;
    6078              :               else
    6079         1758 :                 mo.type = MO_SET;
    6080         4603 :               mo.u.loc = xexpr;
    6081              :             }
    6082              :         }
    6083      8727965 :       mo.insn = cui->insn;
    6084              :     }
    6085              :   else
    6086              :     return;
    6087              : 
    6088     42731983 :   if (type != MO_VAL_SET)
    6089          346 :     goto log_and_return;
    6090              : 
    6091     42731637 :   v = find_use_val (oloc, mode, cui);
    6092              : 
    6093     42731637 :   if (!v)
    6094      6110138 :     goto log_and_return;
    6095              : 
    6096     36621499 :   resolve = preserve = !cselib_preserved_value_p (v);
    6097              : 
    6098              :   /* We cannot track values for multiple-part variables, so we track only
    6099              :      locations for tracked record parameters.  */
    6100     36621499 :   if (track_p
    6101       182460 :       && REG_P (loc)
    6102       177846 :       && REG_EXPR (loc)
    6103     36799345 :       && tracked_record_parameter_p (REG_EXPR (loc)))
    6104              :     {
    6105              :       /* Although we don't use the value here, it could be used later by the
    6106              :          mere virtue of its existence as the operand of the reverse operation
    6107              :          that gave rise to it (typically extension/truncation).  Make sure it
    6108              :          is preserved as required by vt_expand_var_loc_chain.  */
    6109        77684 :       if (preserve)
    6110         1273 :         preserve_value (v);
    6111        77684 :       goto log_and_return;
    6112              :     }
    6113              : 
    6114     36543815 :   if (loc == stack_pointer_rtx
    6115      5220834 :       && (maybe_ne (hard_frame_pointer_adjustment, -1)
    6116      4375373 :           || (!frame_pointer_needed && !ACCUMULATE_OUTGOING_ARGS))
    6117     41703734 :       && preserve)
    6118      1922607 :     cselib_set_value_sp_based (v);
    6119              : 
    6120              :   /* Don't record MO_VAL_SET for VALUEs that can be described using
    6121              :      cfa_base_rtx or cfa_base_rtx + CONST_INT, cselib already knows
    6122              :      all the needed equivalences and they shouldn't change depending
    6123              :      on which register holds that VALUE in some instruction.  */
    6124     36543815 :   if (!frame_pointer_needed
    6125     31533685 :       && cfa_base_rtx
    6126     31531370 :       && cselib_sp_derived_value_p (v)
    6127     42211958 :       && loc == stack_pointer_rtx)
    6128              :     {
    6129      4314461 :       if (preserve)
    6130      1380695 :         preserve_value (v);
    6131              :       return;
    6132              :     }
    6133              : 
    6134     32229354 :   nloc = replace_expr_with_values (oloc);
    6135     32229354 :   if (nloc)
    6136      8727962 :     oloc = nloc;
    6137              : 
    6138     32229354 :   if (GET_CODE (PATTERN (cui->insn)) == COND_EXEC)
    6139              :     {
    6140            0 :       cselib_val *oval = cselib_lookup (oloc, GET_MODE (oloc), 0, VOIDmode);
    6141              : 
    6142            0 :       if (oval == v)
    6143              :         return;
    6144            0 :       gcc_assert (REG_P (oloc) || MEM_P (oloc));
    6145              : 
    6146            0 :       if (oval && !cselib_preserved_value_p (oval))
    6147              :         {
    6148            0 :           micro_operation moa;
    6149              : 
    6150            0 :           preserve_value (oval);
    6151              : 
    6152            0 :           moa.type = MO_VAL_USE;
    6153            0 :           moa.u.loc = gen_rtx_CONCAT (mode, oval->val_rtx, oloc);
    6154            0 :           VAL_NEEDS_RESOLUTION (moa.u.loc) = 1;
    6155            0 :           moa.insn = cui->insn;
    6156              : 
    6157            0 :           if (dump_file && (dump_flags & TDF_DETAILS))
    6158            0 :             log_op_type (moa.u.loc, cui->bb, cui->insn,
    6159              :                          moa.type, dump_file);
    6160            0 :           VTI (bb)->mos.safe_push (moa);
    6161              :         }
    6162              : 
    6163              :       resolve = false;
    6164              :     }
    6165     32229354 :   else if (resolve && GET_CODE (mo.u.loc) == SET)
    6166              :     {
    6167     10450406 :       if (REG_P (SET_SRC (expr)) || MEM_P (SET_SRC (expr)))
    6168            0 :         nloc = replace_expr_with_values (SET_SRC (expr));
    6169              :       else
    6170              :         nloc = NULL_RTX;
    6171              : 
    6172              :       /* Avoid the mode mismatch between oexpr and expr.  */
    6173     10450406 :       if (!nloc && mode != mode2)
    6174              :         {
    6175            0 :           nloc = SET_SRC (expr);
    6176            0 :           gcc_assert (oloc == SET_DEST (expr));
    6177              :         }
    6178              : 
    6179     10450406 :       if (nloc && nloc != SET_SRC (mo.u.loc))
    6180            0 :         oloc = gen_rtx_SET (oloc, nloc);
    6181              :       else
    6182              :         {
    6183     10450406 :           if (oloc == SET_DEST (mo.u.loc))
    6184              :             /* No point in duplicating.  */
    6185     10450404 :             oloc = mo.u.loc;
    6186     10450406 :           if (!REG_P (SET_SRC (mo.u.loc)))
    6187     10450406 :             resolve = false;
    6188              :         }
    6189              :     }
    6190              :   else if (!resolve)
    6191              :     {
    6192     20876462 :       if (GET_CODE (mo.u.loc) == SET
    6193     13047404 :           && oloc == SET_DEST (mo.u.loc))
    6194              :         /* No point in duplicating.  */
    6195     13042801 :         oloc = mo.u.loc;
    6196              :     }
    6197              :   else
    6198              :     resolve = false;
    6199              : 
    6200     32229354 :   loc = gen_rtx_CONCAT (mode, v->val_rtx, oloc);
    6201              : 
    6202     32229354 :   if (mo.u.loc != oloc)
    6203      8728134 :     loc = gen_rtx_CONCAT (GET_MODE (mo.u.loc), loc, mo.u.loc);
    6204              : 
    6205              :   /* The loc of a MO_VAL_SET may have various forms:
    6206              : 
    6207              :      (concat val dst): dst now holds val
    6208              : 
    6209              :      (concat val (set dst src)): dst now holds val, copied from src
    6210              : 
    6211              :      (concat (concat val dstv) dst): dst now holds val; dstv is dst
    6212              :      after replacing mems and non-top-level regs with values.
    6213              : 
    6214              :      (concat (concat val dstv) (set dst src)): dst now holds val,
    6215              :      copied from src.  dstv is a value-based representation of dst, if
    6216              :      it differs from dst.  If resolution is needed, src is a REG, and
    6217              :      its mode is the same as that of val.
    6218              : 
    6219              :      (concat (concat val (set dstv srcv)) (set dst src)): src
    6220              :      copied to dst, holding val.  dstv and srcv are value-based
    6221              :      representations of dst and src, respectively.
    6222              : 
    6223              :   */
    6224              : 
    6225     32229354 :   if (GET_CODE (PATTERN (cui->insn)) != COND_EXEC)
    6226     32229354 :     reverse_op (v->val_rtx, expr, cui->insn);
    6227              : 
    6228     32229354 :   mo.u.loc = loc;
    6229              : 
    6230     32229354 :   if (track_p)
    6231       104776 :     VAL_HOLDS_TRACK_EXPR (loc) = 1;
    6232     32229354 :   if (preserve)
    6233              :     {
    6234     11352892 :       VAL_NEEDS_RESOLUTION (loc) = resolve;
    6235     11352892 :       preserve_value (v);
    6236              :     }
    6237     32229354 :   if (mo.type == MO_CLOBBER)
    6238     32124578 :     VAL_EXPR_IS_CLOBBERED (loc) = 1;
    6239     32229354 :   if (mo.type == MO_COPY)
    6240        19752 :     VAL_EXPR_IS_COPIED (loc) = 1;
    6241              : 
    6242     32229354 :   mo.type = MO_VAL_SET;
    6243              : 
    6244     38417522 :  log_and_return:
    6245     38417522 :   if (dump_file && (dump_flags & TDF_DETAILS))
    6246            8 :     log_op_type (mo.u.loc, cui->bb, cui->insn, mo.type, dump_file);
    6247     38417522 :   VTI (bb)->mos.safe_push (mo);
    6248              : }
    6249              : 
    6250              : /* Arguments to the call.  */
    6251              : static rtx call_arguments;
    6252              : 
    6253              : /* Compute call_arguments.  */
    6254              : 
    6255              : static void
    6256      3280615 : prepare_call_arguments (basic_block bb, rtx_insn *insn)
    6257              : {
    6258      3280615 :   rtx link, x, call;
    6259      3280615 :   rtx prev, cur, next;
    6260      3280615 :   rtx this_arg = NULL_RTX;
    6261      3280615 :   tree type = NULL_TREE, t, fndecl = NULL_TREE;
    6262      3280615 :   tree obj_type_ref = NULL_TREE;
    6263      3280615 :   CUMULATIVE_ARGS args_so_far_v;
    6264      3280615 :   cumulative_args_t args_so_far;
    6265              : 
    6266      3280615 :   memset (&args_so_far_v, 0, sizeof (args_so_far_v));
    6267      3280615 :   args_so_far = pack_cumulative_args (&args_so_far_v);
    6268      3280615 :   call = get_call_rtx_from (insn);
    6269      3280615 :   if (call)
    6270              :     {
    6271      3280615 :       if (GET_CODE (XEXP (XEXP (call, 0), 0)) == SYMBOL_REF)
    6272              :         {
    6273      3153392 :           rtx symbol = XEXP (XEXP (call, 0), 0);
    6274      3153392 :           if (SYMBOL_REF_DECL (symbol))
    6275              :             fndecl = SYMBOL_REF_DECL (symbol);
    6276              :         }
    6277      3280615 :       if (fndecl == NULL_TREE && MEM_P (XEXP (call, 0)))
    6278       603098 :         fndecl = MEM_EXPR (XEXP (call, 0));
    6279       361769 :       if (fndecl
    6280      3039286 :           && TREE_CODE (TREE_TYPE (fndecl)) != FUNCTION_TYPE
    6281       913368 :           && TREE_CODE (TREE_TYPE (fndecl)) != METHOD_TYPE)
    6282              :         fndecl = NULL_TREE;
    6283      3280612 :       if (fndecl && TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
    6284      2983473 :         type = TREE_TYPE (fndecl);
    6285      3280615 :       if (fndecl && TREE_CODE (fndecl) != FUNCTION_DECL)
    6286              :         {
    6287       120440 :           if (INDIRECT_REF_P (fndecl)
    6288       120440 :               && TREE_CODE (TREE_OPERAND (fndecl, 0)) == OBJ_TYPE_REF)
    6289            0 :             obj_type_ref = TREE_OPERAND (fndecl, 0);
    6290              :           fndecl = NULL_TREE;
    6291              :         }
    6292      3280615 :       if (type)
    6293              :         {
    6294      8426920 :           for (t = TYPE_ARG_TYPES (type); t && t != void_list_node;
    6295      5443447 :                t = TREE_CHAIN (t))
    6296      5462579 :             if (TREE_CODE (TREE_VALUE (t)) == REFERENCE_TYPE
    6297      5462579 :                 && INTEGRAL_TYPE_P (TREE_TYPE (TREE_VALUE (t))))
    6298              :               break;
    6299      2983473 :           if ((t == NULL || t == void_list_node) && obj_type_ref == NULL_TREE)
    6300              :             type = NULL;
    6301              :           else
    6302              :             {
    6303        19132 :               int nargs ATTRIBUTE_UNUSED = list_length (TYPE_ARG_TYPES (type));
    6304        19132 :               link = CALL_INSN_FUNCTION_USAGE (insn);
    6305              : #ifndef PCC_STATIC_STRUCT_RETURN
    6306        19132 :               if (aggregate_value_p (TREE_TYPE (type), type)
    6307        19132 :                   && targetm.calls.struct_value_rtx (type, 0) == 0)
    6308              :                 {
    6309          815 :                   tree struct_addr = build_pointer_type (TREE_TYPE (type));
    6310          815 :                   function_arg_info arg (struct_addr, /*named=*/true);
    6311          815 :                   rtx reg;
    6312          815 :                   INIT_CUMULATIVE_ARGS (args_so_far_v, type, NULL_RTX, fndecl,
    6313              :                                         nargs + 1);
    6314          815 :                   reg = targetm.calls.function_arg (args_so_far, arg);
    6315          815 :                   targetm.calls.function_arg_advance (args_so_far, arg);
    6316          815 :                   if (reg == NULL_RTX)
    6317              :                     {
    6318          526 :                       for (; link; link = XEXP (link, 1))
    6319          526 :                         if (GET_CODE (XEXP (link, 0)) == USE
    6320          526 :                             && MEM_P (XEXP (XEXP (link, 0), 0)))
    6321              :                           {
    6322          314 :                             link = XEXP (link, 1);
    6323          314 :                             break;
    6324              :                           }
    6325              :                     }
    6326              :                 }
    6327              :               else
    6328              : #endif
    6329        18317 :                 INIT_CUMULATIVE_ARGS (args_so_far_v, type, NULL_RTX, fndecl,
    6330              :                                       nargs);
    6331        19132 :               if (obj_type_ref && TYPE_ARG_TYPES (type) != void_list_node)
    6332              :                 {
    6333            0 :                   t = TYPE_ARG_TYPES (type);
    6334            0 :                   function_arg_info arg (TREE_VALUE (t), /*named=*/true);
    6335            0 :                   this_arg = targetm.calls.function_arg (args_so_far, arg);
    6336            0 :                   if (this_arg && !REG_P (this_arg))
    6337              :                     this_arg = NULL_RTX;
    6338              :                   else if (this_arg == NULL_RTX)
    6339              :                     {
    6340            0 :                       for (; link; link = XEXP (link, 1))
    6341            0 :                         if (GET_CODE (XEXP (link, 0)) == USE
    6342            0 :                             && MEM_P (XEXP (XEXP (link, 0), 0)))
    6343              :                           {
    6344              :                             this_arg = XEXP (XEXP (link, 0), 0);
    6345              :                             break;
    6346              :                           }
    6347              :                     }
    6348              :                 }
    6349              :             }
    6350              :         }
    6351              :     }
    6352        19132 :   t = type ? TYPE_ARG_TYPES (type) : NULL_TREE;
    6353              : 
    6354      9227220 :   for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
    6355      5946605 :     if (GET_CODE (XEXP (link, 0)) == USE)
    6356              :       {
    6357      5895351 :         rtx item = NULL_RTX;
    6358      5895351 :         x = XEXP (XEXP (link, 0), 0);
    6359      5895351 :         if (GET_MODE (link) == VOIDmode
    6360      4913889 :             || GET_MODE (link) == BLKmode
    6361      4185049 :             || (GET_MODE (link) != GET_MODE (x)
    6362       112844 :                 && ((GET_MODE_CLASS (GET_MODE (link)) != MODE_INT
    6363       112844 :                      && GET_MODE_CLASS (GET_MODE (link)) != MODE_PARTIAL_INT)
    6364       112844 :                     || (GET_MODE_CLASS (GET_MODE (x)) != MODE_INT
    6365       112844 :                         && GET_MODE_CLASS (GET_MODE (x)) != MODE_PARTIAL_INT))))
    6366              :           /* Can't do anything for these, if the original type mode
    6367              :              isn't known or can't be converted.  */;
    6368      4185049 :         else if (REG_P (x))
    6369              :           {
    6370      4175981 :             cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode);
    6371      4175981 :             scalar_int_mode mode;
    6372      4175981 :             if (val && cselib_preserved_value_p (val))
    6373      3797355 :               item = val->val_rtx;
    6374       378626 :             else if (is_a <scalar_int_mode> (GET_MODE (x), &mode))
    6375              :               {
    6376       374655 :                 opt_scalar_int_mode mode_iter;
    6377       398954 :                 FOR_EACH_WIDER_MODE (mode_iter, mode)
    6378              :                   {
    6379       398954 :                     mode = mode_iter.require ();
    6380       800919 :                     if (GET_MODE_BITSIZE (mode) > BITS_PER_WORD)
    6381              :                       break;
    6382              : 
    6383        87531 :                     rtx reg = simplify_subreg (mode, x, GET_MODE (x), 0);
    6384        87531 :                     if (reg == NULL_RTX || !REG_P (reg))
    6385            0 :                       continue;
    6386        87531 :                     val = cselib_lookup (reg, mode, 0, VOIDmode);
    6387        87531 :                     if (val && cselib_preserved_value_p (val))
    6388              :                       {
    6389        63232 :                         item = val->val_rtx;
    6390        63232 :                         break;
    6391              :                       }
    6392              :                   }
    6393              :               }
    6394              :           }
    6395         9068 :         else if (MEM_P (x))
    6396              :           {
    6397         9068 :             rtx mem = x;
    6398         9068 :             cselib_val *val;
    6399              : 
    6400         9068 :             if (!frame_pointer_needed)
    6401              :               {
    6402         8617 :                 class adjust_mem_data amd;
    6403         8617 :                 amd.mem_mode = VOIDmode;
    6404         8617 :                 amd.stack_adjust = -VTI (bb)->out.stack_adjust;
    6405         8617 :                 amd.store = true;
    6406         8617 :                 mem = simplify_replace_fn_rtx (mem, NULL_RTX, adjust_mems,
    6407              :                                                &amd);
    6408         8617 :                 gcc_assert (amd.side_effects.is_empty ());
    6409         8617 :               }
    6410         9068 :             val = cselib_lookup (mem, GET_MODE (mem), 0, VOIDmode);
    6411         9068 :             if (val && cselib_preserved_value_p (val))
    6412         3251 :               item = val->val_rtx;
    6413         5817 :             else if (GET_MODE_CLASS (GET_MODE (mem)) != MODE_INT
    6414         5817 :                      && GET_MODE_CLASS (GET_MODE (mem)) != MODE_PARTIAL_INT)
    6415              :               {
    6416              :                 /* For non-integer stack argument see also if they weren't
    6417              :                    initialized by integers.  */
    6418          258 :                 scalar_int_mode imode;
    6419          258 :                 if (int_mode_for_mode (GET_MODE (mem)).exists (&imode)
    6420          223 :                     && imode != GET_MODE (mem))
    6421              :                   {
    6422          223 :                     val = cselib_lookup (adjust_address_nv (mem, imode, 0),
    6423              :                                          imode, 0, VOIDmode);
    6424          223 :                     if (val && cselib_preserved_value_p (val))
    6425            0 :                       item = lowpart_subreg (GET_MODE (x), val->val_rtx,
    6426              :                                              imode);
    6427              :                   }
    6428              :               }
    6429              :           }
    6430      4175296 :         if (item)
    6431              :           {
    6432      3863838 :             rtx x2 = x;
    6433      3863838 :             if (GET_MODE (item) != GET_MODE (link))
    6434       137956 :               item = lowpart_subreg (GET_MODE (link), item, GET_MODE (item));
    6435      3863838 :             if (GET_MODE (x2) != GET_MODE (link))
    6436       106624 :               x2 = lowpart_subreg (GET_MODE (link), x2, GET_MODE (x2));
    6437      3863838 :             item = gen_rtx_CONCAT (GET_MODE (link), x2, item);
    6438      3863838 :             call_arguments
    6439      3863838 :               = gen_rtx_EXPR_LIST (VOIDmode, item, call_arguments);
    6440              :           }
    6441      5895351 :         if (t && t != void_list_node)
    6442              :           {
    6443        66689 :             rtx reg;
    6444        66689 :             function_arg_info arg (TREE_VALUE (t), /*named=*/true);
    6445        66689 :             apply_pass_by_reference_rules (&args_so_far_v, arg);
    6446        66689 :             reg = targetm.calls.function_arg (args_so_far, arg);
    6447        66689 :             if (TREE_CODE (arg.type) == REFERENCE_TYPE
    6448        32906 :                 && INTEGRAL_TYPE_P (TREE_TYPE (arg.type))
    6449        23258 :                 && reg
    6450        20364 :                 && REG_P (reg)
    6451        20364 :                 && GET_MODE (reg) == arg.mode
    6452        20364 :                 && (GET_MODE_CLASS (arg.mode) == MODE_INT
    6453        20364 :                     || GET_MODE_CLASS (arg.mode) == MODE_PARTIAL_INT)
    6454        20364 :                 && REG_P (x)
    6455        20344 :                 && REGNO (x) == REGNO (reg)
    6456        19456 :                 && GET_MODE (x) == arg.mode
    6457        86145 :                 && item)
    6458              :               {
    6459        18939 :                 machine_mode indmode
    6460        18939 :                   = TYPE_MODE (TREE_TYPE (arg.type));
    6461        18939 :                 rtx mem = gen_rtx_MEM (indmode, x);
    6462        18939 :                 cselib_val *val = cselib_lookup (mem, indmode, 0, VOIDmode);
    6463        18939 :                 if (val && cselib_preserved_value_p (val))
    6464              :                   {
    6465         8155 :                     item = gen_rtx_CONCAT (indmode, mem, val->val_rtx);
    6466         8155 :                     call_arguments = gen_rtx_EXPR_LIST (VOIDmode, item,
    6467              :                                                         call_arguments);
    6468              :                   }
    6469              :                 else
    6470              :                   {
    6471        10784 :                     struct elt_loc_list *l;
    6472        10784 :                     tree initial;
    6473              : 
    6474              :                     /* Try harder, when passing address of a constant
    6475              :                        pool integer it can be easily read back.  */
    6476        10784 :                     item = XEXP (item, 1);
    6477        10784 :                     if (GET_CODE (item) == SUBREG)
    6478            0 :                       item = SUBREG_REG (item);
    6479        10784 :                     gcc_assert (GET_CODE (item) == VALUE);
    6480        10784 :                     val = CSELIB_VAL_PTR (item);
    6481        31138 :                     for (l = val->locs; l; l = l->next)
    6482        23376 :                       if (GET_CODE (l->loc) == SYMBOL_REF
    6483         3135 :                           && TREE_CONSTANT_POOL_ADDRESS_P (l->loc)
    6484         3022 :                           && SYMBOL_REF_DECL (l->loc)
    6485        26398 :                           && DECL_INITIAL (SYMBOL_REF_DECL (l->loc)))
    6486              :                         {
    6487         3022 :                           initial = DECL_INITIAL (SYMBOL_REF_DECL (l->loc));
    6488         3022 :                           if (tree_fits_shwi_p (initial))
    6489              :                             {
    6490         3022 :                               item = GEN_INT (tree_to_shwi (initial));
    6491         3022 :                               item = gen_rtx_CONCAT (indmode, mem, item);
    6492         3022 :                               call_arguments
    6493         3022 :                                 = gen_rtx_EXPR_LIST (VOIDmode, item,
    6494              :                                                      call_arguments);
    6495              :                             }
    6496              :                           break;
    6497              :                         }
    6498              :                   }
    6499              :               }
    6500        66689 :             targetm.calls.function_arg_advance (args_so_far, arg);
    6501        66689 :             t = TREE_CHAIN (t);
    6502              :           }
    6503              :       }
    6504              : 
    6505              :   /* Add debug arguments.  */
    6506      3280615 :   if (fndecl
    6507      2918843 :       && TREE_CODE (fndecl) == FUNCTION_DECL
    6508      6199458 :       && DECL_HAS_DEBUG_ARGS_P (fndecl))
    6509              :     {
    6510        63369 :       vec<tree, va_gc> **debug_args = decl_debug_args_lookup (fndecl);
    6511        63369 :       if (debug_args)
    6512              :         {
    6513              :           unsigned int ix;
    6514              :           tree param;
    6515       139954 :           for (ix = 0; vec_safe_iterate (*debug_args, ix, &param); ix += 2)
    6516              :             {
    6517        76585 :               rtx item;
    6518        76585 :               tree dtemp = (**debug_args)[ix + 1];
    6519        76585 :               machine_mode mode = DECL_MODE (dtemp);
    6520        76585 :               item = gen_rtx_DEBUG_PARAMETER_REF (mode, param);
    6521        76585 :               item = gen_rtx_CONCAT (mode, item, DECL_RTL_KNOWN_SET (dtemp));
    6522        76585 :               call_arguments = gen_rtx_EXPR_LIST (VOIDmode, item,
    6523              :                                                   call_arguments);
    6524              :             }
    6525              :         }
    6526              :     }
    6527              : 
    6528              :   /* Reverse call_arguments chain.  */
    6529      3280615 :   prev = NULL_RTX;
    6530      7232215 :   for (cur = call_arguments; cur; cur = next)
    6531              :     {
    6532      3951600 :       next = XEXP (cur, 1);
    6533      3951600 :       XEXP (cur, 1) = prev;
    6534      3951600 :       prev = cur;
    6535              :     }
    6536      3280615 :   call_arguments = prev;
    6537              : 
    6538      3280615 :   x = get_call_rtx_from (insn);
    6539      3280615 :   if (x)
    6540              :     {
    6541      3280615 :       x = XEXP (XEXP (x, 0), 0);
    6542      3280615 :       if (GET_CODE (x) == SYMBOL_REF)
    6543              :         /* Don't record anything.  */;
    6544       127223 :       else if (CONSTANT_P (x))
    6545              :         {
    6546         1334 :           x = gen_rtx_CONCAT (GET_MODE (x) == VOIDmode ? Pmode : GET_MODE (x),
    6547              :                               pc_rtx, x);
    6548         1334 :           call_arguments
    6549         1334 :             = gen_rtx_EXPR_LIST (VOIDmode, x, call_arguments);
    6550              :         }
    6551              :       else
    6552              :         {
    6553       125889 :           cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode);
    6554       125889 :           if (val && cselib_preserved_value_p (val))
    6555              :             {
    6556        48146 :               x = gen_rtx_CONCAT (GET_MODE (x), pc_rtx, val->val_rtx);
    6557        48146 :               call_arguments
    6558        48146 :                 = gen_rtx_EXPR_LIST (VOIDmode, x, call_arguments);
    6559              :             }
    6560              :         }
    6561              :     }
    6562      3280615 :   if (this_arg)
    6563              :     {
    6564            0 :       machine_mode mode
    6565            0 :         = TYPE_MODE (TREE_TYPE (OBJ_TYPE_REF_EXPR (obj_type_ref)));
    6566            0 :       rtx clobbered = gen_rtx_MEM (mode, this_arg);
    6567            0 :       HOST_WIDE_INT token
    6568            0 :         = tree_to_shwi (OBJ_TYPE_REF_TOKEN (obj_type_ref));
    6569            0 :       if (token)
    6570            0 :         clobbered = plus_constant (mode, clobbered,
    6571            0 :                                    token * GET_MODE_SIZE (mode));
    6572            0 :       clobbered = gen_rtx_MEM (mode, clobbered);
    6573            0 :       x = gen_rtx_CONCAT (mode, gen_rtx_CLOBBER (VOIDmode, pc_rtx), clobbered);
    6574            0 :       call_arguments
    6575            0 :         = gen_rtx_EXPR_LIST (VOIDmode, x, call_arguments);
    6576              :     }
    6577      3280615 : }
    6578              : 
    6579              : /* Callback for cselib_record_sets_hook, that records as micro
    6580              :    operations uses and stores in an insn after cselib_record_sets has
    6581              :    analyzed the sets in an insn, but before it modifies the stored
    6582              :    values in the internal tables, unless cselib_record_sets doesn't
    6583              :    call it directly (perhaps because we're not doing cselib in the
    6584              :    first place, in which case sets and n_sets will be 0).  */
    6585              : 
    6586              : static void
    6587     83755970 : add_with_sets (rtx_insn *insn, struct cselib_set *sets, int n_sets)
    6588              : {
    6589     83755970 :   basic_block bb = BLOCK_FOR_INSN (insn);
    6590     83755970 :   int n1, n2;
    6591     83755970 :   struct count_use_info cui;
    6592     83755970 :   micro_operation *mos;
    6593              : 
    6594     83755970 :   cselib_hook_called = true;
    6595              : 
    6596     83755970 :   cui.insn = insn;
    6597     83755970 :   cui.bb = bb;
    6598     83755970 :   cui.sets = sets;
    6599     83755970 :   cui.n_sets = n_sets;
    6600              : 
    6601     83755970 :   n1 = VTI (bb)->mos.length ();
    6602     83755970 :   cui.store_p = false;
    6603     83755970 :   note_uses (&PATTERN (insn), add_uses_1, &cui);
    6604     83755970 :   n2 = VTI (bb)->mos.length () - 1;
    6605     83755970 :   mos = VTI (bb)->mos.address ();
    6606              : 
    6607              :   /* Order the MO_USEs to be before MO_USE_NO_VARs and MO_VAL_USE, and
    6608              :      MO_VAL_LOC last.  */
    6609     92608158 :   while (n1 < n2)
    6610              :     {
    6611      9003699 :       while (n1 < n2 && mos[n1].type == MO_USE)
    6612       151511 :         n1++;
    6613     18972596 :       while (n1 < n2 && mos[n2].type != MO_USE)
    6614     10120408 :         n2--;
    6615      8852188 :       if (n1 < n2)
    6616       122653 :         std::swap (mos[n1], mos[n2]);
    6617              :     }
    6618              : 
    6619              :   n2 = VTI (bb)->mos.length () - 1;
    6620     95413129 :   while (n1 < n2)
    6621              :     {
    6622     21777567 :       while (n1 < n2 && mos[n1].type != MO_VAL_LOC)
    6623     10120408 :         n1++;
    6624     11657159 :       while (n1 < n2 && mos[n2].type == MO_VAL_LOC)
    6625            0 :         n2--;
    6626     11657159 :       if (n1 < n2)
    6627      3063204 :         std::swap (mos[n1], mos[n2]);
    6628              :     }
    6629              : 
    6630     83755970 :   if (CALL_P (insn))
    6631              :     {
    6632      3280656 :       micro_operation mo;
    6633              : 
    6634      3280656 :       mo.type = MO_CALL;
    6635      3280656 :       mo.insn = insn;
    6636      3280656 :       mo.u.loc = call_arguments;
    6637      3280656 :       call_arguments = NULL_RTX;
    6638              : 
    6639      3280656 :       if (dump_file && (dump_flags & TDF_DETAILS))
    6640            2 :         log_op_type (PATTERN (insn), bb, insn, mo.type, dump_file);
    6641      3280656 :       VTI (bb)->mos.safe_push (mo);
    6642              :     }
    6643              : 
    6644     83755970 :   n1 = VTI (bb)->mos.length ();
    6645              :   /* This will record NEXT_INSN (insn), such that we can
    6646              :      insert notes before it without worrying about any
    6647              :      notes that MO_USEs might emit after the insn.  */
    6648     83755970 :   cui.store_p = true;
    6649     83755970 :   note_stores (insn, add_stores, &cui);
    6650     83755970 :   n2 = VTI (bb)->mos.length () - 1;
    6651     83755970 :   mos = VTI (bb)->mos.address ();
    6652              : 
    6653              :   /* Order the MO_VAL_USEs first (note_stores does nothing
    6654              :      on DEBUG_INSNs, so there are no MO_VAL_LOCs from this
    6655              :      insn), then MO_CLOBBERs, then MO_SET/MO_COPY/MO_VAL_SET.  */
    6656     87724746 :   while (n1 < n2)
    6657              :     {
    6658      3968776 :       while (n1 < n2 && mos[n1].type == MO_VAL_USE)
    6659            0 :         n1++;
    6660      8005293 :       while (n1 < n2 && mos[n2].type != MO_VAL_USE)
    6661      4036517 :         n2--;
    6662      3968776 :       if (n1 < n2)
    6663            0 :         std::swap (mos[n1], mos[n2]);
    6664              :     }
    6665              : 
    6666              :   n2 = VTI (bb)->mos.length () - 1;
    6667     87729996 :   while (n1 < n2)
    6668              :     {
    6669      7220486 :       while (n1 < n2 && mos[n1].type == MO_CLOBBER)
    6670      3246460 :         n1++;
    6671      4764083 :       while (n1 < n2 && mos[n2].type != MO_CLOBBER)
    6672       790057 :         n2--;
    6673      3974026 :       if (n1 < n2)
    6674         5250 :         std::swap (mos[n1], mos[n2]);
    6675              :     }
    6676     83755970 : }
    6677              : 
    6678              : static enum var_init_status
    6679        62850 : find_src_status (dataflow_set *in, rtx src)
    6680              : {
    6681        62850 :   tree decl = NULL_TREE;
    6682        62850 :   enum var_init_status status = VAR_INIT_STATUS_UNINITIALIZED;
    6683              : 
    6684        62850 :   if (! flag_var_tracking_uninit)
    6685        62850 :     status = VAR_INIT_STATUS_INITIALIZED;
    6686              : 
    6687        62850 :   if (src && REG_P (src))
    6688        59158 :     decl = var_debug_decl (REG_EXPR (src));
    6689         3692 :   else if (src && MEM_P (src))
    6690         3692 :     decl = var_debug_decl (MEM_EXPR (src));
    6691              : 
    6692        62850 :   if (src && decl)
    6693        62850 :     status = get_init_value (in, src, dv_from_decl (decl));
    6694              : 
    6695        62850 :   return status;
    6696              : }
    6697              : 
    6698              : /* SRC is the source of an assignment.  Use SET to try to find what
    6699              :    was ultimately assigned to SRC.  Return that value if known,
    6700              :    otherwise return SRC itself.  */
    6701              : 
    6702              : static rtx
    6703       133269 : find_src_set_src (dataflow_set *set, rtx src)
    6704              : {
    6705       133269 :   tree decl = NULL_TREE;   /* The variable being copied around.          */
    6706       133269 :   rtx set_src = NULL_RTX;  /* The value for "decl" stored in "src".      */
    6707       133269 :   variable *var;
    6708       133269 :   location_chain *nextp;
    6709       133269 :   int i;
    6710       133269 :   bool found;
    6711              : 
    6712       133269 :   if (src && REG_P (src))
    6713       125810 :     decl = var_debug_decl (REG_EXPR (src));
    6714         7459 :   else if (src && MEM_P (src))
    6715         7459 :     decl = var_debug_decl (MEM_EXPR (src));
    6716              : 
    6717       133269 :   if (src && decl)
    6718              :     {
    6719       133269 :       decl_or_value dv = dv_from_decl (decl);
    6720              : 
    6721       133269 :       var = shared_hash_find (set->vars, dv);
    6722       133269 :       if (var)
    6723              :         {
    6724              :           found = false;
    6725       269303 :           for (i = 0; i < var->n_var_parts && !found; i++)
    6726       319063 :             for (nextp = var->var_part[i].loc_chain; nextp && !found;
    6727       165405 :                  nextp = nextp->next)
    6728       165405 :               if (rtx_equal_p (nextp->loc, src))
    6729              :                 {
    6730        96385 :                   set_src = nextp->set_src;
    6731        96385 :                   found = true;
    6732              :                 }
    6733              : 
    6734              :         }
    6735              :     }
    6736              : 
    6737       133269 :   return set_src;
    6738              : }
    6739              : 
    6740              : /* Compute the changes of variable locations in the basic block BB.  */
    6741              : 
    6742              : static bool
    6743      9465017 : compute_bb_dataflow (basic_block bb)
    6744              : {
    6745      9465017 :   unsigned int i;
    6746      9465017 :   micro_operation *mo;
    6747      9465017 :   bool changed;
    6748      9465017 :   dataflow_set old_out;
    6749      9465017 :   dataflow_set *in = &VTI (bb)->in;
    6750      9465017 :   dataflow_set *out = &VTI (bb)->out;
    6751              : 
    6752      9465017 :   dataflow_set_init (&old_out);
    6753      9465017 :   dataflow_set_copy (&old_out, out);
    6754      9465017 :   dataflow_set_copy (out, in);
    6755              : 
    6756      9465017 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
    6757      9464930 :     local_get_addr_cache = new hash_map<rtx, rtx>;
    6758              : 
    6759    174077947 :   FOR_EACH_VEC_ELT (VTI (bb)->mos, i, mo)
    6760              :     {
    6761    164612930 :       rtx_insn *insn = mo->insn;
    6762              : 
    6763    164612930 :       switch (mo->type)
    6764              :         {
    6765      3850979 :           case MO_CALL:
    6766      3850979 :             dataflow_set_clear_at_call (out, insn);
    6767      3850979 :             break;
    6768              : 
    6769       417093 :           case MO_USE:
    6770       417093 :             {
    6771       417093 :               rtx loc = mo->u.loc;
    6772              : 
    6773       417093 :               if (REG_P (loc))
    6774       413805 :                 var_reg_set (out, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
    6775         3288 :               else if (MEM_P (loc))
    6776         3288 :                 var_mem_set (out, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
    6777              :             }
    6778              :             break;
    6779              : 
    6780     54395721 :           case MO_VAL_LOC:
    6781     54395721 :             {
    6782     54395721 :               rtx loc = mo->u.loc;
    6783     54395721 :               rtx val, vloc;
    6784     54395721 :               tree var;
    6785              : 
    6786     54395721 :               if (GET_CODE (loc) == CONCAT)
    6787              :                 {
    6788     26162528 :                   val = XEXP (loc, 0);
    6789     26162528 :                   vloc = XEXP (loc, 1);
    6790              :                 }
    6791              :               else
    6792              :                 {
    6793              :                   val = NULL_RTX;
    6794              :                   vloc = loc;
    6795              :                 }
    6796              : 
    6797     54395721 :               var = PAT_VAR_LOCATION_DECL (vloc);
    6798              : 
    6799     54395721 :               clobber_variable_part (out, NULL_RTX,
    6800              :                                      dv_from_decl (var), 0, NULL_RTX);
    6801     54395721 :               if (val)
    6802              :                 {
    6803     26162528 :                   if (VAL_NEEDS_RESOLUTION (loc))
    6804      2494024 :                     val_resolve (out, val, PAT_VAR_LOCATION_LOC (vloc), insn);
    6805     26162528 :                   set_variable_part (out, val, dv_from_decl (var), 0,
    6806              :                                      VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
    6807              :                                      INSERT);
    6808              :                 }
    6809     28233193 :               else if (!VAR_LOC_UNKNOWN_P (PAT_VAR_LOCATION_LOC (vloc)))
    6810      3836368 :                 set_variable_part (out, PAT_VAR_LOCATION_LOC (vloc),
    6811              :                                    dv_from_decl (var), 0,
    6812              :                                    VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
    6813              :                                    INSERT);
    6814              :             }
    6815              :             break;
    6816              : 
    6817     21759248 :           case MO_VAL_USE:
    6818     21759248 :             {
    6819     21759248 :               rtx loc = mo->u.loc;
    6820     21759248 :               rtx val, vloc, uloc;
    6821              : 
    6822     21759248 :               vloc = uloc = XEXP (loc, 1);
    6823     21759248 :               val = XEXP (loc, 0);
    6824              : 
    6825     21759248 :               if (GET_CODE (val) == CONCAT)
    6826              :                 {
    6827     10497552 :                   uloc = XEXP (val, 1);
    6828     10497552 :                   val = XEXP (val, 0);
    6829              :                 }
    6830              : 
    6831     21759248 :               if (VAL_NEEDS_RESOLUTION (loc))
    6832     21759248 :                 val_resolve (out, val, vloc, insn);
    6833              :               else
    6834            0 :                 val_store (out, val, uloc, insn, false);
    6835              : 
    6836     21759248 :               if (VAL_HOLDS_TRACK_EXPR (loc))
    6837              :                 {
    6838       306876 :                   if (GET_CODE (uloc) == REG)
    6839       279574 :                     var_reg_set (out, uloc, VAR_INIT_STATUS_UNINITIALIZED,
    6840              :                                  NULL);
    6841        27302 :                   else if (GET_CODE (uloc) == MEM)
    6842        27302 :                     var_mem_set (out, uloc, VAR_INIT_STATUS_UNINITIALIZED,
    6843              :                                  NULL);
    6844              :                 }
    6845              :             }
    6846              :             break;
    6847              : 
    6848     42059441 :           case MO_VAL_SET:
    6849     42059441 :             {
    6850     42059441 :               rtx loc = mo->u.loc;
    6851     42059441 :               rtx val, vloc, uloc;
    6852     42059441 :               rtx dstv, srcv;
    6853              : 
    6854     42059441 :               vloc = loc;
    6855     42059441 :               uloc = XEXP (vloc, 1);
    6856     42059441 :               val = XEXP (vloc, 0);
    6857     42059441 :               vloc = uloc;
    6858              : 
    6859     42059441 :               if (GET_CODE (uloc) == SET)
    6860              :                 {
    6861     31168740 :                   dstv = SET_DEST (uloc);
    6862     31168740 :                   srcv = SET_SRC (uloc);
    6863              :                 }
    6864              :               else
    6865              :                 {
    6866              :                   dstv = uloc;
    6867              :                   srcv = NULL;
    6868              :                 }
    6869              : 
    6870     42059441 :               if (GET_CODE (val) == CONCAT)
    6871              :                 {
    6872     10887525 :                   dstv = vloc = XEXP (val, 1);
    6873     10887525 :                   val = XEXP (val, 0);
    6874              :                 }
    6875              : 
    6876     42059441 :               if (GET_CODE (vloc) == SET)
    6877              :                 {
    6878     31162873 :                   srcv = SET_SRC (vloc);
    6879              : 
    6880     31162873 :                   gcc_assert (val != srcv);
    6881     31162873 :                   gcc_assert (vloc == uloc || VAL_NEEDS_RESOLUTION (loc));
    6882              : 
    6883     31162873 :                   dstv = vloc = SET_DEST (vloc);
    6884              : 
    6885     31162873 :                   if (VAL_NEEDS_RESOLUTION (loc))
    6886            0 :                     val_resolve (out, val, srcv, insn);
    6887              :                 }
    6888     10896568 :               else if (VAL_NEEDS_RESOLUTION (loc))
    6889              :                 {
    6890            0 :                   gcc_assert (GET_CODE (uloc) == SET
    6891              :                               && GET_CODE (SET_SRC (uloc)) == REG);
    6892            0 :                   val_resolve (out, val, SET_SRC (uloc), insn);
    6893              :                 }
    6894              : 
    6895     42059441 :               if (VAL_HOLDS_TRACK_EXPR (loc))
    6896              :                 {
    6897       139340 :                   if (VAL_EXPR_IS_CLOBBERED (loc))
    6898              :                     {
    6899            0 :                       if (REG_P (uloc))
    6900            0 :                         var_reg_delete (out, uloc, true);
    6901            0 :                       else if (MEM_P (uloc))
    6902              :                         {
    6903            0 :                           gcc_assert (MEM_P (dstv));
    6904            0 :                           gcc_assert (MEM_ATTRS (dstv) == MEM_ATTRS (uloc));
    6905            0 :                           var_mem_delete (out, dstv, true);
    6906              :                         }
    6907              :                     }
    6908              :                   else
    6909              :                     {
    6910       139340 :                       bool copied_p = VAL_EXPR_IS_COPIED (loc);
    6911       139340 :                       rtx src = NULL, dst = uloc;
    6912       139340 :                       enum var_init_status status = VAR_INIT_STATUS_INITIALIZED;
    6913              : 
    6914       139340 :                       if (GET_CODE (uloc) == SET)
    6915              :                         {
    6916       134319 :                           src = SET_SRC (uloc);
    6917       134319 :                           dst = SET_DEST (uloc);
    6918              :                         }
    6919              : 
    6920       139340 :                       if (copied_p)
    6921              :                         {
    6922        26033 :                           if (flag_var_tracking_uninit)
    6923              :                             {
    6924            0 :                               status = find_src_status (in, src);
    6925              : 
    6926            0 :                               if (status == VAR_INIT_STATUS_UNKNOWN)
    6927            0 :                                 status = find_src_status (out, src);
    6928              :                             }
    6929              : 
    6930        26033 :                           src = find_src_set_src (in, src);
    6931              :                         }
    6932              : 
    6933       139340 :                       if (REG_P (dst))
    6934       133461 :                         var_reg_delete_and_set (out, dst, !copied_p,
    6935              :                                                 status, srcv);
    6936         5879 :                       else if (MEM_P (dst))
    6937              :                         {
    6938         5879 :                           gcc_assert (MEM_P (dstv));
    6939         5879 :                           gcc_assert (MEM_ATTRS (dstv) == MEM_ATTRS (dst));
    6940         5879 :                           var_mem_delete_and_set (out, dstv, !copied_p,
    6941              :                                                   status, srcv);
    6942              :                         }
    6943              :                     }
    6944              :                 }
    6945     41920101 :               else if (REG_P (uloc))
    6946         4245 :                 var_regno_delete (out, REGNO (uloc));
    6947     41915856 :               else if (MEM_P (uloc))
    6948              :                 {
    6949     10881435 :                   gcc_checking_assert (GET_CODE (vloc) == MEM);
    6950     10881435 :                   gcc_checking_assert (dstv == vloc);
    6951              :                   if (dstv != vloc)
    6952              :                     clobber_overlapping_mems (out, vloc);
    6953              :                 }
    6954              : 
    6955     42059441 :               val_store (out, val, dstv, insn, true);
    6956              :             }
    6957     42059441 :             break;
    6958              : 
    6959        40285 :           case MO_SET:
    6960        40285 :             {
    6961        40285 :               rtx loc = mo->u.loc;
    6962        40285 :               rtx set_src = NULL;
    6963              : 
    6964        40285 :               if (GET_CODE (loc) == SET)
    6965              :                 {
    6966        40017 :                   set_src = SET_SRC (loc);
    6967        40017 :                   loc = SET_DEST (loc);
    6968              :                 }
    6969              : 
    6970        40285 :               if (REG_P (loc))
    6971        40285 :                 var_reg_delete_and_set (out, loc, true, VAR_INIT_STATUS_INITIALIZED,
    6972              :                                         set_src);
    6973            0 :               else if (MEM_P (loc))
    6974            0 :                 var_mem_delete_and_set (out, loc, true, VAR_INIT_STATUS_INITIALIZED,
    6975              :                                         set_src);
    6976              :             }
    6977              :             break;
    6978              : 
    6979        44386 :           case MO_COPY:
    6980        44386 :             {
    6981        44386 :               rtx loc = mo->u.loc;
    6982        44386 :               enum var_init_status src_status;
    6983        44386 :               rtx set_src = NULL;
    6984              : 
    6985        44386 :               if (GET_CODE (loc) == SET)
    6986              :                 {
    6987        44386 :                   set_src = SET_SRC (loc);
    6988        44386 :                   loc = SET_DEST (loc);
    6989              :                 }
    6990              : 
    6991        44386 :               if (! flag_var_tracking_uninit)
    6992              :                 src_status = VAR_INIT_STATUS_INITIALIZED;
    6993              :               else
    6994              :                 {
    6995            0 :                   src_status = find_src_status (in, set_src);
    6996              : 
    6997            0 :                   if (src_status == VAR_INIT_STATUS_UNKNOWN)
    6998            0 :                     src_status = find_src_status (out, set_src);
    6999              :                 }
    7000              : 
    7001        44386 :               set_src = find_src_set_src (in, set_src);
    7002              : 
    7003        44386 :               if (REG_P (loc))
    7004        44386 :                 var_reg_delete_and_set (out, loc, false, src_status, set_src);
    7005            0 :               else if (MEM_P (loc))
    7006            0 :                 var_mem_delete_and_set (out, loc, false, src_status, set_src);
    7007              :             }
    7008              :             break;
    7009              : 
    7010     29080752 :           case MO_USE_NO_VAR:
    7011     29080752 :             {
    7012     29080752 :               rtx loc = mo->u.loc;
    7013              : 
    7014     29080752 :               if (REG_P (loc))
    7015     29080752 :                 var_reg_delete (out, loc, false);
    7016            0 :               else if (MEM_P (loc))
    7017            0 :                 var_mem_delete (out, loc, false);
    7018              :             }
    7019              :             break;
    7020              : 
    7021      8087937 :           case MO_CLOBBER:
    7022      8087937 :             {
    7023      8087937 :               rtx loc = mo->u.loc;
    7024              : 
    7025      8087937 :               if (REG_P (loc))
    7026      8087934 :                 var_reg_delete (out, loc, true);
    7027            3 :               else if (MEM_P (loc))
    7028            3 :                 var_mem_delete (out, loc, true);
    7029              :             }
    7030              :             break;
    7031              : 
    7032      4877088 :           case MO_ADJUST:
    7033      4877088 :             out->stack_adjust += mo->u.adjust;
    7034      4877088 :             break;
    7035              :         }
    7036              :     }
    7037              : 
    7038      9465017 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
    7039              :     {
    7040     18929860 :       delete local_get_addr_cache;
    7041      9464930 :       local_get_addr_cache = NULL;
    7042              : 
    7043      9464930 :       dataflow_set_equiv_regs (out);
    7044      9464930 :       shared_hash_htab (out->vars)
    7045    432486300 :         ->traverse <dataflow_set *, canonicalize_values_mark> (out);
    7046      9464930 :       shared_hash_htab (out->vars)
    7047      9464930 :         ->traverse <dataflow_set *, canonicalize_values_star> (out);
    7048      9464930 :       if (flag_checking)
    7049      9464918 :         shared_hash_htab (out->vars)
    7050    542609398 :           ->traverse <dataflow_set *, canonicalize_loc_order_check> (out);
    7051              :     }
    7052      9465017 :   changed = dataflow_set_different (&old_out, out);
    7053      9465017 :   dataflow_set_destroy (&old_out);
    7054      9465017 :   return changed;
    7055              : }
    7056              : 
    7057              : /* Find the locations of variables in the whole function.  */
    7058              : 
    7059              : static bool
    7060       509710 : vt_find_locations (void)
    7061              : {
    7062       509710 :   bb_heap_t *worklist = new bb_heap_t (LONG_MIN);
    7063       509710 :   bb_heap_t *pending = new bb_heap_t (LONG_MIN);
    7064       509710 :   sbitmap in_worklist, in_pending;
    7065       509710 :   basic_block bb;
    7066       509710 :   edge e;
    7067       509710 :   int *bb_order;
    7068       509710 :   int *rc_order;
    7069       509710 :   int i;
    7070       509710 :   int htabsz = 0;
    7071       509710 :   int htabmax = param_max_vartrack_size;
    7072       509710 :   bool success = true;
    7073       509710 :   unsigned int n_blocks_processed = 0;
    7074              : 
    7075       509710 :   timevar_push (TV_VAR_TRACKING_DATAFLOW);
    7076              :   /* Compute reverse completion order of depth first search of the CFG
    7077              :      so that the data-flow runs faster.  */
    7078       509710 :   rc_order = XNEWVEC (int, n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS);
    7079       509710 :   bb_order = XNEWVEC (int, last_basic_block_for_fn (cfun));
    7080       509710 :   auto_bitmap exit_bbs;
    7081       509710 :   bitmap_set_bit (exit_bbs, EXIT_BLOCK);
    7082       509710 :   auto_vec<std::pair<int, int> > toplevel_scc_extents;
    7083       509710 :   int n = rev_post_order_and_mark_dfs_back_seme
    7084       509710 :     (cfun, single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)), exit_bbs, true,
    7085              :      rc_order, &toplevel_scc_extents);
    7086      8514774 :   for (i = 0; i < n; i++)
    7087      7495354 :     bb_order[rc_order[i]] = i;
    7088              : 
    7089       509710 :   in_worklist = sbitmap_alloc (last_basic_block_for_fn (cfun));
    7090       509710 :   in_pending = sbitmap_alloc (last_basic_block_for_fn (cfun));
    7091       509710 :   bitmap_clear (in_worklist);
    7092       509710 :   bitmap_clear (in_pending);
    7093              : 
    7094              :   /* We're performing the dataflow iteration independently over the
    7095              :      toplevel SCCs plus leading non-cyclic entry blocks and separately
    7096              :      over the tail.  That ensures best memory locality and the least
    7097              :      number of visited blocks.  */
    7098       509710 :   unsigned extent = 0;
    7099       509710 :   int curr_start = -1;
    7100       509710 :   int curr_end = -1;
    7101       750560 :   do
    7102              :     {
    7103       750560 :       curr_start = curr_end + 1;
    7104       750560 :       if (toplevel_scc_extents.length () <= extent)
    7105       509044 :         curr_end = n - 1;
    7106              :       else
    7107       241516 :         curr_end = toplevel_scc_extents[extent++].second;
    7108              : 
    7109      8245914 :       for (int i = curr_start; i <= curr_end; ++i)
    7110              :         {
    7111      7495354 :           pending->insert (i, BASIC_BLOCK_FOR_FN (cfun, rc_order[i]));
    7112      7495354 :           bitmap_set_bit (in_pending, rc_order[i]);
    7113              :         }
    7114              : 
    7115      1818419 :       while (success && !pending->empty ())
    7116              :         {
    7117              :           std::swap (worklist, pending);
    7118              :           std::swap (in_worklist, in_pending);
    7119              : 
    7120     10532875 :           while (!worklist->empty ())
    7121              :             {
    7122      9465017 :               bool changed;
    7123      9465017 :               edge_iterator ei;
    7124      9465017 :               int oldinsz, oldoutsz;
    7125              : 
    7126      9465017 :               bb = worklist->extract_min ();
    7127      9465017 :               bitmap_clear_bit (in_worklist, bb->index);
    7128              : 
    7129      9465017 :               if (VTI (bb)->in.vars)
    7130              :                 {
    7131      9465017 :                   htabsz -= (shared_hash_htab (VTI (bb)->in.vars)->size ()
    7132      9465017 :                              + shared_hash_htab (VTI (bb)->out.vars)->size ());
    7133      9465017 :                   oldinsz = shared_hash_htab (VTI (bb)->in.vars)->elements ();
    7134      9465017 :                   oldoutsz = shared_hash_htab (VTI (bb)->out.vars)->elements ();
    7135              :                 }
    7136              :               else
    7137              :                 oldinsz = oldoutsz = 0;
    7138              : 
    7139      9465017 :               if (MAY_HAVE_DEBUG_BIND_INSNS)
    7140              :                 {
    7141      9464930 :                   dataflow_set *in = &VTI (bb)->in, *first_out = NULL;
    7142      9464930 :                   bool first = true, adjust = false;
    7143              : 
    7144              :                   /* Calculate the IN set as the intersection of
    7145              :                      predecessor OUT sets.  */
    7146              : 
    7147      9464930 :                   dataflow_set_clear (in);
    7148      9464930 :                   dst_can_be_shared = true;
    7149              : 
    7150     23668390 :                   FOR_EACH_EDGE (e, ei, bb->preds)
    7151     14203460 :                     if (!VTI (e->src)->flooded)
    7152       363550 :                       gcc_assert (bb_order[bb->index]
    7153              :                                   <= bb_order[e->src->index]);
    7154     13839910 :                     else if (first)
    7155              :                       {
    7156      9464930 :                         dataflow_set_copy (in, &VTI (e->src)->out);
    7157      9464930 :                         first_out = &VTI (e->src)->out;
    7158      9464930 :                         first = false;
    7159              :                       }
    7160              :                     else
    7161              :                       {
    7162      4374980 :                         dataflow_set_merge (in, &VTI (e->src)->out);
    7163      4374980 :                         adjust = true;
    7164              :                       }
    7165              : 
    7166      9464930 :                   if (adjust)
    7167              :                     {
    7168      2830679 :                       dataflow_post_merge_adjust (in, &VTI (bb)->permp);
    7169              : 
    7170      2830679 :                       if (flag_checking)
    7171              :                         /* Merge and merge_adjust should keep entries in
    7172              :                            canonical order.  */
    7173      2830675 :                         shared_hash_htab (in->vars)
    7174              :                           ->traverse <dataflow_set *,
    7175      2830675 :                                       canonicalize_loc_order_check> (in);
    7176              : 
    7177      2830679 :                       if (dst_can_be_shared)
    7178              :                         {
    7179         7547 :                           shared_hash_destroy (in->vars);
    7180         7547 :                           in->vars = shared_hash_copy (first_out->vars);
    7181              :                         }
    7182              :                     }
    7183              : 
    7184      9464930 :                   VTI (bb)->flooded = true;
    7185              :                 }
    7186              :               else
    7187              :                 {
    7188              :                   /* Calculate the IN set as union of predecessor OUT sets.  */
    7189           87 :                   dataflow_set_clear (&VTI (bb)->in);
    7190          193 :                   FOR_EACH_EDGE (e, ei, bb->preds)
    7191          106 :                     dataflow_set_union (&VTI (bb)->in, &VTI (e->src)->out);
    7192              :                 }
    7193              : 
    7194      9465017 :               changed = compute_bb_dataflow (bb);
    7195      9465017 :               n_blocks_processed++;
    7196      9465017 :               htabsz += (shared_hash_htab (VTI (bb)->in.vars)->size ()
    7197      9465017 :                          + shared_hash_htab (VTI (bb)->out.vars)->size ());
    7198              : 
    7199      9465017 :               if (htabmax && htabsz > htabmax)
    7200              :                 {
    7201            1 :                   if (MAY_HAVE_DEBUG_BIND_INSNS)
    7202            1 :                     inform (DECL_SOURCE_LOCATION (cfun->decl),
    7203              :                             "variable tracking size limit exceeded with "
    7204              :                             "%<-fvar-tracking-assignments%>, retrying without");
    7205              :                   else
    7206            0 :                     inform (DECL_SOURCE_LOCATION (cfun->decl),
    7207              :                             "variable tracking size limit exceeded");
    7208            1 :                   success = false;
    7209            1 :                   break;
    7210              :                 }
    7211              : 
    7212      9465016 :               if (changed)
    7213              :                 {
    7214     22936594 :                   FOR_EACH_EDGE (e, ei, bb->succs)
    7215              :                     {
    7216     13864842 :                       if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
    7217       626210 :                         continue;
    7218              : 
    7219              :                       /* Iterate to an earlier block in RPO in the next
    7220              :                          round, iterate to the same block immediately.  */
    7221     13238632 :                       if (bb_order[e->dest->index] < bb_order[bb->index])
    7222              :                         {
    7223       510151 :                           gcc_assert (bb_order[e->dest->index] >= curr_start);
    7224       510151 :                           if (!bitmap_bit_p (in_pending, e->dest->index))
    7225              :                             {
    7226              :                               /* Send E->DEST to next round.  */
    7227       440086 :                               bitmap_set_bit (in_pending, e->dest->index);
    7228       440086 :                               pending->insert (bb_order[e->dest->index],
    7229              :                                                e->dest);
    7230              :                             }
    7231              :                         }
    7232     12728481 :                       else if (bb_order[e->dest->index] <= curr_end
    7233     12728481 :                                && !bitmap_bit_p (in_worklist, e->dest->index))
    7234              :                         {
    7235              :                           /* Add E->DEST to current round or delay
    7236              :                              processing if it is in the next SCC.  */
    7237      1529577 :                           bitmap_set_bit (in_worklist, e->dest->index);
    7238      1529577 :                           worklist->insert (bb_order[e->dest->index],
    7239              :                                             e->dest);
    7240              :                         }
    7241              :                     }
    7242              :                 }
    7243              : 
    7244      9465016 :               if (dump_file)
    7245           77 :                 fprintf (dump_file,
    7246              :                          "BB %i: in %i (was %i), out %i (was %i), rem %i + %i, "
    7247              :                          "tsz %i\n", bb->index,
    7248           77 :                          (int)shared_hash_htab (VTI (bb)->in.vars)->size (),
    7249              :                          oldinsz,
    7250           77 :                          (int)shared_hash_htab (VTI (bb)->out.vars)->size (),
    7251              :                          oldoutsz,
    7252           77 :                          (int)worklist->nodes (), (int)pending->nodes (),
    7253              :                          htabsz);
    7254              : 
    7255      9465016 :               if (dump_file && (dump_flags & TDF_DETAILS))
    7256              :                 {
    7257            1 :                   fprintf (dump_file, "BB %i IN:\n", bb->index);
    7258            1 :                   dump_dataflow_set (&VTI (bb)->in);
    7259            1 :                   fprintf (dump_file, "BB %i OUT:\n", bb->index);
    7260            1 :                   dump_dataflow_set (&VTI (bb)->out);
    7261              :                 }
    7262              :             }
    7263              :         }
    7264              :     }
    7265       750560 :   while (curr_end != n - 1);
    7266              : 
    7267       509710 :   statistics_counter_event (cfun, "compute_bb_dataflow times",
    7268              :                             n_blocks_processed);
    7269              : 
    7270       509710 :   if (success && MAY_HAVE_DEBUG_BIND_INSNS)
    7271      8004938 :     FOR_EACH_BB_FN (bb, cfun)
    7272      7495270 :       gcc_assert (VTI (bb)->flooded);
    7273              : 
    7274       509710 :   free (rc_order);
    7275       509710 :   free (bb_order);
    7276       509710 :   delete worklist;
    7277       509710 :   delete pending;
    7278       509710 :   sbitmap_free (in_worklist);
    7279       509710 :   sbitmap_free (in_pending);
    7280              : 
    7281       509710 :   timevar_pop (TV_VAR_TRACKING_DATAFLOW);
    7282       509710 :   return success;
    7283       509710 : }
    7284              : 
    7285              : /* Print the content of the LIST to dump file.  */
    7286              : 
    7287              : static void
    7288            4 : dump_attrs_list (attrs *list)
    7289              : {
    7290            8 :   for (; list; list = list->next)
    7291              :     {
    7292            4 :       if (dv_is_decl_p (list->dv))
    7293            0 :         print_mem_expr (dump_file, dv_as_decl (list->dv));
    7294              :       else
    7295            4 :         print_rtl_single (dump_file, dv_as_value (list->dv));
    7296            4 :       fprintf (dump_file, "+" HOST_WIDE_INT_PRINT_DEC, list->offset);
    7297              :     }
    7298            4 :   fprintf (dump_file, "\n");
    7299            4 : }
    7300              : 
    7301              : /* Print the information about variable *SLOT to dump file.  */
    7302              : 
    7303              : int
    7304            6 : dump_var_tracking_slot (variable **slot, void *data ATTRIBUTE_UNUSED)
    7305              : {
    7306            6 :   variable *var = *slot;
    7307              : 
    7308            6 :   dump_var (var);
    7309              : 
    7310              :   /* Continue traversing the hash table.  */
    7311            6 :   return 1;
    7312              : }
    7313              : 
    7314              : /* Print the information about variable VAR to dump file.  */
    7315              : 
    7316              : static void
    7317            9 : dump_var (variable *var)
    7318              : {
    7319            9 :   int i;
    7320            9 :   location_chain *node;
    7321              : 
    7322            9 :   if (dv_is_decl_p (var->dv))
    7323              :     {
    7324            3 :       const_tree decl = dv_as_decl (var->dv);
    7325              : 
    7326            3 :       if (DECL_NAME (decl))
    7327              :         {
    7328            6 :           fprintf (dump_file, "  name: %s",
    7329            3 :                    IDENTIFIER_POINTER (DECL_NAME (decl)));
    7330            3 :           if (dump_flags & TDF_UID)
    7331            0 :             fprintf (dump_file, "D.%u", DECL_UID (decl));
    7332              :         }
    7333            0 :       else if (TREE_CODE (decl) == DEBUG_EXPR_DECL)
    7334            0 :         fprintf (dump_file, "  name: D#%u", DEBUG_TEMP_UID (decl));
    7335              :       else
    7336            0 :         fprintf (dump_file, "  name: D.%u", DECL_UID (decl));
    7337            3 :       fprintf (dump_file, "\n");
    7338              :     }
    7339              :   else
    7340              :     {
    7341            6 :       fputc (' ', dump_file);
    7342            6 :       print_rtl_single (dump_file, dv_as_value (var->dv));
    7343              :     }
    7344              : 
    7345           18 :   for (i = 0; i < var->n_var_parts; i++)
    7346              :     {
    7347            9 :       fprintf (dump_file, "    offset " HOST_WIDE_INT_PRINT_DEC "\n",
    7348            9 :                var->onepart ? 0 : VAR_PART_OFFSET (var, i));
    7349           21 :       for (node = var->var_part[i].loc_chain; node; node = node->next)
    7350              :         {
    7351           12 :           fprintf (dump_file, "      ");
    7352           12 :           if (node->init == VAR_INIT_STATUS_UNINITIALIZED)
    7353            0 :             fprintf (dump_file, "[uninit]");
    7354           12 :           print_rtl_single (dump_file, node->loc);
    7355              :         }
    7356              :     }
    7357            9 : }
    7358              : 
    7359              : /* Print the information about variables from hash table VARS to dump file.  */
    7360              : 
    7361              : static void
    7362            4 : dump_vars (variable_table_type *vars)
    7363              : {
    7364            4 :   if (!vars->is_empty ())
    7365              :     {
    7366            2 :       fprintf (dump_file, "Variables:\n");
    7367            8 :       vars->traverse <void *, dump_var_tracking_slot> (NULL);
    7368              :     }
    7369            4 : }
    7370              : 
    7371              : /* Print the dataflow set SET to dump file.  */
    7372              : 
    7373              : static void
    7374            4 : dump_dataflow_set (dataflow_set *set)
    7375              : {
    7376            4 :   int i;
    7377              : 
    7378            4 :   fprintf (dump_file, "Stack adjustment: " HOST_WIDE_INT_PRINT_DEC "\n",
    7379              :            set->stack_adjust);
    7380          384 :   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    7381              :     {
    7382          376 :       if (set->regs[i])
    7383              :         {
    7384            4 :           fprintf (dump_file, "Reg %d:", i);
    7385            4 :           dump_attrs_list (set->regs[i]);
    7386              :         }
    7387              :     }
    7388            4 :   dump_vars (shared_hash_htab (set->vars));
    7389            4 :   fprintf (dump_file, "\n");
    7390            4 : }
    7391              : 
    7392              : /* Print the IN and OUT sets for each basic block to dump file.  */
    7393              : 
    7394              : static void
    7395            1 : dump_dataflow_sets (void)
    7396              : {
    7397            1 :   basic_block bb;
    7398              : 
    7399            2 :   FOR_EACH_BB_FN (bb, cfun)
    7400              :     {
    7401            1 :       fprintf (dump_file, "\nBasic block %d:\n", bb->index);
    7402            1 :       fprintf (dump_file, "IN:\n");
    7403            1 :       dump_dataflow_set (&VTI (bb)->in);
    7404            1 :       fprintf (dump_file, "OUT:\n");
    7405            1 :       dump_dataflow_set (&VTI (bb)->out);
    7406              :     }
    7407            1 : }
    7408              : 
    7409              : /* Return the variable for DV in dropped_values, inserting one if
    7410              :    requested with INSERT.  */
    7411              : 
    7412              : static inline variable *
    7413    202242558 : variable_from_dropped (decl_or_value dv, enum insert_option insert)
    7414              : {
    7415    202242558 :   variable **slot;
    7416    202242558 :   variable *empty_var;
    7417    202242558 :   onepart_enum onepart;
    7418              : 
    7419    202242558 :   slot = dropped_values->find_slot_with_hash (dv, dv_htab_hash (dv), insert);
    7420              : 
    7421    202242558 :   if (!slot)
    7422              :     return NULL;
    7423              : 
    7424     93118701 :   if (*slot)
    7425              :     return *slot;
    7426              : 
    7427      7422137 :   gcc_checking_assert (insert == INSERT);
    7428              : 
    7429      7422137 :   onepart = dv_onepart_p (dv);
    7430              : 
    7431      7422137 :   gcc_checking_assert (onepart == ONEPART_VALUE || onepart == ONEPART_DEXPR);
    7432              : 
    7433      7422137 :   empty_var = onepart_pool_allocate (onepart);
    7434      7422137 :   empty_var->dv = dv;
    7435      7422137 :   empty_var->refcount = 1;
    7436      7422137 :   empty_var->n_var_parts = 0;
    7437      7422137 :   empty_var->onepart = onepart;
    7438      7422137 :   empty_var->in_changed_variables = false;
    7439      7422137 :   empty_var->var_part[0].loc_chain = NULL;
    7440      7422137 :   empty_var->var_part[0].cur_loc = NULL;
    7441      7422137 :   VAR_LOC_1PAUX (empty_var) = NULL;
    7442      7422137 :   set_dv_changed (dv, true);
    7443              : 
    7444      7422137 :   *slot = empty_var;
    7445              : 
    7446      7422137 :   return empty_var;
    7447              : }
    7448              : 
    7449              : /* Recover the one-part aux from dropped_values.  */
    7450              : 
    7451              : static struct onepart_aux *
    7452    117369718 : recover_dropped_1paux (variable *var)
    7453              : {
    7454    117369718 :   variable *dvar;
    7455              : 
    7456    117369718 :   gcc_checking_assert (var->onepart);
    7457              : 
    7458    117369718 :   if (VAR_LOC_1PAUX (var))
    7459              :     return VAR_LOC_1PAUX (var);
    7460              : 
    7461    117369718 :   if (var->onepart == ONEPART_VDECL)
    7462              :     return NULL;
    7463              : 
    7464     93602821 :   dvar = variable_from_dropped (var->dv, NO_INSERT);
    7465              : 
    7466     93602821 :   if (!dvar)
    7467              :     return NULL;
    7468              : 
    7469     12931754 :   VAR_LOC_1PAUX (var) = VAR_LOC_1PAUX (dvar);
    7470     12931754 :   VAR_LOC_1PAUX (dvar) = NULL;
    7471              : 
    7472     12931754 :   return VAR_LOC_1PAUX (var);
    7473              : }
    7474              : 
    7475              : /* Add variable VAR to the hash table of changed variables and
    7476              :    if it has no locations delete it from SET's hash table.  */
    7477              : 
    7478              : static void
    7479    386866453 : variable_was_changed (variable *var, dataflow_set *set)
    7480              : {
    7481    386866453 :   hashval_t hash = dv_htab_hash (var->dv);
    7482              : 
    7483    386866453 :   if (emit_notes)
    7484              :     {
    7485    206077704 :       variable **slot;
    7486              : 
    7487              :       /* Remember this decl or VALUE has been added to changed_variables.  */
    7488    206077704 :       set_dv_changed (var->dv, true);
    7489              : 
    7490    206077704 :       slot = changed_variables->find_slot_with_hash (var->dv, hash, INSERT);
    7491              : 
    7492    206077704 :       if (*slot)
    7493              :         {
    7494      3906752 :           variable *old_var = *slot;
    7495      3906752 :           gcc_assert (old_var->in_changed_variables);
    7496      3906752 :           old_var->in_changed_variables = false;
    7497      3906752 :           if (var != old_var && var->onepart)
    7498              :             {
    7499              :               /* Restore the auxiliary info from an empty variable
    7500              :                  previously created for changed_variables, so it is
    7501              :                  not lost.  */
    7502      3460529 :               gcc_checking_assert (!VAR_LOC_1PAUX (var));
    7503      3460529 :               VAR_LOC_1PAUX (var) = VAR_LOC_1PAUX (old_var);
    7504      3460529 :               VAR_LOC_1PAUX (old_var) = NULL;
    7505              :             }
    7506      3906752 :           variable_htab_free (*slot);
    7507              :         }
    7508              : 
    7509    206077704 :       if (set && var->n_var_parts == 0)
    7510              :         {
    7511     37379913 :           onepart_enum onepart = var->onepart;
    7512     37379913 :           variable *empty_var = NULL;
    7513     37379913 :           variable **dslot = NULL;
    7514              : 
    7515     37379913 :           if (onepart == ONEPART_VALUE || onepart == ONEPART_DEXPR)
    7516              :             {
    7517     21467216 :               dslot = dropped_values->find_slot_with_hash (var->dv,
    7518              :                                                            dv_htab_hash (var->dv),
    7519              :                                                            INSERT);
    7520     21467216 :               empty_var = *dslot;
    7521              : 
    7522     21467216 :               if (empty_var)
    7523              :                 {
    7524      6507474 :                   gcc_checking_assert (!empty_var->in_changed_variables);
    7525      6507474 :                   if (!VAR_LOC_1PAUX (var))
    7526              :                     {
    7527      3767620 :                       VAR_LOC_1PAUX (var) = VAR_LOC_1PAUX (empty_var);
    7528      3767620 :                       VAR_LOC_1PAUX (empty_var) = NULL;
    7529              :                     }
    7530              :                   else
    7531      2739854 :                     gcc_checking_assert (!VAR_LOC_1PAUX (empty_var));
    7532              :                 }
    7533              :             }
    7534              : 
    7535      3767620 :           if (!empty_var)
    7536              :             {
    7537     30872439 :               empty_var = onepart_pool_allocate (onepart);
    7538     30872439 :               empty_var->dv = var->dv;
    7539     30872439 :               empty_var->refcount = 1;
    7540     30872439 :               empty_var->n_var_parts = 0;
    7541     30872439 :               empty_var->onepart = onepart;
    7542     30872439 :               if (dslot)
    7543              :                 {
    7544     14959742 :                   empty_var->refcount++;
    7545     14959742 :                   *dslot = empty_var;
    7546              :                 }
    7547              :             }
    7548              :           else
    7549      6507474 :             empty_var->refcount++;
    7550     37379913 :           empty_var->in_changed_variables = true;
    7551     37379913 :           *slot = empty_var;
    7552     37379913 :           if (onepart)
    7553              :             {
    7554     37067675 :               empty_var->var_part[0].loc_chain = NULL;
    7555     37067675 :               empty_var->var_part[0].cur_loc = NULL;
    7556     37067675 :               VAR_LOC_1PAUX (empty_var) = VAR_LOC_1PAUX (var);
    7557     37067675 :               VAR_LOC_1PAUX (var) = NULL;
    7558              :             }
    7559     37379913 :           goto drop_var;
    7560              :         }
    7561              :       else
    7562              :         {
    7563    168697791 :           if (var->onepart && !VAR_LOC_1PAUX (var))
    7564    117369718 :             recover_dropped_1paux (var);
    7565    168697791 :           var->refcount++;
    7566    168697791 :           var->in_changed_variables = true;
    7567    168697791 :           *slot = var;
    7568              :         }
    7569              :     }
    7570              :   else
    7571              :     {
    7572    180788749 :       gcc_assert (set);
    7573    180788749 :       if (var->n_var_parts == 0)
    7574              :         {
    7575     85881874 :           variable **slot;
    7576              : 
    7577     48501961 :         drop_var:
    7578     85881874 :           slot = shared_hash_find_slot_noinsert (set->vars, var->dv);
    7579     85881874 :           if (slot)
    7580              :             {
    7581     85881874 :               if (shared_hash_shared (set->vars))
    7582            0 :                 slot = shared_hash_find_slot_unshare (&set->vars, var->dv,
    7583              :                                                       NO_INSERT);
    7584     85881874 :               shared_hash_htab (set->vars)->clear_slot (slot);
    7585              :             }
    7586              :         }
    7587              :     }
    7588    386866453 : }
    7589              : 
    7590              : /* Look for the index in VAR->var_part corresponding to OFFSET.
    7591              :    Return -1 if not found.  If INSERTION_POINT is non-NULL, the
    7592              :    referenced int will be set to the index that the part has or should
    7593              :    have, if it should be inserted.  */
    7594              : 
    7595              : static inline int
    7596    437966801 : find_variable_location_part (variable *var, HOST_WIDE_INT offset,
    7597              :                              int *insertion_point)
    7598              : {
    7599    437966801 :   int pos, low, high;
    7600              : 
    7601    437966801 :   if (var->onepart)
    7602              :     {
    7603    435190866 :       if (offset != 0)
    7604              :         return -1;
    7605              : 
    7606    435190795 :       if (insertion_point)
    7607            0 :         *insertion_point = 0;
    7608              : 
    7609    435190795 :       return var->n_var_parts - 1;
    7610              :     }
    7611              : 
    7612              :   /* Find the location part.  */
    7613      2775935 :   low = 0;
    7614      2775935 :   high = var->n_var_parts;
    7615      9520261 :   while (low != high)
    7616              :     {
    7617      3968391 :       pos = (low + high) / 2;
    7618      3968391 :       if (VAR_PART_OFFSET (var, pos) < offset)
    7619       744959 :         low = pos + 1;
    7620              :       else
    7621              :         high = pos;
    7622              :     }
    7623      2775935 :   pos = low;
    7624              : 
    7625      2775935 :   if (insertion_point)
    7626      1376330 :     *insertion_point = pos;
    7627              : 
    7628      2775935 :   if (pos < var->n_var_parts && VAR_PART_OFFSET (var, pos) == offset)
    7629      2550478 :     return pos;
    7630              : 
    7631              :   return -1;
    7632              : }
    7633              : 
    7634              : static variable **
    7635    424287130 : set_slot_part (dataflow_set *set, rtx loc, variable **slot,
    7636              :                decl_or_value dv, HOST_WIDE_INT offset,
    7637              :                enum var_init_status initialized, rtx set_src)
    7638              : {
    7639    424287130 :   int pos;
    7640    424287130 :   location_chain *node, *next;
    7641    424287130 :   location_chain **nextp;
    7642    424287130 :   variable *var;
    7643    424287130 :   onepart_enum onepart;
    7644              : 
    7645    424287130 :   var = *slot;
    7646              : 
    7647    424287130 :   if (var)
    7648    270445099 :     onepart = var->onepart;
    7649              :   else
    7650    153842031 :     onepart = dv_onepart_p (dv);
    7651              : 
    7652    424287130 :   gcc_checking_assert (offset == 0 || !onepart);
    7653    424287130 :   gcc_checking_assert (dv != loc);
    7654              : 
    7655    424287130 :   if (! flag_var_tracking_uninit)
    7656    424287130 :     initialized = VAR_INIT_STATUS_INITIALIZED;
    7657              : 
    7658    424287130 :   if (!var)
    7659              :     {
    7660              :       /* Create new variable information.  */
    7661    153842031 :       var = onepart_pool_allocate (onepart);
    7662    153842031 :       var->dv = dv;
    7663    153842031 :       var->refcount = 1;
    7664    153842031 :       var->n_var_parts = 1;
    7665    153842031 :       var->onepart = onepart;
    7666    153842031 :       var->in_changed_variables = false;
    7667    153842031 :       if (var->onepart)
    7668    153410440 :         VAR_LOC_1PAUX (var) = NULL;
    7669              :       else
    7670       431591 :         VAR_PART_OFFSET (var, 0) = offset;
    7671    153842031 :       var->var_part[0].loc_chain = NULL;
    7672    153842031 :       var->var_part[0].cur_loc = NULL;
    7673    153842031 :       *slot = var;
    7674    153842031 :       pos = 0;
    7675    153842031 :       nextp = &var->var_part[0].loc_chain;
    7676              :     }
    7677    270445099 :   else if (onepart)
    7678              :     {
    7679    269068769 :       int r = -1, c = 0;
    7680              : 
    7681    269068769 :       gcc_assert (var->dv == dv);
    7682              : 
    7683    269068769 :       pos = 0;
    7684              : 
    7685    269068769 :       if (GET_CODE (loc) == VALUE)
    7686              :         {
    7687   1907399185 :           for (nextp = &var->var_part[0].loc_chain; (node = *nextp);
    7688   1680075517 :                nextp = &node->next)
    7689   1896541464 :             if (GET_CODE (node->loc) == VALUE)
    7690              :               {
    7691   1786497198 :                 if (node->loc == loc)
    7692              :                   {
    7693              :                     r = 0;
    7694              :                     break;
    7695              :                   }
    7696   1571780935 :                 if (canon_value_cmp (node->loc, loc))
    7697   1570031251 :                   c++;
    7698              :                 else
    7699              :                   {
    7700              :                     r = 1;
    7701              :                     break;
    7702              :                   }
    7703              :               }
    7704    110044266 :             else if (REG_P (node->loc) || MEM_P (node->loc))
    7705    110044266 :               c++;
    7706              :             else
    7707              :               {
    7708              :                 r = 1;
    7709              :                 break;
    7710              :               }
    7711              :         }
    7712     41745101 :       else if (REG_P (loc))
    7713              :         {
    7714     28381159 :           for (nextp = &var->var_part[0].loc_chain; (node = *nextp);
    7715      3563218 :                nextp = &node->next)
    7716     25582727 :             if (REG_P (node->loc))
    7717              :               {
    7718      6250367 :                 if (REGNO (node->loc) < REGNO (loc))
    7719      3563218 :                   c++;
    7720              :                 else
    7721              :                   {
    7722      2687149 :                     if (REGNO (node->loc) == REGNO (loc))
    7723              :                       r = 0;
    7724              :                     else
    7725              :                       r = 1;
    7726              :                     break;
    7727              :                   }
    7728              :               }
    7729              :             else
    7730              :               {
    7731              :                 r = 1;
    7732              :                 break;
    7733              :               }
    7734              :         }
    7735     16927160 :       else if (MEM_P (loc))
    7736              :         {
    7737     39970224 :           for (nextp = &var->var_part[0].loc_chain; (node = *nextp);
    7738     23043064 :                nextp = &node->next)
    7739     27502078 :             if (REG_P (node->loc))
    7740     13625474 :               c++;
    7741     13876604 :             else if (MEM_P (node->loc))
    7742              :               {
    7743     10941041 :                 if ((r = loc_cmp (XEXP (node->loc, 0), XEXP (loc, 0))) >= 0)
    7744              :                   break;
    7745              :                 else
    7746      9417590 :                   c++;
    7747              :               }
    7748              :             else
    7749              :               {
    7750              :                 r = 1;
    7751              :                 break;
    7752              :               }
    7753              :         }
    7754              :       else
    7755            0 :         for (nextp = &var->var_part[0].loc_chain; (node = *nextp);
    7756            0 :              nextp = &node->next)
    7757            0 :           if ((r = loc_cmp (node->loc, loc)) >= 0)
    7758              :             break;
    7759              :           else
    7760            0 :             c++;
    7761              : 
    7762    266381620 :       if (r == 0)
    7763              :         return slot;
    7764              : 
    7765     54049951 :       if (shared_var_p (var, set->vars))
    7766              :         {
    7767     13726722 :           slot = unshare_variable (set, slot, var, initialized);
    7768     13726722 :           var = *slot;
    7769     37400774 :           for (nextp = &var->var_part[0].loc_chain; c;
    7770     23674052 :                nextp = &(*nextp)->next)
    7771     23674052 :             c--;
    7772     13726722 :           gcc_assert ((!node && !*nextp) || node->loc == (*nextp)->loc);
    7773              :         }
    7774              :     }
    7775              :   else
    7776              :     {
    7777      1376330 :       int inspos = 0;
    7778              : 
    7779      1376330 :       gcc_assert (dv_as_decl (var->dv) == dv_as_decl (dv));
    7780              : 
    7781      1376330 :       pos = find_variable_location_part (var, offset, &inspos);
    7782              : 
    7783      1376330 :       if (pos >= 0)
    7784              :         {
    7785      1181411 :           node = var->var_part[pos].loc_chain;
    7786              : 
    7787      1181411 :           if (node
    7788      1181411 :               && ((REG_P (node->loc) && REG_P (loc)
    7789      1116827 :                    && REGNO (node->loc) == REGNO (loc))
    7790       220468 :                   || rtx_equal_p (node->loc, loc)))
    7791              :             {
    7792              :               /* LOC is in the beginning of the chain so we have nothing
    7793              :                  to do.  */
    7794       990293 :               if (node->init < initialized)
    7795            0 :                 node->init = initialized;
    7796       990293 :               if (set_src != NULL)
    7797        12442 :                 node->set_src = set_src;
    7798              : 
    7799       990293 :               return slot;
    7800              :             }
    7801              :           else
    7802              :             {
    7803              :               /* We have to make a copy of a shared variable.  */
    7804       191118 :               if (shared_var_p (var, set->vars))
    7805              :                 {
    7806        80930 :                   slot = unshare_variable (set, slot, var, initialized);
    7807        80930 :                   var = *slot;
    7808              :                 }
    7809              :             }
    7810              :         }
    7811              :       else
    7812              :         {
    7813              :           /* We have not found the location part, new one will be created.  */
    7814              : 
    7815              :           /* We have to make a copy of the shared variable.  */
    7816       194919 :           if (shared_var_p (var, set->vars))
    7817              :             {
    7818        39976 :               slot = unshare_variable (set, slot, var, initialized);
    7819        39976 :               var = *slot;
    7820              :             }
    7821              : 
    7822              :           /* We track only variables whose size is <= MAX_VAR_PARTS bytes
    7823              :              thus there are at most MAX_VAR_PARTS different offsets.  */
    7824       194919 :           gcc_assert (var->n_var_parts < MAX_VAR_PARTS
    7825              :                       && (!var->n_var_parts || !onepart));
    7826              : 
    7827              :           /* We have to move the elements of array starting at index
    7828              :              inspos to the next position.  */
    7829       253095 :           for (pos = var->n_var_parts; pos > inspos; pos--)
    7830        58176 :             var->var_part[pos] = var->var_part[pos - 1];
    7831              : 
    7832       194919 :           var->n_var_parts++;
    7833       194919 :           gcc_checking_assert (!onepart);
    7834       194919 :           VAR_PART_OFFSET (var, pos) = offset;
    7835       194919 :           var->var_part[pos].loc_chain = NULL;
    7836       194919 :           var->var_part[pos].cur_loc = NULL;
    7837              :         }
    7838              : 
    7839              :       /* Delete the location from the list.  */
    7840       386037 :       nextp = &var->var_part[pos].loc_chain;
    7841       587286 :       for (node = var->var_part[pos].loc_chain; node; node = next)
    7842              :         {
    7843       225787 :           next = node->next;
    7844       189566 :           if ((REG_P (node->loc) && REG_P (loc)
    7845       182893 :                && REGNO (node->loc) == REGNO (loc))
    7846       392122 :               || rtx_equal_p (node->loc, loc))
    7847              :             {
    7848              :               /* Save these values, to assign to the new node, before
    7849              :                  deleting this one.  */
    7850        24538 :               if (node->init > initialized)
    7851            0 :                 initialized = node->init;
    7852        24538 :               if (node->set_src != NULL && set_src == NULL)
    7853        24538 :                 set_src = node->set_src;
    7854        24538 :               if (var->var_part[pos].cur_loc == node->loc)
    7855         6053 :                 var->var_part[pos].cur_loc = NULL;
    7856        24538 :               delete node;
    7857        24538 :               *nextp = next;
    7858        24538 :               break;
    7859              :             }
    7860              :           else
    7861       201249 :             nextp = &node->next;
    7862              :         }
    7863              : 
    7864       386037 :       nextp = &var->var_part[pos].loc_chain;
    7865              :     }
    7866              : 
    7867              :   /* Add the location to the beginning.  */
    7868    208278019 :   node = new location_chain;
    7869    208278019 :   node->loc = loc;
    7870    208278019 :   node->init = initialized;
    7871    208278019 :   node->set_src = set_src;
    7872    208278019 :   node->next = *nextp;
    7873    208278019 :   *nextp = node;
    7874              : 
    7875              :   /* If no location was emitted do so.  */
    7876    208278019 :   if (var->var_part[pos].cur_loc == NULL)
    7877    203985421 :     variable_was_changed (var, set);
    7878              : 
    7879              :   return slot;
    7880              : }
    7881              : 
    7882              : /* Set the part of variable's location in the dataflow set SET.  The
    7883              :    variable part is specified by variable's declaration in DV and
    7884              :    offset OFFSET and the part's location by LOC.  IOPT should be
    7885              :    NO_INSERT if the variable is known to be in SET already and the
    7886              :    variable hash table must not be resized, and INSERT otherwise.  */
    7887              : 
    7888              : static void
    7889    231637058 : set_variable_part (dataflow_set *set, rtx loc,
    7890              :                    decl_or_value dv, HOST_WIDE_INT offset,
    7891              :                    enum var_init_status initialized, rtx set_src,
    7892              :                    enum insert_option iopt)
    7893              : {
    7894    231637058 :   variable **slot;
    7895              : 
    7896    231637058 :   if (iopt == NO_INSERT)
    7897       144056 :     slot = shared_hash_find_slot_noinsert (set->vars, dv);
    7898              :   else
    7899              :     {
    7900    231493002 :       slot = shared_hash_find_slot (set->vars, dv);
    7901    231493002 :       if (!slot)
    7902     11783565 :         slot = shared_hash_find_slot_unshare (&set->vars, dv, iopt);
    7903              :     }
    7904    231637058 :   set_slot_part (set, loc, slot, dv, offset, initialized, set_src);
    7905    231637058 : }
    7906              : 
    7907              : /* Remove all recorded register locations for the given variable part
    7908              :    from dataflow set SET, except for those that are identical to loc.
    7909              :    The variable part is specified by variable's declaration or value
    7910              :    DV and offset OFFSET.  */
    7911              : 
    7912              : static variable **
    7913    339596109 : clobber_slot_part (dataflow_set *set, rtx loc, variable **slot,
    7914              :                    HOST_WIDE_INT offset, rtx set_src)
    7915              : {
    7916    339596109 :   variable *var = *slot;
    7917    339596109 :   int pos = find_variable_location_part (var, offset, NULL);
    7918              : 
    7919    339596109 :   if (pos >= 0)
    7920              :     {
    7921    339565506 :       location_chain *node, *next;
    7922              : 
    7923              :       /* Remove the register locations from the dataflow set.  */
    7924    339565506 :       next = var->var_part[pos].loc_chain;
    7925    681557382 :       for (node = next; node; node = next)
    7926              :         {
    7927    341991876 :           next = node->next;
    7928    341991876 :           if (node->loc != loc
    7929    341991876 :               && (!flag_var_tracking_uninit
    7930            0 :                   || !set_src
    7931            0 :                   || MEM_P (set_src)
    7932            0 :                   || !rtx_equal_p (set_src, node->set_src)))
    7933              :             {
    7934     40930253 :               if (REG_P (node->loc))
    7935              :                 {
    7936       962087 :                   attrs *anode, *anext;
    7937       962087 :                   attrs **anextp;
    7938              : 
    7939              :                   /* Remove the variable part from the register's
    7940              :                      list, but preserve any other variable parts
    7941              :                      that might be regarded as live in that same
    7942              :                      register.  */
    7943       962087 :                   anextp = &set->regs[REGNO (node->loc)];
    7944      1949242 :                   for (anode = *anextp; anode; anode = anext)
    7945              :                     {
    7946       987155 :                       anext = anode->next;
    7947       987155 :                       if (anode->dv == var->dv && anode->offset == offset)
    7948              :                         {
    7949        23837 :                           delete anode;
    7950        23837 :                           *anextp = anext;
    7951              :                         }
    7952              :                       else
    7953       963318 :                         anextp = &anode->next;
    7954              :                     }
    7955              :                 }
    7956              : 
    7957     40930253 :               slot = delete_slot_part (set, node->loc, slot, offset);
    7958              :             }
    7959              :         }
    7960              :     }
    7961              : 
    7962    339596109 :   return slot;
    7963              : }
    7964              : 
    7965              : /* Remove all recorded register locations for the given variable part
    7966              :    from dataflow set SET, except for those that are identical to loc.
    7967              :    The variable part is specified by variable's declaration or value
    7968              :    DV and offset OFFSET.  */
    7969              : 
    7970              : static void
    7971    109329239 : clobber_variable_part (dataflow_set *set, rtx loc, decl_or_value dv,
    7972              :                        HOST_WIDE_INT offset, rtx set_src)
    7973              : {
    7974    109329239 :   variable **slot;
    7975              : 
    7976    204636767 :   if (!dv || (!dv_is_value_p (dv) && ! DECL_P (dv_as_decl (dv))))
    7977              :     return;
    7978              : 
    7979     95215284 :   slot = shared_hash_find_slot_noinsert (set->vars, dv);
    7980     95215284 :   if (!slot)
    7981              :     return;
    7982              : 
    7983     38575563 :   clobber_slot_part (set, loc, slot, offset, set_src);
    7984              : }
    7985              : 
    7986              : /* Delete the part of variable's location from dataflow set SET.  The
    7987              :    variable part is specified by its SET->vars slot SLOT and offset
    7988              :    OFFSET and the part's location by LOC.  */
    7989              : 
    7990              : static variable **
    7991     96994362 : delete_slot_part (dataflow_set *set, rtx loc, variable **slot,
    7992              :                   HOST_WIDE_INT offset)
    7993              : {
    7994     96994362 :   variable *var = *slot;
    7995     96994362 :   int pos = find_variable_location_part (var, offset, NULL);
    7996              : 
    7997     96994362 :   if (pos >= 0)
    7998              :     {
    7999     96994356 :       location_chain *node, *next;
    8000     96994356 :       location_chain **nextp;
    8001     96994356 :       bool changed;
    8002     96994356 :       rtx cur_loc;
    8003              : 
    8004     96994356 :       if (shared_var_p (var, set->vars))
    8005              :         {
    8006              :           /* If the variable contains the location part we have to
    8007              :              make a copy of the variable.  */
    8008     35352195 :           for (node = var->var_part[pos].loc_chain; node;
    8009       243847 :                node = node->next)
    8010              :             {
    8011     21468899 :               if ((REG_P (node->loc) && REG_P (loc)
    8012     21468865 :                    && REGNO (node->loc) == REGNO (loc))
    8013     35578072 :                   || rtx_equal_p (node->loc, loc))
    8014              :                 {
    8015     35108348 :                   slot = unshare_variable (set, slot, var,
    8016              :                                            VAR_INIT_STATUS_UNKNOWN);
    8017     35108348 :                   var = *slot;
    8018     35108348 :                   break;
    8019              :                 }
    8020              :             }
    8021              :         }
    8022              : 
    8023     96994356 :       if (pos == 0 && var->onepart && VAR_LOC_1PAUX (var))
    8024     22171529 :         cur_loc = VAR_LOC_FROM (var);
    8025              :       else
    8026     74822827 :         cur_loc = var->var_part[pos].cur_loc;
    8027              : 
    8028              :       /* Delete the location part.  */
    8029     96994356 :       changed = false;
    8030     96994356 :       nextp = &var->var_part[pos].loc_chain;
    8031     99373518 :       for (node = *nextp; node; node = next)
    8032              :         {
    8033     99373518 :           next = node->next;
    8034     58664814 :           if ((REG_P (node->loc) && REG_P (loc)
    8035     58664574 :                && REGNO (node->loc) == REGNO (loc))
    8036    101012142 :               || rtx_equal_p (node->loc, loc))
    8037              :             {
    8038              :               /* If we have deleted the location which was last emitted
    8039              :                  we have to emit new location so add the variable to set
    8040              :                  of changed variables.  */
    8041     96994356 :               if (cur_loc == node->loc)
    8042              :                 {
    8043     18036016 :                   changed = true;
    8044     18036016 :                   var->var_part[pos].cur_loc = NULL;
    8045     18036016 :                   if (pos == 0 && var->onepart && VAR_LOC_1PAUX (var))
    8046     17675266 :                     VAR_LOC_FROM (var) = NULL;
    8047              :                 }
    8048     96994356 :               delete node;
    8049     96994356 :               *nextp = next;
    8050     96994356 :               break;
    8051              :             }
    8052              :           else
    8053      2379162 :             nextp = &node->next;
    8054              :         }
    8055              : 
    8056     96994356 :       if (var->var_part[pos].loc_chain == NULL)
    8057              :         {
    8058     68867398 :           changed = true;
    8059     68867398 :           var->n_var_parts--;
    8060     69047727 :           while (pos < var->n_var_parts)
    8061              :             {
    8062       180329 :               var->var_part[pos] = var->var_part[pos + 1];
    8063       180329 :               pos++;
    8064              :             }
    8065              :         }
    8066     96994356 :       if (changed)
    8067     71112925 :         variable_was_changed (var, set);
    8068              :     }
    8069              : 
    8070     96994362 :   return slot;
    8071              : }
    8072              : 
    8073              : /* Delete the part of variable's location from dataflow set SET.  The
    8074              :    variable part is specified by variable's declaration or value DV
    8075              :    and offset OFFSET and the part's location by LOC.  */
    8076              : 
    8077              : static void
    8078     56036453 : delete_variable_part (dataflow_set *set, rtx loc, decl_or_value dv,
    8079              :                       HOST_WIDE_INT offset)
    8080              : {
    8081     56036453 :   variable **slot = shared_hash_find_slot_noinsert (set->vars, dv);
    8082     56036453 :   if (!slot)
    8083              :     return;
    8084              : 
    8085     56036453 :   delete_slot_part (set, loc, slot, offset);
    8086              : }
    8087              : 
    8088              : 
    8089              : /* Structure for passing some other parameters to function
    8090              :    vt_expand_loc_callback.  */
    8091     48643495 : class expand_loc_callback_data
    8092              : {
    8093              : public:
    8094              :   /* The variables and values active at this point.  */
    8095              :   variable_table_type *vars;
    8096              : 
    8097              :   /* Stack of values and debug_exprs under expansion, and their
    8098              :      children.  */
    8099              :   auto_vec<rtx, 4> expanding;
    8100              : 
    8101              :   /* Stack of values and debug_exprs whose expansion hit recursion
    8102              :      cycles.  They will have VALUE_RECURSED_INTO marked when added to
    8103              :      this list.  This flag will be cleared if any of its dependencies
    8104              :      resolves to a valid location.  So, if the flag remains set at the
    8105              :      end of the search, we know no valid location for this one can
    8106              :      possibly exist.  */
    8107              :   auto_vec<rtx, 4> pending;
    8108              : 
    8109              :   /* The maximum depth among the sub-expressions under expansion.
    8110              :      Zero indicates no expansion so far.  */
    8111              :   expand_depth depth;
    8112              : };
    8113              : 
    8114              : /* Allocate the one-part auxiliary data structure for VAR, with enough
    8115              :    room for COUNT dependencies.  */
    8116              : 
    8117              : static void
    8118    157058649 : loc_exp_dep_alloc (variable *var, int count)
    8119              : {
    8120    157058649 :   size_t allocsize;
    8121              : 
    8122    157058649 :   gcc_checking_assert (var->onepart);
    8123              : 
    8124              :   /* We can be called with COUNT == 0 to allocate the data structure
    8125              :      without any dependencies, e.g. for the backlinks only.  However,
    8126              :      if we are specifying a COUNT, then the dependency list must have
    8127              :      been emptied before.  It would be possible to adjust pointers or
    8128              :      force it empty here, but this is better done at an earlier point
    8129              :      in the algorithm, so we instead leave an assertion to catch
    8130              :      errors.  */
    8131    157058649 :   gcc_checking_assert (!count
    8132              :                        || VAR_LOC_DEP_VEC (var) == NULL
    8133              :                        || VAR_LOC_DEP_VEC (var)->is_empty ());
    8134              : 
    8135    157058649 :   if (VAR_LOC_1PAUX (var) && VAR_LOC_DEP_VEC (var)->space (count))
    8136              :     return;
    8137              : 
    8138     47364153 :   allocsize = offsetof (struct onepart_aux, deps)
    8139     47364153 :               + deps_vec::embedded_size (count);
    8140              : 
    8141     47364153 :   if (VAR_LOC_1PAUX (var))
    8142              :     {
    8143      2748778 :       VAR_LOC_1PAUX (var) = XRESIZEVAR (struct onepart_aux,
    8144              :                                         VAR_LOC_1PAUX (var), allocsize);
    8145              :       /* If the reallocation moves the onepaux structure, the
    8146              :          back-pointer to BACKLINKS in the first list member will still
    8147              :          point to its old location.  Adjust it.  */
    8148      2748778 :       if (VAR_LOC_DEP_LST (var))
    8149      1246229 :         VAR_LOC_DEP_LST (var)->pprev = VAR_LOC_DEP_LSTP (var);
    8150              :     }
    8151              :   else
    8152              :     {
    8153     44615375 :       VAR_LOC_1PAUX (var) = XNEWVAR (struct onepart_aux, allocsize);
    8154     44615375 :       *VAR_LOC_DEP_LSTP (var) = NULL;
    8155     44615375 :       VAR_LOC_FROM (var) = NULL;
    8156     44615375 :       VAR_LOC_DEPTH (var).complexity = 0;
    8157     44615375 :       VAR_LOC_DEPTH (var).entryvals = 0;
    8158              :     }
    8159     47364153 :   VAR_LOC_DEP_VEC (var)->embedded_init (count);
    8160              : }
    8161              : 
    8162              : /* Remove all entries from the vector of active dependencies of VAR,
    8163              :    removing them from the back-links lists too.  */
    8164              : 
    8165              : static void
    8166    131333987 : loc_exp_dep_clear (variable *var)
    8167              : {
    8168    201668515 :   while (VAR_LOC_DEP_VEC (var) && !VAR_LOC_DEP_VEC (var)->is_empty ())
    8169              :     {
    8170     70334528 :       loc_exp_dep *led = &VAR_LOC_DEP_VEC (var)->last ();
    8171     70334528 :       if (led->next)
    8172     10749318 :         led->next->pprev = led->pprev;
    8173     70334528 :       if (led->pprev)
    8174     26552164 :         *led->pprev = led->next;
    8175     70334528 :       VAR_LOC_DEP_VEC (var)->pop ();
    8176              :     }
    8177    131333987 : }
    8178              : 
    8179              : /* Insert an active dependency from VAR on X to the vector of
    8180              :    dependencies, and add the corresponding back-link to X's list of
    8181              :    back-links in VARS.  */
    8182              : 
    8183              : static void
    8184     70386823 : loc_exp_insert_dep (variable *var, rtx x, variable_table_type *vars)
    8185              : {
    8186     70386823 :   decl_or_value dv;
    8187     70386823 :   variable *xvar;
    8188     70386823 :   loc_exp_dep *led;
    8189              : 
    8190     70386823 :   dv = dv_from_rtx (x);
    8191              : 
    8192              :   /* ??? Build a vector of variables parallel to EXPANDING, to avoid
    8193              :      an additional look up?  */
    8194     70386823 :   xvar = vars->find_with_hash (dv, dv_htab_hash (dv));
    8195              : 
    8196     70386823 :   if (!xvar)
    8197              :     {
    8198     36592339 :       xvar = variable_from_dropped (dv, NO_INSERT);
    8199     36592339 :       gcc_checking_assert (xvar);
    8200              :     }
    8201              : 
    8202              :   /* No point in adding the same backlink more than once.  This may
    8203              :      arise if say the same value appears in two complex expressions in
    8204              :      the same loc_list, or even more than once in a single
    8205              :      expression.  */
    8206     70386823 :   if (VAR_LOC_DEP_LST (xvar) && VAR_LOC_DEP_LST (xvar)->dv == var->dv)
    8207        46786 :     return;
    8208              : 
    8209     70340037 :   if (var->onepart == NOT_ONEPART)
    8210         5509 :     led = new loc_exp_dep;
    8211              :   else
    8212              :     {
    8213     70334528 :       loc_exp_dep empty;
    8214     70334528 :       memset (&empty, 0, sizeof (empty));
    8215     70334528 :       VAR_LOC_DEP_VEC (var)->quick_push (empty);
    8216     70334528 :       led = &VAR_LOC_DEP_VEC (var)->last ();
    8217              :     }
    8218     70340037 :   led->dv = var->dv;
    8219     70340037 :   led->value = x;
    8220              : 
    8221     70340037 :   loc_exp_dep_alloc (xvar, 0);
    8222     70340037 :   led->pprev = VAR_LOC_DEP_LSTP (xvar);
    8223     70340037 :   led->next = *led->pprev;
    8224     70340037 :   if (led->next)
    8225     26755924 :     led->next->pprev = &led->next;
    8226     70340037 :   *led->pprev = led;
    8227              : }
    8228              : 
    8229              : /* Create active dependencies of VAR on COUNT values starting at
    8230              :    VALUE, and corresponding back-links to the entries in VARS.  Return
    8231              :    true if we found any pending-recursion results.  */
    8232              : 
    8233              : static bool
    8234     86718612 : loc_exp_dep_set (variable *var, rtx result, rtx *value, int count,
    8235              :                  variable_table_type *vars)
    8236              : {
    8237     86718612 :   bool pending_recursion = false;
    8238              : 
    8239     86718612 :   gcc_checking_assert (VAR_LOC_DEP_VEC (var) == NULL
    8240              :                        || VAR_LOC_DEP_VEC (var)->is_empty ());
    8241              : 
    8242              :   /* Set up all dependencies from last_child (as set up at the end of
    8243              :      the loop above) to the end.  */
    8244     86718612 :   loc_exp_dep_alloc (var, count);
    8245              : 
    8246    243810851 :   while (count--)
    8247              :     {
    8248     70373627 :       rtx x = *value++;
    8249              : 
    8250     70373627 :       if (!pending_recursion)
    8251     69251972 :         pending_recursion = !result && VALUE_RECURSED_INTO (x);
    8252              : 
    8253     70373627 :       loc_exp_insert_dep (var, x, vars);
    8254              :     }
    8255              : 
    8256     86718612 :   return pending_recursion;
    8257              : }
    8258              : 
    8259              : /* Notify the back-links of IVAR that are pending recursion that we
    8260              :    have found a non-NIL value for it, so they are cleared for another
    8261              :    attempt to compute a current location.  */
    8262              : 
    8263              : static void
    8264     34547988 : notify_dependents_of_resolved_value (variable *ivar, variable_table_type *vars)
    8265              : {
    8266     34547988 :   loc_exp_dep *led, *next;
    8267              : 
    8268     37608021 :   for (led = VAR_LOC_DEP_LST (ivar); led; led = next)
    8269              :     {
    8270      3060033 :       decl_or_value dv = led->dv;
    8271      3060033 :       variable *var;
    8272              : 
    8273      3060033 :       next = led->next;
    8274              : 
    8275      3060033 :       if (dv_is_value_p (dv))
    8276              :         {
    8277      3060033 :           rtx value = dv_as_value (dv);
    8278              : 
    8279              :           /* If we have already resolved it, leave it alone.  */
    8280      3060033 :           if (!VALUE_RECURSED_INTO (value))
    8281       224282 :             continue;
    8282              : 
    8283              :           /* Check that VALUE_RECURSED_INTO, true from the test above,
    8284              :              implies NO_LOC_P.  */
    8285      2835751 :           gcc_checking_assert (NO_LOC_P (value));
    8286              : 
    8287              :           /* We won't notify variables that are being expanded,
    8288              :              because their dependency list is cleared before
    8289              :              recursing.  */
    8290      2835751 :           NO_LOC_P (value) = false;
    8291      2835751 :           VALUE_RECURSED_INTO (value) = false;
    8292              : 
    8293      2835751 :           gcc_checking_assert (dv_changed_p (dv));
    8294              :         }
    8295              :       else
    8296              :         {
    8297            0 :           gcc_checking_assert (dv_onepart_p (dv) != NOT_ONEPART);
    8298            0 :           if (!dv_changed_p (dv))
    8299            0 :             continue;
    8300              :       }
    8301              : 
    8302      2835751 :       var = vars->find_with_hash (dv, dv_htab_hash (dv));
    8303              : 
    8304      2835751 :       if (!var)
    8305      2316447 :         var = variable_from_dropped (dv, NO_INSERT);
    8306              : 
    8307      2316447 :       if (var)
    8308      2835751 :         notify_dependents_of_resolved_value (var, vars);
    8309              : 
    8310      2835751 :       if (next)
    8311       712581 :         next->pprev = led->pprev;
    8312      2835751 :       if (led->pprev)
    8313      2835751 :         *led->pprev = next;
    8314      2835751 :       led->next = NULL;
    8315      2835751 :       led->pprev = NULL;
    8316              :     }
    8317     34547988 : }
    8318              : 
    8319              : static rtx vt_expand_loc_callback (rtx x, bitmap regs,
    8320              :                                    int max_depth, void *data);
    8321              : 
    8322              : /* Return the combined depth, when one sub-expression evaluated to
    8323              :    BEST_DEPTH and the previous known depth was SAVED_DEPTH.  */
    8324              : 
    8325              : static inline expand_depth
    8326    115104235 : update_depth (expand_depth saved_depth, expand_depth best_depth)
    8327              : {
    8328              :   /* If we didn't find anything, stick with what we had.  */
    8329    115104235 :   if (!best_depth.complexity)
    8330     16563392 :     return saved_depth;
    8331              : 
    8332              :   /* If we found hadn't found anything, use the depth of the current
    8333              :      expression.  Do NOT add one extra level, we want to compute the
    8334              :      maximum depth among sub-expressions.  We'll increment it later,
    8335              :      if appropriate.  */
    8336     98540843 :   if (!saved_depth.complexity)
    8337     97404973 :     return best_depth;
    8338              : 
    8339              :   /* Combine the entryval count so that regardless of which one we
    8340              :      return, the entryval count is accurate.  */
    8341      1135870 :   best_depth.entryvals = saved_depth.entryvals
    8342      1135870 :     = best_depth.entryvals + saved_depth.entryvals;
    8343              : 
    8344      1135870 :   if (saved_depth.complexity < best_depth.complexity)
    8345        99571 :     return best_depth;
    8346              :   else
    8347      1036299 :     return saved_depth;
    8348              : }
    8349              : 
    8350              : /* Expand VAR to a location RTX, updating its cur_loc.  Use REGS and
    8351              :    DATA for cselib expand callback.  If PENDRECP is given, indicate in
    8352              :    it whether any sub-expression couldn't be fully evaluated because
    8353              :    it is pending recursion resolution.  */
    8354              : 
    8355              : static inline rtx
    8356     86718612 : vt_expand_var_loc_chain (variable *var, bitmap regs, void *data,
    8357              :                          bool *pendrecp)
    8358              : {
    8359     86718612 :   class expand_loc_callback_data *elcd
    8360              :     = (class expand_loc_callback_data *) data;
    8361     86718612 :   location_chain *loc, *next;
    8362     86718612 :   rtx result = NULL;
    8363     86718612 :   int first_child, result_first_child, last_child;
    8364     86718612 :   bool pending_recursion;
    8365     86718612 :   rtx loc_from = NULL;
    8366     86718612 :   struct elt_loc_list *cloc = NULL;
    8367     86718612 :   expand_depth depth = { 0, 0 }, saved_depth = elcd->depth;
    8368     86718612 :   int wanted_entryvals, found_entryvals = 0;
    8369              : 
    8370              :   /* Clear all backlinks pointing at this, so that we're not notified
    8371              :      while we're active.  */
    8372     86718612 :   loc_exp_dep_clear (var);
    8373              : 
    8374     89683809 :  retry:
    8375     89683809 :   if (var->onepart == ONEPART_VALUE)
    8376              :     {
    8377     37889070 :       cselib_val *val = CSELIB_VAL_PTR (dv_as_value (var->dv));
    8378              : 
    8379     37889070 :       gcc_checking_assert (cselib_preserved_value_p (val));
    8380              : 
    8381     37889070 :       cloc = val->locs;
    8382              :     }
    8383              : 
    8384    179367618 :   first_child = result_first_child = last_child
    8385     89683809 :     = elcd->expanding.length ();
    8386              : 
    8387     89683809 :   wanted_entryvals = found_entryvals;
    8388              : 
    8389              :   /* Attempt to expand each available location in turn.  */
    8390     89683809 :   for (next = loc = var->n_var_parts ? var->var_part[0].loc_chain : NULL;
    8391    112912865 :        loc || cloc; loc = next)
    8392              :     {
    8393     93384276 :       result_first_child = last_child;
    8394              : 
    8395     93384276 :       if (!loc)
    8396              :         {
    8397     24261440 :           loc_from = cloc->loc;
    8398     24261440 :           next = loc;
    8399     24261440 :           cloc = cloc->next;
    8400     24261440 :           if (unsuitable_loc (loc_from))
    8401         2534 :             goto try_next_loc;
    8402              :         }
    8403              :       else
    8404              :         {
    8405     69122836 :           loc_from = loc->loc;
    8406     69122836 :           next = loc->next;
    8407              :         }
    8408              : 
    8409     93381742 :       gcc_checking_assert (!unsuitable_loc (loc_from));
    8410              : 
    8411     93381742 :       elcd->depth.complexity = elcd->depth.entryvals = 0;
    8412     93381742 :       result = cselib_expand_value_rtx_cb (loc_from, regs, EXPR_DEPTH,
    8413              :                                            vt_expand_loc_callback, data);
    8414     93381742 :       last_child = elcd->expanding.length ();
    8415              : 
    8416     93381742 :       if (result)
    8417              :         {
    8418     73333658 :           depth = elcd->depth;
    8419              : 
    8420     73333658 :           gcc_checking_assert (depth.complexity
    8421              :                                || result_first_child == last_child);
    8422              : 
    8423     73333658 :           if (last_child - result_first_child != 1)
    8424              :             {
    8425     18816971 :               if (!depth.complexity && GET_CODE (result) == ENTRY_VALUE)
    8426      1941828 :                 depth.entryvals++;
    8427     18816971 :               depth.complexity++;
    8428              :             }
    8429              : 
    8430     73333658 :           if (depth.complexity <= EXPR_USE_DEPTH)
    8431              :             {
    8432     73331142 :               if (depth.entryvals <= wanted_entryvals)
    8433              :                 break;
    8434      3175922 :               else if (!found_entryvals || depth.entryvals < found_entryvals)
    8435     23229056 :                 found_entryvals = depth.entryvals;
    8436              :             }
    8437              : 
    8438              :           result = NULL;
    8439              :         }
    8440              : 
    8441     20048084 :     try_next_loc:
    8442              :       /* Set it up in case we leave the loop.  */
    8443     23229056 :       depth.complexity = depth.entryvals = 0;
    8444     23229056 :       loc_from = NULL;
    8445     23229056 :       result_first_child = first_child;
    8446              :     }
    8447              : 
    8448     89683809 :   if (!loc_from && wanted_entryvals < found_entryvals)
    8449              :     {
    8450              :       /* We found entries with ENTRY_VALUEs and skipped them.  Since
    8451              :          we could not find any expansions without ENTRY_VALUEs, but we
    8452              :          found at least one with them, go back and get an entry with
    8453              :          the minimum number ENTRY_VALUE count that we found.  We could
    8454              :          avoid looping, but since each sub-loc is already resolved,
    8455              :          the re-expansion should be trivial.  ??? Should we record all
    8456              :          attempted locs as dependencies, so that we retry the
    8457              :          expansion should any of them change, in the hope it can give
    8458              :          us a new entry without an ENTRY_VALUE?  */
    8459      2965197 :       elcd->expanding.truncate (first_child);
    8460      2965197 :       goto retry;
    8461              :     }
    8462              : 
    8463              :   /* Register all encountered dependencies as active.  */
    8464     86718612 :   pending_recursion = loc_exp_dep_set
    8465    173437224 :     (var, result, elcd->expanding.address () + result_first_child,
    8466              :      last_child - result_first_child, elcd->vars);
    8467              : 
    8468     86718612 :   elcd->expanding.truncate (first_child);
    8469              : 
    8470              :   /* Record where the expansion came from.  */
    8471     86718612 :   gcc_checking_assert (!result || !pending_recursion);
    8472     86718612 :   VAR_LOC_FROM (var) = loc_from;
    8473     86718612 :   VAR_LOC_DEPTH (var) = depth;
    8474              : 
    8475     86718612 :   gcc_checking_assert (!depth.complexity == !result);
    8476              : 
    8477     86718612 :   elcd->depth = update_depth (saved_depth, depth);
    8478              : 
    8479              :   /* Indicate whether any of the dependencies are pending recursion
    8480              :      resolution.  */
    8481     86718612 :   if (pendrecp)
    8482     42322984 :     *pendrecp = pending_recursion;
    8483              : 
    8484     86718612 :   if (!pendrecp || !pending_recursion)
    8485     81086059 :     var->var_part[0].cur_loc = result;
    8486              : 
    8487     86718612 :   return result;
    8488              : }
    8489              : 
    8490              : /* Callback for cselib_expand_value, that looks for expressions
    8491              :    holding the value in the var-tracking hash tables.  Return X for
    8492              :    standard processing, anything else is to be used as-is.  */
    8493              : 
    8494              : static rtx
    8495     81765192 : vt_expand_loc_callback (rtx x, bitmap regs,
    8496              :                         int max_depth ATTRIBUTE_UNUSED,
    8497              :                         void *data)
    8498              : {
    8499     81765192 :   class expand_loc_callback_data *elcd
    8500              :     = (class expand_loc_callback_data *) data;
    8501     81765192 :   decl_or_value dv;
    8502     81765192 :   variable *var;
    8503     81765192 :   rtx result, subreg;
    8504     81765192 :   bool pending_recursion = false;
    8505     81765192 :   bool from_empty = false;
    8506              : 
    8507     81765192 :   switch (GET_CODE (x))
    8508              :     {
    8509       864257 :     case SUBREG:
    8510       864257 :       subreg = cselib_expand_value_rtx_cb (SUBREG_REG (x), regs,
    8511              :                                            EXPR_DEPTH,
    8512              :                                            vt_expand_loc_callback, data);
    8513              : 
    8514       864257 :       if (!subreg)
    8515              :         return NULL;
    8516              : 
    8517      1206676 :       result = simplify_gen_subreg (GET_MODE (x), subreg,
    8518       603338 :                                     GET_MODE (SUBREG_REG (x)),
    8519       603338 :                                     SUBREG_BYTE (x));
    8520              : 
    8521              :       /* Invalid SUBREGs are ok in debug info.  ??? We could try
    8522              :          alternate expansions for the VALUE as well.  */
    8523       603338 :       if (!result && GET_MODE (subreg) != VOIDmode)
    8524         2624 :         result = gen_rtx_raw_SUBREG (GET_MODE (x), subreg, SUBREG_BYTE (x));
    8525              : 
    8526              :       return result;
    8527              : 
    8528     80900935 :     case DEBUG_EXPR:
    8529     80900935 :     case VALUE:
    8530     80900935 :       dv = dv_from_rtx (x);
    8531     80900935 :       break;
    8532              : 
    8533              :     default:
    8534              :       return x;
    8535              :     }
    8536              : 
    8537     80900935 :   elcd->expanding.safe_push (x);
    8538              : 
    8539              :   /* Check that VALUE_RECURSED_INTO implies NO_LOC_P.  */
    8540     80900935 :   gcc_checking_assert (!VALUE_RECURSED_INTO (x) || NO_LOC_P (x));
    8541              : 
    8542     80900935 :   if (NO_LOC_P (x))
    8543              :     {
    8544     10192328 :       gcc_checking_assert (VALUE_RECURSED_INTO (x) || !dv_changed_p (dv));
    8545              :       return NULL;
    8546              :     }
    8547              : 
    8548     70708607 :   var = elcd->vars->find_with_hash (dv, dv_htab_hash (dv));
    8549              : 
    8550     70708607 :   if (!var)
    8551              :     {
    8552     37144479 :       from_empty = true;
    8553     37144479 :       var = variable_from_dropped (dv, INSERT);
    8554              :     }
    8555              : 
    8556     37144479 :   gcc_checking_assert (var);
    8557              : 
    8558     70708607 :   if (!dv_changed_p (dv))
    8559              :     {
    8560     28385623 :       gcc_checking_assert (!NO_LOC_P (x));
    8561     28385623 :       gcc_checking_assert (var->var_part[0].cur_loc);
    8562     28385623 :       gcc_checking_assert (VAR_LOC_1PAUX (var));
    8563     28385623 :       gcc_checking_assert (VAR_LOC_1PAUX (var)->depth.complexity);
    8564              : 
    8565     28385623 :       elcd->depth = update_depth (elcd->depth, VAR_LOC_1PAUX (var)->depth);
    8566              : 
    8567     28385623 :       return var->var_part[0].cur_loc;
    8568              :     }
    8569              : 
    8570     42322984 :   VALUE_RECURSED_INTO (x) = true;
    8571              :   /* This is tentative, but it makes some tests simpler.  */
    8572     42322984 :   NO_LOC_P (x) = true;
    8573              : 
    8574     42322984 :   gcc_checking_assert (var->n_var_parts == 1 || from_empty);
    8575              : 
    8576     42322984 :   result = vt_expand_var_loc_chain (var, regs, data, &pending_recursion);
    8577              : 
    8578     42322984 :   if (pending_recursion)
    8579              :     {
    8580      5632553 :       gcc_checking_assert (!result);
    8581      5632553 :       elcd->pending.safe_push (x);
    8582              :     }
    8583              :   else
    8584              :     {
    8585     36690431 :       NO_LOC_P (x) = !result;
    8586     36690431 :       VALUE_RECURSED_INTO (x) = false;
    8587     36690431 :       set_dv_changed (dv, false);
    8588              : 
    8589     36690431 :       if (result)
    8590     31712237 :         notify_dependents_of_resolved_value (var, elcd->vars);
    8591              :     }
    8592              : 
    8593              :   return result;
    8594              : }
    8595              : 
    8596              : /* While expanding variables, we may encounter recursion cycles
    8597              :    because of mutual (possibly indirect) dependencies between two
    8598              :    particular variables (or values), say A and B.  If we're trying to
    8599              :    expand A when we get to B, which in turn attempts to expand A, if
    8600              :    we can't find any other expansion for B, we'll add B to this
    8601              :    pending-recursion stack, and tentatively return NULL for its
    8602              :    location.  This tentative value will be used for any other
    8603              :    occurrences of B, unless A gets some other location, in which case
    8604              :    it will notify B that it is worth another try at computing a
    8605              :    location for it, and it will use the location computed for A then.
    8606              :    At the end of the expansion, the tentative NULL locations become
    8607              :    final for all members of PENDING that didn't get a notification.
    8608              :    This function performs this finalization of NULL locations.  */
    8609              : 
    8610              : static void
    8611     48643491 : resolve_expansions_pending_recursion (vec<rtx, va_heap> *pending)
    8612              : {
    8613     54276044 :   while (!pending->is_empty ())
    8614              :     {
    8615      5632553 :       rtx x = pending->pop ();
    8616      5632553 :       decl_or_value dv;
    8617              : 
    8618      5632553 :       if (!VALUE_RECURSED_INTO (x))
    8619      2835751 :         continue;
    8620              : 
    8621      2796802 :       gcc_checking_assert (NO_LOC_P (x));
    8622      2796802 :       VALUE_RECURSED_INTO (x) = false;
    8623      2796802 :       dv = dv_from_rtx (x);
    8624      2796802 :       gcc_checking_assert (dv_changed_p (dv));
    8625      2796802 :       set_dv_changed (dv, false);
    8626              :     }
    8627     48643491 : }
    8628              : 
    8629              : /* Initialize expand_loc_callback_data D with variable hash table V.
    8630              :    It must be a macro because of alloca (vec stack).  */
    8631              : #define INIT_ELCD(d, v)                                         \
    8632              :   do                                                            \
    8633              :     {                                                           \
    8634              :       (d).vars = (v);                                           \
    8635              :       (d).depth.complexity = (d).depth.entryvals = 0;           \
    8636              :     }                                                           \
    8637              :   while (0)
    8638              : /* Finalize expand_loc_callback_data D, resolved to location L.  */
    8639              : #define FINI_ELCD(d, l)                                         \
    8640              :   do                                                            \
    8641              :     {                                                           \
    8642              :       resolve_expansions_pending_recursion (&(d).pending);  \
    8643              :       (d).pending.release ();                                   \
    8644              :       (d).expanding.release ();                                 \
    8645              :                                                                 \
    8646              :       if ((l) && MEM_P (l))                                     \
    8647              :         (l) = targetm.delegitimize_address (l);                 \
    8648              :     }                                                           \
    8649              :   while (0)
    8650              : 
    8651              : /* Expand VALUEs and DEBUG_EXPRs in LOC to a location, using the
    8652              :    equivalences in VARS, updating their CUR_LOCs in the process.  */
    8653              : 
    8654              : static rtx
    8655      4247867 : vt_expand_loc (rtx loc, variable_table_type *vars)
    8656              : {
    8657      4247867 :   class expand_loc_callback_data data;
    8658      4247867 :   rtx result;
    8659              : 
    8660      4247867 :   if (!MAY_HAVE_DEBUG_BIND_INSNS)
    8661              :     return loc;
    8662              : 
    8663      4247863 :   INIT_ELCD (data, vars);
    8664              : 
    8665      4247863 :   result = cselib_expand_value_rtx_cb (loc, scratch_regs, EXPR_DEPTH,
    8666              :                                        vt_expand_loc_callback, &data);
    8667              : 
    8668      4247863 :   FINI_ELCD (data, result);
    8669              : 
    8670              :   return result;
    8671      4247867 : }
    8672              : 
    8673              : /* Expand the one-part VARiable to a location, using the equivalences
    8674              :    in VARS, updating their CUR_LOCs in the process.  */
    8675              : 
    8676              : static rtx
    8677     44395628 : vt_expand_1pvar (variable *var, variable_table_type *vars)
    8678              : {
    8679     44395628 :   class expand_loc_callback_data data;
    8680     44395628 :   rtx loc;
    8681              : 
    8682     44395628 :   gcc_checking_assert (var->onepart && var->n_var_parts == 1);
    8683              : 
    8684     44395628 :   if (!dv_changed_p (var->dv))
    8685            0 :     return var->var_part[0].cur_loc;
    8686              : 
    8687     44395628 :   INIT_ELCD (data, vars);
    8688              : 
    8689     44395628 :   loc = vt_expand_var_loc_chain (var, scratch_regs, &data, NULL);
    8690              : 
    8691     44395628 :   gcc_checking_assert (data.expanding.is_empty ());
    8692              : 
    8693     44395628 :   FINI_ELCD (data, loc);
    8694              : 
    8695              :   return loc;
    8696     44395628 : }
    8697              : 
    8698              : /* Emit the NOTE_INSN_VAR_LOCATION for variable *VARP.  DATA contains
    8699              :    additional parameters: WHERE specifies whether the note shall be emitted
    8700              :    before or after instruction INSN.  */
    8701              : 
    8702              : int
    8703     67258764 : emit_note_insn_var_location (variable **varp, emit_note_data *data)
    8704              : {
    8705     67258764 :   variable *var = *varp;
    8706     67258764 :   rtx_insn *insn = data->insn;
    8707     67258764 :   enum emit_note_where where = data->where;
    8708     67258764 :   variable_table_type *vars = data->vars;
    8709     67258764 :   rtx_note *note;
    8710     67258764 :   rtx note_vl;
    8711     67258764 :   int i, j, n_var_parts;
    8712     67258764 :   bool complete;
    8713     67258764 :   enum var_init_status initialized = VAR_INIT_STATUS_UNINITIALIZED;
    8714     67258764 :   HOST_WIDE_INT last_limit;
    8715     67258764 :   HOST_WIDE_INT offsets[MAX_VAR_PARTS];
    8716     67258764 :   rtx loc[MAX_VAR_PARTS];
    8717     67258764 :   tree decl;
    8718     67258764 :   location_chain *lc;
    8719              : 
    8720     67258764 :   gcc_checking_assert (var->onepart == NOT_ONEPART
    8721              :                        || var->onepart == ONEPART_VDECL);
    8722              : 
    8723     67258764 :   decl = dv_as_decl (var->dv);
    8724              : 
    8725     67258764 :   complete = true;
    8726     67258764 :   last_limit = 0;
    8727     67258764 :   n_var_parts = 0;
    8728     67258764 :   if (!var->onepart)
    8729      1949447 :     for (i = 0; i < var->n_var_parts; i++)
    8730       923863 :       if (var->var_part[i].cur_loc == NULL && var->var_part[i].loc_chain)
    8731       680050 :         var->var_part[i].cur_loc = var->var_part[i].loc_chain->loc;
    8732    112389887 :   for (i = 0; i < var->n_var_parts; i++)
    8733              :     {
    8734     45253606 :       machine_mode mode, wider_mode;
    8735     45253606 :       rtx loc2;
    8736     45253606 :       HOST_WIDE_INT offset, size, wider_size;
    8737              : 
    8738     45253606 :       if (i == 0 && var->onepart)
    8739              :         {
    8740     44395628 :           gcc_checking_assert (var->n_var_parts == 1);
    8741     44395628 :           offset = 0;
    8742     44395628 :           initialized = VAR_INIT_STATUS_INITIALIZED;
    8743     44395628 :           loc2 = vt_expand_1pvar (var, vars);
    8744              :         }
    8745              :       else
    8746              :         {
    8747       857978 :           if (last_limit < VAR_PART_OFFSET (var, i))
    8748              :             {
    8749              :               complete = false;
    8750     67258764 :               break;
    8751              :             }
    8752       735495 :           else if (last_limit > VAR_PART_OFFSET (var, i))
    8753     45131123 :             continue;
    8754       714430 :           offset = VAR_PART_OFFSET (var, i);
    8755       714430 :           loc2 = var->var_part[i].cur_loc;
    8756       714430 :           if (loc2 && GET_CODE (loc2) == MEM
    8757        70084 :               && GET_CODE (XEXP (loc2, 0)) == VALUE)
    8758              :             {
    8759        13196 :               rtx depval = XEXP (loc2, 0);
    8760              : 
    8761        13196 :               loc2 = vt_expand_loc (loc2, vars);
    8762              : 
    8763        13196 :               if (loc2)
    8764        13196 :                 loc_exp_insert_dep (var, depval, vars);
    8765              :             }
    8766        13196 :           if (!loc2)
    8767              :             {
    8768            0 :               complete = false;
    8769            0 :               continue;
    8770              :             }
    8771       714430 :           gcc_checking_assert (GET_CODE (loc2) != VALUE);
    8772       726379 :           for (lc = var->var_part[i].loc_chain; lc; lc = lc->next)
    8773       726379 :             if (var->var_part[i].cur_loc == lc->loc)
    8774              :               {
    8775       714430 :                 initialized = lc->init;
    8776       714430 :                 break;
    8777              :               }
    8778       714430 :           gcc_assert (lc);
    8779              :         }
    8780              : 
    8781     45110058 :       offsets[n_var_parts] = offset;
    8782     45110058 :       if (!loc2)
    8783              :         {
    8784      5952645 :           complete = false;
    8785      5952645 :           continue;
    8786              :         }
    8787     39157413 :       loc[n_var_parts] = loc2;
    8788     39157413 :       mode = GET_MODE (var->var_part[i].cur_loc);
    8789     39157413 :       if (mode == VOIDmode && var->onepart)
    8790      4384051 :         mode = DECL_MODE (decl);
    8791              :       /* We only track subparts of constant-sized objects, since at present
    8792              :          there's no representation for polynomial pieces.  */
    8793     78314826 :       if (!GET_MODE_SIZE (mode).is_constant (&size))
    8794              :         {
    8795              :           complete = false;
    8796              :           continue;
    8797              :         }
    8798     39157413 :       last_limit = offsets[n_var_parts] + size;
    8799              : 
    8800              :       /* Attempt to merge adjacent registers or memory.  */
    8801     39178478 :       for (j = i + 1; j < var->n_var_parts; j++)
    8802       258827 :         if (last_limit <= VAR_PART_OFFSET (var, j))
    8803              :           break;
    8804     39157413 :       if (j < var->n_var_parts
    8805       237762 :           && GET_MODE_WIDER_MODE (mode).exists (&wider_mode)
    8806       475524 :           && GET_MODE_SIZE (wider_mode).is_constant (&wider_size)
    8807       237762 :           && var->var_part[j].cur_loc
    8808       237762 :           && mode == GET_MODE (var->var_part[j].cur_loc)
    8809       233675 :           && (REG_P (loc[n_var_parts]) || MEM_P (loc[n_var_parts]))
    8810       233675 :           && last_limit == (var->onepart ? 0 : VAR_PART_OFFSET (var, j))
    8811       233593 :           && (loc2 = vt_expand_loc (var->var_part[j].cur_loc, vars))
    8812     39391006 :           && GET_CODE (loc[n_var_parts]) == GET_CODE (loc2))
    8813              :         {
    8814       226657 :           rtx new_loc = NULL;
    8815       226657 :           poly_int64 offset2;
    8816              : 
    8817       226657 :           if (REG_P (loc[n_var_parts])
    8818       214131 :               && hard_regno_nregs (REGNO (loc[n_var_parts]), mode) * 2
    8819       214131 :                  == hard_regno_nregs (REGNO (loc[n_var_parts]), wider_mode)
    8820       440191 :               && end_hard_regno (mode, REGNO (loc[n_var_parts]))
    8821       213534 :                  == REGNO (loc2))
    8822              :             {
    8823        54084 :               if (! WORDS_BIG_ENDIAN && ! BYTES_BIG_ENDIAN)
    8824        54084 :                 new_loc = simplify_subreg (wider_mode, loc[n_var_parts],
    8825              :                                            mode, 0);
    8826              :               else if (WORDS_BIG_ENDIAN && BYTES_BIG_ENDIAN)
    8827              :                 new_loc = simplify_subreg (wider_mode, loc2, mode, 0);
    8828        54084 :               if (new_loc)
    8829              :                 {
    8830        54084 :                   if (!REG_P (new_loc)
    8831        54084 :                       || REGNO (new_loc) != REGNO (loc[n_var_parts]))
    8832              :                     new_loc = NULL;
    8833              :                   else
    8834        54084 :                     REG_ATTRS (new_loc) = REG_ATTRS (loc[n_var_parts]);
    8835              :                 }
    8836              :             }
    8837       172573 :           else if (MEM_P (loc[n_var_parts])
    8838        12526 :                    && GET_CODE (XEXP (loc2, 0)) == PLUS
    8839        12525 :                    && REG_P (XEXP (XEXP (loc2, 0), 0))
    8840       185098 :                    && poly_int_rtx_p (XEXP (XEXP (loc2, 0), 1), &offset2))
    8841              :             {
    8842        12525 :               poly_int64 end1 = size;
    8843        12525 :               rtx base1 = strip_offset_and_add (XEXP (loc[n_var_parts], 0),
    8844              :                                                 &end1);
    8845        12525 :               if (rtx_equal_p (base1, XEXP (XEXP (loc2, 0), 0))
    8846        12525 :                   && known_eq (end1, offset2))
    8847        11737 :                 new_loc = adjust_address_nv (loc[n_var_parts],
    8848              :                                              wider_mode, 0);
    8849              :             }
    8850              : 
    8851        66609 :           if (new_loc)
    8852              :             {
    8853        65821 :               loc[n_var_parts] = new_loc;
    8854        65821 :               mode = wider_mode;
    8855        65821 :               last_limit = offsets[n_var_parts] + wider_size;
    8856        65821 :               i = j;
    8857              :             }
    8858              :         }
    8859     39157413 :       ++n_var_parts;
    8860              :     }
    8861     67258764 :   poly_uint64 type_size_unit
    8862     67258764 :     = tree_to_poly_uint64 (TYPE_SIZE_UNIT (TREE_TYPE (decl)));
    8863     67258764 :   if (maybe_lt (poly_uint64 (last_limit), type_size_unit))
    8864     28436953 :     complete = false;
    8865              : 
    8866     67258764 :   if (! flag_var_tracking_uninit)
    8867     67258764 :     initialized = VAR_INIT_STATUS_INITIALIZED;
    8868              : 
    8869     67258764 :   note_vl = NULL_RTX;
    8870     67258764 :   if (!complete)
    8871     28436953 :     note_vl = gen_rtx_VAR_LOCATION (VOIDmode, decl, NULL_RTX, initialized);
    8872     38821811 :   else if (n_var_parts == 1)
    8873              :     {
    8874     38654012 :       rtx expr_list;
    8875              : 
    8876     38654012 :       if (offsets[0] || GET_CODE (loc[0]) == PARALLEL)
    8877            0 :         expr_list = gen_rtx_EXPR_LIST (VOIDmode, loc[0], GEN_INT (offsets[0]));
    8878              :       else
    8879              :         expr_list = loc[0];
    8880              : 
    8881     38654012 :       note_vl = gen_rtx_VAR_LOCATION (VOIDmode, decl, expr_list, initialized);
    8882              :     }
    8883       167799 :   else if (n_var_parts)
    8884              :     {
    8885              :       rtx parallel;
    8886              : 
    8887       503433 :       for (i = 0; i < n_var_parts; i++)
    8888       335634 :         loc[i]
    8889       335634 :           = gen_rtx_EXPR_LIST (VOIDmode, loc[i], GEN_INT (offsets[i]));
    8890              : 
    8891       167799 :       parallel = gen_rtx_PARALLEL (VOIDmode,
    8892              :                                    gen_rtvec_v (n_var_parts, loc));
    8893       167799 :       note_vl = gen_rtx_VAR_LOCATION (VOIDmode, decl,
    8894              :                                       parallel, initialized);
    8895              :     }
    8896              : 
    8897     67258764 :   if (where != EMIT_NOTE_BEFORE_INSN)
    8898              :     {
    8899     38621074 :       note = emit_note_after (NOTE_INSN_VAR_LOCATION, insn);
    8900     38621074 :       if (where == EMIT_NOTE_AFTER_CALL_INSN)
    8901      3459579 :         NOTE_DURING_CALL_P (note) = true;
    8902              :     }
    8903              :   else
    8904              :     {
    8905              :       /* Make sure that the call related notes come first.  */
    8906     28637690 :       while (NEXT_INSN (insn)
    8907     28637690 :              && NOTE_P (insn)
    8908      1390366 :              && NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION
    8909     28637690 :              && NOTE_DURING_CALL_P (insn))
    8910              :         insn = NEXT_INSN (insn);
    8911     28637690 :       if (NOTE_P (insn)
    8912      1390366 :           && NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION
    8913     28637690 :           && NOTE_DURING_CALL_P (insn))
    8914            0 :         note = emit_note_after (NOTE_INSN_VAR_LOCATION, insn);
    8915              :       else
    8916     28637690 :         note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn);
    8917              :     }
    8918     67258764 :   NOTE_VAR_LOCATION (note) = note_vl;
    8919              : 
    8920     67258764 :   set_dv_changed (var->dv, false);
    8921     67258764 :   gcc_assert (var->in_changed_variables);
    8922     67258764 :   var->in_changed_variables = false;
    8923     67258764 :   changed_variables->clear_slot (varp);
    8924              : 
    8925              :   /* Continue traversing the hash table.  */
    8926     67258764 :   return 1;
    8927              : }
    8928              : 
    8929              : /* While traversing changed_variables, push onto DATA (a stack of RTX
    8930              :    values) entries that aren't user variables.  */
    8931              : 
    8932              : int
    8933    181302278 : var_track_values_to_stack (variable **slot,
    8934              :                            vec<rtx, va_heap> *changed_values_stack)
    8935              : {
    8936    181302278 :   variable *var = *slot;
    8937              : 
    8938    181302278 :   if (var->onepart == ONEPART_VALUE)
    8939    121117707 :     changed_values_stack->safe_push (dv_as_value (var->dv));
    8940     60184571 :   else if (var->onepart == ONEPART_DEXPR)
    8941      8930540 :     changed_values_stack->safe_push (DECL_RTL_KNOWN_SET (dv_as_decl (var->dv)));
    8942              : 
    8943    181302278 :   return 1;
    8944              : }
    8945              : 
    8946              : /* Remove from changed_variables the entry whose DV corresponds to
    8947              :    value or debug_expr VAL.  */
    8948              : static void
    8949    130048247 : remove_value_from_changed_variables (rtx val)
    8950              : {
    8951    130048247 :   decl_or_value dv = dv_from_rtx (val);
    8952    130048247 :   variable **slot;
    8953    130048247 :   variable *var;
    8954              : 
    8955    130048247 :   slot = changed_variables->find_slot_with_hash (dv, dv_htab_hash (dv),
    8956              :                                                 NO_INSERT);
    8957    130048247 :   var = *slot;
    8958    130048247 :   var->in_changed_variables = false;
    8959    130048247 :   changed_variables->clear_slot (slot);
    8960    130048247 : }
    8961              : 
    8962              : /* If VAL (a value or debug_expr) has backlinks to variables actively
    8963              :    dependent on it in HTAB or in CHANGED_VARIABLES, mark them as
    8964              :    changed, adding to CHANGED_VALUES_STACK any dependencies that may
    8965              :    have dependencies of their own to notify.  */
    8966              : 
    8967              : static void
    8968    143204785 : notify_dependents_of_changed_value (rtx val, variable_table_type *htab,
    8969              :                                     vec<rtx, va_heap> *changed_values_stack)
    8970              : {
    8971    143204785 :   variable **slot;
    8972    143204785 :   variable *var;
    8973    143204785 :   loc_exp_dep *led;
    8974    143204785 :   decl_or_value dv = dv_from_rtx (val);
    8975              : 
    8976    143204785 :   slot = changed_variables->find_slot_with_hash (dv, dv_htab_hash (dv),
    8977              :                                                 NO_INSERT);
    8978    143204785 :   if (!slot)
    8979     13156538 :     slot = htab->find_slot_with_hash (dv, dv_htab_hash (dv), NO_INSERT);
    8980     13156538 :   if (!slot)
    8981      9028515 :     slot = dropped_values->find_slot_with_hash (dv, dv_htab_hash (dv),
    8982              :                                                 NO_INSERT);
    8983    143204785 :   var = *slot;
    8984              : 
    8985    181623591 :   while ((led = VAR_LOC_DEP_LST (var)))
    8986              :     {
    8987     38418806 :       decl_or_value ldv = led->dv;
    8988     38418806 :       variable *ivar;
    8989              : 
    8990              :       /* Deactivate and remove the backlink, as it was “used up”.  It
    8991              :          makes no sense to attempt to notify the same entity again:
    8992              :          either it will be recomputed and re-register an active
    8993              :          dependency, or it will still have the changed mark.  */
    8994     38418806 :       if (led->next)
    8995     12381449 :         led->next->pprev = led->pprev;
    8996     38418806 :       if (led->pprev)
    8997     38418806 :         *led->pprev = led->next;
    8998     38418806 :       led->next = NULL;
    8999     38418806 :       led->pprev = NULL;
    9000              : 
    9001     38418806 :       if (dv_changed_p (ldv))
    9002      9256439 :         continue;
    9003              : 
    9004     29162367 :       switch (dv_onepart_p (ldv))
    9005              :         {
    9006     13156538 :         case ONEPART_VALUE:
    9007     13156538 :         case ONEPART_DEXPR:
    9008     13156538 :           set_dv_changed (ldv, true);
    9009     13156538 :           changed_values_stack->safe_push (dv_as_rtx (ldv));
    9010     13156538 :           break;
    9011              : 
    9012     16002808 :         case ONEPART_VDECL:
    9013     16002808 :           ivar = htab->find_with_hash (ldv, dv_htab_hash (ldv));
    9014     16002808 :           gcc_checking_assert (!VAR_LOC_DEP_LST (ivar));
    9015     16002808 :           variable_was_changed (ivar, NULL);
    9016     16002808 :           break;
    9017              : 
    9018         3021 :         case NOT_ONEPART:
    9019         3021 :           delete led;
    9020         3021 :           ivar = htab->find_with_hash (ldv, dv_htab_hash (ldv));
    9021         3021 :           if (ivar)
    9022              :             {
    9023         3018 :               int i = ivar->n_var_parts;
    9024         6656 :               while (i--)
    9025              :                 {
    9026         5445 :                   rtx loc = ivar->var_part[i].cur_loc;
    9027              : 
    9028         5445 :                   if (loc && GET_CODE (loc) == MEM
    9029         3083 :                       && XEXP (loc, 0) == val)
    9030              :                     {
    9031         1807 :                       variable_was_changed (ivar, NULL);
    9032         1807 :                       break;
    9033              :                     }
    9034              :                 }
    9035              :             }
    9036              :           break;
    9037              : 
    9038              :         default:
    9039              :           gcc_unreachable ();
    9040              :         }
    9041              :     }
    9042    143204785 : }
    9043              : 
    9044              : /* Take out of changed_variables any entries that don't refer to use
    9045              :    variables.  Back-propagate change notifications from values and
    9046              :    debug_exprs to their active dependencies in HTAB or in
    9047              :    CHANGED_VARIABLES.  */
    9048              : 
    9049              : static void
    9050     90711281 : process_changed_values (variable_table_type *htab)
    9051              : {
    9052     90711281 :   int i, n;
    9053     90711281 :   rtx val;
    9054     90711281 :   auto_vec<rtx, 20> changed_values_stack;
    9055              : 
    9056              :   /* Move values from changed_variables to changed_values_stack.  */
    9057     90711281 :   changed_variables
    9058              :     ->traverse <vec<rtx, va_heap>*, var_track_values_to_stack>
    9059    272013559 :       (&changed_values_stack);
    9060              : 
    9061              :   /* Back-propagate change notifications in values while popping
    9062              :      them from the stack.  */
    9063    324627347 :   for (n = i = changed_values_stack.length ();
    9064    233916066 :        i > 0; i = changed_values_stack.length ())
    9065              :     {
    9066    143204785 :       val = changed_values_stack.pop ();
    9067    143204785 :       notify_dependents_of_changed_value (val, htab, &changed_values_stack);
    9068              : 
    9069              :       /* This condition will hold when visiting each of the entries
    9070              :          originally in changed_variables.  We can't remove them
    9071              :          earlier because this could drop the backlinks before we got a
    9072              :          chance to use them.  */
    9073    143204785 :       if (i == n)
    9074              :         {
    9075    130048247 :           remove_value_from_changed_variables (val);
    9076    130048247 :           n--;
    9077              :         }
    9078              :     }
    9079     90711281 : }
    9080              : 
    9081              : /* Emit NOTE_INSN_VAR_LOCATION note for each variable from a chain
    9082              :    CHANGED_VARIABLES and delete this chain.  WHERE specifies whether
    9083              :    the notes shall be emitted before of after instruction INSN.  */
    9084              : 
    9085              : static void
    9086    126633919 : emit_notes_for_changes (rtx_insn *insn, enum emit_note_where where,
    9087              :                         shared_hash *vars)
    9088              : {
    9089    126633919 :   emit_note_data data;
    9090    126633919 :   variable_table_type *htab = shared_hash_htab (vars);
    9091              : 
    9092    126633919 :   if (changed_variables->is_empty ())
    9093     35922556 :     return;
    9094              : 
    9095     90711363 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
    9096     90711281 :     process_changed_values (htab);
    9097              : 
    9098     90711363 :   data.insn = insn;
    9099     90711363 :   data.where = where;
    9100     90711363 :   data.vars = htab;
    9101              : 
    9102     90711363 :   changed_variables
    9103    157970127 :     ->traverse <emit_note_data*, emit_note_insn_var_location> (&data);
    9104              : }
    9105              : 
    9106              : /* Add variable *SLOT to the chain CHANGED_VARIABLES if it differs from the
    9107              :    same variable in hash table DATA or is not there at all.  */
    9108              : 
    9109              : int
    9110    304072394 : emit_notes_for_differences_1 (variable **slot, variable_table_type *new_vars)
    9111              : {
    9112    304072394 :   variable *old_var, *new_var;
    9113              : 
    9114    304072394 :   old_var = *slot;
    9115    304072394 :   new_var = new_vars->find_with_hash (old_var->dv, dv_htab_hash (old_var->dv));
    9116              : 
    9117    304072394 :   if (!new_var)
    9118              :     {
    9119              :       /* Variable has disappeared.  */
    9120     43499016 :       variable *empty_var = NULL;
    9121              : 
    9122     43499016 :       if (old_var->onepart == ONEPART_VALUE
    9123     43499016 :           || old_var->onepart == ONEPART_DEXPR)
    9124              :         {
    9125     32586472 :           empty_var = variable_from_dropped (old_var->dv, NO_INSERT);
    9126     32586472 :           if (empty_var)
    9127              :             {
    9128      4133682 :               gcc_checking_assert (!empty_var->in_changed_variables);
    9129      4133682 :               if (!VAR_LOC_1PAUX (old_var))
    9130              :                 {
    9131      1829421 :                   VAR_LOC_1PAUX (old_var) = VAR_LOC_1PAUX (empty_var);
    9132      1829421 :                   VAR_LOC_1PAUX (empty_var) = NULL;
    9133              :                 }
    9134              :               else
    9135      2304261 :                 gcc_checking_assert (!VAR_LOC_1PAUX (empty_var));
    9136              :             }
    9137              :         }
    9138              : 
    9139      1829421 :       if (!empty_var)
    9140              :         {
    9141     39365334 :           empty_var = onepart_pool_allocate (old_var->onepart);
    9142     39365334 :           empty_var->dv = old_var->dv;
    9143     39365334 :           empty_var->refcount = 0;
    9144     39365334 :           empty_var->n_var_parts = 0;
    9145     39365334 :           empty_var->onepart = old_var->onepart;
    9146     39365334 :           empty_var->in_changed_variables = false;
    9147              :         }
    9148              : 
    9149     43499016 :       if (empty_var->onepart)
    9150              :         {
    9151              :           /* Propagate the auxiliary data to (ultimately)
    9152              :              changed_variables.  */
    9153     43399001 :           empty_var->var_part[0].loc_chain = NULL;
    9154     43399001 :           empty_var->var_part[0].cur_loc = NULL;
    9155     43399001 :           VAR_LOC_1PAUX (empty_var) = VAR_LOC_1PAUX (old_var);
    9156     43399001 :           VAR_LOC_1PAUX (old_var) = NULL;
    9157              :         }
    9158     43499016 :       variable_was_changed (empty_var, NULL);
    9159              :       /* Continue traversing the hash table.  */
    9160     43499016 :       return 1;
    9161              :     }
    9162              :   /* Update cur_loc and one-part auxiliary data, before new_var goes
    9163              :      through variable_was_changed.  */
    9164    260573378 :   if (old_var != new_var && new_var->onepart)
    9165              :     {
    9166     35030463 :       gcc_checking_assert (VAR_LOC_1PAUX (new_var) == NULL);
    9167     35030463 :       VAR_LOC_1PAUX (new_var) = VAR_LOC_1PAUX (old_var);
    9168     35030463 :       VAR_LOC_1PAUX (old_var) = NULL;
    9169     35030463 :       new_var->var_part[0].cur_loc = old_var->var_part[0].cur_loc;
    9170              :     }
    9171    260573378 :   if (variable_different_p (old_var, new_var))
    9172      8462205 :     variable_was_changed (new_var, NULL);
    9173              : 
    9174              :   /* Continue traversing the hash table.  */
    9175              :   return 1;
    9176              : }
    9177              : 
    9178              : /* Add variable *SLOT to the chain CHANGED_VARIABLES if it is not in hash
    9179              :    table DATA.  */
    9180              : 
    9181              : int
    9182    286901204 : emit_notes_for_differences_2 (variable **slot, variable_table_type *old_vars)
    9183              : {
    9184    286901204 :   variable *old_var, *new_var;
    9185              : 
    9186    286901204 :   new_var = *slot;
    9187    286901204 :   old_var = old_vars->find_with_hash (new_var->dv, dv_htab_hash (new_var->dv));
    9188    286901204 :   if (!old_var)
    9189              :     {
    9190              :       int i;
    9191     52749300 :       for (i = 0; i < new_var->n_var_parts; i++)
    9192     26421474 :         new_var->var_part[i].cur_loc = NULL;
    9193     26327826 :       variable_was_changed (new_var, NULL);
    9194              :     }
    9195              : 
    9196              :   /* Continue traversing the hash table.  */
    9197    286901204 :   return 1;
    9198              : }
    9199              : 
    9200              : /* Emit notes before INSN for differences between dataflow sets OLD_SET and
    9201              :    NEW_SET.  */
    9202              : 
    9203              : static void
    9204      7495353 : emit_notes_for_differences (rtx_insn *insn, dataflow_set *old_set,
    9205              :                             dataflow_set *new_set)
    9206              : {
    9207      7495353 :   shared_hash_htab (old_set->vars)
    9208              :     ->traverse <variable_table_type *, emit_notes_for_differences_1>
    9209    311567747 :       (shared_hash_htab (new_set->vars));
    9210      7495353 :   shared_hash_htab (new_set->vars)
    9211              :     ->traverse <variable_table_type *, emit_notes_for_differences_2>
    9212    294396557 :       (shared_hash_htab (old_set->vars));
    9213      7495353 :   emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN, new_set->vars);
    9214      7495353 : }
    9215              : 
    9216              : /* Return the next insn after INSN that is not a NOTE_INSN_VAR_LOCATION.  */
    9217              : 
    9218              : static rtx_insn *
    9219    123452950 : next_non_note_insn_var_location (rtx_insn *insn)
    9220              : {
    9221    125193762 :   while (insn)
    9222              :     {
    9223    125193762 :       insn = NEXT_INSN (insn);
    9224    125193762 :       if (insn == 0
    9225    125193762 :           || !NOTE_P (insn)
    9226     16721369 :           || NOTE_KIND (insn) != NOTE_INSN_VAR_LOCATION)
    9227              :         break;
    9228              :     }
    9229              : 
    9230    123452950 :   return insn;
    9231              : }
    9232              : 
    9233              : /* Emit the notes for changes of location parts in the basic block BB.  */
    9234              : 
    9235              : static void
    9236      7495353 : emit_notes_in_bb (basic_block bb, dataflow_set *set)
    9237              : {
    9238      7495353 :   unsigned int i;
    9239      7495353 :   micro_operation *mo;
    9240              : 
    9241      7495353 :   dataflow_set_clear (set);
    9242      7495353 :   dataflow_set_copy (set, &VTI (bb)->in);
    9243              : 
    9244    138443656 :   FOR_EACH_VEC_ELT (VTI (bb)->mos, i, mo)
    9245              :     {
    9246    123452950 :       rtx_insn *insn = mo->insn;
    9247    123452950 :       rtx_insn *next_insn = next_non_note_insn_var_location (insn);
    9248              : 
    9249    123452950 :       switch (mo->type)
    9250              :         {
    9251      3280656 :           case MO_CALL:
    9252      3280656 :             dataflow_set_clear_at_call (set, insn);
    9253      3280656 :             emit_notes_for_changes (insn, EMIT_NOTE_AFTER_CALL_INSN, set->vars);
    9254      3280656 :             {
    9255      3280656 :               rtx arguments = mo->u.loc, *p = &arguments;
    9256      7281734 :               while (*p)
    9257              :                 {
    9258      4001078 :                   XEXP (XEXP (*p, 0), 1)
    9259      4001078 :                     = vt_expand_loc (XEXP (XEXP (*p, 0), 1),
    9260              :                                      shared_hash_htab (set->vars));
    9261              :                   /* If expansion is successful, keep it in the list.  */
    9262      4001078 :                   if (XEXP (XEXP (*p, 0), 1))
    9263              :                     {
    9264      3246087 :                       XEXP (XEXP (*p, 0), 1)
    9265      3246087 :                         = copy_rtx_if_shared (XEXP (XEXP (*p, 0), 1));
    9266      3246087 :                       p = &XEXP (*p, 1);
    9267              :                     }
    9268              :                   /* Otherwise, if the following item is data_value for it,
    9269              :                      drop it too too.  */
    9270       754991 :                   else if (XEXP (*p, 1)
    9271       408785 :                            && REG_P (XEXP (XEXP (*p, 0), 0))
    9272       378471 :                            && MEM_P (XEXP (XEXP (XEXP (*p, 1), 0), 0))
    9273          166 :                            && REG_P (XEXP (XEXP (XEXP (XEXP (*p, 1), 0), 0),
    9274              :                                            0))
    9275       755156 :                            && REGNO (XEXP (XEXP (*p, 0), 0))
    9276          165 :                               == REGNO (XEXP (XEXP (XEXP (XEXP (*p, 1), 0),
    9277              :                                                     0), 0)))
    9278            2 :                     *p = XEXP (XEXP (*p, 1), 1);
    9279              :                   /* Just drop this item.  */
    9280              :                   else
    9281       754989 :                     *p = XEXP (*p, 1);
    9282              :                 }
    9283      3280656 :               add_reg_note (insn, REG_CALL_ARG_LOCATION, arguments);
    9284              :             }
    9285      3280656 :             break;
    9286              : 
    9287       337671 :           case MO_USE:
    9288       337671 :             {
    9289       337671 :               rtx loc = mo->u.loc;
    9290              : 
    9291       337671 :               if (REG_P (loc))
    9292       334486 :                 var_reg_set (set, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
    9293              :               else
    9294         3185 :                 var_mem_set (set, loc, VAR_INIT_STATUS_UNINITIALIZED, NULL);
    9295              : 
    9296       337671 :               emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN, set->vars);
    9297              :             }
    9298       337671 :             break;
    9299              : 
    9300     40433678 :           case MO_VAL_LOC:
    9301     40433678 :             {
    9302     40433678 :               rtx loc = mo->u.loc;
    9303     40433678 :               rtx val, vloc;
    9304     40433678 :               tree var;
    9305              : 
    9306     40433678 :               if (GET_CODE (loc) == CONCAT)
    9307              :                 {
    9308     18797317 :                   val = XEXP (loc, 0);
    9309     18797317 :                   vloc = XEXP (loc, 1);
    9310              :                 }
    9311              :               else
    9312              :                 {
    9313              :                   val = NULL_RTX;
    9314              :                   vloc = loc;
    9315              :                 }
    9316              : 
    9317     40433678 :               var = PAT_VAR_LOCATION_DECL (vloc);
    9318              : 
    9319     40433678 :               clobber_variable_part (set, NULL_RTX,
    9320              :                                      dv_from_decl (var), 0, NULL_RTX);
    9321     40433678 :               if (val)
    9322              :                 {
    9323     18797317 :                   if (VAL_NEEDS_RESOLUTION (loc))
    9324      1539307 :                     val_resolve (set, val, PAT_VAR_LOCATION_LOC (vloc), insn);
    9325     18797317 :                   set_variable_part (set, val, dv_from_decl (var), 0,
    9326              :                                      VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
    9327              :                                      INSERT);
    9328              :                 }
    9329     21636361 :               else if (!VAR_LOC_UNKNOWN_P (PAT_VAR_LOCATION_LOC (vloc)))
    9330      3166947 :                 set_variable_part (set, PAT_VAR_LOCATION_LOC (vloc),
    9331              :                                    dv_from_decl (var), 0,
    9332              :                                    VAR_INIT_STATUS_INITIALIZED, NULL_RTX,
    9333              :                                    INSERT);
    9334              : 
    9335     40433678 :               emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN, set->vars);
    9336              :             }
    9337     40433678 :             break;
    9338              : 
    9339     16015878 :           case MO_VAL_USE:
    9340     16015878 :             {
    9341     16015878 :               rtx loc = mo->u.loc;
    9342     16015878 :               rtx val, vloc, uloc;
    9343              : 
    9344     16015878 :               vloc = uloc = XEXP (loc, 1);
    9345     16015878 :               val = XEXP (loc, 0);
    9346              : 
    9347     16015878 :               if (GET_CODE (val) == CONCAT)
    9348              :                 {
    9349      7907530 :                   uloc = XEXP (val, 1);
    9350      7907530 :                   val = XEXP (val, 0);
    9351              :                 }
    9352              : 
    9353     16015878 :               if (VAL_NEEDS_RESOLUTION (loc))
    9354     16015878 :                 val_resolve (set, val, vloc, insn);
    9355              :               else
    9356            0 :                 val_store (set, val, uloc, insn, false);
    9357              : 
    9358     16015878 :               if (VAL_HOLDS_TRACK_EXPR (loc))
    9359              :                 {
    9360       252666 :                   if (GET_CODE (uloc) == REG)
    9361       226275 :                     var_reg_set (set, uloc, VAR_INIT_STATUS_UNINITIALIZED,
    9362              :                                  NULL);
    9363        26391 :                   else if (GET_CODE (uloc) == MEM)
    9364        26391 :                     var_mem_set (set, uloc, VAR_INIT_STATUS_UNINITIALIZED,
    9365              :                                  NULL);
    9366              :                 }
    9367              : 
    9368     16015878 :               emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN, set->vars);
    9369              :             }
    9370     16015878 :             break;
    9371              : 
    9372     32229352 :           case MO_VAL_SET:
    9373     32229352 :             {
    9374     32229352 :               rtx loc = mo->u.loc;
    9375     32229352 :               rtx val, vloc, uloc;
    9376     32229352 :               rtx dstv, srcv;
    9377              : 
    9378     32229352 :               vloc = loc;
    9379     32229352 :               uloc = XEXP (vloc, 1);
    9380     32229352 :               val = XEXP (vloc, 0);
    9381     32229352 :               vloc = uloc;
    9382              : 
    9383     32229352 :               if (GET_CODE (uloc) == SET)
    9384              :                 {
    9385     23497808 :                   dstv = SET_DEST (uloc);
    9386     23497808 :                   srcv = SET_SRC (uloc);
    9387              :                 }
    9388              :               else
    9389              :                 {
    9390              :                   dstv = uloc;
    9391              :                   srcv = NULL;
    9392              :                 }
    9393              : 
    9394     32229352 :               if (GET_CODE (val) == CONCAT)
    9395              :                 {
    9396      8728134 :                   dstv = vloc = XEXP (val, 1);
    9397      8728134 :                   val = XEXP (val, 0);
    9398              :                 }
    9399              : 
    9400     32229352 :               if (GET_CODE (vloc) == SET)
    9401              :                 {
    9402     23493203 :                   srcv = SET_SRC (vloc);
    9403              : 
    9404     23493203 :                   gcc_assert (val != srcv);
    9405     23493203 :                   gcc_assert (vloc == uloc || VAL_NEEDS_RESOLUTION (loc));
    9406              : 
    9407     23493203 :                   dstv = vloc = SET_DEST (vloc);
    9408              : 
    9409     23493203 :                   if (VAL_NEEDS_RESOLUTION (loc))
    9410            0 :                     val_resolve (set, val, srcv, insn);
    9411              :                 }
    9412      8736149 :               else if (VAL_NEEDS_RESOLUTION (loc))
    9413              :                 {
    9414            0 :                   gcc_assert (GET_CODE (uloc) == SET
    9415              :                               && GET_CODE (SET_SRC (uloc)) == REG);
    9416            0 :                   val_resolve (set, val, SET_SRC (uloc), insn);
    9417              :                 }
    9418              : 
    9419     32229352 :               if (VAL_HOLDS_TRACK_EXPR (loc))
    9420              :                 {
    9421       104776 :                   if (VAL_EXPR_IS_CLOBBERED (loc))
    9422              :                     {
    9423            0 :                       if (REG_P (uloc))
    9424            0 :                         var_reg_delete (set, uloc, true);
    9425            0 :                       else if (MEM_P (uloc))
    9426              :                         {
    9427            0 :                           gcc_assert (MEM_P (dstv));
    9428            0 :                           gcc_assert (MEM_ATTRS (dstv) == MEM_ATTRS (uloc));
    9429            0 :                           var_mem_delete (set, dstv, true);
    9430              :                         }
    9431              :                     }
    9432              :                   else
    9433              :                     {
    9434       104776 :                       bool copied_p = VAL_EXPR_IS_COPIED (loc);
    9435       104776 :                       rtx src = NULL, dst = uloc;
    9436       104776 :                       enum var_init_status status = VAR_INIT_STATUS_INITIALIZED;
    9437              : 
    9438       104776 :                       if (GET_CODE (uloc) == SET)
    9439              :                         {
    9440       100283 :                           src = SET_SRC (uloc);
    9441       100283 :                           dst = SET_DEST (uloc);
    9442              :                         }
    9443              : 
    9444       104776 :                       if (copied_p)
    9445              :                         {
    9446        19752 :                           status = find_src_status (set, src);
    9447              : 
    9448        19752 :                           src = find_src_set_src (set, src);
    9449              :                         }
    9450              : 
    9451       104776 :                       if (REG_P (dst))
    9452       100162 :                         var_reg_delete_and_set (set, dst, !copied_p,
    9453              :                                                 status, srcv);
    9454         4614 :                       else if (MEM_P (dst))
    9455              :                         {
    9456         4614 :                           gcc_assert (MEM_P (dstv));
    9457         4614 :                           gcc_assert (MEM_ATTRS (dstv) == MEM_ATTRS (dst));
    9458         4614 :                           var_mem_delete_and_set (set, dstv, !copied_p,
    9459              :                                                   status, srcv);
    9460              :                         }
    9461              :                     }
    9462              :                 }
    9463     32124576 :               else if (REG_P (uloc))
    9464         3703 :                 var_regno_delete (set, REGNO (uloc));
    9465     32120873 :               else if (MEM_P (uloc))
    9466              :                 {
    9467      8723348 :                   gcc_checking_assert (GET_CODE (vloc) == MEM);
    9468      8723348 :                   gcc_checking_assert (vloc == dstv);
    9469              :                   if (vloc != dstv)
    9470              :                     clobber_overlapping_mems (set, vloc);
    9471              :                 }
    9472              : 
    9473     32229352 :               val_store (set, val, dstv, insn, true);
    9474              : 
    9475     32229352 :               emit_notes_for_changes (next_insn, EMIT_NOTE_BEFORE_INSN,
    9476              :                                       set->vars);
    9477              :             }
    9478     32229352 :             break;
    9479              : 
    9480        34654 :           case MO_SET:
    9481        34654 :             {
    9482        34654 :               rtx loc = mo->u.loc;
    9483        34654 :               rtx set_src = NULL;
    9484              : 
    9485        34654 :               if (GET_CODE (loc) == SET)
    9486              :                 {
    9487        34404 :                   set_src = SET_SRC (loc);
    9488        34404 :                   loc = SET_DEST (loc);
    9489              :                 }
    9490              : 
    9491        34654 :               if (REG_P (loc))
    9492        34654 :                 var_reg_delete_and_set (set, loc, true, VAR_INIT_STATUS_INITIALIZED,
    9493              :                                         set_src);
    9494              :               else
    9495            0 :                 var_mem_delete_and_set (set, loc, true, VAR_INIT_STATUS_INITIALIZED,
    9496              :                                         set_src);
    9497              : 
    9498        34654 :               emit_notes_for_changes (next_insn, EMIT_NOTE_BEFORE_INSN,
    9499              :                                       set->vars);
    9500              :             }
    9501        34654 :             break;
    9502              : 
    9503        43098 :           case MO_COPY:
    9504        43098 :             {
    9505        43098 :               rtx loc = mo->u.loc;
    9506        43098 :               enum var_init_status src_status;
    9507        43098 :               rtx set_src = NULL;
    9508              : 
    9509        43098 :               if (GET_CODE (loc) == SET)
    9510              :                 {
    9511        43098 :                   set_src = SET_SRC (loc);
    9512        43098 :                   loc = SET_DEST (loc);
    9513              :                 }
    9514              : 
    9515        43098 :               src_status = find_src_status (set, set_src);
    9516        43098 :               set_src = find_src_set_src (set, set_src);
    9517              : 
    9518        43098 :               if (REG_P (loc))
    9519        43098 :                 var_reg_delete_and_set (set, loc, false, src_status, set_src);
    9520              :               else
    9521            0 :                 var_mem_delete_and_set (set, loc, false, src_status, set_src);
    9522              : 
    9523        43098 :               emit_notes_for_changes (next_insn, EMIT_NOTE_BEFORE_INSN,
    9524              :                                       set->vars);
    9525              :             }
    9526        43098 :             break;
    9527              : 
    9528     20653164 :           case MO_USE_NO_VAR:
    9529     20653164 :             {
    9530     20653164 :               rtx loc = mo->u.loc;
    9531              : 
    9532     20653164 :               if (REG_P (loc))
    9533     20653164 :                 var_reg_delete (set, loc, false);
    9534              :               else
    9535            0 :                 var_mem_delete (set, loc, false);
    9536              : 
    9537     20653164 :               emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN, set->vars);
    9538              :             }
    9539     20653164 :             break;
    9540              : 
    9541      6110415 :           case MO_CLOBBER:
    9542      6110415 :             {
    9543      6110415 :               rtx loc = mo->u.loc;
    9544              : 
    9545      6110415 :               if (REG_P (loc))
    9546      6110412 :                 var_reg_delete (set, loc, true);
    9547              :               else
    9548            3 :                 var_mem_delete (set, loc, true);
    9549              : 
    9550      6110415 :               emit_notes_for_changes (next_insn, EMIT_NOTE_BEFORE_INSN,
    9551              :                                       set->vars);
    9552              :             }
    9553      6110415 :             break;
    9554              : 
    9555      4314384 :           case MO_ADJUST:
    9556      4314384 :             set->stack_adjust += mo->u.adjust;
    9557      4314384 :             break;
    9558              :         }
    9559              :     }
    9560      7495353 : }
    9561              : 
    9562              : /* Emit notes for the whole function.  */
    9563              : 
    9564              : static void
    9565       509709 : vt_emit_notes (void)
    9566              : {
    9567       509709 :   basic_block bb;
    9568       509709 :   dataflow_set cur;
    9569              : 
    9570       509709 :   gcc_assert (changed_variables->is_empty ());
    9571              : 
    9572              :   /* Free memory occupied by the out hash tables, as they aren't used
    9573              :      anymore.  */
    9574      8005062 :   FOR_EACH_BB_FN (bb, cfun)
    9575      7495353 :     dataflow_set_clear (&VTI (bb)->out);
    9576              : 
    9577              :   /* Enable emitting notes by functions (mainly by set_variable_part and
    9578              :      delete_variable_part).  */
    9579       509709 :   emit_notes = true;
    9580              : 
    9581       509709 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
    9582       509668 :     dropped_values = new variable_table_type (cselib_get_next_uid () * 2);
    9583              : 
    9584       509709 :   dataflow_set_init (&cur);
    9585              : 
    9586      8005062 :   FOR_EACH_BB_FN (bb, cfun)
    9587              :     {
    9588              :       /* Emit the notes for changes of variable locations between two
    9589              :          subsequent basic blocks.  */
    9590      7495353 :       emit_notes_for_differences (BB_HEAD (bb), &cur, &VTI (bb)->in);
    9591              : 
    9592      7495353 :       if (MAY_HAVE_DEBUG_BIND_INSNS)
    9593      7495270 :         local_get_addr_cache = new hash_map<rtx, rtx>;
    9594              : 
    9595              :       /* Emit the notes for the changes in the basic block itself.  */
    9596      7495353 :       emit_notes_in_bb (bb, &cur);
    9597              : 
    9598      7495353 :       if (MAY_HAVE_DEBUG_BIND_INSNS)
    9599     14990540 :         delete local_get_addr_cache;
    9600      7495353 :       local_get_addr_cache = NULL;
    9601              : 
    9602              :       /* Free memory occupied by the in hash table, we won't need it
    9603              :          again.  */
    9604      7495353 :       dataflow_set_clear (&VTI (bb)->in);
    9605              :     }
    9606              : 
    9607       509709 :   if (flag_checking)
    9608       509708 :     shared_hash_htab (cur.vars)
    9609              :       ->traverse <variable_table_type *, emit_notes_for_differences_1>
    9610       509708 :         (shared_hash_htab (empty_shared_hash));
    9611              : 
    9612       509709 :   dataflow_set_destroy (&cur);
    9613              : 
    9614       509709 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
    9615       509668 :     delete dropped_values;
    9616       509709 :   dropped_values = NULL;
    9617              : 
    9618       509709 :   emit_notes = false;
    9619       509709 : }
    9620              : 
    9621              : /* If there is a declaration and offset associated with register/memory RTL
    9622              :    assign declaration to *DECLP and offset to *OFFSETP, and return true.  */
    9623              : 
    9624              : static bool
    9625       983074 : vt_get_decl_and_offset (rtx rtl, tree *declp, poly_int64 *offsetp)
    9626              : {
    9627       983074 :   if (REG_P (rtl))
    9628              :     {
    9629       615217 :       if (REG_ATTRS (rtl))
    9630              :         {
    9631       615217 :           *declp = REG_EXPR (rtl);
    9632       615217 :           *offsetp = REG_OFFSET (rtl);
    9633       615217 :           return true;
    9634              :         }
    9635              :     }
    9636       367857 :   else if (GET_CODE (rtl) == PARALLEL)
    9637              :     {
    9638        23604 :       tree decl = NULL_TREE;
    9639        23604 :       HOST_WIDE_INT offset = MAX_VAR_PARTS;
    9640        23604 :       int len = XVECLEN (rtl, 0), i;
    9641              : 
    9642        70587 :       for (i = 0; i < len; i++)
    9643              :         {
    9644        46983 :           rtx reg = XEXP (XVECEXP (rtl, 0, i), 0);
    9645        46983 :           if (!REG_P (reg) || !REG_ATTRS (reg))
    9646              :             break;
    9647        46983 :           if (!decl)
    9648        23604 :             decl = REG_EXPR (reg);
    9649        46983 :           if (REG_EXPR (reg) != decl)
    9650              :             break;
    9651        46983 :           HOST_WIDE_INT this_offset;
    9652        46983 :           if (!track_offset_p (REG_OFFSET (reg), &this_offset))
    9653              :             break;
    9654        46983 :           offset = MIN (offset, this_offset);
    9655              :         }
    9656              : 
    9657        23604 :       if (i == len)
    9658              :         {
    9659        23604 :           *declp = decl;
    9660        23604 :           *offsetp = offset;
    9661        23604 :           return true;
    9662              :         }
    9663              :     }
    9664       344253 :   else if (MEM_P (rtl))
    9665              :     {
    9666       344203 :       if (MEM_ATTRS (rtl))
    9667              :         {
    9668       344174 :           *declp = MEM_EXPR (rtl);
    9669       344174 :           *offsetp = int_mem_offset (rtl);
    9670       344174 :           return true;
    9671              :         }
    9672              :     }
    9673              :   return false;
    9674              : }
    9675              : 
    9676              : /* Record the value for the ENTRY_VALUE of RTL as a global equivalence
    9677              :    of VAL.  */
    9678              : 
    9679              : static void
    9680       689275 : record_entry_value (cselib_val *val, rtx rtl)
    9681              : {
    9682       689275 :   rtx ev = gen_rtx_ENTRY_VALUE (GET_MODE (rtl));
    9683              : 
    9684       689275 :   ENTRY_VALUE_EXP (ev) = rtl;
    9685              : 
    9686       689275 :   cselib_add_permanent_equiv (val, ev, get_insns ());
    9687       689275 : }
    9688              : 
    9689              : /* Insert function parameter PARM in IN and OUT sets of ENTRY_BLOCK.  */
    9690              : 
    9691              : static void
    9692      1010910 : vt_add_function_parameter (tree parm)
    9693              : {
    9694      1010910 :   rtx decl_rtl = DECL_RTL_IF_SET (parm);
    9695      1010910 :   rtx incoming = DECL_INCOMING_RTL (parm);
    9696      1010910 :   tree decl;
    9697      1010910 :   machine_mode mode;
    9698      1010910 :   poly_int64 offset;
    9699      1010910 :   dataflow_set *out;
    9700      1010910 :   decl_or_value dv;
    9701      1010910 :   bool incoming_ok = true;
    9702              : 
    9703      1010910 :   if (TREE_CODE (parm) != PARM_DECL)
    9704        47210 :     return;
    9705              : 
    9706      1010910 :   if (!decl_rtl || !incoming)
    9707              :     return;
    9708              : 
    9709      1010910 :   if (GET_MODE (decl_rtl) == BLKmode || GET_MODE (incoming) == BLKmode)
    9710              :     return;
    9711              : 
    9712              :   /* If there is a DRAP register or a pseudo in internal_arg_pointer,
    9713              :      rewrite the incoming location of parameters passed on the stack
    9714              :      into MEMs based on the argument pointer, so that incoming doesn't
    9715              :      depend on a pseudo.  */
    9716       983024 :   poly_int64 incoming_offset = 0;
    9717       983024 :   if (MEM_P (incoming)
    9718       983024 :       && (strip_offset (XEXP (incoming, 0), &incoming_offset)
    9719       344203 :           == crtl->args.internal_arg_pointer))
    9720              :     {
    9721          364 :       HOST_WIDE_INT off = -FIRST_PARM_OFFSET (current_function_decl);
    9722          364 :       incoming
    9723          364 :         = replace_equiv_address_nv (incoming,
    9724          364 :                                     plus_constant (Pmode,
    9725              :                                                    arg_pointer_rtx,
    9726              :                                                    off + incoming_offset));
    9727              :     }
    9728              : 
    9729              : #ifdef HAVE_window_save
    9730              :   /* DECL_INCOMING_RTL uses the INCOMING_REGNO of parameter registers.
    9731              :      If the target machine has an explicit window save instruction, the
    9732              :      actual entry value is the corresponding OUTGOING_REGNO instead.  */
    9733              :   if (HAVE_window_save && !crtl->uses_only_leaf_regs)
    9734              :     {
    9735              :       if (REG_P (incoming)
    9736              :           && HARD_REGISTER_P (incoming)
    9737              :           && OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
    9738              :         {
    9739              :           parm_reg p;
    9740              :           p.incoming = incoming;
    9741              :           incoming
    9742              :             = gen_rtx_REG_offset (incoming, GET_MODE (incoming),
    9743              :                                   OUTGOING_REGNO (REGNO (incoming)), 0);
    9744              :           p.outgoing = incoming;
    9745              :           vec_safe_push (windowed_parm_regs, p);
    9746              :         }
    9747              :       else if (GET_CODE (incoming) == PARALLEL)
    9748              :         {
    9749              :           rtx outgoing
    9750              :             = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (XVECLEN (incoming, 0)));
    9751              :           int i;
    9752              : 
    9753              :           for (i = 0; i < XVECLEN (incoming, 0); i++)
    9754              :             {
    9755              :               rtx reg = XEXP (XVECEXP (incoming, 0, i), 0);
    9756              :               parm_reg p;
    9757              :               p.incoming = reg;
    9758              :               reg = gen_rtx_REG_offset (reg, GET_MODE (reg),
    9759              :                                         OUTGOING_REGNO (REGNO (reg)), 0);
    9760              :               p.outgoing = reg;
    9761              :               XVECEXP (outgoing, 0, i)
    9762              :                 = gen_rtx_EXPR_LIST (VOIDmode, reg,
    9763              :                                      XEXP (XVECEXP (incoming, 0, i), 1));
    9764              :               vec_safe_push (windowed_parm_regs, p);
    9765              :             }
    9766              : 
    9767              :           incoming = outgoing;
    9768              :         }
    9769              :       else if (MEM_P (incoming)
    9770              :                && REG_P (XEXP (incoming, 0))
    9771              :                && HARD_REGISTER_P (XEXP (incoming, 0)))
    9772              :         {
    9773              :           rtx reg = XEXP (incoming, 0);
    9774              :           if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
    9775              :             {
    9776              :               parm_reg p;
    9777              :               p.incoming = reg;
    9778              :               reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
    9779              :               p.outgoing = reg;
    9780              :               vec_safe_push (windowed_parm_regs, p);
    9781              :               incoming = replace_equiv_address_nv (incoming, reg);
    9782              :             }
    9783              :         }
    9784              :     }
    9785              : #endif
    9786              : 
    9787       983024 :   if (!vt_get_decl_and_offset (incoming, &decl, &offset))
    9788              :     {
    9789           79 :       incoming_ok = false;
    9790           79 :       if (MEM_P (incoming))
    9791              :         {
    9792              :           /* This means argument is passed by invisible reference.  */
    9793           29 :           offset = 0;
    9794           29 :           decl = parm;
    9795              :         }
    9796              :       else
    9797              :         {
    9798           50 :           if (!vt_get_decl_and_offset (decl_rtl, &decl, &offset))
    9799              :             return;
    9800           50 :           offset += byte_lowpart_offset (GET_MODE (incoming),
    9801           50 :                                          GET_MODE (decl_rtl));
    9802              :         }
    9803              :     }
    9804              : 
    9805       983024 :   if (!decl)
    9806              :     return;
    9807              : 
    9808       983024 :   if (parm != decl)
    9809              :     {
    9810              :       /* If that DECL_RTL wasn't a pseudo that got spilled to
    9811              :          memory, bail out.  Otherwise, the spill slot sharing code
    9812              :          will force the memory to reference spill_slot_decl (%sfp),
    9813              :          so we don't match above.  That's ok, the pseudo must have
    9814              :          referenced the entire parameter, so just reset OFFSET.  */
    9815            0 :       if (decl != get_spill_slot_decl (false))
    9816              :         return;
    9817            0 :       offset = 0;
    9818              :     }
    9819              : 
    9820       983024 :   HOST_WIDE_INT const_offset;
    9821       983024 :   if (!track_loc_p (incoming, parm, offset, false, &mode, &const_offset))
    9822              :     return;
    9823              : 
    9824       963700 :   out = &VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->out;
    9825              : 
    9826       963700 :   dv = dv_from_decl (parm);
    9827              : 
    9828       963700 :   if (target_for_debug_bind (parm)
    9829              :       /* We can't deal with these right now, because this kind of
    9830              :          variable is single-part.  ??? We could handle parallels
    9831              :          that describe multiple locations for the same single
    9832              :          value, but ATM we don't.  */
    9833       963700 :       && GET_CODE (incoming) != PARALLEL)
    9834              :     {
    9835       897934 :       cselib_val *val;
    9836       897934 :       rtx lowpart;
    9837              : 
    9838              :       /* ??? We shouldn't ever hit this, but it may happen because
    9839              :          arguments passed by invisible reference aren't dealt with
    9840              :          above: incoming-rtl will have Pmode rather than the
    9841              :          expected mode for the type.  */
    9842       897934 :       if (const_offset)
    9843              :         return;
    9844              : 
    9845       897934 :       lowpart = var_lowpart (mode, incoming);
    9846       897934 :       if (!lowpart)
    9847              :         return;
    9848              : 
    9849       897934 :       val = cselib_lookup_from_insn (lowpart, mode, true,
    9850              :                                      VOIDmode, get_insns ());
    9851              : 
    9852              :       /* ??? Float-typed values in memory are not handled by
    9853              :          cselib.  */
    9854       897934 :       if (val)
    9855              :         {
    9856       897934 :           preserve_value (val);
    9857       897934 :           set_variable_part (out, val->val_rtx, dv, const_offset,
    9858              :                              VAR_INIT_STATUS_INITIALIZED, NULL, INSERT);
    9859       897934 :           dv = dv_from_value (val->val_rtx);
    9860              :         }
    9861              : 
    9862       897934 :       if (MEM_P (incoming))
    9863              :         {
    9864       319643 :           val = cselib_lookup_from_insn (XEXP (incoming, 0), mode, true,
    9865              :                                          VOIDmode, get_insns ());
    9866       319643 :           if (val)
    9867              :             {
    9868       319643 :               preserve_value (val);
    9869       319643 :               incoming = replace_equiv_address_nv (incoming, val->val_rtx);
    9870              :             }
    9871              :         }
    9872              :     }
    9873              : 
    9874       963700 :   if (REG_P (incoming))
    9875              :     {
    9876       599243 :       incoming = var_lowpart (mode, incoming);
    9877       599243 :       gcc_assert (REGNO (incoming) < FIRST_PSEUDO_REGISTER);
    9878       599243 :       attrs_list_insert (&out->regs[REGNO (incoming)], dv, const_offset,
    9879              :                          incoming);
    9880       599243 :       set_variable_part (out, incoming, dv, const_offset,
    9881              :                          VAR_INIT_STATUS_INITIALIZED, NULL, INSERT);
    9882       599243 :       if (dv_is_value_p (dv))
    9883              :         {
    9884       578241 :           record_entry_value (CSELIB_VAL_PTR (dv_as_value (dv)), incoming);
    9885       578241 :           if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE
    9886       578241 :               && INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (parm))))
    9887              :             {
    9888         8824 :               machine_mode indmode
    9889         8824 :                 = TYPE_MODE (TREE_TYPE (TREE_TYPE (parm)));
    9890         8824 :               rtx mem = gen_rtx_MEM (indmode, incoming);
    9891         8824 :               cselib_val *val = cselib_lookup_from_insn (mem, indmode, true,
    9892              :                                                          VOIDmode,
    9893              :                                                          get_insns ());
    9894         8824 :               if (val)
    9895              :                 {
    9896         8824 :                   preserve_value (val);
    9897         8824 :                   record_entry_value (val, mem);
    9898         8824 :                   set_variable_part (out, mem, dv_from_value (val->val_rtx), 0,
    9899              :                                      VAR_INIT_STATUS_INITIALIZED, NULL, INSERT);
    9900              :                 }
    9901              :             }
    9902              : 
    9903       578241 :           if (GET_MODE_CLASS (mode) == MODE_INT)
    9904              :             {
    9905       568547 :               machine_mode wider_mode_iter;
    9906       670757 :               FOR_EACH_WIDER_MODE (wider_mode_iter, mode)
    9907              :                 {
    9908      1634457 :                   if (!HWI_COMPUTABLE_MODE_P (wider_mode_iter))
    9909              :                     break;
    9910       102210 :                   rtx wider_reg
    9911       102210 :                     = gen_rtx_REG (wider_mode_iter, REGNO (incoming));
    9912       102210 :                   cselib_val *wider_val
    9913       102210 :                     = cselib_lookup_from_insn (wider_reg, wider_mode_iter, 1,
    9914              :                                                VOIDmode, get_insns ());
    9915       102210 :                   preserve_value (wider_val);
    9916       102210 :                   record_entry_value (wider_val, wider_reg);
    9917              :                 }
    9918              :             }
    9919              :         }
    9920              :     }
    9921       364457 :   else if (GET_CODE (incoming) == PARALLEL && !dv_onepart_p (dv))
    9922              :     {
    9923        22294 :       int i;
    9924              : 
    9925              :       /* The following code relies on vt_get_decl_and_offset returning true for
    9926              :          incoming, which might not be always the case.  */
    9927        22294 :       if (!incoming_ok)
    9928              :         return;
    9929        66879 :       for (i = 0; i < XVECLEN (incoming, 0); i++)
    9930              :         {
    9931        44585 :           rtx reg = XEXP (XVECEXP (incoming, 0, i), 0);
    9932              :           /* vt_get_decl_and_offset has already checked that the offset
    9933              :              is a valid variable part.  */
    9934        44585 :           const_offset = get_tracked_reg_offset (reg);
    9935        44585 :           gcc_assert (REGNO (reg) < FIRST_PSEUDO_REGISTER);
    9936        44585 :           attrs_list_insert (&out->regs[REGNO (reg)], dv, const_offset, reg);
    9937        44585 :           set_variable_part (out, reg, dv, const_offset,
    9938              :                              VAR_INIT_STATUS_INITIALIZED, NULL, INSERT);
    9939              :         }
    9940              :     }
    9941       342163 :   else if (MEM_P (incoming))
    9942              :     {
    9943       341132 :       incoming = var_lowpart (mode, incoming);
    9944       341132 :       set_variable_part (out, incoming, dv, const_offset,
    9945              :                          VAR_INIT_STATUS_INITIALIZED, NULL, INSERT);
    9946              :     }
    9947              : }
    9948              : 
    9949              : /* Insert function parameters to IN and OUT sets of ENTRY_BLOCK.  */
    9950              : 
    9951              : static void
    9952       509710 : vt_add_function_parameters (void)
    9953              : {
    9954       509710 :   tree parm;
    9955              : 
    9956       509710 :   for (parm = DECL_ARGUMENTS (current_function_decl);
    9957      1472769 :        parm; parm = DECL_CHAIN (parm))
    9958       963059 :     vt_add_function_parameter (parm);
    9959              : 
    9960       509710 :   if (DECL_HAS_VALUE_EXPR_P (DECL_RESULT (current_function_decl)))
    9961              :     {
    9962        47851 :       tree vexpr = DECL_VALUE_EXPR (DECL_RESULT (current_function_decl));
    9963              : 
    9964        47851 :       if (INDIRECT_REF_P (vexpr))
    9965        41568 :         vexpr = TREE_OPERAND (vexpr, 0);
    9966              : 
    9967        47851 :       if (TREE_CODE (vexpr) == PARM_DECL
    9968        47851 :           && DECL_ARTIFICIAL (vexpr)
    9969        47851 :           && !DECL_IGNORED_P (vexpr)
    9970        95702 :           && DECL_NAMELESS (vexpr))
    9971        47851 :         vt_add_function_parameter (vexpr);
    9972              :     }
    9973       509710 : }
    9974              : 
    9975              : /* Initialize cfa_base_rtx, create a preserved VALUE for it and
    9976              :    ensure it isn't flushed during cselib_reset_table.
    9977              :    Can be called only if frame_pointer_rtx resp. arg_pointer_rtx
    9978              :    has been eliminated.  */
    9979              : 
    9980              : static void
    9981       508694 : vt_init_cfa_base (void)
    9982              : {
    9983       508694 :   cselib_val *val;
    9984              : 
    9985              : #ifdef FRAME_POINTER_CFA_OFFSET
    9986              :   cfa_base_rtx = frame_pointer_rtx;
    9987              :   cfa_base_offset = -FRAME_POINTER_CFA_OFFSET (current_function_decl);
    9988              : #else
    9989       508694 :   cfa_base_rtx = arg_pointer_rtx;
    9990       508694 :   cfa_base_offset = -ARG_POINTER_CFA_OFFSET (current_function_decl);
    9991              : #endif
    9992       508694 :   if (cfa_base_rtx == hard_frame_pointer_rtx
    9993       508694 :       || !fixed_regs[REGNO (cfa_base_rtx)])
    9994              :     {
    9995            0 :       cfa_base_rtx = NULL_RTX;
    9996            0 :       return;
    9997              :     }
    9998       508694 :   if (!MAY_HAVE_DEBUG_BIND_INSNS)
    9999              :     return;
   10000              : 
   10001              :   /* Tell alias analysis that cfa_base_rtx should share
   10002              :      find_base_term value with stack pointer or hard frame pointer.  */
   10003       508653 :   if (!frame_pointer_needed)
   10004       485865 :     vt_equate_reg_base_value (cfa_base_rtx, stack_pointer_rtx);
   10005        22788 :   else if (!crtl->stack_realign_tried)
   10006        22188 :     vt_equate_reg_base_value (cfa_base_rtx, hard_frame_pointer_rtx);
   10007              : 
   10008       508653 :   val = cselib_lookup_from_insn (cfa_base_rtx, GET_MODE (cfa_base_rtx), 1,
   10009              :                                  VOIDmode, get_insns ());
   10010       508653 :   preserve_value (val);
   10011       508653 :   cselib_preserve_cfa_base_value (val, REGNO (cfa_base_rtx));
   10012              : }
   10013              : 
   10014              : /* Reemit INSN, a MARKER_DEBUG_INSN, as a note.  */
   10015              : 
   10016              : static rtx_insn *
   10017     11949559 : reemit_marker_as_note (rtx_insn *insn)
   10018              : {
   10019     11949559 :   gcc_checking_assert (DEBUG_MARKER_INSN_P (insn));
   10020              : 
   10021     11949559 :   enum insn_note kind = INSN_DEBUG_MARKER_KIND (insn);
   10022              : 
   10023              :   switch (kind)
   10024              :     {
   10025     11949559 :     case NOTE_INSN_BEGIN_STMT:
   10026     11949559 :     case NOTE_INSN_INLINE_ENTRY:
   10027     11949559 :       {
   10028     11949559 :         rtx_insn *note = NULL;
   10029     11949559 :         if (cfun->debug_nonbind_markers)
   10030              :           {
   10031     11709744 :             note = emit_note_before (kind, insn);
   10032     11709744 :             NOTE_MARKER_LOCATION (note) = INSN_LOCATION (insn);
   10033              :           }
   10034     11949559 :         delete_insn (insn);
   10035     11949559 :         return note;
   10036              :       }
   10037              : 
   10038            0 :     default:
   10039            0 :       gcc_unreachable ();
   10040              :     }
   10041              : }
   10042              : 
   10043              : /* Allocate and initialize the data structures for variable tracking
   10044              :    and parse the RTL to get the micro operations.  */
   10045              : 
   10046              : static bool
   10047       509775 : vt_initialize (void)
   10048              : {
   10049       509775 :   basic_block bb;
   10050       509775 :   poly_int64 fp_cfa_offset = -1;
   10051              : 
   10052       509775 :   alloc_aux_for_blocks (sizeof (variable_tracking_info));
   10053              : 
   10054       509775 :   empty_shared_hash = shared_hash_pool.allocate ();
   10055       509775 :   empty_shared_hash->refcount = 1;
   10056       509775 :   empty_shared_hash->htab = new variable_table_type (1);
   10057       509775 :   changed_variables = new variable_table_type (10);
   10058              : 
   10059              :   /* Init the IN and OUT sets.  */
   10060      9025652 :   FOR_ALL_BB_FN (bb, cfun)
   10061              :     {
   10062      8515877 :       VTI (bb)->visited = false;
   10063      8515877 :       VTI (bb)->flooded = false;
   10064      8515877 :       dataflow_set_init (&VTI (bb)->in);
   10065      8515877 :       dataflow_set_init (&VTI (bb)->out);
   10066      8515877 :       VTI (bb)->permp = NULL;
   10067              :     }
   10068              : 
   10069       509775 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
   10070              :     {
   10071       509734 :       cselib_init (CSELIB_RECORD_MEMORY | CSELIB_PRESERVE_CONSTANTS);
   10072       509734 :       scratch_regs = BITMAP_ALLOC (NULL);
   10073       509734 :       preserved_values.create (256);
   10074       509734 :       global_get_addr_cache = new hash_map<rtx, rtx>;
   10075              :     }
   10076              :   else
   10077              :     {
   10078           41 :       scratch_regs = NULL;
   10079           41 :       global_get_addr_cache = NULL;
   10080              :     }
   10081              : 
   10082       509775 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
   10083              :     {
   10084       509734 :       rtx reg, expr;
   10085       509734 :       int ofst;
   10086       509734 :       cselib_val *val;
   10087              : 
   10088              : #ifdef FRAME_POINTER_CFA_OFFSET
   10089              :       reg = frame_pointer_rtx;
   10090              :       ofst = FRAME_POINTER_CFA_OFFSET (current_function_decl);
   10091              : #else
   10092       509734 :       reg = arg_pointer_rtx;
   10093       509734 :       ofst = ARG_POINTER_CFA_OFFSET (current_function_decl);
   10094              : #endif
   10095              : 
   10096       509734 :       ofst -= INCOMING_FRAME_SP_OFFSET;
   10097              : 
   10098       509734 :       val = cselib_lookup_from_insn (reg, GET_MODE (reg), 1,
   10099              :                                      VOIDmode, get_insns ());
   10100       509734 :       preserve_value (val);
   10101       509734 :       if (reg != hard_frame_pointer_rtx && fixed_regs[REGNO (reg)])
   10102       509734 :         cselib_preserve_cfa_base_value (val, REGNO (reg));
   10103       509734 :       if (ofst)
   10104              :         {
   10105       509734 :           cselib_val *valsp
   10106      1019468 :             = cselib_lookup_from_insn (stack_pointer_rtx,
   10107       509734 :                                        GET_MODE (stack_pointer_rtx), 1,
   10108              :                                        VOIDmode, get_insns ());
   10109       509734 :           preserve_value (valsp);
   10110       509734 :           expr = plus_constant (GET_MODE (reg), reg, ofst);
   10111              :           /* This cselib_add_permanent_equiv call needs to be done before
   10112              :              the other cselib_add_permanent_equiv a few lines later,
   10113              :              because after that one is done, cselib_lookup on this expr
   10114              :              will due to the cselib SP_DERIVED_VALUE_P optimizations
   10115              :              return valsp and so no permanent equivalency will be added.  */
   10116       509734 :           cselib_add_permanent_equiv (valsp, expr, get_insns ());
   10117              :         }
   10118              : 
   10119      1019468 :       expr = plus_constant (GET_MODE (stack_pointer_rtx),
   10120       509734 :                             stack_pointer_rtx, -ofst);
   10121       509734 :       cselib_add_permanent_equiv (val, expr, get_insns ());
   10122              :     }
   10123              : 
   10124              :   /* In order to factor out the adjustments made to the stack pointer or to
   10125              :      the hard frame pointer and thus be able to use DW_OP_fbreg operations
   10126              :      instead of individual location lists, we're going to rewrite MEMs based
   10127              :      on them into MEMs based on the CFA by de-eliminating stack_pointer_rtx
   10128              :      or hard_frame_pointer_rtx to the virtual CFA pointer frame_pointer_rtx
   10129              :      resp. arg_pointer_rtx.  We can do this either when there is no frame
   10130              :      pointer in the function and stack adjustments are consistent for all
   10131              :      basic blocks or when there is a frame pointer and no stack realignment.
   10132              :      But we first have to check that frame_pointer_rtx resp. arg_pointer_rtx
   10133              :      has been eliminated.  */
   10134       509775 :   if (!frame_pointer_needed)
   10135              :     {
   10136       486107 :       rtx reg, elim;
   10137              : 
   10138       486107 :       if (!vt_stack_adjustments ())
   10139              :         return false;
   10140              : 
   10141              : #ifdef FRAME_POINTER_CFA_OFFSET
   10142              :       reg = frame_pointer_rtx;
   10143              : #else
   10144       486042 :       reg = arg_pointer_rtx;
   10145              : #endif
   10146       486042 :       elim = (ira_use_lra_p
   10147       486042 :               ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX)
   10148            0 :               : eliminate_regs (reg, VOIDmode, NULL_RTX));
   10149       486042 :       if (elim != reg)
   10150              :         {
   10151       486042 :           if (GET_CODE (elim) == PLUS)
   10152       486042 :             elim = XEXP (elim, 0);
   10153       486042 :           if (elim == stack_pointer_rtx)
   10154       485906 :             vt_init_cfa_base ();
   10155              :         }
   10156              :     }
   10157        23668 :   else if (!crtl->stack_realign_tried)
   10158              :     {
   10159        22188 :       rtx reg, elim;
   10160              : 
   10161              : #ifdef FRAME_POINTER_CFA_OFFSET
   10162              :       reg = frame_pointer_rtx;
   10163              :       fp_cfa_offset = FRAME_POINTER_CFA_OFFSET (current_function_decl);
   10164              : #else
   10165        22188 :       reg = arg_pointer_rtx;
   10166        22188 :       fp_cfa_offset = ARG_POINTER_CFA_OFFSET (current_function_decl);
   10167              : #endif
   10168        22188 :       elim = (ira_use_lra_p
   10169        22188 :               ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX)
   10170            0 :               : eliminate_regs (reg, VOIDmode, NULL_RTX));
   10171        22188 :       if (elim != reg)
   10172              :         {
   10173        22188 :           if (GET_CODE (elim) == PLUS)
   10174              :             {
   10175        22188 :               fp_cfa_offset -= rtx_to_poly_int64 (XEXP (elim, 1));
   10176        22188 :               elim = XEXP (elim, 0);
   10177              :             }
   10178        22188 :           if (elim != hard_frame_pointer_rtx)
   10179              :             fp_cfa_offset = -1;
   10180              :         }
   10181              :       else
   10182              :         fp_cfa_offset = -1;
   10183              :     }
   10184              : 
   10185              :   /* If the stack is realigned and a DRAP register is used, we're going to
   10186              :      rewrite MEMs based on it representing incoming locations of parameters
   10187              :      passed on the stack into MEMs based on the argument pointer.  Although
   10188              :      we aren't going to rewrite other MEMs, we still need to initialize the
   10189              :      virtual CFA pointer in order to ensure that the argument pointer will
   10190              :      be seen as a constant throughout the function.
   10191              : 
   10192              :      ??? This doesn't work if FRAME_POINTER_CFA_OFFSET is defined.  */
   10193         1480 :   else if (stack_realign_drap)
   10194              :     {
   10195          600 :       rtx reg, elim;
   10196              : 
   10197              : #ifdef FRAME_POINTER_CFA_OFFSET
   10198              :       reg = frame_pointer_rtx;
   10199              : #else
   10200          600 :       reg = arg_pointer_rtx;
   10201              : #endif
   10202          600 :       elim = (ira_use_lra_p
   10203          600 :               ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX)
   10204            0 :               : eliminate_regs (reg, VOIDmode, NULL_RTX));
   10205          600 :       if (elim != reg)
   10206              :         {
   10207          600 :           if (GET_CODE (elim) == PLUS)
   10208          600 :             elim = XEXP (elim, 0);
   10209          600 :           if (elim == hard_frame_pointer_rtx)
   10210          600 :             vt_init_cfa_base ();
   10211              :         }
   10212              :     }
   10213              : 
   10214       509710 :   hard_frame_pointer_adjustment = -1;
   10215              : 
   10216       509710 :   vt_add_function_parameters ();
   10217              : 
   10218       509710 :   bool record_sp_value = false;
   10219      4990739 :   FOR_EACH_BB_FN (bb, cfun)
   10220              :     {
   10221      4481029 :       rtx_insn *insn;
   10222      4481029 :       basic_block first_bb, last_bb;
   10223              : 
   10224      4481029 :       if (MAY_HAVE_DEBUG_BIND_INSNS)
   10225              :         {
   10226      4480959 :           cselib_record_sets_hook = add_with_sets;
   10227      4480959 :           if (dump_file && (dump_flags & TDF_DETAILS))
   10228            1 :             fprintf (dump_file, "first value: %i\n",
   10229              :                      cselib_get_next_uid ());
   10230              :         }
   10231              : 
   10232      4481029 :       if (MAY_HAVE_DEBUG_BIND_INSNS
   10233      4480959 :           && cfa_base_rtx
   10234      4438441 :           && !frame_pointer_needed
   10235      4024406 :           && record_sp_value)
   10236      3538541 :         cselib_record_sp_cfa_base_equiv (-cfa_base_offset
   10237      3538541 :                                          - VTI (bb)->in.stack_adjust,
   10238              :                                          BB_HEAD (bb));
   10239      4481029 :       record_sp_value = true;
   10240              : 
   10241      4481029 :       first_bb = bb;
   10242     10509679 :       for (;;)
   10243              :         {
   10244      7495354 :           edge e;
   10245      7495354 :           if (bb->next_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
   10246      7495354 :               || ! single_pred_p (bb->next_bb))
   10247              :             break;
   10248      4822651 :           e = find_edge (bb, bb->next_bb);
   10249      4822651 :           if (! e || (e->flags & EDGE_FALLTHRU) == 0)
   10250              :             break;
   10251      3014325 :           bb = bb->next_bb;
   10252      3014325 :         }
   10253      4481029 :       last_bb = bb;
   10254              : 
   10255              :       /* Add the micro-operations to the vector.  */
   10256     11976383 :       FOR_BB_BETWEEN (bb, first_bb, last_bb->next_bb, next_bb)
   10257              :         {
   10258      7495354 :           HOST_WIDE_INT offset = VTI (bb)->out.stack_adjust;
   10259      7495354 :           VTI (bb)->out.stack_adjust = VTI (bb)->in.stack_adjust;
   10260              : 
   10261      7495354 :           rtx_insn *next;
   10262    231995068 :           FOR_BB_INSNS_SAFE (bb, insn, next)
   10263              :             {
   10264    112249857 :               if (INSN_P (insn))
   10265              :                 {
   10266     95704618 :                   HOST_WIDE_INT pre = 0, post = 0;
   10267              : 
   10268     95704618 :                   if (!frame_pointer_needed)
   10269              :                     {
   10270     86372655 :                       insn_stack_adjust_offset_pre_post (insn, &pre, &post);
   10271     86372655 :                       if (pre)
   10272              :                         {
   10273      1949590 :                           micro_operation mo;
   10274      1949590 :                           mo.type = MO_ADJUST;
   10275      1949590 :                           mo.u.adjust = pre;
   10276      1949590 :                           mo.insn = insn;
   10277      1949590 :                           if (dump_file && (dump_flags & TDF_DETAILS))
   10278            1 :                             log_op_type (PATTERN (insn), bb, insn,
   10279              :                                          MO_ADJUST, dump_file);
   10280      1949590 :                           VTI (bb)->mos.safe_push (mo);
   10281              :                         }
   10282              :                     }
   10283              : 
   10284     95704618 :                   cselib_hook_called = false;
   10285     95704618 :                   adjust_insn (bb, insn);
   10286              : 
   10287     95704618 :                   if (pre)
   10288      1949590 :                     VTI (bb)->out.stack_adjust += pre;
   10289              : 
   10290     95704618 :                   if (DEBUG_MARKER_INSN_P (insn))
   10291              :                     {
   10292     11948648 :                       reemit_marker_as_note (insn);
   10293     11948648 :                       continue;
   10294              :                     }
   10295              : 
   10296     83755970 :                   if (MAY_HAVE_DEBUG_BIND_INSNS)
   10297              :                     {
   10298     83755560 :                       if (CALL_P (insn))
   10299      3280615 :                         prepare_call_arguments (bb, insn);
   10300     83755560 :                       cselib_process_insn (insn);
   10301     83755560 :                       if (dump_file && (dump_flags & TDF_DETAILS))
   10302              :                         {
   10303           11 :                           if (dump_flags & TDF_SLIM)
   10304           11 :                             dump_insn_slim (dump_file, insn);
   10305              :                           else
   10306            0 :                             print_rtl_single (dump_file, insn);
   10307           11 :                           dump_cselib_table (dump_file);
   10308              :                         }
   10309              :                     }
   10310     83755970 :                   if (!cselib_hook_called)
   10311          410 :                     add_with_sets (insn, 0, 0);
   10312     83755970 :                   cancel_changes (0);
   10313              : 
   10314     83755970 :                   if (post)
   10315              :                     {
   10316      2364794 :                       micro_operation mo;
   10317      2364794 :                       mo.type = MO_ADJUST;
   10318      2364794 :                       mo.u.adjust = post;
   10319      2364794 :                       mo.insn = insn;
   10320      2364794 :                       if (dump_file && (dump_flags & TDF_DETAILS))
   10321            1 :                         log_op_type (PATTERN (insn), bb, insn,
   10322              :                                      MO_ADJUST, dump_file);
   10323      2364794 :                       VTI (bb)->mos.safe_push (mo);
   10324      2364794 :                       VTI (bb)->out.stack_adjust += post;
   10325              :                     }
   10326              : 
   10327     83755970 :                   if (maybe_ne (fp_cfa_offset, -1)
   10328      7544539 :                       && known_eq (hard_frame_pointer_adjustment, -1)
   10329     83876120 :                       && fp_setter_insn (insn))
   10330              :                     {
   10331        22188 :                       vt_init_cfa_base ();
   10332        22188 :                       hard_frame_pointer_adjustment = fp_cfa_offset;
   10333              :                       /* Disassociate sp from fp now.  */
   10334        22188 :                       if (MAY_HAVE_DEBUG_BIND_INSNS)
   10335              :                         {
   10336        22188 :                           cselib_val *v;
   10337        22188 :                           cselib_invalidate_rtx (stack_pointer_rtx);
   10338        36094 :                           v = cselib_lookup (stack_pointer_rtx, Pmode, 1,
   10339              :                                              VOIDmode);
   10340        22188 :                           if (v && !cselib_preserved_value_p (v))
   10341              :                             {
   10342        22188 :                               cselib_set_value_sp_based (v);
   10343        22188 :                               preserve_value (v);
   10344              :                             }
   10345              :                         }
   10346              :                     }
   10347              :                 }
   10348              :             }
   10349      7495354 :           gcc_assert (offset == VTI (bb)->out.stack_adjust);
   10350              :         }
   10351              : 
   10352      4481029 :       bb = last_bb;
   10353              : 
   10354      4481029 :       if (MAY_HAVE_DEBUG_BIND_INSNS)
   10355              :         {
   10356      4480959 :           cselib_preserve_only_values ();
   10357      4480959 :           cselib_reset_table (cselib_get_next_uid ());
   10358      4480959 :           cselib_record_sets_hook = NULL;
   10359              :         }
   10360              :     }
   10361              : 
   10362       509710 :   hard_frame_pointer_adjustment = -1;
   10363       509710 :   VTI (ENTRY_BLOCK_PTR_FOR_FN (cfun))->flooded = true;
   10364       509710 :   cfa_base_rtx = NULL_RTX;
   10365       509710 :   return true;
   10366              : }
   10367              : 
   10368              : /* This is *not* reset after each function.  It gives each
   10369              :    NOTE_INSN_DELETED_DEBUG_LABEL in the entire compilation
   10370              :    a unique label number.  */
   10371              : 
   10372              : static int debug_label_num = 1;
   10373              : 
   10374              : /* Remove from the insn stream a single debug insn used for
   10375              :    variable tracking at assignments.  */
   10376              : 
   10377              : static inline void
   10378     41005884 : delete_vta_debug_insn (rtx_insn *insn)
   10379              : {
   10380     41005884 :   if (DEBUG_MARKER_INSN_P (insn))
   10381              :     {
   10382          911 :       reemit_marker_as_note (insn);
   10383          911 :       return;
   10384              :     }
   10385              : 
   10386     41004973 :   tree decl = INSN_VAR_LOCATION_DECL (insn);
   10387     41004973 :   if (TREE_CODE (decl) == LABEL_DECL
   10388         9679 :       && DECL_NAME (decl)
   10389     41014491 :       && !DECL_RTL_SET_P (decl))
   10390              :     {
   10391         8741 :       PUT_CODE (insn, NOTE);
   10392         8741 :       NOTE_KIND (insn) = NOTE_INSN_DELETED_DEBUG_LABEL;
   10393         8741 :       NOTE_DELETED_LABEL_NAME (insn)
   10394         8741 :         = IDENTIFIER_POINTER (DECL_NAME (decl));
   10395         8741 :       SET_DECL_RTL (decl, insn);
   10396         8741 :       CODE_LABEL_NUMBER (insn) = debug_label_num++;
   10397              :     }
   10398              :   else
   10399     40996232 :     delete_insn (insn);
   10400              : }
   10401              : 
   10402              : /* Remove from the insn stream all debug insns used for variable
   10403              :    tracking at assignments.  USE_CFG should be false if the cfg is no
   10404              :    longer usable.  */
   10405              : 
   10406              : void
   10407       509778 : delete_vta_debug_insns (bool use_cfg)
   10408              : {
   10409       509778 :   basic_block bb;
   10410       509778 :   rtx_insn *insn, *next;
   10411              : 
   10412       509778 :   if (!MAY_HAVE_DEBUG_INSNS)
   10413              :     return;
   10414              : 
   10415       509774 :   if (use_cfg)
   10416      8006077 :     FOR_EACH_BB_FN (bb, cfun)
   10417              :       {
   10418    316308120 :         FOR_BB_INSNS_SAFE (bb, insn, next)
   10419    154405908 :           if (DEBUG_INSN_P (insn))
   10420     41005880 :             delete_vta_debug_insn (insn);
   10421              :       }
   10422              :   else
   10423           12 :     for (insn = get_insns (); insn; insn = next)
   10424              :       {
   10425           11 :         next = NEXT_INSN (insn);
   10426           11 :         if (DEBUG_INSN_P (insn))
   10427            4 :           delete_vta_debug_insn (insn);
   10428              :       }
   10429              : }
   10430              : 
   10431              : /* Run a fast, BB-local only version of var tracking, to take care of
   10432              :    information that we don't do global analysis on, such that not all
   10433              :    information is lost.  If SKIPPED holds, we're skipping the global
   10434              :    pass entirely, so we should try to use information it would have
   10435              :    handled as well..  */
   10436              : 
   10437              : static void
   10438       509774 : vt_debug_insns_local (bool skipped ATTRIBUTE_UNUSED)
   10439              : {
   10440              :   /* ??? Just skip it all for now.  */
   10441            0 :   delete_vta_debug_insns (true);
   10442            0 : }
   10443              : 
   10444              : /* Free the data structures needed for variable tracking.  */
   10445              : 
   10446              : static void
   10447       509775 : vt_finalize (void)
   10448              : {
   10449       509775 :   basic_block bb;
   10450              : 
   10451      8006102 :   FOR_EACH_BB_FN (bb, cfun)
   10452              :     {
   10453      7496327 :       VTI (bb)->mos.release ();
   10454              :     }
   10455              : 
   10456      9025652 :   FOR_ALL_BB_FN (bb, cfun)
   10457              :     {
   10458      8515877 :       dataflow_set_destroy (&VTI (bb)->in);
   10459      8515877 :       dataflow_set_destroy (&VTI (bb)->out);
   10460      8515877 :       if (VTI (bb)->permp)
   10461              :         {
   10462       278085 :           dataflow_set_destroy (VTI (bb)->permp);
   10463       278085 :           XDELETE (VTI (bb)->permp);
   10464              :         }
   10465              :     }
   10466       509775 :   free_aux_for_blocks ();
   10467       509775 :   delete empty_shared_hash->htab;
   10468       509775 :   empty_shared_hash->htab = NULL;
   10469       509775 :   delete changed_variables;
   10470       509775 :   changed_variables = NULL;
   10471       509775 :   attrs_pool.release ();
   10472       509775 :   var_pool.release ();
   10473       509775 :   location_chain_pool.release ();
   10474       509775 :   shared_hash_pool.release ();
   10475              : 
   10476       509775 :   if (MAY_HAVE_DEBUG_BIND_INSNS)
   10477              :     {
   10478       509734 :       if (global_get_addr_cache)
   10479       509734 :         delete global_get_addr_cache;
   10480       509734 :       global_get_addr_cache = NULL;
   10481       509734 :       loc_exp_dep_pool.release ();
   10482       509734 :       valvar_pool.release ();
   10483       509734 :       preserved_values.release ();
   10484       509734 :       cselib_finish ();
   10485       509734 :       BITMAP_FREE (scratch_regs);
   10486       509734 :       scratch_regs = NULL;
   10487              :     }
   10488              : 
   10489              : #ifdef HAVE_window_save
   10490              :   vec_free (windowed_parm_regs);
   10491              : #endif
   10492              : 
   10493       509775 :   if (vui_vec)
   10494         8708 :     XDELETEVEC (vui_vec);
   10495       509775 :   vui_vec = NULL;
   10496       509775 :   vui_allocated = 0;
   10497       509775 : }
   10498              : 
   10499              : /* The entry point to variable tracking pass.  */
   10500              : 
   10501              : static inline unsigned int
   10502       509776 : variable_tracking_main_1 (void)
   10503              : {
   10504       509776 :   bool success;
   10505              : 
   10506              :   /* We won't be called as a separate pass if flag_var_tracking is not
   10507              :      set, but final may call us to turn debug markers into notes.  */
   10508       509776 :   if ((!flag_var_tracking && MAY_HAVE_DEBUG_INSNS)
   10509       509776 :       || flag_var_tracking_assignments < 0
   10510              :       /* Var-tracking right now assumes the IR doesn't contain
   10511              :          any pseudos at this point.  */
   10512       509774 :       || targetm.no_register_allocation)
   10513              :     {
   10514            2 :       delete_vta_debug_insns (true);
   10515            2 :       return 0;
   10516              :     }
   10517              : 
   10518       509774 :   if (!flag_var_tracking)
   10519              :     return 0;
   10520              : 
   10521       509774 :   if (n_basic_blocks_for_fn (cfun) > 500
   10522          418 :       && n_edges_for_fn (cfun) / n_basic_blocks_for_fn (cfun) >= 20)
   10523              :     {
   10524            0 :       vt_debug_insns_local (true);
   10525            0 :       return 0;
   10526              :     }
   10527              : 
   10528       509774 :   if (!vt_initialize ())
   10529              :     {
   10530           65 :       vt_finalize ();
   10531           65 :       vt_debug_insns_local (true);
   10532           65 :       return 0;
   10533              :     }
   10534              : 
   10535       509709 :   success = vt_find_locations ();
   10536              : 
   10537       509709 :   if (!success && flag_var_tracking_assignments > 0)
   10538              :     {
   10539            1 :       vt_finalize ();
   10540              : 
   10541            1 :       delete_vta_debug_insns (true);
   10542              : 
   10543              :       /* This is later restored by our caller.  */
   10544            1 :       flag_var_tracking_assignments = 0;
   10545              : 
   10546            1 :       success = vt_initialize ();
   10547            1 :       gcc_assert (success);
   10548              : 
   10549            1 :       success = vt_find_locations ();
   10550              :     }
   10551              : 
   10552            1 :   if (!success)
   10553              :     {
   10554            0 :       vt_finalize ();
   10555            0 :       vt_debug_insns_local (false);
   10556            0 :       return 0;
   10557              :     }
   10558              : 
   10559       509709 :   if (dump_file && (dump_flags & TDF_DETAILS))
   10560              :     {
   10561            1 :       dump_dataflow_sets ();
   10562            1 :       dump_reg_info (dump_file);
   10563            1 :       dump_flow_info (dump_file, dump_flags);
   10564              :     }
   10565              : 
   10566       509709 :   timevar_push (TV_VAR_TRACKING_EMIT);
   10567       509709 :   vt_emit_notes ();
   10568       509709 :   timevar_pop (TV_VAR_TRACKING_EMIT);
   10569              : 
   10570       509709 :   vt_finalize ();
   10571       509709 :   vt_debug_insns_local (false);
   10572       509709 :   return 0;
   10573              : }
   10574              : 
   10575              : unsigned int
   10576       509776 : variable_tracking_main (void)
   10577              : {
   10578       509776 :   unsigned int ret;
   10579       509776 :   int save = flag_var_tracking_assignments;
   10580              : 
   10581       509776 :   ret = variable_tracking_main_1 ();
   10582              : 
   10583       509776 :   flag_var_tracking_assignments = save;
   10584              : 
   10585       509776 :   return ret;
   10586              : }
   10587              : 
   10588              : namespace {
   10589              : 
   10590              : const pass_data pass_data_variable_tracking =
   10591              : {
   10592              :   RTL_PASS, /* type */
   10593              :   "vartrack", /* name */
   10594              :   OPTGROUP_NONE, /* optinfo_flags */
   10595              :   TV_VAR_TRACKING, /* tv_id */
   10596              :   0, /* properties_required */
   10597              :   0, /* properties_provided */
   10598              :   0, /* properties_destroyed */
   10599              :   0, /* todo_flags_start */
   10600              :   0, /* todo_flags_finish */
   10601              : };
   10602              : 
   10603              : class pass_variable_tracking : public rtl_opt_pass
   10604              : {
   10605              : public:
   10606       294587 :   pass_variable_tracking (gcc::context *ctxt)
   10607       589174 :     : rtl_opt_pass (pass_data_variable_tracking, ctxt)
   10608              :   {}
   10609              : 
   10610              :   /* opt_pass methods: */
   10611      1511392 :   bool gate (function *) final override
   10612              :     {
   10613      1511392 :       return (flag_var_tracking && !targetm.delay_vartrack);
   10614              :     }
   10615              : 
   10616       509776 :   unsigned int execute (function *) final override
   10617              :     {
   10618       509776 :       return variable_tracking_main ();
   10619              :     }
   10620              : 
   10621              : }; // class pass_variable_tracking
   10622              : 
   10623              : } // anon namespace
   10624              : 
   10625              : rtl_opt_pass *
   10626       294587 : make_pass_variable_tracking (gcc::context *ctxt)
   10627              : {
   10628       294587 :   return new pass_variable_tracking (ctxt);
   10629              : }
        

Generated by: LCOV version 2.4-beta

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