LCOV - code coverage report
Current view: top level - gcc - tree.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 85.0 % 7021 5971
Test Date: 2026-06-20 15:32:29 Functions: 90.1 % 456 411
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Language-independent node constructors for parse phase of GNU compiler.
       2              :    Copyright (C) 1987-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : /* This file contains the low level primitives for operating on tree nodes,
      21              :    including allocation, list operations, interning of identifiers,
      22              :    construction of data type nodes and statement nodes,
      23              :    and construction of type conversion nodes.  It also contains
      24              :    tables index by tree code that describe how to take apart
      25              :    nodes of that code.
      26              : 
      27              :    It is intended to be language-independent but can occasionally
      28              :    calls language-dependent routines.  */
      29              : 
      30              : #include "config.h"
      31              : #include "system.h"
      32              : #include "coretypes.h"
      33              : #include "backend.h"
      34              : #include "target.h"
      35              : #include "memmodel.h"
      36              : #include "tm_p.h"
      37              : #include "tree.h"
      38              : #include "gimple.h"
      39              : #include "tree-pass.h"
      40              : #include "ssa.h"
      41              : #include "cgraph.h"
      42              : #include "diagnostic.h"
      43              : #include "flags.h"
      44              : #include "alias.h"
      45              : #include "fold-const.h"
      46              : #include "stor-layout.h"
      47              : #include "calls.h"
      48              : #include "attribs.h"
      49              : #include "toplev.h" /* get_random_seed */
      50              : #include "output.h"
      51              : #include "common/common-target.h"
      52              : #include "langhooks.h"
      53              : #include "tree-inline.h"
      54              : #include "tree-iterator.h"
      55              : #include "internal-fn.h"
      56              : #include "gimple-iterator.h"
      57              : #include "gimplify.h"
      58              : #include "tree-dfa.h"
      59              : #include "langhooks-def.h"
      60              : #include "tree-diagnostic.h"
      61              : #include "except.h"
      62              : #include "builtins.h"
      63              : #include "print-tree.h"
      64              : #include "ipa-utils.h"
      65              : #include "selftest.h"
      66              : #include "stringpool.h"
      67              : #include "attribs.h"
      68              : #include "rtl.h"
      69              : #include "regs.h"
      70              : #include "tree-vector-builder.h"
      71              : #include "gimple-fold.h"
      72              : #include "escaped_string.h"
      73              : #include "gimple-range.h"
      74              : #include "gomp-constants.h"
      75              : #include "dfp.h"
      76              : #include "asan.h"
      77              : #include "ubsan.h"
      78              : #include "attr-callback.h"
      79              : 
      80              : /* Names of tree components.
      81              :    Used for printing out the tree and error messages.  */
      82              : #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
      83              : #define END_OF_BASE_TREE_CODES "@dummy",
      84              : 
      85              : static const char *const tree_code_name[] = {
      86              : #include "all-tree.def"
      87              : };
      88              : 
      89              : #undef DEFTREECODE
      90              : #undef END_OF_BASE_TREE_CODES
      91              : 
      92              : /* Each tree code class has an associated string representation.
      93              :    These must correspond to the tree_code_class entries.  */
      94              : 
      95              : const char *const tree_code_class_strings[] =
      96              : {
      97              :   "exceptional",
      98              :   "constant",
      99              :   "type",
     100              :   "declaration",
     101              :   "reference",
     102              :   "comparison",
     103              :   "unary",
     104              :   "binary",
     105              :   "statement",
     106              :   "vl_exp",
     107              :   "expression"
     108              : };
     109              : 
     110              : /* obstack.[ch] explicitly declined to prototype this.  */
     111              : extern int _obstack_allocated_p (struct obstack *h, void *obj);
     112              : 
     113              : /* Statistics-gathering stuff.  */
     114              : 
     115              : static uint64_t tree_code_counts[MAX_TREE_CODES];
     116              : uint64_t tree_node_counts[(int) all_kinds];
     117              : uint64_t tree_node_sizes[(int) all_kinds];
     118              : 
     119              : /* Keep in sync with tree.h:enum tree_node_kind.  */
     120              : static const char * const tree_node_kind_names[] = {
     121              :   "decls",
     122              :   "types",
     123              :   "blocks",
     124              :   "stmts",
     125              :   "refs",
     126              :   "exprs",
     127              :   "constants",
     128              :   "identifiers",
     129              :   "vecs",
     130              :   "binfos",
     131              :   "ssa names",
     132              :   "constructors",
     133              :   "random kinds",
     134              :   "lang_decl kinds",
     135              :   "lang_type kinds",
     136              :   "omp clauses",
     137              : };
     138              : 
     139              : /* Unique id for next decl created.  */
     140              : static GTY(()) int next_decl_uid;
     141              : /* Unique id for next type created.  */
     142              : static GTY(()) unsigned next_type_uid = 1;
     143              : /* Unique id for next debug decl created.  Use negative numbers,
     144              :    to catch erroneous uses.  */
     145              : static GTY(()) int next_debug_decl_uid;
     146              : 
     147              : /* Since we cannot rehash a type after it is in the table, we have to
     148              :    keep the hash code.  */
     149              : 
     150              : struct GTY((for_user)) type_hash {
     151              :   unsigned long hash;
     152              :   tree type;
     153              : };
     154              : 
     155              : /* Initial size of the hash table (rounded to next prime).  */
     156              : #define TYPE_HASH_INITIAL_SIZE 1000
     157              : 
     158              : struct type_cache_hasher : ggc_cache_ptr_hash<type_hash>
     159              : {
     160   7994211688 :   static hashval_t hash (type_hash *t) { return t->hash; }
     161              :   static bool equal (type_hash *a, type_hash *b);
     162              : 
     163              :   static int
     164   1974031490 :   keep_cache_entry (type_hash *&t)
     165              :   {
     166   1974031490 :     return ggc_marked_p (t->type);
     167              :   }
     168              : };
     169              : 
     170              : /* Now here is the hash table.  When recording a type, it is added to
     171              :    the slot whose index is the hash code.  Note that the hash table is
     172              :    used for several kinds of types (function types, array types and
     173              :    array index range types, for now).  While all these live in the
     174              :    same table, they are completely independent, and the hash code is
     175              :    computed differently for each of these.  */
     176              : 
     177              : static GTY ((cache)) hash_table<type_cache_hasher> *type_hash_table;
     178              : 
     179              : /* Hash table and temporary node for larger integer const values.  */
     180              : static GTY (()) tree int_cst_node;
     181              : 
     182              : struct int_cst_hasher : ggc_cache_ptr_hash<tree_node>
     183              : {
     184              :   static hashval_t hash (tree t);
     185              :   static bool equal (tree x, tree y);
     186              : };
     187              : 
     188              : static GTY ((cache)) hash_table<int_cst_hasher> *int_cst_hash_table;
     189              : 
     190              : /* Class and variable for making sure that there is a single POLY_INT_CST
     191              :    for a given value.  */
     192              : struct poly_int_cst_hasher : ggc_cache_ptr_hash<tree_node>
     193              : {
     194              :   typedef std::pair<tree, const poly_wide_int *> compare_type;
     195              :   static hashval_t hash (tree t);
     196              :   static bool equal (tree x, const compare_type &y);
     197              : };
     198              : 
     199              : static GTY ((cache)) hash_table<poly_int_cst_hasher> *poly_int_cst_hash_table;
     200              : 
     201              : /* Hash table for optimization flags and target option flags.  Use the same
     202              :    hash table for both sets of options.  Nodes for building the current
     203              :    optimization and target option nodes.  The assumption is most of the time
     204              :    the options created will already be in the hash table, so we avoid
     205              :    allocating and freeing up a node repeatably.  */
     206              : static GTY (()) tree cl_optimization_node;
     207              : static GTY (()) tree cl_target_option_node;
     208              : 
     209              : struct cl_option_hasher : ggc_cache_ptr_hash<tree_node>
     210              : {
     211              :   static hashval_t hash (tree t);
     212              :   static bool equal (tree x, tree y);
     213              : };
     214              : 
     215              : static GTY ((cache)) hash_table<cl_option_hasher> *cl_option_hash_table;
     216              : 
     217       867822 : struct gt_value_expr_mark_data {
     218              :   hash_set<tree> pset;
     219              :   auto_vec<tree, 16> to_mark;
     220              : };
     221              : 
     222              : /* Callback called through walk_tree_1 to discover DECL_HAS_VALUE_EXPR_P
     223              :    VAR_DECLs which weren't marked yet, in that case marks them and
     224              :    walks their DECL_VALUE_EXPR expressions.  */
     225              : 
     226              : static tree
     227     19838882 : gt_value_expr_mark_2 (tree *tp, int *, void *data)
     228              : {
     229     19838882 :   tree t = *tp;
     230     19838882 :   if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t) && !ggc_marked_p (t))
     231              :     {
     232         1094 :       tree dve = DECL_VALUE_EXPR (t);
     233         1094 :       gt_value_expr_mark_data *d = (gt_value_expr_mark_data *) data;
     234         1094 :       walk_tree_1 (&dve, gt_value_expr_mark_2, data, &d->pset, NULL);
     235         1094 :       d->to_mark.safe_push (t);
     236              :     }
     237     19838882 :   return NULL_TREE;
     238              : }
     239              : 
     240              : /* Callback called through traverse_noresize on the
     241              :    value_expr_for_decl hash table.  */
     242              : 
     243              : int
     244      8497456 : gt_value_expr_mark_1 (tree_decl_map **e, gt_value_expr_mark_data *data)
     245              : {
     246      8497456 :   if (ggc_marked_p ((*e)->base.from))
     247      7470665 :     walk_tree_1 (&(*e)->to, gt_value_expr_mark_2, data, &data->pset, NULL);
     248      8497456 :   return 1;
     249              : }
     250              : 
     251              : /* The value_expr_for_decl hash table can have mappings for trees
     252              :    which are only referenced from mappings of other trees in the
     253              :    same table, see PR118790.  Without this routine, gt_cleare_cache
     254              :    could clear hash table slot of a tree which isn't marked but
     255              :    will be marked when processing later hash table slot of another
     256              :    tree which is marked.  This function marks with the above
     257              :    helpers marks all the not yet marked DECL_HAS_VALUE_EXPR_P
     258              :    VAR_DECLs mentioned in DECL_VALUE_EXPR expressions of marked
     259              :    trees and in that case also recurses on their DECL_VALUE_EXPR.  */
     260              : 
     261              : void
     262       867822 : gt_value_expr_mark (hash_table<tree_decl_map_cache_hasher> *h)
     263              : {
     264       867822 :   if (!h)
     265            0 :     return;
     266              : 
     267       867822 :   gt_value_expr_mark_data data;
     268       867822 :   h->traverse_noresize<gt_value_expr_mark_data *,
     269      9365278 :                        gt_value_expr_mark_1> (&data);
     270      2604560 :   for (auto v : data.to_mark)
     271         1094 :     gt_ggc_mx (v);
     272       867822 : }
     273              : 
     274              : /* General tree->tree mapping  structure for use in hash tables.  */
     275              : 
     276              : 
     277              : static GTY ((cache))
     278              :      hash_table<tree_decl_map_cache_hasher> *debug_expr_for_decl;
     279              : 
     280              : static GTY ((cache ("gt_value_expr_mark")))
     281              :      hash_table<tree_decl_map_cache_hasher> *value_expr_for_decl;
     282              : 
     283              : static GTY ((cache))
     284              :      hash_table<tree_vec_map_cache_hasher> *debug_args_for_decl;
     285              : 
     286              : static void set_type_quals (tree, int);
     287              : static void print_type_hash_statistics (void);
     288              : static void print_debug_expr_statistics (void);
     289              : static void print_value_expr_statistics (void);
     290              : 
     291              : tree global_trees[TI_MAX];
     292              : tree integer_types[itk_none];
     293              : 
     294              : bool int_n_enabled_p[NUM_INT_N_ENTS];
     295              : struct int_n_trees_t int_n_trees [NUM_INT_N_ENTS];
     296              : 
     297              : bool tree_contains_struct[MAX_TREE_CODES][64];
     298              : 
     299              : /* Number of operands for each OMP clause.  */
     300              : unsigned const char omp_clause_num_ops[] =
     301              : {
     302              :   0, /* OMP_CLAUSE_ERROR  */
     303              :   1, /* OMP_CLAUSE_PRIVATE  */
     304              :   1, /* OMP_CLAUSE_SHARED  */
     305              :   1, /* OMP_CLAUSE_FIRSTPRIVATE  */
     306              :   2, /* OMP_CLAUSE_LASTPRIVATE  */
     307              :   5, /* OMP_CLAUSE_REDUCTION  */
     308              :   5, /* OMP_CLAUSE_TASK_REDUCTION  */
     309              :   5, /* OMP_CLAUSE_IN_REDUCTION  */
     310              :   1, /* OMP_CLAUSE_COPYIN  */
     311              :   1, /* OMP_CLAUSE_COPYPRIVATE  */
     312              :   3, /* OMP_CLAUSE_LINEAR  */
     313              :   1, /* OMP_CLAUSE_AFFINITY  */
     314              :   2, /* OMP_CLAUSE_ALIGNED  */
     315              :   3, /* OMP_CLAUSE_ALLOCATE  */
     316              :   1, /* OMP_CLAUSE_DEPEND  */
     317              :   1, /* OMP_CLAUSE_NONTEMPORAL  */
     318              :   1, /* OMP_CLAUSE_UNIFORM  */
     319              :   1, /* OMP_CLAUSE_ENTER  */
     320              :   1, /* OMP_CLAUSE_LINK  */
     321              :   1, /* OMP_CLAUSE_DETACH  */
     322              :   1, /* OMP_CLAUSE_USE_DEVICE_PTR  */
     323              :   1, /* OMP_CLAUSE_USE_DEVICE_ADDR  */
     324              :   1, /* OMP_CLAUSE_IS_DEVICE_PTR  */
     325              :   1, /* OMP_CLAUSE_INCLUSIVE  */
     326              :   1, /* OMP_CLAUSE_EXCLUSIVE  */
     327              :   3, /* OMP_CLAUSE_FROM  */
     328              :   3, /* OMP_CLAUSE_TO  */
     329              :   3, /* OMP_CLAUSE_MAP (update walk_tree_1 if this is changed)  */
     330              :   1, /* OMP_CLAUSE_HAS_DEVICE_ADDR  */
     331              :   1, /* OMP_CLAUSE_DOACROSS  */
     332              :   3, /* OMP_CLAUSE__MAPPER_BINDING_  */
     333              :   2, /* OMP_CLAUSE__CACHE_  */
     334              :   1, /* OMP_CLAUSE_DESTROY  */
     335              :   2, /* OMP_CLAUSE_INIT  */
     336              :   1, /* OMP_CLAUSE_USE  */
     337              :   1, /* OMP_CLAUSE_INTEROP  */
     338              :   2, /* OMP_CLAUSE_GANG  */
     339              :   1, /* OMP_CLAUSE_ASYNC  */
     340              :   1, /* OMP_CLAUSE_WAIT  */
     341              :   0, /* OMP_CLAUSE_AUTO  */
     342              :   0, /* OMP_CLAUSE_SEQ  */
     343              :   1, /* OMP_CLAUSE__LOOPTEMP_  */
     344              :   1, /* OMP_CLAUSE__REDUCTEMP_  */
     345              :   1, /* OMP_CLAUSE__CONDTEMP_  */
     346              :   1, /* OMP_CLAUSE__SCANTEMP_  */
     347              :   1, /* OMP_CLAUSE_IF  */
     348              :   1, /* OMP_CLAUSE_SELF */
     349              :   1, /* OMP_CLAUSE_NUM_THREADS  */
     350              :   1, /* OMP_CLAUSE_SCHEDULE  */
     351              :   0, /* OMP_CLAUSE_NOWAIT  */
     352              :   1, /* OMP_CLAUSE_ORDERED  */
     353              :   0, /* OMP_CLAUSE_DEFAULT  */
     354              :   3, /* OMP_CLAUSE_COLLAPSE  */
     355              :   0, /* OMP_CLAUSE_UNTIED   */
     356              :   1, /* OMP_CLAUSE_FINAL  */
     357              :   0, /* OMP_CLAUSE_MERGEABLE  */
     358              :   1, /* OMP_CLAUSE_DEVICE  */
     359              :   1, /* OMP_CLAUSE_DIST_SCHEDULE  */
     360              :   0, /* OMP_CLAUSE_INBRANCH  */
     361              :   0, /* OMP_CLAUSE_NOTINBRANCH  */
     362              :   2, /* OMP_CLAUSE_NUM_TEAMS  */
     363              :   1, /* OMP_CLAUSE_THREAD_LIMIT  */
     364              :   0, /* OMP_CLAUSE_PROC_BIND  */
     365              :   1, /* OMP_CLAUSE_SAFELEN  */
     366              :   1, /* OMP_CLAUSE_SIMDLEN  */
     367              :   0, /* OMP_CLAUSE_DEVICE_TYPE  */
     368              :   0, /* OMP_CLAUSE_FOR  */
     369              :   0, /* OMP_CLAUSE_PARALLEL  */
     370              :   0, /* OMP_CLAUSE_SECTIONS  */
     371              :   0, /* OMP_CLAUSE_TASKGROUP  */
     372              :   1, /* OMP_CLAUSE_PRIORITY  */
     373              :   1, /* OMP_CLAUSE_GRAINSIZE  */
     374              :   1, /* OMP_CLAUSE_NUM_TASKS  */
     375              :   0, /* OMP_CLAUSE_NOGROUP  */
     376              :   0, /* OMP_CLAUSE_THREADS  */
     377              :   0, /* OMP_CLAUSE_SIMD  */
     378              :   1, /* OMP_CLAUSE_HINT  */
     379              :   0, /* OMP_CLAUSE_DEFAULTMAP  */
     380              :   0, /* OMP_CLAUSE_ORDER  */
     381              :   0, /* OMP_CLAUSE_BIND  */
     382              :   1, /* OMP_CLAUSE_FILTER  */
     383              :   1, /* OMP_CLAUSE_INDIRECT  */
     384              :   1, /* OMP_CLAUSE_PARTIAL  */
     385              :   0, /* OMP_CLAUSE_FULL  */
     386              :   1, /* OMP_CLAUSE_SIZES  */
     387              :   1, /* OMP_CLAUSE__SIMDUID_  */
     388              :   0, /* OMP_CLAUSE__SIMT_  */
     389              :   0, /* OMP_CLAUSE_INDEPENDENT  */
     390              :   1, /* OMP_CLAUSE_WORKER  */
     391              :   1, /* OMP_CLAUSE_VECTOR  */
     392              :   1, /* OMP_CLAUSE_NUM_GANGS  */
     393              :   1, /* OMP_CLAUSE_NUM_WORKERS  */
     394              :   1, /* OMP_CLAUSE_VECTOR_LENGTH  */
     395              :   3, /* OMP_CLAUSE_TILE  */
     396              :   0, /* OMP_CLAUSE_IF_PRESENT */
     397              :   0, /* OMP_CLAUSE_FINALIZE */
     398              :   0, /* OMP_CLAUSE_NOHOST */
     399              :   1, /* OMP_CLAUSE_NOVARIANTS */
     400              :   1, /* OMP_CLAUSE_NOCONTEXT */
     401              :   1, /* OMP_CLAUSE_DYN_GROUPPRIVATE  */
     402              :   3, /* OMP_CLAUSE_USES_ALLOCATORS */
     403              : };
     404              : 
     405              : const char * const omp_clause_code_name[] =
     406              : {
     407              :   "error_clause",
     408              :   "private",
     409              :   "shared",
     410              :   "firstprivate",
     411              :   "lastprivate",
     412              :   "reduction",
     413              :   "task_reduction",
     414              :   "in_reduction",
     415              :   "copyin",
     416              :   "copyprivate",
     417              :   "linear",
     418              :   "affinity",
     419              :   "aligned",
     420              :   "allocate",
     421              :   "depend",
     422              :   "nontemporal",
     423              :   "uniform",
     424              :   "enter",
     425              :   "link",
     426              :   "detach",
     427              :   "use_device_ptr",
     428              :   "use_device_addr",
     429              :   "is_device_ptr",
     430              :   "inclusive",
     431              :   "exclusive",
     432              :   "from",
     433              :   "to",
     434              :   "map",
     435              :   "has_device_addr",
     436              :   "doacross",
     437              :   "_mapper_binding_",
     438              :   "_cache_",
     439              :   "destroy",
     440              :   "init",
     441              :   "use",
     442              :   "interop",
     443              :   "gang",
     444              :   "async",
     445              :   "wait",
     446              :   "auto",
     447              :   "seq",
     448              :   "_looptemp_",
     449              :   "_reductemp_",
     450              :   "_condtemp_",
     451              :   "_scantemp_",
     452              :   "if",
     453              :   "self",
     454              :   "num_threads",
     455              :   "schedule",
     456              :   "nowait",
     457              :   "ordered",
     458              :   "default",
     459              :   "collapse",
     460              :   "untied",
     461              :   "final",
     462              :   "mergeable",
     463              :   "device",
     464              :   "dist_schedule",
     465              :   "inbranch",
     466              :   "notinbranch",
     467              :   "num_teams",
     468              :   "thread_limit",
     469              :   "proc_bind",
     470              :   "safelen",
     471              :   "simdlen",
     472              :   "device_type",
     473              :   "for",
     474              :   "parallel",
     475              :   "sections",
     476              :   "taskgroup",
     477              :   "priority",
     478              :   "grainsize",
     479              :   "num_tasks",
     480              :   "nogroup",
     481              :   "threads",
     482              :   "simd",
     483              :   "hint",
     484              :   "defaultmap",
     485              :   "order",
     486              :   "bind",
     487              :   "filter",
     488              :   "indirect",
     489              :   "partial",
     490              :   "full",
     491              :   "sizes",
     492              :   "_simduid_",
     493              :   "_simt_",
     494              :   "independent",
     495              :   "worker",
     496              :   "vector",
     497              :   "num_gangs",
     498              :   "num_workers",
     499              :   "vector_length",
     500              :   "tile",
     501              :   "if_present",
     502              :   "finalize",
     503              :   "nohost",
     504              :   "novariants",
     505              :   "nocontext",
     506              :   "dyn_groupprivate",
     507              :   "uses_allocators",
     508              : };
     509              : 
     510              : /* Unless specific to OpenACC, we tend to internally maintain OpenMP-centric
     511              :    clause names, but for use in diagnostics etc. would like to use the "user"
     512              :    clause names.  */
     513              : 
     514              : const char *
     515          445 : user_omp_clause_code_name (tree clause, bool oacc)
     516              : {
     517              :   /* For OpenACC, the 'OMP_CLAUSE_MAP_KIND' of an 'OMP_CLAUSE_MAP' is used to
     518              :      distinguish clauses as seen by the user.  See also where front ends do
     519              :      'build_omp_clause' with 'OMP_CLAUSE_MAP'.  */
     520          890 :   if (oacc && OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP)
     521          445 :     switch (OMP_CLAUSE_MAP_KIND (clause))
     522              :       {
     523              :       case GOMP_MAP_FORCE_ALLOC:
     524              :       case GOMP_MAP_ALLOC: return "create";
     525            0 :       case GOMP_MAP_FORCE_TO:
     526            0 :       case GOMP_MAP_TO: return "copyin";
     527            0 :       case GOMP_MAP_FORCE_FROM:
     528            0 :       case GOMP_MAP_FROM: return "copyout";
     529          361 :       case GOMP_MAP_FORCE_TOFROM:
     530          361 :       case GOMP_MAP_TOFROM: return "copy";
     531            0 :       case GOMP_MAP_RELEASE: return "delete";
     532            0 :       case GOMP_MAP_FORCE_PRESENT: return "present";
     533           42 :       case GOMP_MAP_ATTACH: return "attach";
     534           42 :       case GOMP_MAP_FORCE_DETACH:
     535           42 :       case GOMP_MAP_DETACH: return "detach";
     536            0 :       case GOMP_MAP_DEVICE_RESIDENT: return "device_resident";
     537            0 :       case GOMP_MAP_LINK: return "link";
     538            0 :       case GOMP_MAP_FORCE_DEVICEPTR: return "deviceptr";
     539              :       default: break;
     540              :       }
     541              : 
     542            0 :   return omp_clause_code_name[OMP_CLAUSE_CODE (clause)];
     543              : }
     544              : 
     545              : 
     546              : /* Return the tree node structure used by tree code CODE.  */
     547              : 
     548              : static inline enum tree_node_structure_enum
     549  42343982958 : tree_node_structure_for_code (enum tree_code code)
     550              : {
     551  42343982958 :   switch (TREE_CODE_CLASS (code))
     552              :     {
     553  10522421558 :     case tcc_declaration:
     554  10522421558 :       switch (code)
     555              :         {
     556              :         case CONST_DECL:        return TS_CONST_DECL;
     557              :         case DEBUG_EXPR_DECL:   return TS_DECL_WRTL;
     558              :         case FIELD_DECL:        return TS_FIELD_DECL;
     559              :         case FUNCTION_DECL:     return TS_FUNCTION_DECL;
     560              :         case LABEL_DECL:        return TS_LABEL_DECL;
     561              :         case PARM_DECL:         return TS_PARM_DECL;
     562              :         case RESULT_DECL:       return TS_RESULT_DECL;
     563              :         case TRANSLATION_UNIT_DECL: return TS_TRANSLATION_UNIT_DECL;
     564              :         case TYPE_DECL:         return TS_TYPE_DECL;
     565              :         case VAR_DECL:          return TS_VAR_DECL;
     566              :         default:                return TS_DECL_NON_COMMON;
     567              :         }
     568              : 
     569              :     case tcc_type:              return TS_TYPE_NON_COMMON;
     570              : 
     571  10947606862 :     case tcc_binary:
     572  10947606862 :     case tcc_comparison:
     573  10947606862 :     case tcc_expression:
     574  10947606862 :     case tcc_reference:
     575  10947606862 :     case tcc_statement:
     576  10947606862 :     case tcc_unary:
     577  10947606862 :     case tcc_vl_exp:            return TS_EXP;
     578              : 
     579  15135744532 :     default:  /* tcc_constant and tcc_exceptional */
     580  15135744532 :       break;
     581              :     }
     582              : 
     583  15135744532 :   switch (code)
     584              :     {
     585              :       /* tcc_constant cases.  */
     586              :     case COMPLEX_CST:           return TS_COMPLEX;
     587       298828 :     case FIXED_CST:             return TS_FIXED_CST;
     588    742429968 :     case INTEGER_CST:           return TS_INT_CST;
     589       298828 :     case POLY_INT_CST:          return TS_POLY_INT_CST;
     590     47908818 :     case REAL_CST:              return TS_REAL_CST;
     591    246505655 :     case STRING_CST:            return TS_STRING;
     592     13783760 :     case VECTOR_CST:            return TS_VECTOR;
     593      1167598 :     case VOID_CST:              return TS_TYPED;
     594       299084 :     case RAW_DATA_CST:          return TS_RAW_DATA_CST;
     595              : 
     596              :       /* tcc_exceptional cases.  */
     597    697596432 :     case BLOCK:                 return TS_BLOCK;
     598    135727531 :     case CONSTRUCTOR:           return TS_CONSTRUCTOR;
     599              :     case ERROR_MARK:            return TS_COMMON;
     600      8879105 :     case IDENTIFIER_NODE:       return TS_IDENTIFIER;
     601       856007 :     case OMP_CLAUSE:            return TS_OMP_CLAUSE;
     602      2048792 :     case OPTIMIZATION_NODE:     return TS_OPTIMIZATION;
     603              :     case PLACEHOLDER_EXPR:      return TS_COMMON;
     604    332922686 :     case SSA_NAME:              return TS_SSA_NAME;
     605    758822391 :     case STATEMENT_LIST:        return TS_STATEMENT_LIST;
     606      3983414 :     case TARGET_OPTION_NODE:    return TS_TARGET_OPTION;
     607    256999715 :     case TREE_BINFO:            return TS_BINFO;
     608   9814783847 :     case TREE_LIST:             return TS_LIST;
     609   2068460768 :     case TREE_VEC:              return TS_VEC;
     610              : 
     611            0 :     default:
     612            0 :       gcc_unreachable ();
     613              :     }
     614              : }
     615              : 
     616              : 
     617              : /* Initialize tree_contains_struct to describe the hierarchy of tree
     618              :    nodes.  */
     619              : 
     620              : static void
     621       298828 : initialize_tree_contains_struct (void)
     622              : {
     623       298828 :   unsigned i;
     624              : 
     625     73511688 :   for (i = ERROR_MARK; i < LAST_AND_UNUSED_TREE_CODE; i++)
     626              :     {
     627     73212860 :       enum tree_code code;
     628     73212860 :       enum tree_node_structure_enum ts_code;
     629              : 
     630     73212860 :       code = (enum tree_code) i;
     631     73212860 :       ts_code = tree_node_structure_for_code (code);
     632              : 
     633              :       /* Mark the TS structure itself.  */
     634     73212860 :       tree_contains_struct[code][ts_code] = 1;
     635              : 
     636              :       /* Mark all the structures that TS is derived from.  */
     637     73212860 :       switch (ts_code)
     638              :         {
     639      1195312 :         case TS_TYPED:
     640      1195312 :         case TS_BLOCK:
     641      1195312 :         case TS_OPTIMIZATION:
     642      1195312 :         case TS_TARGET_OPTION:
     643      1195312 :           MARK_TS_BASE (code);
     644      1195312 :           break;
     645              : 
     646     60363256 :         case TS_COMMON:
     647     60363256 :         case TS_INT_CST:
     648     60363256 :         case TS_POLY_INT_CST:
     649     60363256 :         case TS_REAL_CST:
     650     60363256 :         case TS_FIXED_CST:
     651     60363256 :         case TS_VECTOR:
     652     60363256 :         case TS_STRING:
     653     60363256 :         case TS_RAW_DATA_CST:
     654     60363256 :         case TS_COMPLEX:
     655     60363256 :         case TS_SSA_NAME:
     656     60363256 :         case TS_CONSTRUCTOR:
     657     60363256 :         case TS_EXP:
     658     60363256 :         case TS_STATEMENT_LIST:
     659     60363256 :           MARK_TS_TYPED (code);
     660     60363256 :           break;
     661              : 
     662      1494140 :         case TS_IDENTIFIER:
     663      1494140 :         case TS_DECL_MINIMAL:
     664      1494140 :         case TS_TYPE_COMMON:
     665      1494140 :         case TS_LIST:
     666      1494140 :         case TS_VEC:
     667      1494140 :         case TS_BINFO:
     668      1494140 :         case TS_OMP_CLAUSE:
     669      1494140 :           MARK_TS_COMMON (code);
     670      1494140 :           break;
     671              : 
     672            0 :         case TS_TYPE_WITH_LANG_SPECIFIC:
     673            0 :           MARK_TS_TYPE_COMMON (code);
     674            0 :           break;
     675              : 
     676      6275388 :         case TS_TYPE_NON_COMMON:
     677      6275388 :           MARK_TS_TYPE_WITH_LANG_SPECIFIC (code);
     678      6275388 :           break;
     679              : 
     680            0 :         case TS_DECL_COMMON:
     681            0 :           MARK_TS_DECL_MINIMAL (code);
     682            0 :           break;
     683              : 
     684       597656 :         case TS_DECL_WRTL:
     685       597656 :         case TS_CONST_DECL:
     686       597656 :           MARK_TS_DECL_COMMON (code);
     687       597656 :           break;
     688              : 
     689       896484 :         case TS_DECL_NON_COMMON:
     690       896484 :           MARK_TS_DECL_WITH_VIS (code);
     691       896484 :           break;
     692              : 
     693       896484 :         case TS_DECL_WITH_VIS:
     694       896484 :         case TS_PARM_DECL:
     695       896484 :         case TS_LABEL_DECL:
     696       896484 :         case TS_RESULT_DECL:
     697       896484 :           MARK_TS_DECL_WRTL (code);
     698       896484 :           break;
     699              : 
     700       298828 :         case TS_FIELD_DECL:
     701       298828 :           MARK_TS_DECL_COMMON (code);
     702       298828 :           break;
     703              : 
     704       298828 :         case TS_VAR_DECL:
     705       298828 :           MARK_TS_DECL_WITH_VIS (code);
     706       298828 :           break;
     707              : 
     708       597656 :         case TS_TYPE_DECL:
     709       597656 :         case TS_FUNCTION_DECL:
     710       597656 :           MARK_TS_DECL_NON_COMMON (code);
     711       597656 :           break;
     712              : 
     713       298828 :         case TS_TRANSLATION_UNIT_DECL:
     714       298828 :           MARK_TS_DECL_COMMON (code);
     715       298828 :           break;
     716              : 
     717              :         default:
     718              :           gcc_unreachable ();
     719              :         }
     720              :     }
     721              : 
     722              :   /* Basic consistency checks for attributes used in fold.  */
     723       298828 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]);
     724       298828 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]);
     725       298828 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]);
     726       298828 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]);
     727       298828 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]);
     728       298828 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]);
     729       298828 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_COMMON]);
     730       298828 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_COMMON]);
     731       298828 :   gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_COMMON]);
     732       298828 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_COMMON]);
     733       298828 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_COMMON]);
     734       298828 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WRTL]);
     735       298828 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_WRTL]);
     736       298828 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_WRTL]);
     737       298828 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WRTL]);
     738       298828 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_WRTL]);
     739       298828 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_MINIMAL]);
     740       298828 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_MINIMAL]);
     741       298828 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_MINIMAL]);
     742       298828 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_MINIMAL]);
     743       298828 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_MINIMAL]);
     744       298828 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_MINIMAL]);
     745       298828 :   gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_MINIMAL]);
     746       298828 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]);
     747       298828 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]);
     748       298828 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]);
     749       298828 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]);
     750       298828 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]);
     751       298828 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]);
     752       298828 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]);
     753       298828 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]);
     754       298828 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]);
     755       298828 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]);
     756       298828 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_CONST_DECL]);
     757       298828 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_TYPE_DECL]);
     758       298828 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_FUNCTION_DECL]);
     759       298828 :   gcc_assert (tree_contains_struct[IMPORTED_DECL][TS_DECL_MINIMAL]);
     760       298828 :   gcc_assert (tree_contains_struct[IMPORTED_DECL][TS_DECL_COMMON]);
     761       298828 :   gcc_assert (tree_contains_struct[NAMELIST_DECL][TS_DECL_MINIMAL]);
     762       298828 :   gcc_assert (tree_contains_struct[NAMELIST_DECL][TS_DECL_COMMON]);
     763       298828 : }
     764              : 
     765              : 
     766              : /* Init tree.cc.  */
     767              : 
     768              : void
     769       298828 : init_ttree (void)
     770              : {
     771              :   /* Initialize the hash table of types.  */
     772       298828 :   type_hash_table
     773       298828 :     = hash_table<type_cache_hasher>::create_ggc (TYPE_HASH_INITIAL_SIZE);
     774              : 
     775       298828 :   debug_expr_for_decl
     776       298828 :     = hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
     777              : 
     778       298828 :   value_expr_for_decl
     779       298828 :     = hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
     780              : 
     781       298828 :   int_cst_hash_table = hash_table<int_cst_hasher>::create_ggc (1024);
     782              : 
     783       298828 :   poly_int_cst_hash_table = hash_table<poly_int_cst_hasher>::create_ggc (64);
     784              : 
     785       298828 :   int_cst_node = make_int_cst (1, 1);
     786              : 
     787       298828 :   cl_option_hash_table = hash_table<cl_option_hasher>::create_ggc (64);
     788              : 
     789       298828 :   cl_optimization_node = make_node (OPTIMIZATION_NODE);
     790       298828 :   cl_target_option_node = make_node (TARGET_OPTION_NODE);
     791              : 
     792              :   /* Initialize the tree_contains_struct array.  */
     793       298828 :   initialize_tree_contains_struct ();
     794       298828 :   lang_hooks.init_ts ();
     795       298828 : }
     796              : 
     797              : 
     798              : /* Mapping from prefix to label number.  */
     799              : 
     800              : struct identifier_hash : ggc_ptr_hash <tree_node>
     801              : {
     802        46354 :   static inline hashval_t hash (tree t)
     803              :   {
     804        46354 :     return IDENTIFIER_HASH_VALUE (t);
     805              :   }
     806              : };
     807              : struct identifier_count_traits
     808              :   : simple_hashmap_traits<identifier_hash, long> {};
     809              : typedef hash_map<tree, long, identifier_count_traits> internal_label_map;
     810              : static GTY(()) internal_label_map *internal_label_nums;
     811              : 
     812              : /* Generates an identifier intended to be used internally with the
     813              :    given PREFIX.  This is intended to be used by the frontend so that
     814              :    C++ modules can regenerate appropriate (non-clashing) identifiers on
     815              :    stream-in.  */
     816              : 
     817              : tree
     818        39743 : generate_internal_label (const char *prefix)
     819              : {
     820        39743 :   tree prefix_id = get_identifier (prefix);
     821        39743 :   if (!internal_label_nums)
     822         3034 :     internal_label_nums = internal_label_map::create_ggc();
     823        39743 :   long &num = internal_label_nums->get_or_insert (prefix_id);
     824              : 
     825        39743 :   char tmp[32];
     826        39743 :   ASM_GENERATE_INTERNAL_LABEL (tmp, prefix, num++);
     827              : 
     828        39743 :   tree id = get_identifier (tmp);
     829        39743 :   IDENTIFIER_INTERNAL_P (id) = true;
     830              : 
     831              :   /* Cache the prefix on the identifier so we can retrieve it later.  */
     832        39743 :   TREE_CHAIN (id) = prefix_id;
     833              : 
     834        39743 :   return id;
     835              : }
     836              : 
     837              : /* Get the PREFIX we created the internal identifier LABEL with.  */
     838              : 
     839              : const char *
     840            7 : prefix_for_internal_label (tree label)
     841              : {
     842            7 :   gcc_assert (IDENTIFIER_INTERNAL_P (label)
     843              :               && !IDENTIFIER_TRANSPARENT_ALIAS (label)
     844              :               && TREE_CHAIN (label)
     845              :               && TREE_CODE (TREE_CHAIN (label)) == IDENTIFIER_NODE);
     846            7 :   return IDENTIFIER_POINTER (TREE_CHAIN (label));
     847              : }
     848              : 
     849              : /* The name of the object as the assembler will see it (but before any
     850              :    translations made by ASM_OUTPUT_LABELREF).  Often this is the same
     851              :    as DECL_NAME.  It is an IDENTIFIER_NODE.  */
     852              : tree
     853   1698361324 : decl_assembler_name (tree decl)
     854              : {
     855   1698361324 :   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
     856    163926222 :     lang_hooks.set_decl_assembler_name (decl);
     857   1698361324 :   return DECL_ASSEMBLER_NAME_RAW (decl);
     858              : }
     859              : 
     860              : /* The DECL_ASSEMBLER_NAME_RAW of DECL is being explicitly set to NAME
     861              :    (either of which may be NULL).  Inform the FE, if this changes the
     862              :    name.  */
     863              : 
     864              : void
     865    890248756 : overwrite_decl_assembler_name (tree decl, tree name)
     866              : {
     867    890248756 :   if (DECL_ASSEMBLER_NAME_RAW (decl) != name)
     868    449323892 :     lang_hooks.overwrite_decl_assembler_name (decl, name);
     869    890248756 : }
     870              : 
     871              : /* Return true if DECL may need an assembler name to be set.  */
     872              : 
     873              : static inline bool
     874      5029641 : need_assembler_name_p (tree decl)
     875              : {
     876              :   /* We use DECL_ASSEMBLER_NAME to hold mangled type names for One Definition
     877              :      Rule merging.  This makes type_odr_p to return true on those types during
     878              :      LTO and by comparing the mangled name, we can say what types are intended
     879              :      to be equivalent across compilation unit.
     880              : 
     881              :      We do not store names of type_in_anonymous_namespace_p.
     882              : 
     883              :      Record, union and enumeration type have linkage that allows use
     884              :      to check type_in_anonymous_namespace_p. We do not mangle compound types
     885              :      that always can be compared structurally.
     886              : 
     887              :      Similarly for builtin types, we compare properties of their main variant.
     888              :      A special case are integer types where mangling do make differences
     889              :      between char/signed char/unsigned char etc.  Storing name for these makes
     890              :      e.g.  -fno-signed-char/-fsigned-char mismatches to be handled well.
     891              :      See cp/mangle.cc:write_builtin_type for details.  */
     892              : 
     893      5029641 :   if (TREE_CODE (decl) == TYPE_DECL)
     894              :     {
     895       160008 :       if (DECL_NAME (decl)
     896       130728 :           && decl == TYPE_NAME (TREE_TYPE (decl))
     897       130573 :           && TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == TREE_TYPE (decl)
     898       111395 :           && !TYPE_ARTIFICIAL (TREE_TYPE (decl))
     899       108375 :           && ((TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
     900        90569 :                && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE)
     901        18064 :               || TYPE_CXX_ODR_P (TREE_TYPE (decl)))
     902       106976 :           && (type_with_linkage_p (TREE_TYPE (decl))
     903        92171 :               || TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE)
     904       230366 :           && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
     905        70358 :         return !DECL_ASSEMBLER_NAME_SET_P (decl);
     906        89650 :       return false;
     907              :     }
     908              :   /* Only FUNCTION_DECLs and VAR_DECLs are considered.  */
     909      4869633 :   if (!VAR_OR_FUNCTION_DECL_P (decl))
     910              :     return false;
     911              : 
     912              :   /* If DECL already has its assembler name set, it does not need a
     913              :      new one.  */
     914      4174073 :   if (!HAS_DECL_ASSEMBLER_NAME_P (decl)
     915      4174073 :       || DECL_ASSEMBLER_NAME_SET_P (decl))
     916              :     return false;
     917              : 
     918              :   /* Abstract decls do not need an assembler name, except they
     919              :      can be looked up by autofdo.  */
     920      1704741 :   if (DECL_ABSTRACT_P (decl) && !flag_auto_profile)
     921              :     return false;
     922              : 
     923              :   /* For VAR_DECLs, only static, public and external symbols need an
     924              :      assembler name.  */
     925      1703366 :   if (VAR_P (decl)
     926       543374 :       && !TREE_STATIC (decl)
     927       543049 :       && !TREE_PUBLIC (decl)
     928      2246415 :       && !DECL_EXTERNAL (decl))
     929              :     return false;
     930              : 
     931      1160317 :   if (TREE_CODE (decl) == FUNCTION_DECL)
     932              :     {
     933              :       /* Do not set assembler name on builtins.  Allow RTL expansion to
     934              :          decide whether to expand inline or via a regular call.  */
     935      1159992 :       if (fndecl_built_in_p (decl)
     936      1159992 :           && DECL_BUILT_IN_CLASS (decl) != BUILT_IN_FRONTEND)
     937              :         return false;
     938              : 
     939              :       /* Functions represented in the callgraph need an assembler name.  */
     940      1155278 :       if (cgraph_node::get (decl) != NULL)
     941              :         return true;
     942              : 
     943              :       /* Unused and not public functions don't need an assembler name.  */
     944         3341 :       if (!TREE_USED (decl) && !TREE_PUBLIC (decl))
     945              :         return false;
     946              :     }
     947              : 
     948              :   return true;
     949              : }
     950              : 
     951              : /* If T needs an assembler name, have one created for it.  */
     952              : 
     953              : void
     954      5029641 : assign_assembler_name_if_needed (tree t)
     955              : {
     956      5029641 :   if (need_assembler_name_p (t))
     957              :     {
     958              :       /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit
     959              :          diagnostics that use input_location to show locus
     960              :          information.  The problem here is that, at this point,
     961              :          input_location is generally anchored to the end of the file
     962              :          (since the parser is long gone), so we don't have a good
     963              :          position to pin it to.
     964              : 
     965              :          To alleviate this problem, this uses the location of T's
     966              :          declaration.  Examples of this are
     967              :          testsuite/g++.dg/template/cond2.C and
     968              :          testsuite/g++.dg/template/pr35240.C.  */
     969      1225935 :       location_t saved_location = input_location;
     970      1225935 :       input_location = DECL_SOURCE_LOCATION (t);
     971              : 
     972      1225935 :       decl_assembler_name (t);
     973              : 
     974      1225935 :       input_location = saved_location;
     975              :     }
     976      5029641 : }
     977              : 
     978              : /* When the target supports COMDAT groups, this indicates which group the
     979              :    DECL is associated with.  This can be either an IDENTIFIER_NODE or a
     980              :    decl, in which case its DECL_ASSEMBLER_NAME identifies the group.  */
     981              : tree
     982    375342800 : decl_comdat_group (const_tree node)
     983              : {
     984    375342800 :   struct symtab_node *snode = symtab_node::get (node);
     985    375342800 :   if (!snode)
     986              :     return NULL;
     987    358718882 :   return snode->get_comdat_group ();
     988              : }
     989              : 
     990              : /* Likewise, but make sure it's been reduced to an IDENTIFIER_NODE.  */
     991              : tree
     992        11912 : decl_comdat_group_id (const_tree node)
     993              : {
     994        11912 :   struct symtab_node *snode = symtab_node::get (node);
     995        11912 :   if (!snode)
     996              :     return NULL;
     997        11912 :   return snode->get_comdat_group_id ();
     998              : }
     999              : 
    1000              : /* When the target supports named section, return its name as IDENTIFIER_NODE
    1001              :    or NULL if it is in no section.  */
    1002              : const char *
    1003    713150556 : decl_section_name (const_tree node)
    1004              : {
    1005    713150556 :   struct symtab_node *snode = symtab_node::get (node);
    1006    713150556 :   if (!snode)
    1007              :     return NULL;
    1008    536627173 :   return snode->get_section ();
    1009              : }
    1010              : 
    1011              : /* Set section name of NODE to VALUE (that is expected to be
    1012              :    identifier node) */
    1013              : void
    1014      1800580 : set_decl_section_name (tree node, const char *value)
    1015              : {
    1016      1800580 :   struct symtab_node *snode;
    1017              : 
    1018      1800580 :   if (value == NULL)
    1019              :     {
    1020           48 :       snode = symtab_node::get (node);
    1021           48 :       if (!snode)
    1022              :         return;
    1023              :     }
    1024      1800532 :   else if (VAR_P (node))
    1025      1558466 :     snode = varpool_node::get_create (node);
    1026              :   else
    1027       242066 :     snode = cgraph_node::get_create (node);
    1028      1800580 :   snode->set_section (value);
    1029              : }
    1030              : 
    1031              : /* Set section name of NODE to match the section name of OTHER.
    1032              : 
    1033              :    set_decl_section_name (decl, other) is equivalent to
    1034              :    set_decl_section_name (decl, DECL_SECTION_NAME (other)), but possibly more
    1035              :    efficient.  */
    1036              : void
    1037     15789938 : set_decl_section_name (tree decl, const_tree other)
    1038              : {
    1039     15789938 :   struct symtab_node *other_node = symtab_node::get (other);
    1040     15789938 :   if (other_node)
    1041              :     {
    1042     15774510 :       struct symtab_node *decl_node;
    1043     15774510 :       if (VAR_P (decl))
    1044           23 :     decl_node = varpool_node::get_create (decl);
    1045              :       else
    1046     15774487 :     decl_node = cgraph_node::get_create (decl);
    1047     15774510 :       decl_node->set_section (*other_node);
    1048              :     }
    1049              :   else
    1050              :     {
    1051        15428 :       struct symtab_node *decl_node = symtab_node::get (decl);
    1052        15428 :       if (!decl_node)
    1053              :     return;
    1054            0 :       decl_node->set_section (NULL);
    1055              :     }
    1056              : }
    1057              : 
    1058              : /* Return TLS model of a variable NODE.  */
    1059              : enum tls_model
    1060    272087462 : decl_tls_model (const_tree node)
    1061              : {
    1062    272087462 :   struct varpool_node *snode = varpool_node::get (node);
    1063    272087462 :   if (!snode)
    1064              :     return TLS_MODEL_NONE;
    1065    224967074 :   return snode->tls_model;
    1066              : }
    1067              : 
    1068              : /* Set TLS model of variable NODE to MODEL.  */
    1069              : void
    1070        56075 : set_decl_tls_model (tree node, enum tls_model model)
    1071              : {
    1072        56075 :   struct varpool_node *vnode;
    1073              : 
    1074        56075 :   if (model == TLS_MODEL_NONE)
    1075              :     {
    1076         5907 :       vnode = varpool_node::get (node);
    1077         5907 :       if (!vnode)
    1078              :         return;
    1079              :     }
    1080              :   else
    1081        50168 :     vnode = varpool_node::get_create (node);
    1082        50168 :   vnode->tls_model = model;
    1083              : }
    1084              : 
    1085              : /* Compute the number of bytes occupied by a tree with code CODE.
    1086              :    This function cannot be used for nodes that have variable sizes,
    1087              :    including TREE_VEC, INTEGER_CST, STRING_CST, and CALL_EXPR.  */
    1088              : size_t
    1089  18344843490 : tree_code_size (enum tree_code code)
    1090              : {
    1091  18344843490 :   switch (TREE_CODE_CLASS (code))
    1092              :     {
    1093   4441254018 :     case tcc_declaration:  /* A decl node */
    1094   4441254018 :       switch (code)
    1095              :         {
    1096              :         case FIELD_DECL:        return sizeof (tree_field_decl);
    1097              :         case PARM_DECL:         return sizeof (tree_parm_decl);
    1098    266333934 :         case VAR_DECL:          return sizeof (tree_var_decl);
    1099              :         case LABEL_DECL:        return sizeof (tree_label_decl);
    1100              :         case RESULT_DECL:       return sizeof (tree_result_decl);
    1101     29974788 :         case CONST_DECL:        return sizeof (tree_const_decl);
    1102              :         case TYPE_DECL:         return sizeof (tree_type_decl);
    1103   1456378843 :         case FUNCTION_DECL:     return sizeof (tree_function_decl);
    1104              :         case DEBUG_EXPR_DECL:   return sizeof (tree_decl_with_rtl);
    1105              :         case TRANSLATION_UNIT_DECL: return sizeof (tree_translation_unit_decl);
    1106              :         case NAMESPACE_DECL:
    1107              :         case IMPORTED_DECL:
    1108              :         case NAMELIST_DECL:     return sizeof (tree_decl_non_common);
    1109    284164730 :         default:
    1110    284164730 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1111    284164730 :           return lang_hooks.tree_size (code);
    1112              :         }
    1113              : 
    1114   3070859914 :     case tcc_type:  /* a type node */
    1115   3070859914 :       switch (code)
    1116              :         {
    1117              :         case OFFSET_TYPE:
    1118              :         case ENUMERAL_TYPE:
    1119              :         case BOOLEAN_TYPE:
    1120              :         case INTEGER_TYPE:
    1121              :         case REAL_TYPE:
    1122              :         case OPAQUE_TYPE:
    1123              :         case POINTER_TYPE:
    1124              :         case REFERENCE_TYPE:
    1125              :         case NULLPTR_TYPE:
    1126              :         case FIXED_POINT_TYPE:
    1127              :         case COMPLEX_TYPE:
    1128              :         case VECTOR_TYPE:
    1129              :         case ARRAY_TYPE:
    1130              :         case RECORD_TYPE:
    1131              :         case UNION_TYPE:
    1132              :         case QUAL_UNION_TYPE:
    1133              :         case VOID_TYPE:
    1134              :         case FUNCTION_TYPE:
    1135              :         case METHOD_TYPE:
    1136              :         case BITINT_TYPE:
    1137              :         case LANG_TYPE:         return sizeof (tree_type_non_common);
    1138    722885725 :         default:
    1139    722885725 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1140    722885725 :           return lang_hooks.tree_size (code);
    1141              :         }
    1142              : 
    1143   4974526069 :     case tcc_reference:   /* a reference */
    1144   4974526069 :     case tcc_expression:  /* an expression */
    1145   4974526069 :     case tcc_statement:   /* an expression with side effects */
    1146   4974526069 :     case tcc_comparison:  /* a comparison expression */
    1147   4974526069 :     case tcc_unary:       /* a unary arithmetic expression */
    1148   4974526069 :     case tcc_binary:      /* a binary arithmetic expression */
    1149   4974526069 :       return (sizeof (struct tree_exp)
    1150   4974526069 :               + (TREE_CODE_LENGTH (code) - 1) * sizeof (tree));
    1151              : 
    1152     42091316 :     case tcc_constant:  /* a constant */
    1153     42091316 :       switch (code)
    1154              :         {
    1155              :         case VOID_CST:          return sizeof (tree_typed);
    1156            0 :         case INTEGER_CST:       gcc_unreachable ();
    1157              :         case POLY_INT_CST:      return sizeof (tree_poly_int_cst);
    1158     41235575 :         case REAL_CST:          return sizeof (tree_real_cst);
    1159              :         case FIXED_CST:         return sizeof (tree_fixed_cst);
    1160              :         case COMPLEX_CST:       return sizeof (tree_complex);
    1161              :         case RAW_DATA_CST:      return sizeof (tree_raw_data);
    1162            0 :         case VECTOR_CST:        gcc_unreachable ();
    1163            0 :         case STRING_CST:        gcc_unreachable ();
    1164        62125 :         default:
    1165        62125 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1166        62125 :           return lang_hooks.tree_size (code);
    1167              :         }
    1168              : 
    1169   5816112173 :     case tcc_exceptional:  /* something random, like an identifier.  */
    1170   5816112173 :       switch (code)
    1171              :         {
    1172   1743258379 :         case IDENTIFIER_NODE:   return lang_hooks.identifier_size;
    1173              :         case TREE_LIST:         return sizeof (tree_list);
    1174              : 
    1175              :         case ERROR_MARK:
    1176              :         case PLACEHOLDER_EXPR:  return sizeof (tree_common);
    1177              : 
    1178            0 :         case TREE_VEC:          gcc_unreachable ();
    1179            0 :         case OMP_CLAUSE:        gcc_unreachable ();
    1180              : 
    1181              :         case SSA_NAME:          return sizeof (tree_ssa_name);
    1182              : 
    1183              :         case STATEMENT_LIST:    return sizeof (tree_statement_list);
    1184    300053393 :         case BLOCK:             return sizeof (struct tree_block);
    1185              :         case CONSTRUCTOR:       return sizeof (tree_constructor);
    1186              :         case OPTIMIZATION_NODE: return sizeof (tree_optimization_option);
    1187              :         case TARGET_OPTION_NODE: return sizeof (tree_target_option);
    1188              : 
    1189   1590431968 :         default:
    1190   1590431968 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1191   1590431968 :           return lang_hooks.tree_size (code);
    1192              :         }
    1193              : 
    1194            0 :     default:
    1195            0 :       gcc_unreachable ();
    1196              :     }
    1197              : }
    1198              : 
    1199              : /* Compute the number of bytes occupied by NODE.  This routine only
    1200              :    looks at TREE_CODE, except for those nodes that have variable sizes.  */
    1201              : size_t
    1202   4380296189 : tree_size (const_tree node)
    1203              : {
    1204   4380296189 :   const enum tree_code code = TREE_CODE (node);
    1205   4380296189 :   switch (code)
    1206              :     {
    1207       540221 :     case INTEGER_CST:
    1208       540221 :       return (sizeof (struct tree_int_cst)
    1209       540221 :               + (TREE_INT_CST_EXT_NUNITS (node) - 1) * sizeof (HOST_WIDE_INT));
    1210              : 
    1211            0 :     case TREE_BINFO:
    1212            0 :       return (offsetof (struct tree_binfo, base_binfos)
    1213              :               + vec<tree, va_gc>
    1214            0 :                   ::embedded_size (BINFO_N_BASE_BINFOS (node)));
    1215              : 
    1216    404134383 :     case TREE_VEC:
    1217    404134383 :       return (sizeof (struct tree_vec)
    1218    404134383 :               + (TREE_VEC_LENGTH (node) - 1) * sizeof (tree));
    1219              : 
    1220            0 :     case VECTOR_CST:
    1221            0 :       return (sizeof (struct tree_vector)
    1222            0 :               + (vector_cst_encoded_nelts (node) - 1) * sizeof (tree));
    1223              : 
    1224        22862 :     case STRING_CST:
    1225        22862 :       return TREE_STRING_LENGTH (node) + offsetof (struct tree_string, str) + 1;
    1226              : 
    1227        33585 :     case OMP_CLAUSE:
    1228        33585 :       return (sizeof (struct tree_omp_clause)
    1229        33585 :               + (omp_clause_num_ops[OMP_CLAUSE_CODE (node)] - 1)
    1230        33585 :                 * sizeof (tree));
    1231              : 
    1232   3975565138 :     default:
    1233   3975565138 :       if (TREE_CODE_CLASS (code) == tcc_vl_exp)
    1234    180039016 :         return (sizeof (struct tree_exp)
    1235    180039016 :                 + (VL_EXP_OPERAND_LENGTH (node) - 1) * sizeof (tree));
    1236              :       else
    1237   3795526122 :         return tree_code_size (code);
    1238              :     }
    1239              : }
    1240              : 
    1241              : /* Return tree node kind based on tree CODE.  */
    1242              : 
    1243              : static tree_node_kind
    1244            0 : get_stats_node_kind (enum tree_code code)
    1245              : {
    1246            0 :   enum tree_code_class type = TREE_CODE_CLASS (code);
    1247              : 
    1248            0 :   switch (type)
    1249              :     {
    1250              :     case tcc_declaration:  /* A decl node */
    1251              :       return d_kind;
    1252            0 :     case tcc_type:  /* a type node */
    1253            0 :       return t_kind;
    1254            0 :     case tcc_statement:  /* an expression with side effects */
    1255            0 :       return s_kind;
    1256            0 :     case tcc_reference:  /* a reference */
    1257            0 :       return r_kind;
    1258              :     case tcc_expression:  /* an expression */
    1259              :     case tcc_comparison:  /* a comparison expression */
    1260              :     case tcc_unary:  /* a unary arithmetic expression */
    1261              :     case tcc_binary:  /* a binary arithmetic expression */
    1262              :       return e_kind;
    1263            0 :     case tcc_constant:  /* a constant */
    1264            0 :       return c_kind;
    1265            0 :     case tcc_exceptional:  /* something random, like an identifier.  */
    1266            0 :       switch (code)
    1267              :         {
    1268              :         case IDENTIFIER_NODE:
    1269              :           return id_kind;
    1270            0 :         case TREE_VEC:
    1271            0 :           return vec_kind;
    1272            0 :         case TREE_BINFO:
    1273            0 :           return binfo_kind;
    1274            0 :         case SSA_NAME:
    1275            0 :           return ssa_name_kind;
    1276            0 :         case BLOCK:
    1277            0 :           return b_kind;
    1278            0 :         case CONSTRUCTOR:
    1279            0 :           return constr_kind;
    1280            0 :         case OMP_CLAUSE:
    1281            0 :           return omp_clause_kind;
    1282            0 :         default:
    1283            0 :           return x_kind;
    1284              :         }
    1285              :       break;
    1286              :     case tcc_vl_exp:
    1287              :       return e_kind;
    1288            0 :     default:
    1289            0 :       gcc_unreachable ();
    1290              :     }
    1291              : }
    1292              : 
    1293              : /* Record interesting allocation statistics for a tree node with CODE
    1294              :    and LENGTH.  */
    1295              : 
    1296              : static void
    1297            0 : record_node_allocation_statistics (enum tree_code code, size_t length)
    1298              : {
    1299            0 :   if (!GATHER_STATISTICS)
    1300            0 :     return;
    1301              : 
    1302              :   tree_node_kind kind = get_stats_node_kind (code);
    1303              : 
    1304              :   tree_code_counts[(int) code]++;
    1305              :   tree_node_counts[(int) kind]++;
    1306              :   tree_node_sizes[(int) kind] += length;
    1307              : }
    1308              : 
    1309              : /* Allocate and return a new UID from the DECL_UID namespace.  */
    1310              : 
    1311              : int
    1312   4434714399 : allocate_decl_uid (void)
    1313              : {
    1314   4434714399 :   return next_decl_uid++;
    1315              : }
    1316              : 
    1317              : /* Return a newly allocated node of code CODE.  For decl and type
    1318              :    nodes, some other fields are initialized.  The rest of the node is
    1319              :    initialized to zero.  This function cannot be used for TREE_VEC,
    1320              :    INTEGER_CST or OMP_CLAUSE nodes, which is enforced by asserts in
    1321              :    tree_code_size.
    1322              : 
    1323              :    Achoo!  I got a code in the node.  */
    1324              : 
    1325              : tree
    1326  14543661999 : make_node (enum tree_code code MEM_STAT_DECL)
    1327              : {
    1328  14543661999 :   tree t;
    1329  14543661999 :   enum tree_code_class type = TREE_CODE_CLASS (code);
    1330  14543661999 :   size_t length = tree_code_size (code);
    1331              : 
    1332  14543661999 :   record_node_allocation_statistics (code, length);
    1333              : 
    1334  14543661999 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    1335  14543661999 :   TREE_SET_CODE (t, code);
    1336              : 
    1337  14543661999 :   switch (type)
    1338              :     {
    1339    749959668 :     case tcc_statement:
    1340    749959668 :       if (code != DEBUG_BEGIN_STMT)
    1341    393754192 :         TREE_SIDE_EFFECTS (t) = 1;
    1342              :       break;
    1343              : 
    1344   3186902903 :     case tcc_declaration:
    1345   3186902903 :       if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
    1346              :         {
    1347   3186902903 :           if (code == FUNCTION_DECL)
    1348              :             {
    1349   1147196417 :               SET_DECL_ALIGN (t, FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY));
    1350   1147196417 :               SET_DECL_MODE (t, FUNCTION_MODE);
    1351              :             }
    1352              :           else
    1353   2039706486 :             SET_DECL_ALIGN (t, 1);
    1354              :         }
    1355   3186902903 :       DECL_SOURCE_LOCATION (t) = input_location;
    1356   3186902903 :       if (TREE_CODE (t) == DEBUG_EXPR_DECL)
    1357      1921116 :         DECL_UID (t) = --next_debug_decl_uid;
    1358              :       else
    1359              :         {
    1360   3184981787 :           DECL_UID (t) = allocate_decl_uid ();
    1361   3184981787 :           SET_DECL_PT_UID (t, -1);
    1362              :         }
    1363   3186902903 :       if (TREE_CODE (t) == LABEL_DECL)
    1364     36443596 :         LABEL_DECL_UID (t) = -1;
    1365              : 
    1366              :       break;
    1367              : 
    1368   2268983263 :     case tcc_type:
    1369   2268983263 :       TYPE_UID (t) = next_type_uid++;
    1370   2268983263 :       SET_TYPE_ALIGN (t, BITS_PER_UNIT);
    1371   2268983263 :       TYPE_USER_ALIGN (t) = 0;
    1372   2268983263 :       TYPE_MAIN_VARIANT (t) = t;
    1373   2268983263 :       TYPE_CANONICAL (t) = t;
    1374              : 
    1375              :       /* Default to no attributes for type, but let target change that.  */
    1376   2268983263 :       TYPE_ATTRIBUTES (t) = NULL_TREE;
    1377   2268983263 :       targetm.set_default_type_attributes (t);
    1378              : 
    1379              :       /* We have not yet computed the alias set for this type.  */
    1380   2268983263 :       TYPE_ALIAS_SET (t) = -1;
    1381   2268983263 :       break;
    1382              : 
    1383     42089558 :     case tcc_constant:
    1384     42089558 :       TREE_CONSTANT (t) = 1;
    1385     42089558 :       break;
    1386              : 
    1387   1303381711 :     case tcc_expression:
    1388   1303381711 :       switch (code)
    1389              :         {
    1390    281950092 :         case INIT_EXPR:
    1391    281950092 :         case MODIFY_EXPR:
    1392    281950092 :         case VA_ARG_EXPR:
    1393    281950092 :         case PREDECREMENT_EXPR:
    1394    281950092 :         case PREINCREMENT_EXPR:
    1395    281950092 :         case POSTDECREMENT_EXPR:
    1396    281950092 :         case POSTINCREMENT_EXPR:
    1397              :           /* All of these have side-effects, no matter what their
    1398              :              operands are.  */
    1399    281950092 :           TREE_SIDE_EFFECTS (t) = 1;
    1400    281950092 :           break;
    1401              : 
    1402              :         default:
    1403              :           break;
    1404              :         }
    1405              :       break;
    1406              : 
    1407   5607250609 :     case tcc_exceptional:
    1408   5607250609 :       switch (code)
    1409              :         {
    1410      1108691 :         case TARGET_OPTION_NODE:
    1411      2217382 :           TREE_TARGET_OPTION(t)
    1412      1108691 :                             = ggc_cleared_alloc<struct cl_target_option> ();
    1413      1108691 :           break;
    1414              : 
    1415       624447 :         case OPTIMIZATION_NODE:
    1416      1248894 :           TREE_OPTIMIZATION (t)
    1417       624447 :                             = ggc_cleared_alloc<struct cl_optimization> ();
    1418       624447 :           break;
    1419              : 
    1420              :         default:
    1421              :           break;
    1422              :         }
    1423              :       break;
    1424              : 
    1425              :     default:
    1426              :       /* Other classes need no special treatment.  */
    1427              :       break;
    1428              :     }
    1429              : 
    1430  14543661999 :   return t;
    1431              : }
    1432              : 
    1433              : /* Free tree node.  */
    1434              : 
    1435              : void
    1436    666577610 : free_node (tree node)
    1437              : {
    1438    666577610 :   enum tree_code code = TREE_CODE (node);
    1439    666577610 :   if (GATHER_STATISTICS)
    1440              :     {
    1441              :       enum tree_node_kind kind = get_stats_node_kind (code);
    1442              : 
    1443              :       gcc_checking_assert (tree_code_counts[(int) TREE_CODE (node)] != 0);
    1444              :       gcc_checking_assert (tree_node_counts[(int) kind] != 0);
    1445              :       gcc_checking_assert (tree_node_sizes[(int) kind] >= tree_size (node));
    1446              : 
    1447              :       tree_code_counts[(int) TREE_CODE (node)]--;
    1448              :       tree_node_counts[(int) kind]--;
    1449              :       tree_node_sizes[(int) kind] -= tree_size (node);
    1450              :     }
    1451    666577610 :   if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
    1452          349 :     vec_free (CONSTRUCTOR_ELTS (node));
    1453    666577417 :   else if (code == BLOCK)
    1454            0 :     vec_free (BLOCK_NONLOCALIZED_VARS (node));
    1455    666577417 :   else if (code == TREE_BINFO)
    1456          369 :     vec_free (BINFO_BASE_ACCESSES (node));
    1457    666577048 :   else if (code == OPTIMIZATION_NODE)
    1458          830 :     cl_optimization_option_free (TREE_OPTIMIZATION (node));
    1459    666576218 :   else if (code == TARGET_OPTION_NODE)
    1460          895 :     cl_target_option_free (TREE_TARGET_OPTION (node));
    1461    666577610 :   ggc_free (node);
    1462    666577610 : }
    1463              : 
    1464              : /* Return a new node with the same contents as NODE except that its
    1465              :    TREE_CHAIN, if it has one, is zero and it has a fresh uid.  */
    1466              : 
    1467              : tree
    1468   4298484029 : copy_node (tree node MEM_STAT_DECL)
    1469              : {
    1470   4298484029 :   tree t;
    1471   4298484029 :   enum tree_code code = TREE_CODE (node);
    1472   4298484029 :   size_t length;
    1473              : 
    1474   4298484029 :   gcc_assert (code != STATEMENT_LIST);
    1475              : 
    1476   4298484029 :   length = tree_size (node);
    1477   4298484029 :   record_node_allocation_statistics (code, length);
    1478   4298484029 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    1479   4298484029 :   memcpy (t, node, length);
    1480              : 
    1481   4298484029 :   if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
    1482   2503279442 :     TREE_CHAIN (t) = 0;
    1483   4298484029 :   TREE_ASM_WRITTEN (t) = 0;
    1484   4298484029 :   TREE_VISITED (t) = 0;
    1485              : 
    1486   4298484029 :   if (TREE_CODE_CLASS (code) == tcc_declaration)
    1487              :     {
    1488   1248695746 :       if (code == DEBUG_EXPR_DECL)
    1489            0 :         DECL_UID (t) = --next_debug_decl_uid;
    1490              :       else
    1491              :         {
    1492   1248695746 :           DECL_UID (t) = allocate_decl_uid ();
    1493   1248695746 :           if (DECL_PT_UID_SET_P (node))
    1494         3524 :             SET_DECL_PT_UID (t, DECL_PT_UID (node));
    1495              :         }
    1496    620820414 :       if ((TREE_CODE (node) == PARM_DECL || VAR_P (node))
    1497   1329466402 :           && DECL_HAS_VALUE_EXPR_P (node))
    1498              :         {
    1499       846554 :           SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node));
    1500       846554 :           DECL_HAS_VALUE_EXPR_P (t) = 1;
    1501              :         }
    1502              :       /* DECL_DEBUG_EXPR is copied explicitly by callers.  */
    1503   1248695746 :       if (VAR_P (node))
    1504              :         {
    1505     80770656 :           DECL_HAS_DEBUG_EXPR_P (t) = 0;
    1506     80770656 :           t->decl_with_vis.symtab_node = NULL;
    1507              :         }
    1508   1248695746 :       if (VAR_P (node) && DECL_HAS_INIT_PRIORITY_P (node))
    1509              :         {
    1510            0 :           SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node));
    1511            0 :           DECL_HAS_INIT_PRIORITY_P (t) = 1;
    1512              :         }
    1513   1248695746 :       if (TREE_CODE (node) == FUNCTION_DECL)
    1514              :         {
    1515    304133197 :           DECL_STRUCT_FUNCTION (t) = NULL;
    1516    304133197 :           t->decl_with_vis.symtab_node = NULL;
    1517              :         }
    1518              :     }
    1519   3049788283 :   else if (TREE_CODE_CLASS (code) == tcc_type)
    1520              :     {
    1521    801876651 :       TYPE_UID (t) = next_type_uid++;
    1522              :       /* The following is so that the debug code for
    1523              :          the copy is different from the original type.
    1524              :          The two statements usually duplicate each other
    1525              :          (because they clear fields of the same union),
    1526              :          but the optimizer should catch that.  */
    1527    801876651 :       TYPE_SYMTAB_ADDRESS (t) = 0;
    1528    801876651 :       TYPE_SYMTAB_DIE (t) = 0;
    1529              : 
    1530              :       /* Do not copy the values cache.  */
    1531    801876651 :       if (TYPE_CACHED_VALUES_P (t))
    1532              :         {
    1533     19344761 :           TYPE_CACHED_VALUES_P (t) = 0;
    1534     19344761 :           TYPE_CACHED_VALUES (t) = NULL_TREE;
    1535              :         }
    1536              :     }
    1537   2247911632 :     else if (code == TARGET_OPTION_NODE)
    1538              :       {
    1539            0 :         TREE_TARGET_OPTION (t) = ggc_alloc<struct cl_target_option>();
    1540            0 :         memcpy (TREE_TARGET_OPTION (t), TREE_TARGET_OPTION (node),
    1541              :                 sizeof (struct cl_target_option));
    1542              :       }
    1543   2247911632 :     else if (code == OPTIMIZATION_NODE)
    1544              :       {
    1545            0 :         TREE_OPTIMIZATION (t) = ggc_alloc<struct cl_optimization>();
    1546            0 :         memcpy (TREE_OPTIMIZATION (t), TREE_OPTIMIZATION (node),
    1547              :                 sizeof (struct cl_optimization));
    1548              :       }
    1549              : 
    1550   4298484029 :   return t;
    1551              : }
    1552              : 
    1553              : /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
    1554              :    For example, this can copy a list made of TREE_LIST nodes.  */
    1555              : 
    1556              : tree
    1557    160643887 : copy_list (tree list)
    1558              : {
    1559    160643887 :   tree head;
    1560    160643887 :   tree prev, next;
    1561              : 
    1562    160643887 :   if (list == 0)
    1563              :     return 0;
    1564              : 
    1565    155426391 :   head = prev = copy_node (list);
    1566    155426391 :   next = TREE_CHAIN (list);
    1567    304908977 :   while (next)
    1568              :     {
    1569    149482586 :       TREE_CHAIN (prev) = copy_node (next);
    1570    149482586 :       prev = TREE_CHAIN (prev);
    1571    149482586 :       next = TREE_CHAIN (next);
    1572              :     }
    1573              :   return head;
    1574              : }
    1575              : 
    1576              : 
    1577              : /* Return the value that TREE_INT_CST_EXT_NUNITS should have for an
    1578              :    INTEGER_CST with value CST and type TYPE.   */
    1579              : 
    1580              : static unsigned int
    1581  10587553788 : get_int_cst_ext_nunits (tree type, const wide_int &cst)
    1582              : {
    1583  10587553788 :   gcc_checking_assert (cst.get_precision () == TYPE_PRECISION (type));
    1584              :   /* We need extra HWIs if CST is an unsigned integer with its
    1585              :      upper bit set.  */
    1586  10587553788 :   if (TYPE_UNSIGNED (type) && wi::neg_p (cst))
    1587    183118895 :     return cst.get_precision () / HOST_BITS_PER_WIDE_INT + 1;
    1588  10404434893 :   return cst.get_len ();
    1589              : }
    1590              : 
    1591              : /* Return a new INTEGER_CST with value CST and type TYPE.  */
    1592              : 
    1593              : static tree
    1594    132012092 : build_new_int_cst (tree type, const wide_int &cst)
    1595              : {
    1596    132012092 :   unsigned int len = cst.get_len ();
    1597    132012092 :   unsigned int ext_len = get_int_cst_ext_nunits (type, cst);
    1598    132012092 :   tree nt = make_int_cst (len, ext_len);
    1599              : 
    1600    132012092 :   if (len < ext_len)
    1601              :     {
    1602     67921824 :       --ext_len;
    1603    135843648 :       TREE_INT_CST_ELT (nt, ext_len)
    1604     67921824 :         = zext_hwi (-1, cst.get_precision () % HOST_BITS_PER_WIDE_INT);
    1605     90009650 :       for (unsigned int i = len; i < ext_len; ++i)
    1606     22087826 :         TREE_INT_CST_ELT (nt, i) = -1;
    1607              :     }
    1608     64090268 :   else if (TYPE_UNSIGNED (type)
    1609     64090268 :            && cst.get_precision () < len * HOST_BITS_PER_WIDE_INT)
    1610              :     {
    1611     13924694 :       len--;
    1612     27849388 :       TREE_INT_CST_ELT (nt, len)
    1613     13924694 :         = zext_hwi (cst.elt (len),
    1614     13924694 :                     cst.get_precision () % HOST_BITS_PER_WIDE_INT);
    1615              :     }
    1616              : 
    1617    253536224 :   for (unsigned int i = 0; i < len; i++)
    1618    121524132 :     TREE_INT_CST_ELT (nt, i) = cst.elt (i);
    1619    132012092 :   TREE_TYPE (nt) = type;
    1620    132012092 :   return nt;
    1621              : }
    1622              : 
    1623              : /* Return a new POLY_INT_CST with coefficients COEFFS and type TYPE.  */
    1624              : 
    1625              : static tree
    1626            0 : build_new_poly_int_cst (tree type, tree (&coeffs)[NUM_POLY_INT_COEFFS]
    1627              :                         CXX_MEM_STAT_INFO)
    1628              : {
    1629            0 :   size_t length = sizeof (struct tree_poly_int_cst);
    1630            0 :   record_node_allocation_statistics (POLY_INT_CST, length);
    1631              : 
    1632            0 :   tree t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    1633              : 
    1634            0 :   TREE_SET_CODE (t, POLY_INT_CST);
    1635            0 :   TREE_CONSTANT (t) = 1;
    1636            0 :   TREE_TYPE (t) = type;
    1637            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1638            0 :     POLY_INT_CST_COEFF (t, i) = coeffs[i];
    1639            0 :   return t;
    1640              : }
    1641              : 
    1642              : /* Create a constant tree that contains CST sign-extended to TYPE.  */
    1643              : 
    1644              : tree
    1645   6980914580 : build_int_cst (tree type, poly_int64 cst)
    1646              : {
    1647              :   /* Support legacy code.  */
    1648   6980914580 :   if (!type)
    1649   2400665598 :     type = integer_type_node;
    1650              : 
    1651   6980914580 :   return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
    1652              : }
    1653              : 
    1654              : /* Create a constant tree that contains CST zero-extended to TYPE.  */
    1655              : 
    1656              : tree
    1657      9599021 : build_int_cstu (tree type, poly_uint64 cst)
    1658              : {
    1659      9599021 :   return wide_int_to_tree (type, wi::uhwi (cst, TYPE_PRECISION (type)));
    1660              : }
    1661              : 
    1662              : /* Create a constant tree that contains CST sign-extended to TYPE.  */
    1663              : 
    1664              : tree
    1665     27903761 : build_int_cst_type (tree type, poly_int64 cst)
    1666              : {
    1667     27903761 :   gcc_assert (type);
    1668     27903761 :   return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
    1669              : }
    1670              : 
    1671              : /* Constructs tree in type TYPE from with value given by CST.  Signedness
    1672              :    of CST is assumed to be the same as the signedness of TYPE.  */
    1673              : 
    1674              : tree
    1675      7297649 : double_int_to_tree (tree type, double_int cst)
    1676              : {
    1677      7297649 :   return wide_int_to_tree (type, widest_int::from (cst, TYPE_SIGN (type)));
    1678              : }
    1679              : 
    1680              : /* We force the wide_int CST to the range of the type TYPE by sign or
    1681              :    zero extending it.  OVERFLOWABLE indicates if we are interested in
    1682              :    overflow of the value, when >0 we are only interested in signed
    1683              :    overflow, for <0 we are interested in any overflow.  OVERFLOWED
    1684              :    indicates whether overflow has already occurred.  CONST_OVERFLOWED
    1685              :    indicates whether constant overflow has already occurred.  We force
    1686              :    T's value to be within range of T's type (by setting to 0 or 1 all
    1687              :    the bits outside the type's range).  We set TREE_OVERFLOWED if,
    1688              :         OVERFLOWED is nonzero,
    1689              :         or OVERFLOWABLE is >0 and signed overflow occurs
    1690              :         or OVERFLOWABLE is <0 and any overflow occurs
    1691              :    We return a new tree node for the extended wide_int.  The node
    1692              :    is shared if no overflow flags are set.  */
    1693              : 
    1694              : 
    1695              : tree
    1696   2856526785 : force_fit_type (tree type, const poly_wide_int_ref &cst,
    1697              :                 int overflowable, bool overflowed)
    1698              : {
    1699   2856526785 :   signop sign = TYPE_SIGN (type);
    1700              : 
    1701              :   /* If we need to set overflow flags, return a new unshared node.  */
    1702   2856526785 :   if (overflowed || !wi::fits_to_tree_p (cst, type))
    1703              :     {
    1704      6902097 :       if (overflowed
    1705      6902097 :           || overflowable < 0
    1706      5674695 :           || (overflowable > 0 && sign == SIGNED))
    1707              :         {
    1708      1297434 :           poly_wide_int tmp = poly_wide_int::from (cst, TYPE_PRECISION (type),
    1709      1297434 :                                                    sign);
    1710      1297434 :           tree t;
    1711      1297434 :           if (tmp.is_constant ())
    1712      1297434 :             t = build_new_int_cst (type, tmp.coeffs[0]);
    1713              :           else
    1714              :             {
    1715              :               tree coeffs[NUM_POLY_INT_COEFFS];
    1716              :               for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1717              :                 {
    1718              :                   coeffs[i] = build_new_int_cst (type, tmp.coeffs[i]);
    1719              :                   TREE_OVERFLOW (coeffs[i]) = 1;
    1720              :                 }
    1721              :               t = build_new_poly_int_cst (type, coeffs);
    1722              :             }
    1723      1297434 :           TREE_OVERFLOW (t) = 1;
    1724      1297434 :           return t;
    1725      1297434 :         }
    1726              :     }
    1727              : 
    1728              :   /* Else build a shared node.  */
    1729   2855229351 :   return wide_int_to_tree (type, cst);
    1730              : }
    1731              : 
    1732              : /* These are the hash table functions for the hash table of INTEGER_CST
    1733              :    nodes of a sizetype.  */
    1734              : 
    1735              : /* Return the hash code X, an INTEGER_CST.  */
    1736              : 
    1737              : hashval_t
    1738   3069446658 : int_cst_hasher::hash (tree x)
    1739              : {
    1740   3069446658 :   const_tree const t = x;
    1741   3069446658 :   hashval_t code = TYPE_UID (TREE_TYPE (t));
    1742   3069446658 :   int i;
    1743              : 
    1744   6147554766 :   for (i = 0; i < TREE_INT_CST_NUNITS (t); i++)
    1745   3078108108 :     code = iterative_hash_host_wide_int (TREE_INT_CST_ELT(t, i), code);
    1746              : 
    1747   3069446658 :   return code;
    1748              : }
    1749              : 
    1750              : /* Return nonzero if the value represented by *X (an INTEGER_CST tree node)
    1751              :    is the same as that given by *Y, which is the same.  */
    1752              : 
    1753              : bool
    1754   3015447540 : int_cst_hasher::equal (tree x, tree y)
    1755              : {
    1756   3015447540 :   const_tree const xt = x;
    1757   3015447540 :   const_tree const yt = y;
    1758              : 
    1759   3015447540 :   if (TREE_TYPE (xt) != TREE_TYPE (yt)
    1760    922674520 :       || TREE_INT_CST_NUNITS (xt) != TREE_INT_CST_NUNITS (yt)
    1761   3938057473 :       || TREE_INT_CST_EXT_NUNITS (xt) != TREE_INT_CST_EXT_NUNITS (yt))
    1762              :     return false;
    1763              : 
    1764   1266692517 :   for (int i = 0; i < TREE_INT_CST_NUNITS (xt); i++)
    1765    887227121 :     if (TREE_INT_CST_ELT (xt, i) != TREE_INT_CST_ELT (yt, i))
    1766              :       return false;
    1767              : 
    1768              :   return true;
    1769              : }
    1770              : 
    1771              : /* Cache wide_int CST into the TYPE_CACHED_VALUES cache for TYPE.
    1772              :    SLOT is the slot entry to store it in, and MAX_SLOTS is the maximum
    1773              :    number of slots that can be cached for the type.  */
    1774              : 
    1775              : static inline tree
    1776   9914536154 : cache_wide_int_in_type_cache (tree type, const wide_int &cst,
    1777              :                               int slot, int max_slots)
    1778              : {
    1779   9914536154 :   gcc_checking_assert (slot >= 0);
    1780              :   /* Initialize cache.  */
    1781   9914536154 :   if (!TYPE_CACHED_VALUES_P (type))
    1782              :     {
    1783     19608617 :       TYPE_CACHED_VALUES_P (type) = 1;
    1784     19608617 :       TYPE_CACHED_VALUES (type) = make_tree_vec (max_slots);
    1785              :     }
    1786   9914536154 :   tree t = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), slot);
    1787   9914536154 :   if (!t)
    1788              :     {
    1789              :       /* Create a new shared int.  */
    1790     60527009 :       t = build_new_int_cst (type, cst);
    1791     60527009 :       TREE_VEC_ELT (TYPE_CACHED_VALUES (type), slot) = t;
    1792              :     }
    1793   9914536154 :   return t;
    1794              : }
    1795              : 
    1796              : /* Create an INT_CST node of TYPE and value CST.
    1797              :    The returned node is always shared.  For small integers we use a
    1798              :    per-type vector cache, for larger ones we use a single hash table.
    1799              :    The value is extended from its precision according to the sign of
    1800              :    the type to be a multiple of HOST_BITS_PER_WIDE_INT.  This defines
    1801              :    the upper bits and ensures that hashing and value equality based
    1802              :    upon the underlying HOST_WIDE_INTs works without masking.  */
    1803              : 
    1804              : static tree
    1805  10455541696 : wide_int_to_tree_1 (tree type, const wide_int_ref &pcst)
    1806              : {
    1807  10455541696 :   tree t;
    1808  10455541696 :   int ix = -1;
    1809  10455541696 :   int limit = 0;
    1810              : 
    1811  10455541696 :   gcc_assert (type);
    1812  10455541696 :   unsigned int prec = TYPE_PRECISION (type);
    1813  10455541696 :   signop sgn = TYPE_SIGN (type);
    1814              : 
    1815              :   /* Verify that everything is canonical.  */
    1816  10455541696 :   int l = pcst.get_len ();
    1817  10455541696 :   if (l > 1)
    1818              :     {
    1819      4038209 :       if (pcst.elt (l - 1) == 0)
    1820      1218388 :         gcc_checking_assert (pcst.elt (l - 2) < 0);
    1821      4038209 :       if (pcst.elt (l - 1) == HOST_WIDE_INT_M1)
    1822         8550 :         gcc_checking_assert (pcst.elt (l - 2) >= 0);
    1823              :     }
    1824              : 
    1825  10455541696 :   wide_int cst = wide_int::from (pcst, prec, sgn);
    1826  10455541696 :   unsigned int ext_len = get_int_cst_ext_nunits (type, cst);
    1827              : 
    1828  10455541696 :   enum tree_code code = TREE_CODE (type);
    1829  10455541696 :   if (code == POINTER_TYPE || code == REFERENCE_TYPE)
    1830              :     {
    1831              :       /* Cache NULL pointer and zero bounds.  */
    1832    186429447 :       if (cst == 0)
    1833              :         ix = 0;
    1834              :       /* Cache upper bounds of pointers.  */
    1835     48725112 :       else if (cst == wi::max_value (prec, sgn))
    1836              :         ix = 1;
    1837              :       /* Cache 1 which is used for a non-zero range.  */
    1838     46631796 :       else if (cst == 1)
    1839              :         ix = 2;
    1840              : 
    1841              :       if (ix >= 0)
    1842              :         {
    1843    145346964 :           t = cache_wide_int_in_type_cache (type, cst, ix, 3);
    1844              :           /* Make sure no one is clobbering the shared constant.  */
    1845    145346964 :           gcc_checking_assert (TREE_TYPE (t) == type
    1846              :                                && cst == wi::to_wide (t));
    1847    145346964 :           return t;
    1848              :         }
    1849              :     }
    1850  10310194732 :   if (ext_len == 1)
    1851              :     {
    1852              :       /* We just need to store a single HOST_WIDE_INT.  */
    1853  10240007083 :       HOST_WIDE_INT hwi;
    1854  10240007083 :       if (TYPE_UNSIGNED (type))
    1855   6901260497 :         hwi = cst.to_uhwi ();
    1856              :       else
    1857   3338747120 :         hwi = cst.to_shwi ();
    1858              : 
    1859  10240007083 :       switch (code)
    1860              :         {
    1861       228754 :         case NULLPTR_TYPE:
    1862       228754 :           gcc_assert (hwi == 0);
    1863              :           /* Fallthru.  */
    1864              : 
    1865              :         case POINTER_TYPE:
    1866              :         case REFERENCE_TYPE:
    1867              :           /* Ignore pointers, as they were already handled above.  */
    1868              :           break;
    1869              : 
    1870    109492609 :         case BOOLEAN_TYPE:
    1871              :           /* Cache false or true.  */
    1872    109492609 :           limit = 2;
    1873    109492609 :           if (IN_RANGE (hwi, 0, 1))
    1874    109301902 :             ix = hwi;
    1875              :           break;
    1876              : 
    1877  10075019266 :         case INTEGER_TYPE:
    1878  10075019266 :         case OFFSET_TYPE:
    1879  10075019266 :         case BITINT_TYPE:
    1880  10075019266 :           if (TYPE_SIGN (type) == UNSIGNED)
    1881              :             {
    1882              :               /* Cache [0, N).  */
    1883   6742121636 :               limit = param_integer_share_limit;
    1884   6742121636 :               if (IN_RANGE (hwi, 0, param_integer_share_limit - 1))
    1885   6472106752 :                 ix = hwi;
    1886              :             }
    1887              :           else
    1888              :             {
    1889              :               /* Cache [-1, N).  */
    1890   3332897630 :               limit = param_integer_share_limit + 1;
    1891   3332897630 :               if (IN_RANGE (hwi, -1, param_integer_share_limit - 1))
    1892   3187780536 :                 ix = hwi + 1;
    1893              :             }
    1894              :           break;
    1895              : 
    1896              :         case ENUMERAL_TYPE:
    1897              :           break;
    1898              : 
    1899            0 :         default:
    1900            0 :           gcc_unreachable ();
    1901              :         }
    1902              : 
    1903  10240007083 :       if (ix >= 0)
    1904              :         {
    1905   9769189190 :           t = cache_wide_int_in_type_cache (type, cst, ix, limit);
    1906              :           /* Make sure no one is clobbering the shared constant.  */
    1907  19538378380 :           gcc_checking_assert (TREE_TYPE (t) == type
    1908              :                                && TREE_INT_CST_NUNITS (t) == 1
    1909              :                                && TREE_INT_CST_EXT_NUNITS (t) == 1
    1910              :                                && TREE_INT_CST_ELT (t, 0) == hwi);
    1911              :           return t;
    1912              :         }
    1913              :       else
    1914              :         {
    1915              :           /* Use the cache of larger shared ints, using int_cst_node as
    1916              :              a temporary.  */
    1917              : 
    1918    470817893 :           TREE_INT_CST_ELT (int_cst_node, 0) = hwi;
    1919    470817893 :           TREE_TYPE (int_cst_node) = type;
    1920              : 
    1921    470817893 :           tree *slot = int_cst_hash_table->find_slot (int_cst_node, INSERT);
    1922    470817893 :           t = *slot;
    1923    470817893 :           if (!t)
    1924              :             {
    1925              :               /* Insert this one into the hash table.  */
    1926    150121883 :               t = int_cst_node;
    1927    150121883 :               *slot = t;
    1928              :               /* Make a new node for next time round.  */
    1929    150121883 :               int_cst_node = make_int_cst (1, 1);
    1930              :             }
    1931              :         }
    1932              :     }
    1933              :   else
    1934              :     {
    1935              :       /* The value either hashes properly or we drop it on the floor
    1936              :          for the gc to take care of.  There will not be enough of them
    1937              :          to worry about.  */
    1938              : 
    1939     70187649 :       tree nt = build_new_int_cst (type, cst);
    1940     70187649 :       tree *slot = int_cst_hash_table->find_slot (nt, INSERT);
    1941     70187649 :       t = *slot;
    1942     70187649 :       if (!t)
    1943              :         {
    1944              :           /* Insert this one into the hash table.  */
    1945     12140407 :           t = nt;
    1946     12140407 :           *slot = t;
    1947              :         }
    1948              :       else
    1949     58047242 :         ggc_free (nt);
    1950              :     }
    1951              : 
    1952              :   return t;
    1953  10455541696 : }
    1954              : 
    1955              : hashval_t
    1956            0 : poly_int_cst_hasher::hash (tree t)
    1957              : {
    1958            0 :   inchash::hash hstate;
    1959              : 
    1960            0 :   hstate.add_int (TYPE_UID (TREE_TYPE (t)));
    1961            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1962            0 :     hstate.add_wide_int (wi::to_wide (POLY_INT_CST_COEFF (t, i)));
    1963              : 
    1964            0 :   return hstate.end ();
    1965              : }
    1966              : 
    1967              : bool
    1968            0 : poly_int_cst_hasher::equal (tree x, const compare_type &y)
    1969              : {
    1970            0 :   if (TREE_TYPE (x) != y.first)
    1971              :     return false;
    1972            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1973            0 :     if (wi::to_wide (POLY_INT_CST_COEFF (x, i)) != y.second->coeffs[i])
    1974              :       return false;
    1975              :   return true;
    1976              : }
    1977              : 
    1978              : /* Build a POLY_INT_CST node with type TYPE and with the elements in VALUES.
    1979              :    The elements must also have type TYPE.  */
    1980              : 
    1981              : tree
    1982            0 : build_poly_int_cst (tree type, const poly_wide_int_ref &values)
    1983              : {
    1984            0 :   unsigned int prec = TYPE_PRECISION (type);
    1985            0 :   gcc_assert (prec <= values.coeffs[0].get_precision ());
    1986            0 :   poly_wide_int c = poly_wide_int::from (values, prec, SIGNED);
    1987              : 
    1988            0 :   inchash::hash h;
    1989            0 :   h.add_int (TYPE_UID (type));
    1990            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1991            0 :     h.add_wide_int (c.coeffs[i]);
    1992            0 :   poly_int_cst_hasher::compare_type comp (type, &c);
    1993            0 :   tree *slot = poly_int_cst_hash_table->find_slot_with_hash (comp, h.end (),
    1994              :                                                              INSERT);
    1995            0 :   if (*slot == NULL_TREE)
    1996              :     {
    1997              :       tree coeffs[NUM_POLY_INT_COEFFS];
    1998            0 :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1999            0 :         coeffs[i] = wide_int_to_tree_1 (type, c.coeffs[i]);
    2000            0 :       *slot = build_new_poly_int_cst (type, coeffs);
    2001              :     }
    2002            0 :   return *slot;
    2003            0 : }
    2004              : 
    2005              : /* Create a constant tree with value VALUE in type TYPE.  */
    2006              : 
    2007              : tree
    2008  10455541696 : wide_int_to_tree (tree type, const poly_wide_int_ref &value)
    2009              : {
    2010  10455541696 :   if (value.is_constant ())
    2011  10455541696 :     return wide_int_to_tree_1 (type, value.coeffs[0]);
    2012              :   return build_poly_int_cst (type, value);
    2013              : }
    2014              : 
    2015              : /* Insert INTEGER_CST T into a cache of integer constants.  And return
    2016              :    the cached constant (which may or may not be T).  If MIGHT_DUPLICATE
    2017              :    is false, and T falls into the type's 'smaller values' range, there
    2018              :    cannot be an existing entry.  Otherwise, if MIGHT_DUPLICATE is true,
    2019              :    or the value is large, should an existing entry exist, it is
    2020              :    returned (rather than inserting T).  */
    2021              : 
    2022              : tree
    2023       636705 : cache_integer_cst (tree t, bool might_duplicate ATTRIBUTE_UNUSED)
    2024              : {
    2025       636705 :   tree type = TREE_TYPE (t);
    2026       636705 :   int ix = -1;
    2027       636705 :   int limit = 0;
    2028       636705 :   int prec = TYPE_PRECISION (type);
    2029              : 
    2030       636705 :   gcc_assert (!TREE_OVERFLOW (t));
    2031              : 
    2032              :   /* The caching indices here must match those in
    2033              :      wide_int_to_type_1.  */
    2034       636705 :   switch (TREE_CODE (type))
    2035              :     {
    2036            0 :     case NULLPTR_TYPE:
    2037            0 :       gcc_checking_assert (integer_zerop (t));
    2038              :       /* Fallthru.  */
    2039              : 
    2040         4879 :     case POINTER_TYPE:
    2041         4879 :     case REFERENCE_TYPE:
    2042         4879 :       {
    2043         4879 :         if (integer_zerop (t))
    2044              :           ix = 0;
    2045         1878 :         else if (integer_onep (t))
    2046              :           ix = 2;
    2047              : 
    2048              :         if (ix >= 0)
    2049              :           limit = 3;
    2050              :       }
    2051              :       break;
    2052              : 
    2053        10596 :     case BOOLEAN_TYPE:
    2054              :       /* Cache false or true.  */
    2055        10596 :       limit = 2;
    2056        10596 :       if (wi::ltu_p (wi::to_wide (t), 2))
    2057            0 :         ix = TREE_INT_CST_ELT (t, 0);
    2058              :       break;
    2059              : 
    2060       605792 :     case INTEGER_TYPE:
    2061       605792 :     case OFFSET_TYPE:
    2062       605792 :     case BITINT_TYPE:
    2063       605792 :       if (TYPE_UNSIGNED (type))
    2064              :         {
    2065              :           /* Cache 0..N */
    2066       452563 :           limit = param_integer_share_limit;
    2067              : 
    2068              :           /* This is a little hokie, but if the prec is smaller than
    2069              :              what is necessary to hold param_integer_share_limit, then the
    2070              :              obvious test will not get the correct answer.  */
    2071       452563 :           if (prec < HOST_BITS_PER_WIDE_INT)
    2072              :             {
    2073        96243 :               if (tree_to_uhwi (t)
    2074        96243 :                   < (unsigned HOST_WIDE_INT) param_integer_share_limit)
    2075        15772 :                 ix = tree_to_uhwi (t);
    2076              :             }
    2077       356320 :           else if (wi::ltu_p (wi::to_wide (t), param_integer_share_limit))
    2078       276391 :             ix = tree_to_uhwi (t);
    2079              :         }
    2080              :       else
    2081              :         {
    2082              :           /* Cache -1..N */
    2083       153229 :           limit = param_integer_share_limit + 1;
    2084              : 
    2085       153229 :           if (integer_minus_onep (t))
    2086              :             ix = 0;
    2087       152759 :           else if (!wi::neg_p (wi::to_wide (t)))
    2088              :             {
    2089       135735 :               if (prec < HOST_BITS_PER_WIDE_INT)
    2090              :                 {
    2091       129061 :                   if (tree_to_shwi (t) < param_integer_share_limit)
    2092       119990 :                     ix = tree_to_shwi (t) + 1;
    2093              :                 }
    2094         6674 :               else if (wi::ltu_p (wi::to_wide (t), param_integer_share_limit))
    2095         5399 :                 ix = tree_to_shwi (t) + 1;
    2096              :             }
    2097              :         }
    2098              :       break;
    2099              : 
    2100              :     case ENUMERAL_TYPE:
    2101              :       /* The slot used by TYPE_CACHED_VALUES is used for the enum
    2102              :          members.  */
    2103              :       break;
    2104              : 
    2105            0 :     default:
    2106            0 :       gcc_unreachable ();
    2107              :     }
    2108              : 
    2109       420553 :   if (ix >= 0)
    2110              :     {
    2111              :       /* Look for it in the type's vector of small shared ints.  */
    2112       421471 :       if (!TYPE_CACHED_VALUES_P (type))
    2113              :         {
    2114        14183 :           TYPE_CACHED_VALUES_P (type) = 1;
    2115        14183 :           TYPE_CACHED_VALUES (type) = make_tree_vec (limit);
    2116              :         }
    2117              : 
    2118       421471 :       if (tree r = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix))
    2119              :         {
    2120       395061 :           gcc_checking_assert (might_duplicate);
    2121       395061 :           t = r;
    2122              :         }
    2123              :       else
    2124        26410 :         TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix) = t;
    2125              :     }
    2126              :   else
    2127              :     {
    2128              :       /* Use the cache of larger shared ints.  */
    2129       215234 :       tree *slot = int_cst_hash_table->find_slot (t, INSERT);
    2130       215234 :       if (tree r = *slot)
    2131              :         {
    2132              :           /* If there is already an entry for the number verify it's the
    2133              :              same value.  */
    2134       125574 :           gcc_checking_assert (wi::to_wide (tree (r)) == wi::to_wide (t));
    2135              :           /* And return the cached value.  */
    2136       125574 :           t = r;
    2137              :         }
    2138              :       else
    2139              :         /* Otherwise insert this one into the hash table.  */
    2140        89660 :         *slot = t;
    2141              :     }
    2142              : 
    2143       636705 :   return t;
    2144              : }
    2145              : 
    2146              : 
    2147              : /* Builds an integer constant in TYPE such that lowest BITS bits are ones
    2148              :    and the rest are zeros.  */
    2149              : 
    2150              : tree
    2151      9712212 : build_low_bits_mask (tree type, unsigned bits)
    2152              : {
    2153      9712212 :   gcc_assert (bits <= TYPE_PRECISION (type));
    2154              : 
    2155      9712212 :   return wide_int_to_tree (type, wi::mask (bits, false,
    2156      9712212 :                                            TYPE_PRECISION (type)));
    2157              : }
    2158              : 
    2159              : /* Checks that X is integer constant that can be expressed in (unsigned)
    2160              :    HOST_WIDE_INT without loss of precision.  */
    2161              : 
    2162              : bool
    2163    738267273 : cst_and_fits_in_hwi (const_tree x)
    2164              : {
    2165    738267273 :   return (TREE_CODE (x) == INTEGER_CST
    2166    738267273 :           && (tree_fits_shwi_p (x) || tree_fits_uhwi_p (x)));
    2167              : }
    2168              : 
    2169              : /* Build a newly constructed VECTOR_CST with the given values of
    2170              :    (VECTOR_CST_)LOG2_NPATTERNS and (VECTOR_CST_)NELTS_PER_PATTERN.  */
    2171              : 
    2172              : tree
    2173      3340670 : make_vector (unsigned log2_npatterns,
    2174              :              unsigned int nelts_per_pattern MEM_STAT_DECL)
    2175              : {
    2176      3340670 :   gcc_assert (IN_RANGE (nelts_per_pattern, 1, 3));
    2177      3340670 :   tree t;
    2178      3340670 :   unsigned npatterns = 1 << log2_npatterns;
    2179      3340670 :   unsigned encoded_nelts = npatterns * nelts_per_pattern;
    2180      3340670 :   unsigned length = (sizeof (struct tree_vector)
    2181              :                      + (encoded_nelts - 1) * sizeof (tree));
    2182              : 
    2183      3340670 :   record_node_allocation_statistics (VECTOR_CST, length);
    2184              : 
    2185      3340670 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2186              : 
    2187      3340670 :   TREE_SET_CODE (t, VECTOR_CST);
    2188      3340670 :   TREE_CONSTANT (t) = 1;
    2189      3340670 :   VECTOR_CST_LOG2_NPATTERNS (t) = log2_npatterns;
    2190      3340670 :   VECTOR_CST_NELTS_PER_PATTERN (t) = nelts_per_pattern;
    2191              : 
    2192      3340670 :   return t;
    2193              : }
    2194              : 
    2195              : /* Return a new VECTOR_CST node whose type is TYPE and whose values
    2196              :    are extracted from V, a vector of CONSTRUCTOR_ELT.  */
    2197              : 
    2198              : tree
    2199       680285 : build_vector_from_ctor (tree type, const vec<constructor_elt, va_gc> *v)
    2200              : {
    2201       680285 :   if (vec_safe_length (v) == 0)
    2202         1984 :     return build_zero_cst (type);
    2203              : 
    2204       678301 :   unsigned HOST_WIDE_INT idx, nelts, step = 1;
    2205       678301 :   tree value;
    2206              : 
    2207              :   /* If the vector is a VLA, build a VLA constant vector.  */
    2208       678301 :   if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts))
    2209              :     {
    2210              :       nelts = constant_lower_bound (TYPE_VECTOR_SUBPARTS (type));
    2211              :       gcc_assert (vec_safe_length (v) <= nelts);
    2212              :       step = 2;
    2213              :     }
    2214              : 
    2215       678301 :   tree_vector_builder vec (type, nelts, step);
    2216      4506028 :   FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
    2217              :     {
    2218      3827727 :       if (TREE_CODE (value) == VECTOR_CST)
    2219              :         {
    2220              :           /* If NELTS is constant then this must be too.  */
    2221         3186 :           unsigned int sub_nelts = VECTOR_CST_NELTS (value).to_constant ();
    2222        12130 :           for (unsigned i = 0; i < sub_nelts; ++i)
    2223         8944 :             vec.quick_push (VECTOR_CST_ELT (value, i));
    2224              :         }
    2225              :       else
    2226      3824541 :         vec.quick_push (value);
    2227              :     }
    2228      1921074 :   while (vec.length () < nelts * step)
    2229       282236 :     vec.quick_push (build_zero_cst (TREE_TYPE (type)));
    2230              : 
    2231       678301 :   return vec.build ();
    2232       678301 : }
    2233              : 
    2234              : /* Build a vector of type VECTYPE where all the elements are SCs.  */
    2235              : tree
    2236       644844 : build_vector_from_val (tree vectype, tree sc)
    2237              : {
    2238       644844 :   unsigned HOST_WIDE_INT i, nunits;
    2239              : 
    2240       644844 :   if (sc == error_mark_node)
    2241              :     return sc;
    2242              : 
    2243              :   /* Verify that the vector type is suitable for SC.  Note that there
    2244              :      is some inconsistency in the type-system with respect to restrict
    2245              :      qualifications of pointers.  Vector types always have a main-variant
    2246              :      element type and the qualification is applied to the vector-type.
    2247              :      So TREE_TYPE (vector-type) does not return a properly qualified
    2248              :      vector element-type.  */
    2249       644844 :   gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)),
    2250              :                                            TREE_TYPE (vectype)));
    2251              : 
    2252       644844 :   if (CONSTANT_CLASS_P (sc))
    2253              :     {
    2254       614343 :       tree_vector_builder v (vectype, 1, 1);
    2255       614343 :       v.quick_push (sc);
    2256       614343 :       return v.build ();
    2257       614343 :     }
    2258        30501 :   else if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits))
    2259              :     return fold_build1 (VEC_DUPLICATE_EXPR, vectype, sc);
    2260              :   else
    2261              :     {
    2262        30501 :       vec<constructor_elt, va_gc> *v;
    2263        30501 :       vec_alloc (v, nunits);
    2264       146622 :       for (i = 0; i < nunits; ++i)
    2265       116121 :         CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc);
    2266        30501 :       return build_constructor (vectype, v);
    2267              :     }
    2268              : }
    2269              : 
    2270              : /* If TYPE is not a vector type, just return SC, otherwise return
    2271              :    build_vector_from_val (TYPE, SC).  */
    2272              : 
    2273              : tree
    2274      5428266 : build_uniform_cst (tree type, tree sc)
    2275              : {
    2276      5428266 :   if (!VECTOR_TYPE_P (type))
    2277              :     return sc;
    2278              : 
    2279          309 :   return build_vector_from_val (type, sc);
    2280              : }
    2281              : 
    2282              : /* Build a vector series of type TYPE in which element I has the value
    2283              :    BASE + I * STEP.  The result is a constant if BASE and STEP are constant
    2284              :    and a VEC_SERIES_EXPR otherwise.  */
    2285              : 
    2286              : tree
    2287           18 : build_vec_series (tree type, tree base, tree step)
    2288              : {
    2289           18 :   if (integer_zerop (step))
    2290            0 :     return build_vector_from_val (type, base);
    2291           18 :   if (TREE_CODE (base) == INTEGER_CST && TREE_CODE (step) == INTEGER_CST)
    2292              :     {
    2293           18 :       tree_vector_builder builder (type, 1, 3);
    2294           18 :       tree elt1 = wide_int_to_tree (TREE_TYPE (base),
    2295           36 :                                     wi::to_wide (base) + wi::to_wide (step));
    2296           18 :       tree elt2 = wide_int_to_tree (TREE_TYPE (base),
    2297           36 :                                     wi::to_wide (elt1) + wi::to_wide (step));
    2298           18 :       builder.quick_push (base);
    2299           18 :       builder.quick_push (elt1);
    2300           18 :       builder.quick_push (elt2);
    2301           18 :       return builder.build ();
    2302           18 :     }
    2303            0 :   return build2 (VEC_SERIES_EXPR, type, base, step);
    2304              : }
    2305              : 
    2306              : /* Return a vector with the same number of units and number of bits
    2307              :    as VEC_TYPE, but in which the elements are a linear series of unsigned
    2308              :    integers { BASE, BASE + STEP, BASE + STEP * 2, ... }.  */
    2309              : 
    2310              : tree
    2311         1799 : build_index_vector (tree vec_type, poly_uint64 base, poly_uint64 step)
    2312              : {
    2313         1799 :   tree index_vec_type = vec_type;
    2314         1799 :   tree index_elt_type = TREE_TYPE (vec_type);
    2315         1799 :   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vec_type);
    2316         1799 :   if (!INTEGRAL_TYPE_P (index_elt_type) || !TYPE_UNSIGNED (index_elt_type))
    2317              :     {
    2318            4 :       index_elt_type = build_nonstandard_integer_type
    2319            8 :         (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (index_elt_type)), true);
    2320            4 :       index_vec_type = build_vector_type (index_elt_type, nunits);
    2321              :     }
    2322              : 
    2323         1799 :   tree_vector_builder v (index_vec_type, 1, 3);
    2324         7196 :   for (unsigned int i = 0; i < 3; ++i)
    2325         5397 :     v.quick_push (build_int_cstu (index_elt_type, base + i * step));
    2326         1799 :   return v.build ();
    2327         1799 : }
    2328              : 
    2329              : /* Return a VECTOR_CST of type VEC_TYPE in which the first NUM_A
    2330              :    elements are A and the rest are B.  */
    2331              : 
    2332              : tree
    2333            0 : build_vector_a_then_b (tree vec_type, unsigned int num_a, tree a, tree b)
    2334              : {
    2335            0 :   gcc_assert (known_le (num_a, TYPE_VECTOR_SUBPARTS (vec_type)));
    2336            0 :   unsigned int count = constant_lower_bound (TYPE_VECTOR_SUBPARTS (vec_type));
    2337              :   /* Optimize the constant case.  */
    2338            0 :   if ((count & 1) == 0 && TYPE_VECTOR_SUBPARTS (vec_type).is_constant ())
    2339            0 :     count /= 2;
    2340            0 :   tree_vector_builder builder (vec_type, count, 2);
    2341            0 :   for (unsigned int i = 0; i < count * 2; ++i)
    2342            0 :     builder.quick_push (i < num_a ? a : b);
    2343            0 :   return builder.build ();
    2344            0 : }
    2345              : 
    2346              : /* Something has messed with the elements of CONSTRUCTOR C after it was built;
    2347              :    calculate TREE_CONSTANT and TREE_SIDE_EFFECTS.  */
    2348              : 
    2349              : void
    2350    135715542 : recompute_constructor_flags (tree c)
    2351              : {
    2352    135715542 :   unsigned int i;
    2353    135715542 :   tree val;
    2354    135715542 :   bool constant_p = true;
    2355    135715542 :   bool side_effects_p = false;
    2356    135715542 :   vec<constructor_elt, va_gc> *vals = CONSTRUCTOR_ELTS (c);
    2357              : 
    2358    308364545 :   FOR_EACH_CONSTRUCTOR_VALUE (vals, i, val)
    2359              :     {
    2360              :       /* Mostly ctors will have elts that don't have side-effects, so
    2361              :          the usual case is to scan all the elements.  Hence a single
    2362              :          loop for both const and side effects, rather than one loop
    2363              :          each (with early outs).  */
    2364    172649003 :       if (!TREE_CONSTANT (val))
    2365     21325047 :         constant_p = false;
    2366    172649003 :       if (TREE_SIDE_EFFECTS (val))
    2367      4335021 :         side_effects_p = true;
    2368              :     }
    2369              : 
    2370    135715542 :   TREE_SIDE_EFFECTS (c) = side_effects_p;
    2371    135715542 :   TREE_CONSTANT (c) = constant_p;
    2372    135715542 : }
    2373              : 
    2374              : /* Make sure that TREE_CONSTANT and TREE_SIDE_EFFECTS are correct for
    2375              :    CONSTRUCTOR C.  */
    2376              : 
    2377              : void
    2378     17226824 : verify_constructor_flags (tree c)
    2379              : {
    2380     17226824 :   unsigned int i;
    2381     17226824 :   tree val;
    2382     17226824 :   bool constant_p = TREE_CONSTANT (c);
    2383     17226824 :   bool side_effects_p = TREE_SIDE_EFFECTS (c);
    2384     17226824 :   vec<constructor_elt, va_gc> *vals = CONSTRUCTOR_ELTS (c);
    2385              : 
    2386    163075492 :   FOR_EACH_CONSTRUCTOR_VALUE (vals, i, val)
    2387              :     {
    2388    145848668 :       if (constant_p && !TREE_CONSTANT (val))
    2389            0 :         internal_error ("non-constant element in constant CONSTRUCTOR");
    2390    145848668 :       if (!side_effects_p && TREE_SIDE_EFFECTS (val))
    2391            0 :         internal_error ("side-effects element in no-side-effects CONSTRUCTOR");
    2392              :     }
    2393     17226824 : }
    2394              : 
    2395              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2396              :    are in the vec pointed to by VALS.  */
    2397              : tree
    2398    112778409 : build_constructor (tree type, vec<constructor_elt, va_gc> *vals MEM_STAT_DECL)
    2399              : {
    2400    112778409 :   tree c = make_node (CONSTRUCTOR PASS_MEM_STAT);
    2401              : 
    2402    112778409 :   TREE_TYPE (c) = type;
    2403    112778409 :   CONSTRUCTOR_ELTS (c) = vals;
    2404              : 
    2405    112778409 :   recompute_constructor_flags (c);
    2406              : 
    2407    112778409 :   return c;
    2408              : }
    2409              : 
    2410              : /* Build a CONSTRUCTOR node made of a single initializer, with the specified
    2411              :    INDEX and VALUE.  */
    2412              : tree
    2413         6606 : build_constructor_single (tree type, tree index, tree value)
    2414              : {
    2415         6606 :   vec<constructor_elt, va_gc> *v;
    2416         6606 :   constructor_elt elt = {index, value};
    2417              : 
    2418         6606 :   vec_alloc (v, 1);
    2419         6606 :   v->quick_push (elt);
    2420              : 
    2421         6606 :   return build_constructor (type, v);
    2422              : }
    2423              : 
    2424              : 
    2425              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2426              :    are in a list pointed to by VALS.  */
    2427              : tree
    2428         1013 : build_constructor_from_list (tree type, tree vals)
    2429              : {
    2430         1013 :   tree t;
    2431         1013 :   vec<constructor_elt, va_gc> *v = NULL;
    2432              : 
    2433         1013 :   if (vals)
    2434              :     {
    2435         1013 :       vec_alloc (v, list_length (vals));
    2436        20836 :       for (t = vals; t; t = TREE_CHAIN (t))
    2437        19823 :         CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t));
    2438              :     }
    2439              : 
    2440         1013 :   return build_constructor (type, v);
    2441              : }
    2442              : 
    2443              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2444              :    are in a vector pointed to by VALS.  Note that the TREE_PURPOSE
    2445              :    fields in the constructor remain null.  */
    2446              : 
    2447              : tree
    2448         1406 : build_constructor_from_vec (tree type, const vec<tree, va_gc> *vals)
    2449              : {
    2450         1406 :   vec<constructor_elt, va_gc> *v = NULL;
    2451              : 
    2452        73071 :   for (tree t : vals)
    2453        71665 :     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, t);
    2454              : 
    2455         1406 :   return build_constructor (type, v);
    2456              : }
    2457              : 
    2458              : /* Return a new CONSTRUCTOR node whose type is TYPE.  NELTS is the number
    2459              :    of elements, provided as index/value pairs.  */
    2460              : 
    2461              : tree
    2462        39599 : build_constructor_va (tree type, int nelts, ...)
    2463              : {
    2464        39599 :   vec<constructor_elt, va_gc> *v = NULL;
    2465        39599 :   va_list p;
    2466              : 
    2467        39599 :   va_start (p, nelts);
    2468        39599 :   vec_alloc (v, nelts);
    2469        39599 :   while (nelts--)
    2470              :     {
    2471       120061 :       tree index = va_arg (p, tree);
    2472       120061 :       tree value = va_arg (p, tree);
    2473       279721 :       CONSTRUCTOR_APPEND_ELT (v, index, value);
    2474              :     }
    2475        39599 :   va_end (p);
    2476        39599 :   return build_constructor (type, v);
    2477              : }
    2478              : 
    2479              : /* Return a node of type TYPE for which TREE_CLOBBER_P is true.  */
    2480              : 
    2481              : tree
    2482      9547797 : build_clobber (tree type, enum clobber_kind kind)
    2483              : {
    2484      9547797 :   tree clobber = build_constructor (type, NULL);
    2485      9547797 :   TREE_THIS_VOLATILE (clobber) = true;
    2486      9547797 :   CLOBBER_KIND (clobber) = kind;
    2487      9547797 :   return clobber;
    2488              : }
    2489              : 
    2490              : /* Return a new FIXED_CST node whose type is TYPE and value is F.  */
    2491              : 
    2492              : tree
    2493           54 : build_fixed (tree type, FIXED_VALUE_TYPE f)
    2494              : {
    2495           54 :   tree v;
    2496           54 :   FIXED_VALUE_TYPE *fp;
    2497              : 
    2498           54 :   v = make_node (FIXED_CST);
    2499           54 :   fp = ggc_alloc<fixed_value> ();
    2500           54 :   memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE));
    2501              : 
    2502           54 :   TREE_TYPE (v) = type;
    2503           54 :   TREE_FIXED_CST_PTR (v) = fp;
    2504           54 :   return v;
    2505              : }
    2506              : 
    2507              : /* Return a new REAL_CST node whose type is TYPE and value is D.  */
    2508              : 
    2509              : tree
    2510     41114478 : build_real (tree type, REAL_VALUE_TYPE d)
    2511              : {
    2512     41114478 :   tree v;
    2513     41114478 :   int overflow = 0;
    2514              : 
    2515              :   /* dconst{0,1,2,m1,half} are used in various places in
    2516              :      the middle-end and optimizers, allow them here
    2517              :      even for decimal floating point types as an exception
    2518              :      by converting them to decimal.  */
    2519     41114478 :   if (DECIMAL_FLOAT_MODE_P (TYPE_MODE (type))
    2520       610815 :       && (d.cl == rvc_normal || d.cl == rvc_zero)
    2521     41723095 :       && !d.decimal)
    2522              :     {
    2523          610 :       if (memcmp (&d, &dconst1, sizeof (d)) == 0)
    2524            0 :         decimal_real_from_string (&d, "1");
    2525          610 :       else if (memcmp (&d, &dconst2, sizeof (d)) == 0)
    2526           22 :         decimal_real_from_string (&d, "2");
    2527          588 :       else if (memcmp (&d, &dconstm1, sizeof (d)) == 0)
    2528           90 :         decimal_real_from_string (&d, "-1");
    2529          498 :       else if (memcmp (&d, &dconsthalf, sizeof (d)) == 0)
    2530            0 :         decimal_real_from_string (&d, "0.5");
    2531          498 :       else if (memcmp (&d, &dconst0, sizeof (d)) == 0)
    2532              :         {
    2533              :           /* Make sure to give zero the minimum quantum exponent for
    2534              :              the type (which corresponds to all bits zero).  */
    2535          498 :           const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type));
    2536          498 :           char buf[16];
    2537          498 :           sprintf (buf, "0e%d", fmt->emin - fmt->p);
    2538          498 :           decimal_real_from_string (&d, buf);
    2539              :         }
    2540              :       else
    2541            0 :         gcc_unreachable ();
    2542              :     }
    2543              : 
    2544              :   /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE.
    2545              :      Consider doing it via real_convert now.  */
    2546              : 
    2547     41114478 :   v = make_node (REAL_CST);
    2548     41114478 :   TREE_TYPE (v) = type;
    2549     41114478 :   memcpy (TREE_REAL_CST_PTR (v), &d, sizeof (REAL_VALUE_TYPE));
    2550     41114478 :   TREE_OVERFLOW (v) = overflow;
    2551     41114478 :   return v;
    2552              : }
    2553              : 
    2554              : /* Like build_real, but first truncate D to the type.  */
    2555              : 
    2556              : tree
    2557       175772 : build_real_truncate (tree type, REAL_VALUE_TYPE d)
    2558              : {
    2559       175772 :   return build_real (type, real_value_truncate (TYPE_MODE (type), d));
    2560              : }
    2561              : 
    2562              : /* Return a new REAL_CST node whose type is TYPE
    2563              :    and whose value is the integer value of the INTEGER_CST node I.  */
    2564              : 
    2565              : REAL_VALUE_TYPE
    2566     23697134 : real_value_from_int_cst (const_tree type, const_tree i)
    2567              : {
    2568     23697134 :   REAL_VALUE_TYPE d;
    2569              : 
    2570              :   /* Clear all bits of the real value type so that we can later do
    2571              :      bitwise comparisons to see if two values are the same.  */
    2572     23697134 :   memset (&d, 0, sizeof d);
    2573              : 
    2574     23697134 :   real_from_integer (&d, type ? TYPE_MODE (type) : VOIDmode, wi::to_wide (i),
    2575     23697134 :                      TYPE_SIGN (TREE_TYPE (i)));
    2576     23697134 :   return d;
    2577              : }
    2578              : 
    2579              : /* Given a tree representing an integer constant I, return a tree
    2580              :    representing the same value as a floating-point constant of type TYPE.  */
    2581              : 
    2582              : tree
    2583     23122213 : build_real_from_int_cst (tree type, const_tree i)
    2584              : {
    2585     23122213 :   tree v;
    2586     23122213 :   int overflow = TREE_OVERFLOW (i);
    2587              : 
    2588     23122213 :   v = build_real (type, real_value_from_int_cst (type, i));
    2589              : 
    2590     23122213 :   TREE_OVERFLOW (v) |= overflow;
    2591     23122213 :   return v;
    2592              : }
    2593              : 
    2594              : /* Return a new REAL_CST node whose type is TYPE
    2595              :    and whose value is the integer value I which has sign SGN.  */
    2596              : 
    2597              : tree
    2598          138 : build_real_from_wide (tree type, const wide_int_ref &i, signop sgn)
    2599              : {
    2600          138 :   REAL_VALUE_TYPE d;
    2601              : 
    2602              :   /* Clear all bits of the real value type so that we can later do
    2603              :      bitwise comparisons to see if two values are the same.  */
    2604          138 :   memset (&d, 0, sizeof d);
    2605              : 
    2606          138 :   real_from_integer (&d, TYPE_MODE (type), i, sgn);
    2607          138 :   return build_real (type, d);
    2608              : }
    2609              : 
    2610              : /* Return a newly constructed STRING_CST node whose value is the LEN
    2611              :    characters at STR when STR is nonnull, or all zeros otherwise.
    2612              :    Note that for a C string literal, LEN should include the trailing NUL.
    2613              :    The TREE_TYPE is not initialized.  */
    2614              : 
    2615              : tree
    2616     98300742 : build_string (unsigned len, const char *str /*= NULL */)
    2617              : {
    2618              :   /* Do not waste bytes provided by padding of struct tree_string.  */
    2619     98300742 :   unsigned size = len + offsetof (struct tree_string, str) + 1;
    2620              : 
    2621     98300742 :   record_node_allocation_statistics (STRING_CST, size);
    2622              : 
    2623     98300742 :   tree s = (tree) ggc_internal_alloc (size);
    2624              : 
    2625     98300742 :   memset (s, 0, sizeof (struct tree_typed));
    2626     98300742 :   TREE_SET_CODE (s, STRING_CST);
    2627     98300742 :   TREE_CONSTANT (s) = 1;
    2628     98300742 :   TREE_STRING_LENGTH (s) = len;
    2629     98300742 :   if (str)
    2630     98291575 :     memcpy (s->string.str, str, len);
    2631              :   else
    2632         9167 :     memset (s->string.str, 0, len);
    2633     98300742 :   s->string.str[len] = '\0';
    2634              : 
    2635     98300742 :   return s;
    2636              : }
    2637              : 
    2638              : /* Return a newly constructed COMPLEX_CST node whose value is
    2639              :    specified by the real and imaginary parts REAL and IMAG.
    2640              :    Both REAL and IMAG should be constant nodes.  TYPE, if specified,
    2641              :    will be the type of the COMPLEX_CST; otherwise a new type will be made.  */
    2642              : 
    2643              : tree
    2644       486178 : build_complex (tree type, tree real, tree imag)
    2645              : {
    2646       486178 :   gcc_assert (CONSTANT_CLASS_P (real));
    2647       486178 :   gcc_assert (CONSTANT_CLASS_P (imag));
    2648              : 
    2649       486178 :   tree t = make_node (COMPLEX_CST);
    2650              : 
    2651       486178 :   TREE_REALPART (t) = real;
    2652       486178 :   TREE_IMAGPART (t) = imag;
    2653       486178 :   TREE_TYPE (t) = type ? type : build_complex_type (TREE_TYPE (real));
    2654       486178 :   TREE_OVERFLOW (t) = TREE_OVERFLOW (real) | TREE_OVERFLOW (imag);
    2655       486178 :   return t;
    2656              : }
    2657              : 
    2658              : /* Build a complex (inf +- 0i), such as for the result of cproj.
    2659              :    TYPE is the complex tree type of the result.  If NEG is true, the
    2660              :    imaginary zero is negative.  */
    2661              : 
    2662              : tree
    2663          840 : build_complex_inf (tree type, bool neg)
    2664              : {
    2665          840 :   REAL_VALUE_TYPE rzero = dconst0;
    2666              : 
    2667          840 :   rzero.sign = neg;
    2668          840 :   return build_complex (type, build_real (TREE_TYPE (type), dconstinf),
    2669          840 :                         build_real (TREE_TYPE (type), rzero));
    2670              : }
    2671              : 
    2672              : /* Return the constant 1 in type TYPE.  If TYPE has several elements, each
    2673              :    element is set to 1.  In particular, this is 1 + i for complex types.  */
    2674              : 
    2675              : tree
    2676         3854 : build_each_one_cst (tree type)
    2677              : {
    2678         3854 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2679              :     {
    2680            0 :       tree scalar = build_one_cst (TREE_TYPE (type));
    2681            0 :       return build_complex (type, scalar, scalar);
    2682              :     }
    2683              :   else
    2684         3854 :     return build_one_cst (type);
    2685              : }
    2686              : 
    2687              : /* Return a constant of arithmetic type TYPE which is the
    2688              :    multiplicative identity of the set TYPE.  */
    2689              : 
    2690              : tree
    2691     10003320 : build_one_cst (tree type)
    2692              : {
    2693     10003320 :   switch (TREE_CODE (type))
    2694              :     {
    2695      9989229 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2696      9989229 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2697      9989229 :     case OFFSET_TYPE: case BITINT_TYPE:
    2698      9989229 :       return build_int_cst (type, 1);
    2699              : 
    2700        10509 :     case REAL_TYPE:
    2701        10509 :       return build_real (type, dconst1);
    2702              : 
    2703            0 :     case FIXED_POINT_TYPE:
    2704              :       /* We can only generate 1 for accum types.  */
    2705            0 :       gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
    2706            0 :       return build_fixed (type, FCONST1 (TYPE_MODE (type)));
    2707              : 
    2708          579 :     case VECTOR_TYPE:
    2709          579 :       {
    2710          579 :         tree scalar = build_one_cst (TREE_TYPE (type));
    2711              : 
    2712          579 :         return build_vector_from_val (type, scalar);
    2713              :       }
    2714              : 
    2715         3003 :     case COMPLEX_TYPE:
    2716         6006 :       return build_complex (type,
    2717         3003 :                             build_one_cst (TREE_TYPE (type)),
    2718         6006 :                             build_zero_cst (TREE_TYPE (type)));
    2719              : 
    2720            0 :     default:
    2721            0 :       gcc_unreachable ();
    2722              :     }
    2723              : }
    2724              : 
    2725              : /* Return an integer of type TYPE containing all 1's in as much precision as
    2726              :    it contains, or a complex or vector whose subparts are such integers.  */
    2727              : 
    2728              : tree
    2729      1700798 : build_all_ones_cst (tree type)
    2730              : {
    2731      1700798 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2732              :     {
    2733            0 :       tree scalar = build_all_ones_cst (TREE_TYPE (type));
    2734            0 :       return build_complex (type, scalar, scalar);
    2735              :     }
    2736              :   else
    2737      1700798 :     return build_minus_one_cst (type);
    2738              : }
    2739              : 
    2740              : /* Return a constant of arithmetic type TYPE which is the
    2741              :    opposite of the multiplicative identity of the set TYPE.  */
    2742              : 
    2743              : tree
    2744      2300977 : build_minus_one_cst (tree type)
    2745              : {
    2746      2300977 :   switch (TREE_CODE (type))
    2747              :     {
    2748      2182115 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2749      2182115 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2750      2182115 :     case OFFSET_TYPE: case BITINT_TYPE:
    2751      2182115 :       return build_int_cst (type, -1);
    2752              : 
    2753         9750 :     case REAL_TYPE:
    2754         9750 :       return build_real (type, dconstm1);
    2755              : 
    2756            0 :     case FIXED_POINT_TYPE:
    2757              :       /* We can only generate 1 for accum types.  */
    2758            0 :       gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
    2759            0 :       return build_fixed (type,
    2760              :                           fixed_from_double_int (double_int_minus_one,
    2761            0 :                                                  SCALAR_TYPE_MODE (type)));
    2762              : 
    2763       109112 :     case VECTOR_TYPE:
    2764       109112 :       {
    2765       109112 :         tree scalar = build_minus_one_cst (TREE_TYPE (type));
    2766              : 
    2767       109112 :         return build_vector_from_val (type, scalar);
    2768              :       }
    2769              : 
    2770            0 :     case COMPLEX_TYPE:
    2771            0 :       return build_complex (type,
    2772            0 :                             build_minus_one_cst (TREE_TYPE (type)),
    2773            0 :                             build_zero_cst (TREE_TYPE (type)));
    2774              : 
    2775            0 :     default:
    2776            0 :       gcc_unreachable ();
    2777              :     }
    2778              : }
    2779              : 
    2780              : /* Build 0 constant of type TYPE.  This is used by constructor folding
    2781              :    and thus the constant should be represented in memory by
    2782              :    zero(es).  */
    2783              : 
    2784              : tree
    2785     83249148 : build_zero_cst (tree type)
    2786              : {
    2787     83249148 :   switch (TREE_CODE (type))
    2788              :     {
    2789     82686015 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2790     82686015 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2791     82686015 :     case OFFSET_TYPE: case NULLPTR_TYPE: case BITINT_TYPE:
    2792     82686015 :       return build_int_cst (type, 0);
    2793              : 
    2794       207813 :     case REAL_TYPE:
    2795       207813 :       return build_real (type, dconst0);
    2796              : 
    2797            0 :     case FIXED_POINT_TYPE:
    2798            0 :       return build_fixed (type, FCONST0 (TYPE_MODE (type)));
    2799              : 
    2800       167067 :     case VECTOR_TYPE:
    2801       167067 :       {
    2802       167067 :         tree scalar = build_zero_cst (TREE_TYPE (type));
    2803              : 
    2804       167067 :         return build_vector_from_val (type, scalar);
    2805              :       }
    2806              : 
    2807         2054 :     case COMPLEX_TYPE:
    2808         2054 :       {
    2809         2054 :         tree zero = build_zero_cst (TREE_TYPE (type));
    2810              : 
    2811         2054 :         return build_complex (type, zero, zero);
    2812              :       }
    2813              : 
    2814       186199 :     default:
    2815       186199 :       if (!AGGREGATE_TYPE_P (type))
    2816            1 :         return fold_convert (type, integer_zero_node);
    2817       186198 :       return build_constructor (type, NULL);
    2818              :     }
    2819              : }
    2820              : 
    2821              : /* Build a constant of integer type TYPE, made of VALUE's bits replicated
    2822              :    every WIDTH bits to fit TYPE's precision.  */
    2823              : 
    2824              : tree
    2825           14 : build_replicated_int_cst (tree type, unsigned int width, HOST_WIDE_INT value)
    2826              : {
    2827           14 :   int n = ((TYPE_PRECISION (type) + HOST_BITS_PER_WIDE_INT - 1)
    2828           14 :            / HOST_BITS_PER_WIDE_INT);
    2829           14 :   unsigned HOST_WIDE_INT low, mask;
    2830           14 :   HOST_WIDE_INT a[WIDE_INT_MAX_INL_ELTS];
    2831           14 :   int i;
    2832              : 
    2833           14 :   gcc_assert (n && n <= WIDE_INT_MAX_INL_ELTS);
    2834              : 
    2835           14 :   if (width == HOST_BITS_PER_WIDE_INT)
    2836            0 :     low = value;
    2837              :   else
    2838              :     {
    2839           14 :       mask = (HOST_WIDE_INT_1U << width) - 1;
    2840           14 :       low = (unsigned HOST_WIDE_INT) ~0 / mask * (value & mask);
    2841              :     }
    2842              : 
    2843           28 :   for (i = 0; i < n; i++)
    2844           14 :     a[i] = low;
    2845              : 
    2846           14 :   gcc_assert (TYPE_PRECISION (type) <= MAX_BITSIZE_MODE_ANY_INT);
    2847           14 :   return wide_int_to_tree (type, wide_int::from_array (a, n,
    2848           14 :                                                        TYPE_PRECISION (type)));
    2849              : }
    2850              : 
    2851              : /* If floating-point type TYPE has an IEEE-style sign bit, return an
    2852              :    unsigned constant in which only the sign bit is set.  Return null
    2853              :    otherwise.  */
    2854              : 
    2855              : tree
    2856            0 : sign_mask_for (tree type)
    2857              : {
    2858              :   /* Avoid having to choose between a real-only sign and a pair of signs.
    2859              :      This could be relaxed if the choice becomes obvious later.  */
    2860            0 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2861              :     return NULL_TREE;
    2862              : 
    2863            0 :   auto eltmode = as_a<scalar_float_mode> (element_mode (type));
    2864            0 :   auto bits = REAL_MODE_FORMAT (eltmode)->ieee_bits;
    2865            0 :   if (!bits || !pow2p_hwi (bits))
    2866              :     return NULL_TREE;
    2867              : 
    2868            0 :   tree inttype = unsigned_type_for (type);
    2869            0 :   if (!inttype)
    2870              :     return NULL_TREE;
    2871              : 
    2872            0 :   auto mask = wi::set_bit_in_zero (bits - 1, bits);
    2873            0 :   if (VECTOR_TYPE_P (inttype))
    2874              :     {
    2875            0 :       tree elt = wide_int_to_tree (TREE_TYPE (inttype), mask);
    2876            0 :       return build_vector_from_val (inttype, elt);
    2877              :     }
    2878            0 :   return wide_int_to_tree (inttype, mask);
    2879            0 : }
    2880              : 
    2881              : /* Build a BINFO with LEN language slots.  */
    2882              : 
    2883              : tree
    2884    105765077 : make_tree_binfo (unsigned base_binfos MEM_STAT_DECL)
    2885              : {
    2886    105765077 :   tree t;
    2887    105765077 :   size_t length = (offsetof (struct tree_binfo, base_binfos)
    2888    105765077 :                    + vec<tree, va_gc>::embedded_size (base_binfos));
    2889              : 
    2890    105765077 :   record_node_allocation_statistics (TREE_BINFO, length);
    2891              : 
    2892    105765077 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    2893              : 
    2894    105765077 :   memset (t, 0, offsetof (struct tree_binfo, base_binfos));
    2895              : 
    2896    105765077 :   TREE_SET_CODE (t, TREE_BINFO);
    2897              : 
    2898    105765077 :   BINFO_BASE_BINFOS (t)->embedded_init (base_binfos);
    2899              : 
    2900    105765077 :   return t;
    2901              : }
    2902              : 
    2903              : /* Create a CASE_LABEL_EXPR tree node and return it.  */
    2904              : 
    2905              : tree
    2906      6598471 : build_case_label (tree low_value, tree high_value, tree label_decl)
    2907              : {
    2908      6598471 :   tree t = make_node (CASE_LABEL_EXPR);
    2909              : 
    2910      6598471 :   TREE_TYPE (t) = void_type_node;
    2911      6598471 :   SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (label_decl));
    2912              : 
    2913      6598471 :   CASE_LOW (t) = low_value;
    2914      6598471 :   CASE_HIGH (t) = high_value;
    2915      6598471 :   CASE_LABEL (t) = label_decl;
    2916      6598471 :   CASE_CHAIN (t) = NULL_TREE;
    2917              : 
    2918      6598471 :   return t;
    2919              : }
    2920              : 
    2921              : /* Build a newly constructed INTEGER_CST node.  LEN and EXT_LEN are the
    2922              :    values of TREE_INT_CST_NUNITS and TREE_INT_CST_EXT_NUNITS respectively.
    2923              :    The latter determines the length of the HOST_WIDE_INT vector.  */
    2924              : 
    2925              : tree
    2926    283286483 : make_int_cst (int len, int ext_len MEM_STAT_DECL)
    2927              : {
    2928    283286483 :   tree t;
    2929    283286483 :   int length = ((ext_len - 1) * sizeof (HOST_WIDE_INT)
    2930    283286483 :                 + sizeof (struct tree_int_cst));
    2931              : 
    2932    283286483 :   gcc_assert (len);
    2933    283286483 :   record_node_allocation_statistics (INTEGER_CST, length);
    2934              : 
    2935    283286483 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2936              : 
    2937    283286483 :   TREE_SET_CODE (t, INTEGER_CST);
    2938    283286483 :   TREE_INT_CST_NUNITS (t) = len;
    2939    283286483 :   TREE_INT_CST_EXT_NUNITS (t) = ext_len;
    2940    283286483 :   TREE_CONSTANT (t) = 1;
    2941              : 
    2942    283286483 :   return t;
    2943              : }
    2944              : 
    2945              : /* Build a newly constructed TREE_VEC node of length LEN.  */
    2946              : 
    2947              : tree
    2948   3098236859 : make_tree_vec (int len MEM_STAT_DECL)
    2949              : {
    2950   3098236859 :   tree t;
    2951   3098236859 :   size_t length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2952              : 
    2953   3098236859 :   record_node_allocation_statistics (TREE_VEC, length);
    2954              : 
    2955   3098236859 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2956              : 
    2957   3098236859 :   TREE_SET_CODE (t, TREE_VEC);
    2958   3098236859 :   TREE_VEC_LENGTH (t) = len;
    2959              : 
    2960   3098236859 :   return t;
    2961              : }
    2962              : 
    2963              : /* Grow a TREE_VEC node to new length LEN.  */
    2964              : 
    2965              : tree
    2966       464449 : grow_tree_vec (tree v, int len MEM_STAT_DECL)
    2967              : {
    2968       464449 :   gcc_assert (TREE_CODE (v) == TREE_VEC);
    2969              : 
    2970       464449 :   int oldlen = TREE_VEC_LENGTH (v);
    2971       464449 :   gcc_assert (len > oldlen);
    2972              : 
    2973       464449 :   size_t oldlength = (oldlen - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2974       464449 :   size_t length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2975              : 
    2976       464449 :   record_node_allocation_statistics (TREE_VEC, length - oldlength);
    2977              : 
    2978       464449 :   v = (tree) ggc_realloc (v, length PASS_MEM_STAT);
    2979              : 
    2980       464449 :   TREE_VEC_LENGTH (v) = len;
    2981              : 
    2982       464449 :   return v;
    2983              : }
    2984              : 
    2985              : /* Return true if EXPR is the constant zero, whether it is integral, float or
    2986              :    fixed, and scalar, complex or vector.  */
    2987              : 
    2988              : bool
    2989     17225416 : zerop (const_tree expr)
    2990              : {
    2991     17225416 :   return (integer_zerop (expr)
    2992     11982912 :           || real_zerop (expr)
    2993     28834027 :           || fixed_zerop (expr));
    2994              : }
    2995              : 
    2996              : /* Return true if EXPR is the integer constant zero or a complex constant
    2997              :    of zero, or a location wrapper for such a constant.  */
    2998              : 
    2999              : bool
    3000   6304256506 : integer_zerop (const_tree expr)
    3001              : {
    3002   6304256506 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3003              : 
    3004   6304256506 :   switch (TREE_CODE (expr))
    3005              :     {
    3006   5153069885 :     case INTEGER_CST:
    3007   5153069885 :       return wi::to_wide (expr) == 0;
    3008      1198208 :     case COMPLEX_CST:
    3009      1198208 :       return (integer_zerop (TREE_REALPART (expr))
    3010      1220556 :               && integer_zerop (TREE_IMAGPART (expr)));
    3011      2783702 :     case VECTOR_CST:
    3012      2783702 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3013      2634850 :               && VECTOR_CST_DUPLICATE_P (expr)
    3014      4994665 :               && integer_zerop (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3015              :     default:
    3016              :       return false;
    3017              :     }
    3018              : }
    3019              : 
    3020              : /* Return true if EXPR is the integer constant one or the corresponding
    3021              :    complex constant, or a location wrapper for such a constant.  */
    3022              : 
    3023              : bool
    3024   1034608555 : integer_onep (const_tree expr)
    3025              : {
    3026   1034608555 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3027              : 
    3028   1034608555 :   switch (TREE_CODE (expr))
    3029              :     {
    3030    894546788 :     case INTEGER_CST:
    3031    894546788 :       return wi::eq_p (wi::to_widest (expr), 1);
    3032        21547 :     case COMPLEX_CST:
    3033        21547 :       return (integer_onep (TREE_REALPART (expr))
    3034        21571 :               && integer_zerop (TREE_IMAGPART (expr)));
    3035       167754 :     case VECTOR_CST:
    3036       167754 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3037       150237 :               && VECTOR_CST_DUPLICATE_P (expr)
    3038       301194 :               && integer_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3039              :     default:
    3040              :       return false;
    3041              :     }
    3042              : }
    3043              : 
    3044              : /* Return true if EXPR is the integer constant one.  For complex and vector,
    3045              :    return true if every piece is the integer constant one.
    3046              :    Also return true for location wrappers for such a constant.  */
    3047              : 
    3048              : bool
    3049       731066 : integer_each_onep (const_tree expr)
    3050              : {
    3051       731066 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3052              : 
    3053       731066 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3054           34 :     return (integer_onep (TREE_REALPART (expr))
    3055           48 :             && integer_onep (TREE_IMAGPART (expr)));
    3056              :   else
    3057       731032 :     return integer_onep (expr);
    3058              : }
    3059              : 
    3060              : /* Return true if EXPR is an integer containing all 1's in as much precision
    3061              :    as it contains, or a complex or vector whose subparts are such integers,
    3062              :    or a location wrapper for such a constant.  */
    3063              : 
    3064              : bool
    3065    288062339 : integer_all_onesp (const_tree expr)
    3066              : {
    3067    288062339 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3068              : 
    3069    288062339 :   if (TREE_CODE (expr) == COMPLEX_CST
    3070          950 :       && integer_all_onesp (TREE_REALPART (expr))
    3071    288062379 :       && integer_all_onesp (TREE_IMAGPART (expr)))
    3072              :     return true;
    3073              : 
    3074    288062303 :   else if (TREE_CODE (expr) == VECTOR_CST)
    3075       539807 :     return (VECTOR_CST_NPATTERNS (expr) == 1
    3076       493563 :             && VECTOR_CST_DUPLICATE_P (expr)
    3077      1012202 :             && integer_all_onesp (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3078              : 
    3079    287522496 :   else if (TREE_CODE (expr) != INTEGER_CST)
    3080              :     return false;
    3081              : 
    3082    190789923 :   return (wi::max_value (TYPE_PRECISION (TREE_TYPE (expr)), UNSIGNED)
    3083    381580359 :           == wi::to_wide (expr));
    3084              : }
    3085              : 
    3086              : /* Return true if EXPR is the integer constant minus one, or a location
    3087              :    wrapper for such a constant.  */
    3088              : 
    3089              : bool
    3090    211898540 : integer_minus_onep (const_tree expr)
    3091              : {
    3092    211898540 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3093              : 
    3094    211898540 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3095         9069 :     return (integer_all_onesp (TREE_REALPART (expr))
    3096         9073 :             && integer_zerop (TREE_IMAGPART (expr)));
    3097              :   else
    3098    211889471 :     return integer_all_onesp (expr);
    3099              : }
    3100              : 
    3101              : /* Return true if EXPR is an integer constant that is a power of 2 (i.e., has
    3102              :    only one bit on), or a location wrapper for such a constant.  */
    3103              : 
    3104              : bool
    3105     20031648 : integer_pow2p (const_tree expr)
    3106              : {
    3107     20031648 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3108              : 
    3109     20031648 :   if (TREE_CODE (expr) == COMPLEX_CST
    3110          553 :       && integer_pow2p (TREE_REALPART (expr))
    3111     20031875 :       && integer_zerop (TREE_IMAGPART (expr)))
    3112              :     return true;
    3113              : 
    3114     20031495 :   if (TREE_CODE (expr) != INTEGER_CST)
    3115              :     return false;
    3116              : 
    3117     13506469 :   return wi::popcount (wi::to_wide (expr)) == 1;
    3118              : }
    3119              : 
    3120              : /* Return true if EXPR is an integer constant other than zero or a
    3121              :    complex constant other than zero, or a location wrapper for such a
    3122              :    constant.  */
    3123              : 
    3124              : bool
    3125    147683907 : integer_nonzerop (const_tree expr)
    3126              : {
    3127    147683907 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3128              : 
    3129    147683907 :   return ((TREE_CODE (expr) == INTEGER_CST
    3130     72513259 :            && wi::to_wide (expr) != 0)
    3131    165667598 :           || (TREE_CODE (expr) == COMPLEX_CST
    3132          244 :               && (integer_nonzerop (TREE_REALPART (expr))
    3133          184 :                   || integer_nonzerop (TREE_IMAGPART (expr)))));
    3134              : }
    3135              : 
    3136              : /* Return true if EXPR is the integer constant one.  For vector,
    3137              :    return true if every piece is the integer constant minus one
    3138              :    (representing the value TRUE).
    3139              :    Also return true for location wrappers for such a constant.  */
    3140              : 
    3141              : bool
    3142      1129685 : integer_truep (const_tree expr)
    3143              : {
    3144      1129685 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3145              : 
    3146      1129685 :   if (TREE_CODE (expr) == VECTOR_CST)
    3147        14684 :     return integer_all_onesp (expr);
    3148      1115001 :   return integer_onep (expr);
    3149              : }
    3150              : 
    3151              : /* Return true if EXPR is the fixed-point constant zero, or a location wrapper
    3152              :    for such a constant.  */
    3153              : 
    3154              : bool
    3155     28119783 : fixed_zerop (const_tree expr)
    3156              : {
    3157     28119783 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3158              : 
    3159     28119783 :   return (TREE_CODE (expr) == FIXED_CST
    3160     28119783 :           && TREE_FIXED_CST (expr).data.is_zero ());
    3161              : }
    3162              : 
    3163              : /* Return the power of two represented by a tree node known to be a
    3164              :    power of two.  */
    3165              : 
    3166              : int
    3167       767902 : tree_log2 (const_tree expr)
    3168              : {
    3169       767902 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3170            0 :     return tree_log2 (TREE_REALPART (expr));
    3171              : 
    3172       767902 :   return wi::exact_log2 (wi::to_wide (expr));
    3173              : }
    3174              : 
    3175              : /* Similar, but return the largest integer Y such that 2 ** Y is less
    3176              :    than or equal to EXPR.  */
    3177              : 
    3178              : int
    3179      2837003 : tree_floor_log2 (const_tree expr)
    3180              : {
    3181      2837003 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3182            0 :     return tree_log2 (TREE_REALPART (expr));
    3183              : 
    3184      2837003 :   return wi::floor_log2 (wi::to_wide (expr));
    3185              : }
    3186              : 
    3187              : /* Return number of known trailing zero bits in EXPR, or, if the value of
    3188              :    EXPR is known to be zero, the precision of it's type.  */
    3189              : 
    3190              : unsigned int
    3191     83042453 : tree_ctz (const_tree expr)
    3192              : {
    3193    166083184 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
    3194     83050231 :       && !POINTER_TYPE_P (TREE_TYPE (expr)))
    3195              :     return 0;
    3196              : 
    3197     83042392 :   unsigned int ret1, ret2, prec = TYPE_PRECISION (TREE_TYPE (expr));
    3198     83042392 :   switch (TREE_CODE (expr))
    3199              :     {
    3200     43716298 :     case INTEGER_CST:
    3201     43716298 :       ret1 = wi::ctz (wi::to_wide (expr));
    3202     43716298 :       return MIN (ret1, prec);
    3203     12807322 :     case SSA_NAME:
    3204     12807322 :       ret1 = wi::ctz (get_nonzero_bits (expr));
    3205     12807322 :       return MIN (ret1, prec);
    3206      2092570 :     case PLUS_EXPR:
    3207      2092570 :     case MINUS_EXPR:
    3208      2092570 :     case BIT_IOR_EXPR:
    3209      2092570 :     case BIT_XOR_EXPR:
    3210      2092570 :     case MIN_EXPR:
    3211      2092570 :     case MAX_EXPR:
    3212      2092570 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3213      2092570 :       if (ret1 == 0)
    3214              :         return ret1;
    3215       970203 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3216       970203 :       return MIN (ret1, ret2);
    3217            0 :     case POINTER_PLUS_EXPR:
    3218            0 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3219            0 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3220              :       /* Second operand is sizetype, which could be in theory
    3221              :          wider than pointer's precision.  Make sure we never
    3222              :          return more than prec.  */
    3223            0 :       ret2 = MIN (ret2, prec);
    3224            0 :       return MIN (ret1, ret2);
    3225          234 :     case BIT_AND_EXPR:
    3226          234 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3227          234 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3228          234 :       return MAX (ret1, ret2);
    3229     11922544 :     case MULT_EXPR:
    3230     11922544 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3231     11922544 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3232     11922544 :       return MIN (ret1 + ret2, prec);
    3233            0 :     case LSHIFT_EXPR:
    3234            0 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3235            0 :       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
    3236            0 :           && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
    3237              :         {
    3238            0 :           ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
    3239            0 :           return MIN (ret1 + ret2, prec);
    3240              :         }
    3241              :       return ret1;
    3242            0 :     case RSHIFT_EXPR:
    3243            0 :       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
    3244            0 :           && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
    3245              :         {
    3246            0 :           ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3247            0 :           ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
    3248            0 :           if (ret1 > ret2)
    3249            0 :             return ret1 - ret2;
    3250              :         }
    3251              :       return 0;
    3252         5921 :     case TRUNC_DIV_EXPR:
    3253         5921 :     case CEIL_DIV_EXPR:
    3254         5921 :     case FLOOR_DIV_EXPR:
    3255         5921 :     case ROUND_DIV_EXPR:
    3256         5921 :     case EXACT_DIV_EXPR:
    3257         5921 :       if (TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST
    3258         5921 :           && tree_int_cst_sgn (TREE_OPERAND (expr, 1)) == 1)
    3259              :         {
    3260         5921 :           int l = tree_log2 (TREE_OPERAND (expr, 1));
    3261         5921 :           if (l >= 0)
    3262              :             {
    3263         4909 :               ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3264         4909 :               ret2 = l;
    3265         4909 :               if (ret1 > ret2)
    3266            0 :                 return ret1 - ret2;
    3267              :             }
    3268              :         }
    3269              :       return 0;
    3270     12473083 :     CASE_CONVERT:
    3271     12473083 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3272     12473083 :       if (ret1 && ret1 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
    3273              :         ret1 = prec;
    3274     12473083 :       return MIN (ret1, prec);
    3275            0 :     case SAVE_EXPR:
    3276            0 :       return tree_ctz (TREE_OPERAND (expr, 0));
    3277        12567 :     case COND_EXPR:
    3278        12567 :       ret1 = tree_ctz (TREE_OPERAND (expr, 1));
    3279        12567 :       if (ret1 == 0)
    3280              :         return 0;
    3281          205 :       ret2 = tree_ctz (TREE_OPERAND (expr, 2));
    3282          205 :       return MIN (ret1, ret2);
    3283            0 :     case COMPOUND_EXPR:
    3284            0 :       return tree_ctz (TREE_OPERAND (expr, 1));
    3285          197 :     case ADDR_EXPR:
    3286          197 :       ret1 = get_pointer_alignment (const_cast<tree> (expr));
    3287          197 :       if (ret1 > BITS_PER_UNIT)
    3288              :         {
    3289          197 :           ret1 = ctz_hwi (ret1 / BITS_PER_UNIT);
    3290          197 :           return MIN (ret1, prec);
    3291              :         }
    3292              :       return 0;
    3293              :     default:
    3294              :       return 0;
    3295              :     }
    3296              : }
    3297              : 
    3298              : /* Return true if EXPR is the real constant zero.  Trailing zeroes matter for
    3299              :    decimal float constants, so don't return true for them.
    3300              :    Also return true for location wrappers around such a constant.  */
    3301              : 
    3302              : bool
    3303    580803140 : real_zerop (const_tree expr)
    3304              : {
    3305    580803140 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3306              : 
    3307    580803140 :   switch (TREE_CODE (expr))
    3308              :     {
    3309     18716011 :     case REAL_CST:
    3310     18716011 :       return real_equal (&TREE_REAL_CST (expr), &dconst0)
    3311     18716011 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3312        44020 :     case COMPLEX_CST:
    3313        44020 :       return real_zerop (TREE_REALPART (expr))
    3314        56625 :              && real_zerop (TREE_IMAGPART (expr));
    3315       444447 :     case VECTOR_CST:
    3316       444447 :       {
    3317              :         /* Don't simply check for a duplicate because the predicate
    3318              :            accepts both +0.0 and -0.0.  */
    3319       444447 :         unsigned count = vector_cst_encoded_nelts (expr);
    3320       473284 :         for (unsigned int i = 0; i < count; ++i)
    3321       454412 :           if (!real_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
    3322              :             return false;
    3323              :         return true;
    3324              :       }
    3325              :     default:
    3326              :       return false;
    3327              :     }
    3328              : }
    3329              : 
    3330              : /* Return true if EXPR is the real constant one in real or complex form.
    3331              :    Trailing zeroes matter for decimal float constants, so don't return
    3332              :    true for them.
    3333              :    Also return true for location wrappers around such a constant.  */
    3334              : 
    3335              : bool
    3336    120014610 : real_onep (const_tree expr)
    3337              : {
    3338    120014610 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3339              : 
    3340    120014610 :   switch (TREE_CODE (expr))
    3341              :     {
    3342      6955390 :     case REAL_CST:
    3343      6955390 :       return real_equal (&TREE_REAL_CST (expr), &dconst1)
    3344      6955390 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3345        12620 :     case COMPLEX_CST:
    3346        12620 :       return real_onep (TREE_REALPART (expr))
    3347        16109 :              && real_zerop (TREE_IMAGPART (expr));
    3348        58228 :     case VECTOR_CST:
    3349        58228 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3350        49404 :               && VECTOR_CST_DUPLICATE_P (expr)
    3351        97796 :               && real_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3352              :     default:
    3353              :       return false;
    3354              :     }
    3355              : }
    3356              : 
    3357              : /* Return true if EXPR is the real constant minus one.  Trailing zeroes
    3358              :    matter for decimal float constants, so don't return true for them.
    3359              :    Also return true for location wrappers around such a constant.  */
    3360              : 
    3361              : bool
    3362    121028688 : real_minus_onep (const_tree expr)
    3363              : {
    3364    121028688 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3365              : 
    3366    121028688 :   switch (TREE_CODE (expr))
    3367              :     {
    3368      6891119 :     case REAL_CST:
    3369      6891119 :       return real_equal (&TREE_REAL_CST (expr), &dconstm1)
    3370      6891119 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3371        12600 :     case COMPLEX_CST:
    3372        12600 :       return real_minus_onep (TREE_REALPART (expr))
    3373        14972 :              && real_zerop (TREE_IMAGPART (expr));
    3374        59851 :     case VECTOR_CST:
    3375        59851 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3376        50429 :               && VECTOR_CST_DUPLICATE_P (expr)
    3377       100282 :               && real_minus_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3378              :     default:
    3379              :       return false;
    3380              :     }
    3381              : }
    3382              : 
    3383              : /* Return true if T could be a floating point zero.  */
    3384              : 
    3385              : bool
    3386       693469 : real_maybe_zerop (const_tree expr)
    3387              : {
    3388       693469 :   switch (TREE_CODE (expr))
    3389              :     {
    3390       474193 :     case REAL_CST:
    3391              :       /* Can't use real_zerop here, as it always returns false for decimal
    3392              :          floats.  And can't use TREE_REAL_CST (expr).cl == rvc_zero
    3393              :          either, as decimal zeros are rvc_normal.  */
    3394       474193 :       return real_equal (&TREE_REAL_CST (expr), &dconst0);
    3395            0 :     case COMPLEX_CST:
    3396            0 :       return (real_maybe_zerop (TREE_REALPART (expr))
    3397            0 :               || real_maybe_zerop (TREE_IMAGPART (expr)));
    3398            0 :     case VECTOR_CST:
    3399            0 :       {
    3400            0 :         unsigned count = vector_cst_encoded_nelts (expr);
    3401            0 :         for (unsigned int i = 0; i < count; ++i)
    3402            0 :           if (real_maybe_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
    3403              :             return true;
    3404              :         return false;
    3405              :       }
    3406              :     default:
    3407              :       /* Perhaps for SSA_NAMEs we could query frange.  */
    3408              :       return true;
    3409              :     }
    3410              : }
    3411              : 
    3412              : /* True if EXP is a constant or a cast of a constant.  */
    3413              : 
    3414              : bool
    3415         6587 : really_constant_p (const_tree exp)
    3416              : {
    3417              :   /* This is not quite the same as STRIP_NOPS.  It does more.  */
    3418        13182 :   while (CONVERT_EXPR_P (exp)
    3419        13234 :          || TREE_CODE (exp) == NON_LVALUE_EXPR)
    3420           60 :     exp = TREE_OPERAND (exp, 0);
    3421         6587 :   return TREE_CONSTANT (exp);
    3422              : }
    3423              : 
    3424              : /* Return true if T holds a polynomial pointer difference, storing it in
    3425              :    *VALUE if so.  A true return means that T's precision is no greater
    3426              :    than 64 bits, which is the largest address space we support, so *VALUE
    3427              :    never loses precision.  However, the signedness of the result does
    3428              :    not necessarily match the signedness of T: sometimes an unsigned type
    3429              :    like sizetype is used to encode a value that is actually negative.  */
    3430              : 
    3431              : bool
    3432     11381062 : ptrdiff_tree_p (const_tree t, poly_int64 *value)
    3433              : {
    3434     11381062 :   if (!t)
    3435              :     return false;
    3436     11381062 :   if (TREE_CODE (t) == INTEGER_CST)
    3437              :     {
    3438      3376490 :       if (!cst_and_fits_in_hwi (t))
    3439              :         return false;
    3440      3375943 :       *value = int_cst_value (t);
    3441      3375943 :       return true;
    3442              :     }
    3443              :   if (POLY_INT_CST_P (t))
    3444              :     {
    3445              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    3446              :         if (!cst_and_fits_in_hwi (POLY_INT_CST_COEFF (t, i)))
    3447              :           return false;
    3448              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    3449              :         value->coeffs[i] = int_cst_value (POLY_INT_CST_COEFF (t, i));
    3450              :       return true;
    3451              :     }
    3452              :   return false;
    3453              : }
    3454              : 
    3455              : poly_int64
    3456    457615738 : tree_to_poly_int64 (const_tree t)
    3457              : {
    3458    457615738 :   gcc_assert (tree_fits_poly_int64_p (t));
    3459    457615738 :   if (POLY_INT_CST_P (t))
    3460              :     return poly_int_cst_value (t).force_shwi ();
    3461    457615738 :   return TREE_INT_CST_LOW (t);
    3462              : }
    3463              : 
    3464              : poly_uint64
    3465    507553957 : tree_to_poly_uint64 (const_tree t)
    3466              : {
    3467    507553957 :   gcc_assert (tree_fits_poly_uint64_p (t));
    3468    507553957 :   if (POLY_INT_CST_P (t))
    3469              :     return poly_int_cst_value (t).force_uhwi ();
    3470    507553957 :   return TREE_INT_CST_LOW (t);
    3471              : }
    3472              : 
    3473              : /* Return first list element whose TREE_VALUE is ELEM.
    3474              :    Return 0 if ELEM is not in LIST.  */
    3475              : 
    3476              : tree
    3477      7796002 : value_member (tree elem, tree list)
    3478              : {
    3479     22718516 :   while (list)
    3480              :     {
    3481     19744278 :       if (elem == TREE_VALUE (list))
    3482              :         return list;
    3483     14922514 :       list = TREE_CHAIN (list);
    3484              :     }
    3485              :   return NULL_TREE;
    3486              : }
    3487              : 
    3488              : /* Return first list element whose TREE_PURPOSE is ELEM.
    3489              :    Return 0 if ELEM is not in LIST.  */
    3490              : 
    3491              : tree
    3492    193353515 : purpose_member (const_tree elem, tree list)
    3493              : {
    3494    507346394 :   while (list)
    3495              :     {
    3496    344241833 :       if (elem == TREE_PURPOSE (list))
    3497              :         return list;
    3498    313992879 :       list = TREE_CHAIN (list);
    3499              :     }
    3500              :   return NULL_TREE;
    3501              : }
    3502              : 
    3503              : /* Return true if ELEM is in V.  */
    3504              : 
    3505              : bool
    3506      5044682 : vec_member (const_tree elem, vec<tree, va_gc> *v)
    3507              : {
    3508      5044682 :   unsigned ix;
    3509      5044682 :   tree t;
    3510      7690453 :   FOR_EACH_VEC_SAFE_ELT (v, ix, t)
    3511      2649782 :     if (elem == t)
    3512              :       return true;
    3513              :   return false;
    3514              : }
    3515              : 
    3516              : /* Returns element number IDX (zero-origin) of chain CHAIN, or
    3517              :    NULL_TREE.  */
    3518              : 
    3519              : tree
    3520     21521919 : chain_index (int idx, tree chain)
    3521              : {
    3522     27521155 :   for (; chain && idx > 0; --idx)
    3523      5999236 :     chain = TREE_CHAIN (chain);
    3524     21521919 :   return chain;
    3525              : }
    3526              : 
    3527              : /* Return true if ELEM is part of the chain CHAIN.  */
    3528              : 
    3529              : bool
    3530       220003 : chain_member (const_tree elem, const_tree chain)
    3531              : {
    3532       407813 :   while (chain)
    3533              :     {
    3534       406353 :       if (elem == chain)
    3535              :         return true;
    3536       187810 :       chain = DECL_CHAIN (chain);
    3537              :     }
    3538              : 
    3539              :   return false;
    3540              : }
    3541              : 
    3542              : /* Return the length of a chain of nodes chained through TREE_CHAIN.
    3543              :    We expect a null pointer to mark the end of the chain.
    3544              :    This is the Lisp primitive `length'.  */
    3545              : 
    3546              : int
    3547   2109214681 : list_length (const_tree t)
    3548              : {
    3549   2109214681 :   const_tree p = t;
    3550              : #ifdef ENABLE_TREE_CHECKING
    3551   2109214681 :   const_tree q = t;
    3552              : #endif
    3553   2109214681 :   int len = 0;
    3554              : 
    3555   3442207276 :   while (p)
    3556              :     {
    3557   1332992595 :       p = TREE_CHAIN (p);
    3558              : #ifdef ENABLE_TREE_CHECKING
    3559   1332992595 :       if (len % 2)
    3560    432584249 :         q = TREE_CHAIN (q);
    3561   1332992595 :       gcc_assert (p != q);
    3562              : #endif
    3563   1332992595 :       len++;
    3564              :     }
    3565              : 
    3566   2109214681 :   return len;
    3567              : }
    3568              : 
    3569              : /* Returns the first FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or
    3570              :    UNION_TYPE TYPE, or NULL_TREE if none.  */
    3571              : 
    3572              : tree
    3573        97523 : first_field (const_tree type)
    3574              : {
    3575        97523 :   tree t = TYPE_FIELDS (type);
    3576      3504843 :   while (t && TREE_CODE (t) != FIELD_DECL)
    3577      3407320 :     t = TREE_CHAIN (t);
    3578        97523 :   return t;
    3579              : }
    3580              : 
    3581              : /* Returns the last FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or
    3582              :    UNION_TYPE TYPE, or NULL_TREE if none.  */
    3583              : 
    3584              : tree
    3585      2756177 : last_field (const_tree type)
    3586              : {
    3587      2756177 :   tree last = NULL_TREE;
    3588              : 
    3589     58503948 :   for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
    3590              :     {
    3591     55747771 :       if (TREE_CODE (fld) != FIELD_DECL)
    3592     47421972 :         continue;
    3593              : 
    3594              :       last = fld;
    3595              :     }
    3596              : 
    3597      2756177 :   return last;
    3598              : }
    3599              : 
    3600              : /* Concatenate two chains of nodes (chained through TREE_CHAIN)
    3601              :    by modifying the last node in chain 1 to point to chain 2.
    3602              :    This is the Lisp primitive `nconc'.  */
    3603              : 
    3604              : tree
    3605   4141104062 : chainon (tree op1, tree op2)
    3606              : {
    3607   4141104062 :   tree t1;
    3608              : 
    3609   4141104062 :   if (!op1)
    3610              :     return op2;
    3611    747211514 :   if (!op2)
    3612              :     return op1;
    3613              : 
    3614   1536206738 :   for (t1 = op1; TREE_CHAIN (t1); t1 = TREE_CHAIN (t1))
    3615    865704401 :     continue;
    3616    670502337 :   TREE_CHAIN (t1) = op2;
    3617              : 
    3618              : #ifdef ENABLE_TREE_CHECKING
    3619    670502337 :   {
    3620    670502337 :     tree t2;
    3621   1726606193 :     for (t2 = op2; t2; t2 = TREE_CHAIN (t2))
    3622   1056103856 :       gcc_assert (t2 != t1);
    3623              :   }
    3624              : #endif
    3625              : 
    3626              :   return op1;
    3627    865704401 : }
    3628              : 
    3629              : /* Return the last node in a chain of nodes (chained through TREE_CHAIN).  */
    3630              : 
    3631              : tree
    3632    100630476 : tree_last (tree chain)
    3633              : {
    3634    100630476 :   tree next;
    3635    100630476 :   if (chain)
    3636    184473304 :     while ((next = TREE_CHAIN (chain)))
    3637              :       chain = next;
    3638    100630476 :   return chain;
    3639              : }
    3640              : 
    3641              : /* Reverse the order of elements in the chain T,
    3642              :    and return the new head of the chain (old last element).  */
    3643              : 
    3644              : tree
    3645   1506309240 : nreverse (tree t)
    3646              : {
    3647   1506309240 :   tree prev = 0, decl, next;
    3648   3812698376 :   for (decl = t; decl; decl = next)
    3649              :     {
    3650              :       /* We shouldn't be using this function to reverse BLOCK chains; we
    3651              :          have blocks_nreverse for that.  */
    3652   2306389136 :       gcc_checking_assert (TREE_CODE (decl) != BLOCK);
    3653   2306389136 :       next = TREE_CHAIN (decl);
    3654   2306389136 :       TREE_CHAIN (decl) = prev;
    3655   2306389136 :       prev = decl;
    3656              :     }
    3657   1506309240 :   return prev;
    3658              : }
    3659              : 
    3660              : /* Return a newly created TREE_LIST node whose
    3661              :    purpose and value fields are PARM and VALUE.  */
    3662              : 
    3663              : tree
    3664   1403664752 : build_tree_list (tree parm, tree value MEM_STAT_DECL)
    3665              : {
    3666   1403664752 :   tree t = make_node (TREE_LIST PASS_MEM_STAT);
    3667   1403664752 :   TREE_PURPOSE (t) = parm;
    3668   1403664752 :   TREE_VALUE (t) = value;
    3669   1403664752 :   return t;
    3670              : }
    3671              : 
    3672              : /* Build a chain of TREE_LIST nodes from a vector.  */
    3673              : 
    3674              : tree
    3675     88155626 : build_tree_list_vec (const vec<tree, va_gc> *vec MEM_STAT_DECL)
    3676              : {
    3677     88155626 :   tree ret = NULL_TREE;
    3678     88155626 :   tree *pp = &ret;
    3679     88155626 :   unsigned int i;
    3680     88155626 :   tree t;
    3681    185014675 :   FOR_EACH_VEC_SAFE_ELT (vec, i, t)
    3682              :     {
    3683     96859049 :       *pp = build_tree_list (NULL, t PASS_MEM_STAT);
    3684     96859049 :       pp = &TREE_CHAIN (*pp);
    3685              :     }
    3686     88155626 :   return ret;
    3687              : }
    3688              : 
    3689              : /* Return a newly created TREE_LIST node whose
    3690              :    purpose and value fields are PURPOSE and VALUE
    3691              :    and whose TREE_CHAIN is CHAIN.  */
    3692              : 
    3693              : tree
    3694   5502493073 : tree_cons (tree purpose, tree value, tree chain MEM_STAT_DECL)
    3695              : {
    3696   5502493073 :   tree node;
    3697              : 
    3698   5502493073 :   node = ggc_alloc_tree_node_stat (sizeof (struct tree_list) PASS_MEM_STAT);
    3699   5502493073 :   memset (node, 0, sizeof (struct tree_common));
    3700              : 
    3701   5502493073 :   record_node_allocation_statistics (TREE_LIST, sizeof (struct tree_list));
    3702              : 
    3703   5502493073 :   TREE_SET_CODE (node, TREE_LIST);
    3704   5502493073 :   TREE_CHAIN (node) = chain;
    3705   5502493073 :   TREE_PURPOSE (node) = purpose;
    3706   5502493073 :   TREE_VALUE (node) = value;
    3707   5502493073 :   return node;
    3708              : }
    3709              : 
    3710              : /* Return the values of the elements of a CONSTRUCTOR as a vector of
    3711              :    trees.  */
    3712              : 
    3713              : vec<tree, va_gc> *
    3714            0 : ctor_to_vec (tree ctor)
    3715              : {
    3716            0 :   vec<tree, va_gc> *vec;
    3717            0 :   vec_alloc (vec, CONSTRUCTOR_NELTS (ctor));
    3718            0 :   unsigned int ix;
    3719            0 :   tree val;
    3720              : 
    3721            0 :   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), ix, val)
    3722            0 :     vec->quick_push (val);
    3723              : 
    3724            0 :   return vec;
    3725              : }
    3726              : 
    3727              : /* Return the size nominally occupied by an object of type TYPE
    3728              :    when it resides in memory.  The value is measured in units of bytes,
    3729              :    and its data type is that normally used for type sizes
    3730              :    (which is the first type created by make_signed_type or
    3731              :    make_unsigned_type).  */
    3732              : 
    3733              : tree
    3734     28011221 : size_in_bytes_loc (location_t loc, const_tree type)
    3735              : {
    3736     28011221 :   tree t;
    3737              : 
    3738     28011221 :   if (type == error_mark_node)
    3739            0 :     return integer_zero_node;
    3740              : 
    3741     28011221 :   type = TYPE_MAIN_VARIANT (type);
    3742     28011221 :   t = TYPE_SIZE_UNIT (type);
    3743              : 
    3744     28011221 :   if (t == 0)
    3745              :     {
    3746           65 :       lang_hooks.types.incomplete_type_error (loc, NULL_TREE, type);
    3747           65 :       return size_zero_node;
    3748              :     }
    3749              : 
    3750              :   return t;
    3751              : }
    3752              : 
    3753              : /* Return the size of TYPE (in bytes) as a wide integer
    3754              :    or return -1 if the size can vary or is larger than an integer.  */
    3755              : 
    3756              : HOST_WIDE_INT
    3757    504970234 : int_size_in_bytes (const_tree type)
    3758              : {
    3759    504970234 :   tree t;
    3760              : 
    3761    504970234 :   if (type == error_mark_node)
    3762              :     return 0;
    3763              : 
    3764    504970234 :   type = TYPE_MAIN_VARIANT (type);
    3765    504970234 :   t = TYPE_SIZE_UNIT (type);
    3766              : 
    3767    504970234 :   if (t && tree_fits_uhwi_p (t))
    3768    504917149 :     return TREE_INT_CST_LOW (t);
    3769              :   else
    3770              :     return -1;
    3771              : }
    3772              : 
    3773              : /* Return the maximum size of TYPE (in bytes) as a wide integer
    3774              :    or return -1 if the size can vary or is larger than an integer.  */
    3775              : 
    3776              : HOST_WIDE_INT
    3777         9222 : max_int_size_in_bytes (const_tree type)
    3778              : {
    3779         9222 :   HOST_WIDE_INT size = -1;
    3780         9222 :   tree size_tree;
    3781              : 
    3782              :   /* If this is an array type, check for a possible MAX_SIZE attached.  */
    3783              : 
    3784         9222 :   if (TREE_CODE (type) == ARRAY_TYPE)
    3785              :     {
    3786         8489 :       size_tree = TYPE_ARRAY_MAX_SIZE (type);
    3787              : 
    3788         8489 :       if (size_tree && tree_fits_uhwi_p (size_tree))
    3789            0 :         size = tree_to_uhwi (size_tree);
    3790              :     }
    3791              : 
    3792              :   /* If we still haven't been able to get a size, see if the language
    3793              :      can compute a maximum size.  */
    3794              : 
    3795            0 :   if (size == -1)
    3796              :     {
    3797         9222 :       size_tree = lang_hooks.types.max_size (type);
    3798              : 
    3799         9222 :       if (size_tree && tree_fits_uhwi_p (size_tree))
    3800            0 :         size = tree_to_uhwi (size_tree);
    3801              :     }
    3802              : 
    3803         9222 :   return size;
    3804              : }
    3805              : 
    3806              : /* Return the bit position of FIELD, in bits from the start of the record.
    3807              :    This is a tree of type bitsizetype.  */
    3808              : 
    3809              : tree
    3810    130213391 : bit_position (const_tree field)
    3811              : {
    3812    130213391 :   return bit_from_pos (DECL_FIELD_OFFSET (field),
    3813    130213391 :                        DECL_FIELD_BIT_OFFSET (field));
    3814              : }
    3815              : 
    3816              : /* Return the byte position of FIELD, in bytes from the start of the record.
    3817              :    This is a tree of type sizetype.  */
    3818              : 
    3819              : tree
    3820    110165951 : byte_position (const_tree field)
    3821              : {
    3822    110165951 :   return byte_from_pos (DECL_FIELD_OFFSET (field),
    3823    110165951 :                         DECL_FIELD_BIT_OFFSET (field));
    3824              : }
    3825              : 
    3826              : /* Likewise, but return as an integer.  It must be representable in
    3827              :    that way (since it could be a signed value, we don't have the
    3828              :    option of returning -1 like int_size_in_byte can.  */
    3829              : 
    3830              : HOST_WIDE_INT
    3831     10036203 : int_byte_position (const_tree field)
    3832              : {
    3833     10036203 :   return tree_to_shwi (byte_position (field));
    3834              : }
    3835              : 
    3836              : /* Return, as a tree node, the number of elements for TYPE (which is an
    3837              :    ARRAY_TYPE) minus one.  This counts only elements of the top array.  */
    3838              : 
    3839              : tree
    3840    105858185 : array_type_nelts_minus_one (const_tree type)
    3841              : {
    3842    105858185 :   tree index_type, min, max;
    3843              : 
    3844              :   /* If they did it with unspecified bounds, then we should have already
    3845              :      given an error about it before we got here.  */
    3846    105858185 :   if (! TYPE_DOMAIN (type))
    3847      9775986 :     return error_mark_node;
    3848              : 
    3849     96082199 :   index_type = TYPE_DOMAIN (type);
    3850     96082199 :   min = TYPE_MIN_VALUE (index_type);
    3851     96082199 :   max = TYPE_MAX_VALUE (index_type);
    3852              : 
    3853              :   /* TYPE_MAX_VALUE may not be set if the array has unknown length.  */
    3854     96082199 :   if (!max)
    3855              :     {
    3856              :       /* zero sized arrays are represented from C FE as complete types with
    3857              :          NULL TYPE_MAX_VALUE and zero TYPE_SIZE, while C++ FE represents
    3858              :          them as min 0, max -1.  */
    3859      1274601 :       if (COMPLETE_TYPE_P (type)
    3860         3141 :           && integer_zerop (TYPE_SIZE (type))
    3861      1277742 :           && integer_zerop (min))
    3862         3141 :         return build_int_cst (TREE_TYPE (min), -1);
    3863              : 
    3864      1271460 :       return error_mark_node;
    3865              :     }
    3866              : 
    3867     94807598 :   return (integer_zerop (min)
    3868     94807598 :           ? max
    3869      1126637 :           : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));
    3870              : }
    3871              : 
    3872              : /* Return, as an INTEGER_CST node, the number of elements for TYPE
    3873              :    (which is an ARRAY_TYPE).  This counts only elements of the top
    3874              :    array.  */
    3875              : 
    3876              : tree
    3877     20355865 : array_type_nelts_top (tree type)
    3878              : {
    3879     20355865 :   return fold_build2_loc (input_location,
    3880              :                       PLUS_EXPR, sizetype,
    3881              :                       array_type_nelts_minus_one (type),
    3882     20355865 :                       size_one_node);
    3883              : }
    3884              : 
    3885              : /* If arg is static -- a reference to an object in static storage -- then
    3886              :    return the object.  This is not the same as the C meaning of `static'.
    3887              :    If arg isn't static, return NULL.  */
    3888              : 
    3889              : tree
    3890   1145309660 : staticp (tree arg)
    3891              : {
    3892   1146221527 :   switch (TREE_CODE (arg))
    3893              :     {
    3894              :     case FUNCTION_DECL:
    3895              :       /* Nested functions are static, even though taking their address will
    3896              :          involve a trampoline as we unnest the nested function and create
    3897              :          the trampoline on the tree level.  */
    3898              :       return arg;
    3899              : 
    3900    696152971 :     case VAR_DECL:
    3901    548175572 :       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
    3902    193206910 :               && ! DECL_THREAD_LOCAL_P (arg)
    3903    191345904 :               && ! DECL_DLLIMPORT_P (arg)
    3904    696152971 :               ? arg : NULL);
    3905              : 
    3906       701554 :     case CONST_DECL:
    3907           70 :       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
    3908       701554 :               ? arg : NULL);
    3909              : 
    3910            0 :     case CONSTRUCTOR:
    3911            0 :       return TREE_STATIC (arg) ? arg : NULL;
    3912              : 
    3913              :     case LABEL_DECL:
    3914              :     case STRING_CST:
    3915              :       return arg;
    3916              : 
    3917       663743 :     case COMPONENT_REF:
    3918              :       /* If the thing being referenced is not a field, then it is
    3919              :          something language specific.  */
    3920       663743 :       gcc_assert (TREE_CODE (TREE_OPERAND (arg, 1)) == FIELD_DECL);
    3921              : 
    3922              :       /* If we are referencing a bitfield, we can't evaluate an
    3923              :          ADDR_EXPR at compile time and so it isn't a constant.  */
    3924       663743 :       if (DECL_BIT_FIELD (TREE_OPERAND (arg, 1)))
    3925              :         return NULL;
    3926              : 
    3927       663743 :       return staticp (TREE_OPERAND (arg, 0));
    3928              : 
    3929              :     case BIT_FIELD_REF:
    3930              :       return NULL;
    3931              : 
    3932        32518 :     case INDIRECT_REF:
    3933        32518 :       return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL;
    3934              : 
    3935       248212 :     case ARRAY_REF:
    3936       248212 :     case ARRAY_RANGE_REF:
    3937       248212 :       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST
    3938       248212 :           && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
    3939       247868 :         return staticp (TREE_OPERAND (arg, 0));
    3940              :       else
    3941              :         return NULL;
    3942              : 
    3943          256 :     case REALPART_EXPR:
    3944          256 :     case IMAGPART_EXPR:
    3945          256 :       return staticp (TREE_OPERAND (arg, 0));
    3946              : 
    3947          934 :     case COMPOUND_LITERAL_EXPR:
    3948          934 :       return TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (arg)) ? arg : NULL;
    3949              : 
    3950              :     default:
    3951              :       return NULL;
    3952              :     }
    3953              : }
    3954              : 
    3955              : 
    3956              : 
    3957              : 
    3958              : /* Return whether OP is a DECL whose address is function-invariant.  */
    3959              : 
    3960              : bool
    3961   5087194534 : decl_address_invariant_p (const_tree op)
    3962              : {
    3963              :   /* The conditions below are slightly less strict than the one in
    3964              :      staticp.  */
    3965              : 
    3966   5087194534 :   switch (TREE_CODE (op))
    3967              :     {
    3968              :     case PARM_DECL:
    3969              :     case RESULT_DECL:
    3970              :     case LABEL_DECL:
    3971              :     case FUNCTION_DECL:
    3972              :       return true;
    3973              : 
    3974   2776186689 :     case VAR_DECL:
    3975   2088460277 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
    3976   1958809992 :           || DECL_THREAD_LOCAL_P (op)
    3977   1958809992 :           || DECL_CONTEXT (op) == current_function_decl
    3978   2783270272 :           || decl_function_context (op) == current_function_decl)
    3979   2769103106 :         return true;
    3980              :       break;
    3981              : 
    3982     25736828 :     case CONST_DECL:
    3983            0 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
    3984     25736828 :           || decl_function_context (op) == current_function_decl)
    3985     25736828 :         return true;
    3986              :       break;
    3987              : 
    3988              :     default:
    3989              :       break;
    3990              :     }
    3991              : 
    3992              :   return false;
    3993              : }
    3994              : 
    3995              : /* Return whether OP is a DECL whose address is interprocedural-invariant.  */
    3996              : 
    3997              : bool
    3998      1728607 : decl_address_ip_invariant_p (const_tree op)
    3999              : {
    4000              :   /* The conditions below are slightly less strict than the one in
    4001              :      staticp.  */
    4002              : 
    4003      1728607 :   symtab_node* node;
    4004      1728607 :   switch (TREE_CODE (op))
    4005              :     {
    4006              :     case LABEL_DECL:
    4007              :     case STRING_CST:
    4008              :       return true;
    4009              : 
    4010        90035 :     case FUNCTION_DECL:
    4011              :       /* Disable const propagation of symbols defined in assembly.  */
    4012        90035 :       node = symtab_node::get (op);
    4013        90035 :       return !node || !node->must_remain_in_tu_name;
    4014              : 
    4015      1540358 :     case VAR_DECL:
    4016      1540358 :       if (TREE_STATIC (op) || DECL_EXTERNAL (op))
    4017              :           {
    4018              :             /* Disable const propagation of symbols defined in assembly.  */
    4019       460832 :             node = symtab_node::get (op);
    4020       460832 :             if (node && node->must_remain_in_tu_name)
    4021              :               return false;
    4022              :           }
    4023      1115400 :       if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4024       460830 :            && !DECL_DLLIMPORT_P (op))
    4025      2619882 :           || DECL_THREAD_LOCAL_P (op))
    4026       460830 :         return true;
    4027              :       break;
    4028              : 
    4029        52920 :     case CONST_DECL:
    4030        52920 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op)))
    4031              :         return true;
    4032              :       break;
    4033              : 
    4034              :     default:
    4035              :       break;
    4036              :     }
    4037              : 
    4038              :   return false;
    4039              : }
    4040              : 
    4041              : /* Return true if T is an object with invariant address.  */
    4042              : 
    4043              : bool
    4044        39071 : address_invariant_p (tree t)
    4045              : {
    4046        46813 :   while (handled_component_p (t))
    4047              :     {
    4048         8735 :       switch (TREE_CODE (t))
    4049              :         {
    4050         1473 :         case ARRAY_REF:
    4051         1473 :         case ARRAY_RANGE_REF:
    4052         1473 :           if (!tree_invariant_p (TREE_OPERAND (t, 1))
    4053          480 :               || TREE_OPERAND (t, 2) != NULL_TREE
    4054         1953 :               || TREE_OPERAND (t, 3) != NULL_TREE)
    4055              :             return false;
    4056              :           break;
    4057              : 
    4058         7103 :         case COMPONENT_REF:
    4059         7103 :           if (TREE_OPERAND (t, 2) != NULL_TREE)
    4060              :             return false;
    4061              :           break;
    4062              : 
    4063              :         default:
    4064              :           break;
    4065              :         }
    4066         7742 :       t = TREE_OPERAND (t, 0);
    4067              :     }
    4068              : 
    4069        38078 :   STRIP_ANY_LOCATION_WRAPPER (t);
    4070        38078 :   return CONSTANT_CLASS_P (t) || decl_address_invariant_p (t);
    4071              : }
    4072              : 
    4073              : 
    4074              : /* Return true if T is function-invariant (internal function, does
    4075              :    not handle arithmetic; that's handled in skip_simple_arithmetic and
    4076              :    tree_invariant_p).  */
    4077              : 
    4078              : static bool
    4079     15640824 : tree_invariant_p_1 (tree t)
    4080              : {
    4081     15640824 :   if (TREE_CONSTANT (t) || (TREE_READONLY (t) && !TREE_SIDE_EFFECTS (t)))
    4082              :     return true;
    4083              : 
    4084     13130535 :   switch (TREE_CODE (t))
    4085              :     {
    4086              :     case SAVE_EXPR:
    4087              :     case TARGET_EXPR:
    4088              :       return true;
    4089              : 
    4090        39019 :     case ADDR_EXPR:
    4091        39019 :       return address_invariant_p (TREE_OPERAND (t, 0));
    4092              : 
    4093              :     default:
    4094              :       break;
    4095              :     }
    4096              : 
    4097              :   return false;
    4098              : }
    4099              : 
    4100              : /* Return true if T is function-invariant.  */
    4101              : 
    4102              : bool
    4103     12358307 : tree_invariant_p (tree t)
    4104              : {
    4105     12358307 :   tree inner = skip_simple_arithmetic (t);
    4106     12358307 :   return tree_invariant_p_1 (inner);
    4107              : }
    4108              : 
    4109              : /* Wrap a SAVE_EXPR around EXPR, if appropriate.
    4110              :    Do this to any expression which may be used in more than one place,
    4111              :    but must be evaluated only once.
    4112              : 
    4113              :    Normally, expand_expr would reevaluate the expression each time.
    4114              :    Calling save_expr produces something that is evaluated and recorded
    4115              :    the first time expand_expr is called on it.  Subsequent calls to
    4116              :    expand_expr just reuse the recorded value.
    4117              : 
    4118              :    The call to expand_expr that generates code that actually computes
    4119              :    the value is the first call *at compile time*.  Subsequent calls
    4120              :    *at compile time* generate code to use the saved value.
    4121              :    This produces correct result provided that *at run time* control
    4122              :    always flows through the insns made by the first expand_expr
    4123              :    before reaching the other places where the save_expr was evaluated.
    4124              :    You, the caller of save_expr, must make sure this is so.
    4125              : 
    4126              :    Constants, and certain read-only nodes, are returned with no
    4127              :    SAVE_EXPR because that is safe.  Expressions containing placeholders
    4128              :    are not touched; see tree.def for an explanation of what these
    4129              :    are used for.  */
    4130              : 
    4131              : tree
    4132      3282528 : save_expr (tree expr)
    4133              : {
    4134      3282528 :   tree inner;
    4135              : 
    4136              :   /* If the tree evaluates to a constant, then we don't want to hide that
    4137              :      fact (i.e. this allows further folding, and direct checks for constants).
    4138              :      However, a read-only object that has side effects cannot be bypassed.
    4139              :      Since it is no problem to reevaluate literals, we just return the
    4140              :      literal node.  */
    4141      3282528 :   inner = skip_simple_arithmetic (expr);
    4142      3282528 :   if (TREE_CODE (inner) == ERROR_MARK)
    4143              :     return inner;
    4144              : 
    4145      3282517 :   if (tree_invariant_p_1 (inner))
    4146              :     return expr;
    4147              : 
    4148              :   /* If INNER contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
    4149              :      it means that the size or offset of some field of an object depends on
    4150              :      the value within another field.
    4151              : 
    4152              :      Note that it must not be the case that EXPR contains both a PLACEHOLDER_EXPR
    4153              :      and some variable since it would then need to be both evaluated once and
    4154              :      evaluated more than once.  Front-ends must assure this case cannot
    4155              :      happen by surrounding any such subexpressions in their own SAVE_EXPR
    4156              :      and forcing evaluation at the proper time.  */
    4157      2284393 :   if (contains_placeholder_p (inner))
    4158              :     return expr;
    4159              : 
    4160      2284393 :   expr = build1_loc (EXPR_LOCATION (expr), SAVE_EXPR, TREE_TYPE (expr), expr);
    4161              : 
    4162              :   /* This expression might be placed ahead of a jump to ensure that the
    4163              :      value was computed on both sides of the jump.  So make sure it isn't
    4164              :      eliminated as dead.  */
    4165      2284393 :   TREE_SIDE_EFFECTS (expr) = 1;
    4166      2284393 :   return expr;
    4167              : }
    4168              : 
    4169              : /* Look inside EXPR into any simple arithmetic operations.  Return the
    4170              :    outermost non-arithmetic or non-invariant node.  */
    4171              : 
    4172              : tree
    4173     15640835 : skip_simple_arithmetic (tree expr)
    4174              : {
    4175              :   /* We don't care about whether this can be used as an lvalue in this
    4176              :      context.  */
    4177     15656654 :   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
    4178        15819 :     expr = TREE_OPERAND (expr, 0);
    4179              : 
    4180              :   /* If we have simple operations applied to a SAVE_EXPR or to a SAVE_EXPR and
    4181              :      a constant, it will be more efficient to not make another SAVE_EXPR since
    4182              :      it will allow better simplification and GCSE will be able to merge the
    4183              :      computations if they actually occur.  */
    4184     39973005 :   while (true)
    4185              :     {
    4186     39973005 :       if (UNARY_CLASS_P (expr))
    4187     15170309 :         expr = TREE_OPERAND (expr, 0);
    4188     24802696 :       else if (BINARY_CLASS_P (expr))
    4189              :         {
    4190              :           /* Before commutative binary operands are canonicalized,
    4191              :              it is quite common to have constants in the first operand.
    4192              :              Check for that common case first so that we don't walk
    4193              :              large expressions with tree_invariant_p unnecessarily.
    4194              :              This can still have terrible compile time complexity,
    4195              :              we should limit the depth of the tree_invariant_p and
    4196              :              skip_simple_arithmetic recursion.  */
    4197      9209167 :           if ((TREE_CONSTANT (TREE_OPERAND (expr, 0))
    4198      9198919 :                || (TREE_READONLY (TREE_OPERAND (expr, 0))
    4199        10043 :                    && !TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0))))
    4200      9219174 :               && tree_invariant_p (TREE_OPERAND (expr, 0)))
    4201        20255 :             expr = TREE_OPERAND (expr, 1);
    4202      9188912 :           else if (tree_invariant_p (TREE_OPERAND (expr, 1)))
    4203      9132054 :             expr = TREE_OPERAND (expr, 0);
    4204        56858 :           else if (tree_invariant_p (TREE_OPERAND (expr, 0)))
    4205         9552 :             expr = TREE_OPERAND (expr, 1);
    4206              :           else
    4207              :             break;
    4208              :         }
    4209              :       else
    4210              :         break;
    4211              :     }
    4212              : 
    4213     15640835 :   return expr;
    4214              : }
    4215              : 
    4216              : /* Look inside EXPR into simple arithmetic operations involving constants.
    4217              :    Return the outermost non-arithmetic or non-constant node.  */
    4218              : 
    4219              : tree
    4220            0 : skip_simple_constant_arithmetic (tree expr)
    4221              : {
    4222            0 :   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
    4223            0 :     expr = TREE_OPERAND (expr, 0);
    4224              : 
    4225            0 :   while (true)
    4226              :     {
    4227            0 :       if (UNARY_CLASS_P (expr))
    4228            0 :         expr = TREE_OPERAND (expr, 0);
    4229            0 :       else if (BINARY_CLASS_P (expr))
    4230              :         {
    4231            0 :           if (TREE_CONSTANT (TREE_OPERAND (expr, 1)))
    4232            0 :             expr = TREE_OPERAND (expr, 0);
    4233            0 :           else if (TREE_CONSTANT (TREE_OPERAND (expr, 0)))
    4234            0 :             expr = TREE_OPERAND (expr, 1);
    4235              :           else
    4236              :             break;
    4237              :         }
    4238              :       else
    4239              :         break;
    4240              :     }
    4241              : 
    4242            0 :   return expr;
    4243              : }
    4244              : 
    4245              : /* Return which tree structure is used by T.  */
    4246              : 
    4247              : enum tree_node_structure_enum
    4248  42270770098 : tree_node_structure (const_tree t)
    4249              : {
    4250  42270770098 :   const enum tree_code code = TREE_CODE (t);
    4251  42270770098 :   return tree_node_structure_for_code (code);
    4252              : }
    4253              : 
    4254              : /* Set various status flags when building a CALL_EXPR object T.  */
    4255              : 
    4256              : static void
    4257    275244166 : process_call_operands (tree t)
    4258              : {
    4259    275244166 :   bool side_effects = TREE_SIDE_EFFECTS (t);
    4260    275244166 :   bool read_only = false;
    4261    275244166 :   int i = call_expr_flags (t);
    4262              : 
    4263              :   /* Calls have side-effects, except those to const or pure functions.  */
    4264    275244166 :   if ((i & ECF_LOOPING_CONST_OR_PURE) || !(i & (ECF_CONST | ECF_PURE)))
    4265              :     side_effects = true;
    4266              :   /* Propagate TREE_READONLY of arguments for const functions.  */
    4267     58757707 :   if (i & ECF_CONST)
    4268     57185875 :     read_only = true;
    4269              : 
    4270    275244166 :   if (!side_effects || read_only)
    4271    295223718 :     for (i = 1; i < TREE_OPERAND_LENGTH (t); i++)
    4272              :       {
    4273    236466515 :         tree op = TREE_OPERAND (t, i);
    4274    236466515 :         if (op && TREE_SIDE_EFFECTS (op))
    4275              :           side_effects = true;
    4276    236466515 :         if (op && !TREE_READONLY (op) && !CONSTANT_CLASS_P (op))
    4277              :           read_only = false;
    4278              :       }
    4279              : 
    4280    275244166 :   TREE_SIDE_EFFECTS (t) = side_effects;
    4281    275244166 :   TREE_READONLY (t) = read_only;
    4282    275244166 : }
    4283              : 
    4284              : /* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a
    4285              :    size or offset that depends on a field within a record.  */
    4286              : 
    4287              : bool
    4288     38423970 : contains_placeholder_p (const_tree exp)
    4289              : {
    4290     38423970 :   enum tree_code code;
    4291              : 
    4292     38423970 :   if (!exp)
    4293              :     return false;
    4294              : 
    4295     38423970 :   code = TREE_CODE (exp);
    4296     38423970 :   if (code == PLACEHOLDER_EXPR)
    4297              :     return true;
    4298              : 
    4299     38423970 :   switch (TREE_CODE_CLASS (code))
    4300              :     {
    4301      1076467 :     case tcc_reference:
    4302              :       /* Don't look at any PLACEHOLDER_EXPRs that might be in index or bit
    4303              :          position computations since they will be converted into a
    4304              :          WITH_RECORD_EXPR involving the reference, which will assume
    4305              :          here will be valid.  */
    4306      1076467 :       return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
    4307              : 
    4308       558732 :     case tcc_exceptional:
    4309       558732 :       if (code == TREE_LIST)
    4310            0 :         return (CONTAINS_PLACEHOLDER_P (TREE_VALUE (exp))
    4311            0 :                 || CONTAINS_PLACEHOLDER_P (TREE_CHAIN (exp)));
    4312              :       break;
    4313              : 
    4314     33576748 :     case tcc_unary:
    4315     33576748 :     case tcc_binary:
    4316     33576748 :     case tcc_comparison:
    4317     33576748 :     case tcc_expression:
    4318     33576748 :       switch (code)
    4319              :         {
    4320         7297 :         case COMPOUND_EXPR:
    4321              :           /* Ignoring the first operand isn't quite right, but works best.  */
    4322         7297 :           return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1));
    4323              : 
    4324         4530 :         case COND_EXPR:
    4325         9060 :           return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
    4326         4530 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1))
    4327         9060 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 2)));
    4328              : 
    4329              :         case SAVE_EXPR:
    4330              :           /* The save_expr function never wraps anything containing
    4331              :              a PLACEHOLDER_EXPR. */
    4332              :           return false;
    4333              : 
    4334     24437091 :         default:
    4335     24437091 :           break;
    4336              :         }
    4337              : 
    4338     24437091 :       switch (TREE_CODE_LENGTH (code))
    4339              :         {
    4340     14877132 :         case 1:
    4341     14877132 :           return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
    4342      9466067 :         case 2:
    4343     18930595 :           return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
    4344     18930595 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1)));
    4345              :         default:
    4346              :           return false;
    4347              :         }
    4348              : 
    4349       766263 :     case tcc_vl_exp:
    4350       766263 :       switch (code)
    4351              :         {
    4352       766263 :         case CALL_EXPR:
    4353       766263 :           {
    4354       766263 :             const_tree arg;
    4355       766263 :             const_call_expr_arg_iterator iter;
    4356      2670742 :             FOR_EACH_CONST_CALL_EXPR_ARG (arg, iter, exp)
    4357      1138216 :               if (CONTAINS_PLACEHOLDER_P (arg))
    4358              :                 return true;
    4359              :             return false;
    4360              :           }
    4361              :         default:
    4362              :           return false;
    4363              :         }
    4364              : 
    4365              :     default:
    4366              :       return false;
    4367              :     }
    4368              :   return false;
    4369              : }
    4370              : 
    4371              : /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR
    4372              :    directly.  This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and
    4373              :    field positions.  */
    4374              : 
    4375              : static bool
    4376       769080 : type_contains_placeholder_1 (const_tree type)
    4377              : {
    4378              :   /* If the size contains a placeholder or the parent type (component type in
    4379              :      the case of arrays) type involves a placeholder, this type does.  */
    4380      1517105 :   if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type))
    4381       769080 :       || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type))
    4382      1538160 :       || (!POINTER_TYPE_P (type)
    4383       637182 :           && TREE_TYPE (type)
    4384       108228 :           && type_contains_placeholder_p (TREE_TYPE (type))))
    4385            0 :     return true;
    4386              : 
    4387              :   /* Now do type-specific checks.  Note that the last part of the check above
    4388              :      greatly limits what we have to do below.  */
    4389       769080 :   switch (TREE_CODE (type))
    4390              :     {
    4391              :     case VOID_TYPE:
    4392              :     case OPAQUE_TYPE:
    4393              :     case COMPLEX_TYPE:
    4394              :     case ENUMERAL_TYPE:
    4395              :     case BOOLEAN_TYPE:
    4396              :     case POINTER_TYPE:
    4397              :     case OFFSET_TYPE:
    4398              :     case REFERENCE_TYPE:
    4399              :     case METHOD_TYPE:
    4400              :     case FUNCTION_TYPE:
    4401              :     case VECTOR_TYPE:
    4402              :     case NULLPTR_TYPE:
    4403              :       return false;
    4404              : 
    4405       171149 :     case INTEGER_TYPE:
    4406       171149 :     case BITINT_TYPE:
    4407       171149 :     case REAL_TYPE:
    4408       171149 :     case FIXED_POINT_TYPE:
    4409              :       /* Here we just check the bounds.  */
    4410       332747 :       return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type))
    4411       332747 :               || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type)));
    4412              : 
    4413        56599 :     case ARRAY_TYPE:
    4414              :       /* We have already checked the component type above, so just check
    4415              :          the domain type.  Flexible array members have a null domain.  */
    4416       113186 :       return TYPE_DOMAIN (type) ?
    4417        56587 :         type_contains_placeholder_p (TYPE_DOMAIN (type)) : false;
    4418              : 
    4419       386287 :     case RECORD_TYPE:
    4420       386287 :     case UNION_TYPE:
    4421       386287 :     case QUAL_UNION_TYPE:
    4422       386287 :       {
    4423       386287 :         tree field;
    4424              : 
    4425     11007799 :         for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    4426     10621512 :           if (TREE_CODE (field) == FIELD_DECL
    4427     10621512 :               && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field))
    4428       905428 :                   || (TREE_CODE (type) == QUAL_UNION_TYPE
    4429            0 :                       && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field)))
    4430       905428 :                   || type_contains_placeholder_p (TREE_TYPE (field))))
    4431            0 :             return true;
    4432              : 
    4433              :         return false;
    4434              :       }
    4435              : 
    4436            0 :     default:
    4437            0 :       gcc_unreachable ();
    4438              :     }
    4439              : }
    4440              : 
    4441              : /* Wrapper around above function used to cache its result.  */
    4442              : 
    4443              : bool
    4444      2905385 : type_contains_placeholder_p (tree type)
    4445              : {
    4446      2905385 :   bool result;
    4447              : 
    4448              :   /* If the contains_placeholder_bits field has been initialized,
    4449              :      then we know the answer.  */
    4450      2905385 :   if (TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) > 0)
    4451      2136305 :     return TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) - 1;
    4452              : 
    4453              :   /* Indicate that we've seen this type node, and the answer is false.
    4454              :      This is what we want to return if we run into recursion via fields.  */
    4455       769080 :   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = 1;
    4456              : 
    4457              :   /* Compute the real value.  */
    4458       769080 :   result = type_contains_placeholder_1 (type);
    4459              : 
    4460              :   /* Store the real value.  */
    4461       769080 :   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = result + 1;
    4462              : 
    4463       769080 :   return result;
    4464              : }
    4465              : 
    4466              : /* Push tree EXP onto vector QUEUE if it is not already present.  */
    4467              : 
    4468              : static void
    4469            0 : push_without_duplicates (tree exp, vec<tree> *queue)
    4470              : {
    4471            0 :   unsigned int i;
    4472            0 :   tree iter;
    4473              : 
    4474            0 :   FOR_EACH_VEC_ELT (*queue, i, iter)
    4475            0 :     if (simple_cst_equal (iter, exp) == 1)
    4476              :       break;
    4477              : 
    4478            0 :   if (!iter)
    4479            0 :     queue->safe_push (exp);
    4480            0 : }
    4481              : 
    4482              : /* Given a tree EXP, find all occurrences of references to fields
    4483              :    in a PLACEHOLDER_EXPR and place them in vector REFS without
    4484              :    duplicates.  Also record VAR_DECLs and CONST_DECLs.  Note that
    4485              :    we assume here that EXP contains only arithmetic expressions
    4486              :    or CALL_EXPRs with PLACEHOLDER_EXPRs occurring only in their
    4487              :    argument list.  */
    4488              : 
    4489              : void
    4490            0 : find_placeholder_in_expr (tree exp, vec<tree> *refs)
    4491              : {
    4492            0 :   enum tree_code code = TREE_CODE (exp);
    4493            0 :   tree inner;
    4494            0 :   int i;
    4495              : 
    4496              :   /* We handle TREE_LIST and COMPONENT_REF separately.  */
    4497            0 :   if (code == TREE_LIST)
    4498              :     {
    4499            0 :       FIND_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), refs);
    4500            0 :       FIND_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), refs);
    4501              :     }
    4502            0 :   else if (code == COMPONENT_REF)
    4503              :     {
    4504            0 :       for (inner = TREE_OPERAND (exp, 0);
    4505            0 :            REFERENCE_CLASS_P (inner);
    4506            0 :            inner = TREE_OPERAND (inner, 0))
    4507              :         ;
    4508              : 
    4509            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR)
    4510            0 :         push_without_duplicates (exp, refs);
    4511              :       else
    4512            0 :         FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), refs);
    4513              :    }
    4514              :   else
    4515            0 :     switch (TREE_CODE_CLASS (code))
    4516              :       {
    4517              :       case tcc_constant:
    4518              :         break;
    4519              : 
    4520            0 :       case tcc_declaration:
    4521              :         /* Variables allocated to static storage can stay.  */
    4522            0 :         if (!TREE_STATIC (exp))
    4523            0 :           push_without_duplicates (exp, refs);
    4524              :         break;
    4525              : 
    4526            0 :       case tcc_expression:
    4527              :         /* This is the pattern built in ada/make_aligning_type.  */
    4528            0 :         if (code == ADDR_EXPR
    4529            0 :             && TREE_CODE (TREE_OPERAND (exp, 0)) == PLACEHOLDER_EXPR)
    4530              :           {
    4531            0 :             push_without_duplicates (exp, refs);
    4532            0 :             break;
    4533              :           }
    4534              : 
    4535              :         /* Fall through.  */
    4536              : 
    4537              :       case tcc_exceptional:
    4538              :       case tcc_unary:
    4539              :       case tcc_binary:
    4540              :       case tcc_comparison:
    4541              :       case tcc_reference:
    4542            0 :         for (i = 0; i < TREE_CODE_LENGTH (code); i++)
    4543            0 :           FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, i), refs);
    4544              :         break;
    4545              : 
    4546              :       case tcc_vl_exp:
    4547            0 :         for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4548            0 :           FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, i), refs);
    4549              :         break;
    4550              : 
    4551            0 :       default:
    4552            0 :         gcc_unreachable ();
    4553              :       }
    4554            0 : }
    4555              : 
    4556              : /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
    4557              :    return a tree with all occurrences of references to F in a
    4558              :    PLACEHOLDER_EXPR replaced by R.  Also handle VAR_DECLs and
    4559              :    CONST_DECLs.  Note that we assume here that EXP contains only
    4560              :    arithmetic expressions or CALL_EXPRs with PLACEHOLDER_EXPRs
    4561              :    occurring only in their argument list.  */
    4562              : 
    4563              : tree
    4564            0 : substitute_in_expr (tree exp, tree f, tree r)
    4565              : {
    4566            0 :   enum tree_code code = TREE_CODE (exp);
    4567            0 :   tree op0, op1, op2, op3;
    4568            0 :   tree new_tree;
    4569              : 
    4570              :   /* We handle TREE_LIST and COMPONENT_REF separately.  */
    4571            0 :   if (code == TREE_LIST)
    4572              :     {
    4573            0 :       op0 = SUBSTITUTE_IN_EXPR (TREE_CHAIN (exp), f, r);
    4574            0 :       op1 = SUBSTITUTE_IN_EXPR (TREE_VALUE (exp), f, r);
    4575            0 :       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
    4576              :         return exp;
    4577              : 
    4578            0 :       return tree_cons (TREE_PURPOSE (exp), op1, op0);
    4579              :     }
    4580            0 :   else if (code == COMPONENT_REF)
    4581              :     {
    4582            0 :       tree inner;
    4583              : 
    4584              :       /* If this expression is getting a value from a PLACEHOLDER_EXPR
    4585              :          and it is the right field, replace it with R.  */
    4586            0 :       for (inner = TREE_OPERAND (exp, 0);
    4587            0 :            REFERENCE_CLASS_P (inner);
    4588            0 :            inner = TREE_OPERAND (inner, 0))
    4589              :         ;
    4590              : 
    4591              :       /* The field.  */
    4592            0 :       op1 = TREE_OPERAND (exp, 1);
    4593              : 
    4594            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR && op1 == f)
    4595              :         return r;
    4596              : 
    4597              :       /* If this expression hasn't been completed let, leave it alone.  */
    4598            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR && !TREE_TYPE (inner))
    4599              :         return exp;
    4600              : 
    4601            0 :       op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4602            0 :       if (op0 == TREE_OPERAND (exp, 0))
    4603              :         return exp;
    4604              : 
    4605            0 :       new_tree
    4606            0 :         = fold_build3 (COMPONENT_REF, TREE_TYPE (exp), op0, op1, NULL_TREE);
    4607              :    }
    4608              :   else
    4609            0 :     switch (TREE_CODE_CLASS (code))
    4610              :       {
    4611              :       case tcc_constant:
    4612              :         return exp;
    4613              : 
    4614            0 :       case tcc_declaration:
    4615            0 :         if (exp == f)
    4616              :           return r;
    4617              :         else
    4618              :           return exp;
    4619              : 
    4620            0 :       case tcc_expression:
    4621            0 :         if (exp == f)
    4622              :           return r;
    4623              : 
    4624              :         /* Fall through.  */
    4625              : 
    4626            0 :       case tcc_exceptional:
    4627            0 :       case tcc_unary:
    4628            0 :       case tcc_binary:
    4629            0 :       case tcc_comparison:
    4630            0 :       case tcc_reference:
    4631            0 :         switch (TREE_CODE_LENGTH (code))
    4632              :           {
    4633              :           case 0:
    4634              :             return exp;
    4635              : 
    4636            0 :           case 1:
    4637            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4638            0 :             if (op0 == TREE_OPERAND (exp, 0))
    4639              :               return exp;
    4640              : 
    4641            0 :             new_tree = fold_build1 (code, TREE_TYPE (exp), op0);
    4642            0 :             break;
    4643              : 
    4644            0 :           case 2:
    4645            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4646            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4647              : 
    4648            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
    4649              :               return exp;
    4650              : 
    4651            0 :             new_tree = fold_build2 (code, TREE_TYPE (exp), op0, op1);
    4652            0 :             break;
    4653              : 
    4654            0 :           case 3:
    4655            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4656            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4657            0 :             op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
    4658              : 
    4659            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4660            0 :                 && op2 == TREE_OPERAND (exp, 2))
    4661              :               return exp;
    4662              : 
    4663            0 :             new_tree = fold_build3 (code, TREE_TYPE (exp), op0, op1, op2);
    4664            0 :             break;
    4665              : 
    4666            0 :           case 4:
    4667            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4668            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4669            0 :             op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
    4670            0 :             op3 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 3), f, r);
    4671              : 
    4672            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4673            0 :                 && op2 == TREE_OPERAND (exp, 2)
    4674            0 :                 && op3 == TREE_OPERAND (exp, 3))
    4675              :               return exp;
    4676              : 
    4677            0 :             new_tree
    4678            0 :               = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
    4679            0 :             break;
    4680              : 
    4681            0 :           default:
    4682            0 :             gcc_unreachable ();
    4683              :           }
    4684              :         break;
    4685              : 
    4686            0 :       case tcc_vl_exp:
    4687            0 :         {
    4688            0 :           int i;
    4689              : 
    4690            0 :           new_tree = NULL_TREE;
    4691              : 
    4692              :           /* If we are trying to replace F with a constant or with another
    4693              :              instance of one of the arguments of the call, inline back
    4694              :              functions which do nothing else than computing a value from
    4695              :              the arguments they are passed.  This makes it possible to
    4696              :              fold partially or entirely the replacement expression.  */
    4697            0 :           if (code == CALL_EXPR)
    4698              :             {
    4699            0 :               bool maybe_inline = false;
    4700            0 :               if (CONSTANT_CLASS_P (r))
    4701              :                 maybe_inline = true;
    4702              :               else
    4703            0 :                 for (i = 3; i < TREE_OPERAND_LENGTH (exp); i++)
    4704            0 :                   if (operand_equal_p (TREE_OPERAND (exp, i), r, 0))
    4705              :                     {
    4706              :                       maybe_inline = true;
    4707              :                       break;
    4708              :                     }
    4709            0 :               if (maybe_inline)
    4710              :                 {
    4711            0 :                   tree t = maybe_inline_call_in_expr (exp);
    4712            0 :                   if (t)
    4713            0 :                     return SUBSTITUTE_IN_EXPR (t, f, r);
    4714              :                 }
    4715              :             }
    4716              : 
    4717            0 :           for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4718              :             {
    4719            0 :               tree op = TREE_OPERAND (exp, i);
    4720            0 :               tree new_op = SUBSTITUTE_IN_EXPR (op, f, r);
    4721            0 :               if (new_op != op)
    4722              :                 {
    4723            0 :                   if (!new_tree)
    4724            0 :                     new_tree = copy_node (exp);
    4725            0 :                   TREE_OPERAND (new_tree, i) = new_op;
    4726              :                 }
    4727              :             }
    4728              : 
    4729            0 :           if (new_tree)
    4730              :             {
    4731            0 :               new_tree = fold (new_tree);
    4732            0 :               if (TREE_CODE (new_tree) == CALL_EXPR)
    4733            0 :                 process_call_operands (new_tree);
    4734              :             }
    4735              :           else
    4736              :             return exp;
    4737              :         }
    4738              :         break;
    4739              : 
    4740            0 :       default:
    4741            0 :         gcc_unreachable ();
    4742              :       }
    4743              : 
    4744            0 :   TREE_READONLY (new_tree) |= TREE_READONLY (exp);
    4745              : 
    4746            0 :   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
    4747            0 :     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
    4748              : 
    4749              :   return new_tree;
    4750              : }
    4751              : 
    4752              : /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement
    4753              :    for it within OBJ, a tree that is an object or a chain of references.  */
    4754              : 
    4755              : tree
    4756       243523 : substitute_placeholder_in_expr (tree exp, tree obj)
    4757              : {
    4758       243523 :   enum tree_code code = TREE_CODE (exp);
    4759       243523 :   tree op0, op1, op2, op3;
    4760       243523 :   tree new_tree;
    4761              : 
    4762              :   /* If this is a PLACEHOLDER_EXPR, see if we find a corresponding type
    4763              :      in the chain of OBJ.  */
    4764       243523 :   if (code == PLACEHOLDER_EXPR)
    4765              :     {
    4766            0 :       tree need_type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
    4767            0 :       tree elt;
    4768              : 
    4769            0 :       for (elt = obj; elt != 0;
    4770            0 :            elt = ((TREE_CODE (elt) == COMPOUND_EXPR
    4771            0 :                    || TREE_CODE (elt) == COND_EXPR)
    4772            0 :                   ? TREE_OPERAND (elt, 1)
    4773            0 :                   : (REFERENCE_CLASS_P (elt)
    4774              :                      || UNARY_CLASS_P (elt)
    4775              :                      || BINARY_CLASS_P (elt)
    4776              :                      || VL_EXP_CLASS_P (elt)
    4777              :                      || EXPRESSION_CLASS_P (elt))
    4778            0 :                   ? TREE_OPERAND (elt, 0) : 0))
    4779            0 :         if (TYPE_MAIN_VARIANT (TREE_TYPE (elt)) == need_type)
    4780              :           return elt;
    4781              : 
    4782            0 :       for (elt = obj; elt != 0;
    4783            0 :            elt = ((TREE_CODE (elt) == COMPOUND_EXPR
    4784            0 :                    || TREE_CODE (elt) == COND_EXPR)
    4785            0 :                   ? TREE_OPERAND (elt, 1)
    4786            0 :                   : (REFERENCE_CLASS_P (elt)
    4787              :                      || UNARY_CLASS_P (elt)
    4788              :                      || BINARY_CLASS_P (elt)
    4789              :                      || VL_EXP_CLASS_P (elt)
    4790              :                      || EXPRESSION_CLASS_P (elt))
    4791            0 :                   ? TREE_OPERAND (elt, 0) : 0))
    4792            0 :         if (POINTER_TYPE_P (TREE_TYPE (elt))
    4793            0 :             && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (elt)))
    4794              :                 == need_type))
    4795            0 :           return fold_build1 (INDIRECT_REF, need_type, elt);
    4796              : 
    4797              :       /* If we didn't find it, return the original PLACEHOLDER_EXPR.  If it
    4798              :          survives until RTL generation, there will be an error.  */
    4799              :       return exp;
    4800              :     }
    4801              : 
    4802              :   /* TREE_LIST is special because we need to look at TREE_VALUE
    4803              :      and TREE_CHAIN, not TREE_OPERANDS.  */
    4804       243523 :   else if (code == TREE_LIST)
    4805              :     {
    4806            0 :       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), obj);
    4807            0 :       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), obj);
    4808            0 :       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
    4809              :         return exp;
    4810              : 
    4811            0 :       return tree_cons (TREE_PURPOSE (exp), op1, op0);
    4812              :     }
    4813              :   else
    4814       243523 :     switch (TREE_CODE_CLASS (code))
    4815              :       {
    4816              :       case tcc_constant:
    4817              :       case tcc_declaration:
    4818              :         return exp;
    4819              : 
    4820         9742 :       case tcc_exceptional:
    4821         9742 :       case tcc_unary:
    4822         9742 :       case tcc_binary:
    4823         9742 :       case tcc_comparison:
    4824         9742 :       case tcc_expression:
    4825         9742 :       case tcc_reference:
    4826         9742 :       case tcc_statement:
    4827         9742 :         switch (TREE_CODE_LENGTH (code))
    4828              :           {
    4829              :           case 0:
    4830              :             return exp;
    4831              : 
    4832         7419 :           case 1:
    4833         7419 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4834         7419 :             if (op0 == TREE_OPERAND (exp, 0))
    4835              :               return exp;
    4836              : 
    4837            0 :             new_tree = fold_build1 (code, TREE_TYPE (exp), op0);
    4838            0 :             break;
    4839              : 
    4840         2311 :           case 2:
    4841         2311 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4842         2311 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4843              : 
    4844         2311 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
    4845              :               return exp;
    4846              : 
    4847            0 :             new_tree = fold_build2 (code, TREE_TYPE (exp), op0, op1);
    4848            0 :             break;
    4849              : 
    4850           12 :           case 3:
    4851           12 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4852           12 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4853           12 :             op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
    4854              : 
    4855           24 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4856           24 :                 && op2 == TREE_OPERAND (exp, 2))
    4857              :               return exp;
    4858              : 
    4859            0 :             new_tree = fold_build3 (code, TREE_TYPE (exp), op0, op1, op2);
    4860            0 :             break;
    4861              : 
    4862            0 :           case 4:
    4863            0 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4864            0 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4865            0 :             op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
    4866            0 :             op3 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 3), obj);
    4867              : 
    4868            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4869            0 :                 && op2 == TREE_OPERAND (exp, 2)
    4870            0 :                 && op3 == TREE_OPERAND (exp, 3))
    4871              :               return exp;
    4872              : 
    4873            0 :             new_tree
    4874            0 :               = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
    4875            0 :             break;
    4876              : 
    4877            0 :           default:
    4878            0 :             gcc_unreachable ();
    4879              :           }
    4880              :         break;
    4881              : 
    4882              :       case tcc_vl_exp:
    4883              :         {
    4884              :           int i;
    4885              : 
    4886              :           new_tree = NULL_TREE;
    4887              : 
    4888            0 :           for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4889              :             {
    4890            0 :               tree op = TREE_OPERAND (exp, i);
    4891            0 :               tree new_op = SUBSTITUTE_PLACEHOLDER_IN_EXPR (op, obj);
    4892            0 :               if (new_op != op)
    4893              :                 {
    4894            0 :                   if (!new_tree)
    4895            0 :                     new_tree = copy_node (exp);
    4896            0 :                   TREE_OPERAND (new_tree, i) = new_op;
    4897              :                 }
    4898              :             }
    4899              : 
    4900            0 :           if (new_tree)
    4901              :             {
    4902            0 :               new_tree = fold (new_tree);
    4903            0 :               if (TREE_CODE (new_tree) == CALL_EXPR)
    4904            0 :                 process_call_operands (new_tree);
    4905              :             }
    4906              :           else
    4907              :             return exp;
    4908              :         }
    4909              :         break;
    4910              : 
    4911            0 :       default:
    4912            0 :         gcc_unreachable ();
    4913              :       }
    4914              : 
    4915            0 :   TREE_READONLY (new_tree) |= TREE_READONLY (exp);
    4916              : 
    4917            0 :   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
    4918            0 :     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
    4919              : 
    4920              :   return new_tree;
    4921              : }
    4922              : 
    4923              : 
    4924              : /* Subroutine of stabilize_reference; this is called for subtrees of
    4925              :    references.  Any expression with side-effects must be put in a SAVE_EXPR
    4926              :    to ensure that it is only evaluated once.
    4927              : 
    4928              :    We don't put SAVE_EXPR nodes around everything, because assigning very
    4929              :    simple expressions to temporaries causes us to miss good opportunities
    4930              :    for optimizations.  Among other things, the opportunity to fold in the
    4931              :    addition of a constant into an addressing mode often gets lost, e.g.
    4932              :    "y[i+1] += x;".  In general, we take the approach that we should not make
    4933              :    an assignment unless we are forced into it - i.e., that any non-side effect
    4934              :    operator should be allowed, and that cse should take care of coalescing
    4935              :    multiple utterances of the same expression should that prove fruitful.  */
    4936              : 
    4937              : static tree
    4938       855059 : stabilize_reference_1 (tree e)
    4939              : {
    4940       855059 :   tree result;
    4941       855059 :   enum tree_code code = TREE_CODE (e);
    4942              : 
    4943              :   /* We cannot ignore const expressions because it might be a reference
    4944              :      to a const array but whose index contains side-effects.  But we can
    4945              :      ignore things that are actual constant or that already have been
    4946              :      handled by this function.  */
    4947              : 
    4948       855059 :   if (tree_invariant_p (e))
    4949              :     return e;
    4950              : 
    4951       130301 :   switch (TREE_CODE_CLASS (code))
    4952              :     {
    4953            0 :     case tcc_exceptional:
    4954              :       /* Always wrap STATEMENT_LIST into SAVE_EXPR, even if it doesn't
    4955              :          have side-effects.  */
    4956            0 :       if (code == STATEMENT_LIST)
    4957            0 :         return save_expr (e);
    4958              :       /* FALLTHRU */
    4959       100734 :     case tcc_type:
    4960       100734 :     case tcc_declaration:
    4961       100734 :     case tcc_comparison:
    4962       100734 :     case tcc_statement:
    4963       100734 :     case tcc_expression:
    4964       100734 :     case tcc_reference:
    4965       100734 :     case tcc_vl_exp:
    4966              :       /* If the expression has side-effects, then encase it in a SAVE_EXPR
    4967              :          so that it will only be evaluated once.  */
    4968              :       /* The reference (r) and comparison (<) classes could be handled as
    4969              :          below, but it is generally faster to only evaluate them once.  */
    4970       100734 :       if (TREE_SIDE_EFFECTS (e))
    4971         1002 :         return save_expr (e);
    4972              :       return e;
    4973              : 
    4974              :     case tcc_constant:
    4975              :       /* Constants need no processing.  In fact, we should never reach
    4976              :          here.  */
    4977              :       return e;
    4978              : 
    4979        21883 :     case tcc_binary:
    4980              :       /* Division is slow and tends to be compiled with jumps,
    4981              :          especially the division by powers of 2 that is often
    4982              :          found inside of an array reference.  So do it just once.  */
    4983        21883 :       if (code == TRUNC_DIV_EXPR || code == TRUNC_MOD_EXPR
    4984        19843 :           || code == FLOOR_DIV_EXPR || code == FLOOR_MOD_EXPR
    4985        19843 :           || code == CEIL_DIV_EXPR || code == CEIL_MOD_EXPR
    4986        19843 :           || code == ROUND_DIV_EXPR || code == ROUND_MOD_EXPR)
    4987         2040 :         return save_expr (e);
    4988              :       /* Recursively stabilize each operand.  */
    4989        19843 :       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)),
    4990        19843 :                          stabilize_reference_1 (TREE_OPERAND (e, 1)));
    4991        19843 :       break;
    4992              : 
    4993         7684 :     case tcc_unary:
    4994              :       /* Recursively stabilize each operand.  */
    4995         7684 :       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)));
    4996         7684 :       break;
    4997              : 
    4998            0 :     default:
    4999            0 :       gcc_unreachable ();
    5000              :     }
    5001              : 
    5002        27527 :   TREE_TYPE (result) = TREE_TYPE (e);
    5003        27527 :   TREE_READONLY (result) = TREE_READONLY (e);
    5004        27527 :   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
    5005        27527 :   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
    5006              : 
    5007        27527 :   return result;
    5008              : }
    5009              : 
    5010              : /* Stabilize a reference so that we can use it any number of times
    5011              :    without causing its operands to be evaluated more than once.
    5012              :    Returns the stabilized reference.  This works by means of save_expr,
    5013              :    so see the caveats in the comments about save_expr.
    5014              : 
    5015              :    Also allows conversion expressions whose operands are references.
    5016              :    Any other kind of expression is returned unchanged.  */
    5017              : 
    5018              : tree
    5019      4636522 : stabilize_reference (tree ref)
    5020              : {
    5021      4636522 :   tree result;
    5022      4636522 :   enum tree_code code = TREE_CODE (ref);
    5023              : 
    5024      4636522 :   switch (code)
    5025              :     {
    5026              :     case VAR_DECL:
    5027              :     case PARM_DECL:
    5028              :     case RESULT_DECL:
    5029              :       /* No action is needed in this case.  */
    5030              :       return ref;
    5031              : 
    5032            0 :     CASE_CONVERT:
    5033            0 :     case FLOAT_EXPR:
    5034            0 :     case FIX_TRUNC_EXPR:
    5035            0 :       result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
    5036            0 :       break;
    5037              : 
    5038       760785 :     case INDIRECT_REF:
    5039       760785 :       result = build_nt (INDIRECT_REF,
    5040       760785 :                          stabilize_reference_1 (TREE_OPERAND (ref, 0)));
    5041       760785 :       break;
    5042              : 
    5043       446451 :     case COMPONENT_REF:
    5044       446451 :       result = build_nt (COMPONENT_REF,
    5045       446451 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5046       446451 :                          TREE_OPERAND (ref, 1), NULL_TREE);
    5047       446451 :       break;
    5048              : 
    5049            0 :     case BIT_FIELD_REF:
    5050            0 :       result = build_nt (BIT_FIELD_REF,
    5051            0 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5052            0 :                          TREE_OPERAND (ref, 1), TREE_OPERAND (ref, 2));
    5053            0 :       REF_REVERSE_STORAGE_ORDER (result) = REF_REVERSE_STORAGE_ORDER (ref);
    5054            0 :       break;
    5055              : 
    5056        46904 :     case ARRAY_REF:
    5057        93808 :       result = build_nt (ARRAY_REF,
    5058        46904 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5059        46904 :                          stabilize_reference_1 (TREE_OPERAND (ref, 1)),
    5060        46904 :                          TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
    5061        46904 :       break;
    5062              : 
    5063            0 :     case ARRAY_RANGE_REF:
    5064            0 :       result = build_nt (ARRAY_RANGE_REF,
    5065            0 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5066            0 :                          stabilize_reference_1 (TREE_OPERAND (ref, 1)),
    5067            0 :                          TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
    5068            0 :       break;
    5069              : 
    5070            0 :     case COMPOUND_EXPR:
    5071              :       /* We cannot wrap the first expression in a SAVE_EXPR, as then
    5072              :          it wouldn't be ignored.  This matters when dealing with
    5073              :          volatiles.  */
    5074            0 :       return stabilize_reference_1 (ref);
    5075              : 
    5076              :       /* If arg isn't a kind of lvalue we recognize, make no change.
    5077              :          Caller should recognize the error for an invalid lvalue.  */
    5078              :     default:
    5079              :       return ref;
    5080              : 
    5081            0 :     case ERROR_MARK:
    5082            0 :       return error_mark_node;
    5083              :     }
    5084              : 
    5085      1254140 :   TREE_TYPE (result) = TREE_TYPE (ref);
    5086      1254140 :   TREE_READONLY (result) = TREE_READONLY (ref);
    5087      1254140 :   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
    5088      1254140 :   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
    5089      1254140 :   protected_set_expr_location (result, EXPR_LOCATION (ref));
    5090              : 
    5091      1254140 :   return result;
    5092              : }
    5093              : 
    5094              : /* Low-level constructors for expressions.  */
    5095              : 
    5096              : /* A helper function for build1 and constant folders.  Set TREE_CONSTANT,
    5097              :    and TREE_SIDE_EFFECTS for an ADDR_EXPR.  */
    5098              : 
    5099              : void
    5100   1354819061 : recompute_tree_invariant_for_addr_expr (tree t)
    5101              : {
    5102   1354819061 :   tree node;
    5103   1354819061 :   bool tc = true, se = false;
    5104              : 
    5105   1354819061 :   gcc_assert (TREE_CODE (t) == ADDR_EXPR);
    5106              : 
    5107              :   /* We started out assuming this address is both invariant and constant, but
    5108              :      does not have side effects.  Now go down any handled components and see if
    5109              :      any of them involve offsets that are either non-constant or non-invariant.
    5110              :      Also check for side-effects.
    5111              : 
    5112              :      ??? Note that this code makes no attempt to deal with the case where
    5113              :      taking the address of something causes a copy due to misalignment.  */
    5114              : 
    5115              : #define UPDATE_FLAGS(NODE)  \
    5116              : do { tree _node = (NODE); \
    5117              :      if (_node && !TREE_CONSTANT (_node)) tc = false; \
    5118              :      if (_node && TREE_SIDE_EFFECTS (_node)) se = true; } while (0)
    5119              : 
    5120   1579390465 :   for (node = TREE_OPERAND (t, 0); handled_component_p (node);
    5121    224571404 :        node = TREE_OPERAND (node, 0))
    5122              :     {
    5123              :       /* If the first operand doesn't have an ARRAY_TYPE, this is a bogus
    5124              :          array reference (probably made temporarily by the G++ front end),
    5125              :          so ignore all the operands.  */
    5126    224571404 :       if ((TREE_CODE (node) == ARRAY_REF
    5127    224571404 :            || TREE_CODE (node) == ARRAY_RANGE_REF)
    5128    224571404 :           && TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) == ARRAY_TYPE)
    5129              :         {
    5130     33305077 :           UPDATE_FLAGS (TREE_OPERAND (node, 1));
    5131     33305077 :           if (TREE_OPERAND (node, 2))
    5132      2301175 :             UPDATE_FLAGS (TREE_OPERAND (node, 2));
    5133     33305077 :           if (TREE_OPERAND (node, 3))
    5134       274236 :             UPDATE_FLAGS (TREE_OPERAND (node, 3));
    5135              :         }
    5136              :       /* Likewise, just because this is a COMPONENT_REF doesn't mean we have a
    5137              :          FIELD_DECL, apparently.  The G++ front end can put something else
    5138              :          there, at least temporarily.  */
    5139    191266327 :       else if (TREE_CODE (node) == COMPONENT_REF
    5140    191266327 :                && TREE_CODE (TREE_OPERAND (node, 1)) == FIELD_DECL)
    5141              :         {
    5142    190123007 :           if (TREE_OPERAND (node, 2))
    5143        17035 :             UPDATE_FLAGS (TREE_OPERAND (node, 2));
    5144              :         }
    5145              :     }
    5146              : 
    5147   1354819061 :   node = lang_hooks.expr_to_decl (node, &tc, &se);
    5148              : 
    5149              :   /* Now see what's inside.  If it's an INDIRECT_REF, copy our properties from
    5150              :      the address, since &(*a)->b is a form of addition.  If it's a constant, the
    5151              :      address is constant too.  If it's a decl, its address is constant if the
    5152              :      decl is static.  Everything else is not constant and, furthermore,
    5153              :      taking the address of a volatile variable is not volatile.  */
    5154   1354819061 :   if (INDIRECT_REF_P (node)
    5155   1317395326 :       || TREE_CODE (node) == MEM_REF)
    5156    155535562 :     UPDATE_FLAGS (TREE_OPERAND (node, 0));
    5157   1199283499 :   else if (CONSTANT_CLASS_P (node))
    5158              :     ;
    5159   1121471558 :   else if (DECL_P (node))
    5160   1098447027 :     tc &= (staticp (node) != NULL_TREE);
    5161              :   else
    5162              :     {
    5163     23024531 :       tc = false;
    5164     23024531 :       se |= TREE_SIDE_EFFECTS (node);
    5165              :     }
    5166              : 
    5167              : 
    5168   1354819061 :   TREE_CONSTANT (t) = tc;
    5169   1354819061 :   TREE_SIDE_EFFECTS (t) = se;
    5170              : #undef UPDATE_FLAGS
    5171   1354819061 : }
    5172              : 
    5173              : /* Build an expression of code CODE, data type TYPE, and operands as
    5174              :    specified.  Expressions and reference nodes can be created this way.
    5175              :    Constants, decls, types and misc nodes cannot be.
    5176              : 
    5177              :    We define 5 non-variadic functions, from 0 to 4 arguments.  This is
    5178              :    enough for all extant tree codes.  */
    5179              : 
    5180              : tree
    5181    381937550 : build0 (enum tree_code code, tree tt MEM_STAT_DECL)
    5182              : {
    5183    381937550 :   tree t;
    5184              : 
    5185    381937550 :   gcc_assert (TREE_CODE_LENGTH (code) == 0);
    5186              : 
    5187    381937550 :   t = make_node (code PASS_MEM_STAT);
    5188    381937550 :   TREE_TYPE (t) = tt;
    5189              : 
    5190    381937550 :   return t;
    5191              : }
    5192              : 
    5193              : tree
    5194   3850990745 : build1 (enum tree_code code, tree type, tree node MEM_STAT_DECL)
    5195              : {
    5196   3850990745 :   int length = sizeof (struct tree_exp);
    5197   3850990745 :   tree t;
    5198              : 
    5199   3850990745 :   record_node_allocation_statistics (code, length);
    5200              : 
    5201   3850990745 :   gcc_assert (TREE_CODE_LENGTH (code) == 1);
    5202              : 
    5203   3850990745 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    5204              : 
    5205   3850990745 :   memset (t, 0, sizeof (struct tree_common));
    5206              : 
    5207   3850990745 :   TREE_SET_CODE (t, code);
    5208              : 
    5209   3850990745 :   TREE_TYPE (t) = type;
    5210   3850990745 :   SET_EXPR_LOCATION (t, UNKNOWN_LOCATION);
    5211   3850990745 :   TREE_OPERAND (t, 0) = node;
    5212   3850990745 :   if (node && !TYPE_P (node))
    5213              :     {
    5214   3850928906 :       TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
    5215   3850928906 :       TREE_READONLY (t) = TREE_READONLY (node);
    5216              :     }
    5217              : 
    5218   3850990745 :   if (TREE_CODE_CLASS (code) == tcc_statement)
    5219              :     {
    5220     23488147 :       if (code != DEBUG_BEGIN_STMT)
    5221     23488147 :         TREE_SIDE_EFFECTS (t) = 1;
    5222              :     }
    5223   3827502598 :   else switch (code)
    5224              :     {
    5225        51136 :     case VA_ARG_EXPR:
    5226              :       /* All of these have side-effects, no matter what their
    5227              :          operands are.  */
    5228        51136 :       TREE_SIDE_EFFECTS (t) = 1;
    5229        51136 :       TREE_READONLY (t) = 0;
    5230        51136 :       break;
    5231              : 
    5232    606731874 :     case INDIRECT_REF:
    5233              :       /* Whether a dereference is readonly has nothing to do with whether
    5234              :          its operand is readonly.  */
    5235    606731874 :       TREE_READONLY (t) = 0;
    5236    606731874 :       break;
    5237              : 
    5238    629824339 :     case ADDR_EXPR:
    5239    629824339 :       if (node)
    5240    629824339 :         recompute_tree_invariant_for_addr_expr (t);
    5241              :       break;
    5242              : 
    5243   2590895249 :     default:
    5244    973644076 :       if ((TREE_CODE_CLASS (code) == tcc_unary || code == VIEW_CONVERT_EXPR)
    5245   2450552765 :           && node && !TYPE_P (node)
    5246   5041448014 :           && TREE_CONSTANT (node))
    5247    682798924 :         TREE_CONSTANT (t) = 1;
    5248   2590895249 :       if (TREE_CODE_CLASS (code) == tcc_reference
    5249    835847975 :           && node && TREE_THIS_VOLATILE (node))
    5250      2904102 :         TREE_THIS_VOLATILE (t) = 1;
    5251              :       break;
    5252              :     }
    5253              : 
    5254   3850990745 :   return t;
    5255              : }
    5256              : 
    5257              : #define PROCESS_ARG(N)                          \
    5258              :   do {                                          \
    5259              :     TREE_OPERAND (t, N) = arg##N;               \
    5260              :     if (arg##N &&!TYPE_P (arg##N))              \
    5261              :       {                                         \
    5262              :         if (TREE_SIDE_EFFECTS (arg##N))         \
    5263              :           side_effects = 1;                     \
    5264              :         if (!TREE_READONLY (arg##N)             \
    5265              :             && !CONSTANT_CLASS_P (arg##N))      \
    5266              :           (void) (read_only = 0);               \
    5267              :         if (!TREE_CONSTANT (arg##N))            \
    5268              :           (void) (constant = 0);                \
    5269              :       }                                         \
    5270              :   } while (0)
    5271              : 
    5272              : tree
    5273   1254104770 : build2 (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
    5274              : {
    5275   1254104770 :   bool constant, read_only, side_effects, div_by_zero;
    5276   1254104770 :   tree t;
    5277              : 
    5278   1254104770 :   gcc_assert (TREE_CODE_LENGTH (code) == 2);
    5279              : 
    5280   1254104770 :   if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
    5281    190777999 :       && arg0 && arg1 && tt && POINTER_TYPE_P (tt)
    5282              :       /* When sizetype precision doesn't match that of pointers
    5283              :          we need to be able to build explicit extensions or truncations
    5284              :          of the offset argument.  */
    5285   1254104770 :       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (tt))
    5286            0 :     gcc_assert (TREE_CODE (arg0) == INTEGER_CST
    5287              :                 && TREE_CODE (arg1) == INTEGER_CST);
    5288              : 
    5289   1254104770 :   if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
    5290     57983477 :     gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))
    5291              :                 && ptrofftype_p (TREE_TYPE (arg1)));
    5292              : 
    5293   1254104770 :   t = make_node (code PASS_MEM_STAT);
    5294   1254104770 :   TREE_TYPE (t) = tt;
    5295              : 
    5296              :   /* Below, we automatically set TREE_SIDE_EFFECTS and TREE_READONLY for the
    5297              :      result based on those same flags for the arguments.  But if the
    5298              :      arguments aren't really even `tree' expressions, we shouldn't be trying
    5299              :      to do this.  */
    5300              : 
    5301              :   /* Expressions without side effects may be constant if their
    5302              :      arguments are as well.  */
    5303   2508209540 :   constant = (TREE_CODE_CLASS (code) == tcc_comparison
    5304   1254104770 :               || TREE_CODE_CLASS (code) == tcc_binary);
    5305   1254104770 :   read_only = 1;
    5306   1254104770 :   side_effects = TREE_SIDE_EFFECTS (t);
    5307              : 
    5308   1254104770 :   switch (code)
    5309              :     {
    5310     14103608 :     case TRUNC_DIV_EXPR:
    5311     14103608 :     case CEIL_DIV_EXPR:
    5312     14103608 :     case FLOOR_DIV_EXPR:
    5313     14103608 :     case ROUND_DIV_EXPR:
    5314     14103608 :     case EXACT_DIV_EXPR:
    5315     14103608 :     case CEIL_MOD_EXPR:
    5316     14103608 :     case FLOOR_MOD_EXPR:
    5317     14103608 :     case ROUND_MOD_EXPR:
    5318     14103608 :     case TRUNC_MOD_EXPR:
    5319     14103608 :       div_by_zero = integer_zerop (arg1);
    5320     14103608 :       break;
    5321              :     default:
    5322              :       div_by_zero = false;
    5323              :     }
    5324              : 
    5325   1387992994 :   PROCESS_ARG (0);
    5326   1768823319 :   PROCESS_ARG (1);
    5327              : 
    5328   1254104770 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5329   1254104770 :   if (code == MEM_REF)
    5330              :     {
    5331     77801217 :       if (arg0 && TREE_CODE (arg0) == ADDR_EXPR)
    5332              :         {
    5333     21575381 :           tree o = TREE_OPERAND (arg0, 0);
    5334     21575381 :           TREE_READONLY (t) = TREE_READONLY (o);
    5335     21575381 :           TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o);
    5336              :         }
    5337              :     }
    5338              :   else
    5339              :     {
    5340   1176303553 :       TREE_READONLY (t) = read_only;
    5341              :       /* Don't mark X / 0 as constant.  */
    5342   1176303553 :       TREE_CONSTANT (t) = constant && !div_by_zero;
    5343   1176303553 :       TREE_THIS_VOLATILE (t)
    5344   1176303553 :         = (TREE_CODE_CLASS (code) == tcc_reference
    5345   1176303553 :            && arg0 && TREE_THIS_VOLATILE (arg0));
    5346              :     }
    5347              : 
    5348   1254104770 :   return t;
    5349              : }
    5350              : 
    5351              : 
    5352              : tree
    5353    455261712 : build3 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5354              :         tree arg2 MEM_STAT_DECL)
    5355              : {
    5356    455261712 :   bool constant, read_only, side_effects;
    5357    455261712 :   tree t;
    5358              : 
    5359    455261712 :   gcc_assert (TREE_CODE_LENGTH (code) == 3);
    5360    455261712 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    5361              : 
    5362    455261712 :   t = make_node (code PASS_MEM_STAT);
    5363    455261712 :   TREE_TYPE (t) = tt;
    5364              : 
    5365    455261712 :   read_only = 1;
    5366              : 
    5367              :   /* As a special exception, if COND_EXPR has NULL branches, we
    5368              :      assume that it is a gimple statement and always consider
    5369              :      it to have side effects.  */
    5370    455261712 :   if (code == COND_EXPR
    5371     38764248 :       && tt == void_type_node
    5372     24229345 :       && arg1 == NULL_TREE
    5373     24229345 :       && arg2 == NULL_TREE)
    5374              :     side_effects = true;
    5375              :   else
    5376    455261712 :     side_effects = TREE_SIDE_EFFECTS (t);
    5377              : 
    5378    498206649 :   PROCESS_ARG (0);
    5379    468725992 :   PROCESS_ARG (1);
    5380    468791126 :   PROCESS_ARG (2);
    5381              : 
    5382    455261712 :   if (code == COND_EXPR)
    5383     38764248 :     TREE_READONLY (t) = read_only;
    5384              : 
    5385    455261712 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5386    455261712 :   TREE_THIS_VOLATILE (t)
    5387    455261712 :     = (TREE_CODE_CLASS (code) == tcc_reference
    5388    455261712 :        && arg0 && TREE_THIS_VOLATILE (arg0));
    5389              : 
    5390    455261712 :   return t;
    5391              : }
    5392              : 
    5393              : tree
    5394     54100447 : build4 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5395              :         tree arg2, tree arg3 MEM_STAT_DECL)
    5396              : {
    5397     54100447 :   bool constant, read_only, side_effects;
    5398     54100447 :   tree t;
    5399              : 
    5400     54100447 :   gcc_assert (TREE_CODE_LENGTH (code) == 4);
    5401              : 
    5402     54100447 :   t = make_node (code PASS_MEM_STAT);
    5403     54100447 :   TREE_TYPE (t) = tt;
    5404              : 
    5405     54100447 :   side_effects = TREE_SIDE_EFFECTS (t);
    5406              : 
    5407     54100447 :   PROCESS_ARG (0);
    5408     54100447 :   PROCESS_ARG (1);
    5409     54100447 :   PROCESS_ARG (2);
    5410     54100447 :   PROCESS_ARG (3);
    5411              : 
    5412     54100447 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5413     54100447 :   TREE_THIS_VOLATILE (t)
    5414    108200894 :     = (TREE_CODE_CLASS (code) == tcc_reference
    5415     54100447 :        && arg0 && TREE_THIS_VOLATILE (arg0));
    5416              : 
    5417     54100447 :   return t;
    5418              : }
    5419              : 
    5420              : tree
    5421      1169423 : build5 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5422              :         tree arg2, tree arg3, tree arg4 MEM_STAT_DECL)
    5423              : {
    5424      1169423 :   bool constant, read_only, side_effects;
    5425      1169423 :   tree t;
    5426              : 
    5427      1169423 :   gcc_assert (TREE_CODE_LENGTH (code) == 5);
    5428              : 
    5429      1169423 :   t = make_node (code PASS_MEM_STAT);
    5430      1169423 :   TREE_TYPE (t) = tt;
    5431              : 
    5432      1169423 :   side_effects = TREE_SIDE_EFFECTS (t);
    5433              : 
    5434      1169423 :   PROCESS_ARG (0);
    5435      1169423 :   PROCESS_ARG (1);
    5436      1169423 :   PROCESS_ARG (2);
    5437      1169423 :   PROCESS_ARG (3);
    5438      1169423 :   PROCESS_ARG (4);
    5439              : 
    5440      1169423 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5441      1169423 :   if (code == TARGET_MEM_REF)
    5442              :     {
    5443      1160870 :       if (arg0 && TREE_CODE (arg0) == ADDR_EXPR)
    5444              :         {
    5445       196974 :           tree o = TREE_OPERAND (arg0, 0);
    5446       196974 :           TREE_READONLY (t) = TREE_READONLY (o);
    5447       196974 :           TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o);
    5448              :         }
    5449              :     }
    5450              :   else
    5451         8553 :     TREE_THIS_VOLATILE (t)
    5452         8553 :       = (TREE_CODE_CLASS (code) == tcc_reference
    5453         8553 :          && arg0 && TREE_THIS_VOLATILE (arg0));
    5454              : 
    5455      1169423 :   return t;
    5456              : }
    5457              : 
    5458              : /* Build a simple MEM_REF tree with the semantics of a plain INDIRECT_REF
    5459              :    on the pointer PTR.  */
    5460              : 
    5461              : tree
    5462       478933 : build_simple_mem_ref_loc (location_t loc, tree ptr)
    5463              : {
    5464       478933 :   poly_int64 offset = 0;
    5465       478933 :   tree ptype = TREE_TYPE (ptr);
    5466       478933 :   tree tem;
    5467              :   /* For convenience allow addresses that collapse to a simple base
    5468              :      and offset.  */
    5469       478933 :   if (TREE_CODE (ptr) == ADDR_EXPR
    5470       478933 :       && (handled_component_p (TREE_OPERAND (ptr, 0))
    5471        15611 :           || TREE_CODE (TREE_OPERAND (ptr, 0)) == MEM_REF))
    5472              :     {
    5473          147 :       ptr = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &offset);
    5474          147 :       gcc_assert (ptr);
    5475          147 :       if (TREE_CODE (ptr) == MEM_REF)
    5476              :         {
    5477           37 :           offset += mem_ref_offset (ptr).force_shwi ();
    5478           37 :           ptr = TREE_OPERAND (ptr, 0);
    5479              :         }
    5480              :       else
    5481          110 :         ptr = build_fold_addr_expr (ptr);
    5482          147 :       gcc_assert (is_gimple_reg (ptr) || is_gimple_min_invariant (ptr));
    5483              :     }
    5484       478933 :   tem = build2 (MEM_REF, TREE_TYPE (ptype),
    5485              :                 ptr, build_int_cst (ptype, offset));
    5486       478933 :   SET_EXPR_LOCATION (tem, loc);
    5487       478933 :   return tem;
    5488              : }
    5489              : 
    5490              : /* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T.  */
    5491              : 
    5492              : poly_offset_int
    5493   1202308323 : mem_ref_offset (const_tree t)
    5494              : {
    5495   1202308323 :   return poly_offset_int::from (wi::to_poly_wide (TREE_OPERAND (t, 1)),
    5496   1202308323 :                                 SIGNED);
    5497              : }
    5498              : 
    5499              : /* Return an invariant ADDR_EXPR of type TYPE taking the address of BASE
    5500              :    offsetted by OFFSET units.  */
    5501              : 
    5502              : tree
    5503       195160 : build_invariant_address (tree type, tree base, poly_int64 offset)
    5504              : {
    5505       195160 :   tree ref = fold_build2 (MEM_REF, TREE_TYPE (type),
    5506              :                           build_fold_addr_expr (base),
    5507              :                           build_int_cst (ptr_type_node, offset));
    5508       195160 :   tree addr = build1 (ADDR_EXPR, type, ref);
    5509       195160 :   recompute_tree_invariant_for_addr_expr (addr);
    5510       195160 :   return addr;
    5511              : }
    5512              : 
    5513              : /* Similar except don't specify the TREE_TYPE
    5514              :    and leave the TREE_SIDE_EFFECTS as 0.
    5515              :    It is permissible for arguments to be null,
    5516              :    or even garbage if their values do not matter.  */
    5517              : 
    5518              : tree
    5519      5506910 : build_nt (enum tree_code code, ...)
    5520              : {
    5521      5506910 :   tree t;
    5522      5506910 :   int length;
    5523      5506910 :   int i;
    5524      5506910 :   va_list p;
    5525              : 
    5526      5506910 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    5527              : 
    5528      5506910 :   va_start (p, code);
    5529              : 
    5530      5506910 :   t = make_node (code);
    5531      5506910 :   length = TREE_CODE_LENGTH (code);
    5532              : 
    5533     14872516 :   for (i = 0; i < length; i++)
    5534      9365606 :     TREE_OPERAND (t, i) = va_arg (p, tree);
    5535              : 
    5536      5506910 :   va_end (p);
    5537      5506910 :   return t;
    5538              : }
    5539              : 
    5540              : /* Similar to build_nt, but for creating a CALL_EXPR object with a
    5541              :    tree vec.  */
    5542              : 
    5543              : tree
    5544            0 : build_nt_call_vec (tree fn, vec<tree, va_gc> *args)
    5545              : {
    5546            0 :   tree ret, t;
    5547            0 :   unsigned int ix;
    5548              : 
    5549            0 :   ret = build_vl_exp (CALL_EXPR, vec_safe_length (args) + 3);
    5550            0 :   CALL_EXPR_FN (ret) = fn;
    5551            0 :   CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE;
    5552            0 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
    5553            0 :     CALL_EXPR_ARG (ret, ix) = t;
    5554            0 :   return ret;
    5555              : }
    5556              : 
    5557              : /* Create a DECL_... node of code CODE, name NAME  (if non-null)
    5558              :    and data type TYPE.
    5559              :    We do NOT enter this node in any sort of symbol table.
    5560              : 
    5561              :    LOC is the location of the decl.
    5562              : 
    5563              :    layout_decl is used to set up the decl's storage layout.
    5564              :    Other slots are initialized to 0 or null pointers.  */
    5565              : 
    5566              : tree
    5567   3180699883 : build_decl (location_t loc, enum tree_code code, tree name,
    5568              :                  tree type MEM_STAT_DECL)
    5569              : {
    5570   3180699883 :   tree t;
    5571              : 
    5572   3180699883 :   t = make_node (code PASS_MEM_STAT);
    5573   3180699883 :   DECL_SOURCE_LOCATION (t) = loc;
    5574              : 
    5575              : /*  if (type == error_mark_node)
    5576              :     type = integer_type_node; */
    5577              : /* That is not done, deliberately, so that having error_mark_node
    5578              :    as the type can suppress useless errors in the use of this variable.  */
    5579              : 
    5580   3180699883 :   DECL_NAME (t) = name;
    5581   3180699883 :   TREE_TYPE (t) = type;
    5582              : 
    5583   3180699883 :   if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
    5584   1117208373 :     layout_decl (t, 0);
    5585              : 
    5586   3180699883 :   return t;
    5587              : }
    5588              : 
    5589              : /* Create and return a DEBUG_EXPR_DECL node of the given TYPE.  */
    5590              : 
    5591              : tree
    5592      1628807 : build_debug_expr_decl (tree type)
    5593              : {
    5594      1628807 :   tree vexpr = make_node (DEBUG_EXPR_DECL);
    5595      1628807 :   DECL_ARTIFICIAL (vexpr) = 1;
    5596      1628807 :   TREE_TYPE (vexpr) = type;
    5597      1628807 :   SET_DECL_MODE (vexpr, TYPE_MODE (type));
    5598      1628807 :   return vexpr;
    5599              : }
    5600              : 
    5601              : /* Builds and returns function declaration with NAME and TYPE.  */
    5602              : 
    5603              : tree
    5604        21317 : build_fn_decl (const char *name, tree type)
    5605              : {
    5606        21317 :   tree id = get_identifier (name);
    5607        21317 :   tree decl = build_decl (input_location, FUNCTION_DECL, id, type);
    5608              : 
    5609        21317 :   DECL_EXTERNAL (decl) = 1;
    5610        21317 :   TREE_PUBLIC (decl) = 1;
    5611        21317 :   DECL_ARTIFICIAL (decl) = 1;
    5612        21317 :   TREE_NOTHROW (decl) = 1;
    5613              : 
    5614        21317 :   return decl;
    5615              : }
    5616              : 
    5617              : vec<tree, va_gc> *all_translation_units;
    5618              : 
    5619              : /* Builds a new translation-unit decl with name NAME, queues it in the
    5620              :    global list of translation-unit decls and returns it.   */
    5621              : 
    5622              : tree
    5623       259057 : build_translation_unit_decl (tree name)
    5624              : {
    5625       259057 :   tree tu = build_decl (UNKNOWN_LOCATION, TRANSLATION_UNIT_DECL,
    5626       259057 :                         name, NULL_TREE);
    5627       259057 :   TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.name;
    5628       259057 :   vec_safe_push (all_translation_units, tu);
    5629       259057 :   return tu;
    5630              : }
    5631              : 
    5632              : 
    5633              : /* BLOCK nodes are used to represent the structure of binding contours
    5634              :    and declarations, once those contours have been exited and their contents
    5635              :    compiled.  This information is used for outputting debugging info.  */
    5636              : 
    5637              : tree
    5638       725366 : build_block (tree vars, tree subblocks, tree supercontext, tree chain)
    5639              : {
    5640       725366 :   tree block = make_node (BLOCK);
    5641              : 
    5642       725366 :   BLOCK_VARS (block) = vars;
    5643       725366 :   BLOCK_SUBBLOCKS (block) = subblocks;
    5644       725366 :   BLOCK_SUPERCONTEXT (block) = supercontext;
    5645       725366 :   BLOCK_CHAIN (block) = chain;
    5646       725366 :   return block;
    5647              : }
    5648              : 
    5649              : 
    5650              : /* Like SET_EXPR_LOCATION, but make sure the tree can have a location.
    5651              : 
    5652              :    LOC is the location to use in tree T.  */
    5653              : 
    5654              : void
    5655  14259009549 : protected_set_expr_location (tree t, location_t loc)
    5656              : {
    5657  14259009549 :   if (CAN_HAVE_LOCATION_P (t))
    5658   2263235252 :     SET_EXPR_LOCATION (t, loc);
    5659  11911230440 :   else if (t && TREE_CODE (t) == STATEMENT_LIST)
    5660              :     {
    5661        22243 :       t = expr_single (t);
    5662        22243 :       if (t && CAN_HAVE_LOCATION_P (t))
    5663           18 :         SET_EXPR_LOCATION (t, loc);
    5664              :     }
    5665  14259009549 : }
    5666              : 
    5667              : /* Like PROTECTED_SET_EXPR_LOCATION, but only do that if T has
    5668              :    UNKNOWN_LOCATION.  */
    5669              : 
    5670              : void
    5671     24522323 : protected_set_expr_location_if_unset (tree t, location_t loc)
    5672              : {
    5673     24522323 :   t = expr_single (t);
    5674     24522323 :   if (t && !EXPR_HAS_LOCATION (t))
    5675     17552034 :     protected_set_expr_location (t, loc);
    5676     24522323 : }
    5677              : 
    5678              : /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
    5679              :    of the various TYPE_QUAL values.  */
    5680              : 
    5681              : static void
    5682    108624177 : set_type_quals (tree type, int type_quals)
    5683              : {
    5684    108624177 :   TYPE_READONLY (type) = (type_quals & TYPE_QUAL_CONST) != 0;
    5685    108624177 :   TYPE_VOLATILE (type) = (type_quals & TYPE_QUAL_VOLATILE) != 0;
    5686    108624177 :   TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0;
    5687    108624177 :   TYPE_ATOMIC (type) = (type_quals & TYPE_QUAL_ATOMIC) != 0;
    5688    108624177 :   TYPE_ADDR_SPACE (type) = DECODE_QUAL_ADDR_SPACE (type_quals);
    5689    108624177 : }
    5690              : 
    5691              : /* Returns true iff CAND and BASE have equivalent language-specific
    5692              :    qualifiers.  */
    5693              : 
    5694              : bool
    5695   3036477091 : check_lang_type (const_tree cand, const_tree base)
    5696              : {
    5697   3036477091 :   if (lang_hooks.types.type_hash_eq == NULL)
    5698              :     return true;
    5699              :   /* type_hash_eq currently only applies to these types.  */
    5700   2980199200 :   if (TREE_CODE (cand) != FUNCTION_TYPE
    5701   2980199200 :       && TREE_CODE (cand) != METHOD_TYPE)
    5702              :     return true;
    5703      1005361 :   return lang_hooks.types.type_hash_eq (cand, base);
    5704              : }
    5705              : 
    5706              : /* This function checks to see if TYPE matches the size one of the built-in
    5707              :    atomic types, and returns that core atomic type.  */
    5708              : 
    5709              : static tree
    5710         8880 : find_atomic_core_type (const_tree type)
    5711              : {
    5712         8880 :   tree base_atomic_type;
    5713              : 
    5714              :   /* Only handle complete types.  */
    5715         8880 :   if (!tree_fits_uhwi_p (TYPE_SIZE (type)))
    5716              :     return NULL_TREE;
    5717              : 
    5718         8868 :   switch (tree_to_uhwi (TYPE_SIZE (type)))
    5719              :     {
    5720         2710 :     case 8:
    5721         2710 :       base_atomic_type = atomicQI_type_node;
    5722         2710 :       break;
    5723              : 
    5724          862 :     case 16:
    5725          862 :       base_atomic_type = atomicHI_type_node;
    5726          862 :       break;
    5727              : 
    5728         1117 :     case 32:
    5729         1117 :       base_atomic_type = atomicSI_type_node;
    5730         1117 :       break;
    5731              : 
    5732         2749 :     case 64:
    5733         2749 :       base_atomic_type = atomicDI_type_node;
    5734         2749 :       break;
    5735              : 
    5736         1310 :     case 128:
    5737         1310 :       base_atomic_type = atomicTI_type_node;
    5738         1310 :       break;
    5739              : 
    5740              :     default:
    5741              :       base_atomic_type = NULL_TREE;
    5742              :     }
    5743              : 
    5744              :   return base_atomic_type;
    5745              : }
    5746              : 
    5747              : /* Returns true iff unqualified CAND and BASE are equivalent.  */
    5748              : 
    5749              : bool
    5750   4851455653 : check_base_type (const_tree cand, const_tree base)
    5751              : {
    5752   4851455653 :   if (TYPE_NAME (cand) != TYPE_NAME (base)
    5753              :       /* Apparently this is needed for Objective-C.  */
    5754   4279167887 :       || TYPE_CONTEXT (cand) != TYPE_CONTEXT (base)
    5755   9130623539 :       || !attribute_list_equal (TYPE_ATTRIBUTES (cand),
    5756   4279167886 :                                 TYPE_ATTRIBUTES (base)))
    5757    572287767 :     return false;
    5758              :   /* Check alignment.  */
    5759   4279167886 :   if (TYPE_ALIGN (cand) == TYPE_ALIGN (base)
    5760   4279167886 :       && TYPE_USER_ALIGN (cand) == TYPE_USER_ALIGN (base))
    5761              :     return true;
    5762              :   /* Atomic types increase minimal alignment.  We must to do so as well
    5763              :      or we get duplicated canonical types. See PR88686.  */
    5764        11163 :   if ((TYPE_QUALS (cand) & TYPE_QUAL_ATOMIC))
    5765              :     {
    5766              :       /* See if this object can map to a basic atomic type.  */
    5767         1775 :       tree atomic_type = find_atomic_core_type (cand);
    5768         1775 :       if (atomic_type && TYPE_ALIGN (atomic_type) == TYPE_ALIGN (cand))
    5769              :        return true;
    5770              :     }
    5771              :   return false;
    5772              : }
    5773              : 
    5774              : /* Returns true iff CAND is equivalent to BASE with TYPE_QUALS.  */
    5775              : 
    5776              : bool
    5777   5187546700 : check_qualified_type (const_tree cand, const_tree base, int type_quals)
    5778              : {
    5779   5187546700 :   return (TYPE_QUALS (cand) == type_quals
    5780   3606688792 :           && check_base_type (cand, base)
    5781   8222274326 :           && check_lang_type (cand, base));
    5782              : }
    5783              : 
    5784              : /* Returns true iff CAND is equivalent to BASE with ALIGN.  */
    5785              : 
    5786              : static bool
    5787      3662915 : check_aligned_type (const_tree cand, const_tree base, unsigned int align)
    5788              : {
    5789      3662915 :   return (TYPE_QUALS (cand) == TYPE_QUALS (base)
    5790      2995900 :           && TYPE_NAME (cand) == TYPE_NAME (base)
    5791              :           /* Apparently this is needed for Objective-C.  */
    5792      2171252 :           && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base)
    5793              :           /* Check alignment.  */
    5794      2171252 :           && TYPE_ALIGN (cand) == align
    5795              :           /* Check this is a user-aligned type as build_aligned_type
    5796              :              would create.  */
    5797      1020382 :           && TYPE_USER_ALIGN (cand)
    5798      1017766 :           && attribute_list_equal (TYPE_ATTRIBUTES (cand),
    5799      1017766 :                                    TYPE_ATTRIBUTES (base))
    5800      4680681 :           && check_lang_type (cand, base));
    5801              : }
    5802              : 
    5803              : /* Return a version of the TYPE, qualified as indicated by the
    5804              :    TYPE_QUALS, if one exists.  If no qualified version exists yet,
    5805              :    return NULL_TREE.  */
    5806              : 
    5807              : tree
    5808   4509796497 : get_qualified_type (tree type, int type_quals)
    5809              : {
    5810   4509796497 :   if (TYPE_QUALS (type) == type_quals)
    5811              :     return type;
    5812              : 
    5813   3143498718 :   tree mv = TYPE_MAIN_VARIANT (type);
    5814   3143498718 :   if (check_qualified_type (mv, type, type_quals))
    5815              :     return mv;
    5816              : 
    5817              :   /* Search the chain of variants to see if there is already one there just
    5818              :      like the one we need to have.  If so, use that existing one.  We must
    5819              :      preserve the TYPE_NAME, since there is code that depends on this.  */
    5820   2152826661 :   for (tree *tp = &TYPE_NEXT_VARIANT (mv); *tp; tp = &TYPE_NEXT_VARIANT (*tp))
    5821   2043984790 :     if (check_qualified_type (*tp, type, type_quals))
    5822              :       {
    5823              :         /* Put the found variant at the head of the variant list so
    5824              :            frequently searched variants get found faster.  The C++ FE
    5825              :            benefits greatly from this.  */
    5826   1289267854 :         tree t = *tp;
    5827   1289267854 :         *tp = TYPE_NEXT_VARIANT (t);
    5828   1289267854 :         TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (mv);
    5829   1289267854 :         TYPE_NEXT_VARIANT (mv) = t;
    5830   1289267854 :         return t;
    5831              :       }
    5832              : 
    5833              :   return NULL_TREE;
    5834              : }
    5835              : 
    5836              : /* Like get_qualified_type, but creates the type if it does not
    5837              :    exist.  This function never returns NULL_TREE.  */
    5838              : 
    5839              : tree
    5840   4036433154 : build_qualified_type (tree type, int type_quals MEM_STAT_DECL)
    5841              : {
    5842   4036433154 :   tree t;
    5843              : 
    5844              :   /* See if we already have the appropriate qualified variant.  */
    5845   4036433154 :   t = get_qualified_type (type, type_quals);
    5846              : 
    5847              :   /* If not, build it.  */
    5848   4036433154 :   if (!t)
    5849              :     {
    5850    107131782 :       t = build_variant_type_copy (type PASS_MEM_STAT);
    5851    107131782 :       set_type_quals (t, type_quals);
    5852              : 
    5853    107131782 :       if (((type_quals & TYPE_QUAL_ATOMIC) == TYPE_QUAL_ATOMIC))
    5854              :         {
    5855              :           /* See if this object can map to a basic atomic type.  */
    5856         7105 :           tree atomic_type = find_atomic_core_type (type);
    5857         7105 :           if (atomic_type)
    5858              :             {
    5859              :               /* Ensure the alignment of this type is compatible with
    5860              :                  the required alignment of the atomic type.  */
    5861         6973 :               if (TYPE_ALIGN (atomic_type) > TYPE_ALIGN (t))
    5862           94 :                 SET_TYPE_ALIGN (t, TYPE_ALIGN (atomic_type));
    5863              :             }
    5864              :         }
    5865              : 
    5866    107131782 :       if (TYPE_STRUCTURAL_EQUALITY_P (type))
    5867              :         /* Propagate structural equality. */
    5868      5455920 :         SET_TYPE_STRUCTURAL_EQUALITY (t);
    5869    101675862 :       else if (TYPE_CANONICAL (type) != type)
    5870              :         /* Build the underlying canonical type, since it is different
    5871              :            from TYPE. */
    5872              :         {
    5873     33189889 :           tree c = build_qualified_type (TYPE_CANONICAL (type), type_quals);
    5874     33189889 :           TYPE_CANONICAL (t) = TYPE_CANONICAL (c);
    5875              :         }
    5876              :       else
    5877              :         /* T is its own canonical type. */
    5878     68485973 :         TYPE_CANONICAL (t) = t;
    5879              : 
    5880              :     }
    5881              : 
    5882   4036433154 :   return t;
    5883              : }
    5884              : 
    5885              : /* Create a variant of type T with alignment ALIGN which
    5886              :    is measured in bits.  */
    5887              : 
    5888              : tree
    5889      1303494 : build_aligned_type (tree type, unsigned int align)
    5890              : {
    5891      1303494 :   tree t;
    5892              : 
    5893      1303494 :   if (TYPE_PACKED (type)
    5894      1303494 :       || TYPE_ALIGN (type) == align)
    5895              :     return type;
    5896              : 
    5897      3768162 :   for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
    5898      3662915 :     if (check_aligned_type (t, type, align))
    5899              :       return t;
    5900              : 
    5901       105247 :   t = build_variant_type_copy (type);
    5902       105247 :   SET_TYPE_ALIGN (t, align);
    5903       105247 :   TYPE_USER_ALIGN (t) = 1;
    5904              : 
    5905       105247 :   return t;
    5906              : }
    5907              : 
    5908              : /* Create a new distinct copy of TYPE.  The new type is made its own
    5909              :    MAIN_VARIANT. If TYPE requires structural equality checks, the
    5910              :    resulting type requires structural equality checks; otherwise, its
    5911              :    TYPE_CANONICAL points to itself. */
    5912              : 
    5913              : tree
    5914    787655832 : build_distinct_type_copy (tree type MEM_STAT_DECL)
    5915              : {
    5916    787655832 :   tree t = copy_node (type PASS_MEM_STAT);
    5917              : 
    5918    787655832 :   TYPE_POINTER_TO (t) = 0;
    5919    787655832 :   TYPE_REFERENCE_TO (t) = 0;
    5920              : 
    5921              :   /* Set the canonical type either to a new equivalence class, or
    5922              :      propagate the need for structural equality checks. */
    5923    787655832 :   if (TYPE_STRUCTURAL_EQUALITY_P (type))
    5924     65530533 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    5925              :   else
    5926    722125299 :     TYPE_CANONICAL (t) = t;
    5927              : 
    5928              :   /* Make it its own variant.  */
    5929    787655832 :   TYPE_MAIN_VARIANT (t) = t;
    5930    787655832 :   TYPE_NEXT_VARIANT (t) = 0;
    5931              : 
    5932              :   /* Note that it is now possible for TYPE_MIN_VALUE to be a value
    5933              :      whose TREE_TYPE is not t.  This can also happen in the Ada
    5934              :      frontend when using subtypes.  */
    5935              : 
    5936    787655832 :   return t;
    5937              : }
    5938              : 
    5939              : /* Create a new variant of TYPE, equivalent but distinct.  This is so
    5940              :    the caller can modify it. TYPE_CANONICAL for the return type will
    5941              :    be equivalent to TYPE_CANONICAL of TYPE, indicating that the types
    5942              :    are considered equal by the language itself (or that both types
    5943              :    require structural equality checks). */
    5944              : 
    5945              : tree
    5946    497104461 : build_variant_type_copy (tree type MEM_STAT_DECL)
    5947              : {
    5948    497104461 :   tree t, m = TYPE_MAIN_VARIANT (type);
    5949              : 
    5950    497104461 :   t = build_distinct_type_copy (type PASS_MEM_STAT);
    5951              : 
    5952              :   /* Since we're building a variant, assume that it is a non-semantic
    5953              :      variant.  This also propagates TYPE_STRUCTURAL_EQUALITY_P. */
    5954    497104461 :   TYPE_CANONICAL (t) = TYPE_CANONICAL (type);
    5955              :   /* Type variants have no alias set defined.  */
    5956    497104461 :   TYPE_ALIAS_SET (t) = -1;
    5957              : 
    5958              :   /* Add the new type to the chain of variants of TYPE.  */
    5959    497104461 :   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
    5960    497104461 :   TYPE_NEXT_VARIANT (m) = t;
    5961    497104461 :   TYPE_MAIN_VARIANT (t) = m;
    5962              : 
    5963    497104461 :   return t;
    5964              : }
    5965              : 
    5966              : /* Return true if the from tree in both tree maps are equal.  */
    5967              : 
    5968              : int
    5969   1738792029 : tree_map_base_eq (const void *va, const void *vb)
    5970              : {
    5971   1738792029 :   const struct tree_map_base  *const a = (const struct tree_map_base *) va,
    5972   1738792029 :     *const b = (const struct tree_map_base *) vb;
    5973   1738792029 :   return (a->from == b->from);
    5974              : }
    5975              : 
    5976              : /* Hash a from tree in a tree_base_map.  */
    5977              : 
    5978              : unsigned int
    5979            0 : tree_map_base_hash (const void *item)
    5980              : {
    5981            0 :   return htab_hash_pointer (((const struct tree_map_base *)item)->from);
    5982              : }
    5983              : 
    5984              : /* Return true if this tree map structure is marked for garbage collection
    5985              :    purposes.  We simply return true if the from tree is marked, so that this
    5986              :    structure goes away when the from tree goes away.  */
    5987              : 
    5988              : bool
    5989            0 : tree_map_base_marked_p (const void *p)
    5990              : {
    5991            0 :   return ggc_marked_p (((const struct tree_map_base *) p)->from);
    5992              : }
    5993              : 
    5994              : /* Hash a from tree in a tree_map.  */
    5995              : 
    5996              : unsigned int
    5997          219 : tree_map_hash (const void *item)
    5998              : {
    5999          219 :   return (((const struct tree_map *) item)->hash);
    6000              : }
    6001              : 
    6002              : /* Hash a from tree in a tree_decl_map.  */
    6003              : 
    6004              : unsigned int
    6005   1184132672 : tree_decl_map_hash (const void *item)
    6006              : {
    6007   1184132672 :   return DECL_UID (((const struct tree_decl_map *) item)->base.from);
    6008              : }
    6009              : 
    6010              : /* Return the initialization priority for DECL.  */
    6011              : 
    6012              : priority_type
    6013        24063 : decl_init_priority_lookup (tree decl)
    6014              : {
    6015        24063 :   symtab_node *snode = symtab_node::get (decl);
    6016              : 
    6017        24063 :   if (!snode)
    6018              :     return DEFAULT_INIT_PRIORITY;
    6019        24063 :   return
    6020        24063 :     snode->get_init_priority ();
    6021              : }
    6022              : 
    6023              : /* Return the finalization priority for DECL.  */
    6024              : 
    6025              : priority_type
    6026         1832 : decl_fini_priority_lookup (tree decl)
    6027              : {
    6028         1832 :   cgraph_node *node = cgraph_node::get (decl);
    6029              : 
    6030         1832 :   if (!node)
    6031              :     return DEFAULT_INIT_PRIORITY;
    6032         1832 :   return
    6033         1832 :     node->get_fini_priority ();
    6034              : }
    6035              : 
    6036              : /* Set the initialization priority for DECL to PRIORITY.  */
    6037              : 
    6038              : void
    6039        25580 : decl_init_priority_insert (tree decl, priority_type priority)
    6040              : {
    6041        25580 :   struct symtab_node *snode;
    6042              : 
    6043        25580 :   if (priority == DEFAULT_INIT_PRIORITY)
    6044              :     {
    6045        21798 :       snode = symtab_node::get (decl);
    6046        21798 :       if (!snode)
    6047              :         return;
    6048              :     }
    6049         3782 :   else if (VAR_P (decl))
    6050           45 :     snode = varpool_node::get_create (decl);
    6051              :   else
    6052         3737 :     snode = cgraph_node::get_create (decl);
    6053        24757 :   snode->set_init_priority (priority);
    6054              : }
    6055              : 
    6056              : /* Set the finalization priority for DECL to PRIORITY.  */
    6057              : 
    6058              : void
    6059         1693 : decl_fini_priority_insert (tree decl, priority_type priority)
    6060              : {
    6061         1693 :   struct cgraph_node *node;
    6062              : 
    6063         1693 :   if (priority == DEFAULT_INIT_PRIORITY)
    6064              :     {
    6065          105 :       node = cgraph_node::get (decl);
    6066          105 :       if (!node)
    6067              :         return;
    6068              :     }
    6069              :   else
    6070         1588 :     node = cgraph_node::get_create (decl);
    6071         1598 :   node->set_fini_priority (priority);
    6072              : }
    6073              : 
    6074              : /* Print out the statistics for the DECL_DEBUG_EXPR hash table.  */
    6075              : 
    6076              : static void
    6077            0 : print_debug_expr_statistics (void)
    6078              : {
    6079            0 :   fprintf (stderr, "DECL_DEBUG_EXPR  hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6080              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6081            0 :            (fmt_size_t) debug_expr_for_decl->size (),
    6082            0 :            (fmt_size_t) debug_expr_for_decl->elements (),
    6083              :            debug_expr_for_decl->collisions ());
    6084            0 : }
    6085              : 
    6086              : /* Print out the statistics for the DECL_VALUE_EXPR hash table.  */
    6087              : 
    6088              : static void
    6089            0 : print_value_expr_statistics (void)
    6090              : {
    6091            0 :   fprintf (stderr, "DECL_VALUE_EXPR  hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6092              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6093            0 :            (fmt_size_t) value_expr_for_decl->size (),
    6094            0 :            (fmt_size_t) value_expr_for_decl->elements (),
    6095              :            value_expr_for_decl->collisions ());
    6096            0 : }
    6097              : 
    6098              : /* Lookup a debug expression for FROM, and return it if we find one.  */
    6099              : 
    6100              : tree
    6101    422382131 : decl_debug_expr_lookup (tree from)
    6102              : {
    6103    422382131 :   struct tree_decl_map *h, in;
    6104    422382131 :   in.base.from = from;
    6105              : 
    6106    422382131 :   h = debug_expr_for_decl->find_with_hash (&in, DECL_UID (from));
    6107    422382131 :   if (h)
    6108    422382131 :     return h->to;
    6109              :   return NULL_TREE;
    6110              : }
    6111              : 
    6112              : /* Insert a mapping FROM->TO in the debug expression hashtable.  */
    6113              : 
    6114              : void
    6115      1349717 : decl_debug_expr_insert (tree from, tree to)
    6116              : {
    6117      1349717 :   struct tree_decl_map *h;
    6118              : 
    6119      1349717 :   h = ggc_alloc<tree_decl_map> ();
    6120      1349717 :   h->base.from = from;
    6121      1349717 :   h->to = to;
    6122      1349717 :   *debug_expr_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
    6123      1349717 : }
    6124              : 
    6125              : /* Lookup a value expression for FROM, and return it if we find one.  */
    6126              : 
    6127              : tree
    6128     16459252 : decl_value_expr_lookup (tree from)
    6129              : {
    6130     16459252 :   struct tree_decl_map *h, in;
    6131     16459252 :   in.base.from = from;
    6132              : 
    6133     16459252 :   h = value_expr_for_decl->find_with_hash (&in, DECL_UID (from));
    6134     16459252 :   if (h)
    6135     16459252 :     return h->to;
    6136              :   return NULL_TREE;
    6137              : }
    6138              : 
    6139              : /* Insert a mapping FROM->TO in the value expression hashtable.  */
    6140              : 
    6141              : void
    6142      7125939 : decl_value_expr_insert (tree from, tree to)
    6143              : {
    6144      7125939 :   struct tree_decl_map *h;
    6145              : 
    6146              :   /* Uses of FROM shouldn't look like they happen at the location of TO.  */
    6147      7125939 :   to = protected_set_expr_location_unshare (to, UNKNOWN_LOCATION);
    6148              : 
    6149      7125939 :   h = ggc_alloc<tree_decl_map> ();
    6150      7125939 :   h->base.from = from;
    6151      7125939 :   h->to = to;
    6152      7125939 :   *value_expr_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
    6153      7125939 : }
    6154              : 
    6155              : /* Lookup a vector of debug arguments for FROM, and return it if we
    6156              :    find one.  */
    6157              : 
    6158              : vec<tree, va_gc> **
    6159       895549 : decl_debug_args_lookup (tree from)
    6160              : {
    6161       895549 :   struct tree_vec_map *h, in;
    6162              : 
    6163       895549 :   if (!DECL_HAS_DEBUG_ARGS_P (from))
    6164              :     return NULL;
    6165       760362 :   gcc_checking_assert (debug_args_for_decl != NULL);
    6166       760362 :   in.base.from = from;
    6167       760362 :   h = debug_args_for_decl->find_with_hash (&in, DECL_UID (from));
    6168       760362 :   if (h)
    6169       756426 :     return &h->to;
    6170              :   return NULL;
    6171              : }
    6172              : 
    6173              : /* Insert a mapping FROM->empty vector of debug arguments in the value
    6174              :    expression hashtable.  */
    6175              : 
    6176              : vec<tree, va_gc> **
    6177       275653 : decl_debug_args_insert (tree from)
    6178              : {
    6179       275653 :   struct tree_vec_map *h;
    6180       275653 :   tree_vec_map **loc;
    6181              : 
    6182       275653 :   if (DECL_HAS_DEBUG_ARGS_P (from))
    6183       189646 :     return decl_debug_args_lookup (from);
    6184        86007 :   if (debug_args_for_decl == NULL)
    6185         8331 :     debug_args_for_decl = hash_table<tree_vec_map_cache_hasher>::create_ggc (64);
    6186        86007 :   h = ggc_alloc<tree_vec_map> ();
    6187        86007 :   h->base.from = from;
    6188        86007 :   h->to = NULL;
    6189        86007 :   loc = debug_args_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT);
    6190        86007 :   *loc = h;
    6191        86007 :   DECL_HAS_DEBUG_ARGS_P (from) = 1;
    6192        86007 :   return &h->to;
    6193              : }
    6194              : 
    6195              : /* Hashing of types so that we don't make duplicates.
    6196              :    The entry point is `type_hash_canon'.  */
    6197              : 
    6198              : /* Generate the default hash code for TYPE.  This is designed for
    6199              :    speed, rather than maximum entropy.  */
    6200              : 
    6201              : hashval_t
    6202   1424195118 : type_hash_canon_hash (tree type)
    6203              : {
    6204   1424195118 :   inchash::hash hstate;
    6205              : 
    6206   1424195118 :   hstate.add_int (TREE_CODE (type));
    6207              : 
    6208   1424195118 :   hstate.add_flag (TYPE_STRUCTURAL_EQUALITY_P (type));
    6209              : 
    6210   1424195118 :   if (TREE_TYPE (type))
    6211   1424112326 :     hstate.add_object (TYPE_HASH (TREE_TYPE (type)));
    6212              : 
    6213   1711704671 :   for (tree t = TYPE_ATTRIBUTES (type); t; t = TREE_CHAIN (t))
    6214              :     /* Just the identifier is adequate to distinguish.  */
    6215    287509553 :     hstate.add_object (IDENTIFIER_HASH_VALUE (get_attribute_name (t)));
    6216              : 
    6217   1424195118 :   switch (TREE_CODE (type))
    6218              :     {
    6219    326986314 :     case METHOD_TYPE:
    6220    326986314 :       hstate.add_object (TYPE_HASH (TYPE_METHOD_BASETYPE (type)));
    6221              :       /* FALLTHROUGH. */
    6222   1232445415 :     case FUNCTION_TYPE:
    6223   4860686224 :       for (tree t = TYPE_ARG_TYPES (type); t; t = TREE_CHAIN (t))
    6224   3628240809 :         if (TREE_VALUE (t) != error_mark_node)
    6225   3628228522 :           hstate.add_object (TYPE_HASH (TREE_VALUE (t)));
    6226              :       break;
    6227              : 
    6228       951467 :     case OFFSET_TYPE:
    6229       951467 :       hstate.add_object (TYPE_HASH (TYPE_OFFSET_BASETYPE (type)));
    6230       951467 :       break;
    6231              : 
    6232     70374584 :     case ARRAY_TYPE:
    6233     70374584 :       {
    6234     70374584 :         if (TYPE_DOMAIN (type))
    6235     67478293 :           hstate.add_object (TYPE_HASH (TYPE_DOMAIN (type)));
    6236     70374584 :         if (!AGGREGATE_TYPE_P (TREE_TYPE (type)))
    6237              :           {
    6238     67952306 :             unsigned typeless = TYPE_TYPELESS_STORAGE (type);
    6239     67952306 :             hstate.add_object (typeless);
    6240              :           }
    6241              :       }
    6242              :       break;
    6243              : 
    6244     42002463 :     case INTEGER_TYPE:
    6245     42002463 :       {
    6246     42002463 :         tree t = TYPE_MAX_VALUE (type);
    6247     42002463 :         if (!t)
    6248       551304 :           t = TYPE_MIN_VALUE (type);
    6249     84004927 :         for (int i = 0; i < TREE_INT_CST_NUNITS (t); i++)
    6250     42002464 :           hstate.add_object (TREE_INT_CST_ELT (t, i));
    6251              :         break;
    6252              :       }
    6253              : 
    6254        60545 :     case BITINT_TYPE:
    6255        60545 :       {
    6256        60545 :         unsigned prec = TYPE_PRECISION (type);
    6257        60545 :         unsigned uns = TYPE_UNSIGNED (type);
    6258        60545 :         hstate.add_object (prec);
    6259        60545 :         hstate.add_int (uns);
    6260        60545 :         break;
    6261              :       }
    6262              : 
    6263        12001 :     case REAL_TYPE:
    6264        12001 :     case FIXED_POINT_TYPE:
    6265        12001 :       {
    6266        12001 :         unsigned prec = TYPE_PRECISION (type);
    6267        12001 :         hstate.add_object (prec);
    6268        12001 :         break;
    6269              :       }
    6270              : 
    6271     72618525 :     case VECTOR_TYPE:
    6272     72618525 :       hstate.add_poly_int (TYPE_VECTOR_SUBPARTS (type));
    6273     72618525 :       break;
    6274              : 
    6275              :     case REFERENCE_TYPE:
    6276   1424195118 :       hstate.add_flag (TYPE_REF_IS_RVALUE (type));
    6277              :       break;
    6278              : 
    6279              :     default:
    6280              :       break;
    6281              :     }
    6282              : 
    6283   1424195118 :   return hstate.end ();
    6284              : }
    6285              : 
    6286              : /* These are the Hashtable callback functions.  */
    6287              : 
    6288              : /* Returns true iff the types are equivalent.  */
    6289              : 
    6290              : bool
    6291   9406248387 : type_cache_hasher::equal (type_hash *a, type_hash *b)
    6292              : {
    6293              :   /* First test the things that are the same for all types.  */
    6294   9406248387 :   if (a->hash != b->hash
    6295    701997616 :       || TREE_CODE (a->type) != TREE_CODE (b->type)
    6296    701996789 :       || TREE_TYPE (a->type) != TREE_TYPE (b->type)
    6297    701996464 :       || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
    6298    701996464 :                                  TYPE_ATTRIBUTES (b->type))
    6299  10101011113 :       || (TREE_CODE (a->type) != COMPLEX_TYPE
    6300    692578868 :           && TYPE_NAME (a->type) != TYPE_NAME (b->type)))
    6301   8712342140 :     return false;
    6302              : 
    6303              :   /* Be careful about comparing arrays before and after the element type
    6304              :      has been completed; don't compare TYPE_ALIGN unless both types are
    6305              :      complete.  */
    6306   1384699842 :   if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type)
    6307   1384699842 :       && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
    6308    690793054 :           || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
    6309          604 :     return false;
    6310              : 
    6311    693905643 :   if (TYPE_STRUCTURAL_EQUALITY_P (a->type)
    6312    693905643 :       != TYPE_STRUCTURAL_EQUALITY_P (b->type))
    6313              :     return false;
    6314              : 
    6315    693901778 :   switch (TREE_CODE (a->type))
    6316              :     {
    6317              :     case VOID_TYPE:
    6318              :     case OPAQUE_TYPE:
    6319              :     case COMPLEX_TYPE:
    6320              :     case POINTER_TYPE:
    6321              :     case NULLPTR_TYPE:
    6322              :       return true;
    6323              : 
    6324     66040779 :     case VECTOR_TYPE:
    6325     66040779 :       return known_eq (TYPE_VECTOR_SUBPARTS (a->type),
    6326              :                        TYPE_VECTOR_SUBPARTS (b->type));
    6327              : 
    6328            0 :     case ENUMERAL_TYPE:
    6329            0 :       if (TYPE_VALUES (a->type) != TYPE_VALUES (b->type)
    6330            0 :           && !(TYPE_VALUES (a->type)
    6331            0 :                && TREE_CODE (TYPE_VALUES (a->type)) == TREE_LIST
    6332            0 :                && TYPE_VALUES (b->type)
    6333            0 :                && TREE_CODE (TYPE_VALUES (b->type)) == TREE_LIST
    6334            0 :                && type_list_equal (TYPE_VALUES (a->type),
    6335            0 :                                    TYPE_VALUES (b->type))))
    6336            0 :         return false;
    6337              : 
    6338              :       /* fall through */
    6339              : 
    6340     39110076 :     case INTEGER_TYPE:
    6341     39110076 :     case REAL_TYPE:
    6342     39110076 :     case BOOLEAN_TYPE:
    6343     39110076 :       if (TYPE_PRECISION (a->type) != TYPE_PRECISION (b->type))
    6344              :         return false;
    6345     39096615 :       return ((TYPE_MAX_VALUE (a->type) == TYPE_MAX_VALUE (b->type)
    6346       724395 :                || tree_int_cst_equal (TYPE_MAX_VALUE (a->type),
    6347       724395 :                                       TYPE_MAX_VALUE (b->type)))
    6348     39419658 :               && (TYPE_MIN_VALUE (a->type) == TYPE_MIN_VALUE (b->type)
    6349       474421 :                   || tree_int_cst_equal (TYPE_MIN_VALUE (a->type),
    6350       474421 :                                          TYPE_MIN_VALUE (b->type))));
    6351              : 
    6352        54259 :     case BITINT_TYPE:
    6353        54259 :       if (TYPE_PRECISION (a->type) != TYPE_PRECISION (b->type))
    6354              :         return false;
    6355        54259 :       return TYPE_UNSIGNED (a->type) == TYPE_UNSIGNED (b->type);
    6356              : 
    6357            0 :     case FIXED_POINT_TYPE:
    6358            0 :       return TYPE_SATURATING (a->type) == TYPE_SATURATING (b->type);
    6359              : 
    6360       722115 :     case OFFSET_TYPE:
    6361       722115 :       return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type);
    6362              : 
    6363     90991988 :     case METHOD_TYPE:
    6364     90991988 :       if (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type)
    6365     90991988 :           && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
    6366     90850937 :               || (TYPE_ARG_TYPES (a->type)
    6367     90850937 :                   && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
    6368     90850937 :                   && TYPE_ARG_TYPES (b->type)
    6369     90850937 :                   && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
    6370     90850937 :                   && type_list_equal (TYPE_ARG_TYPES (a->type),
    6371     90850937 :                                       TYPE_ARG_TYPES (b->type)))))
    6372              :         break;
    6373              :       return false;
    6374     59340301 :     case ARRAY_TYPE:
    6375              :       /* Don't compare TYPE_TYPELESS_STORAGE flag on aggregates,
    6376              :          where the flag should be inherited from the element type
    6377              :          and can change after ARRAY_TYPEs are created; on non-aggregates
    6378              :          compare it and hash it, scalars will never have that flag set
    6379              :          and we need to differentiate between arrays created by different
    6380              :          front-ends or middle-end created arrays.  */
    6381     59340301 :       return (TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type)
    6382     59340301 :               && (AGGREGATE_TYPE_P (TREE_TYPE (a->type))
    6383     57555389 :                   || (TYPE_TYPELESS_STORAGE (a->type)
    6384     57555389 :                       == TYPE_TYPELESS_STORAGE (b->type))));
    6385              : 
    6386            0 :     case RECORD_TYPE:
    6387            0 :     case UNION_TYPE:
    6388            0 :     case QUAL_UNION_TYPE:
    6389            0 :       return (TYPE_FIELDS (a->type) == TYPE_FIELDS (b->type)
    6390            0 :               || (TYPE_FIELDS (a->type)
    6391            0 :                   && TREE_CODE (TYPE_FIELDS (a->type)) == TREE_LIST
    6392            0 :                   && TYPE_FIELDS (b->type)
    6393            0 :                   && TREE_CODE (TYPE_FIELDS (b->type)) == TREE_LIST
    6394            0 :                   && type_list_equal (TYPE_FIELDS (a->type),
    6395            0 :                                       TYPE_FIELDS (b->type))));
    6396              : 
    6397    435457944 :     case FUNCTION_TYPE:
    6398    435457944 :       if ((TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
    6399    278227428 :            && (TYPE_NO_NAMED_ARGS_STDARG_P (a->type)
    6400    278227428 :                == TYPE_NO_NAMED_ARGS_STDARG_P (b->type)))
    6401    435782401 :           || (TYPE_ARG_TYPES (a->type)
    6402    157230516 :               && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
    6403    157230516 :               && TYPE_ARG_TYPES (b->type)
    6404    157230501 :               && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
    6405    157230501 :               && type_list_equal (TYPE_ARG_TYPES (a->type),
    6406    157230501 :                                   TYPE_ARG_TYPES (b->type))))
    6407              :         break;
    6408              :       return false;
    6409              : 
    6410            9 :     case REFERENCE_TYPE:
    6411            9 :       return TYPE_REF_IS_RVALUE (a->type) == TYPE_REF_IS_RVALUE (b->type);
    6412              : 
    6413              :     default:
    6414              :       return false;
    6415              :     }
    6416              : 
    6417    499544203 :   if (lang_hooks.types.type_hash_eq != NULL)
    6418    311363681 :     return lang_hooks.types.type_hash_eq (a->type, b->type);
    6419              : 
    6420              :   return true;
    6421              : }
    6422              : 
    6423              : /* Given TYPE, and HASHCODE its hash code, return the canonical
    6424              :    object for an identical type if one already exists.
    6425              :    Otherwise, return TYPE, and record it as the canonical object.
    6426              : 
    6427              :    To use this function, first create a type of the sort you want.
    6428              :    Then compute its hash code from the fields of the type that
    6429              :    make it different from other similar types.
    6430              :    Then call this function and use the value.  */
    6431              : 
    6432              : tree
    6433   1425264835 : type_hash_canon (unsigned int hashcode, tree type)
    6434              : {
    6435   1425264835 :   type_hash in;
    6436   1425264835 :   type_hash **loc;
    6437              : 
    6438              :   /* The hash table only contains main variants, so ensure that's what we're
    6439              :      being passed.  */
    6440   1425264835 :   gcc_assert (TYPE_MAIN_VARIANT (type) == type);
    6441              : 
    6442              :   /* The TYPE_ALIGN field of a type is set by layout_type(), so we
    6443              :      must call that routine before comparing TYPE_ALIGNs.  */
    6444   1425264835 :   layout_type (type);
    6445              : 
    6446   1425264835 :   in.hash = hashcode;
    6447   1425264835 :   in.type = type;
    6448              : 
    6449   1425264835 :   loc = type_hash_table->find_slot_with_hash (&in, hashcode, INSERT);
    6450   1425264835 :   if (*loc)
    6451              :     {
    6452    666423577 :       tree t1 = ((type_hash *) *loc)->type;
    6453    666423577 :       gcc_assert (TYPE_MAIN_VARIANT (t1) == t1
    6454              :                   && t1 != type);
    6455    666423577 :       if (TYPE_UID (type) + 1 == next_type_uid)
    6456    661072569 :         --next_type_uid;
    6457              :       /* Free also min/max values and the cache for integer
    6458              :          types.  This can't be done in free_node, as LTO frees
    6459              :          those on its own.  */
    6460    666423577 :       if (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == BITINT_TYPE)
    6461              :         {
    6462     38591860 :           if (TYPE_MIN_VALUE (type)
    6463     38591860 :               && TREE_TYPE (TYPE_MIN_VALUE (type)) == type)
    6464              :             {
    6465              :               /* Zero is always in TYPE_CACHED_VALUES.  */
    6466       370366 :               if (! TYPE_UNSIGNED (type))
    6467       226204 :                 int_cst_hash_table->remove_elt (TYPE_MIN_VALUE (type));
    6468       370366 :               ggc_free (TYPE_MIN_VALUE (type));
    6469              :             }
    6470     38591860 :           if (TYPE_MAX_VALUE (type)
    6471     38591860 :               && TREE_TYPE (TYPE_MAX_VALUE (type)) == type)
    6472              :             {
    6473       370366 :               int_cst_hash_table->remove_elt (TYPE_MAX_VALUE (type));
    6474       370366 :               ggc_free (TYPE_MAX_VALUE (type));
    6475              :             }
    6476     38591860 :           if (TYPE_CACHED_VALUES_P (type))
    6477       144162 :             ggc_free (TYPE_CACHED_VALUES (type));
    6478              :         }
    6479    666423577 :       free_node (type);
    6480    666423577 :       return t1;
    6481              :     }
    6482              :   else
    6483              :     {
    6484    758841258 :       struct type_hash *h;
    6485              : 
    6486    758841258 :       h = ggc_alloc<type_hash> ();
    6487    758841258 :       h->hash = hashcode;
    6488    758841258 :       h->type = type;
    6489    758841258 :       *loc = h;
    6490              : 
    6491    758841258 :       return type;
    6492              :     }
    6493              : }
    6494              : 
    6495              : static void
    6496            0 : print_type_hash_statistics (void)
    6497              : {
    6498            0 :   fprintf (stderr, "Type hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6499              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6500            0 :            (fmt_size_t) type_hash_table->size (),
    6501            0 :            (fmt_size_t) type_hash_table->elements (),
    6502              :            type_hash_table->collisions ());
    6503            0 : }
    6504              : 
    6505              : /* Given two lists of types
    6506              :    (chains of TREE_LIST nodes with types in the TREE_VALUE slots)
    6507              :    return 1 if the lists contain the same types in the same order.
    6508              :    Also, the TREE_PURPOSEs must match.  */
    6509              : 
    6510              : bool
    6511    248081960 : type_list_equal (const_tree l1, const_tree l2)
    6512              : {
    6513    248081960 :   const_tree t1, t2;
    6514              : 
    6515    933138256 :   for (t1 = l1, t2 = l2; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    6516    711637508 :     if (TREE_VALUE (t1) != TREE_VALUE (t2)
    6517    711637508 :         || (TREE_PURPOSE (t1) != TREE_PURPOSE (t2)
    6518     26582804 :             && ! (1 == simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2))
    6519         1626 :                   && (TREE_TYPE (TREE_PURPOSE (t1))
    6520         1626 :                       == TREE_TYPE (TREE_PURPOSE (t2))))))
    6521     26581212 :       return false;
    6522              : 
    6523    221500748 :   return t1 == t2;
    6524              : }
    6525              : 
    6526              : /* Returns the number of arguments to the FUNCTION_TYPE or METHOD_TYPE
    6527              :    given by TYPE.  If the argument list accepts variable arguments,
    6528              :    then this function counts only the ordinary arguments.  */
    6529              : 
    6530              : int
    6531     82016382 : type_num_arguments (const_tree fntype)
    6532              : {
    6533     82016382 :   int i = 0;
    6534              : 
    6535    318892970 :   for (tree t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t))
    6536              :     /* If the function does not take a variable number of arguments,
    6537              :        the last element in the list will have type `void'.  */
    6538    299520692 :     if (VOID_TYPE_P (TREE_VALUE (t)))
    6539              :       break;
    6540              :     else
    6541    236876588 :       ++i;
    6542              : 
    6543     82016382 :   return i;
    6544              : }
    6545              : 
    6546              : /* Return the type of the function TYPE's argument ARGNO if known.
    6547              :    For vararg function's where ARGNO refers to one of the variadic
    6548              :    arguments return null.  Otherwise, return a void_type_node for
    6549              :    out-of-bounds ARGNO.  */
    6550              : 
    6551              : tree
    6552     81004320 : type_argument_type (const_tree fntype, unsigned argno)
    6553              : {
    6554              :   /* Treat zero the same as an out-of-bounds argument number.  */
    6555     81004320 :   if (!argno)
    6556            0 :     return void_type_node;
    6557              : 
    6558     81004320 :   function_args_iterator iter;
    6559              : 
    6560     81004320 :   tree argtype;
    6561     81004320 :   unsigned i = 1;
    6562    174873442 :   FOREACH_FUNCTION_ARGS (fntype, argtype, iter)
    6563              :     {
    6564              :       /* A vararg function's argument list ends in a null.  Otherwise,
    6565              :          an ordinary function's argument list ends with void.  Return
    6566              :          null if ARGNO refers to a vararg argument, void_type_node if
    6567              :          it's out of bounds, and the formal argument type otherwise.  */
    6568    169060778 :       if (!argtype)
    6569              :         break;
    6570              : 
    6571    169060778 :       if (i == argno || VOID_TYPE_P (argtype))
    6572              :         return argtype;
    6573              : 
    6574     93869122 :       ++i;
    6575              :     }
    6576              : 
    6577              :   return NULL_TREE;
    6578              : }
    6579              : 
    6580              : /* True if integer constants T1 and T2
    6581              :    represent the same constant value.  */
    6582              : 
    6583              : bool
    6584   1279056173 : tree_int_cst_equal (const_tree t1, const_tree t2)
    6585              : {
    6586   1279056173 :   if (t1 == t2)
    6587              :     return true;
    6588              : 
    6589    648660511 :   if (t1 == 0 || t2 == 0)
    6590              :     return false;
    6591              : 
    6592    648257411 :   STRIP_ANY_LOCATION_WRAPPER (t1);
    6593    648257411 :   STRIP_ANY_LOCATION_WRAPPER (t2);
    6594              : 
    6595    648257411 :   if (TREE_CODE (t1) == INTEGER_CST
    6596    644282329 :       && TREE_CODE (t2) == INTEGER_CST
    6597   1292539740 :       && wi::to_widest (t1) == wi::to_widest (t2))
    6598     18927249 :     return true;
    6599              : 
    6600              :   return false;
    6601              : }
    6602              : 
    6603              : /* Return true if T is an INTEGER_CST whose numerical value (extended
    6604              :    according to TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  */
    6605              : 
    6606              : bool
    6607   2264759507 : tree_fits_shwi_p (const_tree t)
    6608              : {
    6609   2264759507 :   return (t != NULL_TREE
    6610   2264759416 :           && TREE_CODE (t) == INTEGER_CST
    6611   4526926521 :           && wi::fits_shwi_p (wi::to_widest (t)));
    6612              : }
    6613              : 
    6614              : /* Return true if T is an INTEGER_CST or POLY_INT_CST whose numerical
    6615              :    value (extended according to TYPE_UNSIGNED) fits in a poly_int64.  */
    6616              : 
    6617              : bool
    6618    956558584 : tree_fits_poly_int64_p (const_tree t)
    6619              : {
    6620    956558584 :   if (t == NULL_TREE)
    6621              :     return false;
    6622    919412875 :   if (POLY_INT_CST_P (t))
    6623              :     {
    6624              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; i++)
    6625              :         if (!wi::fits_shwi_p (wi::to_wide (POLY_INT_CST_COEFF (t, i))))
    6626              :           return false;
    6627              :       return true;
    6628              :     }
    6629    919412875 :   return (TREE_CODE (t) == INTEGER_CST
    6630   1838928735 :           && wi::fits_shwi_p (wi::to_widest (t)));
    6631              : }
    6632              : 
    6633              : /* Return true if T is an INTEGER_CST whose numerical value (extended
    6634              :    according to TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  */
    6635              : 
    6636              : bool
    6637   3989056180 : tree_fits_uhwi_p (const_tree t)
    6638              : {
    6639   3989056180 :   return (t != NULL_TREE
    6640   3988452593 :           && TREE_CODE (t) == INTEGER_CST
    6641   7972442596 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6642              : }
    6643              : 
    6644              : /* Return true if T is an INTEGER_CST or POLY_INT_CST whose numerical
    6645              :    value (extended according to TYPE_UNSIGNED) fits in a poly_uint64.  */
    6646              : 
    6647              : bool
    6648   1016078203 : tree_fits_poly_uint64_p (const_tree t)
    6649              : {
    6650   1016078203 :   if (t == NULL_TREE)
    6651              :     return false;
    6652   1015720311 :   if (POLY_INT_CST_P (t))
    6653              :     {
    6654              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; i++)
    6655              :         if (!wi::fits_uhwi_p (wi::to_widest (POLY_INT_CST_COEFF (t, i))))
    6656              :           return false;
    6657              :       return true;
    6658              :     }
    6659   1015720311 :   return (TREE_CODE (t) == INTEGER_CST
    6660   2031442016 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6661              : }
    6662              : 
    6663              : /* Return true if T is an INTEGER_CST whose numerical value (extended according
    6664              :    to TYPE_UNSIGNED) fits in a sanitize_code_type (uint64_t).  */
    6665              : 
    6666              : bool
    6667           90 : tree_fits_sanitize_code_type_p (const_tree t)
    6668              : {
    6669           90 :   if (t == NULL_TREE)
    6670              :     return false;
    6671           90 :   return (TREE_CODE (t) == INTEGER_CST
    6672          180 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6673              : }
    6674              : 
    6675              : /* T is an INTEGER_CST whose numerical value (extended according to
    6676              :    TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  Return that
    6677              :    HOST_WIDE_INT.  */
    6678              : 
    6679              : HOST_WIDE_INT
    6680   1353316359 : tree_to_shwi (const_tree t)
    6681              : {
    6682   1353316359 :   gcc_assert (tree_fits_shwi_p (t));
    6683   1353316359 :   return TREE_INT_CST_LOW (t);
    6684              : }
    6685              : 
    6686              : /* T is an INTEGER_CST whose numerical value (extended according to
    6687              :    TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  Return that
    6688              :    HOST_WIDE_INT.  */
    6689              : 
    6690              : unsigned HOST_WIDE_INT
    6691    978888009 : tree_to_uhwi (const_tree t)
    6692              : {
    6693    978888009 :   gcc_assert (tree_fits_uhwi_p (t));
    6694    978888009 :   return TREE_INT_CST_LOW (t);
    6695              : }
    6696              : 
    6697              : /* T is an INTEGER_CST whose numerical value (extended according to
    6698              :    TYPE_UNSIGNED) fits in a sanitize_code_type.  Return that
    6699              :    sanitize_code_type.  */
    6700              : 
    6701              : sanitize_code_type
    6702           90 : tree_to_sanitize_code_type (const_tree t)
    6703              : {
    6704           90 :   gcc_assert (tree_fits_sanitize_code_type_p (t));
    6705           90 :   return TREE_INT_CST_LOW (t);
    6706              : }
    6707              : 
    6708              : /* Return the most significant (sign) bit of T.  */
    6709              : 
    6710              : int
    6711     43949350 : tree_int_cst_sign_bit (const_tree t)
    6712              : {
    6713     43949350 :   unsigned bitno = TYPE_PRECISION (TREE_TYPE (t)) - 1;
    6714              : 
    6715     43949350 :   return wi::extract_uhwi (wi::to_wide (t), bitno, 1);
    6716              : }
    6717              : 
    6718              : /* Return an indication of the sign of the integer constant T.
    6719              :    The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
    6720              :    Note that -1 will never be returned if T's type is unsigned.  */
    6721              : 
    6722              : int
    6723   1808935265 : tree_int_cst_sgn (const_tree t)
    6724              : {
    6725   1808935265 :   if (wi::to_wide (t) == 0)
    6726              :     return 0;
    6727   1686509459 :   else if (TYPE_UNSIGNED (TREE_TYPE (t)))
    6728              :     return 1;
    6729     79187972 :   else if (wi::neg_p (wi::to_wide (t)))
    6730              :     return -1;
    6731              :   else
    6732              :     return 1;
    6733              : }
    6734              : 
    6735              : /* Return the minimum number of bits needed to represent VALUE in a
    6736              :    signed or unsigned type, UNSIGNEDP says which.  */
    6737              : 
    6738              : unsigned int
    6739      3573051 : tree_int_cst_min_precision (tree value, signop sgn)
    6740              : {
    6741              :   /* If the value is negative, compute its negative minus 1.  The latter
    6742              :      adjustment is because the absolute value of the largest negative value
    6743              :      is one larger than the largest positive value.  This is equivalent to
    6744              :      a bit-wise negation, so use that operation instead.  */
    6745              : 
    6746      3573051 :   if (tree_int_cst_sgn (value) < 0)
    6747       102004 :     value = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (value), value);
    6748              : 
    6749              :   /* Return the number of bits needed, taking into account the fact
    6750              :      that we need one more bit for a signed than unsigned type.
    6751              :      If value is 0 or -1, the minimum precision is 1 no matter
    6752              :      whether unsignedp is true or false.  */
    6753              : 
    6754      3573051 :   if (integer_zerop (value))
    6755              :     return 1;
    6756              :   else
    6757      5131228 :     return tree_floor_log2 (value) + 1 + (sgn == SIGNED ? 1 : 0) ;
    6758              : }
    6759              : 
    6760              : /* Return truthvalue of whether T1 is the same tree structure as T2.
    6761              :    Return 1 if they are the same.
    6762              :    Return 0 if they are understandably different.
    6763              :    Return -1 if either contains tree structure not understood by
    6764              :    this function.  */
    6765              : 
    6766              : int
    6767    199106145 : simple_cst_equal (const_tree t1, const_tree t2)
    6768              : {
    6769    202679631 :   enum tree_code code1, code2;
    6770    202679631 :   int cmp;
    6771    202679631 :   int i;
    6772              : 
    6773    202679631 :   if (t1 == t2)
    6774              :     return 1;
    6775    130357605 :   if (t1 == 0 || t2 == 0)
    6776              :     return 0;
    6777              : 
    6778              :   /* For location wrappers to be the same, they must be at the same
    6779              :      source location (and wrap the same thing).  */
    6780    121837414 :   if (location_wrapper_p (t1) && location_wrapper_p (t2))
    6781              :     {
    6782     12635882 :       if (EXPR_LOCATION (t1) != EXPR_LOCATION (t2))
    6783              :         return 0;
    6784          738 :       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6785              :     }
    6786              : 
    6787    109201532 :   code1 = TREE_CODE (t1);
    6788    109201532 :   code2 = TREE_CODE (t2);
    6789              : 
    6790    109201532 :   if (CONVERT_EXPR_CODE_P (code1) || code1 == NON_LVALUE_EXPR)
    6791              :     {
    6792      3561156 :       if (CONVERT_EXPR_CODE_P (code2)
    6793      3560475 :           || code2 == NON_LVALUE_EXPR)
    6794          681 :         return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6795              :       else
    6796      3560475 :         return simple_cst_equal (TREE_OPERAND (t1, 0), t2);
    6797              :     }
    6798              : 
    6799    105640376 :   else if (CONVERT_EXPR_CODE_P (code2)
    6800    105640361 :            || code2 == NON_LVALUE_EXPR)
    6801          113 :     return simple_cst_equal (t1, TREE_OPERAND (t2, 0));
    6802              : 
    6803    105640263 :   if (code1 != code2)
    6804              :     return 0;
    6805              : 
    6806    101404129 :   switch (code1)
    6807              :     {
    6808     91924282 :     case INTEGER_CST:
    6809     91924282 :       return wi::to_widest (t1) == wi::to_widest (t2);
    6810              : 
    6811           93 :     case REAL_CST:
    6812           93 :       return real_identical (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
    6813              : 
    6814            0 :     case FIXED_CST:
    6815            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1), TREE_FIXED_CST (t2));
    6816              : 
    6817      3189030 :     case STRING_CST:
    6818      3189030 :       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
    6819      3189030 :               && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
    6820      3654922 :                          TREE_STRING_LENGTH (t1)));
    6821              : 
    6822          218 :     case CONSTRUCTOR:
    6823          218 :       {
    6824          218 :         unsigned HOST_WIDE_INT idx;
    6825          218 :         vec<constructor_elt, va_gc> *v1 = CONSTRUCTOR_ELTS (t1);
    6826          218 :         vec<constructor_elt, va_gc> *v2 = CONSTRUCTOR_ELTS (t2);
    6827              : 
    6828          242 :         if (vec_safe_length (v1) != vec_safe_length (v2))
    6829              :           return 0;
    6830              : 
    6831          224 :         for (idx = 0; idx < vec_safe_length (v1); ++idx)
    6832              :           {
    6833           12 :             if ((*v1)[idx].index
    6834           12 :                 && TREE_CODE ((*v1)[idx].index) == FIELD_DECL)
    6835              :               {
    6836            9 :                 if ((*v1)[idx].index != (*v2)[idx].index)
    6837              :                   return 0;
    6838              :               }
    6839              :             else
    6840              :               {
    6841            3 :                 cmp = simple_cst_equal ((*v1)[idx].index, (*v2)[idx].index);
    6842            3 :                 if (cmp <= 0)
    6843              :                   return cmp;
    6844              :               }
    6845           12 :             cmp = simple_cst_equal ((*v1)[idx].value, (*v2)[idx].value);
    6846           12 :             if (cmp <= 0)
    6847              :               return cmp;
    6848              :           }
    6849              :         return 1;
    6850              :       }
    6851              : 
    6852            0 :     case SAVE_EXPR:
    6853            0 :       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6854              : 
    6855       197325 :     case CALL_EXPR:
    6856       197325 :       cmp = simple_cst_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2));
    6857       197325 :       if (cmp <= 0)
    6858              :         return cmp;
    6859        81275 :       if (call_expr_nargs (t1) != call_expr_nargs (t2))
    6860              :         return 0;
    6861        81275 :       {
    6862        81275 :         const_tree arg1, arg2;
    6863        81275 :         const_call_expr_arg_iterator iter1, iter2;
    6864       162550 :         for (arg1 = first_const_call_expr_arg (t1, &iter1),
    6865        81275 :                arg2 = first_const_call_expr_arg (t2, &iter2);
    6866        81309 :              arg1 && arg2;
    6867           34 :              arg1 = next_const_call_expr_arg (&iter1),
    6868           34 :                arg2 = next_const_call_expr_arg (&iter2))
    6869              :           {
    6870        81249 :             cmp = simple_cst_equal (arg1, arg2);
    6871        81249 :             if (cmp <= 0)
    6872              :               return cmp;
    6873              :           }
    6874           60 :         return arg1 == arg2;
    6875              :       }
    6876              : 
    6877        11271 :     case TARGET_EXPR:
    6878              :       /* Special case: if either target is an unallocated VAR_DECL,
    6879              :          it means that it's going to be unified with whatever the
    6880              :          TARGET_EXPR is really supposed to initialize, so treat it
    6881              :          as being equivalent to anything.  */
    6882        11271 :       if ((TREE_CODE (TREE_OPERAND (t1, 0)) == VAR_DECL
    6883        11271 :            && DECL_NAME (TREE_OPERAND (t1, 0)) == NULL_TREE
    6884        11271 :            && !DECL_RTL_SET_P (TREE_OPERAND (t1, 0)))
    6885        11271 :           || (TREE_CODE (TREE_OPERAND (t2, 0)) == VAR_DECL
    6886            0 :               && DECL_NAME (TREE_OPERAND (t2, 0)) == NULL_TREE
    6887            0 :               && !DECL_RTL_SET_P (TREE_OPERAND (t2, 0))))
    6888              :         cmp = 1;
    6889              :       else
    6890            0 :         cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6891              : 
    6892            0 :       if (cmp <= 0)
    6893              :         return cmp;
    6894              : 
    6895        11271 :       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
    6896              : 
    6897            0 :     case WITH_CLEANUP_EXPR:
    6898            0 :       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6899            0 :       if (cmp <= 0)
    6900              :         return cmp;
    6901              : 
    6902            0 :       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
    6903              : 
    6904          208 :     case COMPONENT_REF:
    6905          208 :       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
    6906          208 :         return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6907              : 
    6908              :       return 0;
    6909              : 
    6910              :     case VAR_DECL:
    6911              :     case PARM_DECL:
    6912              :     case CONST_DECL:
    6913              :     case FUNCTION_DECL:
    6914              :       return 0;
    6915              : 
    6916      6018768 :     default:
    6917      6018768 :       if (POLY_INT_CST_P (t1))
    6918              :         /* A false return means maybe_ne rather than known_ne.  */
    6919              :         return known_eq (poly_widest_int::from (poly_int_cst_value (t1),
    6920              :                                                 TYPE_SIGN (TREE_TYPE (t1))),
    6921              :                          poly_widest_int::from (poly_int_cst_value (t2),
    6922              :                                                 TYPE_SIGN (TREE_TYPE (t2))));
    6923      6018768 :       break;
    6924              :     }
    6925              : 
    6926              :   /* This general rule works for most tree codes.  All exceptions should be
    6927              :      handled above.  If this is a language-specific tree code, we can't
    6928              :      trust what might be in the operand, so say we don't know
    6929              :      the situation.  */
    6930      6018768 :   if ((int) code1 >= (int) LAST_AND_UNUSED_TREE_CODE)
    6931              :     return -1;
    6932              : 
    6933       845649 :   switch (TREE_CODE_CLASS (code1))
    6934              :     {
    6935              :     case tcc_unary:
    6936              :     case tcc_binary:
    6937              :     case tcc_comparison:
    6938              :     case tcc_expression:
    6939              :     case tcc_reference:
    6940              :     case tcc_statement:
    6941              :       cmp = 1;
    6942         1172 :       for (i = 0; i < TREE_CODE_LENGTH (code1); i++)
    6943              :         {
    6944          903 :           cmp = simple_cst_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
    6945          903 :           if (cmp <= 0)
    6946              :             return cmp;
    6947              :         }
    6948              : 
    6949              :       return cmp;
    6950              : 
    6951              :     default:
    6952              :       return -1;
    6953              :     }
    6954              : }
    6955              : 
    6956              : /* Compare the value of T, an INTEGER_CST, with U, an unsigned integer value.
    6957              :    Return -1, 0, or 1 if the value of T is less than, equal to, or greater
    6958              :    than U, respectively.  */
    6959              : 
    6960              : int
    6961   1478623606 : compare_tree_int (const_tree t, unsigned HOST_WIDE_INT u)
    6962              : {
    6963   1478623606 :   if (tree_int_cst_sgn (t) < 0)
    6964              :     return -1;
    6965   1478623328 :   else if (!tree_fits_uhwi_p (t))
    6966              :     return 1;
    6967   1478623303 :   else if (TREE_INT_CST_LOW (t) == u)
    6968              :     return 0;
    6969   1322075673 :   else if (TREE_INT_CST_LOW (t) < u)
    6970              :     return -1;
    6971              :   else
    6972     13242589 :     return 1;
    6973              : }
    6974              : 
    6975              : /* Return true if SIZE represents a constant size that is in bounds of
    6976              :    what the middle-end and the backend accepts (covering not more than
    6977              :    half of the address-space).
    6978              :    When PERR is non-null, set *PERR on failure to the description of
    6979              :    why SIZE is not valid.  */
    6980              : 
    6981              : bool
    6982     65713191 : valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
    6983              : {
    6984     65713191 :   if (POLY_INT_CST_P (size))
    6985              :     {
    6986              :       if (TREE_OVERFLOW (size))
    6987              :         return false;
    6988              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    6989              :         if (!valid_constant_size_p (POLY_INT_CST_COEFF (size, i)))
    6990              :           return false;
    6991              :       return true;
    6992              :     }
    6993              : 
    6994     65713191 :   cst_size_error error;
    6995     65713191 :   if (!perr)
    6996     60194808 :     perr = &error;
    6997              : 
    6998     65713191 :   if (TREE_CODE (size) != INTEGER_CST)
    6999              :     {
    7000            3 :       *perr = cst_size_not_constant;
    7001            3 :       return false;
    7002              :     }
    7003              : 
    7004     65713188 :   if (TREE_OVERFLOW_P (size))
    7005              :     {
    7006           60 :       *perr = cst_size_overflow;
    7007           60 :       return false;
    7008              :     }
    7009              : 
    7010     65713128 :   if (tree_int_cst_sgn (size) < 0)
    7011              :     {
    7012          442 :       *perr = cst_size_negative;
    7013          442 :       return false;
    7014              :     }
    7015    131425372 :   if (!tree_fits_uhwi_p (size)
    7016    197138058 :       || (wi::to_widest (TYPE_MAX_VALUE (sizetype))
    7017    197138058 :           < wi::to_widest (size) * 2))
    7018              :     {
    7019          624 :       *perr = cst_size_too_big;
    7020          624 :       return false;
    7021              :     }
    7022              : 
    7023              :   return true;
    7024              : }
    7025              : 
    7026              : /* Return the precision of the type, or for a complex or vector type the
    7027              :    precision of the type of its elements.  */
    7028              : 
    7029              : unsigned int
    7030   7391153821 : element_precision (const_tree type)
    7031              : {
    7032   7391153821 :   if (!TYPE_P (type))
    7033      6122374 :     type = TREE_TYPE (type);
    7034   7391153821 :   enum tree_code code = TREE_CODE (type);
    7035   7391153821 :   if (code == COMPLEX_TYPE || code == VECTOR_TYPE)
    7036     55406764 :     type = TREE_TYPE (type);
    7037              : 
    7038   7391153821 :   return TYPE_PRECISION (type);
    7039              : }
    7040              : 
    7041              : /* Return true if CODE represents an associative tree code.  Otherwise
    7042              :    return false.  */
    7043              : bool
    7044     34759046 : associative_tree_code (enum tree_code code)
    7045              : {
    7046     34759046 :   switch (code)
    7047              :     {
    7048              :     case BIT_IOR_EXPR:
    7049              :     case BIT_AND_EXPR:
    7050              :     case BIT_XOR_EXPR:
    7051              :     case PLUS_EXPR:
    7052              :     case MULT_EXPR:
    7053              :     case MIN_EXPR:
    7054              :     case MAX_EXPR:
    7055              :       return true;
    7056              : 
    7057     24349007 :     default:
    7058     24349007 :       break;
    7059              :     }
    7060     24349007 :   return false;
    7061              : }
    7062              : 
    7063              : /* Return true if CODE represents a commutative tree code.  Otherwise
    7064              :    return false.  */
    7065              : bool
    7066   1740578886 : commutative_tree_code (enum tree_code code)
    7067              : {
    7068   1740578886 :   switch (code)
    7069              :     {
    7070              :     case PLUS_EXPR:
    7071              :     case MULT_EXPR:
    7072              :     case MULT_HIGHPART_EXPR:
    7073              :     case MIN_EXPR:
    7074              :     case MAX_EXPR:
    7075              :     case BIT_IOR_EXPR:
    7076              :     case BIT_XOR_EXPR:
    7077              :     case BIT_AND_EXPR:
    7078              :     case NE_EXPR:
    7079              :     case EQ_EXPR:
    7080              :     case UNORDERED_EXPR:
    7081              :     case ORDERED_EXPR:
    7082              :     case UNEQ_EXPR:
    7083              :     case LTGT_EXPR:
    7084              :     case TRUTH_AND_EXPR:
    7085              :     case TRUTH_XOR_EXPR:
    7086              :     case TRUTH_OR_EXPR:
    7087              :     case WIDEN_MULT_EXPR:
    7088              :     case VEC_WIDEN_MULT_HI_EXPR:
    7089              :     case VEC_WIDEN_MULT_LO_EXPR:
    7090              :     case VEC_WIDEN_MULT_EVEN_EXPR:
    7091              :     case VEC_WIDEN_MULT_ODD_EXPR:
    7092              :       return true;
    7093              : 
    7094    925651698 :     default:
    7095    925651698 :       break;
    7096              :     }
    7097    925651698 :   return false;
    7098              : }
    7099              : 
    7100              : /* Return true if CODE represents a ternary tree code for which the
    7101              :    first two operands are commutative.  Otherwise return false.  */
    7102              : bool
    7103     87783913 : commutative_ternary_tree_code (enum tree_code code)
    7104              : {
    7105     87783913 :   switch (code)
    7106              :     {
    7107              :     case WIDEN_MULT_PLUS_EXPR:
    7108              :     case WIDEN_MULT_MINUS_EXPR:
    7109              :     case DOT_PROD_EXPR:
    7110              :       return true;
    7111              : 
    7112     87774413 :     default:
    7113     87774413 :       break;
    7114              :     }
    7115     87774413 :   return false;
    7116              : }
    7117              : 
    7118              : /* Returns true if CODE can overflow.  */
    7119              : 
    7120              : bool
    7121         2794 : operation_can_overflow (enum tree_code code)
    7122              : {
    7123         2794 :   switch (code)
    7124              :     {
    7125              :     case PLUS_EXPR:
    7126              :     case MINUS_EXPR:
    7127              :     case MULT_EXPR:
    7128              :     case LSHIFT_EXPR:
    7129              :       /* Can overflow in various ways.  */
    7130              :       return true;
    7131              :     case TRUNC_DIV_EXPR:
    7132              :     case EXACT_DIV_EXPR:
    7133              :     case FLOOR_DIV_EXPR:
    7134              :     case CEIL_DIV_EXPR:
    7135              :       /* For INT_MIN / -1.  */
    7136              :       return true;
    7137              :     case NEGATE_EXPR:
    7138              :     case ABS_EXPR:
    7139              :       /* For -INT_MIN.  */
    7140              :       return true;
    7141          159 :     default:
    7142              :       /* These operators cannot overflow.  */
    7143          159 :       return false;
    7144              :     }
    7145              : }
    7146              : 
    7147              : /* Returns true if CODE operating on operands of type TYPE doesn't overflow, or
    7148              :    ftrapv doesn't generate trapping insns for CODE.  */
    7149              : 
    7150              : bool
    7151      5962727 : operation_no_trapping_overflow (tree type, enum tree_code code)
    7152              : {
    7153      5962727 :   gcc_checking_assert (ANY_INTEGRAL_TYPE_P (type));
    7154              : 
    7155              :   /* We don't generate instructions that trap on overflow for complex or vector
    7156              :      types.  */
    7157      5962727 :   if (!INTEGRAL_TYPE_P (type))
    7158              :     return true;
    7159              : 
    7160      5962727 :   if (!TYPE_OVERFLOW_TRAPS (type))
    7161              :     return true;
    7162              : 
    7163         1345 :   switch (code)
    7164              :     {
    7165              :     case PLUS_EXPR:
    7166              :     case MINUS_EXPR:
    7167              :     case MULT_EXPR:
    7168              :     case NEGATE_EXPR:
    7169              :     case ABS_EXPR:
    7170              :       /* These operators can overflow, and -ftrapv generates trapping code for
    7171              :          these.  */
    7172              :       return false;
    7173              :     case TRUNC_DIV_EXPR:
    7174              :     case EXACT_DIV_EXPR:
    7175              :     case FLOOR_DIV_EXPR:
    7176              :     case CEIL_DIV_EXPR:
    7177              :     case LSHIFT_EXPR:
    7178              :       /* These operators can overflow, but -ftrapv does not generate trapping
    7179              :          code for these.  */
    7180              :       return true;
    7181              :     default:
    7182              :       /* These operators cannot overflow.  */
    7183              :       return true;
    7184              :     }
    7185              : }
    7186              : 
    7187              : /* Constructors for pointer, array and function types.
    7188              :    (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
    7189              :    constructed by language-dependent code, not here.)  */
    7190              : 
    7191              : /* Construct, lay out and return the type of pointers to TO_TYPE with
    7192              :    mode MODE.  If MODE is VOIDmode, a pointer mode for the address
    7193              :    space of TO_TYPE will be picked.  If CAN_ALIAS_ALL is TRUE,
    7194              :    indicate this type can reference all of memory. If such a type has
    7195              :    already been constructed, reuse it.  */
    7196              : 
    7197              : tree
    7198   2485486898 : build_pointer_type_for_mode (tree to_type, machine_mode mode,
    7199              :                              bool can_alias_all)
    7200              : {
    7201   2485486898 :   tree t;
    7202   2485486898 :   bool could_alias = can_alias_all;
    7203              : 
    7204   2485486898 :   if (to_type == error_mark_node)
    7205              :     return error_mark_node;
    7206              : 
    7207   2485486892 :   if (mode == VOIDmode)
    7208              :     {
    7209   2359676604 :       addr_space_t as = TYPE_ADDR_SPACE (to_type);
    7210   2359676604 :       mode = targetm.addr_space.pointer_mode (as);
    7211              :     }
    7212              : 
    7213              :   /* If the pointed-to type has the may_alias attribute set, force
    7214              :      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
    7215   2485486892 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
    7216      4359570 :     can_alias_all = true;
    7217              : 
    7218              :   /* In some cases, languages will have things that aren't a POINTER_TYPE
    7219              :      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
    7220              :      In that case, return that type without regard to the rest of our
    7221              :      operands.
    7222              : 
    7223              :      ??? This is a kludge, but consistent with the way this function has
    7224              :      always operated and there doesn't seem to be a good way to avoid this
    7225              :      at the moment.  */
    7226   2485486892 :   if (TYPE_POINTER_TO (to_type) != 0
    7227   2485486892 :       && TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
    7228        43561 :     return TYPE_POINTER_TO (to_type);
    7229              : 
    7230              :   /* First, if we already have a type for pointers to TO_TYPE and it's
    7231              :      the proper mode, use it.  */
    7232   2486071225 :   for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
    7233   2338980369 :     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
    7234              :       return t;
    7235              : 
    7236    147090856 :   t = make_node (POINTER_TYPE);
    7237              : 
    7238    147090856 :   TREE_TYPE (t) = to_type;
    7239    147090856 :   SET_TYPE_MODE (t, mode);
    7240    147090856 :   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
    7241    147090856 :   TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
    7242    147090856 :   TYPE_POINTER_TO (to_type) = t;
    7243              : 
    7244              :   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
    7245    147090856 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)
    7246      5457972 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7247    141632884 :   else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
    7248     42248806 :     TYPE_CANONICAL (t)
    7249     84497612 :       = build_pointer_type_for_mode (TYPE_CANONICAL (to_type),
    7250              :                                      mode, false);
    7251              : 
    7252              :   /* Lay out the type.  This function has many callers that are concerned
    7253              :      with expression-construction, and this simplifies them all.  */
    7254    147090856 :   layout_type (t);
    7255              : 
    7256    147090856 :   return t;
    7257              : }
    7258              : 
    7259              : /* By default build pointers in ptr_mode.  */
    7260              : 
    7261              : tree
    7262   2358979623 : build_pointer_type (tree to_type)
    7263              : {
    7264   2358979623 :   return build_pointer_type_for_mode (to_type, VOIDmode, false);
    7265              : }
    7266              : 
    7267              : /* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE.  */
    7268              : 
    7269              : tree
    7270    689160593 : build_reference_type_for_mode (tree to_type, machine_mode mode,
    7271              :                                bool can_alias_all)
    7272              : {
    7273    689160593 :   tree t;
    7274    689160593 :   bool could_alias = can_alias_all;
    7275              : 
    7276    689160593 :   if (to_type == error_mark_node)
    7277              :     return error_mark_node;
    7278              : 
    7279    689160593 :   if (mode == VOIDmode)
    7280              :     {
    7281    545127045 :       addr_space_t as = TYPE_ADDR_SPACE (to_type);
    7282    545127045 :       mode = targetm.addr_space.pointer_mode (as);
    7283              :     }
    7284              : 
    7285              :   /* If the pointed-to type has the may_alias attribute set, force
    7286              :      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
    7287    689160593 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
    7288       726196 :     can_alias_all = true;
    7289              : 
    7290              :   /* In some cases, languages will have things that aren't a REFERENCE_TYPE
    7291              :      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_REFERENCE_TO.
    7292              :      In that case, return that type without regard to the rest of our
    7293              :      operands.
    7294              : 
    7295              :      ??? This is a kludge, but consistent with the way this function has
    7296              :      always operated and there doesn't seem to be a good way to avoid this
    7297              :      at the moment.  */
    7298    689160593 :   if (TYPE_REFERENCE_TO (to_type) != 0
    7299    689160593 :       && TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
    7300            0 :     return TYPE_REFERENCE_TO (to_type);
    7301              : 
    7302              :   /* First, if we already have a type for pointers to TO_TYPE and it's
    7303              :      the proper mode, use it.  */
    7304    689160593 :   for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
    7305    600592344 :     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
    7306              :       return t;
    7307              : 
    7308     88568249 :   t = make_node (REFERENCE_TYPE);
    7309              : 
    7310     88568249 :   TREE_TYPE (t) = to_type;
    7311     88568249 :   SET_TYPE_MODE (t, mode);
    7312     88568249 :   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
    7313     88568249 :   TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (to_type);
    7314     88568249 :   TYPE_REFERENCE_TO (to_type) = t;
    7315              : 
    7316              :   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
    7317     88568249 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)
    7318      4826806 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7319     83741443 :   else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
    7320     49501204 :     TYPE_CANONICAL (t)
    7321     99002408 :       = build_reference_type_for_mode (TYPE_CANONICAL (to_type),
    7322              :                                        mode, false);
    7323              : 
    7324     88568249 :   layout_type (t);
    7325              : 
    7326     88568249 :   return t;
    7327              : }
    7328              : 
    7329              : 
    7330              : /* Build the node for the type of references-to-TO_TYPE by default
    7331              :    in ptr_mode.  */
    7332              : 
    7333              : tree
    7334     26193894 : build_reference_type (tree to_type)
    7335              : {
    7336     26193894 :   return build_reference_type_for_mode (to_type, VOIDmode, false);
    7337              : }
    7338              : 
    7339              : #define MAX_INT_CACHED_PREC \
    7340              :   (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
    7341              : static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2];
    7342              : 
    7343              : static void
    7344       268600 : clear_nonstandard_integer_type_cache (void)
    7345              : {
    7346     35186600 :   for (size_t i = 0 ; i < 2 * MAX_INT_CACHED_PREC + 2 ; i++)
    7347              :   {
    7348     34918000 :     nonstandard_integer_type_cache[i] = NULL;
    7349              :   }
    7350            0 : }
    7351              : 
    7352              : /* Builds a signed or unsigned integer type of precision PRECISION.
    7353              :    Used for C bitfields whose precision does not match that of
    7354              :    built-in target types.  */
    7355              : tree
    7356     60182017 : build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
    7357              :                                 int unsignedp)
    7358              : {
    7359     60182017 :   tree itype, ret;
    7360              : 
    7361     60182017 :   if (unsignedp)
    7362     50735734 :     unsignedp = MAX_INT_CACHED_PREC + 1;
    7363              : 
    7364     60182017 :   if (precision <= MAX_INT_CACHED_PREC)
    7365              :     {
    7366     59825562 :       itype = nonstandard_integer_type_cache[precision + unsignedp];
    7367     59825562 :       if (itype)
    7368              :         return itype;
    7369              :     }
    7370              : 
    7371      1069717 :   itype = make_node (INTEGER_TYPE);
    7372      1069717 :   TYPE_PRECISION (itype) = precision;
    7373              : 
    7374      1069717 :   if (unsignedp)
    7375       697471 :     fixup_unsigned_type (itype);
    7376              :   else
    7377       372246 :     fixup_signed_type (itype);
    7378              : 
    7379      1069717 :   inchash::hash hstate;
    7380      1069717 :   inchash::add_expr (TYPE_MAX_VALUE (itype), hstate);
    7381      1069717 :   ret = type_hash_canon (hstate.end (), itype);
    7382      1069717 :   if (precision <= MAX_INT_CACHED_PREC)
    7383       713262 :     nonstandard_integer_type_cache[precision + unsignedp] = ret;
    7384              : 
    7385              :   return ret;
    7386              : }
    7387              : 
    7388              : #define MAX_BOOL_CACHED_PREC \
    7389              :   (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
    7390              : static GTY(()) tree nonstandard_boolean_type_cache[MAX_BOOL_CACHED_PREC + 1];
    7391              : 
    7392              : /* Builds a boolean type of precision PRECISION.
    7393              :    Used for boolean vectors to choose proper vector element size.  */
    7394              : tree
    7395      2566125 : build_nonstandard_boolean_type (unsigned HOST_WIDE_INT precision)
    7396              : {
    7397      2566125 :   tree type;
    7398              : 
    7399      2566125 :   if (precision <= MAX_BOOL_CACHED_PREC)
    7400              :     {
    7401      2562129 :       type = nonstandard_boolean_type_cache[precision];
    7402      2562129 :       if (type)
    7403              :         return type;
    7404              :     }
    7405              : 
    7406        81293 :   type = make_node (BOOLEAN_TYPE);
    7407        81293 :   TYPE_PRECISION (type) = precision;
    7408        81293 :   fixup_signed_type (type);
    7409              : 
    7410        81293 :   if (precision <= MAX_INT_CACHED_PREC)
    7411        77297 :     nonstandard_boolean_type_cache[precision] = type;
    7412              : 
    7413              :   return type;
    7414              : }
    7415              : 
    7416              : static GTY(()) vec<tree, va_gc> *bitint_type_cache;
    7417              : 
    7418              : /* Builds a signed or unsigned _BitInt(PRECISION) type.  */
    7419              : tree
    7420        75322 : build_bitint_type (unsigned HOST_WIDE_INT precision, int unsignedp)
    7421              : {
    7422        75322 :   tree itype, ret;
    7423              : 
    7424        75322 :   gcc_checking_assert (precision >= 1);
    7425              : 
    7426        75322 :   if (unsignedp)
    7427        37114 :     unsignedp = MAX_INT_CACHED_PREC + 1;
    7428              : 
    7429        75322 :   if (bitint_type_cache == NULL)
    7430          600 :     vec_safe_grow_cleared (bitint_type_cache, 2 * MAX_INT_CACHED_PREC + 2);
    7431              : 
    7432        75322 :   if (precision <= MAX_INT_CACHED_PREC)
    7433              :     {
    7434        16534 :       itype = (*bitint_type_cache)[precision + unsignedp];
    7435        16534 :       if (itype)
    7436              :         return itype;
    7437              :     }
    7438              : 
    7439        60544 :   itype = make_node (BITINT_TYPE);
    7440        60544 :   TYPE_PRECISION (itype) = precision;
    7441              : 
    7442        60544 :   if (unsignedp)
    7443        30291 :     fixup_unsigned_type (itype);
    7444              :   else
    7445        30253 :     fixup_signed_type (itype);
    7446              : 
    7447        60544 :   hashval_t hash = type_hash_canon_hash (itype);
    7448        60544 :   ret = type_hash_canon (hash, itype);
    7449        60544 :   if (precision <= MAX_INT_CACHED_PREC)
    7450         1756 :     (*bitint_type_cache)[precision + unsignedp] = ret;
    7451              : 
    7452              :   return ret;
    7453              : }
    7454              : 
    7455              : /* Create a range of some discrete type TYPE (an INTEGER_TYPE, ENUMERAL_TYPE
    7456              :    or BOOLEAN_TYPE) with low bound LOWVAL and high bound HIGHVAL.  If SHARED
    7457              :    is true, reuse such a type that has already been constructed.  */
    7458              : 
    7459              : static tree
    7460     43132916 : build_range_type_1 (tree type, tree lowval, tree highval, bool shared)
    7461              : {
    7462     43132916 :   tree itype = make_node (INTEGER_TYPE);
    7463              : 
    7464     43132916 :   TREE_TYPE (itype) = type;
    7465              : 
    7466     43132916 :   TYPE_MIN_VALUE (itype) = fold_convert (type, lowval);
    7467     43132916 :   TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL;
    7468              : 
    7469     43132916 :   TYPE_PRECISION (itype) = TYPE_PRECISION (type);
    7470     43132916 :   SET_TYPE_MODE (itype, TYPE_MODE (type));
    7471     43132916 :   TYPE_SIZE (itype) = TYPE_SIZE (type);
    7472     43132916 :   TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type);
    7473     43132916 :   SET_TYPE_ALIGN (itype, TYPE_ALIGN (type));
    7474     43132916 :   TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type);
    7475     43132916 :   SET_TYPE_WARN_IF_NOT_ALIGN (itype, TYPE_WARN_IF_NOT_ALIGN (type));
    7476              : 
    7477     43132916 :   if (!shared)
    7478              :     return itype;
    7479              : 
    7480     43132916 :   if ((TYPE_MIN_VALUE (itype)
    7481     43132916 :        && TREE_CODE (TYPE_MIN_VALUE (itype)) != INTEGER_CST)
    7482     86264995 :       || (TYPE_MAX_VALUE (itype)
    7483     42580775 :           && TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST))
    7484              :     {
    7485              :       /* Since we cannot reliably merge this type, we need to compare it using
    7486              :          structural equality checks.  */
    7487      1140798 :       SET_TYPE_STRUCTURAL_EQUALITY (itype);
    7488      1140798 :       return itype;
    7489              :     }
    7490              : 
    7491     41992118 :   hashval_t hash = type_hash_canon_hash (itype);
    7492     41992118 :   itype = type_hash_canon (hash, itype);
    7493              : 
    7494     41992118 :   return itype;
    7495              : }
    7496              : 
    7497              : /* Wrapper around build_range_type_1 with SHARED set to true.  */
    7498              : 
    7499              : tree
    7500     43132916 : build_range_type (tree type, tree lowval, tree highval)
    7501              : {
    7502     43132916 :   return build_range_type_1 (type, lowval, highval, true);
    7503              : }
    7504              : 
    7505              : /* Wrapper around build_range_type_1 with SHARED set to false.  */
    7506              : 
    7507              : tree
    7508            0 : build_nonshared_range_type (tree type, tree lowval, tree highval)
    7509              : {
    7510            0 :   return build_range_type_1 (type, lowval, highval, false);
    7511              : }
    7512              : 
    7513              : /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
    7514              :    MAXVAL should be the maximum value in the domain
    7515              :    (one less than the length of the array).
    7516              : 
    7517              :    The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
    7518              :    We don't enforce this limit, that is up to caller (e.g. language front end).
    7519              :    The limit exists because the result is a signed type and we don't handle
    7520              :    sizes that use more than one HOST_WIDE_INT.  */
    7521              : 
    7522              : tree
    7523     40280533 : build_index_type (tree maxval)
    7524              : {
    7525     40280533 :   return build_range_type (sizetype, size_zero_node, maxval);
    7526              : }
    7527              : 
    7528              : /* Return true if the debug information for TYPE, a subtype, should be emitted
    7529              :    as a subrange type.  If so, set LOWVAL to the low bound and HIGHVAL to the
    7530              :    high bound, respectively.  Sometimes doing so unnecessarily obfuscates the
    7531              :    debug info and doesn't reflect the source code.  */
    7532              : 
    7533              : bool
    7534           18 : subrange_type_for_debug_p (const_tree type, tree *lowval, tree *highval)
    7535              : {
    7536           18 :   tree base_type = TREE_TYPE (type), low, high;
    7537              : 
    7538              :   /* Subrange types have a base type which is an integral type.  */
    7539           18 :   if (!INTEGRAL_TYPE_P (base_type))
    7540              :     return false;
    7541              : 
    7542              :   /* Get the real bounds of the subtype.  */
    7543           18 :   if (lang_hooks.types.get_subrange_bounds)
    7544            0 :     lang_hooks.types.get_subrange_bounds (type, &low, &high);
    7545              :   else
    7546              :     {
    7547           18 :       low = TYPE_MIN_VALUE (type);
    7548           18 :       high = TYPE_MAX_VALUE (type);
    7549              :     }
    7550              : 
    7551              :   /* If the type and its base type have the same representation and the same
    7552              :      name, then the type is not a subrange but a copy of the base type.  */
    7553           18 :   if ((TREE_CODE (base_type) == INTEGER_TYPE
    7554           18 :        || TREE_CODE (base_type) == BOOLEAN_TYPE)
    7555           18 :       && int_size_in_bytes (type) == int_size_in_bytes (base_type)
    7556           18 :       && tree_int_cst_equal (low, TYPE_MIN_VALUE (base_type))
    7557            0 :       && tree_int_cst_equal (high, TYPE_MAX_VALUE (base_type))
    7558           18 :       && TYPE_IDENTIFIER (type) == TYPE_IDENTIFIER (base_type))
    7559              :     return false;
    7560              : 
    7561           18 :   if (lowval)
    7562           18 :     *lowval = low;
    7563           18 :   if (highval)
    7564           18 :     *highval = high;
    7565              :   return true;
    7566              : }
    7567              : 
    7568              : /* Construct, lay out and return the type of arrays of elements with ELT_TYPE
    7569              :    and number of elements specified by the range of values of INDEX_TYPE.
    7570              :    If TYPELESS_STORAGE is true, TYPE_TYPELESS_STORAGE flag is set on the type.
    7571              :    If SHARED is true, reuse such a type that has already been constructed.
    7572              :    If SET_CANONICAL is true, compute TYPE_CANONICAL from the element type.  */
    7573              : 
    7574              : tree
    7575     69759988 : build_array_type_1 (tree elt_type, tree index_type, bool typeless_storage,
    7576              :                     bool shared, bool set_canonical)
    7577              : {
    7578     69759988 :   tree t;
    7579              : 
    7580     69759988 :   if (TREE_CODE (elt_type) == FUNCTION_TYPE)
    7581              :     {
    7582            0 :       error ("arrays of functions are not meaningful");
    7583            0 :       elt_type = integer_type_node;
    7584              :     }
    7585              : 
    7586     69759988 :   t = make_node (ARRAY_TYPE);
    7587     69759988 :   TREE_TYPE (t) = elt_type;
    7588     69759988 :   TYPE_DOMAIN (t) = index_type;
    7589     69759988 :   TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (elt_type);
    7590     69759988 :   TYPE_TYPELESS_STORAGE (t) = typeless_storage;
    7591              : 
    7592              :   /* Set TYPE_STRUCTURAL_EQUALITY_P.  */
    7593     69759988 :   if (set_canonical
    7594     69759988 :       && (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    7595     69720807 :           || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
    7596     69453004 :           || in_lto_p))
    7597       382213 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7598              : 
    7599     69759988 :   layout_type (t);
    7600              : 
    7601     69759988 :   if (shared)
    7602              :     {
    7603     69759959 :       hashval_t hash = type_hash_canon_hash (t);
    7604     69759959 :       tree probe_type = t;
    7605     69759959 :       t = type_hash_canon (hash, t);
    7606     69759959 :       if (t != probe_type)
    7607              :         return t;
    7608              :     }
    7609              : 
    7610     10904448 :   if (TYPE_CANONICAL (t) == t && set_canonical)
    7611              :     {
    7612     10571286 :       if (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    7613     10571286 :           || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
    7614     21142572 :           || in_lto_p)
    7615            0 :         gcc_unreachable ();
    7616     10571286 :       else if (TYPE_CANONICAL (elt_type) != elt_type
    7617     10571286 :                || (index_type && TYPE_CANONICAL (index_type) != index_type))
    7618       106058 :         TYPE_CANONICAL (t)
    7619       307730 :           = build_array_type_1 (TYPE_CANONICAL (elt_type),
    7620              :                                 index_type
    7621        95614 :                                 ? TYPE_CANONICAL (index_type) : NULL_TREE,
    7622              :                                 typeless_storage, shared, set_canonical);
    7623              :     }
    7624              : 
    7625              :   return t;
    7626              : }
    7627              : 
    7628              : /* Wrapper around build_array_type_1 with SHARED set to true.  */
    7629              : 
    7630              : tree
    7631     69653901 : build_array_type (tree elt_type, tree index_type, bool typeless_storage)
    7632              : {
    7633     69653901 :   return
    7634     69653901 :     build_array_type_1 (elt_type, index_type, typeless_storage, true, true);
    7635              : }
    7636              : 
    7637              : /* Wrapper around build_array_type_1 with SHARED set to false.  */
    7638              : 
    7639              : tree
    7640            0 : build_nonshared_array_type (tree elt_type, tree index_type)
    7641              : {
    7642            0 :   return build_array_type_1 (elt_type, index_type, false, false, true);
    7643              : }
    7644              : 
    7645              : /* Return a representation of ELT_TYPE[NELTS], using indices of type
    7646              :    sizetype.  */
    7647              : 
    7648              : tree
    7649      1624329 : build_array_type_nelts (tree elt_type, poly_uint64 nelts)
    7650              : {
    7651      1624329 :   return build_array_type (elt_type, build_index_type (size_int (nelts - 1)));
    7652              : }
    7653              : 
    7654              : /* Computes the canonical argument types from the argument type list
    7655              :    ARGTYPES.
    7656              : 
    7657              :    Upon return, *ANY_STRUCTURAL_P will be true iff either it was true
    7658              :    on entry to this function, or if any of the ARGTYPES are
    7659              :    structural.
    7660              : 
    7661              :    Upon return, *ANY_NONCANONICAL_P will be true iff either it was
    7662              :    true on entry to this function, or if any of the ARGTYPES are
    7663              :    non-canonical.
    7664              : 
    7665              :    Returns a canonical argument list, which may be ARGTYPES when the
    7666              :    canonical argument list is unneeded (i.e., *ANY_STRUCTURAL_P is
    7667              :    true) or would not differ from ARGTYPES.  */
    7668              : 
    7669              : static tree
    7670    974381347 : maybe_canonicalize_argtypes (tree argtypes,
    7671              :                              bool *any_structural_p,
    7672              :                              bool *any_noncanonical_p)
    7673              : {
    7674    974381347 :   tree arg;
    7675    974381347 :   bool any_noncanonical_argtypes_p = false;
    7676              : 
    7677   3361607336 :   for (arg = argtypes; arg && !(*any_structural_p); arg = TREE_CHAIN (arg))
    7678              :     {
    7679   2387225989 :       if (!TREE_VALUE (arg) || TREE_VALUE (arg) == error_mark_node)
    7680              :         /* Fail gracefully by stating that the type is structural.  */
    7681         4722 :         *any_structural_p = true;
    7682   2387221267 :       else if (TYPE_STRUCTURAL_EQUALITY_P (TREE_VALUE (arg)))
    7683     34734732 :         *any_structural_p = true;
    7684   2352486535 :       else if (TYPE_CANONICAL (TREE_VALUE (arg)) != TREE_VALUE (arg)
    7685   2352486535 :                || TREE_PURPOSE (arg))
    7686              :         /* If the argument has a default argument, we consider it
    7687              :            non-canonical even though the type itself is canonical.
    7688              :            That way, different variants of function and method types
    7689              :            with default arguments will all point to the variant with
    7690              :            no defaults as their canonical type.  */
    7691              :         any_noncanonical_argtypes_p = true;
    7692              :     }
    7693              : 
    7694    974381347 :   if (*any_structural_p)
    7695              :     return argtypes;
    7696              : 
    7697    878881564 :   if (any_noncanonical_argtypes_p)
    7698              :     {
    7699              :       /* Build the canonical list of argument types.  */
    7700              :       tree canon_argtypes = NULL_TREE;
    7701              :       bool is_void = false;
    7702              : 
    7703    858287553 :       for (arg = argtypes; arg; arg = TREE_CHAIN (arg))
    7704              :         {
    7705    659130620 :           if (arg == void_list_node)
    7706              :             is_void = true;
    7707              :           else
    7708    921959334 :             canon_argtypes = tree_cons (NULL_TREE,
    7709    460979667 :                                         TYPE_CANONICAL (TREE_VALUE (arg)),
    7710              :                                         canon_argtypes);
    7711              :         }
    7712              : 
    7713    199156933 :       canon_argtypes = nreverse (canon_argtypes);
    7714    199156933 :       if (is_void)
    7715    198150953 :         canon_argtypes = chainon (canon_argtypes, void_list_node);
    7716              : 
    7717              :       /* There is a non-canonical type.  */
    7718    199156933 :       *any_noncanonical_p = true;
    7719    199156933 :       return canon_argtypes;
    7720              :     }
    7721              : 
    7722              :   /* The canonical argument types are the same as ARGTYPES.  */
    7723              :   return argtypes;
    7724              : }
    7725              : 
    7726              : /* Construct, lay out and return
    7727              :    the type of functions returning type VALUE_TYPE
    7728              :    given arguments of types ARG_TYPES.
    7729              :    ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs
    7730              :    are data type nodes for the arguments of the function.
    7731              :    NO_NAMED_ARGS_STDARG_P is true if this is a prototyped
    7732              :    variable-arguments function with (...) prototype (no named arguments).
    7733              :    If such a type has already been constructed, reuse it.  */
    7734              : 
    7735              : tree
    7736    648406046 : build_function_type (tree value_type, tree arg_types,
    7737              :                      bool no_named_args_stdarg_p)
    7738              : {
    7739    648406046 :   tree t;
    7740    648406046 :   inchash::hash hstate;
    7741    648406046 :   bool any_structural_p, any_noncanonical_p;
    7742    648406046 :   tree canon_argtypes;
    7743              : 
    7744    648406046 :   gcc_assert (arg_types != error_mark_node);
    7745              : 
    7746    648406046 :   if (TREE_CODE (value_type) == FUNCTION_TYPE)
    7747              :     {
    7748            0 :       error ("function return type cannot be function");
    7749            0 :       value_type = integer_type_node;
    7750              :     }
    7751              : 
    7752              :   /* Make a node of the sort we want.  */
    7753    648406046 :   t = make_node (FUNCTION_TYPE);
    7754    648406046 :   TREE_TYPE (t) = value_type;
    7755    648406046 :   TYPE_ARG_TYPES (t) = arg_types;
    7756    648406046 :   if (no_named_args_stdarg_p)
    7757              :     {
    7758       836784 :       gcc_assert (arg_types == NULL_TREE);
    7759       836784 :       TYPE_NO_NAMED_ARGS_STDARG_P (t) = 1;
    7760              :     }
    7761              : 
    7762              :   /* Set up the canonical type. */
    7763    648406046 :   any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
    7764    648406046 :   any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
    7765    648406046 :   canon_argtypes = maybe_canonicalize_argtypes (arg_types,
    7766              :                                                 &any_structural_p,
    7767              :                                                 &any_noncanonical_p);
    7768              :   /* Set TYPE_STRUCTURAL_EQUALITY_P early.  */
    7769    648406046 :   if (any_structural_p)
    7770     70190218 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7771              : 
    7772              :   /* If we already have such a type, use the old one.  */
    7773    648406046 :   hashval_t hash = type_hash_canon_hash (t);
    7774    648406046 :   tree probe_type = t;
    7775    648406046 :   t = type_hash_canon (hash, t);
    7776    648406046 :   if (t != probe_type)
    7777              :     return t;
    7778              : 
    7779    420484297 :   if (any_structural_p)
    7780     57216184 :     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
    7781    363268113 :   else if (any_noncanonical_p)
    7782     85103832 :     TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
    7783              :                                               canon_argtypes,
    7784              :                                               no_named_args_stdarg_p);
    7785              : 
    7786    420484297 :   if (!COMPLETE_TYPE_P (t))
    7787            0 :     layout_type (t);
    7788              :   return t;
    7789              : }
    7790              : 
    7791              : /* Build a function type.  The RETURN_TYPE is the type returned by the
    7792              :    function.  If VAARGS is set, no void_type_node is appended to the
    7793              :    list.  ARGP must be always be terminated be a NULL_TREE.  */
    7794              : 
    7795              : static tree
    7796     15402668 : build_function_type_list_1 (bool vaargs, tree return_type, va_list argp)
    7797              : {
    7798     15402668 :   tree t, args, last;
    7799              : 
    7800     15402668 :   t = va_arg (argp, tree);
    7801     65081531 :   for (args = NULL_TREE; t != NULL_TREE; t = va_arg (argp, tree))
    7802     34276195 :     args = tree_cons (NULL_TREE, t, args);
    7803              : 
    7804     15402668 :   if (vaargs)
    7805              :     {
    7806       960629 :       last = args;
    7807       960629 :       if (args != NULL_TREE)
    7808       828591 :         args = nreverse (args);
    7809       960629 :       gcc_assert (last != void_list_node);
    7810              :     }
    7811     14442039 :   else if (args == NULL_TREE)
    7812      1202941 :     args = void_list_node;
    7813              :   else
    7814              :     {
    7815     13239098 :       last = args;
    7816     13239098 :       args = nreverse (args);
    7817     13239098 :       TREE_CHAIN (last) = void_list_node;
    7818              :     }
    7819     15402668 :   args = build_function_type (return_type, args, vaargs && args == NULL_TREE);
    7820              : 
    7821     15402668 :   return args;
    7822              : }
    7823              : 
    7824              : /* Build a function type.  The RETURN_TYPE is the type returned by the
    7825              :    function.  If additional arguments are provided, they are
    7826              :    additional argument types.  The list of argument types must always
    7827              :    be terminated by NULL_TREE.  */
    7828              : 
    7829              : tree
    7830     14442039 : build_function_type_list (tree return_type, ...)
    7831              : {
    7832     14442039 :   tree args;
    7833     14442039 :   va_list p;
    7834              : 
    7835     14442039 :   va_start (p, return_type);
    7836     14442039 :   args = build_function_type_list_1 (false, return_type, p);
    7837     14442039 :   va_end (p);
    7838     14442039 :   return args;
    7839              : }
    7840              : 
    7841              : /* Build a variable argument function type.  The RETURN_TYPE is the
    7842              :    type returned by the function.  If additional arguments are provided,
    7843              :    they are additional argument types.  The list of argument types must
    7844              :    always be terminated by NULL_TREE.  */
    7845              : 
    7846              : tree
    7847       960629 : build_varargs_function_type_list (tree return_type, ...)
    7848              : {
    7849       960629 :   tree args;
    7850       960629 :   va_list p;
    7851              : 
    7852       960629 :   va_start (p, return_type);
    7853       960629 :   args = build_function_type_list_1 (true, return_type, p);
    7854       960629 :   va_end (p);
    7855              : 
    7856       960629 :   return args;
    7857              : }
    7858              : 
    7859              : /* Build a function type.  RETURN_TYPE is the type returned by the
    7860              :    function; VAARGS indicates whether the function takes varargs.  The
    7861              :    function takes N named arguments, the types of which are provided in
    7862              :    ARG_TYPES.  */
    7863              : 
    7864              : static tree
    7865    121883043 : build_function_type_array_1 (bool vaargs, tree return_type, int n,
    7866              :                              tree *arg_types)
    7867              : {
    7868    121883043 :   int i;
    7869    121883043 :   tree t = vaargs ? NULL_TREE : void_list_node;
    7870              : 
    7871    399654762 :   for (i = n - 1; i >= 0; i--)
    7872    277771719 :     t = tree_cons (NULL_TREE, arg_types[i], t);
    7873              : 
    7874    121883043 :   return build_function_type (return_type, t, vaargs && n == 0);
    7875              : }
    7876              : 
    7877              : /* Build a function type.  RETURN_TYPE is the type returned by the
    7878              :    function.  The function takes N named arguments, the types of which
    7879              :    are provided in ARG_TYPES.  */
    7880              : 
    7881              : tree
    7882    115329194 : build_function_type_array (tree return_type, int n, tree *arg_types)
    7883              : {
    7884    115329194 :   return build_function_type_array_1 (false, return_type, n, arg_types);
    7885              : }
    7886              : 
    7887              : /* Build a variable argument function type.  RETURN_TYPE is the type
    7888              :    returned by the function.  The function takes N named arguments, the
    7889              :    types of which are provided in ARG_TYPES.  */
    7890              : 
    7891              : tree
    7892      6553849 : build_varargs_function_type_array (tree return_type, int n, tree *arg_types)
    7893              : {
    7894      6553849 :   return build_function_type_array_1 (true, return_type, n, arg_types);
    7895              : }
    7896              : 
    7897              : /* Build a METHOD_TYPE for a member of BASETYPE.  The RETTYPE (a TYPE)
    7898              :    and ARGTYPES (a TREE_LIST) are the return type and arguments types
    7899              :    for the method.  An implicit additional parameter (of type
    7900              :    pointer-to-BASETYPE) is added to the ARGTYPES.  */
    7901              : 
    7902              : tree
    7903    325975301 : build_method_type_directly (tree basetype,
    7904              :                             tree rettype,
    7905              :                             tree argtypes)
    7906              : {
    7907    325975301 :   tree t;
    7908    325975301 :   tree ptype;
    7909    325975301 :   bool any_structural_p, any_noncanonical_p;
    7910    325975301 :   tree canon_argtypes;
    7911              : 
    7912              :   /* Make a node of the sort we want.  */
    7913    325975301 :   t = make_node (METHOD_TYPE);
    7914              : 
    7915    325975301 :   TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
    7916    325975301 :   TREE_TYPE (t) = rettype;
    7917    325975301 :   ptype = build_pointer_type (basetype);
    7918              : 
    7919              :   /* The actual arglist for this function includes a "hidden" argument
    7920              :      which is "this".  Put it into the list of argument types.  */
    7921    325975301 :   argtypes = tree_cons (NULL_TREE, ptype, argtypes);
    7922    325975301 :   TYPE_ARG_TYPES (t) = argtypes;
    7923              : 
    7924              :   /* Set up the canonical type. */
    7925    325975301 :   any_structural_p
    7926    325975301 :     = (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    7927    325975301 :        || TYPE_STRUCTURAL_EQUALITY_P (rettype));
    7928    325975301 :   any_noncanonical_p
    7929    325975301 :     = (TYPE_CANONICAL (basetype) != basetype
    7930    325975301 :        || TYPE_CANONICAL (rettype) != rettype);
    7931    325975301 :   canon_argtypes = maybe_canonicalize_argtypes (TREE_CHAIN (argtypes),
    7932              :                                                 &any_structural_p,
    7933              :                                                 &any_noncanonical_p);
    7934              : 
    7935              :   /* Set TYPE_STRUCTURAL_EQUALITY_P early.  */
    7936    325975301 :   if (any_structural_p)
    7937     25309565 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7938              : 
    7939              :   /* If we already have such a type, use the old one.  */
    7940    325975301 :   hashval_t hash = type_hash_canon_hash (t);
    7941    325975301 :   tree probe_type = t;
    7942    325975301 :   t = type_hash_canon (hash, t);
    7943    325975301 :   if (t != probe_type)
    7944              :     return t;
    7945              : 
    7946    251166908 :   if (any_structural_p)
    7947     21358168 :     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
    7948    229808740 :   else if (any_noncanonical_p)
    7949     84451821 :     TYPE_CANONICAL (t)
    7950    168903642 :       = build_method_type_directly (TYPE_CANONICAL (basetype),
    7951     84451821 :                                     TYPE_CANONICAL (rettype),
    7952              :                                     canon_argtypes);
    7953    251166908 :   if (!COMPLETE_TYPE_P (t))
    7954            0 :     layout_type (t);
    7955              : 
    7956              :   return t;
    7957              : }
    7958              : 
    7959              : /* Construct, lay out and return the type of methods belonging to class
    7960              :    BASETYPE and whose arguments and values are described by TYPE.
    7961              :    If that type exists already, reuse it.
    7962              :    TYPE must be a FUNCTION_TYPE node.  */
    7963              : 
    7964              : tree
    7965            0 : build_method_type (tree basetype, tree type)
    7966              : {
    7967            0 :   gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
    7968              : 
    7969            0 :   return build_method_type_directly (basetype,
    7970            0 :                                      TREE_TYPE (type),
    7971            0 :                                      TYPE_ARG_TYPES (type));
    7972              : }
    7973              : 
    7974              : /* Construct, lay out and return the type of offsets to a value
    7975              :    of type TYPE, within an object of type BASETYPE.
    7976              :    If a suitable offset type exists already, reuse it.  */
    7977              : 
    7978              : tree
    7979       951461 : build_offset_type (tree basetype, tree type)
    7980              : {
    7981       951461 :   tree t;
    7982              : 
    7983              :   /* Make a node of the sort we want.  */
    7984       951461 :   t = make_node (OFFSET_TYPE);
    7985              : 
    7986       951461 :   TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
    7987       951461 :   TREE_TYPE (t) = type;
    7988       951461 :   if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    7989       951461 :       || TYPE_STRUCTURAL_EQUALITY_P (type))
    7990            4 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7991              : 
    7992              :   /* If we already have such a type, use the old one.  */
    7993       951461 :   hashval_t hash = type_hash_canon_hash (t);
    7994       951461 :   tree probe_type = t;
    7995       951461 :   t = type_hash_canon (hash, t);
    7996       951461 :   if (t != probe_type)
    7997              :     return t;
    7998              : 
    7999       229346 :   if (!COMPLETE_TYPE_P (t))
    8000            0 :     layout_type (t);
    8001              : 
    8002       229346 :   if (TYPE_CANONICAL (t) == t)
    8003              :     {
    8004       229342 :       if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    8005       229342 :           || TYPE_STRUCTURAL_EQUALITY_P (type))
    8006            0 :         gcc_unreachable ();
    8007       229342 :       else if (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)) != basetype
    8008       229342 :                || TYPE_CANONICAL (type) != type)
    8009       131686 :         TYPE_CANONICAL (t)
    8010       263372 :           = build_offset_type (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)),
    8011       131686 :                                TYPE_CANONICAL (type));
    8012              :     }
    8013              : 
    8014              :   return t;
    8015              : }
    8016              : 
    8017              : /* Create a complex type whose components are COMPONENT_TYPE.
    8018              : 
    8019              :    If NAMED is true, the type is given a TYPE_NAME.  We do not always
    8020              :    do so because this creates a DECL node and thus make the DECL_UIDs
    8021              :    dependent on the type canonicalization hashtable, which is GC-ed,
    8022              :    so the DECL_UIDs would not be stable wrt garbage collection.  */
    8023              : 
    8024              : tree
    8025      5437672 : build_complex_type (tree component_type, bool named)
    8026              : {
    8027      5437672 :   gcc_assert (INTEGRAL_TYPE_P (component_type)
    8028              :               || SCALAR_FLOAT_TYPE_P (component_type)
    8029              :               || FIXED_POINT_TYPE_P (component_type));
    8030              : 
    8031              :   /* Make a node of the sort we want.  */
    8032      5437672 :   tree probe = make_node (COMPLEX_TYPE);
    8033              : 
    8034      5437672 :   TREE_TYPE (probe) = TYPE_MAIN_VARIANT (component_type);
    8035      5437672 :   if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (probe)))
    8036            0 :     SET_TYPE_STRUCTURAL_EQUALITY (probe);
    8037              : 
    8038              :   /* If we already have such a type, use the old one.  */
    8039      5437672 :   hashval_t hash = type_hash_canon_hash (probe);
    8040      5437672 :   tree t = type_hash_canon (hash, probe);
    8041              : 
    8042      5437672 :   if (t == probe)
    8043              :     {
    8044              :       /* We created a new type.  The hash insertion will have laid
    8045              :          out the type.  We need to check the canonicalization and
    8046              :          maybe set the name.  */
    8047      3253814 :       gcc_checking_assert (COMPLETE_TYPE_P (t)
    8048              :                            && !TYPE_NAME (t));
    8049              : 
    8050      3253814 :       if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)))
    8051              :         ;
    8052      3253814 :       else if (TYPE_CANONICAL (TREE_TYPE (t)) != TREE_TYPE (t))
    8053          101 :         TYPE_CANONICAL (t)
    8054          202 :           = build_complex_type (TYPE_CANONICAL (TREE_TYPE (t)), named);
    8055              : 
    8056              :       /* We need to create a name, since complex is a fundamental type.  */
    8057      3253814 :       if (named)
    8058              :         {
    8059      1193916 :           const char *name = NULL;
    8060              : 
    8061      1193916 :           if (TREE_TYPE (t) == char_type_node)
    8062              :             name = "complex char";
    8063      1193916 :           else if (TREE_TYPE (t) == signed_char_type_node)
    8064              :             name = "complex signed char";
    8065      1193916 :           else if (TREE_TYPE (t) == unsigned_char_type_node)
    8066              :             name = "complex unsigned char";
    8067      1193916 :           else if (TREE_TYPE (t) == short_integer_type_node)
    8068              :             name = "complex short int";
    8069      1193916 :           else if (TREE_TYPE (t) == short_unsigned_type_node)
    8070              :             name = "complex short unsigned int";
    8071      1193916 :           else if (TREE_TYPE (t) == integer_type_node)
    8072              :             name = "complex int";
    8073       895437 :           else if (TREE_TYPE (t) == unsigned_type_node)
    8074              :             name = "complex unsigned int";
    8075       895437 :           else if (TREE_TYPE (t) == long_integer_type_node)
    8076              :             name = "complex long int";
    8077       895437 :           else if (TREE_TYPE (t) == long_unsigned_type_node)
    8078              :             name = "complex long unsigned int";
    8079       895437 :           else if (TREE_TYPE (t) == long_long_integer_type_node)
    8080              :             name = "complex long long int";
    8081       895437 :           else if (TREE_TYPE (t) == long_long_unsigned_type_node)
    8082              :             name = "complex long long unsigned int";
    8083              : 
    8084              :           if (name != NULL)
    8085       298479 :             TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
    8086              :                                         get_identifier (name), t);
    8087              :         }
    8088              :     }
    8089              : 
    8090      5437672 :   return build_qualified_type (t, TYPE_QUALS (component_type));
    8091              : }
    8092              : 
    8093              : /* If TYPE is a real or complex floating-point type and the target
    8094              :    does not directly support arithmetic on TYPE then return the wider
    8095              :    type to be used for arithmetic on TYPE.  Otherwise, return
    8096              :    NULL_TREE.  */
    8097              : 
    8098              : tree
    8099     88582144 : excess_precision_type (tree type)
    8100              : {
    8101              :   /* The target can give two different responses to the question of
    8102              :      which excess precision mode it would like depending on whether we
    8103              :      are in -fexcess-precision=standard or -fexcess-precision=fast.  */
    8104              : 
    8105      3511410 :   enum excess_precision_type requested_type
    8106     88582144 :     = (flag_excess_precision == EXCESS_PRECISION_FAST
    8107     88582144 :        ? EXCESS_PRECISION_TYPE_FAST
    8108              :        : (flag_excess_precision == EXCESS_PRECISION_FLOAT16
    8109      3511479 :           ? EXCESS_PRECISION_TYPE_FLOAT16 : EXCESS_PRECISION_TYPE_STANDARD));
    8110              : 
    8111     88582144 :   enum flt_eval_method target_flt_eval_method
    8112     88582144 :     = targetm.c.excess_precision (requested_type);
    8113              : 
    8114              :   /* The target should not ask for unpredictable float evaluation (though
    8115              :      it might advertise that implicitly the evaluation is unpredictable,
    8116              :      but we don't care about that here, it will have been reported
    8117              :      elsewhere).  If it does ask for unpredictable evaluation, we have
    8118              :      nothing to do here.  */
    8119     88582144 :   gcc_assert (target_flt_eval_method != FLT_EVAL_METHOD_UNPREDICTABLE);
    8120              : 
    8121              :   /* Nothing to do.  The target has asked for all types we know about
    8122              :      to be computed with their native precision and range.  */
    8123     88582144 :   if (target_flt_eval_method == FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16)
    8124              :     return NULL_TREE;
    8125              : 
    8126              :   /* The target will promote this type in a target-dependent way, so excess
    8127              :      precision ought to leave it alone.  */
    8128     86968897 :   if (targetm.promoted_type (type) != NULL_TREE)
    8129              :     return NULL_TREE;
    8130              : 
    8131     86968897 :   machine_mode float16_type_mode = (float16_type_node
    8132     86968897 :                                     ? TYPE_MODE (float16_type_node)
    8133     86968897 :                                     : VOIDmode);
    8134     86968897 :   machine_mode bfloat16_type_mode = (bfloat16_type_node
    8135     86968897 :                                      ? TYPE_MODE (bfloat16_type_node)
    8136     86968897 :                                      : VOIDmode);
    8137     86968897 :   machine_mode float_type_mode = TYPE_MODE (float_type_node);
    8138     86968897 :   machine_mode double_type_mode = TYPE_MODE (double_type_node);
    8139              : 
    8140     86968897 :   switch (TREE_CODE (type))
    8141              :     {
    8142     58724077 :     case REAL_TYPE:
    8143     58724077 :       {
    8144     58724077 :         machine_mode type_mode = TYPE_MODE (type);
    8145     58724077 :         switch (target_flt_eval_method)
    8146              :           {
    8147     58711244 :           case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT:
    8148     58711244 :             if (type_mode == float16_type_mode
    8149     58711244 :                 || type_mode == bfloat16_type_mode)
    8150       202874 :               return float_type_node;
    8151              :             break;
    8152            0 :           case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE:
    8153            0 :             if (type_mode == float16_type_mode
    8154            0 :                 || type_mode == bfloat16_type_mode
    8155            0 :                 || type_mode == float_type_mode)
    8156            0 :               return double_type_node;
    8157              :             break;
    8158        12833 :           case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE:
    8159        12833 :             if (type_mode == float16_type_mode
    8160        12833 :                 || type_mode == bfloat16_type_mode
    8161        12828 :                 || type_mode == float_type_mode
    8162        12828 :                 || type_mode == double_type_mode)
    8163        12384 :               return long_double_type_node;
    8164              :             break;
    8165            0 :           default:
    8166            0 :             gcc_unreachable ();
    8167              :           }
    8168              :         break;
    8169              :       }
    8170       371078 :     case COMPLEX_TYPE:
    8171       371078 :       {
    8172       371078 :         if (TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    8173              :           return NULL_TREE;
    8174       361594 :         machine_mode type_mode = TYPE_MODE (TREE_TYPE (type));
    8175       361594 :         switch (target_flt_eval_method)
    8176              :           {
    8177       361261 :           case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT:
    8178       361261 :             if (type_mode == float16_type_mode
    8179       361261 :                 || type_mode == bfloat16_type_mode)
    8180          271 :               return complex_float_type_node;
    8181              :             break;
    8182            0 :           case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE:
    8183            0 :             if (type_mode == float16_type_mode
    8184            0 :                 || type_mode == bfloat16_type_mode
    8185            0 :                 || type_mode == float_type_mode)
    8186            0 :               return complex_double_type_node;
    8187              :             break;
    8188          333 :           case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE:
    8189          333 :             if (type_mode == float16_type_mode
    8190          333 :                 || type_mode == bfloat16_type_mode
    8191          333 :                 || type_mode == float_type_mode
    8192          333 :                 || type_mode == double_type_mode)
    8193          281 :               return complex_long_double_type_node;
    8194              :             break;
    8195            0 :           default:
    8196            0 :             gcc_unreachable ();
    8197              :           }
    8198              :         break;
    8199              :       }
    8200              :     default:
    8201              :       break;
    8202              :     }
    8203              : 
    8204              :   return NULL_TREE;
    8205              : }
    8206              : 
    8207              : /* Return OP, stripped of any conversions to wider types as much as is safe.
    8208              :    Converting the value back to OP's type makes a value equivalent to OP.
    8209              : 
    8210              :    If FOR_TYPE is nonzero, we return a value which, if converted to
    8211              :    type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE.
    8212              : 
    8213              :    OP must have integer, real or enumeral type.  Pointers are not allowed!
    8214              : 
    8215              :    There are some cases where the obvious value we could return
    8216              :    would regenerate to OP if converted to OP's type,
    8217              :    but would not extend like OP to wider types.
    8218              :    If FOR_TYPE indicates such extension is contemplated, we eschew such values.
    8219              :    For example, if OP is (unsigned short)(signed char)-1,
    8220              :    we avoid returning (signed char)-1 if FOR_TYPE is int,
    8221              :    even though extending that to an unsigned short would regenerate OP,
    8222              :    since the result of extending (signed char)-1 to (int)
    8223              :    is different from (int) OP.  */
    8224              : 
    8225              : tree
    8226     11176788 : get_unwidened (tree op, tree for_type)
    8227              : {
    8228              :   /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension.  */
    8229     11176788 :   tree type = TREE_TYPE (op);
    8230     11176788 :   unsigned final_prec
    8231     18921013 :     = TYPE_PRECISION (for_type != 0 ? for_type : type);
    8232     11176788 :   int uns
    8233     11176788 :     = (for_type != 0 && for_type != type
    8234      3115429 :        && final_prec > TYPE_PRECISION (type)
    8235     11412018 :        && TYPE_UNSIGNED (type));
    8236     11176788 :   tree win = op;
    8237              : 
    8238     11493227 :   while (CONVERT_EXPR_P (op))
    8239              :     {
    8240       316492 :       int bitschange;
    8241              : 
    8242              :       /* TYPE_PRECISION on vector types has different meaning
    8243              :          (TYPE_VECTOR_SUBPARTS) and casts from vectors are view conversions,
    8244              :          so avoid them here.  */
    8245       316492 :       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == VECTOR_TYPE)
    8246              :         break;
    8247              : 
    8248       316492 :       bitschange = TYPE_PRECISION (TREE_TYPE (op))
    8249       316492 :                    - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
    8250              : 
    8251              :       /* Truncations are many-one so cannot be removed.
    8252              :          Unless we are later going to truncate down even farther.  */
    8253       316492 :       if (bitschange < 0
    8254       316492 :           && final_prec > TYPE_PRECISION (TREE_TYPE (op)))
    8255              :         break;
    8256              : 
    8257              :       /* See what's inside this conversion.  If we decide to strip it,
    8258              :          we will set WIN.  */
    8259       316439 :       op = TREE_OPERAND (op, 0);
    8260              : 
    8261              :       /* If we have not stripped any zero-extensions (uns is 0),
    8262              :          we can strip any kind of extension.
    8263              :          If we have previously stripped a zero-extension,
    8264              :          only zero-extensions can safely be stripped.
    8265              :          Any extension can be stripped if the bits it would produce
    8266              :          are all going to be discarded later by truncating to FOR_TYPE.  */
    8267              : 
    8268       316439 :       if (bitschange > 0)
    8269              :         {
    8270       188874 :           if (! uns || final_prec <= TYPE_PRECISION (TREE_TYPE (op)))
    8271              :             win = op;
    8272              :           /* TYPE_UNSIGNED says whether this is a zero-extension.
    8273              :              Let's avoid computing it if it does not affect WIN
    8274              :              and if UNS will not be needed again.  */
    8275       188874 :           if ((uns
    8276       188843 :                || CONVERT_EXPR_P (op))
    8277       189465 :               && TYPE_UNSIGNED (TREE_TYPE (op)))
    8278              :             {
    8279              :               uns = 1;
    8280              :               win = op;
    8281              :             }
    8282              :         }
    8283              :     }
    8284              : 
    8285              :   /* If we finally reach a constant see if it fits in sth smaller and
    8286              :      in that case convert it.  */
    8287     11176788 :   if (TREE_CODE (win) == INTEGER_CST)
    8288              :     {
    8289       513476 :       tree wtype = TREE_TYPE (win);
    8290       513476 :       unsigned prec = wi::min_precision (wi::to_wide (win), TYPE_SIGN (wtype));
    8291       513476 :       if (for_type)
    8292       502067 :         prec = MAX (prec, final_prec);
    8293       513476 :       if (prec < TYPE_PRECISION (wtype))
    8294              :         {
    8295       509958 :           tree t = lang_hooks.types.type_for_size (prec, TYPE_UNSIGNED (wtype));
    8296       509958 :           if (t && TYPE_PRECISION (t) < TYPE_PRECISION (wtype))
    8297       499047 :             win = fold_convert (t, win);
    8298              :         }
    8299              :     }
    8300              : 
    8301     11176788 :   return win;
    8302              : }
    8303              : 
    8304              : /* Return OP or a simpler expression for a narrower value
    8305              :    which can be sign-extended or zero-extended to give back OP.
    8306              :    Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
    8307              :    or 0 if the value should be sign-extended.  */
    8308              : 
    8309              : tree
    8310     80791164 : get_narrower (tree op, int *unsignedp_ptr)
    8311              : {
    8312     80791164 :   int uns = 0;
    8313     80791164 :   bool first = true;
    8314     80791164 :   tree win = op;
    8315     80791164 :   bool integral_p = INTEGRAL_TYPE_P (TREE_TYPE (op));
    8316              : 
    8317     80791164 :   if (TREE_CODE (op) == COMPOUND_EXPR)
    8318              :     {
    8319        88827 :       do
    8320        88827 :         op = TREE_OPERAND (op, 1);
    8321        88827 :       while (TREE_CODE (op) == COMPOUND_EXPR);
    8322        88812 :       tree ret = get_narrower (op, unsignedp_ptr);
    8323        88812 :       if (ret == op)
    8324              :         return win;
    8325         4262 :       auto_vec <tree, 16> v;
    8326         4262 :       unsigned int i;
    8327         8531 :       for (op = win; TREE_CODE (op) == COMPOUND_EXPR;
    8328         4269 :            op = TREE_OPERAND (op, 1))
    8329         4269 :         v.safe_push (op);
    8330        12793 :       FOR_EACH_VEC_ELT_REVERSE (v, i, op)
    8331         4269 :         ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
    8332         4269 :                           TREE_TYPE (ret), TREE_OPERAND (op, 0),
    8333              :                           ret);
    8334         4262 :       return ret;
    8335         4262 :     }
    8336     96291523 :   while (TREE_CODE (op) == NOP_EXPR)
    8337              :     {
    8338     15620980 :       int bitschange
    8339     15620980 :         = (TYPE_PRECISION (TREE_TYPE (op))
    8340     15620980 :            - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0))));
    8341              : 
    8342              :       /* Truncations are many-one so cannot be removed.  */
    8343     15620980 :       if (bitschange < 0)
    8344              :         break;
    8345              : 
    8346              :       /* See what's inside this conversion.  If we decide to strip it,
    8347              :          we will set WIN.  */
    8348              : 
    8349     15589267 :       if (bitschange > 0)
    8350              :         {
    8351      3668149 :           op = TREE_OPERAND (op, 0);
    8352              :           /* An extension: the outermost one can be stripped,
    8353              :              but remember whether it is zero or sign extension.  */
    8354      3668149 :           if (first)
    8355      3657829 :             uns = TYPE_UNSIGNED (TREE_TYPE (op));
    8356              :           /* Otherwise, if a sign extension has been stripped,
    8357              :              only sign extensions can now be stripped;
    8358              :              if a zero extension has been stripped, only zero-extensions.  */
    8359        10320 :           else if (uns != TYPE_UNSIGNED (TREE_TYPE (op)))
    8360              :             break;
    8361              :           first = false;
    8362              :         }
    8363              :       else /* bitschange == 0 */
    8364              :         {
    8365              :           /* A change in nominal type can always be stripped, but we must
    8366              :              preserve the unsignedness.  */
    8367     11921118 :           if (first)
    8368     11353716 :             uns = TYPE_UNSIGNED (TREE_TYPE (op));
    8369     11921118 :           first = false;
    8370     11921118 :           op = TREE_OPERAND (op, 0);
    8371              :           /* Keep trying to narrow, but don't assign op to win if it
    8372              :              would turn an integral type into something else.  */
    8373     22139524 :           if (INTEGRAL_TYPE_P (TREE_TYPE (op)) != integral_p)
    8374        96115 :             continue;
    8375              :         }
    8376              : 
    8377     15493056 :       win = op;
    8378              :     }
    8379              : 
    8380     80702352 :   if (TREE_CODE (op) == COMPONENT_REF
    8381              :       /* Since type_for_size always gives an integer type.  */
    8382      2827312 :       && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE
    8383      2726430 :       && TREE_CODE (TREE_TYPE (op)) != FIXED_POINT_TYPE
    8384              :       /* Ensure field is laid out already.  */
    8385      2726430 :       && DECL_SIZE (TREE_OPERAND (op, 1)) != 0
    8386     83428779 :       && tree_fits_uhwi_p (DECL_SIZE (TREE_OPERAND (op, 1))))
    8387              :     {
    8388      2726427 :       unsigned HOST_WIDE_INT innerprec
    8389      2726427 :         = tree_to_uhwi (DECL_SIZE (TREE_OPERAND (op, 1)));
    8390      2726427 :       int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
    8391      2726427 :                        || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
    8392      2726427 :       tree type = lang_hooks.types.type_for_size (innerprec, unsignedp);
    8393              : 
    8394              :       /* We can get this structure field in a narrower type that fits it,
    8395              :          but the resulting extension to its nominal type (a fullword type)
    8396              :          must satisfy the same conditions as for other extensions.
    8397              : 
    8398              :          Do this only for fields that are aligned (not bit-fields),
    8399              :          because when bit-field insns will be used there is no
    8400              :          advantage in doing this.  */
    8401              : 
    8402      2726427 :       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
    8403            0 :           && ! DECL_BIT_FIELD (TREE_OPERAND (op, 1))
    8404            0 :           && (first || uns == DECL_UNSIGNED (TREE_OPERAND (op, 1)))
    8405      2726427 :           && type != 0)
    8406              :         {
    8407            0 :           if (first)
    8408            0 :             uns = DECL_UNSIGNED (TREE_OPERAND (op, 1));
    8409            0 :           win = fold_convert (type, op);
    8410              :         }
    8411              :     }
    8412              : 
    8413     80702352 :   *unsignedp_ptr = uns;
    8414     80702352 :   return win;
    8415              : }
    8416              : 
    8417              : /* Return true if integer constant C has a value that is permissible
    8418              :    for TYPE, an integral type.  */
    8419              : 
    8420              : bool
    8421    190364099 : int_fits_type_p (const_tree c, const_tree type)
    8422              : {
    8423    190364099 :   tree type_low_bound, type_high_bound;
    8424    190364099 :   bool ok_for_low_bound, ok_for_high_bound;
    8425    190364099 :   signop sgn_c = TYPE_SIGN (TREE_TYPE (c));
    8426              : 
    8427              :   /* Non-standard boolean types can have arbitrary precision but various
    8428              :      transformations assume that they can only take values 0 and +/-1.  */
    8429    190364099 :   if (TREE_CODE (type) == BOOLEAN_TYPE)
    8430      1243131 :     return wi::fits_to_boolean_p (wi::to_wide (c), type);
    8431              : 
    8432    189120968 : retry:
    8433    189132815 :   type_low_bound = TYPE_MIN_VALUE (type);
    8434    189132815 :   type_high_bound = TYPE_MAX_VALUE (type);
    8435              : 
    8436              :   /* If at least one bound of the type is a constant integer, we can check
    8437              :      ourselves and maybe make a decision. If no such decision is possible, but
    8438              :      this type is a subtype, try checking against that.  Otherwise, use
    8439              :      fits_to_tree_p, which checks against the precision.
    8440              : 
    8441              :      Compute the status for each possibly constant bound, and return if we see
    8442              :      one does not match. Use ok_for_xxx_bound for this purpose, assigning -1
    8443              :      for "unknown if constant fits", 0 for "constant known *not* to fit" and 1
    8444              :      for "constant known to fit".  */
    8445              : 
    8446              :   /* Check if c >= type_low_bound.  */
    8447    189132815 :   if (type_low_bound && TREE_CODE (type_low_bound) == INTEGER_CST)
    8448              :     {
    8449    189132815 :       if (tree_int_cst_lt (c, type_low_bound))
    8450              :         return false;
    8451              :       ok_for_low_bound = true;
    8452              :     }
    8453              :   else
    8454              :     ok_for_low_bound = false;
    8455              : 
    8456              :   /* Check if c <= type_high_bound.  */
    8457    188890375 :   if (type_high_bound && TREE_CODE (type_high_bound) == INTEGER_CST)
    8458              :     {
    8459    188858803 :       if (tree_int_cst_lt (type_high_bound, c))
    8460              :         return false;
    8461              :       ok_for_high_bound = true;
    8462              :     }
    8463              :   else
    8464              :     ok_for_high_bound = false;
    8465              : 
    8466              :   /* If the constant fits both bounds, the result is known.  */
    8467    186993653 :   if (ok_for_low_bound && ok_for_high_bound)
    8468              :     return true;
    8469              : 
    8470              :   /* Perform some generic filtering which may allow making a decision
    8471              :      even if the bounds are not constant.  First, negative integers
    8472              :      never fit in unsigned types, */
    8473        31572 :   if (TYPE_UNSIGNED (type) && sgn_c == SIGNED && wi::neg_p (wi::to_wide (c)))
    8474            0 :     return false;
    8475              : 
    8476              :   /* Second, narrower types always fit in wider ones.  */
    8477        31572 :   if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c)))
    8478              :     return true;
    8479              : 
    8480              :   /* Third, unsigned integers with top bit set never fit signed types.  */
    8481        11856 :   if (!TYPE_UNSIGNED (type) && sgn_c == UNSIGNED)
    8482              :     {
    8483           14 :       int prec = GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (c))) - 1;
    8484           14 :       if (prec < TYPE_PRECISION (TREE_TYPE (c)))
    8485              :         {
    8486              :           /* When a tree_cst is converted to a wide-int, the precision
    8487              :              is taken from the type.  However, if the precision of the
    8488              :              mode underneath the type is smaller than that, it is
    8489              :              possible that the value will not fit.  The test below
    8490              :              fails if any bit is set between the sign bit of the
    8491              :              underlying mode and the top bit of the type.  */
    8492           14 :           if (wi::zext (wi::to_wide (c), prec - 1) != wi::to_wide (c))
    8493              :             return false;
    8494              :         }
    8495            0 :       else if (wi::neg_p (wi::to_wide (c)))
    8496              :         return false;
    8497              :     }
    8498              : 
    8499              :   /* If we haven't been able to decide at this point, there nothing more we
    8500              :      can check ourselves here.  Look at the base type if we have one and it
    8501              :      has the same precision.  */
    8502        11847 :   if (TREE_CODE (type) == INTEGER_TYPE
    8503        11847 :       && TREE_TYPE (type) != 0
    8504        23694 :       && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (type)))
    8505              :     {
    8506        11847 :       type = TREE_TYPE (type);
    8507        11847 :       goto retry;
    8508              :     }
    8509              : 
    8510              :   /* Or to fits_to_tree_p, if nothing else.  */
    8511            0 :   return wi::fits_to_tree_p (wi::to_wide (c), type);
    8512              : }
    8513              : 
    8514              : /* Stores bounds of an integer TYPE in MIN and MAX.  If TYPE has non-constant
    8515              :    bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be
    8516              :    represented (assuming two's-complement arithmetic) within the bit
    8517              :    precision of the type are returned instead.  */
    8518              : 
    8519              : void
    8520     22901643 : get_type_static_bounds (const_tree type, mpz_t min, mpz_t max)
    8521              : {
    8522     21480853 :   if (!POINTER_TYPE_P (type) && TYPE_MIN_VALUE (type)
    8523     44382496 :       && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
    8524     21480853 :     wi::to_mpz (wi::to_wide (TYPE_MIN_VALUE (type)), min, TYPE_SIGN (type));
    8525              :   else
    8526              :     {
    8527      1420790 :       if (TYPE_UNSIGNED (type))
    8528      1420790 :         mpz_set_ui (min, 0);
    8529              :       else
    8530              :         {
    8531            0 :           wide_int mn = wi::min_value (TYPE_PRECISION (type), SIGNED);
    8532            0 :           wi::to_mpz (mn, min, SIGNED);
    8533            0 :         }
    8534              :     }
    8535              : 
    8536     21480853 :   if (!POINTER_TYPE_P (type) && TYPE_MAX_VALUE (type)
    8537     44382496 :       && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
    8538     21480853 :     wi::to_mpz (wi::to_wide (TYPE_MAX_VALUE (type)), max, TYPE_SIGN (type));
    8539              :   else
    8540              :     {
    8541      1420790 :       wide_int mn = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
    8542      1420790 :       wi::to_mpz (mn, max, TYPE_SIGN (type));
    8543      1420790 :     }
    8544     22901643 : }
    8545              : 
    8546              : /* Return true if VAR is an automatic variable.  */
    8547              : 
    8548              : bool
    8549    446057146 : auto_var_p (const_tree var)
    8550              : {
    8551    240104108 :   return ((((VAR_P (var) && ! DECL_EXTERNAL (var))
    8552    209297706 :             || TREE_CODE (var) == PARM_DECL)
    8553    330463602 :            && ! TREE_STATIC (var))
    8554    570337541 :           || TREE_CODE (var) == RESULT_DECL);
    8555              : }
    8556              : 
    8557              : /* Return true if VAR is an automatic variable defined in function FN.  */
    8558              : 
    8559              : bool
    8560   1589212878 : auto_var_in_fn_p (const_tree var, const_tree fn)
    8561              : {
    8562    451570670 :   return (DECL_P (var) && DECL_CONTEXT (var) == fn
    8563   1909662255 :           && (auto_var_p (var)
    8564      4636618 :               || TREE_CODE (var) == LABEL_DECL));
    8565              : }
    8566              : 
    8567              : /* Subprogram of following function.  Called by walk_tree.
    8568              : 
    8569              :    Return *TP if it is an automatic variable or parameter of the
    8570              :    function passed in as DATA.  */
    8571              : 
    8572              : static tree
    8573       124895 : find_var_from_fn (tree *tp, int *walk_subtrees, void *data)
    8574              : {
    8575       124895 :   tree fn = (tree) data;
    8576              : 
    8577       124895 :   if (TYPE_P (*tp))
    8578            0 :     *walk_subtrees = 0;
    8579              : 
    8580       124895 :   else if (DECL_P (*tp)
    8581       124895 :            && auto_var_in_fn_p (*tp, fn))
    8582       116534 :     return *tp;
    8583              : 
    8584              :   return NULL_TREE;
    8585              : }
    8586              : 
    8587              : /* Returns true if T is, contains, or refers to a type with variable
    8588              :    size.  For METHOD_TYPEs and FUNCTION_TYPEs we exclude the
    8589              :    arguments, but not the return type.  If FN is nonzero, only return
    8590              :    true if a modifier of the type or position of FN is a variable or
    8591              :    parameter inside FN.
    8592              : 
    8593              :    This concept is more general than that of C99 'variably modified types':
    8594              :    in C99, a struct type is never variably modified because a VLA may not
    8595              :    appear as a structure member.  However, in GNU C code like:
    8596              : 
    8597              :      struct S { int i[f()]; };
    8598              : 
    8599              :    is valid, and other languages may define similar constructs.  */
    8600              : 
    8601              : bool
    8602   2312743161 : variably_modified_type_p (tree type, tree fn)
    8603              : {
    8604   2312743161 :   tree t;
    8605              : 
    8606              : /* Test if T is either variable (if FN is zero) or an expression containing
    8607              :    a variable in FN.  If TYPE isn't gimplified, return true also if
    8608              :    gimplify_one_sizepos would gimplify the expression into a local
    8609              :    variable.  */
    8610              : #define RETURN_TRUE_IF_VAR(T)                                           \
    8611              :   do { tree _t = (T);                                                   \
    8612              :     if (_t != NULL_TREE                                                 \
    8613              :         && _t != error_mark_node                                        \
    8614              :         && !CONSTANT_CLASS_P (_t)                                       \
    8615              :         && TREE_CODE (_t) != PLACEHOLDER_EXPR                           \
    8616              :         && (!fn                                                         \
    8617              :             || (!TYPE_SIZES_GIMPLIFIED (type)                           \
    8618              :                 && (TREE_CODE (_t) != VAR_DECL                          \
    8619              :                     && !CONTAINS_PLACEHOLDER_P (_t)))                   \
    8620              :             || walk_tree (&_t, find_var_from_fn, fn, NULL)))                \
    8621              :       return true;  } while (0)
    8622              : 
    8623   2312743161 :   if (type == error_mark_node)
    8624              :     return false;
    8625              : 
    8626              :   /* If TYPE itself has variable size, it is variably modified.  */
    8627   2312742810 :   RETURN_TRUE_IF_VAR (TYPE_SIZE (type));
    8628   2312615739 :   RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT (type));
    8629              : 
    8630   2312615115 :   switch (TREE_CODE (type))
    8631              :     {
    8632    628770732 :     case POINTER_TYPE:
    8633    628770732 :     case REFERENCE_TYPE:
    8634    628770732 :     case VECTOR_TYPE:
    8635              :       /* Ada can have pointer types referring to themselves indirectly.  */
    8636    628770732 :       if (TREE_VISITED (type))
    8637              :         return false;
    8638    628770732 :       TREE_VISITED (type) = true;
    8639    628770732 :       if (variably_modified_type_p (TREE_TYPE (type), fn))
    8640              :         {
    8641        79825 :           TREE_VISITED (type) = false;
    8642        79825 :           return true;
    8643              :         }
    8644    628690907 :       TREE_VISITED (type) = false;
    8645    628690907 :       break;
    8646              : 
    8647    130970202 :     case FUNCTION_TYPE:
    8648    130970202 :     case METHOD_TYPE:
    8649              :       /* If TYPE is a function type, it is variably modified if the
    8650              :          return type is variably modified.  */
    8651    130970202 :       if (variably_modified_type_p (TREE_TYPE (type), fn))
    8652              :           return true;
    8653              :       break;
    8654              : 
    8655    567859307 :     case INTEGER_TYPE:
    8656    567859307 :     case REAL_TYPE:
    8657    567859307 :     case FIXED_POINT_TYPE:
    8658    567859307 :     case ENUMERAL_TYPE:
    8659    567859307 :     case BOOLEAN_TYPE:
    8660              :       /* Scalar types are variably modified if their end points
    8661              :          aren't constant.  */
    8662    567859307 :       RETURN_TRUE_IF_VAR (TYPE_MIN_VALUE (type));
    8663    567859307 :       RETURN_TRUE_IF_VAR (TYPE_MAX_VALUE (type));
    8664    567824518 :       break;
    8665              : 
    8666    798370952 :     case RECORD_TYPE:
    8667    798370952 :     case UNION_TYPE:
    8668    798370952 :     case QUAL_UNION_TYPE:
    8669              :       /* We can't see if any of the fields are variably-modified by the
    8670              :          definition we normally use, since that would produce infinite
    8671              :          recursion via pointers.  */
    8672              :       /* This is variably modified if some field's type is.  */
    8673  36668502301 :       for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t))
    8674  35870131349 :         if (TREE_CODE (t) == FIELD_DECL)
    8675              :           {
    8676   1161965208 :             RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t));
    8677   1161965208 :             RETURN_TRUE_IF_VAR (DECL_SIZE (t));
    8678   1161965208 :             RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t));
    8679              : 
    8680              :             /* If the type is a qualified union, then the DECL_QUALIFIER
    8681              :                of fields can also be an expression containing a variable.  */
    8682   1161965208 :             if (TREE_CODE (type) == QUAL_UNION_TYPE)
    8683            0 :               RETURN_TRUE_IF_VAR (DECL_QUALIFIER (t));
    8684              : 
    8685              :             /* If the field is a qualified union, then it's only a container
    8686              :                for what's inside so we look into it.  That's necessary in LTO
    8687              :                mode because the sizes of the field tested above have been set
    8688              :                to PLACEHOLDER_EXPRs by free_lang_data.  */
    8689   1161965208 :             if (TREE_CODE (TREE_TYPE (t)) == QUAL_UNION_TYPE
    8690   1161965208 :                 && variably_modified_type_p (TREE_TYPE (t), fn))
    8691              :               return true;
    8692              :           }
    8693              :       break;
    8694              : 
    8695     13738342 :     case ARRAY_TYPE:
    8696              :       /* Do not call ourselves to avoid infinite recursion.  This is
    8697              :          variably modified if the element type is.  */
    8698     13738342 :       RETURN_TRUE_IF_VAR (TYPE_SIZE (TREE_TYPE (type)));
    8699     13735023 :       RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT (TREE_TYPE (type)));
    8700     13734997 :       break;
    8701              : 
    8702              :     default:
    8703              :       break;
    8704              :     }
    8705              : 
    8706              :   /* The current language may have other cases to check, but in general,
    8707              :      all other types are not variably modified.  */
    8708   2312496926 :   return lang_hooks.tree_inlining.var_mod_type_p (type, fn);
    8709              : 
    8710              : #undef RETURN_TRUE_IF_VAR
    8711              : }
    8712              : 
    8713              : /* Given a DECL or TYPE, return the scope in which it was declared, or
    8714              :    NULL_TREE if there is no containing scope.  */
    8715              : 
    8716              : tree
    8717   2899407616 : get_containing_scope (const_tree t)
    8718              : {
    8719   2899407616 :   return (TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t));
    8720              : }
    8721              : 
    8722              : /* Returns the ultimate TRANSLATION_UNIT_DECL context of DECL or NULL.  */
    8723              : 
    8724              : const_tree
    8725        14099 : get_ultimate_context (const_tree decl)
    8726              : {
    8727        38311 :   while (decl && TREE_CODE (decl) != TRANSLATION_UNIT_DECL)
    8728              :     {
    8729        24212 :       if (TREE_CODE (decl) == BLOCK)
    8730            0 :         decl = BLOCK_SUPERCONTEXT (decl);
    8731              :       else
    8732        24212 :         decl = get_containing_scope (decl);
    8733              :     }
    8734        14099 :   return decl;
    8735              : }
    8736              : 
    8737              : /* Return the innermost context enclosing DECL that is
    8738              :    a FUNCTION_DECL, or zero if none.  */
    8739              : 
    8740              : tree
    8741   1472052637 : decl_function_context (const_tree decl)
    8742              : {
    8743   1472052637 :   tree context;
    8744              : 
    8745   1472052637 :   if (TREE_CODE (decl) == ERROR_MARK)
    8746              :     return 0;
    8747              : 
    8748              :   /* C++ virtual functions use DECL_CONTEXT for the class of the vtable
    8749              :      where we look up the function at runtime.  Such functions always take
    8750              :      a first argument of type 'pointer to real context'.
    8751              : 
    8752              :      C++ should really be fixed to use DECL_CONTEXT for the real context,
    8753              :      and use something else for the "virtual context".  */
    8754   1472052637 :   else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
    8755      4616263 :     context
    8756      4616263 :       = TYPE_MAIN_VARIANT
    8757              :         (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
    8758              :   else
    8759   1467436374 :     context = DECL_CONTEXT (decl);
    8760              : 
    8761   3578502413 :   while (context && TREE_CODE (context) != FUNCTION_DECL)
    8762              :     {
    8763   2106449776 :       if (TREE_CODE (context) == BLOCK)
    8764            0 :         context = BLOCK_SUPERCONTEXT (context);
    8765              :       else
    8766   2106449776 :         context = get_containing_scope (context);
    8767              :     }
    8768              : 
    8769              :   return context;
    8770              : }
    8771              : 
    8772              : /* Return the innermost context enclosing DECL that is
    8773              :    a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
    8774              :    TYPE_DECLs and FUNCTION_DECLs are transparent to this function.  */
    8775              : 
    8776              : tree
    8777     90775273 : decl_type_context (const_tree decl)
    8778              : {
    8779     90775273 :   tree context = DECL_CONTEXT (decl);
    8780              : 
    8781     93417673 :   while (context)
    8782     87690296 :     switch (TREE_CODE (context))
    8783              :       {
    8784              :       case NAMESPACE_DECL:
    8785              :       case TRANSLATION_UNIT_DECL:
    8786              :         return NULL_TREE;
    8787              : 
    8788              :       case RECORD_TYPE:
    8789              :       case UNION_TYPE:
    8790              :       case QUAL_UNION_TYPE:
    8791              :         return context;
    8792              : 
    8793      2642400 :       case TYPE_DECL:
    8794      2642400 :       case FUNCTION_DECL:
    8795      2642400 :         context = DECL_CONTEXT (context);
    8796      2642400 :         break;
    8797              : 
    8798            0 :       case BLOCK:
    8799            0 :         context = BLOCK_SUPERCONTEXT (context);
    8800            0 :         break;
    8801              : 
    8802            0 :       default:
    8803            0 :         gcc_unreachable ();
    8804              :       }
    8805              : 
    8806              :   return NULL_TREE;
    8807              : }
    8808              : 
    8809              : /* CALL is a CALL_EXPR.  Return the declaration for the function
    8810              :    called, or NULL_TREE if the called function cannot be
    8811              :    determined.  */
    8812              : 
    8813              : tree
    8814   1175457717 : get_callee_fndecl (const_tree call)
    8815              : {
    8816   1175457717 :   tree addr;
    8817              : 
    8818   1175457717 :   if (call == error_mark_node)
    8819              :     return error_mark_node;
    8820              : 
    8821              :   /* It's invalid to call this function with anything but a
    8822              :      CALL_EXPR.  */
    8823   1175457717 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    8824              : 
    8825              :   /* The first operand to the CALL is the address of the function
    8826              :      called.  */
    8827   1175457717 :   addr = CALL_EXPR_FN (call);
    8828              : 
    8829              :   /* If there is no function, return early.  */
    8830   1175457717 :   if (addr == NULL_TREE)
    8831              :     return NULL_TREE;
    8832              : 
    8833   1173053976 :   STRIP_NOPS (addr);
    8834              : 
    8835              :   /* If this is a readonly function pointer, extract its initial value.  */
    8836     20135517 :   if (DECL_P (addr) && TREE_CODE (addr) != FUNCTION_DECL
    8837      2392590 :       && TREE_READONLY (addr) && ! TREE_THIS_VOLATILE (addr)
    8838   1173673706 :       && DECL_INITIAL (addr))
    8839       619675 :     addr = DECL_INITIAL (addr);
    8840              : 
    8841              :   /* If the address is just `&f' for some function `f', then we know
    8842              :      that `f' is being called.  */
    8843   1173053976 :   if (TREE_CODE (addr) == ADDR_EXPR
    8844   1173053976 :       && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
    8845   1120610644 :     return TREE_OPERAND (addr, 0);
    8846              : 
    8847              :   /* We couldn't figure out what was being called.  */
    8848              :   return NULL_TREE;
    8849              : }
    8850              : 
    8851              : /* Return true when STMTs arguments and return value match those of FNDECL,
    8852              :    a decl of a builtin function.  */
    8853              : 
    8854              : static bool
    8855      6032005 : tree_builtin_call_types_compatible_p (const_tree call, tree fndecl)
    8856              : {
    8857      6032005 :   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
    8858              : 
    8859      6032005 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
    8860      6032005 :     if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
    8861      6032005 :       fndecl = decl;
    8862              : 
    8863      6032005 :   bool gimple_form = (cfun && (cfun->curr_properties & PROP_gimple)) != 0;
    8864      6032005 :   if (gimple_form
    8865        14070 :       ? !useless_type_conversion_p (TREE_TYPE (call),
    8866        14070 :                                     TREE_TYPE (TREE_TYPE (fndecl)))
    8867      6017935 :       : (TYPE_MAIN_VARIANT (TREE_TYPE (call))
    8868      6017935 :          != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))))
    8869              :     return false;
    8870              : 
    8871      6031789 :   tree targs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
    8872      6031789 :   unsigned nargs = call_expr_nargs (call);
    8873     15344590 :   for (unsigned i = 0; i < nargs; ++i, targs = TREE_CHAIN (targs))
    8874              :     {
    8875              :       /* Variadic args follow.  */
    8876     10720299 :       if (!targs)
    8877              :         return true;
    8878      9313458 :       tree arg = CALL_EXPR_ARG (call, i);
    8879      9313458 :       tree type = TREE_VALUE (targs);
    8880      9313458 :       if (gimple_form
    8881      9313458 :           ? !useless_type_conversion_p (type, TREE_TYPE (arg))
    8882      9299388 :           : TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (arg)))
    8883              :         {
    8884              :           /* For pointer arguments be more forgiving, e.g. due to
    8885              :              FILE * vs. fileptr_type_node, or say char * vs. const char *
    8886              :              differences etc.  */
    8887      1127209 :           if (!gimple_form
    8888       563933 :               && POINTER_TYPE_P (type)
    8889       563381 :               && POINTER_TYPE_P (TREE_TYPE (arg))
    8890      1127209 :               && tree_nop_conversion_p (type, TREE_TYPE (arg)))
    8891       563276 :             continue;
    8892          657 :           return false;
    8893              :         }
    8894              :     }
    8895      9247935 :   if (targs && !VOID_TYPE_P (TREE_VALUE (targs)))
    8896              :     return false;
    8897              :   return true;
    8898              : }
    8899              : 
    8900              : /* If CALL_EXPR CALL calls a normal built-in function or an internal function,
    8901              :    return the associated function code, otherwise return CFN_LAST.  */
    8902              : 
    8903              : combined_fn
    8904     40098086 : get_call_combined_fn (const_tree call)
    8905              : {
    8906              :   /* It's invalid to call this function with anything but a CALL_EXPR.  */
    8907     40098086 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    8908              : 
    8909     40098086 :   if (!CALL_EXPR_FN (call))
    8910        66194 :     return as_combined_fn (CALL_EXPR_IFN (call));
    8911              : 
    8912     40031892 :   tree fndecl = get_callee_fndecl (call);
    8913     40031892 :   if (fndecl
    8914     40010325 :       && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    8915     46063897 :       && tree_builtin_call_types_compatible_p (call, fndecl))
    8916      6031127 :     return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
    8917              : 
    8918              :   return CFN_LAST;
    8919              : }
    8920              : 
    8921              : /* Comparator of indices based on tree_node_counts.  */
    8922              : 
    8923              : static int
    8924            0 : tree_nodes_cmp (const void *p1, const void *p2)
    8925              : {
    8926            0 :   const unsigned *n1 = (const unsigned *)p1;
    8927            0 :   const unsigned *n2 = (const unsigned *)p2;
    8928              : 
    8929            0 :   return tree_node_counts[*n1] - tree_node_counts[*n2];
    8930              : }
    8931              : 
    8932              : /* Comparator of indices based on tree_code_counts.  */
    8933              : 
    8934              : static int
    8935            0 : tree_codes_cmp (const void *p1, const void *p2)
    8936              : {
    8937            0 :   const unsigned *n1 = (const unsigned *)p1;
    8938            0 :   const unsigned *n2 = (const unsigned *)p2;
    8939              : 
    8940            0 :   return tree_code_counts[*n1] - tree_code_counts[*n2];
    8941              : }
    8942              : 
    8943              : #define TREE_MEM_USAGE_SPACES 40
    8944              : 
    8945              : /* Print debugging information about tree nodes generated during the compile,
    8946              :    and any language-specific information.  */
    8947              : 
    8948              : void
    8949            0 : dump_tree_statistics (void)
    8950              : {
    8951            0 :   if (GATHER_STATISTICS)
    8952              :     {
    8953              :       uint64_t total_nodes, total_bytes;
    8954              :       fprintf (stderr, "\nKind                   Nodes      Bytes\n");
    8955              :       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    8956              :       total_nodes = total_bytes = 0;
    8957              : 
    8958              :       {
    8959              :         auto_vec<unsigned> indices (all_kinds);
    8960              :         for (unsigned i = 0; i < all_kinds; i++)
    8961              :           indices.quick_push (i);
    8962              :         indices.qsort (tree_nodes_cmp);
    8963              : 
    8964              :         for (unsigned i = 0; i < (int) all_kinds; i++)
    8965              :           {
    8966              :             unsigned j = indices[i];
    8967              :             fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n",
    8968              :                      tree_node_kind_names[j], SIZE_AMOUNT (tree_node_counts[j]),
    8969              :                      SIZE_AMOUNT (tree_node_sizes[j]));
    8970              :             total_nodes += tree_node_counts[j];
    8971              :             total_bytes += tree_node_sizes[j];
    8972              :           }
    8973              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    8974              :         fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n", "Total",
    8975              :                  SIZE_AMOUNT (total_nodes), SIZE_AMOUNT (total_bytes));
    8976              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    8977              :       }
    8978              : 
    8979              :       {
    8980              :         fprintf (stderr, "Code                              Nodes\n");
    8981              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    8982              : 
    8983              :         auto_vec<unsigned> indices (MAX_TREE_CODES);
    8984              :         for (unsigned i = 0; i < MAX_TREE_CODES; i++)
    8985              :           indices.quick_push (i);
    8986              :         indices.qsort (tree_codes_cmp);
    8987              : 
    8988              :         for (unsigned i = 0; i < MAX_TREE_CODES; i++)
    8989              :           {
    8990              :             unsigned j = indices[i];
    8991              :             fprintf (stderr, "%-32s %6" PRIu64 "%c\n",
    8992              :                      get_tree_code_name ((enum tree_code) j),
    8993              :                      SIZE_AMOUNT (tree_code_counts[j]));
    8994              :           }
    8995              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    8996              :         fprintf (stderr, "\n");
    8997              :         ssanames_print_statistics ();
    8998              :         fprintf (stderr, "\n");
    8999              :         phinodes_print_statistics ();
    9000              :         fprintf (stderr, "\n");
    9001              :       }
    9002              :     }
    9003              :   else
    9004            0 :     fprintf (stderr, "(No per-node statistics)\n");
    9005              : 
    9006            0 :   print_type_hash_statistics ();
    9007            0 :   print_debug_expr_statistics ();
    9008            0 :   print_value_expr_statistics ();
    9009            0 :   lang_hooks.print_statistics ();
    9010            0 : }
    9011              : 
    9012              : #define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s"
    9013              : 
    9014              : /* Generate a crc32 of the low BYTES bytes of VALUE.  */
    9015              : 
    9016              : unsigned
    9017     16574058 : crc32_unsigned_n (unsigned chksum, unsigned value, unsigned bytes)
    9018              : {
    9019              :   /* This relies on the raw feedback's top 4 bits being zero.  */
    9020              : #define FEEDBACK(X) ((X) * 0x04c11db7)
    9021              : #define SYNDROME(X) (FEEDBACK ((X) & 1) ^ FEEDBACK ((X) & 2) \
    9022              :                      ^ FEEDBACK ((X) & 4) ^ FEEDBACK ((X) & 8))
    9023     16574058 :   static const unsigned syndromes[16] =
    9024              :     {
    9025              :       SYNDROME(0x0), SYNDROME(0x1), SYNDROME(0x2), SYNDROME(0x3),
    9026              :       SYNDROME(0x4), SYNDROME(0x5), SYNDROME(0x6), SYNDROME(0x7),
    9027              :       SYNDROME(0x8), SYNDROME(0x9), SYNDROME(0xa), SYNDROME(0xb),
    9028              :       SYNDROME(0xc), SYNDROME(0xd), SYNDROME(0xe), SYNDROME(0xf),
    9029              :     };
    9030              : #undef FEEDBACK
    9031              : #undef SYNDROME
    9032              : 
    9033     16574058 :   value <<= (32 - bytes * 8);
    9034     55427418 :   for (unsigned ix = bytes * 2; ix--; value <<= 4)
    9035              :     {
    9036     38853360 :       unsigned feedback = syndromes[((value ^ chksum) >> 28) & 0xf];
    9037              : 
    9038     38853360 :       chksum = (chksum << 4) ^ feedback;
    9039              :     }
    9040              : 
    9041     16574058 :   return chksum;
    9042              : }
    9043              : 
    9044              : /* Generate a crc32 of a string.  */
    9045              : 
    9046              : unsigned
    9047         8794 : crc32_string (unsigned chksum, const char *string)
    9048              : {
    9049       351139 :   do
    9050       351139 :     chksum = crc32_byte (chksum, *string);
    9051       351139 :   while (*string++);
    9052         8794 :   return chksum;
    9053              : }
    9054              : 
    9055              : /* P is a string that will be used in a symbol.  Mask out any characters
    9056              :    that are not valid in that context.  */
    9057              : 
    9058              : void
    9059         7484 : clean_symbol_name (char *p)
    9060              : {
    9061        84116 :   for (; *p; p++)
    9062        76632 :     if (! (ISALNUM (*p)
    9063              : #ifndef NO_DOLLAR_IN_LABEL      /* this for `$'; unlikely, but... -- kr */
    9064              :             || *p == '$'
    9065              : #endif
    9066              : #ifndef NO_DOT_IN_LABEL         /* this for `.'; unlikely, but...  */
    9067              :             || *p == '.'
    9068              : #endif
    9069              :            ))
    9070         6929 :       *p = '_';
    9071         7484 : }
    9072              : 
    9073              : static GTY(()) unsigned anon_cnt = 0; /* Saved for PCH.  */
    9074              : 
    9075              : /* Create a unique anonymous identifier.  The identifier is still a
    9076              :    valid assembly label.  */
    9077              : 
    9078              : tree
    9079      3340633 : make_anon_name ()
    9080              : {
    9081      3340633 :   const char *fmt =
    9082              : #if !defined (NO_DOT_IN_LABEL)
    9083              :     "."
    9084              : #elif !defined (NO_DOLLAR_IN_LABEL)
    9085              :     "$"
    9086              : #else
    9087              :     "_"
    9088              : #endif
    9089              :     "_anon_%d";
    9090              : 
    9091      3340633 :   char buf[24];
    9092      3340633 :   int len = snprintf (buf, sizeof (buf), fmt, anon_cnt++);
    9093      3340633 :   gcc_checking_assert (len < int (sizeof (buf)));
    9094              : 
    9095      3340633 :   tree id = get_identifier_with_length (buf, len);
    9096      3340633 :   IDENTIFIER_ANON_P (id) = true;
    9097              : 
    9098      3340633 :   return id;
    9099              : }
    9100              : 
    9101              : /* Generate a name for a special-purpose function.
    9102              :    The generated name may need to be unique across the whole link.
    9103              :    Changes to this function may also require corresponding changes to
    9104              :    xstrdup_mask_random.
    9105              :    TYPE is some string to identify the purpose of this function to the
    9106              :    linker or collect2; it must start with an uppercase letter,
    9107              :    one of:
    9108              :    I - for constructors
    9109              :    D - for destructors
    9110              :    N - for C++ anonymous namespaces
    9111              :    F - for DWARF unwind frame information.  */
    9112              : 
    9113              : tree
    9114         5509 : get_file_function_name (const char *type)
    9115              : {
    9116         5509 :   char *buf;
    9117         5509 :   const char *p;
    9118         5509 :   char *q;
    9119              : 
    9120              :   /* If we already have a name we know to be unique, just use that.  */
    9121         5509 :   if (first_global_object_name)
    9122         5214 :     p = q = ASTRDUP (first_global_object_name);
    9123              :   /* If the target is handling the constructors/destructors, they
    9124              :      will be local to this file and the name is only necessary for
    9125              :      debugging purposes.
    9126              :      We also assign sub_I and sub_D suffixes to constructors called from
    9127              :      the global static constructors.  These are always local.
    9128              :      OpenMP "declare target" offloaded constructors/destructors use "off_I" and
    9129              :      "off_D" for the same purpose.  */
    9130          295 :   else if (((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors)
    9131          590 :            || ((startswith (type, "sub_") || startswith (type, "off_"))
    9132          295 :                && (type[4] == 'I' || type[4] == 'D')))
    9133              :     {
    9134          295 :       const char *file = main_input_filename;
    9135          295 :       if (! file)
    9136            0 :         file = LOCATION_FILE (input_location);
    9137              :       /* Just use the file's basename, because the full pathname
    9138              :          might be quite long.  */
    9139          295 :       p = q = ASTRDUP (lbasename (file));
    9140              :     }
    9141              :   else
    9142              :     {
    9143              :       /* Otherwise, the name must be unique across the entire link.
    9144              :          We don't have anything that we know to be unique to this translation
    9145              :          unit, so use what we do have and throw in some randomness.  */
    9146            0 :       unsigned len;
    9147            0 :       const char *name = weak_global_object_name;
    9148            0 :       const char *file = main_input_filename;
    9149              : 
    9150            0 :       if (! name)
    9151            0 :         name = "";
    9152            0 :       if (! file)
    9153            0 :         file = LOCATION_FILE (input_location);
    9154              : 
    9155            0 :       len = strlen (file);
    9156            0 :       q = (char *) alloca (9 + 19 + len + 1);
    9157            0 :       memcpy (q, file, len + 1);
    9158              : 
    9159            0 :       snprintf (q + len, 9 + 19 + 1, "_%08X_" HOST_WIDE_INT_PRINT_HEX,
    9160              :                 crc32_string (0, name), get_random_seed (false));
    9161              : 
    9162            0 :       p = q;
    9163              :     }
    9164              : 
    9165         5509 :   clean_symbol_name (q);
    9166         5509 :   buf = (char *) alloca (sizeof (FILE_FUNCTION_FORMAT) + strlen (p)
    9167              :                          + strlen (type));
    9168              : 
    9169              :   /* Set up the name of the file-level functions we may need.
    9170              :      Use a global object (which is already required to be unique over
    9171              :      the program) rather than the file name (which imposes extra
    9172              :      constraints).  */
    9173         5509 :   sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
    9174              : 
    9175         5509 :   return get_identifier (buf);
    9176              : }
    9177              : 
    9178              : #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
    9179              : 
    9180              : /* Complain that the tree code of NODE does not match the expected 0
    9181              :    terminated list of trailing codes.  The trailing code list can be
    9182              :    empty, for a more vague error message.  FILE, LINE, and FUNCTION
    9183              :    are of the caller.  */
    9184              : 
    9185              : void
    9186            0 : tree_check_failed (const_tree node, const char *file,
    9187              :                    int line, const char *function, ...)
    9188              : {
    9189            0 :   va_list args;
    9190            0 :   const char *buffer;
    9191            0 :   unsigned length = 0;
    9192            0 :   enum tree_code code;
    9193              : 
    9194            0 :   va_start (args, function);
    9195            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9196            0 :     length += 4 + strlen (get_tree_code_name (code));
    9197            0 :   va_end (args);
    9198            0 :   if (length)
    9199              :     {
    9200            0 :       char *tmp;
    9201            0 :       va_start (args, function);
    9202            0 :       length += strlen ("expected ");
    9203            0 :       buffer = tmp = (char *) alloca (length);
    9204            0 :       length = 0;
    9205            0 :       while ((code = (enum tree_code) va_arg (args, int)))
    9206              :         {
    9207            0 :           const char *prefix = length ? " or " : "expected ";
    9208              : 
    9209            0 :           strcpy (tmp + length, prefix);
    9210            0 :           length += strlen (prefix);
    9211            0 :           strcpy (tmp + length, get_tree_code_name (code));
    9212            0 :           length += strlen (get_tree_code_name (code));
    9213              :         }
    9214            0 :       va_end (args);
    9215              :     }
    9216              :   else
    9217              :     buffer = "unexpected node";
    9218              : 
    9219            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9220            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9221              :                   function, trim_filename (file), line);
    9222              : }
    9223              : 
    9224              : /* Complain that the tree code of NODE does match the expected 0
    9225              :    terminated list of trailing codes. FILE, LINE, and FUNCTION are of
    9226              :    the caller.  */
    9227              : 
    9228              : void
    9229            0 : tree_not_check_failed (const_tree node, const char *file,
    9230              :                        int line, const char *function, ...)
    9231              : {
    9232            0 :   va_list args;
    9233            0 :   char *buffer;
    9234            0 :   unsigned length = 0;
    9235            0 :   enum tree_code code;
    9236              : 
    9237            0 :   va_start (args, function);
    9238            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9239            0 :     length += 4 + strlen (get_tree_code_name (code));
    9240            0 :   va_end (args);
    9241            0 :   va_start (args, function);
    9242            0 :   buffer = (char *) alloca (length);
    9243            0 :   length = 0;
    9244            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9245              :     {
    9246            0 :       if (length)
    9247              :         {
    9248            0 :           strcpy (buffer + length, " or ");
    9249            0 :           length += 4;
    9250              :         }
    9251            0 :       strcpy (buffer + length, get_tree_code_name (code));
    9252            0 :       length += strlen (get_tree_code_name (code));
    9253              :     }
    9254            0 :   va_end (args);
    9255              : 
    9256            0 :   internal_error ("tree check: expected none of %s, have %s in %s, at %s:%d",
    9257            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9258              :                   function, trim_filename (file), line);
    9259              : }
    9260              : 
    9261              : /* Similar to tree_check_failed, except that we check for a class of tree
    9262              :    code, given in CL.  */
    9263              : 
    9264              : void
    9265            0 : tree_class_check_failed (const_tree node, const enum tree_code_class cl,
    9266              :                          const char *file, int line, const char *function)
    9267              : {
    9268            0 :   internal_error
    9269            0 :     ("tree check: expected class %qs, have %qs (%s) in %s, at %s:%d",
    9270            0 :      TREE_CODE_CLASS_STRING (cl),
    9271            0 :      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
    9272            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9273              : }
    9274              : 
    9275              : /* Similar to tree_check_failed, except that instead of specifying a
    9276              :    dozen codes, use the knowledge that they're all sequential.  */
    9277              : 
    9278              : void
    9279            0 : tree_range_check_failed (const_tree node, const char *file, int line,
    9280              :                          const char *function, enum tree_code c1,
    9281              :                          enum tree_code c2)
    9282              : {
    9283            0 :   char *buffer;
    9284            0 :   unsigned length = 0;
    9285            0 :   unsigned int c;
    9286              : 
    9287            0 :   for (c = c1; c <= c2; ++c)
    9288            0 :     length += 4 + strlen (get_tree_code_name ((enum tree_code) c));
    9289              : 
    9290            0 :   length += strlen ("expected ");
    9291            0 :   buffer = (char *) alloca (length);
    9292            0 :   length = 0;
    9293              : 
    9294            0 :   for (c = c1; c <= c2; ++c)
    9295              :     {
    9296            0 :       const char *prefix = length ? " or " : "expected ";
    9297              : 
    9298            0 :       strcpy (buffer + length, prefix);
    9299            0 :       length += strlen (prefix);
    9300            0 :       strcpy (buffer + length, get_tree_code_name ((enum tree_code) c));
    9301            0 :       length += strlen (get_tree_code_name ((enum tree_code) c));
    9302              :     }
    9303              : 
    9304            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9305            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9306              :                   function, trim_filename (file), line);
    9307              : }
    9308              : 
    9309              : 
    9310              : /* Similar to tree_check_failed, except that we check that a tree does
    9311              :    not have the specified code, given in CL.  */
    9312              : 
    9313              : void
    9314            0 : tree_not_class_check_failed (const_tree node, const enum tree_code_class cl,
    9315              :                              const char *file, int line, const char *function)
    9316              : {
    9317            0 :   internal_error
    9318            0 :     ("tree check: did not expect class %qs, have %qs (%s) in %s, at %s:%d",
    9319            0 :      TREE_CODE_CLASS_STRING (cl),
    9320            0 :      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
    9321            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9322              : }
    9323              : 
    9324              : 
    9325              : /* Similar to tree_check_failed but applied to OMP_CLAUSE codes.  */
    9326              : 
    9327              : void
    9328            0 : omp_clause_check_failed (const_tree node, const char *file, int line,
    9329              :                          const char *function, enum omp_clause_code code)
    9330              : {
    9331            0 :   internal_error ("tree check: expected %<omp_clause %s%>, have %qs "
    9332              :                   "in %s, at %s:%d",
    9333            0 :                   omp_clause_code_name[code],
    9334            0 :                   get_tree_code_name (TREE_CODE (node)),
    9335              :                   function, trim_filename (file), line);
    9336              : }
    9337              : 
    9338              : 
    9339              : /* Similar to tree_range_check_failed but applied to OMP_CLAUSE codes.  */
    9340              : 
    9341              : void
    9342            0 : omp_clause_range_check_failed (const_tree node, const char *file, int line,
    9343              :                                const char *function, enum omp_clause_code c1,
    9344              :                                enum omp_clause_code c2)
    9345              : {
    9346            0 :   char *buffer;
    9347            0 :   unsigned length = 0;
    9348            0 :   unsigned int c;
    9349              : 
    9350            0 :   for (c = c1; c <= c2; ++c)
    9351            0 :     length += 4 + strlen (omp_clause_code_name[c]);
    9352              : 
    9353            0 :   length += strlen ("expected ");
    9354            0 :   buffer = (char *) alloca (length);
    9355            0 :   length = 0;
    9356              : 
    9357            0 :   for (c = c1; c <= c2; ++c)
    9358              :     {
    9359            0 :       const char *prefix = length ? " or " : "expected ";
    9360              : 
    9361            0 :       strcpy (buffer + length, prefix);
    9362            0 :       length += strlen (prefix);
    9363            0 :       strcpy (buffer + length, omp_clause_code_name[c]);
    9364            0 :       length += strlen (omp_clause_code_name[c]);
    9365              :     }
    9366              : 
    9367            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9368            0 :                   buffer, omp_clause_code_name[TREE_CODE (node)],
    9369              :                   function, trim_filename (file), line);
    9370              : }
    9371              : 
    9372              : 
    9373              : #undef DEFTREESTRUCT
    9374              : #define DEFTREESTRUCT(VAL, NAME) NAME,
    9375              : 
    9376              : static const char *ts_enum_names[] = {
    9377              : #include "treestruct.def"
    9378              : };
    9379              : #undef DEFTREESTRUCT
    9380              : 
    9381              : #define TS_ENUM_NAME(EN) (ts_enum_names[(EN)])
    9382              : 
    9383              : /* Similar to tree_class_check_failed, except that we check for
    9384              :    whether CODE contains the tree structure identified by EN.  */
    9385              : 
    9386              : void
    9387            0 : tree_contains_struct_check_failed (const_tree node,
    9388              :                                    const enum tree_node_structure_enum en,
    9389              :                                    const char *file, int line,
    9390              :                                    const char *function)
    9391              : {
    9392            0 :   internal_error
    9393            0 :     ("tree check: expected tree that contains %qs structure, have %qs in %s, at %s:%d",
    9394            0 :      TS_ENUM_NAME (en),
    9395            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9396              : }
    9397              : 
    9398              : 
    9399              : /* Similar to above, except that the check is for the bounds of a TREE_VEC's
    9400              :    (dynamically sized) vector.  */
    9401              : 
    9402              : void
    9403            0 : tree_int_cst_elt_check_failed (int idx, int len, const char *file, int line,
    9404              :                                const char *function)
    9405              : {
    9406            0 :   internal_error
    9407            0 :     ("tree check: accessed elt %d of %<tree_int_cst%> with %d elts in %s, "
    9408              :      "at %s:%d",
    9409              :      idx + 1, len, function, trim_filename (file), line);
    9410              : }
    9411              : 
    9412              : /* Similar to above, except that the check is for the bounds of a TREE_VEC's
    9413              :    (dynamically sized) vector.  */
    9414              : 
    9415              : void
    9416            0 : tree_vec_elt_check_failed (int idx, int len, const char *file, int line,
    9417              :                            const char *function)
    9418              : {
    9419            0 :   internal_error
    9420            0 :     ("tree check: accessed elt %d of %<tree_vec%> with %d elts in %s, at %s:%d",
    9421              :      idx + 1, len, function, trim_filename (file), line);
    9422              : }
    9423              : 
    9424              : /* Similar to above, except that the check is for the bounds of the operand
    9425              :    vector of an expression node EXP.  */
    9426              : 
    9427              : void
    9428            0 : tree_operand_check_failed (int idx, const_tree exp, const char *file,
    9429              :                            int line, const char *function)
    9430              : {
    9431            0 :   enum tree_code code = TREE_CODE (exp);
    9432            0 :   internal_error
    9433            0 :     ("tree check: accessed operand %d of %s with %d operands in %s, at %s:%d",
    9434              :      idx + 1, get_tree_code_name (code), TREE_OPERAND_LENGTH (exp),
    9435              :      function, trim_filename (file), line);
    9436              : }
    9437              : 
    9438              : /* Similar to above, except that the check is for the number of
    9439              :    operands of an OMP_CLAUSE node.  */
    9440              : 
    9441              : void
    9442            0 : omp_clause_operand_check_failed (int idx, const_tree t, const char *file,
    9443              :                                  int line, const char *function)
    9444              : {
    9445            0 :   internal_error
    9446            0 :     ("tree check: accessed operand %d of %<omp_clause %s%> with %d operands "
    9447            0 :      "in %s, at %s:%d", idx + 1, omp_clause_code_name[OMP_CLAUSE_CODE (t)],
    9448            0 :      omp_clause_num_ops [OMP_CLAUSE_CODE (t)], function,
    9449              :      trim_filename (file), line);
    9450              : }
    9451              : #endif /* ENABLE_TREE_CHECKING */
    9452              : 
    9453              : /* Create a new vector type node holding NUNITS units of type INNERTYPE,
    9454              :    and mapped to the machine mode MODE.  Initialize its fields and build
    9455              :    the information necessary for debugging output.  */
    9456              : 
    9457              : static tree
    9458     72009518 : make_vector_type (tree innertype, poly_int64 nunits, machine_mode mode)
    9459              : {
    9460     72009518 :   tree t;
    9461     72009518 :   tree mv_innertype = TYPE_MAIN_VARIANT (innertype);
    9462              : 
    9463     72009518 :   t = make_node (VECTOR_TYPE);
    9464     72009518 :   TREE_TYPE (t) = mv_innertype;
    9465     72009518 :   SET_TYPE_VECTOR_SUBPARTS (t, nunits);
    9466     72009518 :   SET_TYPE_MODE (t, mode);
    9467              : 
    9468     72009518 :   if (TYPE_STRUCTURAL_EQUALITY_P (mv_innertype) || in_lto_p)
    9469      1266923 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    9470     70742595 :   else if ((TYPE_CANONICAL (mv_innertype) != innertype
    9471     67243663 :             || mode != VOIDmode)
    9472    102353640 :            && !VECTOR_BOOLEAN_TYPE_P (t))
    9473     32618033 :     TYPE_CANONICAL (t)
    9474     65236066 :       = make_vector_type (TYPE_CANONICAL (mv_innertype), nunits, VOIDmode);
    9475              : 
    9476     72009518 :   layout_type (t);
    9477              : 
    9478     72009518 :   hashval_t hash = type_hash_canon_hash (t);
    9479     72009518 :   t = type_hash_canon (hash, t);
    9480              : 
    9481              :   /* We have built a main variant, based on the main variant of the
    9482              :      inner type. Use it to build the variant we return.  */
    9483    144013566 :   if ((TYPE_ATTRIBUTES (innertype) || TYPE_QUALS (innertype))
    9484     72782689 :       && TREE_TYPE (t) != innertype)
    9485       777316 :     return build_type_attribute_qual_variant (t,
    9486       777316 :                                               TYPE_ATTRIBUTES (innertype),
    9487      1554632 :                                               TYPE_QUALS (innertype));
    9488              : 
    9489              :   return t;
    9490              : }
    9491              : 
    9492              : static tree
    9493      4171550 : make_or_reuse_type (unsigned size, int unsignedp)
    9494              : {
    9495      4171550 :   int i;
    9496              : 
    9497      4171550 :   if (size == INT_TYPE_SIZE)
    9498       895437 :     return unsignedp ? unsigned_type_node : integer_type_node;
    9499      3276113 :   if (size == CHAR_TYPE_SIZE)
    9500       596958 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    9501      2679155 :   if (size == SHORT_TYPE_SIZE)
    9502       895437 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    9503      1820110 :   if (size == LONG_TYPE_SIZE)
    9504       873663 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    9505       910055 :   if (size == LONG_LONG_TYPE_SIZE)
    9506        21774 :     return (unsignedp ? long_long_unsigned_type_node
    9507        21774 :             : long_long_integer_type_node);
    9508              : 
    9509       902593 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    9510       888281 :     if (size == int_n_data[i].bitsize
    9511       888281 :         && int_n_enabled_p[i])
    9512       873969 :       return (unsignedp ? int_n_trees[i].unsigned_type
    9513       873969 :               : int_n_trees[i].signed_type);
    9514              : 
    9515        14312 :   if (unsignedp)
    9516         7156 :     return make_unsigned_type (size);
    9517              :   else
    9518         7156 :     return make_signed_type (size);
    9519              : }
    9520              : 
    9521              : /* Create or reuse a fract type by SIZE, UNSIGNEDP, and SATP.  */
    9522              : 
    9523              : static tree
    9524      5969580 : make_or_reuse_fract_type (unsigned size, int unsignedp, int satp)
    9525              : {
    9526      5969580 :   if (satp)
    9527              :     {
    9528      2984790 :       if (size == SHORT_FRACT_TYPE_SIZE)
    9529       596958 :         return unsignedp ? sat_unsigned_short_fract_type_node
    9530       596958 :                          : sat_short_fract_type_node;
    9531      2387832 :       if (size == FRACT_TYPE_SIZE)
    9532       596958 :         return unsignedp ? sat_unsigned_fract_type_node : sat_fract_type_node;
    9533      1790874 :       if (size == LONG_FRACT_TYPE_SIZE)
    9534       596958 :         return unsignedp ? sat_unsigned_long_fract_type_node
    9535       596958 :                          : sat_long_fract_type_node;
    9536      1193916 :       if (size == LONG_LONG_FRACT_TYPE_SIZE)
    9537       596958 :         return unsignedp ? sat_unsigned_long_long_fract_type_node
    9538       596958 :                          : sat_long_long_fract_type_node;
    9539              :     }
    9540              :   else
    9541              :     {
    9542      2984790 :       if (size == SHORT_FRACT_TYPE_SIZE)
    9543       596958 :         return unsignedp ? unsigned_short_fract_type_node
    9544       596958 :                          : short_fract_type_node;
    9545      2387832 :       if (size == FRACT_TYPE_SIZE)
    9546       596958 :         return unsignedp ? unsigned_fract_type_node : fract_type_node;
    9547      1790874 :       if (size == LONG_FRACT_TYPE_SIZE)
    9548       596958 :         return unsignedp ? unsigned_long_fract_type_node
    9549       596958 :                          : long_fract_type_node;
    9550      1193916 :       if (size == LONG_LONG_FRACT_TYPE_SIZE)
    9551       596958 :         return unsignedp ? unsigned_long_long_fract_type_node
    9552       596958 :                          : long_long_fract_type_node;
    9553              :     }
    9554              : 
    9555      1193916 :   return make_fract_type (size, unsignedp, satp);
    9556              : }
    9557              : 
    9558              : /* Create or reuse an accum type by SIZE, UNSIGNEDP, and SATP.  */
    9559              : 
    9560              : static tree
    9561      4775664 : make_or_reuse_accum_type (unsigned size, int unsignedp, int satp)
    9562              : {
    9563      4775664 :   if (satp)
    9564              :     {
    9565      2387832 :       if (size == SHORT_ACCUM_TYPE_SIZE)
    9566       596958 :         return unsignedp ? sat_unsigned_short_accum_type_node
    9567       596958 :                          : sat_short_accum_type_node;
    9568      1790874 :       if (size == ACCUM_TYPE_SIZE)
    9569       596958 :         return unsignedp ? sat_unsigned_accum_type_node : sat_accum_type_node;
    9570      1193916 :       if (size == LONG_ACCUM_TYPE_SIZE)
    9571       596958 :         return unsignedp ? sat_unsigned_long_accum_type_node
    9572       596958 :                          : sat_long_accum_type_node;
    9573       596958 :       if (size == LONG_LONG_ACCUM_TYPE_SIZE)
    9574       596958 :         return unsignedp ? sat_unsigned_long_long_accum_type_node
    9575       596958 :                          : sat_long_long_accum_type_node;
    9576              :     }
    9577              :   else
    9578              :     {
    9579      2387832 :       if (size == SHORT_ACCUM_TYPE_SIZE)
    9580       596958 :         return unsignedp ? unsigned_short_accum_type_node
    9581       596958 :                          : short_accum_type_node;
    9582      1790874 :       if (size == ACCUM_TYPE_SIZE)
    9583       596958 :         return unsignedp ? unsigned_accum_type_node : accum_type_node;
    9584      1193916 :       if (size == LONG_ACCUM_TYPE_SIZE)
    9585       596958 :         return unsignedp ? unsigned_long_accum_type_node
    9586       596958 :                          : long_accum_type_node;
    9587       596958 :       if (size == LONG_LONG_ACCUM_TYPE_SIZE)
    9588       596958 :         return unsignedp ? unsigned_long_long_accum_type_node
    9589       596958 :                          : long_long_accum_type_node;
    9590              :     }
    9591              : 
    9592            0 :   return make_accum_type (size, unsignedp, satp);
    9593              : }
    9594              : 
    9595              : 
    9596              : /* Create an atomic variant node for TYPE.  This routine is called
    9597              :    during initialization of data types to create the 5 basic atomic
    9598              :    types.  The generic build_variant_type function requires these to
    9599              :    already be set up in order to function properly, so cannot be
    9600              :    called from there.  If ALIGN is non-zero, then ensure alignment is
    9601              :    overridden to this value.  */
    9602              : 
    9603              : static tree
    9604      1492395 : build_atomic_base (tree type, unsigned int align)
    9605              : {
    9606      1492395 :   tree t;
    9607              : 
    9608              :   /* Make sure its not already registered.  */
    9609      1492395 :   if ((t = get_qualified_type (type, TYPE_QUAL_ATOMIC)))
    9610              :     return t;
    9611              : 
    9612      1492395 :   t = build_variant_type_copy (type);
    9613      1492395 :   set_type_quals (t, TYPE_QUAL_ATOMIC);
    9614              : 
    9615      1492395 :   if (align)
    9616            0 :     SET_TYPE_ALIGN (t, align);
    9617              : 
    9618              :   return t;
    9619              : }
    9620              : 
    9621              : /* Return unsigned integer tree node for TYPE.  */
    9622              : 
    9623              : tree
    9624       298519 : unsigned_integer_tree_node_for_type (const char *type)
    9625              : {
    9626       298519 :   tree type_node;
    9627              : 
    9628       298519 :   if (strcmp (type, "unsigned int") == 0)
    9629         7258 :     type_node = unsigned_type_node;
    9630       291261 :   else if (strcmp (type, "long unsigned int") == 0)
    9631       291261 :     type_node = long_unsigned_type_node;
    9632            0 :   else if (strcmp (type, "long long unsigned int") == 0)
    9633            0 :     type_node = long_long_unsigned_type_node;
    9634            0 :   else if (strcmp (type, "short unsigned int") == 0)
    9635            0 :     type_node = short_unsigned_type_node;
    9636              :   else
    9637              :     {
    9638              :       int i;
    9639              : 
    9640              :       type_node = nullptr;
    9641            0 :       for (i = 0; i < NUM_INT_N_ENTS; i++)
    9642            0 :         if (int_n_enabled_p[i])
    9643              :           {
    9644            0 :             char name[50], altname[50];
    9645            0 :             sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
    9646            0 :             sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
    9647              : 
    9648            0 :             if (strcmp (name, type) == 0
    9649            0 :                 || strcmp (altname, type) == 0)
    9650              :               {
    9651            0 :                 type_node = int_n_trees[i].unsigned_type;
    9652              :               }
    9653              :           }
    9654            0 :       if (type_node == nullptr)
    9655            0 :         gcc_unreachable ();
    9656              :     }
    9657              : 
    9658       298519 :   return type_node;
    9659              : }
    9660              : 
    9661              : /* Information about the _FloatN and _FloatNx types.  This must be in
    9662              :    the same order as the corresponding TI_* enum values.  */
    9663              : const floatn_type_info floatn_nx_types[NUM_FLOATN_NX_TYPES] =
    9664              :   {
    9665              :     { 16, false },
    9666              :     { 32, false },
    9667              :     { 64, false },
    9668              :     { 128, false },
    9669              :     { 32, true },
    9670              :     { 64, true },
    9671              :     { 128, true },
    9672              :   };
    9673              : 
    9674              : 
    9675              : /* Create nodes for all integer types (and error_mark_node) using the sizes
    9676              :    of C datatypes.  SIGNED_CHAR specifies whether char is signed.  */
    9677              : 
    9678              : void
    9679       298479 : build_common_tree_nodes (bool signed_char)
    9680              : {
    9681       298479 :   int i;
    9682              : 
    9683       298479 :   error_mark_node = make_node (ERROR_MARK);
    9684       298479 :   TREE_TYPE (error_mark_node) = error_mark_node;
    9685              : 
    9686       298479 :   initialize_sizetypes ();
    9687              : 
    9688              :   /* Define both `signed char' and `unsigned char'.  */
    9689       298479 :   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
    9690       298479 :   TYPE_STRING_FLAG (signed_char_type_node) = 1;
    9691       298479 :   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
    9692       298479 :   TYPE_STRING_FLAG (unsigned_char_type_node) = 1;
    9693              : 
    9694              :   /* Define `char', which is like either `signed char' or `unsigned char'
    9695              :      but not the same as either.  */
    9696       298479 :   char_type_node
    9697       298479 :     = (signed_char
    9698       298479 :        ? make_signed_type (CHAR_TYPE_SIZE)
    9699        57576 :        : make_unsigned_type (CHAR_TYPE_SIZE));
    9700       298479 :   TYPE_STRING_FLAG (char_type_node) = 1;
    9701              : 
    9702       298479 :   short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
    9703       298479 :   short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
    9704       298479 :   integer_type_node = make_signed_type (INT_TYPE_SIZE);
    9705       298479 :   unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
    9706       305737 :   long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
    9707       305737 :   long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
    9708       298479 :   long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
    9709       298479 :   long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
    9710              : 
    9711       895437 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    9712              :     {
    9713       298479 :       int_n_trees[i].signed_type = make_signed_type (int_n_data[i].bitsize);
    9714       298479 :       int_n_trees[i].unsigned_type = make_unsigned_type (int_n_data[i].bitsize);
    9715              : 
    9716       298479 :       if (int_n_enabled_p[i])
    9717              :         {
    9718       291323 :           integer_types[itk_intN_0 + i * 2] = int_n_trees[i].signed_type;
    9719       291323 :           integer_types[itk_unsigned_intN_0 + i * 2] = int_n_trees[i].unsigned_type;
    9720              :         }
    9721              :     }
    9722              : 
    9723              :   /* Define a boolean type.  This type only represents boolean values but
    9724              :      may be larger than char depending on the value of BOOL_TYPE_SIZE.  */
    9725       298479 :   boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
    9726       298479 :   TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
    9727       298479 :   TYPE_PRECISION (boolean_type_node) = 1;
    9728       298479 :   TYPE_MAX_VALUE (boolean_type_node) = build_int_cst (boolean_type_node, 1);
    9729              : 
    9730              :   /* Define what type to use for size_t.  */
    9731       305737 :   size_type_node = unsigned_integer_tree_node_for_type (SIZE_TYPE);
    9732              : 
    9733              :   /* Define what type to use for ptrdiff_t.  */
    9734       305737 :   if (strcmp (PTRDIFF_TYPE, "int") == 0)
    9735         7258 :     ptrdiff_type_node = integer_type_node;
    9736       291221 :   else if (strcmp (PTRDIFF_TYPE, "long int") == 0)
    9737       291221 :     ptrdiff_type_node = long_integer_type_node;
    9738            0 :   else if (strcmp (PTRDIFF_TYPE, "long long int") == 0)
    9739            0 :     ptrdiff_type_node = long_long_integer_type_node;
    9740            0 :   else if (strcmp (PTRDIFF_TYPE, "short int") == 0)
    9741            0 :     ptrdiff_type_node = short_integer_type_node;
    9742              :   else
    9743              :     {
    9744            0 :       ptrdiff_type_node = NULL_TREE;
    9745            0 :       for (int i = 0; i < NUM_INT_N_ENTS; i++)
    9746            0 :         if (int_n_enabled_p[i])
    9747              :           {
    9748            0 :             char name[50], altname[50];
    9749            0 :             sprintf (name, "__int%d", int_n_data[i].bitsize);
    9750            0 :             sprintf (altname, "__int%d__", int_n_data[i].bitsize);
    9751              : 
    9752            0 :             if (strcmp (name, PTRDIFF_TYPE) == 0
    9753            0 :                 || strcmp (altname, PTRDIFF_TYPE) == 0)
    9754            0 :               ptrdiff_type_node = int_n_trees[i].signed_type;
    9755              :           }
    9756            0 :       if (ptrdiff_type_node == NULL_TREE)
    9757            0 :         gcc_unreachable ();
    9758              :     }
    9759              : 
    9760              :   /* Fill in the rest of the sized types.  Reuse existing type nodes
    9761              :      when possible.  */
    9762       298479 :   intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 0);
    9763       298479 :   intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 0);
    9764       298479 :   intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 0);
    9765       298479 :   intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 0);
    9766       298479 :   intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 0);
    9767              : 
    9768       298479 :   unsigned_intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 1);
    9769       298479 :   unsigned_intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 1);
    9770       298479 :   unsigned_intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 1);
    9771       298479 :   unsigned_intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 1);
    9772       298479 :   unsigned_intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 1);
    9773              : 
    9774              :   /* Don't call build_qualified type for atomics.  That routine does
    9775              :      special processing for atomics, and until they are initialized
    9776              :      it's better not to make that call.
    9777              : 
    9778              :      Check to see if there is a target override for atomic types.  */
    9779              : 
    9780       298479 :   atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node,
    9781       298479 :                                         targetm.atomic_align_for_mode (QImode));
    9782       298479 :   atomicHI_type_node = build_atomic_base (unsigned_intHI_type_node,
    9783       298479 :                                         targetm.atomic_align_for_mode (HImode));
    9784       298479 :   atomicSI_type_node = build_atomic_base (unsigned_intSI_type_node,
    9785       298479 :                                         targetm.atomic_align_for_mode (SImode));
    9786       298479 :   atomicDI_type_node = build_atomic_base (unsigned_intDI_type_node,
    9787       298479 :                                         targetm.atomic_align_for_mode (DImode));
    9788       298479 :   atomicTI_type_node = build_atomic_base (unsigned_intTI_type_node,
    9789       298479 :                                         targetm.atomic_align_for_mode (TImode));
    9790              : 
    9791       298479 :   access_public_node = get_identifier ("public");
    9792       298479 :   access_protected_node = get_identifier ("protected");
    9793       298479 :   access_private_node = get_identifier ("private");
    9794              : 
    9795              :   /* Define these next since types below may used them.  */
    9796       298479 :   integer_zero_node = build_int_cst (integer_type_node, 0);
    9797       298479 :   integer_one_node = build_int_cst (integer_type_node, 1);
    9798       298479 :   integer_minus_one_node = build_int_cst (integer_type_node, -1);
    9799              : 
    9800       298479 :   size_zero_node = size_int (0);
    9801       298479 :   size_one_node = size_int (1);
    9802       298479 :   bitsize_zero_node = bitsize_int (0);
    9803       298479 :   bitsize_one_node = bitsize_int (1);
    9804       298479 :   bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
    9805              : 
    9806       298479 :   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
    9807       298479 :   boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
    9808              : 
    9809       298479 :   void_type_node = make_node (VOID_TYPE);
    9810       298479 :   layout_type (void_type_node);
    9811              : 
    9812              :   /* We are not going to have real types in C with less than byte alignment,
    9813              :      so we might as well not have any types that claim to have it.  */
    9814       298479 :   SET_TYPE_ALIGN (void_type_node, BITS_PER_UNIT);
    9815       298479 :   TYPE_USER_ALIGN (void_type_node) = 0;
    9816              : 
    9817       298479 :   void_node = make_node (VOID_CST);
    9818       298479 :   TREE_TYPE (void_node) = void_type_node;
    9819              : 
    9820       298479 :   void_list_node = build_tree_list (NULL_TREE, void_type_node);
    9821              : 
    9822       298479 :   null_pointer_node = build_int_cst (build_pointer_type (void_type_node), 0);
    9823       298479 :   layout_type (TREE_TYPE (null_pointer_node));
    9824              : 
    9825       298479 :   ptr_type_node = build_pointer_type (void_type_node);
    9826       298479 :   const_ptr_type_node
    9827       298479 :     = build_pointer_type (build_type_variant (void_type_node, 1, 0));
    9828      2089353 :   for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
    9829      1790874 :     builtin_structptr_types[i].node = builtin_structptr_types[i].base;
    9830              : 
    9831       305737 :   pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
    9832              : 
    9833       298479 :   float_type_node = make_node (REAL_TYPE);
    9834       298479 :   machine_mode float_type_mode
    9835       298479 :     = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
    9836       298479 :   SET_TYPE_MODE (float_type_node, float_type_mode);
    9837       298479 :   TYPE_PRECISION (float_type_node)
    9838       298479 :     = GET_MODE_PRECISION (float_type_mode).to_constant ();
    9839       298479 :   layout_type (float_type_node);
    9840              : 
    9841       298479 :   double_type_node = make_node (REAL_TYPE);
    9842       298479 :   machine_mode double_type_mode
    9843       298479 :     = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
    9844       298479 :   SET_TYPE_MODE (double_type_node, double_type_mode);
    9845       298479 :   TYPE_PRECISION (double_type_node)
    9846       298479 :     = GET_MODE_PRECISION (double_type_mode).to_constant ();
    9847       298479 :   layout_type (double_type_node);
    9848              : 
    9849       298479 :   long_double_type_node = make_node (REAL_TYPE);
    9850       298479 :   machine_mode long_double_type_mode
    9851       298479 :     = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
    9852       298479 :   SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
    9853       298479 :   TYPE_PRECISION (long_double_type_node)
    9854       298479 :     = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
    9855       298479 :   layout_type (long_double_type_node);
    9856              : 
    9857      2387832 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    9858              :     {
    9859      2089353 :       int n = floatn_nx_types[i].n;
    9860      2089353 :       bool extended = floatn_nx_types[i].extended;
    9861      2089353 :       scalar_float_mode mode;
    9862      2089353 :       if (!targetm.floatn_mode (n, extended).exists (&mode))
    9863       298479 :         continue;
    9864      1790874 :       int precision = GET_MODE_PRECISION (mode);
    9865      1790874 :       FLOATN_NX_TYPE_NODE (i) = make_node (REAL_TYPE);
    9866      1790874 :       TYPE_PRECISION (FLOATN_NX_TYPE_NODE (i)) = precision;
    9867      1790874 :       layout_type (FLOATN_NX_TYPE_NODE (i));
    9868      1790874 :       SET_TYPE_MODE (FLOATN_NX_TYPE_NODE (i), mode);
    9869              :     }
    9870       298479 :   float128t_type_node = float128_type_node;
    9871              : #ifdef HAVE_BFmode
    9872       298479 :   if (REAL_MODE_FORMAT (BFmode) == &arm_bfloat_half_format
    9873       298479 :       && targetm.scalar_mode_supported_p (BFmode)
    9874       596958 :       && targetm.libgcc_floating_mode_supported_p (BFmode))
    9875              :     {
    9876       298479 :       bfloat16_type_node = make_node (REAL_TYPE);
    9877       298479 :       TYPE_PRECISION (bfloat16_type_node) = GET_MODE_PRECISION (BFmode);
    9878       298479 :       layout_type (bfloat16_type_node);
    9879       298479 :       SET_TYPE_MODE (bfloat16_type_node, BFmode);
    9880              :     }
    9881              : #endif
    9882              : 
    9883       298479 :   float_ptr_type_node = build_pointer_type (float_type_node);
    9884       298479 :   double_ptr_type_node = build_pointer_type (double_type_node);
    9885       298479 :   long_double_ptr_type_node = build_pointer_type (long_double_type_node);
    9886       298479 :   integer_ptr_type_node = build_pointer_type (integer_type_node);
    9887              : 
    9888              :   /* Fixed size integer types.  */
    9889       298479 :   uint16_type_node = make_or_reuse_type (16, 1);
    9890       298479 :   uint32_type_node = make_or_reuse_type (32, 1);
    9891       298479 :   uint64_type_node = make_or_reuse_type (64, 1);
    9892       298479 :   if (targetm.scalar_mode_supported_p (TImode))
    9893       291323 :     uint128_type_node = make_or_reuse_type (128, 1);
    9894              : 
    9895              :   /* Decimal float types. */
    9896       298479 :   if (targetm.decimal_float_supported_p ())
    9897              :     {
    9898       298479 :       dfloat32_type_node = make_node (REAL_TYPE);
    9899       298479 :       TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE;
    9900       298479 :       SET_TYPE_MODE (dfloat32_type_node, SDmode);
    9901       298479 :       layout_type (dfloat32_type_node);
    9902              : 
    9903       298479 :       dfloat64_type_node = make_node (REAL_TYPE);
    9904       298479 :       TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE;
    9905       298479 :       SET_TYPE_MODE (dfloat64_type_node, DDmode);
    9906       298479 :       layout_type (dfloat64_type_node);
    9907              : 
    9908       298479 :       dfloat128_type_node = make_node (REAL_TYPE);
    9909       298479 :       TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE;
    9910       298479 :       SET_TYPE_MODE (dfloat128_type_node, TDmode);
    9911       298479 :       layout_type (dfloat128_type_node);
    9912              : 
    9913       298479 :       dfloat64x_type_node = make_node (REAL_TYPE);
    9914       298479 :       TYPE_PRECISION (dfloat64x_type_node) = DECIMAL128_TYPE_SIZE;
    9915       298479 :       SET_TYPE_MODE (dfloat64x_type_node, TDmode);
    9916       298479 :       layout_type (dfloat64x_type_node);
    9917              :     }
    9918              : 
    9919       298479 :   complex_integer_type_node = build_complex_type (integer_type_node, true);
    9920       298479 :   complex_float_type_node = build_complex_type (float_type_node, true);
    9921       298479 :   complex_double_type_node = build_complex_type (double_type_node, true);
    9922       298479 :   complex_long_double_type_node = build_complex_type (long_double_type_node,
    9923              :                                                       true);
    9924              : 
    9925      2387832 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    9926              :     {
    9927      2089353 :       if (FLOATN_NX_TYPE_NODE (i) != NULL_TREE)
    9928      1790874 :         COMPLEX_FLOATN_NX_TYPE_NODE (i)
    9929      1790874 :           = build_complex_type (FLOATN_NX_TYPE_NODE (i));
    9930              :     }
    9931              : 
    9932              : /* Make fixed-point nodes based on sat/non-sat and signed/unsigned.  */
    9933              : #define MAKE_FIXED_TYPE_NODE(KIND,SIZE) \
    9934              :   sat_ ## KIND ## _type_node = \
    9935              :     make_sat_signed_ ## KIND ## _type (SIZE); \
    9936              :   sat_unsigned_ ## KIND ## _type_node = \
    9937              :     make_sat_unsigned_ ## KIND ## _type (SIZE); \
    9938              :   KIND ## _type_node = make_signed_ ## KIND ## _type (SIZE); \
    9939              :   unsigned_ ## KIND ## _type_node = \
    9940              :     make_unsigned_ ## KIND ## _type (SIZE);
    9941              : 
    9942              : #define MAKE_FIXED_TYPE_NODE_WIDTH(KIND,WIDTH,SIZE) \
    9943              :   sat_ ## WIDTH ## KIND ## _type_node = \
    9944              :     make_sat_signed_ ## KIND ## _type (SIZE); \
    9945              :   sat_unsigned_ ## WIDTH ## KIND ## _type_node = \
    9946              :     make_sat_unsigned_ ## KIND ## _type (SIZE); \
    9947              :   WIDTH ## KIND ## _type_node = make_signed_ ## KIND ## _type (SIZE); \
    9948              :   unsigned_ ## WIDTH ## KIND ## _type_node = \
    9949              :     make_unsigned_ ## KIND ## _type (SIZE);
    9950              : 
    9951              : /* Make fixed-point type nodes based on four different widths.  */
    9952              : #define MAKE_FIXED_TYPE_NODE_FAMILY(N1,N2) \
    9953              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, short_, SHORT_ ## N2 ## _TYPE_SIZE) \
    9954              :   MAKE_FIXED_TYPE_NODE (N1, N2 ## _TYPE_SIZE) \
    9955              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, long_, LONG_ ## N2 ## _TYPE_SIZE) \
    9956              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, long_long_, LONG_LONG_ ## N2 ## _TYPE_SIZE)
    9957              : 
    9958              : /* Make fixed-point mode nodes based on sat/non-sat and signed/unsigned.  */
    9959              : #define MAKE_FIXED_MODE_NODE(KIND,NAME,MODE) \
    9960              :   NAME ## _type_node = \
    9961              :     make_or_reuse_signed_ ## KIND ## _type (GET_MODE_BITSIZE (MODE ## mode)); \
    9962              :   u ## NAME ## _type_node = \
    9963              :     make_or_reuse_unsigned_ ## KIND ## _type \
    9964              :       (GET_MODE_BITSIZE (U ## MODE ## mode)); \
    9965              :   sat_ ## NAME ## _type_node = \
    9966              :     make_or_reuse_sat_signed_ ## KIND ## _type \
    9967              :       (GET_MODE_BITSIZE (MODE ## mode)); \
    9968              :   sat_u ## NAME ## _type_node = \
    9969              :     make_or_reuse_sat_unsigned_ ## KIND ## _type \
    9970              :       (GET_MODE_BITSIZE (U ## MODE ## mode));
    9971              : 
    9972              :   /* Fixed-point type and mode nodes.  */
    9973       298479 :   MAKE_FIXED_TYPE_NODE_FAMILY (fract, FRACT)
    9974       298479 :   MAKE_FIXED_TYPE_NODE_FAMILY (accum, ACCUM)
    9975       298479 :   MAKE_FIXED_MODE_NODE (fract, qq, QQ)
    9976       298479 :   MAKE_FIXED_MODE_NODE (fract, hq, HQ)
    9977       298479 :   MAKE_FIXED_MODE_NODE (fract, sq, SQ)
    9978       298479 :   MAKE_FIXED_MODE_NODE (fract, dq, DQ)
    9979       298479 :   MAKE_FIXED_MODE_NODE (fract, tq, TQ)
    9980       298479 :   MAKE_FIXED_MODE_NODE (accum, ha, HA)
    9981       298479 :   MAKE_FIXED_MODE_NODE (accum, sa, SA)
    9982       298479 :   MAKE_FIXED_MODE_NODE (accum, da, DA)
    9983       298479 :   MAKE_FIXED_MODE_NODE (accum, ta, TA)
    9984              : 
    9985       298479 :   {
    9986       298479 :     tree t = targetm.build_builtin_va_list ();
    9987              : 
    9988              :     /* Many back-ends define record types without setting TYPE_NAME.
    9989              :        If we copied the record type here, we'd keep the original
    9990              :        record type without a name.  This breaks name mangling.  So,
    9991              :        don't copy record types and let c_common_nodes_and_builtins()
    9992              :        declare the type to be __builtin_va_list.  */
    9993       298479 :     if (TREE_CODE (t) != RECORD_TYPE)
    9994       298479 :       t = build_variant_type_copy (t);
    9995              : 
    9996       298479 :     va_list_type_node = t;
    9997              :   }
    9998              : 
    9999              :   /* SCEV analyzer global shared trees.  */
   10000       298479 :   chrec_dont_know = make_node (SCEV_NOT_KNOWN);
   10001       298479 :   TREE_TYPE (chrec_dont_know) = void_type_node;
   10002       298479 :   chrec_known = make_node (SCEV_KNOWN);
   10003       298479 :   TREE_TYPE (chrec_known) = void_type_node;
   10004       298479 : }
   10005              : 
   10006              : /* Modify DECL for given flags.
   10007              :    TM_PURE attribute is set only on types, so the function will modify
   10008              :    DECL's type when ECF_TM_PURE is used.  */
   10009              : 
   10010              : void
   10011     32175001 : set_call_expr_flags (tree decl, int flags)
   10012              : {
   10013     32175001 :   if (flags & ECF_NOTHROW)
   10014     27759346 :     TREE_NOTHROW (decl) = 1;
   10015     32175001 :   if (flags & ECF_CONST)
   10016     13327551 :     TREE_READONLY (decl) = 1;
   10017     32175001 :   if (flags & ECF_PURE)
   10018      1613608 :     DECL_PURE_P (decl) = 1;
   10019     32175001 :   if (flags & ECF_LOOPING_CONST_OR_PURE)
   10020        58877 :     DECL_LOOPING_CONST_OR_PURE_P (decl) = 1;
   10021     32175001 :   if (flags & ECF_NOVOPS)
   10022            0 :     DECL_IS_NOVOPS (decl) = 1;
   10023     32175001 :   if (flags & ECF_NORETURN)
   10024      1265187 :     TREE_THIS_VOLATILE (decl) = 1;
   10025     32175001 :   if (flags & ECF_MALLOC)
   10026       764464 :     DECL_IS_MALLOC (decl) = 1;
   10027     32175001 :   if (flags & ECF_RETURNS_TWICE)
   10028            0 :     DECL_IS_RETURNS_TWICE (decl) = 1;
   10029     32175001 :   if (flags & ECF_LEAF)
   10030     27634913 :     DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
   10031     27634913 :                                         NULL, DECL_ATTRIBUTES (decl));
   10032     32175001 :   if (flags & ECF_COLD)
   10033       663344 :     DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("cold"),
   10034       663344 :                                         NULL, DECL_ATTRIBUTES (decl));
   10035     32175001 :   if (flags & ECF_RET1)
   10036            0 :     DECL_ATTRIBUTES (decl)
   10037            0 :       = tree_cons (get_identifier ("fn spec"),
   10038              :                    build_tree_list (NULL_TREE, build_string (2, "1 ")),
   10039            0 :                    DECL_ATTRIBUTES (decl));
   10040     32175001 :   if ((flags & ECF_TM_PURE) && flag_tm)
   10041          582 :     apply_tm_attr (decl, get_identifier ("transaction_pure"));
   10042     32175001 :   if ((flags & ECF_XTHROW))
   10043       425434 :     DECL_ATTRIBUTES (decl)
   10044       850868 :       = tree_cons (get_identifier ("expected_throw"),
   10045       425434 :                    NULL, DECL_ATTRIBUTES (decl));
   10046              : 
   10047     32175001 :   if (flags & ECF_CB_1_2)
   10048              :     {
   10049       381192 :       tree attr = callback_build_attr (1, 1, 2);
   10050       381192 :       TREE_CHAIN (attr) = DECL_ATTRIBUTES (decl);
   10051       381192 :       DECL_ATTRIBUTES (decl) = attr;
   10052              :     }
   10053              : 
   10054              :     /* Looping const or pure is implied by noreturn.
   10055              :      There is currently no way to declare looping const or looping pure alone.  */
   10056     32175001 :   gcc_assert (!(flags & ECF_LOOPING_CONST_OR_PURE)
   10057              :               || (flags & (ECF_CONST | ECF_PURE)));
   10058     32175001 : }
   10059              : 
   10060              : 
   10061              : /* A subroutine of build_common_builtin_nodes.  Define a builtin function.  */
   10062              : 
   10063              : static void
   10064      9936407 : local_define_builtin (const char *name, tree type, enum built_in_function code,
   10065              :                       const char *library_name, int ecf_flags)
   10066              : {
   10067      9936407 :   tree decl;
   10068              : 
   10069      9936407 :   decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL,
   10070              :                                library_name, NULL_TREE);
   10071      9936407 :   set_call_expr_flags (decl, ecf_flags);
   10072              : 
   10073      9936407 :   set_builtin_decl (code, decl, true);
   10074      9936407 : }
   10075              : 
   10076              : /* Call this function after instantiating all builtins that the language
   10077              :    front end cares about.  This will build the rest of the builtins
   10078              :    and internal functions that are relied upon by the tree optimizers and
   10079              :    the middle-end.  */
   10080              : 
   10081              : void
   10082       298462 : build_common_builtin_nodes (void)
   10083              : {
   10084       298462 :   tree tmp, ftype;
   10085       298462 :   int ecf_flags;
   10086              : 
   10087       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_CLEAR_PADDING))
   10088              :     {
   10089        58877 :       ftype = build_function_type_list (void_type_node,
   10090              :                                         ptr_type_node,
   10091              :                                         ptr_type_node,
   10092              :                                         NULL_TREE);
   10093        58877 :       local_define_builtin ("__builtin_clear_padding", ftype,
   10094              :                             BUILT_IN_CLEAR_PADDING,
   10095              :                             "__builtin_clear_padding",
   10096              :                             ECF_LEAF | ECF_NOTHROW);
   10097              :     }
   10098              : 
   10099       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE)
   10100       244229 :       || !builtin_decl_explicit_p (BUILT_IN_TRAP)
   10101       244229 :       || !builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP)
   10102       239585 :       || !builtin_decl_explicit_p (BUILT_IN_OBSERVABLE_CHKPT)
   10103       538047 :       || !builtin_decl_explicit_p (BUILT_IN_ABORT))
   10104              :     {
   10105        58877 :       ftype = build_function_type (void_type_node, void_list_node);
   10106        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE))
   10107        54233 :         local_define_builtin ("__builtin_unreachable", ftype,
   10108              :                               BUILT_IN_UNREACHABLE,
   10109              :                               "__builtin_unreachable",
   10110              :                               ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
   10111              :                               | ECF_CONST | ECF_COLD);
   10112        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP))
   10113        58877 :         local_define_builtin ("__builtin_unreachable trap", ftype,
   10114              :                               BUILT_IN_UNREACHABLE_TRAP,
   10115              :                               "__builtin_unreachable trap",
   10116              :                               ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
   10117              :                               | ECF_CONST | ECF_COLD);
   10118        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_ABORT))
   10119        58877 :         local_define_builtin ("__builtin_abort", ftype, BUILT_IN_ABORT,
   10120              :                               "abort",
   10121              :                               ECF_LEAF | ECF_NORETURN | ECF_CONST | ECF_COLD);
   10122        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_TRAP))
   10123        22467 :         local_define_builtin ("__builtin_trap", ftype, BUILT_IN_TRAP,
   10124              :                               "__builtin_trap",
   10125              :                               ECF_NORETURN | ECF_NOTHROW | ECF_LEAF | ECF_COLD);
   10126        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_OBSERVABLE_CHKPT))
   10127        58877 :         local_define_builtin ("__builtin_observable_checkpoint", ftype,
   10128              :                               BUILT_IN_OBSERVABLE_CHKPT,
   10129              :                               "__builtin_observable_checkpoint",
   10130              :                               ECF_NOTHROW | ECF_LEAF | ECF_CONST
   10131              :                               | ECF_LOOPING_CONST_OR_PURE);
   10132              :     }
   10133              : 
   10134       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY)
   10135       298462 :       || !builtin_decl_explicit_p (BUILT_IN_MEMMOVE))
   10136              :     {
   10137        58877 :       ftype = build_function_type_list (ptr_type_node,
   10138              :                                         ptr_type_node, const_ptr_type_node,
   10139              :                                         size_type_node, NULL_TREE);
   10140              : 
   10141        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY))
   10142        58877 :         local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
   10143              :                               "memcpy", ECF_NOTHROW | ECF_LEAF);
   10144        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_MEMMOVE))
   10145        54233 :         local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE,
   10146              :                               "memmove", ECF_NOTHROW | ECF_LEAF);
   10147              :     }
   10148              : 
   10149       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMCMP))
   10150              :     {
   10151        54233 :       ftype = build_function_type_list (integer_type_node, const_ptr_type_node,
   10152              :                                         const_ptr_type_node, size_type_node,
   10153              :                                         NULL_TREE);
   10154        54233 :       local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
   10155              :                             "memcmp", ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10156              :     }
   10157              : 
   10158       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMSET))
   10159              :     {
   10160        54233 :       ftype = build_function_type_list (ptr_type_node,
   10161              :                                         ptr_type_node, integer_type_node,
   10162              :                                         size_type_node, NULL_TREE);
   10163        54233 :       local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
   10164              :                             "memset", ECF_NOTHROW | ECF_LEAF);
   10165              :     }
   10166              : 
   10167              :   /* If we're checking the stack, `alloca' can throw.  */
   10168       298392 :   const int alloca_flags
   10169       298462 :     = ECF_MALLOC | ECF_LEAF | (flag_stack_check ? 0 : ECF_NOTHROW);
   10170              : 
   10171       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_ALLOCA))
   10172              :     {
   10173        58877 :       ftype = build_function_type_list (ptr_type_node,
   10174              :                                         size_type_node, NULL_TREE);
   10175        58877 :       local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
   10176              :                             "alloca", alloca_flags);
   10177              :     }
   10178              : 
   10179       298462 :   ftype = build_function_type_list (ptr_type_node, size_type_node,
   10180              :                                     size_type_node, NULL_TREE);
   10181       298462 :   local_define_builtin ("__builtin_alloca_with_align", ftype,
   10182              :                         BUILT_IN_ALLOCA_WITH_ALIGN,
   10183              :                         "__builtin_alloca_with_align",
   10184              :                         alloca_flags);
   10185              : 
   10186       298462 :   ftype = build_function_type_list (ptr_type_node, size_type_node,
   10187              :                                     size_type_node, size_type_node, NULL_TREE);
   10188       298462 :   local_define_builtin ("__builtin_alloca_with_align_and_max", ftype,
   10189              :                         BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX,
   10190              :                         "__builtin_alloca_with_align_and_max",
   10191              :                         alloca_flags);
   10192              : 
   10193       298462 :   ftype = build_function_type_list (void_type_node,
   10194              :                                     ptr_type_node, ptr_type_node,
   10195              :                                     ptr_type_node, NULL_TREE);
   10196       298462 :   local_define_builtin ("__builtin_init_trampoline", ftype,
   10197              :                         BUILT_IN_INIT_TRAMPOLINE,
   10198              :                         "__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF);
   10199       298462 :   local_define_builtin ("__builtin_init_heap_trampoline", ftype,
   10200              :                         BUILT_IN_INIT_HEAP_TRAMPOLINE,
   10201              :                         "__builtin_init_heap_trampoline",
   10202              :                         ECF_NOTHROW | ECF_LEAF);
   10203       298462 :   local_define_builtin ("__builtin_init_descriptor", ftype,
   10204              :                         BUILT_IN_INIT_DESCRIPTOR,
   10205              :                         "__builtin_init_descriptor", ECF_NOTHROW | ECF_LEAF);
   10206              : 
   10207       298462 :   ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE);
   10208       298462 :   local_define_builtin ("__builtin_adjust_trampoline", ftype,
   10209              :                         BUILT_IN_ADJUST_TRAMPOLINE,
   10210              :                         "__builtin_adjust_trampoline",
   10211              :                         ECF_CONST | ECF_NOTHROW);
   10212       298462 :   local_define_builtin ("__builtin_adjust_descriptor", ftype,
   10213              :                         BUILT_IN_ADJUST_DESCRIPTOR,
   10214              :                         "__builtin_adjust_descriptor",
   10215              :                         ECF_CONST | ECF_NOTHROW);
   10216              : 
   10217       298462 :   ftype = build_function_type_list (void_type_node,
   10218              :                                     ptr_type_node, ptr_type_node, NULL_TREE);
   10219       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_CLEAR_CACHE))
   10220        58877 :     local_define_builtin ("__builtin___clear_cache", ftype,
   10221              :                           BUILT_IN_CLEAR_CACHE,
   10222              :                           "__clear_cache",
   10223              :                           ECF_NOTHROW);
   10224              : 
   10225       298462 :   local_define_builtin ("__builtin_nonlocal_goto", ftype,
   10226              :                         BUILT_IN_NONLOCAL_GOTO,
   10227              :                         "__builtin_nonlocal_goto",
   10228              :                         ECF_NORETURN | ECF_NOTHROW);
   10229              : 
   10230       298462 :   tree ptr_ptr_type_node = build_pointer_type (ptr_type_node);
   10231              : 
   10232       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_CREATED))
   10233              :     {
   10234        58877 :       ftype = build_function_type_list (void_type_node,
   10235              :                                         ptr_type_node, // void *chain
   10236              :                                         ptr_type_node, // void *func
   10237              :                                         ptr_ptr_type_node, // void **dst
   10238              :                                         NULL_TREE);
   10239        58877 :       local_define_builtin ("__builtin___gcc_nested_func_ptr_created", ftype,
   10240              :                             BUILT_IN_GCC_NESTED_PTR_CREATED,
   10241              :                             "__gcc_nested_func_ptr_created", ECF_NOTHROW);
   10242              :     }
   10243              : 
   10244       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_DELETED))
   10245              :     {
   10246        58877 :       ftype = build_function_type_list (void_type_node, NULL_TREE);
   10247        58877 :       local_define_builtin ("__builtin___gcc_nested_func_ptr_deleted", ftype,
   10248              :                             BUILT_IN_GCC_NESTED_PTR_DELETED,
   10249              :                             "__gcc_nested_func_ptr_deleted", ECF_NOTHROW);
   10250              :     }
   10251              : 
   10252       298462 :   ftype = build_function_type_list (void_type_node,
   10253              :                                     ptr_type_node, ptr_type_node, NULL_TREE);
   10254       298462 :   local_define_builtin ("__builtin_setjmp_setup", ftype,
   10255              :                         BUILT_IN_SETJMP_SETUP,
   10256              :                         "__builtin_setjmp_setup", ECF_NOTHROW);
   10257              : 
   10258       298462 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10259       298462 :   local_define_builtin ("__builtin_setjmp_receiver", ftype,
   10260              :                         BUILT_IN_SETJMP_RECEIVER,
   10261              :                         "__builtin_setjmp_receiver", ECF_NOTHROW | ECF_LEAF);
   10262              : 
   10263       298462 :   ftype = build_function_type_list (ptr_type_node, NULL_TREE);
   10264       298462 :   local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
   10265              :                         "__builtin_stack_save", ECF_NOTHROW | ECF_LEAF);
   10266              : 
   10267       298462 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10268       298462 :   local_define_builtin ("__builtin_stack_restore", ftype,
   10269              :                         BUILT_IN_STACK_RESTORE,
   10270              :                         "__builtin_stack_restore", ECF_NOTHROW | ECF_LEAF);
   10271              : 
   10272       298462 :   ftype = build_function_type_list (integer_type_node, const_ptr_type_node,
   10273              :                                     const_ptr_type_node, size_type_node,
   10274              :                                     NULL_TREE);
   10275       298462 :   local_define_builtin ("__builtin_memcmp_eq", ftype, BUILT_IN_MEMCMP_EQ,
   10276              :                         "__builtin_memcmp_eq",
   10277              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10278              : 
   10279       298462 :   local_define_builtin ("__builtin_strncmp_eq", ftype, BUILT_IN_STRNCMP_EQ,
   10280              :                         "__builtin_strncmp_eq",
   10281              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10282              : 
   10283       298462 :   local_define_builtin ("__builtin_strcmp_eq", ftype, BUILT_IN_STRCMP_EQ,
   10284              :                         "__builtin_strcmp_eq",
   10285              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10286              : 
   10287              :   /* If there's a possibility that we might use the ARM EABI, build the
   10288              :     alternate __cxa_end_cleanup node used to resume from C++.  */
   10289       298462 :   if (targetm.arm_eabi_unwinder)
   10290              :     {
   10291            0 :       ftype = build_function_type_list (void_type_node, NULL_TREE);
   10292            0 :       local_define_builtin ("__builtin_cxa_end_cleanup", ftype,
   10293              :                             BUILT_IN_CXA_END_CLEANUP,
   10294              :                             "__cxa_end_cleanup",
   10295              :                             ECF_NORETURN | ECF_XTHROW | ECF_LEAF);
   10296              :     }
   10297              : 
   10298       298462 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10299       596924 :   local_define_builtin ("__builtin_unwind_resume", ftype,
   10300              :                         BUILT_IN_UNWIND_RESUME,
   10301       298462 :                         ((targetm_common.except_unwind_info (&global_options)
   10302              :                           == UI_SJLJ)
   10303              :                          ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"),
   10304              :                         ECF_NORETURN | ECF_XTHROW);
   10305              : 
   10306       298462 :   if (builtin_decl_explicit (BUILT_IN_RETURN_ADDRESS) == NULL_TREE)
   10307              :     {
   10308        54233 :       ftype = build_function_type_list (ptr_type_node, integer_type_node,
   10309              :                                         NULL_TREE);
   10310        54233 :       local_define_builtin ("__builtin_return_address", ftype,
   10311              :                             BUILT_IN_RETURN_ADDRESS,
   10312              :                             "__builtin_return_address",
   10313              :                             ECF_NOTHROW);
   10314              :     }
   10315              : 
   10316       298462 :   if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER)
   10317       298462 :       || !builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT))
   10318              :     {
   10319        58877 :       ftype = build_function_type_list (void_type_node, ptr_type_node,
   10320              :                                         ptr_type_node, NULL_TREE);
   10321        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER))
   10322        58877 :         local_define_builtin ("__cyg_profile_func_enter", ftype,
   10323              :                               BUILT_IN_PROFILE_FUNC_ENTER,
   10324              :                               "__cyg_profile_func_enter", 0);
   10325        58877 :       if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT))
   10326        58877 :         local_define_builtin ("__cyg_profile_func_exit", ftype,
   10327              :                               BUILT_IN_PROFILE_FUNC_EXIT,
   10328              :                               "__cyg_profile_func_exit", 0);
   10329              :     }
   10330              : 
   10331              :   /* The exception object and filter values from the runtime.  The argument
   10332              :      must be zero before exception lowering, i.e. from the front end.  After
   10333              :      exception lowering, it will be the region number for the exception
   10334              :      landing pad.  These functions are PURE instead of CONST to prevent
   10335              :      them from being hoisted past the exception edge that will initialize
   10336              :      its value in the landing pad.  */
   10337       298462 :   ftype = build_function_type_list (ptr_type_node,
   10338              :                                     integer_type_node, NULL_TREE);
   10339       298462 :   ecf_flags = ECF_PURE | ECF_NOTHROW | ECF_LEAF;
   10340              :   /* Only use TM_PURE if we have TM language support.  */
   10341       298462 :   if (builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1))
   10342          518 :     ecf_flags |= ECF_TM_PURE;
   10343       298462 :   local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER,
   10344              :                         "__builtin_eh_pointer", ecf_flags);
   10345              : 
   10346       298462 :   tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0);
   10347       298462 :   ftype = build_function_type_list (tmp, integer_type_node, NULL_TREE);
   10348       298462 :   local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER,
   10349              :                         "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10350              : 
   10351       298462 :   ftype = build_function_type_list (void_type_node,
   10352              :                                     integer_type_node, integer_type_node,
   10353              :                                     NULL_TREE);
   10354       298462 :   local_define_builtin ("__builtin_eh_copy_values", ftype,
   10355              :                         BUILT_IN_EH_COPY_VALUES,
   10356              :                         "__builtin_eh_copy_values", ECF_NOTHROW);
   10357              : 
   10358              :   /* Complex multiplication and division.  These are handled as builtins
   10359              :      rather than optabs because emit_library_call_value doesn't support
   10360              :      complex.  Further, we can do slightly better with folding these
   10361              :      beasties if the real and complex parts of the arguments are separate.  */
   10362       298462 :   {
   10363       298462 :     int mode;
   10364              : 
   10365      2089234 :     for (mode = MIN_MODE_COMPLEX_FLOAT; mode <= MAX_MODE_COMPLEX_FLOAT; ++mode)
   10366              :       {
   10367      1790772 :         char mode_name_buf[4], *q;
   10368      1790772 :         const char *p;
   10369      1790772 :         enum built_in_function mcode, dcode;
   10370      1790772 :         tree type, inner_type;
   10371      1790772 :         const char *prefix = "__";
   10372              : 
   10373      1790772 :         if (targetm.libfunc_gnu_prefix)
   10374            0 :           prefix = "__gnu_";
   10375              : 
   10376      1790772 :         type = lang_hooks.types.type_for_mode ((machine_mode) mode, 0);
   10377      1790772 :         if (type == NULL)
   10378       128597 :           continue;
   10379      1662175 :         inner_type = TREE_TYPE (type);
   10380              : 
   10381      1662175 :         ftype = build_function_type_list (type, inner_type, inner_type,
   10382              :                                           inner_type, inner_type, NULL_TREE);
   10383              : 
   10384      1662175 :         mcode = ((enum built_in_function)
   10385      1662175 :                  (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
   10386      1662175 :         dcode = ((enum built_in_function)
   10387      1662175 :                  (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
   10388              : 
   10389      4986525 :         for (p = GET_MODE_NAME (mode), q = mode_name_buf; *p; p++, q++)
   10390      3324350 :           *q = TOLOWER (*p);
   10391      1662175 :         *q = '\0';
   10392              : 
   10393              :         /* For -ftrapping-math these should throw from a former
   10394              :            -fnon-call-exception stmt.  */
   10395      1662175 :         built_in_names[mcode] = concat (prefix, "mul", mode_name_buf, "3",
   10396              :                                         NULL);
   10397      1662175 :         local_define_builtin (built_in_names[mcode], ftype, mcode,
   10398              :                               built_in_names[mcode],
   10399              :                               ECF_CONST | ECF_LEAF);
   10400              : 
   10401      1662175 :         built_in_names[dcode] = concat (prefix, "div", mode_name_buf, "3",
   10402              :                                         NULL);
   10403      1662175 :         local_define_builtin (built_in_names[dcode], ftype, dcode,
   10404              :                               built_in_names[dcode],
   10405              :                               ECF_CONST | ECF_LEAF);
   10406              :       }
   10407              :   }
   10408              : 
   10409       298462 :   init_internal_fns ();
   10410       298462 : }
   10411              : 
   10412              : /* HACK.  GROSS.  This is absolutely disgusting.  I wish there was a
   10413              :    better way.
   10414              : 
   10415              :    If we requested a pointer to a vector, build up the pointers that
   10416              :    we stripped off while looking for the inner type.  Similarly for
   10417              :    return values from functions.
   10418              : 
   10419              :    The argument TYPE is the top of the chain, and BOTTOM is the
   10420              :    new type which we will point to.  */
   10421              : 
   10422              : tree
   10423            0 : reconstruct_complex_type (tree type, tree bottom)
   10424              : {
   10425            0 :   tree inner, outer;
   10426              : 
   10427            0 :   if (TREE_CODE (type) == POINTER_TYPE)
   10428              :     {
   10429            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10430            0 :       outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
   10431            0 :                                            TYPE_REF_CAN_ALIAS_ALL (type));
   10432              :     }
   10433              :   else if (TREE_CODE (type) == REFERENCE_TYPE)
   10434              :     {
   10435            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10436            0 :       outer = build_reference_type_for_mode (inner, TYPE_MODE (type),
   10437            0 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
   10438              :     }
   10439              :   else if (TREE_CODE (type) == ARRAY_TYPE)
   10440              :     {
   10441            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10442            0 :       outer = build_array_type (inner, TYPE_DOMAIN (type));
   10443              :     }
   10444              :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   10445              :     {
   10446            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10447            0 :       outer = build_function_type (inner, TYPE_ARG_TYPES (type),
   10448            0 :                                    TYPE_NO_NAMED_ARGS_STDARG_P (type));
   10449              :     }
   10450              :   else if (TREE_CODE (type) == METHOD_TYPE)
   10451              :     {
   10452            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10453              :       /* The build_method_type_directly() routine prepends 'this' to argument list,
   10454              :          so we must compensate by getting rid of it.  */
   10455            0 :       outer
   10456              :         = build_method_type_directly
   10457            0 :             (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type))),
   10458              :              inner,
   10459            0 :              TREE_CHAIN (TYPE_ARG_TYPES (type)));
   10460              :     }
   10461              :   else if (TREE_CODE (type) == OFFSET_TYPE)
   10462              :     {
   10463            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10464            0 :       outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner);
   10465              :     }
   10466              :   else
   10467              :     return bottom;
   10468              : 
   10469            0 :   return build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
   10470            0 :                                             TYPE_QUALS (type));
   10471              : }
   10472              : 
   10473              : /* Returns a vector tree node given a mode (integer, vector, or BLKmode) and
   10474              :    the inner type.  */
   10475              : tree
   10476     33800749 : build_vector_type_for_mode (tree innertype, machine_mode mode)
   10477              : {
   10478     33800749 :   poly_int64 nunits;
   10479     33800749 :   unsigned int bitsize;
   10480              : 
   10481     33800749 :   switch (GET_MODE_CLASS (mode))
   10482              :     {
   10483     33799453 :     case MODE_VECTOR_BOOL:
   10484     33799453 :     case MODE_VECTOR_INT:
   10485     33799453 :     case MODE_VECTOR_FLOAT:
   10486     33799453 :     case MODE_VECTOR_FRACT:
   10487     33799453 :     case MODE_VECTOR_UFRACT:
   10488     33799453 :     case MODE_VECTOR_ACCUM:
   10489     33799453 :     case MODE_VECTOR_UACCUM:
   10490     67598906 :       nunits = GET_MODE_NUNITS (mode);
   10491     33799453 :       break;
   10492              : 
   10493         1296 :     case MODE_INT:
   10494              :       /* Check that there are no leftover bits.  */
   10495         1296 :       bitsize = GET_MODE_BITSIZE (as_a <scalar_int_mode> (mode));
   10496         1296 :       gcc_assert (bitsize % TREE_INT_CST_LOW (TYPE_SIZE (innertype)) == 0);
   10497         1296 :       nunits = bitsize / TREE_INT_CST_LOW (TYPE_SIZE (innertype));
   10498         1296 :       break;
   10499              : 
   10500            0 :     default:
   10501            0 :       gcc_unreachable ();
   10502              :     }
   10503              : 
   10504     33800749 :   return make_vector_type (innertype, nunits, mode);
   10505              : }
   10506              : 
   10507              : /* Similarly, but takes the inner type and number of units, which must be
   10508              :    a power of two.  */
   10509              : 
   10510              : tree
   10511      2915576 : build_vector_type (tree innertype, poly_int64 nunits)
   10512              : {
   10513      2915576 :   return make_vector_type (innertype, nunits, VOIDmode);
   10514              : }
   10515              : 
   10516              : /* Build a truth vector with NUNITS units, giving it mode MASK_MODE.  */
   10517              : 
   10518              : tree
   10519      2565504 : build_truth_vector_type_for_mode (poly_uint64 nunits, machine_mode mask_mode)
   10520              : {
   10521      2565504 :   gcc_assert (mask_mode != BLKmode);
   10522              : 
   10523      2565504 :   unsigned HOST_WIDE_INT esize;
   10524      2565504 :   if (VECTOR_MODE_P (mask_mode))
   10525              :     {
   10526      2428258 :       poly_uint64 vsize = GET_MODE_PRECISION (mask_mode);
   10527      2428258 :       esize = vector_element_size (vsize, nunits);
   10528      2428258 :     }
   10529              :   else
   10530              :     esize = 1;
   10531              : 
   10532      2565504 :   tree bool_type = build_nonstandard_boolean_type (esize);
   10533              : 
   10534      2565504 :   return make_vector_type (bool_type, nunits, mask_mode);
   10535              : }
   10536              : 
   10537              : /* Build a vector type that holds one boolean result for each element of
   10538              :    vector type VECTYPE.  The public interface for this operation is
   10539              :    truth_type_for.  */
   10540              : 
   10541              : static tree
   10542      2553998 : build_truth_vector_type_for (tree vectype)
   10543              : {
   10544      2553998 :   machine_mode vector_mode = TYPE_MODE (vectype);
   10545      2553998 :   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
   10546              : 
   10547      2553998 :   machine_mode mask_mode;
   10548        99627 :   if (VECTOR_MODE_P (vector_mode)
   10549      2653015 :       && targetm.vectorize.get_mask_mode (vector_mode).exists (&mask_mode))
   10550      2553388 :     return build_truth_vector_type_for_mode (nunits, mask_mode);
   10551              : 
   10552          610 :   poly_uint64 vsize = tree_to_poly_uint64 (TYPE_SIZE (vectype));
   10553          610 :   unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
   10554          610 :   tree bool_type = build_nonstandard_boolean_type (esize);
   10555              : 
   10556          610 :   return make_vector_type (bool_type, nunits, VOIDmode);
   10557              : }
   10558              : 
   10559              : /* Like build_vector_type, but builds a variant type with TYPE_VECTOR_OPAQUE
   10560              :    set.  */
   10561              : 
   10562              : tree
   10563       109046 : build_opaque_vector_type (tree innertype, poly_int64 nunits)
   10564              : {
   10565       109046 :   tree t = make_vector_type (innertype, nunits, VOIDmode);
   10566       109046 :   tree cand;
   10567              :   /* We always build the non-opaque variant before the opaque one,
   10568              :      so if it already exists, it is TYPE_NEXT_VARIANT of this one.  */
   10569       109046 :   cand = TYPE_NEXT_VARIANT (t);
   10570       109046 :   if (cand
   10571        97398 :       && TYPE_VECTOR_OPAQUE (cand)
   10572       172238 :       && check_qualified_type (cand, t, TYPE_QUALS (t)))
   10573              :     return cand;
   10574              :   /* Otherwise build a variant type and make sure to queue it after
   10575              :      the non-opaque type.  */
   10576        45855 :   cand = build_distinct_type_copy (t);
   10577        45855 :   TYPE_VECTOR_OPAQUE (cand) = true;
   10578        45855 :   TYPE_CANONICAL (cand) = TYPE_CANONICAL (t);
   10579        45855 :   TYPE_NEXT_VARIANT (cand) = TYPE_NEXT_VARIANT (t);
   10580        45855 :   TYPE_NEXT_VARIANT (t) = cand;
   10581        45855 :   TYPE_MAIN_VARIANT (cand) = TYPE_MAIN_VARIANT (t);
   10582              :   /* Type variants have no alias set defined.  */
   10583        45855 :   TYPE_ALIAS_SET (cand) = -1;
   10584        45855 :   return cand;
   10585              : }
   10586              : 
   10587              : /* Return the value of element I of VECTOR_CST T as a wide_int.  */
   10588              : 
   10589              : static poly_wide_int
   10590       535695 : vector_cst_int_elt (const_tree t, unsigned int i)
   10591              : {
   10592              :   /* First handle elements that are directly encoded.  */
   10593       535695 :   unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
   10594       535695 :   if (i < encoded_nelts)
   10595            0 :     return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, i));
   10596              : 
   10597              :   /* Identify the pattern that contains element I and work out the index of
   10598              :      the last encoded element for that pattern.  */
   10599       535695 :   unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
   10600       535695 :   unsigned int pattern = i % npatterns;
   10601       535695 :   unsigned int count = i / npatterns;
   10602       535695 :   unsigned int final_i = encoded_nelts - npatterns + pattern;
   10603              : 
   10604              :   /* If there are no steps, the final encoded value is the right one.  */
   10605       535695 :   if (!VECTOR_CST_STEPPED_P (t))
   10606            0 :     return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
   10607              : 
   10608              :   /* Otherwise work out the value from the last two encoded elements.  */
   10609       535695 :   tree v1 = VECTOR_CST_ENCODED_ELT (t, final_i - npatterns);
   10610       535695 :   tree v2 = VECTOR_CST_ENCODED_ELT (t, final_i);
   10611       535695 :   poly_wide_int diff = wi::to_poly_wide (v2) - wi::to_poly_wide (v1);
   10612       535695 :   return wi::to_poly_wide (v2) + (count - 2) * diff;
   10613       535695 : }
   10614              : 
   10615              : /* Return the value of element I of VECTOR_CST T.  */
   10616              : 
   10617              : tree
   10618      6913571 : vector_cst_elt (const_tree t, unsigned int i)
   10619              : {
   10620              :   /* First handle elements that are directly encoded.  */
   10621      6913571 :   unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
   10622      6913571 :   if (i < encoded_nelts)
   10623      4611014 :     return VECTOR_CST_ENCODED_ELT (t, i);
   10624              : 
   10625              :   /* If there are no steps, the final encoded value is the right one.  */
   10626      2302557 :   if (!VECTOR_CST_STEPPED_P (t))
   10627              :     {
   10628              :       /* Identify the pattern that contains element I and work out the index of
   10629              :          the last encoded element for that pattern.  */
   10630      1766862 :       unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
   10631      1766862 :       unsigned int pattern = i % npatterns;
   10632      1766862 :       unsigned int final_i = encoded_nelts - npatterns + pattern;
   10633      1766862 :       return VECTOR_CST_ENCODED_ELT (t, final_i);
   10634              :     }
   10635              : 
   10636              :   /* Otherwise work out the value from the last two encoded elements.  */
   10637       535695 :   return wide_int_to_tree (TREE_TYPE (TREE_TYPE (t)),
   10638      1071390 :                            vector_cst_int_elt (t, i));
   10639              : }
   10640              : 
   10641              : /* Given an initializer INIT, return TRUE if INIT is zero or some
   10642              :    aggregate of zeros.  Otherwise return FALSE.  If NONZERO is not
   10643              :    null, set *NONZERO if and only if INIT is known not to be all
   10644              :    zeros.  The combination of return value of false and *NONZERO
   10645              :    false implies that INIT may but need not be all zeros.  Other
   10646              :    combinations indicate definitive answers.  */
   10647              : 
   10648              : bool
   10649     42786146 : initializer_zerop (const_tree init, bool *nonzero /* = NULL */)
   10650              : {
   10651     42786146 :   bool dummy;
   10652     42786146 :   if (!nonzero)
   10653     40032446 :     nonzero = &dummy;
   10654              : 
   10655              :   /* Conservatively clear NONZERO and set it only if INIT is definitely
   10656              :      not all zero.  */
   10657     42786146 :   *nonzero = false;
   10658              : 
   10659     42786146 :   STRIP_NOPS (init);
   10660              : 
   10661     42786146 :   unsigned HOST_WIDE_INT off = 0;
   10662              : 
   10663     42786146 :   switch (TREE_CODE (init))
   10664              :     {
   10665     16665116 :     case INTEGER_CST:
   10666     16665116 :       if (integer_zerop (init))
   10667              :         return true;
   10668              : 
   10669     10561334 :       *nonzero = true;
   10670     10561334 :       return false;
   10671              : 
   10672       556266 :     case REAL_CST:
   10673              :       /* ??? Note that this is not correct for C4X float formats.  There,
   10674              :          a bit pattern of all zeros is 1.0; 0.0 is encoded with the most
   10675              :          negative exponent.  */
   10676       556266 :       if (real_zerop (init)
   10677       645676 :           && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init)))
   10678              :         return true;
   10679              : 
   10680       469840 :       *nonzero = true;
   10681       469840 :       return false;
   10682              : 
   10683            0 :     case FIXED_CST:
   10684            0 :       if (fixed_zerop (init))
   10685              :         return true;
   10686              : 
   10687            0 :       *nonzero = true;
   10688            0 :       return false;
   10689              : 
   10690        17404 :     case COMPLEX_CST:
   10691        17404 :       if (integer_zerop (init)
   10692        17404 :           || (real_zerop (init)
   10693         2957 :               && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init)))
   10694         2915 :               && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init)))))
   10695         3143 :         return true;
   10696              : 
   10697        14261 :       *nonzero = true;
   10698        14261 :       return false;
   10699              : 
   10700      1131730 :     case VECTOR_CST:
   10701      1131730 :       if (VECTOR_CST_NPATTERNS (init) == 1
   10702      1041407 :           && VECTOR_CST_DUPLICATE_P (init)
   10703      1782412 :           && initializer_zerop (VECTOR_CST_ENCODED_ELT (init, 0)))
   10704              :         return true;
   10705              : 
   10706       792461 :       *nonzero = true;
   10707       792461 :       return false;
   10708              : 
   10709              :     case RAW_DATA_CST:
   10710         1596 :       for (unsigned int i = 0; i < (unsigned int) RAW_DATA_LENGTH (init); ++i)
   10711         1596 :         if (RAW_DATA_POINTER (init)[i])
   10712              :           {
   10713         1548 :             *nonzero = true;
   10714         1548 :             return false;
   10715              :           }
   10716              :       return true;
   10717              : 
   10718      4248548 :     case CONSTRUCTOR:
   10719      4248548 :       {
   10720      4248548 :         if (TREE_CLOBBER_P (init))
   10721              :           return false;
   10722              : 
   10723              :         unsigned HOST_WIDE_INT idx;
   10724              :         tree elt;
   10725              : 
   10726      3608710 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (init), idx, elt)
   10727      2753700 :           if (!initializer_zerop (elt, nonzero))
   10728              :             return false;
   10729              : 
   10730              :         return true;
   10731              :       }
   10732              : 
   10733       357257 :     case MEM_REF:
   10734       357257 :       {
   10735       357257 :         tree arg = TREE_OPERAND (init, 0);
   10736       357257 :         if (TREE_CODE (arg) != ADDR_EXPR)
   10737              :           return false;
   10738        89497 :         tree offset = TREE_OPERAND (init, 1);
   10739        89497 :         if (TREE_CODE (offset) != INTEGER_CST
   10740        89497 :             || !tree_fits_uhwi_p (offset))
   10741              :           return false;
   10742        89497 :         off = tree_to_uhwi (offset);
   10743        89497 :         if (INT_MAX < off)
   10744              :           return false;
   10745        89493 :         arg = TREE_OPERAND (arg, 0);
   10746        89493 :         if (TREE_CODE (arg) != STRING_CST)
   10747              :           return false;
   10748              :         init = arg;
   10749              :       }
   10750              :       /* Fall through.  */
   10751              : 
   10752              :     case STRING_CST:
   10753              :       {
   10754              :         gcc_assert (off <= INT_MAX);
   10755              : 
   10756       154132 :         int i = off;
   10757       154132 :         int n = TREE_STRING_LENGTH (init);
   10758       154132 :         if (n <= i)
   10759              :           return false;
   10760              : 
   10761              :         /* We need to loop through all elements to handle cases like
   10762              :            "\0" and "\0foobar".  */
   10763       166204 :         for (i = 0; i < n; ++i)
   10764       160757 :           if (TREE_STRING_POINTER (init)[i] != '\0')
   10765              :             {
   10766       148652 :               *nonzero = true;
   10767       148652 :               return false;
   10768              :             }
   10769              : 
   10770              :         return true;
   10771              :       }
   10772              : 
   10773              :     default:
   10774              :       return false;
   10775              :     }
   10776              : }
   10777              : 
   10778              : /* Return true if EXPR is an initializer expression in which every element
   10779              :    is a constant that is numerically equal to 0 or 1.  The elements do not
   10780              :    need to be equal to each other.  */
   10781              : 
   10782              : bool
   10783       126697 : initializer_each_zero_or_onep (const_tree expr)
   10784              : {
   10785       126697 :   STRIP_ANY_LOCATION_WRAPPER (expr);
   10786              : 
   10787       126697 :   switch (TREE_CODE (expr))
   10788              :     {
   10789        45804 :     case INTEGER_CST:
   10790        45804 :       return integer_zerop (expr) || integer_onep (expr);
   10791              : 
   10792        22943 :     case REAL_CST:
   10793        22943 :       return real_zerop (expr) || real_onep (expr);
   10794              : 
   10795        57950 :     case VECTOR_CST:
   10796        57950 :       {
   10797        57950 :         unsigned HOST_WIDE_INT nelts = vector_cst_encoded_nelts (expr);
   10798        57950 :         if (VECTOR_CST_STEPPED_P (expr)
   10799        57950 :             && !TYPE_VECTOR_SUBPARTS (TREE_TYPE (expr)).is_constant (&nelts))
   10800              :           return false;
   10801              : 
   10802        70183 :         for (unsigned int i = 0; i < nelts; ++i)
   10803              :           {
   10804        68747 :             tree elt = vector_cst_elt (expr, i);
   10805        68747 :             if (!initializer_each_zero_or_onep (elt))
   10806              :               return false;
   10807              :           }
   10808              : 
   10809              :         return true;
   10810              :       }
   10811              : 
   10812              :     default:
   10813              :       return false;
   10814              :     }
   10815              : }
   10816              : 
   10817              : /* Check if vector VEC consists of all the equal elements and
   10818              :    that the number of elements corresponds to the type of VEC.
   10819              :    The function returns first element of the vector
   10820              :    or NULL_TREE if the vector is not uniform.  */
   10821              : tree
   10822      3041186 : uniform_vector_p (const_tree vec)
   10823              : {
   10824      3041186 :   tree first, t;
   10825      3041186 :   unsigned HOST_WIDE_INT i, nelts;
   10826              : 
   10827      3041186 :   if (vec == NULL_TREE)
   10828              :     return NULL_TREE;
   10829              : 
   10830      3041186 :   gcc_assert (VECTOR_TYPE_P (TREE_TYPE (vec)));
   10831              : 
   10832      3041186 :   if (TREE_CODE (vec) == VEC_DUPLICATE_EXPR)
   10833            0 :     return TREE_OPERAND (vec, 0);
   10834              : 
   10835      3041186 :   else if (TREE_CODE (vec) == VECTOR_CST)
   10836              :     {
   10837       330589 :       if (VECTOR_CST_NPATTERNS (vec) == 1 && VECTOR_CST_DUPLICATE_P (vec))
   10838       267954 :         return VECTOR_CST_ENCODED_ELT (vec, 0);
   10839              :       return NULL_TREE;
   10840              :     }
   10841              : 
   10842      2710597 :   else if (TREE_CODE (vec) == CONSTRUCTOR
   10843      2710597 :            && TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec)).is_constant (&nelts))
   10844              :     {
   10845       165424 :       first = error_mark_node;
   10846              : 
   10847       554030 :       FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (vec), i, t)
   10848              :         {
   10849       492561 :           if (i == 0)
   10850              :             {
   10851       165424 :               first = t;
   10852       165424 :               continue;
   10853              :             }
   10854       327137 :           if (!operand_equal_p (first, t, 0))
   10855              :             return NULL_TREE;
   10856              :         }
   10857        61469 :       if (i != nelts)
   10858              :         return NULL_TREE;
   10859              : 
   10860        61231 :       if (TREE_CODE (first) == CONSTRUCTOR || TREE_CODE (first) == VECTOR_CST)
   10861              :         return uniform_vector_p (first);
   10862              :       return first;
   10863              :     }
   10864              : 
   10865              :   return NULL_TREE;
   10866              : }
   10867              : 
   10868              : /* If OP is a uniform vector return the element it is a splat from.  */
   10869              : 
   10870              : tree
   10871       276713 : ssa_uniform_vector_p (tree op)
   10872              : {
   10873       276713 :   if (TREE_CODE (op) == VECTOR_CST
   10874              :       || TREE_CODE (op) == VEC_DUPLICATE_EXPR
   10875              :       || TREE_CODE (op) == CONSTRUCTOR)
   10876        11617 :     return uniform_vector_p (op);
   10877              :   if (TREE_CODE (op) == SSA_NAME)
   10878              :     {
   10879       265096 :       gimple *def_stmt = SSA_NAME_DEF_STMT (op);
   10880       265096 :       if (gimple_assign_single_p (def_stmt))
   10881       111262 :         return uniform_vector_p (gimple_assign_rhs1 (def_stmt));
   10882              :     }
   10883              :   return NULL_TREE;
   10884              : }
   10885              : 
   10886              : /* If the argument is INTEGER_CST, return it.  If the argument is vector
   10887              :    with all elements the same INTEGER_CST, return that INTEGER_CST.  Otherwise
   10888              :    return NULL_TREE.
   10889              :    Look through location wrappers. */
   10890              : 
   10891              : tree
   10892    857428881 : uniform_integer_cst_p (tree t)
   10893              : {
   10894    857428881 :   STRIP_ANY_LOCATION_WRAPPER (t);
   10895              : 
   10896    857428881 :   if (TREE_CODE (t) == INTEGER_CST)
   10897              :     return t;
   10898              : 
   10899    346215937 :   if (VECTOR_TYPE_P (TREE_TYPE (t)))
   10900              :     {
   10901      1234123 :       t = uniform_vector_p (t);
   10902      1234123 :       if (t && TREE_CODE (t) == INTEGER_CST)
   10903              :         return t;
   10904              :     }
   10905              : 
   10906              :   return NULL_TREE;
   10907              : }
   10908              : 
   10909              : /* Checks to see if T is a constant or a constant vector and if each element E
   10910              :    adheres to ~E + 1 == pow2 then return ~E otherwise NULL_TREE.  */
   10911              : 
   10912              : tree
   10913      2851152 : bitmask_inv_cst_vector_p (tree t)
   10914              : {
   10915              : 
   10916      2851152 :   tree_code code = TREE_CODE (t);
   10917      2851152 :   tree type = TREE_TYPE (t);
   10918              : 
   10919      2851152 :   if (!INTEGRAL_TYPE_P (type)
   10920      2851152 :       && !VECTOR_INTEGER_TYPE_P (type))
   10921              :     return NULL_TREE;
   10922              : 
   10923      2851152 :   unsigned HOST_WIDE_INT nelts = 1;
   10924      2851152 :   tree cst;
   10925      2851152 :   unsigned int idx = 0;
   10926      2851152 :   bool uniform = uniform_integer_cst_p (t);
   10927      2851152 :   tree newtype = unsigned_type_for (type);
   10928      2851152 :   tree_vector_builder builder;
   10929      2851152 :   if (code == INTEGER_CST)
   10930              :     cst = t;
   10931              :   else
   10932              :     {
   10933        17640 :       if (!VECTOR_CST_NELTS (t).is_constant (&nelts))
   10934              :         return NULL_TREE;
   10935              : 
   10936        17640 :       cst = vector_cst_elt (t, 0);
   10937        17640 :       builder.new_vector (newtype, nelts, 1);
   10938              :     }
   10939              : 
   10940      2851152 :   tree ty = unsigned_type_for (TREE_TYPE (cst));
   10941              : 
   10942      2851164 :   do
   10943              :     {
   10944      2851164 :       if (idx > 0)
   10945           12 :         cst = vector_cst_elt (t, idx);
   10946      2851164 :       wide_int icst = wi::to_wide (cst);
   10947      2851164 :       wide_int inv =  wi::bit_not (icst);
   10948      2851164 :       icst = wi::add (1, inv);
   10949      2851164 :       if (wi::popcount (icst) != 1)
   10950              :         return NULL_TREE;
   10951              : 
   10952         8084 :       tree newcst = wide_int_to_tree (ty, inv);
   10953              : 
   10954         8084 :       if (uniform)
   10955         8068 :         return build_uniform_cst (newtype, newcst);
   10956              : 
   10957           16 :       builder.quick_push (newcst);
   10958      2851164 :     }
   10959           16 :   while (++idx < nelts);
   10960              : 
   10961            4 :   return builder.build ();
   10962      2851152 : }
   10963              : 
   10964              : /* If VECTOR_CST T has a single nonzero element, return the index of that
   10965              :    element, otherwise return -1.  */
   10966              : 
   10967              : int
   10968          180 : single_nonzero_element (const_tree t)
   10969              : {
   10970          180 :   unsigned HOST_WIDE_INT nelts;
   10971          180 :   unsigned int repeat_nelts;
   10972          180 :   if (VECTOR_CST_NELTS (t).is_constant (&nelts))
   10973          180 :     repeat_nelts = nelts;
   10974              :   else if (VECTOR_CST_NELTS_PER_PATTERN (t) == 2)
   10975              :     {
   10976              :       nelts = vector_cst_encoded_nelts (t);
   10977              :       repeat_nelts = VECTOR_CST_NPATTERNS (t);
   10978              :     }
   10979              :   else
   10980              :     return -1;
   10981              : 
   10982          180 :   int res = -1;
   10983          567 :   for (unsigned int i = 0; i < nelts; ++i)
   10984              :     {
   10985          531 :       tree elt = vector_cst_elt (t, i);
   10986          531 :       if (!integer_zerop (elt) && !real_zerop (elt))
   10987              :         {
   10988          324 :           if (res >= 0 || i >= repeat_nelts)
   10989              :             return -1;
   10990          180 :           res = i;
   10991              :         }
   10992              :     }
   10993              :   return res;
   10994              : }
   10995              : 
   10996              : /* Build an empty statement at location LOC.  */
   10997              : 
   10998              : tree
   10999     15036513 : build_empty_stmt (location_t loc)
   11000              : {
   11001     15036513 :   tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
   11002     15036513 :   SET_EXPR_LOCATION (t, loc);
   11003     15036513 :   return t;
   11004              : }
   11005              : 
   11006              : 
   11007              : /* Build an OMP clause with code CODE.  LOC is the location of the
   11008              :    clause.  */
   11009              : 
   11010              : tree
   11011      1753476 : build_omp_clause (location_t loc, enum omp_clause_code code)
   11012              : {
   11013      1753476 :   tree t;
   11014      1753476 :   int size, length;
   11015              : 
   11016      1753476 :   length = omp_clause_num_ops[code];
   11017      1753476 :   size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree));
   11018              : 
   11019      1753476 :   record_node_allocation_statistics (OMP_CLAUSE, size);
   11020              : 
   11021      1753476 :   t = (tree) ggc_internal_alloc (size);
   11022      1753476 :   memset (t, 0, size);
   11023      1753476 :   TREE_SET_CODE (t, OMP_CLAUSE);
   11024      1753476 :   OMP_CLAUSE_SET_CODE (t, code);
   11025      1753476 :   OMP_CLAUSE_LOCATION (t) = loc;
   11026              : 
   11027      1753476 :   return t;
   11028              : }
   11029              : 
   11030              : /* Build a tcc_vl_exp object with code CODE and room for LEN operands.  LEN
   11031              :    includes the implicit operand count in TREE_OPERAND 0, and so must be >= 1.
   11032              :    Except for the CODE and operand count field, other storage for the
   11033              :    object is initialized to zeros.  */
   11034              : 
   11035              : tree
   11036    516430731 : build_vl_exp (enum tree_code code, int len MEM_STAT_DECL)
   11037              : {
   11038    516430731 :   tree t;
   11039    516430731 :   int length = (len - 1) * sizeof (tree) + sizeof (struct tree_exp);
   11040              : 
   11041    516430731 :   gcc_assert (TREE_CODE_CLASS (code) == tcc_vl_exp);
   11042    516430731 :   gcc_assert (len >= 1);
   11043              : 
   11044    516430731 :   record_node_allocation_statistics (code, length);
   11045              : 
   11046    516430731 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
   11047              : 
   11048    516430731 :   TREE_SET_CODE (t, code);
   11049              : 
   11050              :   /* Can't use TREE_OPERAND to store the length because if checking is
   11051              :      enabled, it will try to check the length before we store it.  :-P  */
   11052    516430731 :   t->exp.operands[0] = build_int_cst (sizetype, len);
   11053              : 
   11054    516430731 :   return t;
   11055              : }
   11056              : 
   11057              : /* Helper function for build_call_* functions; build a CALL_EXPR with
   11058              :    indicated RETURN_TYPE, FN, and NARGS, but do not initialize any of
   11059              :    the argument slots.  */
   11060              : 
   11061              : static tree
   11062    275244166 : build_call_1 (tree return_type, tree fn, int nargs)
   11063              : {
   11064    275244166 :   tree t;
   11065              : 
   11066    275244166 :   t = build_vl_exp (CALL_EXPR, nargs + 3);
   11067    275244166 :   TREE_TYPE (t) = return_type;
   11068    275244166 :   CALL_EXPR_FN (t) = fn;
   11069    275244166 :   CALL_EXPR_STATIC_CHAIN (t) = NULL;
   11070              : 
   11071    275244166 :   return t;
   11072              : }
   11073              : 
   11074              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11075              :    FN and a null static chain slot.  NARGS is the number of call arguments
   11076              :    which are specified as a va_list ARGS.  */
   11077              : 
   11078              : tree
   11079       135475 : build_call_valist (tree return_type, tree fn, int nargs, va_list args)
   11080              : {
   11081       135475 :   tree t;
   11082       135475 :   int i;
   11083              : 
   11084       135475 :   t = build_call_1 (return_type, fn, nargs);
   11085       549065 :   for (i = 0; i < nargs; i++)
   11086       278115 :     CALL_EXPR_ARG (t, i) = va_arg (args, tree);
   11087       135475 :   process_call_operands (t);
   11088       135475 :   return t;
   11089              : }
   11090              : 
   11091              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11092              :    FN and a null static chain slot.  ARGS specifies the call arguments.  */
   11093              : 
   11094              : tree
   11095          260 : build_call (tree return_type, tree fn, std::initializer_list<tree> args)
   11096              : {
   11097          260 :   tree t;
   11098          260 :   int i;
   11099          260 :   int nargs = args.size();
   11100              : 
   11101          260 :   t = build_call_1 (return_type, fn, nargs);
   11102          994 :   for (i = 0; i < nargs; i++)
   11103          474 :     CALL_EXPR_ARG (t, i) = args.begin()[i];
   11104          260 :   process_call_operands (t);
   11105          260 :   return t;
   11106              : }
   11107              : 
   11108              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11109              :    FN and a null static chain slot.  NARGS is the number of call arguments
   11110              :    which are specified as a tree array ARGS.  */
   11111              : 
   11112              : tree
   11113    228950761 : build_call_array_loc (location_t loc, tree return_type, tree fn,
   11114              :                       int nargs, const tree *args)
   11115              : {
   11116    228950761 :   tree t;
   11117    228950761 :   int i;
   11118              : 
   11119    228950761 :   t = build_call_1 (return_type, fn, nargs);
   11120    771905367 :   for (i = 0; i < nargs; i++)
   11121    314003845 :     CALL_EXPR_ARG (t, i) = args[i];
   11122    228950761 :   process_call_operands (t);
   11123    228950761 :   SET_EXPR_LOCATION (t, loc);
   11124    228950761 :   return t;
   11125              : }
   11126              : 
   11127              : /* Like build_call_array, but takes a vec.  */
   11128              : 
   11129              : tree
   11130     45411744 : build_call_vec (tree return_type, tree fn, const vec<tree, va_gc> *args)
   11131              : {
   11132     45411744 :   tree ret, t;
   11133     45411744 :   unsigned int ix;
   11134              : 
   11135     45411744 :   ret = build_call_1 (return_type, fn, vec_safe_length (args));
   11136    125268149 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
   11137     34444661 :     CALL_EXPR_ARG (ret, ix) = t;
   11138     45411744 :   process_call_operands (ret);
   11139     45411744 :   return ret;
   11140              : }
   11141              : 
   11142              : /* Conveniently construct a function call expression.  FNDECL names the
   11143              :    function to be called and N arguments are passed in the array
   11144              :    ARGARRAY.  */
   11145              : 
   11146              : tree
   11147     22173374 : build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
   11148              : {
   11149     22173374 :   tree fntype = TREE_TYPE (fndecl);
   11150     22173374 :   tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
   11151              : 
   11152     22173374 :   return fold_build_call_array_loc (loc, TREE_TYPE (fntype), fn, n, argarray);
   11153              : }
   11154              : 
   11155              : /* Conveniently construct a function call expression.  FNDECL names the
   11156              :    function to be called and the arguments are passed in the vector
   11157              :    VEC.  */
   11158              : 
   11159              : tree
   11160        20710 : build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
   11161              : {
   11162        20710 :   return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
   11163        20710 :                                     vec_safe_address (vec));
   11164              : }
   11165              : 
   11166              : 
   11167              : /* Conveniently construct a function call expression.  FNDECL names the
   11168              :    function to be called, N is the number of arguments, and the "..."
   11169              :    parameters are the argument expressions.  */
   11170              : 
   11171              : tree
   11172     20877213 : build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
   11173              : {
   11174     20877213 :   va_list ap;
   11175     20877213 :   tree *argarray = XALLOCAVEC (tree, n);
   11176     20877213 :   int i;
   11177              : 
   11178     20877213 :   va_start (ap, n);
   11179     23702304 :   for (i = 0; i < n; i++)
   11180      2825091 :     argarray[i] = va_arg (ap, tree);
   11181     20877213 :   va_end (ap);
   11182     20877213 :   return build_call_expr_loc_array (loc, fndecl, n, argarray);
   11183              : }
   11184              : 
   11185              : /* Like build_call_expr_loc (UNKNOWN_LOCATION, ...).  Duplicated because
   11186              :    varargs macros aren't supported by all bootstrap compilers.  */
   11187              : 
   11188              : tree
   11189      1270963 : build_call_expr (tree fndecl, int n, ...)
   11190              : {
   11191      1270963 :   va_list ap;
   11192      1270963 :   tree *argarray = XALLOCAVEC (tree, n);
   11193      1270963 :   int i;
   11194              : 
   11195      1270963 :   va_start (ap, n);
   11196      3738684 :   for (i = 0; i < n; i++)
   11197      2467721 :     argarray[i] = va_arg (ap, tree);
   11198      1270963 :   va_end (ap);
   11199      1270963 :   return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
   11200              : }
   11201              : 
   11202              : /* Build an internal call to IFN, with arguments ARGS[0:N-1] and with return
   11203              :    type TYPE.  This is just like CALL_EXPR, except its CALL_EXPR_FN is NULL.
   11204              :    It will get gimplified later into an ordinary internal function.  */
   11205              : 
   11206              : tree
   11207       745926 : build_call_expr_internal_loc_array (location_t loc, internal_fn ifn,
   11208              :                                     tree type, int n, const tree *args)
   11209              : {
   11210       745926 :   tree t = build_call_1 (type, NULL_TREE, n);
   11211      2361710 :   for (int i = 0; i < n; ++i)
   11212      1615784 :     CALL_EXPR_ARG (t, i) = args[i];
   11213       745926 :   SET_EXPR_LOCATION (t, loc);
   11214       745926 :   CALL_EXPR_IFN (t) = ifn;
   11215       745926 :   process_call_operands (t);
   11216       745926 :   return t;
   11217              : }
   11218              : 
   11219              : /* Build internal call expression.  This is just like CALL_EXPR, except
   11220              :    its CALL_EXPR_FN is NULL.  It will get gimplified later into ordinary
   11221              :    internal function.  */
   11222              : 
   11223              : tree
   11224       744850 : build_call_expr_internal_loc (location_t loc, enum internal_fn ifn,
   11225              :                               tree type, int n, ...)
   11226              : {
   11227       744850 :   va_list ap;
   11228       744850 :   tree *argarray = XALLOCAVEC (tree, n);
   11229       744850 :   int i;
   11230              : 
   11231       744850 :   va_start (ap, n);
   11232      2358470 :   for (i = 0; i < n; i++)
   11233      1613620 :     argarray[i] = va_arg (ap, tree);
   11234       744850 :   va_end (ap);
   11235       744850 :   return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
   11236              : }
   11237              : 
   11238              : /* Return a function call to FN, if the target is guaranteed to support it,
   11239              :    or null otherwise.
   11240              : 
   11241              :    N is the number of arguments, passed in the "...", and TYPE is the
   11242              :    type of the return value.  */
   11243              : 
   11244              : tree
   11245         1870 : maybe_build_call_expr_loc (location_t loc, combined_fn fn, tree type,
   11246              :                            int n, ...)
   11247              : {
   11248         1870 :   va_list ap;
   11249         1870 :   tree *argarray = XALLOCAVEC (tree, n);
   11250         1870 :   int i;
   11251              : 
   11252         1870 :   va_start (ap, n);
   11253         4873 :   for (i = 0; i < n; i++)
   11254         3003 :     argarray[i] = va_arg (ap, tree);
   11255         1870 :   va_end (ap);
   11256         1870 :   if (internal_fn_p (fn))
   11257              :     {
   11258         1064 :       internal_fn ifn = as_internal_fn (fn);
   11259         1064 :       if (direct_internal_fn_p (ifn))
   11260              :         {
   11261            1 :           tree_pair types = direct_internal_fn_types (ifn, type, argarray);
   11262            1 :           if (!direct_internal_fn_supported_p (ifn, types,
   11263              :                                                OPTIMIZE_FOR_BOTH))
   11264            1 :             return NULL_TREE;
   11265              :         }
   11266         1063 :       return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
   11267              :     }
   11268              :   else
   11269              :     {
   11270          806 :       tree fndecl = builtin_decl_implicit (as_builtin_fn (fn));
   11271          806 :       if (!fndecl)
   11272              :         return NULL_TREE;
   11273          698 :       return build_call_expr_loc_array (loc, fndecl, n, argarray);
   11274              :     }
   11275              : }
   11276              : 
   11277              : /* Return a function call to the appropriate builtin alloca variant.
   11278              : 
   11279              :    SIZE is the size to be allocated.  ALIGN, if non-zero, is the requested
   11280              :    alignment of the allocated area.  MAX_SIZE, if non-negative, is an upper
   11281              :    bound for SIZE in case it is not a fixed value.  */
   11282              : 
   11283              : tree
   11284         8965 : build_alloca_call_expr (tree size, unsigned int align, HOST_WIDE_INT max_size)
   11285              : {
   11286         8965 :   if (max_size >= 0)
   11287              :     {
   11288            0 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX);
   11289            0 :       return
   11290            0 :         build_call_expr (t, 3, size, size_int (align), size_int (max_size));
   11291              :     }
   11292         8965 :   else if (align > 0)
   11293              :     {
   11294         8965 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN);
   11295         8965 :       return build_call_expr (t, 2, size, size_int (align));
   11296              :     }
   11297              :   else
   11298              :     {
   11299            0 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA);
   11300            0 :       return build_call_expr (t, 1, size);
   11301              :     }
   11302              : }
   11303              : 
   11304              : /* The built-in decl to use to mark code points believed to be unreachable.
   11305              :    Typically __builtin_unreachable, but __builtin_trap if
   11306              :    -fsanitize=unreachable -fsanitize-trap=unreachable.  If only
   11307              :    -fsanitize=unreachable, we rely on sanopt to replace calls with the
   11308              :    appropriate ubsan function.  When building a call directly, use
   11309              :    {gimple_},build_builtin_unreachable instead.  */
   11310              : 
   11311              : tree
   11312       310680 : builtin_decl_unreachable ()
   11313              : {
   11314       310680 :   enum built_in_function fncode = BUILT_IN_UNREACHABLE;
   11315              : 
   11316       621360 :   if (sanitize_flags_p (SANITIZE_UNREACHABLE)
   11317       310680 :       ? (flag_sanitize_trap & SANITIZE_UNREACHABLE)
   11318       310084 :       : flag_unreachable_traps)
   11319           22 :     fncode = BUILT_IN_UNREACHABLE_TRAP;
   11320              :   /* For non-trapping sanitize, we will rewrite __builtin_unreachable () later,
   11321              :      in the sanopt pass.  */
   11322              : 
   11323       310680 :   return builtin_decl_explicit (fncode);
   11324              : }
   11325              : 
   11326              : /* Build a call to __builtin_unreachable, possibly rewritten by
   11327              :    -fsanitize=unreachable.  Use this rather than the above when practical.  */
   11328              : 
   11329              : tree
   11330     19415764 : build_builtin_unreachable (location_t loc)
   11331              : {
   11332     19415764 :   tree data = NULL_TREE;
   11333     19415764 :   tree fn = sanitize_unreachable_fn (&data, loc);
   11334     19415764 :   return build_call_expr_loc (loc, fn, data != NULL_TREE, data);
   11335              : }
   11336              : 
   11337              : /* Create a new constant string literal of type ELTYPE[SIZE] (or LEN
   11338              :    if SIZE == -1) and return a tree node representing char* pointer to
   11339              :    it as an ADDR_EXPR (ARRAY_REF (ELTYPE, ...)).  When STR is nonnull
   11340              :    the STRING_CST value is the LEN bytes at STR (the representation
   11341              :    of the string, which may be wide).  Otherwise it's all zeros.  */
   11342              : 
   11343              : tree
   11344       219163 : build_string_literal (unsigned len, const char *str /* = NULL */,
   11345              :                       tree eltype /* = char_type_node */,
   11346              :                       unsigned HOST_WIDE_INT size /* = -1 */)
   11347              : {
   11348       219163 :   tree t = build_string (len, str);
   11349              :   /* Set the maximum valid index based on the string length or SIZE.  */
   11350       438326 :   unsigned HOST_WIDE_INT maxidx
   11351       219163 :     = (size == HOST_WIDE_INT_M1U ? len : size) - 1;
   11352              : 
   11353       219163 :   tree index = build_index_type (size_int (maxidx));
   11354       219163 :   eltype = build_type_variant (eltype, 1, 0);
   11355       219163 :   tree type = build_array_type (eltype, index);
   11356       219163 :   TREE_TYPE (t) = type;
   11357       219163 :   TREE_CONSTANT (t) = 1;
   11358       219163 :   TREE_READONLY (t) = 1;
   11359       219163 :   TREE_STATIC (t) = 1;
   11360              : 
   11361       219163 :   type = build_pointer_type (eltype);
   11362       219163 :   t = build1 (ADDR_EXPR, type,
   11363              :               build4 (ARRAY_REF, eltype,
   11364              :                       t, integer_zero_node, NULL_TREE, NULL_TREE));
   11365       219163 :   return t;
   11366              : }
   11367              : 
   11368              : 
   11369              : 
   11370              : /* Return true if T (assumed to be a DECL) must be assigned a memory
   11371              :    location.  */
   11372              : 
   11373              : bool
   11374   1962484185 : needs_to_live_in_memory (const_tree t)
   11375              : {
   11376   1962484185 :   return (TREE_ADDRESSABLE (t)
   11377   1595197290 :           || is_global_var (t)
   11378   3115196739 :           || (TREE_CODE (t) == RESULT_DECL
   11379      8190500 :               && !DECL_BY_REFERENCE (t)
   11380      5785916 :               && aggregate_value_p (t, current_function_decl)));
   11381              : }
   11382              : 
   11383              : /* Return value of a constant X and sign-extend it.  */
   11384              : 
   11385              : HOST_WIDE_INT
   11386    719508934 : int_cst_value (const_tree x)
   11387              : {
   11388    719508934 :   unsigned bits = TYPE_PRECISION (TREE_TYPE (x));
   11389    719508934 :   unsigned HOST_WIDE_INT val = TREE_INT_CST_LOW (x);
   11390              : 
   11391              :   /* Make sure the sign-extended value will fit in a HOST_WIDE_INT.  */
   11392    719508934 :   gcc_assert (cst_and_fits_in_hwi (x));
   11393              : 
   11394    719508934 :   if (bits < HOST_BITS_PER_WIDE_INT)
   11395              :     {
   11396    704369446 :       bool negative = ((val >> (bits - 1)) & 1) != 0;
   11397    704369446 :       if (negative)
   11398       251778 :         val |= HOST_WIDE_INT_M1U << (bits - 1) << 1;
   11399              :       else
   11400    704117668 :         val &= ~(HOST_WIDE_INT_M1U << (bits - 1) << 1);
   11401              :     }
   11402              : 
   11403    719508934 :   return val;
   11404              : }
   11405              : 
   11406              : /* If TYPE is an integral or pointer type, return an integer type with
   11407              :    the same precision which is unsigned iff UNSIGNEDP is true, or itself
   11408              :    if TYPE is already an integer type of signedness UNSIGNEDP.
   11409              :    If TYPE is a floating-point type, return an integer type with the same
   11410              :    bitsize and with the signedness given by UNSIGNEDP; this is useful
   11411              :    when doing bit-level operations on a floating-point value.  */
   11412              : 
   11413              : tree
   11414     79433575 : signed_or_unsigned_type_for (int unsignedp, tree type)
   11415              : {
   11416     79433575 :   if (ANY_INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) == unsignedp)
   11417              :     return type;
   11418              : 
   11419     53657827 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11420              :     {
   11421        28156 :       tree inner = TREE_TYPE (type);
   11422        28156 :       tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
   11423        28156 :       if (!inner2)
   11424              :         return NULL_TREE;
   11425        28156 :       if (inner == inner2)
   11426              :         return type;
   11427        28156 :       machine_mode new_mode;
   11428        56312 :       if (VECTOR_MODE_P (TYPE_MODE (type))
   11429        56228 :           && related_int_vector_mode (TYPE_MODE (type)).exists (&new_mode))
   11430        28072 :         return build_vector_type_for_mode (inner2, new_mode);
   11431           84 :       return build_vector_type (inner2, TYPE_VECTOR_SUBPARTS (type));
   11432              :     }
   11433              : 
   11434              :   if (TREE_CODE (type) == COMPLEX_TYPE)
   11435              :     {
   11436           24 :       tree inner = TREE_TYPE (type);
   11437           24 :       tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
   11438           24 :       if (!inner2)
   11439              :         return NULL_TREE;
   11440           24 :       if (inner == inner2)
   11441              :         return type;
   11442           24 :       return build_complex_type (inner2);
   11443              :     }
   11444              : 
   11445              :   unsigned int bits;
   11446              :   if (INTEGRAL_TYPE_P (type)
   11447              :       || POINTER_TYPE_P (type)
   11448              :       || TREE_CODE (type) == OFFSET_TYPE)
   11449     53629553 :     bits = TYPE_PRECISION (type);
   11450              :   else if (TREE_CODE (type) == REAL_TYPE)
   11451          188 :     bits = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (type));
   11452              :   else
   11453              :     return NULL_TREE;
   11454              : 
   11455     53629647 :   if (TREE_CODE (type) == BITINT_TYPE)
   11456         1858 :     return build_bitint_type (bits, unsignedp);
   11457     53627789 :   return build_nonstandard_integer_type (bits, unsignedp);
   11458              : }
   11459              : 
   11460              : /* If TYPE is an integral or pointer type, return an integer type with
   11461              :    the same precision which is unsigned, or itself if TYPE is already an
   11462              :    unsigned integer type.  If TYPE is a floating-point type, return an
   11463              :    unsigned integer type with the same bitsize as TYPE.  */
   11464              : 
   11465              : tree
   11466     69280082 : unsigned_type_for (tree type)
   11467              : {
   11468     69280082 :   return signed_or_unsigned_type_for (1, type);
   11469              : }
   11470              : 
   11471              : /* If TYPE is an integral or pointer type, return an integer type with
   11472              :    the same precision which is signed, or itself if TYPE is already a
   11473              :    signed integer type.  If TYPE is a floating-point type, return a
   11474              :    signed integer type with the same bitsize as TYPE.  */
   11475              : 
   11476              : tree
   11477     10119965 : signed_type_for (tree type)
   11478              : {
   11479     10119965 :   return signed_or_unsigned_type_for (0, type);
   11480              : }
   11481              : 
   11482              : /* - For VECTOR_TYPEs:
   11483              :     - The truth type must be a VECTOR_BOOLEAN_TYPE.
   11484              :     - The number of elements must match (known_eq).
   11485              :     - targetm.vectorize.get_mask_mode exists, and exactly
   11486              :       the same mode as the truth type.
   11487              :    - Otherwise, the truth type must be a BOOLEAN_TYPE
   11488              :      or useless_type_conversion_p to BOOLEAN_TYPE.  */
   11489              : bool
   11490         1422 : is_truth_type_for (tree type, tree truth_type)
   11491              : {
   11492         1422 :   machine_mode mask_mode = TYPE_MODE (truth_type);
   11493         1422 :   machine_mode vmode = TYPE_MODE (type);
   11494         1422 :   machine_mode tmask_mode;
   11495              : 
   11496         1422 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11497              :     {
   11498         1422 :       if (VECTOR_BOOLEAN_TYPE_P (truth_type)
   11499         1422 :           && known_eq (TYPE_VECTOR_SUBPARTS (type),
   11500              :                        TYPE_VECTOR_SUBPARTS (truth_type))
   11501         1422 :           && targetm.vectorize.get_mask_mode (vmode).exists (&tmask_mode)
   11502         2844 :           && tmask_mode == mask_mode)
   11503         1403 :         return true;
   11504              : 
   11505           19 :       return false;
   11506              :     }
   11507              : 
   11508            0 :   return useless_type_conversion_p (boolean_type_node, truth_type);
   11509              : }
   11510              : 
   11511              : /* If TYPE is a vector type, return a signed integer vector type with the
   11512              :    same width and number of subparts. Otherwise return boolean_type_node.  */
   11513              : 
   11514              : tree
   11515      4412757 : truth_type_for (tree type)
   11516              : {
   11517      4412757 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11518              :     {
   11519      2628096 :       if (VECTOR_BOOLEAN_TYPE_P (type))
   11520              :         return type;
   11521      2553998 :       return build_truth_vector_type_for (type);
   11522              :     }
   11523              :   else
   11524      1784661 :     return boolean_type_node;
   11525              : }
   11526              : 
   11527              : /* Returns the largest value obtainable by casting something in INNER type to
   11528              :    OUTER type.  */
   11529              : 
   11530              : tree
   11531     10980512 : upper_bound_in_type (tree outer, tree inner)
   11532              : {
   11533     10980512 :   unsigned int det = 0;
   11534     10980512 :   unsigned oprec = TYPE_PRECISION (outer);
   11535     10980512 :   unsigned iprec = TYPE_PRECISION (inner);
   11536     10980512 :   unsigned prec;
   11537              : 
   11538              :   /* Compute a unique number for every combination.  */
   11539     10980512 :   det |= (oprec > iprec) ? 4 : 0;
   11540     10980512 :   det |= TYPE_UNSIGNED (outer) ? 2 : 0;
   11541     10980512 :   det |= TYPE_UNSIGNED (inner) ? 1 : 0;
   11542              : 
   11543              :   /* Determine the exponent to use.  */
   11544     10980512 :   switch (det)
   11545              :     {
   11546      7267671 :     case 0:
   11547      7267671 :     case 1:
   11548              :       /* oprec <= iprec, outer: signed, inner: don't care.  */
   11549      7267671 :       prec = oprec - 1;
   11550      7267671 :       break;
   11551              :     case 2:
   11552              :     case 3:
   11553              :       /* oprec <= iprec, outer: unsigned, inner: don't care.  */
   11554              :       prec = oprec;
   11555              :       break;
   11556        22612 :     case 4:
   11557              :       /* oprec > iprec, outer: signed, inner: signed.  */
   11558        22612 :       prec = iprec - 1;
   11559        22612 :       break;
   11560              :     case 5:
   11561              :       /* oprec > iprec, outer: signed, inner: unsigned.  */
   11562         8746 :       prec = iprec;
   11563              :       break;
   11564              :     case 6:
   11565              :       /* oprec > iprec, outer: unsigned, inner: signed.  */
   11566              :       prec = oprec;
   11567              :       break;
   11568              :     case 7:
   11569              :       /* oprec > iprec, outer: unsigned, inner: unsigned.  */
   11570         8746 :       prec = iprec;
   11571              :       break;
   11572              :     default:
   11573              :       gcc_unreachable ();
   11574              :     }
   11575              : 
   11576     10980512 :   return wide_int_to_tree (outer,
   11577     10980512 :                            wi::mask (prec, false, TYPE_PRECISION (outer)));
   11578              : }
   11579              : 
   11580              : /* Returns the smallest value obtainable by casting something in INNER type to
   11581              :    OUTER type.  */
   11582              : 
   11583              : tree
   11584      8365927 : lower_bound_in_type (tree outer, tree inner)
   11585              : {
   11586      8365927 :   unsigned oprec = TYPE_PRECISION (outer);
   11587      8365927 :   unsigned iprec = TYPE_PRECISION (inner);
   11588              : 
   11589              :   /* If OUTER type is unsigned, we can definitely cast 0 to OUTER type
   11590              :      and obtain 0.  */
   11591      8365927 :   if (TYPE_UNSIGNED (outer)
   11592              :       /* If we are widening something of an unsigned type, OUTER type
   11593              :          contains all values of INNER type.  In particular, both INNER
   11594              :          and OUTER types have zero in common.  */
   11595      8365927 :       || (oprec > iprec && TYPE_UNSIGNED (inner)))
   11596      2235356 :     return build_int_cst (outer, 0);
   11597              :   else
   11598              :     {
   11599              :       /* If we are widening a signed type to another signed type, we
   11600              :          want to obtain -2^^(iprec-1).  If we are keeping the
   11601              :          precision or narrowing to a signed type, we want to obtain
   11602              :          -2^(oprec-1).  */
   11603      6130571 :       unsigned prec = oprec > iprec ? iprec : oprec;
   11604      6130571 :       return wide_int_to_tree (outer,
   11605     12261142 :                                wi::mask (prec - 1, true,
   11606      6130571 :                                          TYPE_PRECISION (outer)));
   11607              :     }
   11608              : }
   11609              : 
   11610              : /* Return true if two operands that are suitable for PHI nodes are
   11611              :    necessarily equal.  Specifically, both ARG0 and ARG1 must be either
   11612              :    SSA_NAME or invariant.  Note that this is strictly an optimization.
   11613              :    That is, callers of this function can directly call operand_equal_p
   11614              :    and get the same result, only slower.  */
   11615              : 
   11616              : bool
   11617     21141839 : operand_equal_for_phi_arg_p (const_tree arg0, const_tree arg1)
   11618              : {
   11619     21141839 :   if (arg0 == arg1)
   11620              :     return true;
   11621     19541961 :   if (TREE_CODE (arg0) == SSA_NAME || TREE_CODE (arg1) == SSA_NAME)
   11622              :     return false;
   11623      4123084 :   return operand_equal_p (arg0, arg1, 0);
   11624              : }
   11625              : 
   11626              : /* Returns number of zeros at the end of binary representation of X.  */
   11627              : 
   11628              : tree
   11629      9336623 : num_ending_zeros (const_tree x)
   11630              : {
   11631      9336623 :   return build_int_cst (TREE_TYPE (x), wi::ctz (wi::to_wide (x)));
   11632              : }
   11633              : 
   11634              : 
   11635              : #define WALK_SUBTREE(NODE)                              \
   11636              :   do                                                    \
   11637              :     {                                                   \
   11638              :       result = walk_tree_1 (&(NODE), func, data, pset, lh); \
   11639              :       if (result)                                       \
   11640              :         return result;                                  \
   11641              :     }                                                   \
   11642              :   while (0)
   11643              : 
   11644              : /* This is a subroutine of walk_tree that walks field of TYPE that are to
   11645              :    be walked whenever a type is seen in the tree.  Rest of operands and return
   11646              :    value are as for walk_tree.  */
   11647              : 
   11648              : static tree
   11649   4944298661 : walk_type_fields (tree type, walk_tree_fn func, void *data,
   11650              :                   hash_set<tree> *pset, walk_tree_lh lh)
   11651              : {
   11652   4944298661 :   tree result = NULL_TREE;
   11653              : 
   11654   4944298661 :   switch (TREE_CODE (type))
   11655              :     {
   11656   1438737072 :     case POINTER_TYPE:
   11657   1438737072 :     case REFERENCE_TYPE:
   11658   1438737072 :     case VECTOR_TYPE:
   11659              :       /* We have to worry about mutually recursive pointers.  These can't
   11660              :          be written in C.  They can in Ada.  It's pathological, but
   11661              :          there's an ACATS test (c38102a) that checks it.  Deal with this
   11662              :          by checking if we're pointing to another pointer, that one
   11663              :          points to another pointer, that one does too, and we have no htab.
   11664              :          If so, get a hash table.  We check three levels deep to avoid
   11665              :          the cost of the hash table if we don't need one.  */
   11666   2829700908 :       if (POINTER_TYPE_P (TREE_TYPE (type))
   11667     47773303 :           && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (type)))
   11668      7324471 :           && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (TREE_TYPE (type))))
   11669   1445965354 :           && !pset)
   11670              :         {
   11671            0 :           result = walk_tree_without_duplicates (&TREE_TYPE (type),
   11672              :                                                  func, data);
   11673            0 :           if (result)
   11674              :             return result;
   11675              : 
   11676              :           break;
   11677              :         }
   11678              : 
   11679              :       /* fall through */
   11680              : 
   11681   1441503390 :     case COMPLEX_TYPE:
   11682   1441503390 :       WALK_SUBTREE (TREE_TYPE (type));
   11683              :       break;
   11684              : 
   11685    252110555 :     case METHOD_TYPE:
   11686    252110555 :       WALK_SUBTREE (TYPE_METHOD_BASETYPE (type));
   11687              : 
   11688              :       /* Fall through.  */
   11689              : 
   11690    411500400 :     case FUNCTION_TYPE:
   11691    411500400 :       WALK_SUBTREE (TREE_TYPE (type));
   11692    411500362 :       {
   11693    411500362 :         tree arg;
   11694              : 
   11695              :         /* We never want to walk into default arguments.  */
   11696   1578115088 :         for (arg = TYPE_ARG_TYPES (type); arg; arg = TREE_CHAIN (arg))
   11697   1166642326 :           WALK_SUBTREE (TREE_VALUE (arg));
   11698              :       }
   11699              :       break;
   11700              : 
   11701     16177519 :     case ARRAY_TYPE:
   11702              :       /* Don't follow this nodes's type if a pointer for fear that
   11703              :          we'll have infinite recursion.  If we have a PSET, then we
   11704              :          need not fear.  */
   11705     16177519 :       if (pset
   11706     16177519 :           || (!POINTER_TYPE_P (TREE_TYPE (type))
   11707       145539 :               && TREE_CODE (TREE_TYPE (type)) != OFFSET_TYPE))
   11708     16157421 :         WALK_SUBTREE (TREE_TYPE (type));
   11709     16174939 :       WALK_SUBTREE (TYPE_DOMAIN (type));
   11710              :       break;
   11711              : 
   11712      1067669 :     case OFFSET_TYPE:
   11713      1067669 :       WALK_SUBTREE (TREE_TYPE (type));
   11714      1066811 :       WALK_SUBTREE (TYPE_OFFSET_BASETYPE (type));
   11715              :       break;
   11716              : 
   11717              :     default:
   11718              :       break;
   11719              :     }
   11720              : 
   11721              :   return NULL_TREE;
   11722              : }
   11723              : 
   11724              : /* Apply FUNC to all the sub-trees of TP in a pre-order traversal.  FUNC is
   11725              :    called with the DATA and the address of each sub-tree.  If FUNC returns a
   11726              :    non-NULL value, the traversal is stopped, and the value returned by FUNC
   11727              :    is returned.  If PSET is non-NULL it is used to record the nodes visited,
   11728              :    and to avoid visiting a node more than once.  */
   11729              : 
   11730              : tree
   11731  >10468*10^7 : walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
   11732              :              hash_set<tree> *pset, walk_tree_lh lh)
   11733              : {
   11734              : #define WALK_SUBTREE_TAIL(NODE)                         \
   11735              :   do                                                    \
   11736              :     {                                                   \
   11737              :        tp = & (NODE);                                       \
   11738              :        goto tail_recurse;                               \
   11739              :     }                                                   \
   11740              :   while (0)
   11741              : 
   11742  >12924*10^7 :  tail_recurse:
   11743              :   /* Skip empty subtrees.  */
   11744  >12924*10^7 :   if (!*tp)
   11745              :     return NULL_TREE;
   11746              : 
   11747              :   /* Don't walk the same tree twice, if the user has requested
   11748              :      that we avoid doing so.  */
   11749  >10685*10^7 :   if (pset && pset->add (*tp))
   11750              :     return NULL_TREE;
   11751              : 
   11752              :   /* Call the function.  */
   11753  >10518*10^7 :   int walk_subtrees = 1;
   11754  >10518*10^7 :   tree result = (*func) (tp, &walk_subtrees, data);
   11755              : 
   11756              :   /* If we found something, return it.  */
   11757  >10518*10^7 :   if (result)
   11758              :     return result;
   11759              : 
   11760  >10511*10^7 :   tree t = *tp;
   11761  >10511*10^7 :   tree_code code = TREE_CODE (t);
   11762              : 
   11763              :   /* Even if we didn't, FUNC may have decided that there was nothing
   11764              :      interesting below this point in the tree.  */
   11765  >10511*10^7 :   if (!walk_subtrees)
   11766              :     {
   11767              :       /* But we still need to check our siblings.  */
   11768  64419383313 :       if (code == TREE_LIST)
   11769       104174 :         WALK_SUBTREE_TAIL (TREE_CHAIN (t));
   11770  64419279139 :       else if (code == OMP_CLAUSE)
   11771       887131 :         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (t));
   11772              :       else
   11773              :         return NULL_TREE;
   11774              :     }
   11775              : 
   11776  40693579015 :   if (lh)
   11777              :     {
   11778  23906670359 :       result = (*lh) (tp, &walk_subtrees, func, data, pset);
   11779  23906670359 :       if (result || !walk_subtrees)
   11780   2771917744 :         return result;
   11781              :     }
   11782              : 
   11783  37921661271 :   switch (code)
   11784              :     {
   11785              :     case ERROR_MARK:
   11786              :     case IDENTIFIER_NODE:
   11787              :     case INTEGER_CST:
   11788              :     case REAL_CST:
   11789              :     case FIXED_CST:
   11790              :     case STRING_CST:
   11791              :     case BLOCK:
   11792              :     case PLACEHOLDER_EXPR:
   11793              :     case SSA_NAME:
   11794              :     case FIELD_DECL:
   11795              :     case RESULT_DECL:
   11796              :       /* None of these have subtrees other than those already walked
   11797              :          above.  */
   11798              :       break;
   11799              : 
   11800    268461577 :     case TREE_LIST:
   11801    268461577 :       WALK_SUBTREE (TREE_VALUE (t));
   11802    267999462 :       WALK_SUBTREE_TAIL (TREE_CHAIN (t));
   11803              : 
   11804   1266738065 :     case TREE_VEC:
   11805   1266738065 :       {
   11806   1266738065 :         int len = TREE_VEC_LENGTH (t);
   11807              : 
   11808   1266738065 :         if (len == 0)
   11809              :           break;
   11810              : 
   11811              :         /* Walk all elements but the last.  */
   11812   2330912126 :         for (int i = 0; i < len - 1; ++i)
   11813   1073492121 :           WALK_SUBTREE (TREE_VEC_ELT (t, i));
   11814              : 
   11815              :         /* Now walk the last one as a tail call.  */
   11816   1257420005 :         WALK_SUBTREE_TAIL (TREE_VEC_ELT (t, len - 1));
   11817              :       }
   11818              : 
   11819      5121608 :     case VECTOR_CST:
   11820      5121608 :       {
   11821      5121608 :         unsigned len = vector_cst_encoded_nelts (t);
   11822      5121608 :         if (len == 0)
   11823              :           break;
   11824              :         /* Walk all elements but the last.  */
   11825     17466455 :         for (unsigned i = 0; i < len - 1; ++i)
   11826     12344991 :           WALK_SUBTREE (VECTOR_CST_ENCODED_ELT (t, i));
   11827              :         /* Now walk the last one as a tail call.  */
   11828      5121464 :         WALK_SUBTREE_TAIL (VECTOR_CST_ENCODED_ELT (t, len - 1));
   11829              :       }
   11830              : 
   11831       629959 :     case COMPLEX_CST:
   11832       629959 :       WALK_SUBTREE (TREE_REALPART (t));
   11833       628393 :       WALK_SUBTREE_TAIL (TREE_IMAGPART (t));
   11834              : 
   11835              :     case CONSTRUCTOR:
   11836              :       {
   11837              :         unsigned HOST_WIDE_INT idx;
   11838              :         constructor_elt *ce;
   11839              : 
   11840    897095591 :         for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (t), idx, &ce);
   11841              :              idx++)
   11842    463688133 :           WALK_SUBTREE (ce->value);
   11843              :       }
   11844              :       break;
   11845              : 
   11846      4526603 :     case SAVE_EXPR:
   11847      4526603 :       WALK_SUBTREE_TAIL (TREE_OPERAND (t, 0));
   11848              : 
   11849    255857492 :     case BIND_EXPR:
   11850    255857492 :       {
   11851    255857492 :         tree decl;
   11852    412623327 :         for (decl = BIND_EXPR_VARS (t); decl; decl = DECL_CHAIN (decl))
   11853              :           {
   11854              :             /* Walk the DECL_INITIAL and DECL_SIZE.  We don't want to walk
   11855              :                into declarations that are just mentioned, rather than
   11856              :                declared; they don't really belong to this part of the tree.
   11857              :                And, we can see cycles: the initializer for a declaration
   11858              :                can refer to the declaration itself.  */
   11859    156765859 :             WALK_SUBTREE (DECL_INITIAL (decl));
   11860    156765835 :             WALK_SUBTREE (DECL_SIZE (decl));
   11861    156765835 :             WALK_SUBTREE (DECL_SIZE_UNIT (decl));
   11862              :           }
   11863    255857468 :         WALK_SUBTREE_TAIL (BIND_EXPR_BODY (t));
   11864              :       }
   11865              : 
   11866    343448893 :     case STATEMENT_LIST:
   11867    343448893 :       {
   11868    343448893 :         tree_stmt_iterator i;
   11869   1233577033 :         for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
   11870    890305511 :           WALK_SUBTREE (*tsi_stmt_ptr (i));
   11871              :       }
   11872    343271522 :       break;
   11873              : 
   11874      1835718 :     case OMP_CLAUSE:
   11875      1835718 :       {
   11876      1835718 :         int len = omp_clause_num_ops[OMP_CLAUSE_CODE (t)];
   11877              :         /* Do not walk the iterator operand of OpenMP MAP clauses.  */
   11878      1835718 :         if (OMP_CLAUSE_HAS_ITERATORS (t))
   11879         1578 :           len--;
   11880      5227713 :         for (int i = 0; i < len; i++)
   11881      3391995 :           WALK_SUBTREE (OMP_CLAUSE_OPERAND (t, i));
   11882      1835718 :         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (t));
   11883              :       }
   11884              : 
   11885     77541579 :     case TARGET_EXPR:
   11886     77541579 :       {
   11887     77541579 :         int i, len;
   11888              : 
   11889              :         /* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
   11890              :            But, we only want to walk once.  */
   11891     77541579 :         len = (TREE_OPERAND (t, 3) == TREE_OPERAND (t, 1)) ? 2 : 3;
   11892    310134131 :         for (i = 0; i < len; ++i)
   11893    232608616 :           WALK_SUBTREE (TREE_OPERAND (t, i));
   11894     77525515 :         WALK_SUBTREE_TAIL (TREE_OPERAND (t, len));
   11895              :       }
   11896              : 
   11897    153583444 :     case DECL_EXPR:
   11898              :       /* If this is a TYPE_DECL, walk into the fields of the type that it's
   11899              :          defining.  We only want to walk into these fields of a type in this
   11900              :          case and not in the general case of a mere reference to the type.
   11901              : 
   11902              :          The criterion is as follows: if the field can be an expression, it
   11903              :          must be walked only here.  This should be in keeping with the fields
   11904              :          that are directly gimplified in gimplify_type_sizes in order for the
   11905              :          mark/copy-if-shared/unmark machinery of the gimplifier to work with
   11906              :          variable-sized types.
   11907              : 
   11908              :          Note that DECLs get walked as part of processing the BIND_EXPR.  */
   11909    153583444 :       if (TREE_CODE (DECL_EXPR_DECL (t)) == TYPE_DECL)
   11910              :         {
   11911              :           /* Call the function for the decl so e.g. copy_tree_body_r can
   11912              :              replace it with the remapped one.  */
   11913      1586279 :           result = (*func) (&DECL_EXPR_DECL (t), &walk_subtrees, data);
   11914      1586279 :           if (result || !walk_subtrees)
   11915        44615 :             return result;
   11916              : 
   11917      1541664 :           tree *type_p = &TREE_TYPE (DECL_EXPR_DECL (t));
   11918      1541664 :           if (TREE_CODE (*type_p) == ERROR_MARK)
   11919              :             return NULL_TREE;
   11920              : 
   11921              :           /* Call the function for the type.  See if it returns anything or
   11922              :              doesn't want us to continue.  If we are to continue, walk both
   11923              :              the normal fields and those for the declaration case.  */
   11924      1541664 :           result = (*func) (type_p, &walk_subtrees, data);
   11925      1541664 :           if (result || !walk_subtrees)
   11926        86502 :             return result;
   11927              : 
   11928      1455162 :           tree type = *type_p;
   11929              : 
   11930              :           /* But do not walk a pointed-to type since it may itself need to
   11931              :              be walked in the declaration case if it isn't anonymous.  */
   11932      1455162 :           if (!POINTER_TYPE_P (type))
   11933              :             {
   11934      1439456 :               result = walk_type_fields (type, func, data, pset, lh);
   11935      1439456 :               if (result)
   11936              :                 return result;
   11937              :             }
   11938              : 
   11939              :           /* If this is a record type, also walk the fields.  */
   11940      1455162 :           if (RECORD_OR_UNION_TYPE_P (type))
   11941              :             {
   11942       429392 :               tree field;
   11943              : 
   11944      1969620 :               for (field = TYPE_FIELDS (type); field;
   11945      1540228 :                    field = DECL_CHAIN (field))
   11946              :                 {
   11947              :                   /* We'd like to look at the type of the field, but we can
   11948              :                      easily get infinite recursion.  So assume it's pointed
   11949              :                      to elsewhere in the tree.  Also, ignore things that
   11950              :                      aren't fields.  */
   11951      1540228 :                   if (TREE_CODE (field) != FIELD_DECL)
   11952      1180833 :                     continue;
   11953              : 
   11954       359395 :                   WALK_SUBTREE (DECL_FIELD_OFFSET (field));
   11955       359395 :                   WALK_SUBTREE (DECL_SIZE (field));
   11956       359395 :                   WALK_SUBTREE (DECL_SIZE_UNIT (field));
   11957       359395 :                   if (TREE_CODE (type) == QUAL_UNION_TYPE)
   11958            0 :                     WALK_SUBTREE (DECL_QUALIFIER (field));
   11959              :                 }
   11960              :             }
   11961              : 
   11962              :           /* Same for scalar types.  */
   11963      1025770 :           else if (TREE_CODE (type) == BOOLEAN_TYPE
   11964              :                    || TREE_CODE (type) == ENUMERAL_TYPE
   11965      1025770 :                    || TREE_CODE (type) == INTEGER_TYPE
   11966      1025383 :                    || TREE_CODE (type) == FIXED_POINT_TYPE
   11967      1025383 :                    || TREE_CODE (type) == REAL_TYPE)
   11968              :             {
   11969          388 :               WALK_SUBTREE (TYPE_MIN_VALUE (type));
   11970          388 :               WALK_SUBTREE (TYPE_MAX_VALUE (type));
   11971              :             }
   11972              : 
   11973      1455162 :           WALK_SUBTREE (TYPE_SIZE (type));
   11974      1455162 :           WALK_SUBTREE_TAIL (TYPE_SIZE_UNIT (type));
   11975              :         }
   11976              :       /* FALLTHRU */
   11977              : 
   11978  30895417360 :     default:
   11979  30895417360 :       if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
   11980              :         {
   11981  22939950928 :           int i, len;
   11982              : 
   11983              :           /* Walk over all the sub-trees of this operand.  */
   11984  22939950928 :           len = TREE_OPERAND_LENGTH (t);
   11985              : 
   11986              :           /* Go through the subtrees.  We need to do this in forward order so
   11987              :              that the scope of a FOR_EXPR is handled properly.  */
   11988  22939950928 :           if (len)
   11989              :             {
   11990  46125047737 :               for (i = 0; i < len - 1; ++i)
   11991  23442221391 :                 WALK_SUBTREE (TREE_OPERAND (t, i));
   11992  22682826346 :               WALK_SUBTREE_TAIL (TREE_OPERAND (t, len - 1));
   11993              :             }
   11994              :         }
   11995              :       /* If this is a type, walk the needed fields in the type.  */
   11996   7955466432 :       else if (TYPE_P (t))
   11997   4942859205 :         return walk_type_fields (t, func, data, pset, lh);
   11998              :       break;
   11999              :     }
   12000              : 
   12001              :   /* We didn't find what we were looking for.  */
   12002              :   return NULL_TREE;
   12003              : 
   12004              : #undef WALK_SUBTREE_TAIL
   12005              : }
   12006              : #undef WALK_SUBTREE
   12007              : 
   12008              : /* Like walk_tree, but does not walk duplicate nodes more than once.  */
   12009              : 
   12010              : tree
   12011   3676598733 : walk_tree_without_duplicates_1 (tree *tp, walk_tree_fn func, void *data,
   12012              :                                 walk_tree_lh lh)
   12013              : {
   12014   3676598733 :   tree result;
   12015              : 
   12016   3676598733 :   hash_set<tree> pset;
   12017   3676598733 :   result = walk_tree_1 (tp, func, data, &pset, lh);
   12018   3676598733 :   return result;
   12019   3676598733 : }
   12020              : 
   12021              : 
   12022              : tree
   12023   1113967012 : tree_block (tree t)
   12024              : {
   12025   1113967012 :   const enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
   12026              : 
   12027   1113967012 :   if (IS_EXPR_CODE_CLASS (c))
   12028   1113967012 :     return LOCATION_BLOCK (t->exp.locus);
   12029            0 :   gcc_unreachable ();
   12030              :   return NULL;
   12031              : }
   12032              : 
   12033              : void
   12034    699486200 : tree_set_block (tree t, tree b)
   12035              : {
   12036    699486200 :   const enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
   12037              : 
   12038    699486200 :   if (IS_EXPR_CODE_CLASS (c))
   12039              :     {
   12040    699486200 :       t->exp.locus = set_block (t->exp.locus, b);
   12041              :     }
   12042              :   else
   12043            0 :     gcc_unreachable ();
   12044    699486200 : }
   12045              : 
   12046              : /* Create a nameless artificial label and put it in the current
   12047              :    function context.  The label has a location of LOC.  Returns the
   12048              :    newly created label.  */
   12049              : 
   12050              : tree
   12051     31734209 : create_artificial_label (location_t loc)
   12052              : {
   12053     31734209 :   tree lab = build_decl (loc,
   12054              :                          LABEL_DECL, NULL_TREE, void_type_node);
   12055              : 
   12056     31734209 :   DECL_ARTIFICIAL (lab) = 1;
   12057     31734209 :   DECL_IGNORED_P (lab) = 1;
   12058     31734209 :   DECL_CONTEXT (lab) = current_function_decl;
   12059     31734209 :   return lab;
   12060              : }
   12061              : 
   12062              : /*  Given a tree, try to return a useful variable name that we can use
   12063              :     to prefix a temporary that is being assigned the value of the tree.
   12064              :     I.E. given  <temp> = &A, return A.  */
   12065              : 
   12066              : const char *
   12067     24880927 : get_name (tree t)
   12068              : {
   12069     26723209 :   tree stripped_decl;
   12070              : 
   12071     26723209 :   stripped_decl = t;
   12072     26723209 :   STRIP_NOPS (stripped_decl);
   12073     26723209 :   if (DECL_P (stripped_decl) && DECL_NAME (stripped_decl))
   12074      4053695 :     return IDENTIFIER_POINTER (DECL_NAME (stripped_decl));
   12075     22669514 :   else if (TREE_CODE (stripped_decl) == SSA_NAME)
   12076              :     {
   12077      1368370 :       tree name = SSA_NAME_IDENTIFIER (stripped_decl);
   12078       336534 :       if (!name)
   12079              :         return NULL;
   12080       335006 :       return IDENTIFIER_POINTER (name);
   12081              :     }
   12082              :   else
   12083              :     {
   12084     21301144 :       switch (TREE_CODE (stripped_decl))
   12085              :         {
   12086      1842282 :         case ADDR_EXPR:
   12087      1842282 :           return get_name (TREE_OPERAND (stripped_decl, 0));
   12088              :         default:
   12089              :           return NULL;
   12090              :         }
   12091              :     }
   12092              : }
   12093              : 
   12094              : /* Return true if TYPE has a variable argument list.  */
   12095              : 
   12096              : bool
   12097    226810068 : stdarg_p (const_tree fntype)
   12098              : {
   12099    226810068 :   function_args_iterator args_iter;
   12100    226810068 :   tree n = NULL_TREE, t;
   12101              : 
   12102    226810068 :   if (!fntype)
   12103              :     return false;
   12104              : 
   12105    226679187 :   if (TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
   12106              :     return true;
   12107              : 
   12108    919151455 :   FOREACH_FUNCTION_ARGS (fntype, t, args_iter)
   12109              :     {
   12110    693214100 :       n = t;
   12111              :     }
   12112              : 
   12113    225937355 :   return n != NULL_TREE && n != void_type_node;
   12114              : }
   12115              : 
   12116              : /* Return true if TYPE has a prototype.  */
   12117              : 
   12118              : bool
   12119    726054315 : prototype_p (const_tree fntype)
   12120              : {
   12121    726054315 :   tree t;
   12122              : 
   12123    726054315 :   gcc_assert (fntype != NULL_TREE);
   12124              : 
   12125    726054315 :   if (TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
   12126              :     return true;
   12127              : 
   12128    725214627 :   t = TYPE_ARG_TYPES (fntype);
   12129    725214627 :   return (t != NULL_TREE);
   12130              : }
   12131              : 
   12132              : /* If BLOCK is inlined from an __attribute__((__artificial__))
   12133              :    routine, return pointer to location from where it has been
   12134              :    called.  */
   12135              : location_t *
   12136       166281 : block_nonartificial_location (tree block)
   12137              : {
   12138       166281 :   location_t *ret = NULL;
   12139              : 
   12140       423177 :   while (block && TREE_CODE (block) == BLOCK
   12141       508591 :          && BLOCK_ABSTRACT_ORIGIN (block))
   12142              :     {
   12143       154431 :       tree ao = BLOCK_ABSTRACT_ORIGIN (block);
   12144       154431 :       if (TREE_CODE (ao) == FUNCTION_DECL)
   12145              :         {
   12146              :           /* If AO is an artificial inline, point RET to the
   12147              :              call site locus at which it has been inlined and continue
   12148              :              the loop, in case AO's caller is also an artificial
   12149              :              inline.  */
   12150        65570 :           if (DECL_DECLARED_INLINE_P (ao)
   12151        65570 :               && lookup_attribute ("artificial", DECL_ATTRIBUTES (ao)))
   12152         1813 :             ret = &BLOCK_SOURCE_LOCATION (block);
   12153              :           else
   12154              :             break;
   12155              :         }
   12156        88861 :       else if (TREE_CODE (ao) != BLOCK)
   12157              :         break;
   12158              : 
   12159        90674 :       block = BLOCK_SUPERCONTEXT (block);
   12160              :     }
   12161       166281 :   return ret;
   12162              : }
   12163              : 
   12164              : 
   12165              : /* If EXP is inlined from an __attribute__((__artificial__))
   12166              :    function, return the location of the original call expression.  */
   12167              : 
   12168              : location_t
   12169           59 : tree_nonartificial_location (tree exp)
   12170              : {
   12171           59 :   location_t *loc = block_nonartificial_location (TREE_BLOCK (exp));
   12172              : 
   12173           59 :   if (loc)
   12174            0 :     return *loc;
   12175              :   else
   12176           59 :     return EXPR_LOCATION (exp);
   12177              : }
   12178              : 
   12179              : /* Return the location into which EXP has been inlined.  Analogous
   12180              :    to tree_nonartificial_location() above but not limited to artificial
   12181              :    functions declared inline.  If SYSTEM_HEADER is true, return
   12182              :    the macro expansion point of the location if it's in a system header */
   12183              : 
   12184              : location_t
   12185            0 : tree_inlined_location (tree exp, bool system_header /* = true */)
   12186              : {
   12187            0 :   location_t loc = UNKNOWN_LOCATION;
   12188              : 
   12189            0 :   tree block = TREE_BLOCK (exp);
   12190              : 
   12191            0 :   while (block && TREE_CODE (block) == BLOCK
   12192            0 :          && BLOCK_ABSTRACT_ORIGIN (block))
   12193              :     {
   12194            0 :       tree ao = BLOCK_ABSTRACT_ORIGIN (block);
   12195            0 :       if (TREE_CODE (ao) == FUNCTION_DECL)
   12196            0 :         loc = BLOCK_SOURCE_LOCATION (block);
   12197            0 :       else if (TREE_CODE (ao) != BLOCK)
   12198              :         break;
   12199              : 
   12200            0 :       block = BLOCK_SUPERCONTEXT (block);
   12201              :     }
   12202              : 
   12203            0 :   if (loc == UNKNOWN_LOCATION)
   12204              :     {
   12205            0 :       loc = EXPR_LOCATION (exp);
   12206            0 :       if (system_header)
   12207              :         /* Only consider macro expansion when the block traversal failed
   12208              :            to find a location.  Otherwise it's not relevant.  */
   12209            0 :         return expansion_point_location_if_in_system_header (loc);
   12210              :     }
   12211              : 
   12212              :   return loc;
   12213              : }
   12214              : 
   12215              : /* These are the hash table functions for the hash table of OPTIMIZATION_NODE
   12216              :    nodes.  */
   12217              : 
   12218              : /* Return the hash code X, an OPTIMIZATION_NODE or TARGET_OPTION code.  */
   12219              : 
   12220              : hashval_t
   12221    868690096 : cl_option_hasher::hash (tree x)
   12222              : {
   12223    868690096 :   const_tree const t = x;
   12224              : 
   12225    868690096 :   if (TREE_CODE (t) == OPTIMIZATION_NODE)
   12226     98842980 :     return cl_optimization_hash (TREE_OPTIMIZATION (t));
   12227    769847116 :   else if (TREE_CODE (t) == TARGET_OPTION_NODE)
   12228    769847116 :     return cl_target_option_hash (TREE_TARGET_OPTION (t));
   12229              :   else
   12230            0 :     gcc_unreachable ();
   12231              : }
   12232              : 
   12233              : /* Return nonzero if the value represented by *X (an OPTIMIZATION or
   12234              :    TARGET_OPTION tree node) is the same as that given by *Y, which is the
   12235              :    same.  */
   12236              : 
   12237              : bool
   12238    933210588 : cl_option_hasher::equal (tree x, tree y)
   12239              : {
   12240    933210588 :   const_tree const xt = x;
   12241    933210588 :   const_tree const yt = y;
   12242              : 
   12243    933210588 :   if (TREE_CODE (xt) != TREE_CODE (yt))
   12244              :     return false;
   12245              : 
   12246    535275015 :   if (TREE_CODE (xt) == OPTIMIZATION_NODE)
   12247     97036247 :     return cl_optimization_option_eq (TREE_OPTIMIZATION (xt),
   12248     97036247 :                                       TREE_OPTIMIZATION (yt));
   12249    438238768 :   else if (TREE_CODE (xt) == TARGET_OPTION_NODE)
   12250    438238768 :     return cl_target_option_eq (TREE_TARGET_OPTION (xt),
   12251    438238768 :                                 TREE_TARGET_OPTION (yt));
   12252              :   else
   12253            0 :     gcc_unreachable ();
   12254              : }
   12255              : 
   12256              : /* Build an OPTIMIZATION_NODE based on the options in OPTS and OPTS_SET.  */
   12257              : 
   12258              : tree
   12259     97336805 : build_optimization_node (struct gcc_options *opts,
   12260              :                          struct gcc_options *opts_set)
   12261              : {
   12262     97336805 :   tree t;
   12263              : 
   12264              :   /* Use the cache of optimization nodes.  */
   12265              : 
   12266     97336805 :   cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node),
   12267              :                         opts, opts_set);
   12268              : 
   12269     97336805 :   tree *slot = cl_option_hash_table->find_slot (cl_optimization_node, INSERT);
   12270     97336805 :   t = *slot;
   12271     97336805 :   if (!t)
   12272              :     {
   12273              :       /* Insert this one into the hash table.  */
   12274       301044 :       t = cl_optimization_node;
   12275       301044 :       *slot = t;
   12276              : 
   12277              :       /* Make a new node for next time round.  */
   12278       301044 :       cl_optimization_node = make_node (OPTIMIZATION_NODE);
   12279              :     }
   12280              : 
   12281     97336805 :   return t;
   12282              : }
   12283              : 
   12284              : /* Build a TARGET_OPTION_NODE based on the options in OPTS and OPTS_SET.  */
   12285              : 
   12286              : tree
   12287     75427261 : build_target_option_node (struct gcc_options *opts,
   12288              :                           struct gcc_options *opts_set)
   12289              : {
   12290     75427261 :   tree t;
   12291              : 
   12292              :   /* Use the cache of optimization nodes.  */
   12293              : 
   12294     75427261 :   cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node),
   12295              :                          opts, opts_set);
   12296              : 
   12297     75427261 :   tree *slot = cl_option_hash_table->find_slot (cl_target_option_node, INSERT);
   12298     75427261 :   t = *slot;
   12299     75427261 :   if (!t)
   12300              :     {
   12301              :       /* Insert this one into the hash table.  */
   12302       785728 :       t = cl_target_option_node;
   12303       785728 :       *slot = t;
   12304              : 
   12305              :       /* Make a new node for next time round.  */
   12306       785728 :       cl_target_option_node = make_node (TARGET_OPTION_NODE);
   12307              :     }
   12308              : 
   12309     75427261 :   return t;
   12310              : }
   12311              : 
   12312              : /* Clear TREE_TARGET_GLOBALS of all TARGET_OPTION_NODE trees,
   12313              :    so that they aren't saved during PCH writing.  */
   12314              : 
   12315              : void
   12316          474 : prepare_target_option_nodes_for_pch (void)
   12317              : {
   12318          474 :   hash_table<cl_option_hasher>::iterator iter = cl_option_hash_table->begin ();
   12319         2844 :   for (; iter != cl_option_hash_table->end (); ++iter)
   12320          948 :     if (TREE_CODE (*iter) == TARGET_OPTION_NODE)
   12321          474 :       TREE_TARGET_GLOBALS (*iter) = NULL;
   12322          474 : }
   12323              : 
   12324              : /* Determine the "ultimate origin" of a block.  */
   12325              : 
   12326              : tree
   12327    210749128 : block_ultimate_origin (const_tree block)
   12328              : {
   12329    210749128 :   tree origin = BLOCK_ABSTRACT_ORIGIN (block);
   12330              : 
   12331    210749128 :   if (origin == NULL_TREE)
   12332              :     return NULL_TREE;
   12333              :   else
   12334              :     {
   12335    252561496 :       gcc_checking_assert ((DECL_P (origin)
   12336              :                             && DECL_ORIGIN (origin) == origin)
   12337              :                            || BLOCK_ORIGIN (origin) == origin);
   12338              :       return origin;
   12339              :     }
   12340              : }
   12341              : 
   12342              : /* Return true iff conversion from INNER_TYPE to OUTER_TYPE generates
   12343              :    no instruction.  */
   12344              : 
   12345              : bool
   12346   1622825065 : tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
   12347              : {
   12348   1622825065 :   if (!inner_type || inner_type == error_mark_node)
   12349              :     return false;
   12350              : 
   12351              :   /* Do not strip casts into or out of differing address spaces.  */
   12352   1622788529 :   if (POINTER_TYPE_P (outer_type)
   12353   1622788529 :       && TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != ADDR_SPACE_GENERIC)
   12354              :     {
   12355          302 :       if (!POINTER_TYPE_P (inner_type)
   12356          302 :           || (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
   12357          268 :               != TYPE_ADDR_SPACE (TREE_TYPE (inner_type))))
   12358              :         return false;
   12359              :     }
   12360   1622788227 :   else if (POINTER_TYPE_P (inner_type)
   12361   1622788227 :            && TYPE_ADDR_SPACE (TREE_TYPE (inner_type)) != ADDR_SPACE_GENERIC)
   12362              :     {
   12363              :       /* We already know that outer_type is not a pointer with
   12364              :          a non-generic address space.  */
   12365              :       return false;
   12366              :     }
   12367              : 
   12368              :   /* Use precision rather then machine mode when we can, which gives
   12369              :      the correct answer even for submode (bit-field) types.  */
   12370   1622785949 :   if ((INTEGRAL_TYPE_P (outer_type)
   12371    674484433 :        || POINTER_TYPE_P (outer_type)
   12372     70546562 :        || TREE_CODE (outer_type) == OFFSET_TYPE)
   12373   1552251014 :       && (INTEGRAL_TYPE_P (inner_type)
   12374    683515815 :           || POINTER_TYPE_P (inner_type)
   12375      1687581 :           || TREE_CODE (inner_type) == OFFSET_TYPE))
   12376   1550587200 :     return TYPE_PRECISION (outer_type) == TYPE_PRECISION (inner_type);
   12377              : 
   12378              :   /* Otherwise fall back on comparing machine modes (e.g. for
   12379              :      aggregate types, floats).  */
   12380     72198749 :   return TYPE_MODE (outer_type) == TYPE_MODE (inner_type);
   12381              : }
   12382              : 
   12383              : /* Return true iff conversion in EXP generates no instruction.  Mark
   12384              :    it inline so that we fully inline into the stripping functions even
   12385              :    though we have two uses of this function.  */
   12386              : 
   12387              : static inline bool
   12388  19987296588 : tree_nop_conversion (const_tree exp)
   12389              : {
   12390  19987296588 :   tree outer_type, inner_type;
   12391              : 
   12392  19987296588 :   if (location_wrapper_p (exp))
   12393              :     return true;
   12394  19924218081 :   if (!CONVERT_EXPR_P (exp)
   12395  18917304633 :       && TREE_CODE (exp) != NON_LVALUE_EXPR)
   12396              :     return false;
   12397              : 
   12398   1022059353 :   outer_type = TREE_TYPE (exp);
   12399   1022059353 :   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
   12400              : 
   12401   1022059353 :   return tree_nop_conversion_p (outer_type, inner_type);
   12402              : }
   12403              : 
   12404              : /* Return true iff conversion in EXP generates no instruction.  Don't
   12405              :    consider conversions changing the signedness.  */
   12406              : 
   12407              : static bool
   12408   2210971641 : tree_sign_nop_conversion (const_tree exp)
   12409              : {
   12410   2210971641 :   tree outer_type, inner_type;
   12411              : 
   12412   2210971641 :   if (!tree_nop_conversion (exp))
   12413              :     return false;
   12414              : 
   12415    210248841 :   outer_type = TREE_TYPE (exp);
   12416    210248841 :   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
   12417              : 
   12418    210248841 :   return (TYPE_UNSIGNED (outer_type) == TYPE_UNSIGNED (inner_type)
   12419    210248841 :           && POINTER_TYPE_P (outer_type) == POINTER_TYPE_P (inner_type));
   12420              : }
   12421              : 
   12422              : /* Strip conversions from EXP according to tree_nop_conversion and
   12423              :    return the resulting expression.  */
   12424              : 
   12425              : tree
   12426  17060283806 : tree_strip_nop_conversions (tree exp)
   12427              : {
   12428  17776324947 :   while (tree_nop_conversion (exp))
   12429    716041141 :     exp = TREE_OPERAND (exp, 0);
   12430  17060283806 :   return exp;
   12431              : }
   12432              : 
   12433              : /* Strip conversions from EXP according to tree_sign_nop_conversion
   12434              :    and return the resulting expression.  */
   12435              : 
   12436              : tree
   12437   2023078566 : tree_strip_sign_nop_conversions (tree exp)
   12438              : {
   12439   2210971641 :   while (tree_sign_nop_conversion (exp))
   12440    187893075 :     exp = TREE_OPERAND (exp, 0);
   12441   2023078566 :   return exp;
   12442              : }
   12443              : 
   12444              : /* Avoid any floating point extensions from EXP.  */
   12445              : tree
   12446     92610598 : strip_float_extensions (tree exp)
   12447              : {
   12448     92714211 :   tree sub, expt, subt;
   12449              : 
   12450              :   /*  For floating point constant look up the narrowest type that can hold
   12451              :       it properly and handle it like (type)(narrowest_type)constant.
   12452              :       This way we can optimize for instance a=a*2.0 where "a" is float
   12453              :       but 2.0 is double constant.  */
   12454     92714211 :   if (TREE_CODE (exp) == REAL_CST && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (exp)))
   12455              :     {
   12456      1966556 :       REAL_VALUE_TYPE orig;
   12457      1966556 :       tree type = NULL;
   12458              : 
   12459      1966556 :       orig = TREE_REAL_CST (exp);
   12460      1966556 :       if (TYPE_PRECISION (TREE_TYPE (exp)) > TYPE_PRECISION (float_type_node)
   12461      1966556 :           && exact_real_truncate (TYPE_MODE (float_type_node), &orig))
   12462       140654 :         type = float_type_node;
   12463      1825902 :       else if (TYPE_PRECISION (TREE_TYPE (exp))
   12464      1825902 :                > TYPE_PRECISION (double_type_node)
   12465      1825902 :                && exact_real_truncate (TYPE_MODE (double_type_node), &orig))
   12466        34591 :         type = double_type_node;
   12467      1966556 :       if (type)
   12468       175245 :         return build_real_truncate (type, orig);
   12469              :     }
   12470              : 
   12471     92538966 :   if (!CONVERT_EXPR_P (exp))
   12472              :     return exp;
   12473              : 
   12474      5277408 :   sub = TREE_OPERAND (exp, 0);
   12475      5277408 :   subt = TREE_TYPE (sub);
   12476      5277408 :   expt = TREE_TYPE (exp);
   12477              : 
   12478      5277408 :   if (!FLOAT_TYPE_P (subt))
   12479              :     return exp;
   12480              : 
   12481       379981 :   if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt))
   12482              :     return exp;
   12483              : 
   12484       127025 :   if (element_precision (subt) > element_precision (expt))
   12485              :     return exp;
   12486              : 
   12487              :   return strip_float_extensions (sub);
   12488              : }
   12489              : 
   12490              : /* Strip out all handled components that produce invariant
   12491              :    offsets.  */
   12492              : 
   12493              : const_tree
   12494   5735365604 : strip_invariant_refs (const_tree op)
   12495              : {
   12496   6666917597 :   while (handled_component_p (op))
   12497              :     {
   12498    943759708 :       switch (TREE_CODE (op))
   12499              :         {
   12500    189198294 :         case ARRAY_REF:
   12501    189198294 :         case ARRAY_RANGE_REF:
   12502    189198294 :           if (!is_gimple_constant (TREE_OPERAND (op, 1))
   12503    178691504 :               || TREE_OPERAND (op, 2) != NULL_TREE
   12504    177123120 :               || TREE_OPERAND (op, 3) != NULL_TREE)
   12505              :             return NULL;
   12506              :           break;
   12507              : 
   12508    753710695 :         case COMPONENT_REF:
   12509    753710695 :           if (TREE_OPERAND (op, 2) != NULL_TREE)
   12510              :             return NULL;
   12511              :           break;
   12512              : 
   12513    931551993 :         default:;
   12514              :         }
   12515    931551993 :       op = TREE_OPERAND (op, 0);
   12516              :     }
   12517              : 
   12518              :   return op;
   12519              : }
   12520              : 
   12521              : /* Strip handled components with zero offset from OP.  */
   12522              : 
   12523              : tree
   12524       568625 : strip_zero_offset_components (tree op)
   12525              : {
   12526       568625 :   while (TREE_CODE (op) == COMPONENT_REF
   12527       429190 :          && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (op, 1)))
   12528      1108381 :          && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (op, 1))))
   12529       176647 :     op = TREE_OPERAND (op, 0);
   12530       568625 :   return op;
   12531              : }
   12532              : 
   12533              : static GTY(()) tree gcc_eh_personality_decl;
   12534              : 
   12535              : /* Return the GCC personality function decl.  */
   12536              : 
   12537              : tree
   12538          406 : lhd_gcc_personality (void)
   12539              : {
   12540          406 :   if (!gcc_eh_personality_decl)
   12541          160 :     gcc_eh_personality_decl = build_personality_function ("gcc");
   12542          406 :   return gcc_eh_personality_decl;
   12543              : }
   12544              : 
   12545              : /* TARGET is a call target of GIMPLE call statement
   12546              :    (obtained by gimple_call_fn).  Return true if it is
   12547              :    OBJ_TYPE_REF representing an virtual call of C++ method.
   12548              :    (As opposed to OBJ_TYPE_REF representing objc calls
   12549              :    through a cast where middle-end devirtualization machinery
   12550              :    can't apply.)  FOR_DUMP_P is true when being called from
   12551              :    the dump routines.  */
   12552              : 
   12553              : bool
   12554     27581276 : virtual_method_call_p (const_tree target, bool for_dump_p)
   12555              : {
   12556     27581276 :   if (TREE_CODE (target) != OBJ_TYPE_REF)
   12557              :     return false;
   12558      1224221 :   tree t = TREE_TYPE (target);
   12559      1224221 :   gcc_checking_assert (TREE_CODE (t) == POINTER_TYPE);
   12560      1224221 :   t = TREE_TYPE (t);
   12561      1224221 :   if (TREE_CODE (t) == FUNCTION_TYPE)
   12562              :     return false;
   12563      1223133 :   gcc_checking_assert (TREE_CODE (t) == METHOD_TYPE);
   12564              :   /* If we do not have BINFO associated, it means that type was built
   12565              :      without devirtualization enabled.  Do not consider this a virtual
   12566              :      call.  */
   12567      1223133 :   if (!TYPE_BINFO (obj_type_ref_class (target, for_dump_p)))
   12568              :     return false;
   12569              :   return true;
   12570              : }
   12571              : 
   12572              : /* Lookup sub-BINFO of BINFO of TYPE at offset POS.  */
   12573              : 
   12574              : static tree
   12575          108 : lookup_binfo_at_offset (tree binfo, tree type, HOST_WIDE_INT pos)
   12576              : {
   12577          108 :   unsigned int i;
   12578          108 :   tree base_binfo, b;
   12579              : 
   12580          124 :   for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
   12581          108 :     if (pos == tree_to_shwi (BINFO_OFFSET (base_binfo))
   12582          108 :         && types_same_for_odr (TREE_TYPE (base_binfo), type))
   12583              :       return base_binfo;
   12584           70 :     else if ((b = lookup_binfo_at_offset (base_binfo, type, pos)) != NULL)
   12585              :       return b;
   12586              :   return NULL;
   12587              : }
   12588              : 
   12589              : /* Try to find a base info of BINFO that would have its field decl at offset
   12590              :    OFFSET within the BINFO type and which is of EXPECTED_TYPE.  If it can be
   12591              :    found, return, otherwise return NULL_TREE.  */
   12592              : 
   12593              : tree
   12594       277777 : get_binfo_at_offset (tree binfo, poly_int64 offset, tree expected_type)
   12595              : {
   12596       277777 :   tree type = BINFO_TYPE (binfo);
   12597              : 
   12598       743007 :   while (true)
   12599              :     {
   12600       510392 :       HOST_WIDE_INT pos, size;
   12601       510392 :       tree fld;
   12602       510392 :       int i;
   12603              : 
   12604       510392 :       if (types_same_for_odr (type, expected_type))
   12605       277777 :           return binfo;
   12606       232615 :       if (maybe_lt (offset, 0))
   12607              :         return NULL_TREE;
   12608              : 
   12609      1175788 :       for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
   12610              :         {
   12611      1175788 :           if (TREE_CODE (fld) != FIELD_DECL || !DECL_ARTIFICIAL (fld))
   12612       942976 :             continue;
   12613              : 
   12614       232812 :           pos = int_bit_position (fld);
   12615       232812 :           size = tree_to_uhwi (DECL_SIZE (fld));
   12616      1175985 :           if (known_in_range_p (offset, pos, size))
   12617              :             break;
   12618              :         }
   12619       232615 :       if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE)
   12620              :         return NULL_TREE;
   12621              : 
   12622              :       /* Offset 0 indicates the primary base, whose vtable contents are
   12623              :          represented in the binfo for the derived class.  */
   12624       232615 :       else if (maybe_ne (offset, 0))
   12625              :         {
   12626          197 :           tree found_binfo = NULL, base_binfo;
   12627              :           /* Offsets in BINFO are in bytes relative to the whole structure
   12628              :              while POS is in bits relative to the containing field.  */
   12629          197 :           int binfo_offset = (tree_to_shwi (BINFO_OFFSET (binfo)) + pos
   12630          197 :                              / BITS_PER_UNIT);
   12631              : 
   12632          377 :           for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
   12633          339 :             if (tree_to_shwi (BINFO_OFFSET (base_binfo)) == binfo_offset
   12634          339 :                 && types_same_for_odr (TREE_TYPE (base_binfo), TREE_TYPE (fld)))
   12635              :               {
   12636              :                 found_binfo = base_binfo;
   12637              :                 break;
   12638              :               }
   12639          197 :           if (found_binfo)
   12640              :             binfo = found_binfo;
   12641              :           else
   12642           38 :             binfo = lookup_binfo_at_offset (binfo, TREE_TYPE (fld),
   12643              :                                             binfo_offset);
   12644              :          }
   12645              : 
   12646       232615 :       type = TREE_TYPE (fld);
   12647       232615 :       offset -= pos;
   12648       232615 :     }
   12649              : }
   12650              : 
   12651              : /* PR 84195: Replace control characters in "unescaped" with their
   12652              :    escaped equivalents.  Allow newlines if -fmessage-length has
   12653              :    been set to a non-zero value.  This is done here, rather than
   12654              :    where the attribute is recorded as the message length can
   12655              :    change between these two locations.  */
   12656              : 
   12657              : void
   12658       129382 : escaped_string::escape (const char *unescaped)
   12659              : {
   12660       129382 :   char *escaped;
   12661       129382 :   size_t i, new_i, len;
   12662              : 
   12663       129382 :   if (m_owned)
   12664            8 :     free (m_str);
   12665              : 
   12666       129382 :   m_str = const_cast<char *> (unescaped);
   12667       129382 :   m_owned = false;
   12668              : 
   12669       129382 :   if (unescaped == NULL || *unescaped == 0)
   12670              :     return;
   12671              : 
   12672       129374 :   len = strlen (unescaped);
   12673       129374 :   escaped = NULL;
   12674       129374 :   new_i = 0;
   12675              : 
   12676      3755208 :   for (i = 0; i < len; i++)
   12677              :     {
   12678      3625834 :       char c = unescaped[i];
   12679              : 
   12680      3625834 :       if (!ISCNTRL (c))
   12681              :         {
   12682      3625749 :           if (escaped)
   12683           33 :             escaped[new_i++] = c;
   12684      3625749 :           continue;
   12685              :         }
   12686              : 
   12687           85 :       if (c != '\n' || !pp_is_wrapping_line (global_dc->get_reference_printer ()))
   12688              :         {
   12689           77 :           if (escaped == NULL)
   12690              :             {
   12691              :               /* We only allocate space for a new string if we
   12692              :                  actually encounter a control character that
   12693              :                  needs replacing.  */
   12694           19 :               escaped = (char *) xmalloc (len * 2 + 1);
   12695           19 :               strncpy (escaped, unescaped, i);
   12696           19 :               new_i = i;
   12697              :             }
   12698              : 
   12699           77 :           escaped[new_i++] = '\\';
   12700              : 
   12701           77 :           switch (c)
   12702              :             {
   12703            8 :             case '\a': escaped[new_i++] = 'a'; break;
   12704            8 :             case '\b': escaped[new_i++] = 'b'; break;
   12705            8 :             case '\f': escaped[new_i++] = 'f'; break;
   12706           15 :             case '\n': escaped[new_i++] = 'n'; break;
   12707           15 :             case '\r': escaped[new_i++] = 'r'; break;
   12708           15 :             case '\t': escaped[new_i++] = 't'; break;
   12709            8 :             case '\v': escaped[new_i++] = 'v'; break;
   12710            0 :             default:   escaped[new_i++] = '?'; break;
   12711              :             }
   12712              :         }
   12713            8 :       else if (escaped)
   12714            4 :         escaped[new_i++] = c;
   12715              :     }
   12716              : 
   12717       129374 :   if (escaped)
   12718              :     {
   12719           19 :       escaped[new_i] = 0;
   12720           19 :       m_str = escaped;
   12721           19 :       m_owned = true;
   12722              :     }
   12723              : }
   12724              : 
   12725              : /* Warn about a use of an identifier which was marked deprecated.  Returns
   12726              :    whether a warning was given.  */
   12727              : 
   12728              : bool
   12729      1326665 : warn_deprecated_use (tree node, tree attr)
   12730              : {
   12731      1326665 :   escaped_string msg;
   12732              : 
   12733      1326665 :   if (node == 0 || !warn_deprecated_decl)
   12734              :     return false;
   12735              : 
   12736      1319426 :   if (!attr)
   12737              :     {
   12738      1209892 :       if (DECL_P (node))
   12739      1209728 :         attr = DECL_ATTRIBUTES (node);
   12740          164 :       else if (TYPE_P (node))
   12741              :         {
   12742          164 :           tree decl = TYPE_STUB_DECL (node);
   12743          164 :           if (decl)
   12744          140 :             attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
   12745           24 :           else if ((decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)))
   12746              :                    != NULL_TREE)
   12747              :             {
   12748            6 :               node = TREE_TYPE (decl);
   12749            6 :               attr = TYPE_ATTRIBUTES (node);
   12750              :             }
   12751              :         }
   12752              :     }
   12753              : 
   12754      1209892 :   if (attr)
   12755       129052 :     attr = lookup_attribute ("deprecated", attr);
   12756              : 
   12757       129052 :   if (attr)
   12758       129041 :     msg.escape (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   12759              : 
   12760      1319426 :   bool w = false;
   12761      1319426 :   if (DECL_P (node))
   12762              :     {
   12763      1319252 :       auto_diagnostic_group d;
   12764      1319252 :       if (msg)
   12765       128956 :         w = warning (OPT_Wdeprecated_declarations,
   12766              :                      "%qD is deprecated: %s", node, (const char *) msg);
   12767              :       else
   12768      1190296 :         w = warning (OPT_Wdeprecated_declarations,
   12769              :                      "%qD is deprecated", node);
   12770      1319252 :       if (w)
   12771          798 :         inform (DECL_SOURCE_LOCATION (node), "declared here");
   12772      1319252 :     }
   12773          174 :   else if (TYPE_P (node))
   12774              :     {
   12775          174 :       tree what = NULL_TREE;
   12776          174 :       tree decl = TYPE_STUB_DECL (node);
   12777              : 
   12778          174 :       if (TYPE_NAME (node))
   12779              :         {
   12780          169 :           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
   12781           10 :             what = TYPE_NAME (node);
   12782          159 :           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
   12783          159 :                    && DECL_NAME (TYPE_NAME (node)))
   12784          159 :             what = DECL_NAME (TYPE_NAME (node));
   12785              :         }
   12786              : 
   12787          174 :       auto_diagnostic_group d;
   12788          174 :       if (what)
   12789              :         {
   12790          169 :           if (msg)
   12791           83 :             w = warning (OPT_Wdeprecated_declarations,
   12792              :                          "%qE is deprecated: %s", what, (const char *) msg);
   12793              :           else
   12794           86 :             w = warning (OPT_Wdeprecated_declarations,
   12795              :                          "%qE is deprecated", what);
   12796              :         }
   12797              :       else
   12798              :         {
   12799            5 :           if (msg)
   12800            2 :             w = warning (OPT_Wdeprecated_declarations,
   12801              :                          "type is deprecated: %s", (const char *) msg);
   12802              :           else
   12803            3 :             w = warning (OPT_Wdeprecated_declarations,
   12804              :                          "type is deprecated");
   12805              :         }
   12806              : 
   12807          174 :       if (w && decl)
   12808          111 :         inform (DECL_SOURCE_LOCATION (decl), "declared here");
   12809          174 :     }
   12810              : 
   12811              :   return w;
   12812      1326665 : }
   12813              : 
   12814              : /* Error out with an identifier which was marked 'unavailable'. */
   12815              : void
   12816          376 : error_unavailable_use (tree node, tree attr)
   12817              : {
   12818          376 :   escaped_string msg;
   12819              : 
   12820          376 :   if (node == 0)
   12821            0 :     return;
   12822              : 
   12823          376 :   if (!attr)
   12824              :     {
   12825          366 :       if (DECL_P (node))
   12826          306 :         attr = DECL_ATTRIBUTES (node);
   12827           60 :       else if (TYPE_P (node))
   12828              :         {
   12829           60 :           tree decl = TYPE_STUB_DECL (node);
   12830           60 :           if (decl)
   12831           51 :             attr = lookup_attribute ("unavailable",
   12832           51 :                                      TYPE_ATTRIBUTES (TREE_TYPE (decl)));
   12833              :         }
   12834              :     }
   12835              : 
   12836          366 :   if (attr)
   12837          164 :     attr = lookup_attribute ("unavailable", attr);
   12838              : 
   12839          164 :   if (attr)
   12840          164 :     msg.escape (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   12841              : 
   12842          376 :   if (DECL_P (node))
   12843              :     {
   12844          306 :       auto_diagnostic_group d;
   12845          306 :       if (msg)
   12846          129 :         error ("%qD is unavailable: %s", node, (const char *) msg);
   12847              :       else
   12848          177 :         error ("%qD is unavailable", node);
   12849          306 :       inform (DECL_SOURCE_LOCATION (node), "declared here");
   12850          306 :     }
   12851           70 :   else if (TYPE_P (node))
   12852              :     {
   12853           70 :       tree what = NULL_TREE;
   12854           70 :       tree decl = TYPE_STUB_DECL (node);
   12855              : 
   12856           70 :       if (TYPE_NAME (node))
   12857              :         {
   12858           66 :           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
   12859            4 :             what = TYPE_NAME (node);
   12860           62 :           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
   12861           62 :                    && DECL_NAME (TYPE_NAME (node)))
   12862           62 :             what = DECL_NAME (TYPE_NAME (node));
   12863              :         }
   12864              : 
   12865           70 :       auto_diagnostic_group d;
   12866           70 :       if (what)
   12867              :         {
   12868           66 :           if (msg)
   12869           33 :             error ("%qE is unavailable: %s", what, (const char *) msg);
   12870              :           else
   12871           33 :             error ("%qE is unavailable", what);
   12872              :         }
   12873              :       else
   12874              :         {
   12875            4 :           if (msg)
   12876            2 :             error ("type is unavailable: %s", (const char *) msg);
   12877              :           else
   12878            2 :             error ("type is unavailable");
   12879              :         }
   12880              : 
   12881           70 :       if (decl)
   12882           52 :         inform (DECL_SOURCE_LOCATION (decl), "declared here");
   12883           70 :     }
   12884          376 : }
   12885              : 
   12886              : /* Return true if REF has a COMPONENT_REF with a bit-field field declaration
   12887              :    somewhere in it.  */
   12888              : 
   12889              : bool
   12890      5551960 : contains_bitfld_component_ref_p (const_tree ref)
   12891              : {
   12892     11375603 :   while (handled_component_p (ref))
   12893              :     {
   12894      5839837 :       if (TREE_CODE (ref) == COMPONENT_REF
   12895      5839837 :           && DECL_BIT_FIELD (TREE_OPERAND (ref, 1)))
   12896              :         return true;
   12897      5823643 :       ref = TREE_OPERAND (ref, 0);
   12898              :     }
   12899              : 
   12900              :   return false;
   12901              : }
   12902              : 
   12903              : /* Try to determine whether a TRY_CATCH expression can fall through.
   12904              :    This is a subroutine of block_may_fallthru.  */
   12905              : 
   12906              : static bool
   12907            1 : try_catch_may_fallthru (const_tree stmt)
   12908              : {
   12909            1 :   tree_stmt_iterator i;
   12910              : 
   12911              :   /* If the TRY block can fall through, the whole TRY_CATCH can
   12912              :      fall through.  */
   12913            1 :   if (block_may_fallthru (TREE_OPERAND (stmt, 0)))
   12914              :     return true;
   12915              : 
   12916            1 :   switch (TREE_CODE (TREE_OPERAND (stmt, 1)))
   12917              :     {
   12918            0 :     case CATCH_EXPR:
   12919              :       /* See below.  */
   12920            0 :       return block_may_fallthru (CATCH_BODY (TREE_OPERAND (stmt, 1)));
   12921              : 
   12922            0 :     case EH_FILTER_EXPR:
   12923              :       /* See below.  */
   12924            0 :       return block_may_fallthru (EH_FILTER_FAILURE (TREE_OPERAND (stmt, 1)));
   12925              : 
   12926            0 :     case STATEMENT_LIST:
   12927            0 :       break;
   12928              : 
   12929              :     default:
   12930              :       /* See below.  */
   12931              :       return false;
   12932              :     }
   12933              : 
   12934            0 :   i = tsi_start (TREE_OPERAND (stmt, 1));
   12935            0 :   switch (TREE_CODE (tsi_stmt (i)))
   12936              :     {
   12937              :     case CATCH_EXPR:
   12938              :       /* We expect to see a sequence of CATCH_EXPR trees, each with a
   12939              :          catch expression and a body.  The whole TRY_CATCH may fall
   12940              :          through iff any of the catch bodies falls through.  */
   12941            0 :       for (; !tsi_end_p (i); tsi_next (&i))
   12942              :         {
   12943            0 :           if (block_may_fallthru (CATCH_BODY (tsi_stmt (i))))
   12944              :             return true;
   12945              :         }
   12946              :       return false;
   12947              : 
   12948            0 :     case EH_FILTER_EXPR:
   12949              :       /* The exception filter expression only matters if there is an
   12950              :          exception.  If the exception does not match EH_FILTER_TYPES,
   12951              :          we will execute EH_FILTER_FAILURE, and we will fall through
   12952              :          if that falls through.  If the exception does match
   12953              :          EH_FILTER_TYPES, the stack unwinder will continue up the
   12954              :          stack, so we will not fall through.  We don't know whether we
   12955              :          will throw an exception which matches EH_FILTER_TYPES or not,
   12956              :          so we just ignore EH_FILTER_TYPES and assume that we might
   12957              :          throw an exception which doesn't match.  */
   12958            0 :       return block_may_fallthru (EH_FILTER_FAILURE (tsi_stmt (i)));
   12959              : 
   12960              :     default:
   12961              :       /* This case represents statements to be executed when an
   12962              :          exception occurs.  Those statements are implicitly followed
   12963              :          by a RESX statement to resume execution after the exception.
   12964              :          So in this case the TRY_CATCH never falls through.  */
   12965              :       return false;
   12966              :     }
   12967              : }
   12968              : 
   12969              : /* Try to determine if we can fall out of the bottom of BLOCK.  This guess
   12970              :    need not be 100% accurate; simply be conservative and return true if we
   12971              :    don't know.  This is used only to avoid stupidly generating extra code.
   12972              :    If we're wrong, we'll just delete the extra code later.  */
   12973              : 
   12974              : bool
   12975      8812652 : block_may_fallthru (const_tree block)
   12976              : {
   12977              :   /* This CONST_CAST is okay because expr_last returns its argument
   12978              :      unmodified and we assign it to a const_tree.  */
   12979     10146193 :   const_tree stmt = expr_last (const_cast<tree> (block));
   12980              : 
   12981     10146193 :   switch (stmt ? TREE_CODE (stmt) : ERROR_MARK)
   12982              :     {
   12983              :     case GOTO_EXPR:
   12984              :     case RETURN_EXPR:
   12985              :       /* Easy cases.  If the last statement of the block implies
   12986              :          control transfer, then we can't fall through.  */
   12987              :       return false;
   12988              : 
   12989           10 :     case SWITCH_EXPR:
   12990              :       /* If there is a default: label or case labels cover all possible
   12991              :          SWITCH_COND values, then the SWITCH_EXPR will transfer control
   12992              :          to some case label in all cases and all we care is whether the
   12993              :          SWITCH_BODY falls through.  */
   12994           10 :       if (SWITCH_ALL_CASES_P (stmt))
   12995            9 :         return block_may_fallthru (SWITCH_BODY (stmt));
   12996              :       return true;
   12997              : 
   12998        21401 :     case COND_EXPR:
   12999        21401 :       if (block_may_fallthru (COND_EXPR_THEN (stmt)))
   13000              :         return true;
   13001         2827 :       return block_may_fallthru (COND_EXPR_ELSE (stmt));
   13002              : 
   13003       871083 :     case BIND_EXPR:
   13004       871083 :       return block_may_fallthru (BIND_EXPR_BODY (stmt));
   13005              : 
   13006            1 :     case TRY_CATCH_EXPR:
   13007            1 :       return try_catch_may_fallthru (stmt);
   13008              : 
   13009         1766 :     case TRY_FINALLY_EXPR:
   13010              :       /* The finally clause is always executed after the try clause,
   13011              :          so if it does not fall through, then the try-finally will not
   13012              :          fall through.  Otherwise, if the try clause does not fall
   13013              :          through, then when the finally clause falls through it will
   13014              :          resume execution wherever the try clause was going.  So the
   13015              :          whole try-finally will only fall through if both the try
   13016              :          clause and the finally clause fall through.  */
   13017         1766 :       return (block_may_fallthru (TREE_OPERAND (stmt, 0))
   13018         1766 :               && block_may_fallthru (TREE_OPERAND (stmt, 1)));
   13019              : 
   13020            0 :     case EH_ELSE_EXPR:
   13021            0 :       return block_may_fallthru (TREE_OPERAND (stmt, 0));
   13022              : 
   13023        91644 :     case MODIFY_EXPR:
   13024        91644 :       if (TREE_CODE (TREE_OPERAND (stmt, 1)) == CALL_EXPR)
   13025         1580 :         stmt = TREE_OPERAND (stmt, 1);
   13026              :       else
   13027              :         return true;
   13028              :       /* FALLTHRU */
   13029              : 
   13030       430003 :     case CALL_EXPR:
   13031              :       /* Functions that do not return do not fall through.  */
   13032       430003 :       return (call_expr_flags (stmt) & ECF_NORETURN) == 0;
   13033              : 
   13034       459612 :     case CLEANUP_POINT_EXPR:
   13035       459612 :       return block_may_fallthru (TREE_OPERAND (stmt, 0));
   13036              : 
   13037           10 :     case TARGET_EXPR:
   13038           10 :       return block_may_fallthru (TREE_OPERAND (stmt, 1));
   13039              : 
   13040              :     case ERROR_MARK:
   13041              :       return true;
   13042              : 
   13043      6124130 :     default:
   13044      6124130 :       return lang_hooks.block_may_fallthru (stmt);
   13045              :     }
   13046              : }
   13047              : 
   13048              : /* True if we are using EH to handle cleanups.  */
   13049              : static bool using_eh_for_cleanups_flag = false;
   13050              : 
   13051              : /* This routine is called from front ends to indicate eh should be used for
   13052              :    cleanups.  */
   13053              : void
   13054       124688 : using_eh_for_cleanups (void)
   13055              : {
   13056       124688 :   using_eh_for_cleanups_flag = true;
   13057       124688 : }
   13058              : 
   13059              : /* Query whether EH is used for cleanups.  */
   13060              : bool
   13061      1625512 : using_eh_for_cleanups_p (void)
   13062              : {
   13063      1625512 :   return using_eh_for_cleanups_flag;
   13064              : }
   13065              : 
   13066              : /* Wrapper for tree_code_name to ensure that tree code is valid */
   13067              : const char *
   13068  14160389533 : get_tree_code_name (enum tree_code code)
   13069              : {
   13070  14160389533 :   const char *invalid = "<invalid tree code>";
   13071              : 
   13072              :   /* The tree_code enum promotes to signed, but we could be getting
   13073              :      invalid values, so force an unsigned comparison.  */
   13074  14160389533 :   if (unsigned (code) >= MAX_TREE_CODES)
   13075              :     {
   13076            0 :       if ((unsigned)code == 0xa5a5)
   13077              :         return "ggc_freed";
   13078            0 :       return invalid;
   13079              :     }
   13080              : 
   13081  14160389533 :   return tree_code_name[code];
   13082              : }
   13083              : 
   13084              : /* Drops the TREE_OVERFLOW flag from T.  */
   13085              : 
   13086              : tree
   13087        35220 : drop_tree_overflow (tree t)
   13088              : {
   13089        35220 :   gcc_checking_assert (TREE_OVERFLOW (t));
   13090              : 
   13091              :   /* For tree codes with a sharing machinery re-build the result.  */
   13092        35220 :   if (poly_int_tree_p (t))
   13093        35208 :     return wide_int_to_tree (TREE_TYPE (t), wi::to_poly_wide (t));
   13094              : 
   13095              :   /* For VECTOR_CST, remove the overflow bits from the encoded elements
   13096              :      and canonicalize the result.  */
   13097           12 :   if (TREE_CODE (t) == VECTOR_CST)
   13098              :     {
   13099            0 :       tree_vector_builder builder;
   13100            0 :       builder.new_unary_operation (TREE_TYPE (t), t, true);
   13101            0 :       unsigned int count = builder.encoded_nelts ();
   13102            0 :       for (unsigned int i = 0; i < count; ++i)
   13103              :         {
   13104            0 :           tree elt = VECTOR_CST_ELT (t, i);
   13105            0 :           if (TREE_OVERFLOW (elt))
   13106            0 :             elt = drop_tree_overflow (elt);
   13107            0 :           builder.quick_push (elt);
   13108              :         }
   13109            0 :       return builder.build ();
   13110            0 :     }
   13111              : 
   13112              :   /* Otherwise, as all tcc_constants are possibly shared, copy the node
   13113              :      and drop the flag.  */
   13114           12 :   t = copy_node (t);
   13115           12 :   TREE_OVERFLOW (t) = 0;
   13116              : 
   13117              :   /* For constants that contain nested constants, drop the flag
   13118              :      from those as well.  */
   13119           12 :   if (TREE_CODE (t) == COMPLEX_CST)
   13120              :     {
   13121           12 :       if (TREE_OVERFLOW (TREE_REALPART (t)))
   13122           12 :         TREE_REALPART (t) = drop_tree_overflow (TREE_REALPART (t));
   13123           12 :       if (TREE_OVERFLOW (TREE_IMAGPART (t)))
   13124            0 :         TREE_IMAGPART (t) = drop_tree_overflow (TREE_IMAGPART (t));
   13125              :     }
   13126              : 
   13127              :   return t;
   13128              : }
   13129              : 
   13130              : /* Given a memory reference expression T, return its base address.
   13131              :    The base address of a memory reference expression is the main
   13132              :    object being referenced.  For instance, the base address for
   13133              :    'array[i].fld[j]' is 'array'.  You can think of this as stripping
   13134              :    away the offset part from a memory address.
   13135              : 
   13136              :    This function calls handled_component_p to strip away all the inner
   13137              :    parts of the memory reference until it reaches the base object.  */
   13138              : 
   13139              : tree
   13140   3143379992 : get_base_address (tree t)
   13141              : {
   13142   3143379992 :   if (TREE_CODE (t) == WITH_SIZE_EXPR)
   13143          899 :     t = TREE_OPERAND (t, 0);
   13144   3909747952 :   while (handled_component_p (t))
   13145    766367960 :     t = TREE_OPERAND (t, 0);
   13146              : 
   13147   3143379992 :   if ((TREE_CODE (t) == MEM_REF
   13148   3143379992 :        || TREE_CODE (t) == TARGET_MEM_REF)
   13149   3143379992 :       && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
   13150    141708565 :     t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
   13151              : 
   13152   3143379992 :   return t;
   13153              : }
   13154              : 
   13155              : /* Return a tree of sizetype representing the size, in bytes, of the element
   13156              :    of EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13157              : 
   13158              : tree
   13159    785685292 : array_ref_element_size (tree exp)
   13160              : {
   13161    785685292 :   tree aligned_size = TREE_OPERAND (exp, 3);
   13162    785685292 :   tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13163    785685292 :   location_t loc = EXPR_LOCATION (exp);
   13164              : 
   13165              :   /* If a size was specified in the ARRAY_REF, it's the size measured
   13166              :      in alignment units of the element type.  So multiply by that value.  */
   13167    785685292 :   if (aligned_size)
   13168              :     {
   13169              :       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
   13170              :          sizetype from another type of the same width and signedness.  */
   13171       389335 :       if (TREE_TYPE (aligned_size) != sizetype)
   13172         3039 :         aligned_size = fold_convert_loc (loc, sizetype, aligned_size);
   13173       389335 :       return size_binop_loc (loc, MULT_EXPR, aligned_size,
   13174       389335 :                              size_int (TYPE_ALIGN_UNIT (elmt_type)));
   13175              :     }
   13176              : 
   13177              :   /* Otherwise, take the size from that of the element type.  Substitute
   13178              :      any PLACEHOLDER_EXPR that we have.  */
   13179              :   else
   13180    785295957 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (elmt_type), exp);
   13181              : }
   13182              : 
   13183              : /* Return a tree representing the lower bound of the array mentioned in
   13184              :    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13185              : 
   13186              : tree
   13187   1085545515 : array_ref_low_bound (tree exp)
   13188              : {
   13189   1085545515 :   tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13190              : 
   13191              :   /* If a lower bound is specified in EXP, use it.  */
   13192   1085545515 :   if (TREE_OPERAND (exp, 2))
   13193      1973363 :     return TREE_OPERAND (exp, 2);
   13194              : 
   13195              :   /* Otherwise, if there is a domain type and it has a lower bound, use it,
   13196              :      substituting for a PLACEHOLDER_EXPR as needed.  */
   13197   1083572152 :   if (domain_type && TYPE_MIN_VALUE (domain_type))
   13198   1082643785 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MIN_VALUE (domain_type), exp);
   13199              : 
   13200              :   /* Otherwise, return a zero of the appropriate type.  */
   13201       928367 :   tree idxtype = TREE_TYPE (TREE_OPERAND (exp, 1));
   13202       928367 :   return (idxtype == error_mark_node
   13203       928367 :           ? integer_zero_node : build_int_cst (idxtype, 0));
   13204              : }
   13205              : 
   13206              : /* Return a tree representing the upper bound of the array mentioned in
   13207              :    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13208              : 
   13209              : tree
   13210    251640572 : array_ref_up_bound (tree exp)
   13211              : {
   13212    251640572 :   tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13213              : 
   13214              :   /* If there is a domain type and it has an upper bound, use it, substituting
   13215              :      for a PLACEHOLDER_EXPR as needed.  */
   13216    251640572 :   if (domain_type && TYPE_MAX_VALUE (domain_type))
   13217    250823607 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MAX_VALUE (domain_type), exp);
   13218              : 
   13219              :   /* Otherwise fail.  */
   13220              :   return NULL_TREE;
   13221              : }
   13222              : 
   13223              : /* Returns true if REF is an array reference, a component reference,
   13224              :    or a memory reference to an array whose actual size might be larger
   13225              :    than its upper bound implies, there are multiple cases:
   13226              :    A. a ref to a flexible array member at the end of a structure;
   13227              :    B. a ref to an array with a different type against the original decl;
   13228              :       for example:
   13229              : 
   13230              :    short a[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
   13231              :    (*((char(*)[16])&a[0]))[i+8]
   13232              : 
   13233              :    C. a ref to an array that was passed as a parameter;
   13234              :       for example:
   13235              : 
   13236              :    int test (uint8_t *p, uint32_t t[1][1], int n) {
   13237              :    for (int i = 0; i < 4; i++, p++)
   13238              :      t[i][0] = ...;
   13239              : 
   13240              :    If non-null, set IS_TRAILING_ARRAY to true if the ref is the above case A.
   13241              : */
   13242              : 
   13243              : bool
   13244     74776137 : array_ref_flexible_size_p (tree ref, bool *is_trailing_array /* = NULL */)
   13245              : {
   13246              :   /* The TYPE for this array reference.  */
   13247     74776137 :   tree atype = NULL_TREE;
   13248              :   /* The FIELD_DECL for the array field in the containing structure.  */
   13249     74776137 :   tree afield_decl = NULL_TREE;
   13250              :   /* Whether this array is the trailing array of a structure.  */
   13251     74776137 :   bool is_trailing_array_tmp = false;
   13252     74776137 :   if (!is_trailing_array)
   13253     74696285 :     is_trailing_array = &is_trailing_array_tmp;
   13254              : 
   13255     74776137 :   if (TREE_CODE (ref) == ARRAY_REF
   13256     74776137 :       || TREE_CODE (ref) == ARRAY_RANGE_REF)
   13257              :     {
   13258     74539162 :       atype = TREE_TYPE (TREE_OPERAND (ref, 0));
   13259     74539162 :       ref = TREE_OPERAND (ref, 0);
   13260              :     }
   13261       236975 :   else if (TREE_CODE (ref) == COMPONENT_REF
   13262       236975 :            && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 1))) == ARRAY_TYPE)
   13263              :     {
   13264       167965 :       atype = TREE_TYPE (TREE_OPERAND (ref, 1));
   13265       167965 :       afield_decl = TREE_OPERAND (ref, 1);
   13266              :     }
   13267        69010 :   else if (TREE_CODE (ref) == MEM_REF)
   13268              :     {
   13269         7352 :       tree arg = TREE_OPERAND (ref, 0);
   13270         7352 :       if (TREE_CODE (arg) == ADDR_EXPR)
   13271         7352 :         arg = TREE_OPERAND (arg, 0);
   13272         7352 :       tree argtype = TREE_TYPE (arg);
   13273         7352 :       if (TREE_CODE (argtype) == RECORD_TYPE)
   13274              :         {
   13275          157 :           if (tree fld = last_field (argtype))
   13276              :             {
   13277          157 :               atype = TREE_TYPE (fld);
   13278          157 :               afield_decl = fld;
   13279          157 :               if (TREE_CODE (atype) != ARRAY_TYPE)
   13280              :                 return false;
   13281          157 :               if (VAR_P (arg) && DECL_SIZE (fld))
   13282              :                 return false;
   13283              :             }
   13284              :           else
   13285              :             return false;
   13286              :         }
   13287              :       else
   13288              :         return false;
   13289              :     }
   13290              :   else
   13291              :     return false;
   13292              : 
   13293     74707240 :   if (TREE_CODE (ref) == STRING_CST)
   13294              :     return false;
   13295              : 
   13296              :   tree ref_to_array = ref;
   13297     91553282 :   while (handled_component_p (ref))
   13298              :     {
   13299              :       /* If the reference chain contains a component reference to a
   13300              :          non-union type and there follows another field the reference
   13301              :          is not at the end of a structure.  */
   13302     19984855 :       if (TREE_CODE (ref) == COMPONENT_REF)
   13303              :         {
   13304     18823615 :           if (TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == RECORD_TYPE)
   13305              :             {
   13306     17574387 :               tree nextf = DECL_CHAIN (TREE_OPERAND (ref, 1));
   13307     33808496 :               while (nextf && TREE_CODE (nextf) != FIELD_DECL)
   13308     16234109 :                 nextf = DECL_CHAIN (nextf);
   13309              :               if (nextf)
   13310              :                 return false;
   13311              :             }
   13312              :         }
   13313              :       /* If we have a multi-dimensional array we do not consider
   13314              :          a non-innermost dimension as flex array if the whole
   13315              :          multi-dimensional array is at struct end.
   13316              :          Same for an array of aggregates with a trailing array
   13317              :          member.  */
   13318      1161240 :       else if (TREE_CODE (ref) == ARRAY_REF)
   13319              :         return false;
   13320       193420 :       else if (TREE_CODE (ref) == ARRAY_RANGE_REF)
   13321              :         ;
   13322              :       /* If we view an underlying object as sth else then what we
   13323              :          gathered up to now is what we have to rely on.  */
   13324       193410 :       else if (TREE_CODE (ref) == VIEW_CONVERT_EXPR)
   13325              :         break;
   13326              :       else
   13327            0 :         gcc_unreachable ();
   13328              : 
   13329     16847240 :       ref = TREE_OPERAND (ref, 0);
   13330              :     }
   13331              : 
   13332     71761837 :   gcc_assert (!afield_decl
   13333              :               || (afield_decl && TREE_CODE (afield_decl) == FIELD_DECL));
   13334              : 
   13335              :   /* The array now is at struct end.  Treat flexible array member as
   13336              :      always subject to extend, even into just padding constrained by
   13337              :      an underlying decl.  */
   13338     71761837 :   if (! TYPE_SIZE (atype)
   13339     69219502 :       || ! TYPE_DOMAIN (atype)
   13340    140981339 :       || ! TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
   13341              :     {
   13342      2547730 :       *is_trailing_array = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13343      2632334 :       return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13344              :     }
   13345              : 
   13346              :   /* If the reference is based on a declared entity, the size of the array
   13347              :      is constrained by its given domain.  (Do not trust commons PR/69368).  */
   13348     69214107 :   ref = get_base_address (ref);
   13349     69214107 :   if (ref
   13350     69214107 :       && DECL_P (ref)
   13351     59249906 :       && !(flag_unconstrained_commons
   13352           14 :            && VAR_P (ref) && DECL_COMMON (ref))
   13353     59249892 :       && DECL_SIZE_UNIT (ref)
   13354    128463622 :       && TREE_CODE (DECL_SIZE_UNIT (ref)) == INTEGER_CST)
   13355              :     {
   13356              :       /* If the object itself is the array it is not at struct end.  */
   13357     59249487 :       if (DECL_P (ref_to_array))
   13358              :         return false;
   13359              : 
   13360              :       /* Check whether the array domain covers all of the available
   13361              :          padding.  */
   13362     15462355 :       poly_int64 offset;
   13363     15462355 :       if (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (atype))) != INTEGER_CST
   13364     15460995 :           || TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (atype))) != INTEGER_CST
   13365     30901096 :           || TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (atype))) != INTEGER_CST)
   13366              :         {
   13367        23614 :           *is_trailing_array
   13368        23614 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13369        23657 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13370              :         }
   13371     15438741 :       if (! get_addr_base_and_unit_offset (ref_to_array, &offset))
   13372              :         {
   13373         2821 :           *is_trailing_array
   13374         2821 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13375         2821 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13376              :         }
   13377              : 
   13378              :       /* If at least one extra element fits it is a flexarray.  */
   13379     15435920 :       if (known_le ((wi::to_offset (TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
   13380              :                      - wi::to_offset (TYPE_MIN_VALUE (TYPE_DOMAIN (atype)))
   13381              :                      + 2)
   13382              :                     * wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (atype))),
   13383              :                     wi::to_offset (DECL_SIZE_UNIT (ref)) - offset))
   13384              :         {
   13385       368010 :           *is_trailing_array
   13386       368010 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13387       377521 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13388              :         }
   13389              : 
   13390              :       return false;
   13391              :     }
   13392              : 
   13393      9964620 :   *is_trailing_array = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13394      9979177 :   return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13395              : }
   13396              : 
   13397              : 
   13398              : /* Return a tree representing the offset, in bytes, of the field referenced
   13399              :    by EXP.  This does not include any offset in DECL_FIELD_BIT_OFFSET.  */
   13400              : 
   13401              : tree
   13402   2683248134 : component_ref_field_offset (tree exp)
   13403              : {
   13404   2683248134 :   tree aligned_offset = TREE_OPERAND (exp, 2);
   13405   2683248134 :   tree field = TREE_OPERAND (exp, 1);
   13406   2683248134 :   location_t loc = EXPR_LOCATION (exp);
   13407              : 
   13408              :   /* If an offset was specified in the COMPONENT_REF, it's the offset measured
   13409              :      in units of DECL_OFFSET_ALIGN / BITS_PER_UNIT.  So multiply by that
   13410              :      value.  */
   13411   2683248134 :   if (aligned_offset)
   13412              :     {
   13413              :       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
   13414              :          sizetype from another type of the same width and signedness.  */
   13415        11909 :       if (TREE_TYPE (aligned_offset) != sizetype)
   13416          133 :         aligned_offset = fold_convert_loc (loc, sizetype, aligned_offset);
   13417        11909 :       return size_binop_loc (loc, MULT_EXPR, aligned_offset,
   13418        11909 :                              size_int (DECL_OFFSET_ALIGN (field)
   13419              :                                        / BITS_PER_UNIT));
   13420              :     }
   13421              : 
   13422              :   /* Otherwise, take the offset from that of the field.  Substitute
   13423              :      any PLACEHOLDER_EXPR that we have.  */
   13424              :   else
   13425   2683236225 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (DECL_FIELD_OFFSET (field), exp);
   13426              : }
   13427              : 
   13428              : /* Given the initializer INIT, return the initializer for the field
   13429              :    DECL if it exists, otherwise null.  Used to obtain the initializer
   13430              :    for a flexible array member and determine its size.  */
   13431              : 
   13432              : static tree
   13433         1267 : get_initializer_for (tree init, tree decl)
   13434              : {
   13435         1267 :   STRIP_NOPS (init);
   13436              : 
   13437         1267 :   tree fld, fld_init;
   13438         1267 :   unsigned HOST_WIDE_INT i;
   13439         3571 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), i, fld, fld_init)
   13440              :     {
   13441         1926 :       if (decl == fld)
   13442              :         return fld_init;
   13443              : 
   13444         1037 :       if (TREE_CODE (fld) == CONSTRUCTOR)
   13445              :         {
   13446            0 :           fld_init = get_initializer_for (fld_init, decl);
   13447            0 :           if (fld_init)
   13448              :             return fld_init;
   13449              :         }
   13450              :     }
   13451              : 
   13452              :   return NULL_TREE;
   13453              : }
   13454              : 
   13455              : /* Determines the special array member type for the array reference REF.  */
   13456              : special_array_member
   13457       250824 : component_ref_sam_type (tree ref)
   13458              : {
   13459       250824 :   special_array_member sam_type = special_array_member::none;
   13460              : 
   13461       250824 :   tree member = TREE_OPERAND (ref, 1);
   13462       250824 :   tree memsize = DECL_SIZE_UNIT (member);
   13463       250824 :   if (memsize)
   13464              :     {
   13465       118798 :       tree memtype = TREE_TYPE (member);
   13466       118798 :       if (TREE_CODE (memtype) != ARRAY_TYPE)
   13467       118676 :         return sam_type;
   13468              : 
   13469        79852 :       bool trailing = false;
   13470        79852 :       (void) array_ref_flexible_size_p (ref, &trailing);
   13471        79852 :       bool zero_elts = integer_zerop (memsize);
   13472        79852 :       if (zero_elts && integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (memtype))))
   13473              :         {
   13474              :           /* If array element has zero size, verify if it is a flexible
   13475              :              array member or zero length array.  Clear zero_elts if
   13476              :              it has one or more members or is a VLA member.  */
   13477            6 :           if (tree dom = TYPE_DOMAIN (memtype))
   13478            6 :             if (tree min = TYPE_MIN_VALUE (dom))
   13479            6 :               if (tree max = TYPE_MAX_VALUE (dom))
   13480            4 :                 if (TREE_CODE (min) != INTEGER_CST
   13481            4 :                     || TREE_CODE (max) != INTEGER_CST
   13482           12 :                     || !((integer_zerop (min) && integer_all_onesp (max))
   13483            4 :                          || tree_int_cst_lt (max, min)))
   13484              :                   zero_elts = false;
   13485              :         }
   13486        79852 :       if (!trailing && !zero_elts)
   13487              :         /* MEMBER is an interior array with more than one element.  */
   13488              :         return special_array_member::int_n;
   13489              : 
   13490        22654 :       if (zero_elts)
   13491              :         {
   13492         1074 :           if (trailing)
   13493              :             return special_array_member::trail_0;
   13494              :           else
   13495          463 :             return special_array_member::int_0;
   13496              :         }
   13497              : 
   13498        22043 :       if (!zero_elts)
   13499        22043 :         if (tree dom = TYPE_DOMAIN (memtype))
   13500        22043 :           if (tree min = TYPE_MIN_VALUE (dom))
   13501        22043 :             if (tree max = TYPE_MAX_VALUE (dom))
   13502        22043 :               if (TREE_CODE (min) == INTEGER_CST
   13503        22043 :                   && TREE_CODE (max) == INTEGER_CST)
   13504              :                 {
   13505        21921 :                   offset_int minidx = wi::to_offset (min);
   13506        21921 :                   offset_int maxidx = wi::to_offset (max);
   13507        21921 :                   offset_int neltsm1 = maxidx - minidx;
   13508        21921 :                   if (neltsm1 > 0)
   13509              :                     /* MEMBER is a trailing array with more than
   13510              :                        one elements.  */
   13511        21921 :                     return special_array_member::trail_n;
   13512              : 
   13513         2182 :                   if (neltsm1 == 0)
   13514              :                     return special_array_member::trail_1;
   13515              :                 }
   13516              :     }
   13517              : 
   13518              :   return sam_type;
   13519              : }
   13520              : 
   13521              : /* Determines the size of the member referenced by the COMPONENT_REF
   13522              :    REF, using its initializer expression if necessary in order to
   13523              :    determine the size of an initialized flexible array member.
   13524              :    If non-null, set *SAM to the type of special array member.
   13525              :    Returns the size as sizetype (which might be zero for an object
   13526              :    with an uninitialized flexible array member) or null if the size
   13527              :    cannot be determined.  */
   13528              : 
   13529              : tree
   13530       151462 : component_ref_size (tree ref, special_array_member *sam /* = NULL */)
   13531              : {
   13532       151462 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
   13533              : 
   13534       151462 :   special_array_member sambuf;
   13535       151462 :   if (!sam)
   13536        97668 :     sam = &sambuf;
   13537       151462 :   *sam = component_ref_sam_type (ref);
   13538              : 
   13539              :   /* The object/argument referenced by the COMPONENT_REF and its type.  */
   13540       151462 :   tree arg = TREE_OPERAND (ref, 0);
   13541       151462 :   tree argtype = TREE_TYPE (arg);
   13542              :   /* The referenced member.  */
   13543       151462 :   tree member = TREE_OPERAND (ref, 1);
   13544              : 
   13545       151462 :   tree memsize = DECL_SIZE_UNIT (member);
   13546       151462 :   if (memsize)
   13547              :     {
   13548        83909 :       tree memtype = TREE_TYPE (member);
   13549        83909 :       if (TREE_CODE (memtype) != ARRAY_TYPE)
   13550              :         /* DECL_SIZE may be less than TYPE_SIZE in C++ when referring
   13551              :            to the type of a class with a virtual base which doesn't
   13552              :            reflect the size of the virtual's members (see pr97595).
   13553              :            If that's the case fail for now and implement something
   13554              :            more robust in the future.  */
   13555        38946 :         return (tree_int_cst_equal (memsize, TYPE_SIZE_UNIT (memtype))
   13556        38946 :                 ? memsize : NULL_TREE);
   13557              : 
   13558              :       /* 2-or-more elements arrays are treated as normal arrays by default.  */
   13559        44963 :       if (*sam == special_array_member::int_n
   13560        44963 :           || *sam == special_array_member::trail_n)
   13561              :         return memsize;
   13562              : 
   13563         1849 :       tree afield_decl = TREE_OPERAND (ref, 1);
   13564         1849 :       gcc_assert (TREE_CODE (afield_decl) == FIELD_DECL);
   13565              :       /* If the trailing array is a not a flexible array member, treat it as
   13566              :          a normal array.  */
   13567         1849 :       if (DECL_NOT_FLEXARRAY (afield_decl)
   13568         1849 :           && *sam != special_array_member::int_0)
   13569              :         return memsize;
   13570              : 
   13571         1840 :       if (*sam == special_array_member::int_0)
   13572          270 :         memsize = NULL_TREE;
   13573              : 
   13574              :       /* For a reference to a flexible array member of a union
   13575              :          use the size of the union instead of the size of the member.  */
   13576         1840 :       if (TREE_CODE (argtype) == UNION_TYPE)
   13577          277 :         memsize = TYPE_SIZE_UNIT (argtype);
   13578              :     }
   13579              : 
   13580              :   /* MEMBER is either a bona fide flexible array member, or a zero-elements
   13581              :      array member, or an array of length one treated as such.  */
   13582              : 
   13583              :   /* If the reference is to a declared object and the member a true
   13584              :      flexible array, try to determine its size from its initializer.  */
   13585        69393 :   poly_int64 baseoff = 0;
   13586        69393 :   tree base = get_addr_base_and_unit_offset (ref, &baseoff);
   13587        69393 :   if (!base || !VAR_P (base))
   13588              :     {
   13589        66045 :       if (*sam != special_array_member::int_0)
   13590              :         return NULL_TREE;
   13591              : 
   13592           52 :       if (TREE_CODE (arg) != COMPONENT_REF)
   13593              :         return NULL_TREE;
   13594              : 
   13595              :       base = arg;
   13596            6 :       while (TREE_CODE (base) == COMPONENT_REF)
   13597            3 :         base = TREE_OPERAND (base, 0);
   13598            3 :       baseoff = tree_to_poly_int64 (byte_position (TREE_OPERAND (ref, 1)));
   13599              :     }
   13600              : 
   13601              :   /* BASE is the declared object of which MEMBER is either a member
   13602              :      or that is cast to ARGTYPE (e.g., a char buffer used to store
   13603              :      an ARGTYPE object).  */
   13604         3351 :   tree basetype = TREE_TYPE (base);
   13605              : 
   13606              :   /* Determine the base type of the referenced object.  If it's
   13607              :      the same as ARGTYPE and MEMBER has a known size, return it.  */
   13608         3351 :   tree bt = basetype;
   13609         3351 :   if (*sam != special_array_member::int_0)
   13610         3352 :     while (TREE_CODE (bt) == ARRAY_TYPE)
   13611          222 :       bt = TREE_TYPE (bt);
   13612         3351 :   bool typematch = useless_type_conversion_p (argtype, bt);
   13613         3351 :   if (memsize && typematch)
   13614              :     return memsize;
   13615              : 
   13616         3261 :   memsize = NULL_TREE;
   13617              : 
   13618         3261 :   if (typematch)
   13619              :     /* MEMBER is a true flexible array member.  Compute its size from
   13620              :        the initializer of the BASE object if it has one.  */
   13621         2697 :     if (tree init = DECL_P (base) ? DECL_INITIAL (base) : NULL_TREE)
   13622         1300 :       if (init != error_mark_node)
   13623              :         {
   13624         1267 :           init = get_initializer_for (init, member);
   13625         1267 :           if (init)
   13626              :             {
   13627          889 :               memsize = TYPE_SIZE_UNIT (TREE_TYPE (init));
   13628          889 :               if (tree refsize = TYPE_SIZE_UNIT (argtype))
   13629              :                 {
   13630              :                   /* Use the larger of the initializer size and the tail
   13631              :                      padding in the enclosing struct.  */
   13632          889 :                   poly_int64 rsz = tree_to_poly_int64 (refsize);
   13633          889 :                   rsz -= baseoff;
   13634          889 :                   if (known_lt (tree_to_poly_int64 (memsize), rsz))
   13635           56 :                     memsize = wide_int_to_tree (TREE_TYPE (memsize), rsz);
   13636              :                 }
   13637              : 
   13638          889 :               baseoff = 0;
   13639              :             }
   13640              :         }
   13641              : 
   13642          889 :   if (!memsize)
   13643              :     {
   13644         2372 :       if (typematch)
   13645              :         {
   13646         1808 :           if (DECL_P (base)
   13647         1808 :               && DECL_EXTERNAL (base)
   13648          454 :               && bt == basetype
   13649         2256 :               && *sam != special_array_member::int_0)
   13650              :             /* The size of a flexible array member of an extern struct
   13651              :                with no initializer cannot be determined (it's defined
   13652              :                in another translation unit and can have an initializer
   13653              :                with an arbitrary number of elements).  */
   13654              :             return NULL_TREE;
   13655              : 
   13656              :           /* Use the size of the base struct or, for interior zero-length
   13657              :              arrays, the size of the enclosing type.  */
   13658         1383 :           memsize = TYPE_SIZE_UNIT (bt);
   13659              :         }
   13660          564 :       else if (DECL_P (base))
   13661              :         /* Use the size of the BASE object (possibly an array of some
   13662              :            other type such as char used to store the struct).  */
   13663          561 :         memsize = DECL_SIZE_UNIT (base);
   13664              :       else
   13665              :         return NULL_TREE;
   13666              :     }
   13667              : 
   13668              :   /* If the flexible array member has a known size use the greater
   13669              :      of it and the tail padding in the enclosing struct.
   13670              :      Otherwise, when the size of the flexible array member is unknown
   13671              :      and the referenced object is not a struct, use the size of its
   13672              :      type when known.  This detects sizes of array buffers when cast
   13673              :      to struct types with flexible array members.  */
   13674         1944 :   if (memsize)
   13675              :     {
   13676         2808 :       if (!tree_fits_poly_int64_p (memsize))
   13677              :         return NULL_TREE;
   13678         2808 :       poly_int64 memsz64 = memsize ? tree_to_poly_int64 (memsize) : 0;
   13679         2808 :       if (known_lt (baseoff, memsz64))
   13680              :         {
   13681         1341 :           memsz64 -= baseoff;
   13682         1341 :           return wide_int_to_tree (TREE_TYPE (memsize), memsz64);
   13683              :         }
   13684         1467 :       return size_zero_node;
   13685              :     }
   13686              : 
   13687              :   /* Return "don't know" for an external non-array object since its
   13688              :      flexible array member can be initialized to have any number of
   13689              :      elements.  Otherwise, return zero because the flexible array
   13690              :      member has no elements.  */
   13691           25 :   return (DECL_P (base)
   13692           25 :           && DECL_EXTERNAL (base)
   13693           25 :           && (!typematch
   13694            0 :               || TREE_CODE (basetype) != ARRAY_TYPE)
   13695           25 :           ? NULL_TREE : size_zero_node);
   13696              : }
   13697              : 
   13698              : /* Return true if the given node CALL is a call to a .ACCESS_WITH_SIZE
   13699              :    function.  */
   13700              : bool
   13701    162855721 : is_access_with_size_p (const_tree call)
   13702              : {
   13703    162855721 :   if (TREE_CODE (call) != CALL_EXPR)
   13704              :     return false;
   13705     42063289 :   if (CALL_EXPR_IFN (call) == IFN_ACCESS_WITH_SIZE)
   13706         1073 :     return true;
   13707              :   return false;
   13708              : }
   13709              : 
   13710              : /* Get the corresponding reference from the call to a .ACCESS_WITH_SIZE.
   13711              :  * i.e the first argument of this call.  Return NULL_TREE otherwise.  */
   13712              : tree
   13713            3 : get_ref_from_access_with_size (tree call)
   13714              : {
   13715            3 :   if (is_access_with_size_p (call))
   13716            3 :     return  CALL_EXPR_ARG (call, 0);
   13717              :   return NULL_TREE;
   13718              : }
   13719              : 
   13720              : /* Return the machine mode of T.  For vectors, returns the mode of the
   13721              :    inner type.  The main use case is to feed the result to HONOR_NANS,
   13722              :    avoiding the BLKmode that a direct TYPE_MODE (T) might return.  */
   13723              : 
   13724              : machine_mode
   13725   5701702280 : element_mode (const_tree t)
   13726              : {
   13727   5701702280 :   if (!TYPE_P (t))
   13728    197488117 :     t = TREE_TYPE (t);
   13729   5701702280 :   if (VECTOR_TYPE_P (t) || TREE_CODE (t) == COMPLEX_TYPE)
   13730   1517236459 :     t = TREE_TYPE (t);
   13731   5701702280 :   return TYPE_MODE (t);
   13732              : }
   13733              : 
   13734              : /* Vector types need to re-check the target flags each time we report
   13735              :    the machine mode.  We need to do this because attribute target can
   13736              :    change the result of vector_mode_supported_p and have_regs_of_mode
   13737              :    on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
   13738              :    change on a per-function basis.  */
   13739              : /* ??? Possibly a better solution is to run through all the types
   13740              :    referenced by a function and re-compute the TYPE_MODE once, rather
   13741              :    than make the TYPE_MODE macro call a function.  */
   13742              : 
   13743              : machine_mode
   13744   1351565182 : vector_type_mode (const_tree t)
   13745              : {
   13746   1351565182 :   machine_mode mode;
   13747              : 
   13748   1351565182 :   gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
   13749              : 
   13750   1351565182 :   mode = t->type_common.mode;
   13751    310705322 :   if (VECTOR_MODE_P (mode)
   13752   1624001357 :       && (!targetm.vector_mode_supported_p (mode)
   13753   1290465180 :           || !have_regs_of_mode[mode]))
   13754              :     {
   13755     23781880 :       scalar_int_mode innermode;
   13756              : 
   13757              :       /* For integers, try mapping it to a same-sized scalar mode.  */
   13758     23781880 :       if (is_int_mode (TREE_TYPE (t)->type_common.mode, &innermode))
   13759              :         {
   13760     35446540 :           poly_int64 size = (TYPE_VECTOR_SUBPARTS (t)
   13761     17723270 :                              * GET_MODE_BITSIZE (innermode));
   13762     17723270 :           scalar_int_mode mode;
   13763     32120015 :           if (int_mode_for_size (size, 0).exists (&mode)
   13764     14450277 :               && have_regs_of_mode[mode])
   13765        53532 :             return mode;
   13766              :         }
   13767              : 
   13768     23728348 :       return BLKmode;
   13769              :     }
   13770              : 
   13771              :   return mode;
   13772              : }
   13773              : 
   13774              : /* Return the size in bits of each element of vector type TYPE.  */
   13775              : 
   13776              : unsigned int
   13777       245260 : vector_element_bits (const_tree type)
   13778              : {
   13779       245260 :   gcc_checking_assert (VECTOR_TYPE_P (type));
   13780       245260 :   if (VECTOR_BOOLEAN_TYPE_P (type))
   13781         1166 :     return TYPE_PRECISION (TREE_TYPE (type));
   13782       244094 :   return tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type)));
   13783              : }
   13784              : 
   13785              : /* Calculate the size in bits of each element of vector type TYPE
   13786              :    and return the result as a tree of type bitsizetype.  */
   13787              : 
   13788              : tree
   13789       111382 : vector_element_bits_tree (const_tree type)
   13790              : {
   13791       111382 :   gcc_checking_assert (VECTOR_TYPE_P (type));
   13792       111382 :   if (VECTOR_BOOLEAN_TYPE_P (type))
   13793          630 :     return bitsize_int (vector_element_bits (type));
   13794       110752 :   return TYPE_SIZE (TREE_TYPE (type));
   13795              : }
   13796              : 
   13797              : /* Verify that basic properties of T match TV and thus T can be a variant of
   13798              :    TV.  TV should be the more specified variant (i.e. the main variant).  */
   13799              : 
   13800              : static bool
   13801    186644647 : verify_type_variant (const_tree t, tree tv)
   13802              : {
   13803              :   /* Type variant can differ by:
   13804              : 
   13805              :      - TYPE_QUALS: TYPE_READONLY, TYPE_VOLATILE, TYPE_ATOMIC, TYPE_RESTRICT,
   13806              :                    ENCODE_QUAL_ADDR_SPACE.
   13807              :      - main variant may be TYPE_COMPLETE_P and variant types !TYPE_COMPLETE_P
   13808              :        in this case some values may not be set in the variant types
   13809              :        (see TYPE_COMPLETE_P checks).
   13810              :      - it is possible to have TYPE_ARTIFICIAL variant of non-artificial type
   13811              :      - by TYPE_NAME and attributes (i.e. when variant originate by typedef)
   13812              :      - TYPE_CANONICAL (TYPE_ALIAS_SET is the same among variants)
   13813              :      - by the alignment: TYPE_ALIGN and TYPE_USER_ALIGN
   13814              :      - during LTO by TYPE_CONTEXT if type is TYPE_FILE_SCOPE_P
   13815              :        this is necessary to make it possible to merge types form different TUs
   13816              :      - arrays, pointers and references may have TREE_TYPE that is a variant
   13817              :        of TREE_TYPE of their main variants.
   13818              :      - aggregates may have new TYPE_FIELDS list that list variants of
   13819              :        the main variant TYPE_FIELDS.
   13820              :      - vector types may differ by TYPE_VECTOR_OPAQUE
   13821              :    */
   13822              : 
   13823              :   /* Convenience macro for matching individual fields.  */
   13824              : #define verify_variant_match(flag)                                          \
   13825              :   do {                                                                      \
   13826              :     if (flag (tv) != flag (t))                                              \
   13827              :       {                                                                     \
   13828              :         error ("type variant differs by %s", #flag);                      \
   13829              :         debug_tree (tv);                                                    \
   13830              :         return false;                                                       \
   13831              :       }                                                                     \
   13832              :   } while (false)
   13833              : 
   13834              :   /* tree_base checks.  */
   13835              : 
   13836    186644647 :   verify_variant_match (TREE_CODE);
   13837              :   /* FIXME: Ada builds non-artificial variants of artificial types.  */
   13838              : #if 0
   13839              :   if (TYPE_ARTIFICIAL (tv))
   13840              :     verify_variant_match (TYPE_ARTIFICIAL);
   13841              : #endif
   13842    186644647 :   if (POINTER_TYPE_P (tv))
   13843     12214243 :     verify_variant_match (TYPE_REF_CAN_ALIAS_ALL);
   13844              :   /* FIXME: TYPE_SIZES_GIMPLIFIED may differs for Ada build.  */
   13845    186644647 :   verify_variant_match (TYPE_UNSIGNED);
   13846    186644647 :   verify_variant_match (TYPE_PACKED);
   13847    186644647 :   if (TREE_CODE (t) == REFERENCE_TYPE)
   13848      2964483 :     verify_variant_match (TYPE_REF_IS_RVALUE);
   13849    186644647 :   if (AGGREGATE_TYPE_P (t))
   13850     77042275 :     verify_variant_match (TYPE_REVERSE_STORAGE_ORDER);
   13851              :   else
   13852    109602372 :     verify_variant_match (TYPE_SATURATING);
   13853              :   /* FIXME: This check trigger during libstdc++ build.  */
   13854              : #if 0
   13855              :   if (RECORD_OR_UNION_TYPE_P (t) && COMPLETE_TYPE_P (t))
   13856              :     verify_variant_match (TYPE_FINAL_P);
   13857              : #endif
   13858              : 
   13859              :   /* tree_type_common checks.  */
   13860              : 
   13861    186644647 :   if (COMPLETE_TYPE_P (t))
   13862              :     {
   13863    175350260 :       verify_variant_match (TYPE_MODE);
   13864    175350260 :       if (TREE_CODE (TYPE_SIZE (t)) != PLACEHOLDER_EXPR
   13865    175350260 :           && TREE_CODE (TYPE_SIZE (tv)) != PLACEHOLDER_EXPR)
   13866    175350260 :         verify_variant_match (TYPE_SIZE);
   13867    175350260 :       if (TREE_CODE (TYPE_SIZE_UNIT (t)) != PLACEHOLDER_EXPR
   13868    175350260 :           && TREE_CODE (TYPE_SIZE_UNIT (tv)) != PLACEHOLDER_EXPR
   13869    350700520 :           && TYPE_SIZE_UNIT (t) != TYPE_SIZE_UNIT (tv))
   13870              :         {
   13871            0 :           gcc_assert (!operand_equal_p (TYPE_SIZE_UNIT (t),
   13872              :                                         TYPE_SIZE_UNIT (tv), 0));
   13873            0 :           error ("type variant has different %<TYPE_SIZE_UNIT%>");
   13874            0 :           debug_tree (tv);
   13875            0 :           error ("type variant%'s %<TYPE_SIZE_UNIT%>");
   13876            0 :           debug_tree (TYPE_SIZE_UNIT (tv));
   13877            0 :           error ("type%'s %<TYPE_SIZE_UNIT%>");
   13878            0 :           debug_tree (TYPE_SIZE_UNIT (t));
   13879            0 :           return false;
   13880              :         }
   13881    175350260 :       verify_variant_match (TYPE_NEEDS_CONSTRUCTING);
   13882              :     }
   13883    186644647 :   verify_variant_match (TYPE_PRECISION_RAW);
   13884    186644647 :   if (RECORD_OR_UNION_TYPE_P (t))
   13885     76453378 :     verify_variant_match (TYPE_TRANSPARENT_AGGR);
   13886    110191269 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   13887       588897 :     verify_variant_match (TYPE_NONALIASED_COMPONENT);
   13888              :   /* During LTO we merge variant lists from different translation units
   13889              :      that may differ BY TYPE_CONTEXT that in turn may point
   13890              :      to TRANSLATION_UNIT_DECL.
   13891              :      Ada also builds variants of types with different TYPE_CONTEXT.   */
   13892              : #if 0
   13893              :   if (!in_lto_p || !TYPE_FILE_SCOPE_P (t))
   13894              :     verify_variant_match (TYPE_CONTEXT);
   13895              : #endif
   13896    186644647 :   if (TREE_CODE (t) == ARRAY_TYPE || TREE_CODE (t) == INTEGER_TYPE)
   13897     59936643 :     verify_variant_match (TYPE_STRING_FLAG);
   13898    186644647 :   if (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE)
   13899     76453378 :     verify_variant_match (TYPE_CXX_ODR_P);
   13900    186644647 :   if (TYPE_ALIAS_SET_KNOWN_P (t))
   13901              :     {
   13902            0 :       error ("type variant with %<TYPE_ALIAS_SET_KNOWN_P%>");
   13903            0 :       debug_tree (tv);
   13904            0 :       return false;
   13905              :     }
   13906              : 
   13907              :   /* tree_type_non_common checks.  */
   13908              : 
   13909              :   /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
   13910              :      and dangle the pointer from time to time.  */
   13911     76453378 :   if (RECORD_OR_UNION_TYPE_P (t) && TYPE_VFIELD (t) != TYPE_VFIELD (tv)
   13912    186644647 :       && (in_lto_p || !TYPE_VFIELD (tv)
   13913            0 :           || TREE_CODE (TYPE_VFIELD (tv)) != TREE_LIST))
   13914              :     {
   13915            0 :       error ("type variant has different %<TYPE_VFIELD%>");
   13916            0 :       debug_tree (tv);
   13917            0 :       return false;
   13918              :     }
   13919      3339446 :   if ((TREE_CODE (t) == ENUMERAL_TYPE && COMPLETE_TYPE_P (t))
   13920    183305258 :        || TREE_CODE (t) == INTEGER_TYPE
   13921    123957512 :        || TREE_CODE (t) == BOOLEAN_TYPE
   13922     91736993 :        || TREE_CODE (t) == BITINT_TYPE
   13923     91736829 :        || SCALAR_FLOAT_TYPE_P (t)
   13924    276611979 :        || FIXED_POINT_TYPE_P (t))
   13925              :     {
   13926     96677315 :       verify_variant_match (TYPE_MAX_VALUE);
   13927     96677315 :       verify_variant_match (TYPE_MIN_VALUE);
   13928              :     }
   13929    186644647 :   if (TREE_CODE (t) == METHOD_TYPE)
   13930        11630 :     verify_variant_match (TYPE_METHOD_BASETYPE);
   13931    186644647 :   if (TREE_CODE (t) == OFFSET_TYPE)
   13932          878 :     verify_variant_match (TYPE_OFFSET_BASETYPE);
   13933    186644647 :   if (TREE_CODE (t) == ARRAY_TYPE)
   13934       588897 :     verify_variant_match (TYPE_ARRAY_MAX_SIZE);
   13935              :   /* FIXME: Be lax and allow TYPE_BINFO to be missing in variant types
   13936              :      or even type's main variant.  This is needed to make bootstrap pass
   13937              :      and the bug seems new in GCC 5.
   13938              :      C++ FE should be updated to make this consistent and we should check
   13939              :      that TYPE_BINFO is always NULL for !COMPLETE_TYPE_P and otherwise there
   13940              :      is a match with main variant.
   13941              : 
   13942              :      Also disable the check for Java for now because of parser hack that builds
   13943              :      first an dummy BINFO and then sometimes replace it by real BINFO in some
   13944              :      of the copies.  */
   13945     76453378 :   if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t) && TYPE_BINFO (tv)
   13946     64956714 :       && TYPE_BINFO (t) != TYPE_BINFO (tv)
   13947              :       /* FIXME: Java sometimes keep dump TYPE_BINFOs on variant types.
   13948              :          Since there is no cheap way to tell C++/Java type w/o LTO, do checking
   13949              :          at LTO time only.  */
   13950    186644647 :       && (in_lto_p && odr_type_p (t)))
   13951              :     {
   13952            0 :       error ("type variant has different %<TYPE_BINFO%>");
   13953            0 :       debug_tree (tv);
   13954            0 :       error ("type variant%'s %<TYPE_BINFO%>");
   13955            0 :       debug_tree (TYPE_BINFO (tv));
   13956            0 :       error ("type%'s %<TYPE_BINFO%>");
   13957            0 :       debug_tree (TYPE_BINFO (t));
   13958            0 :       return false;
   13959              :     }
   13960              : 
   13961              :   /* Check various uses of TYPE_VALUES_RAW.  */
   13962    186644647 :   if (TREE_CODE (t) == ENUMERAL_TYPE
   13963    186644647 :       && TYPE_VALUES (t))
   13964      3176059 :     verify_variant_match (TYPE_VALUES);
   13965    183468588 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   13966       588897 :     verify_variant_match (TYPE_DOMAIN);
   13967              :   /* Permit incomplete variants of complete type.  While FEs may complete
   13968              :      all variants, this does not happen for C++ templates in all cases.  */
   13969    182879691 :   else if (RECORD_OR_UNION_TYPE_P (t)
   13970     76453378 :            && COMPLETE_TYPE_P (t)
   13971    248234744 :            && TYPE_FIELDS (t) != TYPE_FIELDS (tv))
   13972              :     {
   13973         3913 :       tree f1, f2;
   13974              : 
   13975              :       /* Fortran builds qualified variants as new records with items of
   13976              :          qualified type. Verify that they looks same.  */
   13977         3913 :       for (f1 = TYPE_FIELDS (t), f2 = TYPE_FIELDS (tv);
   13978        12588 :            f1 && f2;
   13979         8675 :            f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
   13980         8675 :         if (TREE_CODE (f1) != FIELD_DECL || TREE_CODE (f2) != FIELD_DECL
   13981         8675 :             || (TYPE_MAIN_VARIANT (TREE_TYPE (f1))
   13982         8675 :                  != TYPE_MAIN_VARIANT (TREE_TYPE (f2))
   13983              :                 /* FIXME: gfc_nonrestricted_type builds all types as variants
   13984              :                    with exception of pointer types.  It deeply copies the type
   13985              :                    which means that we may end up with a variant type
   13986              :                    referring non-variant pointer.  We may change it to
   13987              :                    produce types as variants, too, like
   13988              :                    objc_get_protocol_qualified_type does.  */
   13989           21 :                 && !POINTER_TYPE_P (TREE_TYPE (f1)))
   13990         8675 :             || DECL_FIELD_OFFSET (f1) != DECL_FIELD_OFFSET (f2)
   13991        17350 :             || DECL_FIELD_BIT_OFFSET (f1) != DECL_FIELD_BIT_OFFSET (f2))
   13992              :           break;
   13993         3913 :       if (f1 || f2)
   13994              :         {
   13995            0 :           error ("type variant has different %<TYPE_FIELDS%>");
   13996            0 :           debug_tree (tv);
   13997            0 :           error ("first mismatch is field");
   13998            0 :           debug_tree (f1);
   13999            0 :           error ("and field");
   14000            0 :           debug_tree (f2);
   14001            0 :           return false;
   14002              :         }
   14003              :     }
   14004    182875778 :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14005       147194 :     verify_variant_match (TYPE_ARG_TYPES);
   14006              :   /* For C++ the qualified variant of array type is really an array type
   14007              :      of qualified TREE_TYPE.
   14008              :      objc builds variants of pointer where pointer to type is a variant, too
   14009              :      in objc_get_protocol_qualified_type.  */
   14010    186644647 :   if (TREE_TYPE (t) != TREE_TYPE (tv)
   14011    186644647 :       && ((TREE_CODE (t) != ARRAY_TYPE
   14012            0 :            && !POINTER_TYPE_P (t))
   14013       508436 :           || TYPE_MAIN_VARIANT (TREE_TYPE (t))
   14014       508436 :              != TYPE_MAIN_VARIANT (TREE_TYPE (tv))))
   14015              :     {
   14016            0 :       error ("type variant has different %<TREE_TYPE%>");
   14017            0 :       debug_tree (tv);
   14018            0 :       error ("type variant%'s %<TREE_TYPE%>");
   14019            0 :       debug_tree (TREE_TYPE (tv));
   14020            0 :       error ("type%'s %<TREE_TYPE%>");
   14021            0 :       debug_tree (TREE_TYPE (t));
   14022            0 :       return false;
   14023              :     }
   14024    186644647 :   if (type_with_alias_set_p (t)
   14025    186644647 :       && !gimple_canonical_types_compatible_p (t, tv, false))
   14026              :     {
   14027            0 :       error ("type is not compatible with its variant");
   14028            0 :       debug_tree (tv);
   14029            0 :       error ("type variant%'s %<TREE_TYPE%>");
   14030            0 :       debug_tree (TREE_TYPE (tv));
   14031            0 :       error ("type%'s %<TREE_TYPE%>");
   14032            0 :       debug_tree (TREE_TYPE (t));
   14033            0 :       return false;
   14034              :     }
   14035              :   return true;
   14036              : #undef verify_variant_match
   14037              : }
   14038              : 
   14039              : 
   14040              : /* The TYPE_CANONICAL merging machinery.  It should closely resemble
   14041              :    the middle-end types_compatible_p function.  It needs to avoid
   14042              :    claiming types are different for types that should be treated
   14043              :    the same with respect to TBAA.  Canonical types are also used
   14044              :    for IL consistency checks via the useless_type_conversion_p
   14045              :    predicate which does not handle all type kinds itself but falls
   14046              :    back to pointer-comparison of TYPE_CANONICAL for aggregates
   14047              :    for example.  */
   14048              : 
   14049              : /* Return true if TYPE_UNSIGNED of TYPE should be ignored for canonical
   14050              :    type calculation because we need to allow inter-operability between signed
   14051              :    and unsigned variants.  */
   14052              : 
   14053              : bool
   14054      1874024 : type_with_interoperable_signedness (const_tree type)
   14055              : {
   14056              :   /* Fortran standard require C_SIGNED_CHAR to be interoperable with both
   14057              :      signed char and unsigned char.  Similarly fortran FE builds
   14058              :      C_SIZE_T as signed type, while C defines it unsigned.  */
   14059              : 
   14060      1874024 :   return tree_code_for_canonical_type_merging (TREE_CODE (type))
   14061              :            == INTEGER_TYPE
   14062      1873820 :          && (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node)
   14063       502371 :              || TYPE_PRECISION (type) == TYPE_PRECISION (size_type_node));
   14064              : }
   14065              : 
   14066              : /* Return true iff T1 and T2 are structurally identical for what
   14067              :    TBAA is concerned.
   14068              :    This function is used both by lto.cc canonical type merging and by the
   14069              :    verifier.  If TRUST_TYPE_CANONICAL we do not look into structure of types
   14070              :    that have TYPE_CANONICAL defined and assume them equivalent.  This is useful
   14071              :    only for LTO because only in these cases TYPE_CANONICAL equivalence
   14072              :    correspond to one defined by gimple_canonical_types_compatible_p.  */
   14073              : 
   14074              : bool
   14075    382331265 : gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
   14076              :                                      bool trust_type_canonical)
   14077              : {
   14078              :   /* Type variants should be same as the main variant.  When not doing sanity
   14079              :      checking to verify this fact, go to main variants and save some work.  */
   14080    382331265 :   if (trust_type_canonical)
   14081              :     {
   14082      1003963 :       t1 = TYPE_MAIN_VARIANT (t1);
   14083      1003963 :       t2 = TYPE_MAIN_VARIANT (t2);
   14084              :     }
   14085              : 
   14086              :   /* Check first for the obvious case of pointer identity.  */
   14087    382331265 :   if (t1 == t2)
   14088              :     return true;
   14089              : 
   14090              :   /* Check that we have two types to compare.  */
   14091    323990593 :   if (t1 == NULL_TREE || t2 == NULL_TREE)
   14092              :     return false;
   14093              : 
   14094              :   /* We consider complete types always compatible with incomplete type.
   14095              :      This does not make sense for canonical type calculation and thus we
   14096              :      need to ensure that we are never called on it.
   14097              : 
   14098              :      FIXME: For more correctness the function probably should have three modes
   14099              :         1) mode assuming that types are complete matching their structure
   14100              :         2) mode allowing incomplete types but producing equivalence classes
   14101              :            and thus ignoring all info from complete types
   14102              :         3) mode allowing incomplete types to match complete but checking
   14103              :            compatibility between complete types.
   14104              : 
   14105              :      1 and 2 can be used for canonical type calculation. 3 is the real
   14106              :      definition of type compatibility that can be used i.e. for warnings during
   14107              :      declaration merging.  */
   14108              : 
   14109    323990593 :   gcc_assert (!trust_type_canonical
   14110              :               || (type_with_alias_set_p (t1) && type_with_alias_set_p (t2)));
   14111              : 
   14112              :   /* If the types have been previously registered and found equal
   14113              :      they still are.  */
   14114              : 
   14115    647685090 :   if (TYPE_CANONICAL (t1) && TYPE_CANONICAL (t2)
   14116    646641166 :       && trust_type_canonical)
   14117              :     {
   14118              :       /* Do not use TYPE_CANONICAL of pointer types.  For LTO streamed types
   14119              :          they are always NULL, but they are set to non-NULL for types
   14120              :          constructed by build_pointer_type and variants.  In this case the
   14121              :          TYPE_CANONICAL is more fine grained than the equivalnce we test (where
   14122              :          all pointers are considered equal.  Be sure to not return false
   14123              :          negatives.  */
   14124       186440 :       gcc_checking_assert (canonical_type_used_p (t1)
   14125              :                            && canonical_type_used_p (t2));
   14126        93220 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
   14127              :     }
   14128              : 
   14129              :   /* For types where we do ODR based TBAA the canonical type is always
   14130              :      set correctly, so we know that types are different if their
   14131              :      canonical types does not match.  */
   14132    323897373 :   if (trust_type_canonical
   14133    324805101 :       && (odr_type_p (t1) && odr_based_tbaa_p (t1))
   14134       907728 :           != (odr_type_p (t2) && odr_based_tbaa_p (t2)))
   14135              :     return false;
   14136              : 
   14137              :   /* Can't be the same type if the types don't have the same code.  */
   14138    323897373 :   enum tree_code code = tree_code_for_canonical_type_merging (TREE_CODE (t1));
   14139    643787419 :   if (code != tree_code_for_canonical_type_merging (TREE_CODE (t2)))
   14140              :     return false;
   14141              : 
   14142              :   /* Qualifiers do not matter for canonical type comparison purposes.  */
   14143              : 
   14144              :   /* Void types and nullptr types are always the same.  */
   14145    323897338 :   if (VOID_TYPE_P (t1)
   14146    323851260 :       || TREE_CODE (t1) == NULLPTR_TYPE)
   14147              :     return true;
   14148              : 
   14149              :   /* Can't be compatible types if they have different mode.  Because of
   14150              :      flexible array members, we allow mismatching modes for structures or
   14151              :      unions.  */
   14152    323224495 :   if (!RECORD_OR_UNION_TYPE_P (t1)
   14153    323224495 :       && TREE_CODE (t1) != ARRAY_TYPE
   14154    323224495 :       && TYPE_MODE (t1) != TYPE_MODE (t2))
   14155              :     return false;
   14156              : 
   14157              :   /* Non-aggregate types can be handled cheaply.  */
   14158    323224495 :   if (INTEGRAL_TYPE_P (t1)
   14159    323224495 :       || SCALAR_FLOAT_TYPE_P (t1)
   14160    171469764 :       || FIXED_POINT_TYPE_P (t1)
   14161    171050760 :       || VECTOR_TYPE_P (t1)
   14162    171015934 :       || TREE_CODE (t1) == COMPLEX_TYPE
   14163    170667708 :       || TREE_CODE (t1) == OFFSET_TYPE
   14164    170665747 :       || POINTER_TYPE_P (t1))
   14165              :     {
   14166              :       /* Can't be the same type if they have different precision.  */
   14167    193463649 :       if (TYPE_PRECISION_RAW (t1) != TYPE_PRECISION_RAW (t2))
   14168              :         return false;
   14169              : 
   14170              :       /* In some cases the signed and unsigned types are required to be
   14171              :          inter-operable.  */
   14172    193463649 :       if (TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2)
   14173    193463649 :           && !type_with_interoperable_signedness (t1))
   14174              :         return false;
   14175              : 
   14176              :       /* Fortran's C_SIGNED_CHAR is !TYPE_STRING_FLAG but needs to be
   14177              :          interoperable with "signed char".  Unless all frontends are revisited
   14178              :          to agree on these types, we must ignore the flag completely.  */
   14179              : 
   14180              :       /* Fortran standard define C_PTR type that is compatible with every
   14181              :          C pointer.  For this reason we need to glob all pointers into one.
   14182              :          Still pointers in different address spaces are not compatible.  */
   14183    193463649 :       if (POINTER_TYPE_P (t1))
   14184              :         {
   14185     40904901 :           if (TYPE_ADDR_SPACE (TREE_TYPE (t1))
   14186     40904901 :               != TYPE_ADDR_SPACE (TREE_TYPE (t2)))
   14187              :             return false;
   14188              :         }
   14189              : 
   14190              :       /* Tail-recurse to components.  */
   14191    193463649 :       if (VECTOR_TYPE_P (t1)
   14192    193463649 :           || TREE_CODE (t1) == COMPLEX_TYPE)
   14193       383052 :         return gimple_canonical_types_compatible_p (TREE_TYPE (t1),
   14194       383052 :                                                     TREE_TYPE (t2),
   14195       383052 :                                                     trust_type_canonical);
   14196              : 
   14197              :       return true;
   14198              :     }
   14199              : 
   14200              :   /* Do type-specific comparisons.  */
   14201    129760846 :   switch (TREE_CODE (t1))
   14202              :     {
   14203      1071084 :     case ARRAY_TYPE:
   14204              :       /* Array types are the same if the element types are the same and
   14205              :          minimum and maximum index are the same.  */
   14206      1071084 :       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
   14207              :                                                 trust_type_canonical)
   14208      1071045 :           || TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2)
   14209      1071045 :           || TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2)
   14210      2142129 :           || TYPE_NONALIASED_COMPONENT (t1) != TYPE_NONALIASED_COMPONENT (t2))
   14211              :         return false;
   14212              :       else
   14213              :         {
   14214      1071045 :           tree i1 = TYPE_DOMAIN (t1);
   14215      1071045 :           tree i2 = TYPE_DOMAIN (t2);
   14216              : 
   14217              :           /* For an incomplete external array, the type domain can be
   14218              :              NULL_TREE.  Check this condition also.  */
   14219      1071045 :           if (i1 == NULL_TREE && i2 == NULL_TREE)
   14220              :             return true;
   14221       977875 :           else if (i1 == NULL_TREE || i2 == NULL_TREE)
   14222              :             return false;
   14223              :           else
   14224              :             {
   14225       977875 :               tree min1 = TYPE_MIN_VALUE (i1);
   14226       977875 :               tree min2 = TYPE_MIN_VALUE (i2);
   14227       977875 :               tree max1 = TYPE_MAX_VALUE (i1);
   14228       977875 :               tree max2 = TYPE_MAX_VALUE (i2);
   14229              : 
   14230              :               /* The minimum/maximum values have to be the same.  */
   14231       977875 :               if ((min1 == min2
   14232            0 :                    || (min1 && min2
   14233            0 :                        && ((TREE_CODE (min1) == PLACEHOLDER_EXPR
   14234            0 :                             && TREE_CODE (min2) == PLACEHOLDER_EXPR)
   14235            0 :                            || operand_equal_p (min1, min2, 0))))
   14236       977875 :                   && (max1 == max2
   14237            0 :                       || (max1 && max2
   14238            0 :                           && ((TREE_CODE (max1) == PLACEHOLDER_EXPR
   14239            0 :                                && TREE_CODE (max2) == PLACEHOLDER_EXPR)
   14240            0 :                               || operand_equal_p (max1, max2, 0)))))
   14241       977875 :                 return true;
   14242              :               else
   14243            0 :                 return false;
   14244              :             }
   14245              :         }
   14246              : 
   14247         7032 :     case METHOD_TYPE:
   14248         7032 :     case FUNCTION_TYPE:
   14249              :       /* Function types are the same if the return type and arguments types
   14250              :          are the same.  */
   14251         7032 :       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
   14252              :                                                 trust_type_canonical))
   14253              :         return false;
   14254              : 
   14255         7032 :       if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2)
   14256         7032 :           && (TYPE_NO_NAMED_ARGS_STDARG_P (t1)
   14257          322 :               == TYPE_NO_NAMED_ARGS_STDARG_P (t2)))
   14258              :         return true;
   14259              :       else
   14260              :         {
   14261         6710 :           tree parms1, parms2;
   14262              : 
   14263         6710 :           for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2);
   14264        29881 :                parms1 && parms2;
   14265        23171 :                parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2))
   14266              :             {
   14267        23171 :               if (!gimple_canonical_types_compatible_p
   14268        23171 :                      (TREE_VALUE (parms1), TREE_VALUE (parms2),
   14269              :                       trust_type_canonical))
   14270              :                 return false;
   14271              :             }
   14272              : 
   14273         6710 :           if (parms1 || parms2)
   14274              :             return false;
   14275              : 
   14276              :           return true;
   14277              :         }
   14278              : 
   14279    128385617 :     case RECORD_TYPE:
   14280    128385617 :     case UNION_TYPE:
   14281    128385617 :     case QUAL_UNION_TYPE:
   14282    128385617 :       {
   14283    128385617 :         tree f1, f2;
   14284              : 
   14285              :         /* Don't try to compare variants of an incomplete type, before
   14286              :            TYPE_FIELDS has been copied around.  */
   14287    128385617 :         if (!COMPLETE_TYPE_P (t1) && !COMPLETE_TYPE_P (t2))
   14288              :           return true;
   14289              : 
   14290              : 
   14291    117953828 :         if (TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2))
   14292              :           return false;
   14293              : 
   14294              :         /* For aggregate types, all the fields must be the same.  */
   14295    117953828 :         for (f1 = TYPE_FIELDS (t1), f2 = TYPE_FIELDS (t2);
   14296    176039883 :              f1 || f2;
   14297     58086055 :              f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
   14298              :           {
   14299              :             /* Skip non-fields and zero-sized fields, except zero-sized
   14300              :                arrays at the end.  */
   14301   1773593720 :             while (f1 && (TREE_CODE (f1) != FIELD_DECL
   14302    107288400 :                           || (DECL_SIZE (f1)
   14303    107271106 :                               && integer_zerop (DECL_SIZE (f1))
   14304     49202322 :                               && (TREE_CHAIN (f1)
   14305         3497 :                                   || TREE_CODE (TREE_TYPE (f1))
   14306              :                                      != ARRAY_TYPE))))
   14307   1598659865 :               f1 = TREE_CHAIN (f1);
   14308   1773595282 :             while (f2 && (TREE_CODE (f2) != FIELD_DECL
   14309    107303371 :                           || (DECL_SIZE (f2)
   14310    107285969 :                               && integer_zerop (DECL_SIZE (f2))
   14311     49203891 :                               && (TREE_CHAIN (f2)
   14312         4558 :                                   || TREE_CODE (TREE_TYPE (f2))
   14313              :                                      != ARRAY_TYPE))))
   14314   1598661427 :               f2 = TREE_CHAIN (f2);
   14315    174933855 :             if (!f1 || !f2)
   14316              :               break;
   14317              : 
   14318     58086838 :             tree t1 = TREE_TYPE (f1);
   14319     58086838 :             tree t2 = TREE_TYPE (f2);
   14320              : 
   14321              :             /* If the last element are arrays, we only compare the element
   14322              :                types.  */
   14323     59183417 :             if (TREE_CHAIN (f1) == NULL_TREE && TREE_CODE (t1) == ARRAY_TYPE
   14324     58173779 :                 && TREE_CHAIN (f2) == NULL_TREE && TREE_CODE (t2) == ARRAY_TYPE)
   14325              :               {
   14326              :                 /* If both arrays have zero size, this is a match.  */
   14327       156996 :                 if (DECL_SIZE (f1) && integer_zerop (DECL_SIZE (f1))
   14328        87696 :                     && DECL_SIZE (f2) && integer_zerop (DECL_SIZE (f2)))
   14329              :                   return true;
   14330              : 
   14331        86177 :                 t1 = TREE_TYPE (t1);
   14332        86177 :                 t2 = TREE_TYPE (t2);
   14333              :               }
   14334              : 
   14335     58086079 :             if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
   14336     58086074 :                 || !gimple_compare_field_offset (f1, f2)
   14337    116172153 :                 || !gimple_canonical_types_compatible_p
   14338     58086074 :                       (t1, t2, trust_type_canonical))
   14339           24 :               return false;
   14340              :           }
   14341              : 
   14342              :         /* If one aggregate has more fields than the other, they
   14343              :            are not the same.  */
   14344    117953045 :         if (f1 || f2)
   14345              :           return false;
   14346              : 
   14347              :         return true;
   14348              :       }
   14349              : 
   14350       297113 :     default:
   14351              :       /* Consider all types with language specific trees in them mutually
   14352              :          compatible.  This is executed only from verify_type and false
   14353              :          positives can be tolerated.  */
   14354       297113 :       gcc_assert (!in_lto_p);
   14355              :       return true;
   14356              :     }
   14357              : }
   14358              : 
   14359              : /* For OPAQUE_TYPE T, it should have only size and alignment information
   14360              :    and its mode should be of class MODE_OPAQUE.  This function verifies
   14361              :    these properties of T match TV which is the main variant of T and TC
   14362              :    which is the canonical of T.  */
   14363              : 
   14364              : static void
   14365            0 : verify_opaque_type (const_tree t, tree tv, tree tc)
   14366              : {
   14367            0 :   gcc_assert (OPAQUE_TYPE_P (t));
   14368            0 :   gcc_assert (tv && tv == TYPE_MAIN_VARIANT (tv));
   14369            0 :   gcc_assert (tc && tc == TYPE_CANONICAL (tc));
   14370              : 
   14371              :   /* For an opaque type T1, check if some of its properties match
   14372              :      the corresponding ones of the other opaque type T2, emit some
   14373              :      error messages for those inconsistent ones.  */
   14374            0 :   auto check_properties_for_opaque_type = [](const_tree t1, tree t2,
   14375              :                                              const char *kind_msg)
   14376              :   {
   14377            0 :     if (!OPAQUE_TYPE_P (t2))
   14378              :       {
   14379            0 :         error ("type %s is not an opaque type", kind_msg);
   14380            0 :         debug_tree (t2);
   14381            0 :         return;
   14382              :       }
   14383            0 :     if (!OPAQUE_MODE_P (TYPE_MODE (t2)))
   14384              :       {
   14385            0 :         error ("type %s is not with opaque mode", kind_msg);
   14386            0 :         debug_tree (t2);
   14387            0 :         return;
   14388              :       }
   14389            0 :     if (TYPE_MODE (t1) != TYPE_MODE (t2))
   14390              :       {
   14391            0 :         error ("type %s differs by %<TYPE_MODE%>", kind_msg);
   14392            0 :         debug_tree (t2);
   14393            0 :         return;
   14394              :       }
   14395            0 :     poly_uint64 t1_size = tree_to_poly_uint64 (TYPE_SIZE (t1));
   14396            0 :     poly_uint64 t2_size = tree_to_poly_uint64 (TYPE_SIZE (t2));
   14397            0 :     if (maybe_ne (t1_size, t2_size))
   14398              :       {
   14399            0 :         error ("type %s differs by %<TYPE_SIZE%>", kind_msg);
   14400            0 :         debug_tree (t2);
   14401            0 :         return;
   14402              :       }
   14403            0 :     if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2))
   14404              :       {
   14405            0 :         error ("type %s differs by %<TYPE_ALIGN%>", kind_msg);
   14406            0 :         debug_tree (t2);
   14407            0 :         return;
   14408              :       }
   14409            0 :     if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
   14410              :       {
   14411            0 :         error ("type %s differs by %<TYPE_USER_ALIGN%>", kind_msg);
   14412            0 :         debug_tree (t2);
   14413            0 :         return;
   14414              :       }
   14415              :   };
   14416              : 
   14417            0 :   if (t != tv)
   14418            0 :     check_properties_for_opaque_type (t, tv, "variant");
   14419              : 
   14420            0 :   if (t != tc)
   14421            0 :     check_properties_for_opaque_type (t, tc, "canonical");
   14422            0 : }
   14423              : 
   14424              : /* Verify type T.  */
   14425              : 
   14426              : void
   14427    866093412 : verify_type (const_tree t)
   14428              : {
   14429    866093412 :   bool error_found = false;
   14430    866093412 :   tree mv = TYPE_MAIN_VARIANT (t);
   14431    866093412 :   tree ct = TYPE_CANONICAL (t);
   14432              : 
   14433    866093412 :   if (OPAQUE_TYPE_P (t))
   14434              :     {
   14435            0 :       verify_opaque_type (t, mv, ct);
   14436            0 :       return;
   14437              :     }
   14438              : 
   14439    866093412 :   if (!mv)
   14440              :     {
   14441            0 :       error ("main variant is not defined");
   14442            0 :       error_found = true;
   14443              :     }
   14444    866093412 :   else if (mv != TYPE_MAIN_VARIANT (mv))
   14445              :     {
   14446            0 :       error ("%<TYPE_MAIN_VARIANT%> has different %<TYPE_MAIN_VARIANT%>");
   14447            0 :       debug_tree (mv);
   14448            0 :       error_found = true;
   14449              :     }
   14450    866093412 :   else if (t != mv && !verify_type_variant (t, mv))
   14451              :     error_found = true;
   14452              : 
   14453    866093412 :   if (!ct)
   14454              :     ;
   14455    864070357 :   else if (TYPE_CANONICAL (ct) != ct)
   14456              :     {
   14457            0 :       error ("%<TYPE_CANONICAL%> has different %<TYPE_CANONICAL%>");
   14458            0 :       debug_tree (ct);
   14459            0 :       error_found = true;
   14460              :     }
   14461              :   /* Method and function types cannot be used to address memory and thus
   14462              :      TYPE_CANONICAL really matters only for determining useless conversions.
   14463              : 
   14464              :      FIXME: C++ FE produce declarations of builtin functions that are not
   14465              :      compatible with main variants.  */
   14466    864070357 :   else if (TREE_CODE (t) == FUNCTION_TYPE)
   14467              :     ;
   14468    863473020 :   else if (t != ct
   14469              :            /* FIXME: gimple_canonical_types_compatible_p cannot compare types
   14470              :               with variably sized arrays because their sizes possibly
   14471              :               gimplified to different variables.  */
   14472    146565605 :            && !variably_modified_type_p (ct, NULL)
   14473    146561129 :            && !gimple_canonical_types_compatible_p (t, ct, false)
   14474    863486429 :            && COMPLETE_TYPE_P (t))
   14475              :     {
   14476            0 :       error ("%<TYPE_CANONICAL%> is not compatible");
   14477            0 :       debug_tree (ct);
   14478            0 :       error_found = true;
   14479              :     }
   14480   1565325990 :   if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t)
   14481              :       /* We allow a mismatch for structure or union because of
   14482              :          flexible array members.  */
   14483    697280196 :       && !RECORD_OR_UNION_TYPE_P (t)
   14484    287374704 :       && !RECORD_OR_UNION_TYPE_P (TYPE_CANONICAL (t))
   14485    287374704 :       && TREE_CODE (t) != ARRAY_TYPE
   14486   1152032926 :       && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t)))
   14487              :     {
   14488            0 :       error ("%<TYPE_MODE%> of %<TYPE_CANONICAL%> is not compatible");
   14489            0 :       debug_tree (ct);
   14490            0 :       error_found = true;
   14491              :     }
   14492    866093412 :   if (TYPE_MAIN_VARIANT (t) == t && ct && TYPE_MAIN_VARIANT (ct) != ct)
   14493              :    {
   14494              :      /* This can happen when build_type_attribute_variant is called on
   14495              :         C/C++ arrays of qualified types.  volatile int[2] is unqualified
   14496              :         ARRAY_TYPE with volatile int element type.
   14497              :         TYPE_CANONICAL (volatile int) is itself and so is
   14498              :         TYPE_CANONICAL (volatile int[2]).  build_type_attribute_qual_variant
   14499              :         creates a distinct type copy (so TYPE_MAIN_VARIANT is itself) and sets
   14500              :         its TYPE_CANONICAL to the unqualified ARRAY_TYPE (so volatile int[2]).
   14501              :         But this is not the TYPE_MAIN_VARIANT, which is int[2].  So, just
   14502              :         verify that TYPE_MAIN_VARIANT (ct) is already the final type we
   14503              :         need.  */
   14504            2 :       tree mvc = TYPE_MAIN_VARIANT (ct);
   14505            2 :       if (TYPE_CANONICAL (mvc) != mvc)
   14506              :         {
   14507            0 :           error ("main variant of %<TYPE_CANONICAL%> of main variant is not"
   14508              :                  " its own %<TYPE_CANONICAL%>");
   14509            0 :           debug_tree (ct);
   14510            0 :           debug_tree (TYPE_MAIN_VARIANT (ct));
   14511            0 :           error_found = true;
   14512              :         }
   14513              :    }
   14514              : 
   14515              : 
   14516              :   /* Check various uses of TYPE_MIN_VALUE_RAW.  */
   14517    866093412 :   if (RECORD_OR_UNION_TYPE_P (t))
   14518              :     {
   14519              :       /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
   14520              :          and danagle the pointer from time to time.  */
   14521    455549844 :       if (TYPE_VFIELD (t)
   14522     11805297 :           && TREE_CODE (TYPE_VFIELD (t)) != FIELD_DECL
   14523    455549844 :           && TREE_CODE (TYPE_VFIELD (t)) != TREE_LIST)
   14524              :         {
   14525            0 :           error ("%<TYPE_VFIELD%> is not %<FIELD_DECL%> nor %<TREE_LIST%>");
   14526            0 :           debug_tree (TYPE_VFIELD (t));
   14527            0 :           error_found = true;
   14528              :         }
   14529              :     }
   14530    410543568 :   else if (TREE_CODE (t) == POINTER_TYPE)
   14531              :     {
   14532    105646441 :       if (TYPE_NEXT_PTR_TO (t)
   14533    105646441 :           && TREE_CODE (TYPE_NEXT_PTR_TO (t)) != POINTER_TYPE)
   14534              :         {
   14535            0 :           error ("%<TYPE_NEXT_PTR_TO%> is not %<POINTER_TYPE%>");
   14536            0 :           debug_tree (TYPE_NEXT_PTR_TO (t));
   14537            0 :           error_found = true;
   14538              :         }
   14539              :     }
   14540    304897127 :   else if (TREE_CODE (t) == REFERENCE_TYPE)
   14541              :     {
   14542     48135822 :       if (TYPE_NEXT_REF_TO (t)
   14543     48135822 :           && TREE_CODE (TYPE_NEXT_REF_TO (t)) != REFERENCE_TYPE)
   14544              :         {
   14545            0 :           error ("%<TYPE_NEXT_REF_TO%> is not %<REFERENCE_TYPE%>");
   14546            0 :           debug_tree (TYPE_NEXT_REF_TO (t));
   14547            0 :           error_found = true;
   14548              :         }
   14549              :     }
   14550              :   else if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t)
   14551              :            || FIXED_POINT_TYPE_P (t))
   14552              :     {
   14553              :       /* FIXME: The following check should pass:
   14554              :           useless_type_conversion_p (const_cast <tree> (t),
   14555              :                                      TREE_TYPE (TYPE_MIN_VALUE (t))
   14556              :          but does not for C sizetypes in LTO.  */
   14557              :     }
   14558              : 
   14559              :   /* Check various uses of TYPE_MAXVAL_RAW.  */
   14560    866093412 :   if (RECORD_OR_UNION_TYPE_P (t))
   14561              :     {
   14562    455549844 :       if (!TYPE_BINFO (t))
   14563              :         ;
   14564    428051594 :       else if (TREE_CODE (TYPE_BINFO (t)) != TREE_BINFO)
   14565              :         {
   14566            0 :           error ("%<TYPE_BINFO%> is not %<TREE_BINFO%>");
   14567            0 :           debug_tree (TYPE_BINFO (t));
   14568            0 :           error_found = true;
   14569              :         }
   14570    428051594 :       else if (TREE_TYPE (TYPE_BINFO (t)) != TYPE_MAIN_VARIANT (t))
   14571              :         {
   14572            0 :           error ("%<TYPE_BINFO%> type is not %<TYPE_MAIN_VARIANT%>");
   14573            0 :           debug_tree (TREE_TYPE (TYPE_BINFO (t)));
   14574            0 :           error_found = true;
   14575              :         }
   14576              :     }
   14577              :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14578              :     {
   14579       817221 :       if (TYPE_METHOD_BASETYPE (t)
   14580        68143 :           && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != RECORD_TYPE
   14581       817419 :           && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != UNION_TYPE)
   14582              :         {
   14583            0 :           error ("%<TYPE_METHOD_BASETYPE%> is not record nor union");
   14584            0 :           debug_tree (TYPE_METHOD_BASETYPE (t));
   14585            0 :           error_found = true;
   14586              :         }
   14587              :     }
   14588              :   else if (TREE_CODE (t) == OFFSET_TYPE)
   14589              :     {
   14590        33079 :       if (TYPE_OFFSET_BASETYPE (t)
   14591        33079 :           && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != RECORD_TYPE
   14592        33087 :           && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != UNION_TYPE)
   14593              :         {
   14594            0 :           error ("%<TYPE_OFFSET_BASETYPE%> is not record nor union");
   14595            0 :           debug_tree (TYPE_OFFSET_BASETYPE (t));
   14596            0 :           error_found = true;
   14597              :         }
   14598              :     }
   14599              :   else if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t)
   14600              :            || FIXED_POINT_TYPE_P (t))
   14601              :     {
   14602              :       /* FIXME: The following check should pass:
   14603              :           useless_type_conversion_p (const_cast <tree> (t),
   14604              :                                      TREE_TYPE (TYPE_MAX_VALUE (t))
   14605              :          but does not for C sizetypes in LTO.  */
   14606              :     }
   14607              :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14608              :     {
   14609      1694960 :       if (TYPE_ARRAY_MAX_SIZE (t)
   14610      1694960 :           && TREE_CODE (TYPE_ARRAY_MAX_SIZE (t)) != INTEGER_CST)
   14611              :         {
   14612            0 :           error ("%<TYPE_ARRAY_MAX_SIZE%> not %<INTEGER_CST%>");
   14613            0 :           debug_tree (TYPE_ARRAY_MAX_SIZE (t));
   14614            0 :           error_found = true;
   14615              :         }
   14616              :     }
   14617    276228080 :   else if (TYPE_MAX_VALUE_RAW (t))
   14618              :     {
   14619            0 :       error ("%<TYPE_MAX_VALUE_RAW%> non-NULL");
   14620            0 :       debug_tree (TYPE_MAX_VALUE_RAW (t));
   14621            0 :       error_found = true;
   14622              :     }
   14623              : 
   14624    866093412 :   if (TYPE_LANG_SLOT_1 (t) && in_lto_p)
   14625              :     {
   14626            0 :       error ("%<TYPE_LANG_SLOT_1 (binfo)%> field is non-NULL");
   14627            0 :       debug_tree (TYPE_LANG_SLOT_1 (t));
   14628            0 :       error_found = true;
   14629              :     }
   14630              : 
   14631              :   /* Check various uses of TYPE_VALUES_RAW.  */
   14632    866093412 :   if (TREE_CODE (t) == ENUMERAL_TYPE)
   14633     97710871 :     for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l))
   14634              :       {
   14635     84901771 :         tree value = TREE_VALUE (l);
   14636     84901771 :         tree name = TREE_PURPOSE (l);
   14637              : 
   14638              :         /* C FE porduce INTEGER_CST of INTEGER_TYPE, while C++ FE uses
   14639              :            CONST_DECL of ENUMERAL TYPE.  */
   14640     84901771 :         if (TREE_CODE (value) != INTEGER_CST && TREE_CODE (value) != CONST_DECL)
   14641              :           {
   14642            0 :             error ("enum value is not %<CONST_DECL%> or %<INTEGER_CST%>");
   14643            0 :             debug_tree (value);
   14644            0 :             debug_tree (name);
   14645            0 :             error_found = true;
   14646              :           }
   14647     84901771 :         if (TREE_CODE (TREE_TYPE (value)) != INTEGER_TYPE
   14648     84884455 :             && TREE_CODE (TREE_TYPE (value)) != BOOLEAN_TYPE
   14649    169786223 :             && !useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (value)))
   14650              :           {
   14651            0 :             error ("enum value type is not %<INTEGER_TYPE%> nor convertible "
   14652              :                    "to the enum");
   14653            0 :             debug_tree (value);
   14654            0 :             debug_tree (name);
   14655            0 :             error_found = true;
   14656              :           }
   14657     84901771 :         if (TREE_CODE (name) != IDENTIFIER_NODE)
   14658              :           {
   14659            0 :             error ("enum value name is not %<IDENTIFIER_NODE%>");
   14660            0 :             debug_tree (value);
   14661            0 :             debug_tree (name);
   14662            0 :             error_found = true;
   14663              :           }
   14664              :       }
   14665    853284312 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14666              :     {
   14667      1694960 :       if (TYPE_DOMAIN (t) && TREE_CODE (TYPE_DOMAIN (t)) != INTEGER_TYPE)
   14668              :         {
   14669            0 :           error ("array %<TYPE_DOMAIN%> is not integer type");
   14670            0 :           debug_tree (TYPE_DOMAIN (t));
   14671            0 :           error_found = true;
   14672              :         }
   14673              :     }
   14674    851589352 :   else if (RECORD_OR_UNION_TYPE_P (t))
   14675              :     {
   14676    455549844 :       if (TYPE_FIELDS (t) && !COMPLETE_TYPE_P (t) && in_lto_p)
   14677              :         {
   14678            0 :           error ("%<TYPE_FIELDS%> defined in incomplete type");
   14679            0 :           error_found = true;
   14680              :         }
   14681  19612233835 :       for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
   14682              :         {
   14683              :           /* TODO: verify properties of decls.  */
   14684  19156683991 :           if (TREE_CODE (fld) == FIELD_DECL)
   14685              :             ;
   14686              :           else if (TREE_CODE (fld) == TYPE_DECL)
   14687              :             ;
   14688              :           else if (TREE_CODE (fld) == CONST_DECL)
   14689              :             ;
   14690              :           else if (VAR_P (fld))
   14691              :             ;
   14692              :           else if (TREE_CODE (fld) == TEMPLATE_DECL)
   14693              :             ;
   14694              :           else if (TREE_CODE (fld) == USING_DECL)
   14695              :             ;
   14696              :           else if (TREE_CODE (fld) == FUNCTION_DECL)
   14697              :             ;
   14698              :           else
   14699              :             {
   14700            0 :               error ("wrong tree in %<TYPE_FIELDS%> list");
   14701            0 :               debug_tree (fld);
   14702            0 :               error_found = true;
   14703              :             }
   14704              :         }
   14705              :     }
   14706    396039508 :   else if (TREE_CODE (t) == INTEGER_TYPE
   14707              :            || TREE_CODE (t) == BOOLEAN_TYPE
   14708    396039508 :            || TREE_CODE (t) == BITINT_TYPE
   14709    281919068 :            || TREE_CODE (t) == OFFSET_TYPE
   14710    281885989 :            || TREE_CODE (t) == REFERENCE_TYPE
   14711    233750167 :            || TREE_CODE (t) == NULLPTR_TYPE
   14712    233421696 :            || TREE_CODE (t) == POINTER_TYPE)
   14713              :     {
   14714    268264253 :       if (TYPE_CACHED_VALUES_P (t) != (TYPE_CACHED_VALUES (t) != NULL))
   14715              :         {
   14716            0 :           error ("%<TYPE_CACHED_VALUES_P%> is %i while %<TYPE_CACHED_VALUES%> "
   14717              :                  "is %p",
   14718            0 :                  TYPE_CACHED_VALUES_P (t), (void *)TYPE_CACHED_VALUES (t));
   14719            0 :           error_found = true;
   14720              :         }
   14721    268264253 :       else if (TYPE_CACHED_VALUES_P (t) && TREE_CODE (TYPE_CACHED_VALUES (t)) != TREE_VEC)
   14722              :         {
   14723            0 :           error ("%<TYPE_CACHED_VALUES%> is not %<TREE_VEC%>");
   14724            0 :           debug_tree (TYPE_CACHED_VALUES (t));
   14725            0 :           error_found = true;
   14726              :         }
   14727              :       /* Verify just enough of cache to ensure that no one copied it to new type.
   14728              :          All copying should go by copy_node that should clear it.  */
   14729    268264253 :       else if (TYPE_CACHED_VALUES_P (t))
   14730              :         {
   14731              :           int i;
   14732   8020527904 :           for (i = 0; i < TREE_VEC_LENGTH (TYPE_CACHED_VALUES (t)); i++)
   14733   7958677808 :             if (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i)
   14734   7958677808 :                 && TREE_TYPE (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i)) != t)
   14735              :               {
   14736            0 :                 error ("wrong %<TYPE_CACHED_VALUES%> entry");
   14737            0 :                 debug_tree (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i));
   14738            0 :                 error_found = true;
   14739            0 :                 break;
   14740              :               }
   14741              :         }
   14742              :     }
   14743    127775255 :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14744      3067942 :     for (tree l = TYPE_ARG_TYPES (t); l; l = TREE_CHAIN (l))
   14745              :       {
   14746              :         /* C++ FE uses TREE_PURPOSE to store initial values.  */
   14747      2250721 :         if (TREE_PURPOSE (l) && in_lto_p)
   14748              :           {
   14749            0 :             error ("%<TREE_PURPOSE%> is non-NULL in %<TYPE_ARG_TYPES%> list");
   14750            0 :             debug_tree (l);
   14751            0 :             error_found = true;
   14752              :           }
   14753      2250721 :         if (!TYPE_P (TREE_VALUE (l)))
   14754              :           {
   14755            0 :             error ("wrong entry in %<TYPE_ARG_TYPES%> list");
   14756            0 :             debug_tree (l);
   14757            0 :             error_found = true;
   14758              :           }
   14759              :       }
   14760    253592229 :   else if (!is_lang_specific (t) && TYPE_VALUES_RAW (t))
   14761              :     {
   14762            0 :       error ("%<TYPE_VALUES_RAW%> field is non-NULL");
   14763            0 :       debug_tree (TYPE_VALUES_RAW (t));
   14764            0 :       error_found = true;
   14765              :     }
   14766    866093412 :   if (TREE_CODE (t) != INTEGER_TYPE
   14767              :       && TREE_CODE (t) != BOOLEAN_TYPE
   14768    866093412 :       && TREE_CODE (t) != BITINT_TYPE
   14769              :       && TREE_CODE (t) != OFFSET_TYPE
   14770              :       && TREE_CODE (t) != REFERENCE_TYPE
   14771              :       && TREE_CODE (t) != NULLPTR_TYPE
   14772              :       && TREE_CODE (t) != POINTER_TYPE
   14773    597829159 :       && TYPE_CACHED_VALUES_P (t))
   14774              :     {
   14775            0 :       error ("%<TYPE_CACHED_VALUES_P%> is set while it should not be");
   14776            0 :       error_found = true;
   14777              :     }
   14778              : 
   14779              :   /* ipa-devirt makes an assumption that TYPE_METHOD_BASETYPE is always
   14780              :      TYPE_MAIN_VARIANT and it would be odd to add methods only to variatns
   14781              :      of a type. */
   14782    866093412 :   if (TREE_CODE (t) == METHOD_TYPE
   14783    866093412 :       && TYPE_MAIN_VARIANT (TYPE_METHOD_BASETYPE (t)) != TYPE_METHOD_BASETYPE (t))
   14784              :     {
   14785            0 :         error ("%<TYPE_METHOD_BASETYPE%> is not main variant");
   14786            0 :         error_found = true;
   14787              :     }
   14788              : 
   14789    866093412 :   if (error_found)
   14790              :     {
   14791            0 :       debug_tree (const_cast <tree> (t));
   14792            0 :       internal_error ("%qs failed", __func__);
   14793              :     }
   14794              : }
   14795              : 
   14796              : 
   14797              : /* Return 1 if ARG interpreted as signed in its precision is known to be
   14798              :    always non-negative or 2 if ARG is known to be always negative, or 3 if
   14799              :    ARG may be non-negative or negative.  STMT if specified is the statement
   14800              :    on which it is being tested.  */
   14801              : 
   14802              : int
   14803       831029 : get_range_pos_neg (tree arg, gimple *stmt)
   14804              : {
   14805       831029 :   if (arg == error_mark_node || !INTEGRAL_TYPE_P (TREE_TYPE (arg)))
   14806              :     return 3;
   14807              : 
   14808       831029 :   int prec = TYPE_PRECISION (TREE_TYPE (arg));
   14809       831029 :   int cnt = 0;
   14810       831029 :   if (TREE_CODE (arg) == INTEGER_CST)
   14811              :     {
   14812        73734 :       wide_int w = wi::sext (wi::to_wide (arg), prec);
   14813        73734 :       if (wi::neg_p (w))
   14814              :         return 2;
   14815              :       else
   14816        59271 :         return 1;
   14817        73734 :     }
   14818       756082 :   while (CONVERT_EXPR_P (arg)
   14819        14467 :          && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
   14820       785016 :          && TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg, 0))) <= prec)
   14821              :     {
   14822        13683 :       arg = TREE_OPERAND (arg, 0);
   14823              :       /* Narrower value zero extended into wider type
   14824              :          will always result in positive values.  */
   14825        13683 :       if (TYPE_UNSIGNED (TREE_TYPE (arg))
   14826        13683 :           && TYPE_PRECISION (TREE_TYPE (arg)) < prec)
   14827              :         return 1;
   14828        13254 :       prec = TYPE_PRECISION (TREE_TYPE (arg));
   14829        13254 :       if (++cnt > 30)
   14830              :         return 3;
   14831              :     }
   14832              : 
   14833       756866 :   if (TREE_CODE (arg) != SSA_NAME)
   14834              :     return 3;
   14835       750250 :   int_range_max r;
   14836      1514683 :   while (!get_range_query (cfun)->range_of_expr (r, arg, stmt)
   14837      1528866 :          || r.undefined_p () || r.varying_p ())
   14838              :     {
   14839       486761 :       gimple *g = SSA_NAME_DEF_STMT (arg);
   14840       486761 :       if (is_gimple_assign (g)
   14841       486761 :           && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (g)))
   14842              :         {
   14843        23350 :           tree t = gimple_assign_rhs1 (g);
   14844        46373 :           if (INTEGRAL_TYPE_P (TREE_TYPE (t))
   14845        43856 :               && TYPE_PRECISION (TREE_TYPE (t)) <= prec)
   14846              :             {
   14847        14183 :               if (TYPE_UNSIGNED (TREE_TYPE (t))
   14848        14183 :                   && TYPE_PRECISION (TREE_TYPE (t)) < prec)
   14849              :                 return 1;
   14850        14183 :               prec = TYPE_PRECISION (TREE_TYPE (t));
   14851        14183 :               arg = t;
   14852        14183 :               if (++cnt > 30)
   14853              :                 return 3;
   14854        14183 :               continue;
   14855              :             }
   14856              :         }
   14857              :       return 3;
   14858              :     }
   14859       277672 :   if (TYPE_UNSIGNED (TREE_TYPE (arg)))
   14860              :     {
   14861              :       /* For unsigned values, the "positive" range comes
   14862              :          below the "negative" range.  */
   14863       113457 :       if (!wi::neg_p (wi::sext (r.upper_bound (), prec), SIGNED))
   14864              :         return 1;
   14865        32178 :       if (wi::neg_p (wi::sext (r.lower_bound (), prec), SIGNED))
   14866              :         return 2;
   14867              :     }
   14868              :   else
   14869              :     {
   14870       164215 :       if (!wi::neg_p (wi::sext (r.lower_bound (), prec), SIGNED))
   14871              :         return 1;
   14872        69446 :       if (wi::neg_p (wi::sext (r.upper_bound (), prec), SIGNED))
   14873              :         return 2;
   14874              :     }
   14875              :   return 3;
   14876       750250 : }
   14877              : 
   14878              : 
   14879              : 
   14880              : 
   14881              : /* Return true if ARG is marked with the nonnull attribute in the
   14882              :    current function signature.  */
   14883              : 
   14884              : bool
   14885     26026397 : nonnull_arg_p (const_tree arg)
   14886              : {
   14887     26026397 :   tree t, attrs, fntype;
   14888     26026397 :   unsigned HOST_WIDE_INT arg_num;
   14889              : 
   14890     26026397 :   gcc_assert (TREE_CODE (arg) == PARM_DECL
   14891              :               && (POINTER_TYPE_P (TREE_TYPE (arg))
   14892              :                   || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE));
   14893              : 
   14894              :   /* The static chain decl is always non null.  */
   14895     26026397 :   if (arg == cfun->static_chain_decl)
   14896              :     return true;
   14897              : 
   14898              :   /* THIS argument of method is always non-NULL.  */
   14899     25757335 :   if (TREE_CODE (TREE_TYPE (cfun->decl)) == METHOD_TYPE
   14900      9632306 :       && arg == DECL_ARGUMENTS (cfun->decl)
   14901     31826221 :       && flag_delete_null_pointer_checks)
   14902              :     return true;
   14903              : 
   14904              :   /* Values passed by reference are always non-NULL.  */
   14905     19690527 :   if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE
   14906     19690527 :       && flag_delete_null_pointer_checks)
   14907              :     return true;
   14908              : 
   14909     13691705 :   fntype = TREE_TYPE (cfun->decl);
   14910     13714682 :   for (attrs = TYPE_ATTRIBUTES (fntype); attrs; attrs = TREE_CHAIN (attrs))
   14911              :     {
   14912       548459 :       attrs = lookup_attribute ("nonnull", attrs);
   14913              : 
   14914              :       /* If "nonnull" wasn't specified, we know nothing about the argument.  */
   14915       548459 :       if (attrs == NULL_TREE)
   14916              :         return false;
   14917              : 
   14918              :       /* If "nonnull" applies to all the arguments, then ARG is non-null.  */
   14919       113282 :       if (TREE_VALUE (attrs) == NULL_TREE)
   14920              :         return true;
   14921              : 
   14922              :       /* Get the position number for ARG in the function signature.  */
   14923        56212 :       for (arg_num = 1, t = DECL_ARGUMENTS (cfun->decl);
   14924       130733 :            t;
   14925        74521 :            t = DECL_CHAIN (t), arg_num++)
   14926              :         {
   14927       130733 :           if (t == arg)
   14928              :             break;
   14929              :         }
   14930              : 
   14931        56212 :       gcc_assert (t == arg);
   14932              : 
   14933              :       /* Now see if ARG_NUM is mentioned in the nonnull list.  */
   14934        88932 :       for (t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t))
   14935              :         {
   14936        65955 :           if (compare_tree_int (TREE_VALUE (t), arg_num) == 0)
   14937              :             return true;
   14938              :         }
   14939              :     }
   14940              : 
   14941              :   return false;
   14942              : }
   14943              : 
   14944              : /* Combine LOC and BLOCK to a combined adhoc loc, retaining any range
   14945              :    information.  */
   14946              : 
   14947              : location_t
   14948    889727431 : set_block (location_t loc, tree block)
   14949              : {
   14950    889727431 :   location_t pure_loc = get_pure_location (loc);
   14951    889727431 :   source_range src_range = get_range_from_loc (line_table, loc);
   14952    889727431 :   unsigned discriminator = get_discriminator_from_loc (line_table, loc);
   14953    889727431 :   return line_table->get_or_create_combined_loc (pure_loc, src_range, block,
   14954    889727431 :                                                  discriminator);
   14955              : }
   14956              : 
   14957              : location_t
   14958    221941489 : set_source_range (tree expr, location_t start, location_t finish)
   14959              : {
   14960    221941489 :   source_range src_range;
   14961    221941489 :   src_range.m_start = start;
   14962    221941489 :   src_range.m_finish = finish;
   14963    221941489 :   return set_source_range (expr, src_range);
   14964              : }
   14965              : 
   14966              : location_t
   14967    453364338 : set_source_range (tree expr, source_range src_range)
   14968              : {
   14969    453364338 :   if (!EXPR_P (expr))
   14970              :     return UNKNOWN_LOCATION;
   14971              : 
   14972    199586923 :   location_t expr_location = EXPR_LOCATION (expr);
   14973    199586923 :   location_t pure_loc = get_pure_location (expr_location);
   14974    199586923 :   unsigned discriminator = get_discriminator_from_loc (expr_location);
   14975    199586923 :   location_t adhoc = line_table->get_or_create_combined_loc (pure_loc,
   14976              :                                                              src_range,
   14977              :                                                              nullptr,
   14978              :                                                              discriminator);
   14979    199586923 :   SET_EXPR_LOCATION (expr, adhoc);
   14980    199586923 :   return adhoc;
   14981              : }
   14982              : 
   14983              : /* Return EXPR, potentially wrapped with a node expression LOC,
   14984              :    if !CAN_HAVE_LOCATION_P (expr).
   14985              : 
   14986              :    NON_LVALUE_EXPR is used for wrapping constants, apart from STRING_CST.
   14987              :    VIEW_CONVERT_EXPR is used for wrapping non-constants and STRING_CST.
   14988              : 
   14989              :    Wrapper nodes can be identified using location_wrapper_p.  */
   14990              : 
   14991              : tree
   14992   1521911227 : maybe_wrap_with_location (tree expr, location_t loc)
   14993              : {
   14994   1521911227 :   if (expr == NULL)
   14995              :     return NULL;
   14996   1521911223 :   if (loc == UNKNOWN_LOCATION)
   14997              :     return expr;
   14998   1470352183 :   if (CAN_HAVE_LOCATION_P (expr))
   14999              :     return expr;
   15000              :   /* We should only be adding wrappers for constants and for decls,
   15001              :      or for some exceptional tree nodes (e.g. BASELINK in the C++ FE).  */
   15002    896633922 :   gcc_assert (CONSTANT_CLASS_P (expr)
   15003              :               || DECL_P (expr)
   15004              :               || EXCEPTIONAL_CLASS_P (expr));
   15005              : 
   15006              :   /* For now, don't add wrappers to exceptional tree nodes, to minimize
   15007              :      any impact of the wrapper nodes.  */
   15008    896633922 :   if (EXCEPTIONAL_CLASS_P (expr) || error_operand_p (expr))
   15009              :     return expr;
   15010              : 
   15011              :   /* Compiler-generated temporary variables don't need a wrapper.  */
   15012    827803122 :   if (DECL_P (expr) && DECL_ARTIFICIAL (expr) && DECL_IGNORED_P (expr))
   15013              :     return expr;
   15014              : 
   15015              :   /* If any auto_suppress_location_wrappers are active, don't create
   15016              :      wrappers.  */
   15017    827800683 :   if (suppress_location_wrappers > 0)
   15018              :     return expr;
   15019              : 
   15020   1547691302 :   tree_code code
   15021    204177170 :     = (((CONSTANT_CLASS_P (expr) && TREE_CODE (expr) != STRING_CST)
   15022    578399117 :         || (TREE_CODE (expr) == CONST_DECL && !TREE_STATIC (expr)))
   15023    773845651 :        ? NON_LVALUE_EXPR : VIEW_CONVERT_EXPR);
   15024    773845651 :   tree wrapper = build1_loc (loc, code, TREE_TYPE (expr), expr);
   15025              :   /* Mark this node as being a wrapper.  */
   15026    773845651 :   EXPR_LOCATION_WRAPPER_P (wrapper) = 1;
   15027    773845651 :   return wrapper;
   15028              : }
   15029              : 
   15030              : int suppress_location_wrappers;
   15031              : 
   15032              : /* Return the name of combined function FN, for debugging purposes.  */
   15033              : 
   15034              : const char *
   15035            0 : combined_fn_name (combined_fn fn)
   15036              : {
   15037            0 :   if (builtin_fn_p (fn))
   15038              :     {
   15039            0 :       tree fndecl = builtin_decl_explicit (as_builtin_fn (fn));
   15040            0 :       return IDENTIFIER_POINTER (DECL_NAME (fndecl));
   15041              :     }
   15042              :   else
   15043            0 :     return internal_fn_name (as_internal_fn (fn));
   15044              : }
   15045              : 
   15046              : /* Return a bitmap with a bit set corresponding to each argument in
   15047              :    a function call type FNTYPE declared with attribute nonnull,
   15048              :    or null if none of the function's argument are nonnull.  The caller
   15049              :    must free the bitmap.  */
   15050              : 
   15051              : bitmap
   15052     21320833 : get_nonnull_args (const_tree fntype)
   15053              : {
   15054     21320833 :   if (fntype == NULL_TREE)
   15055              :     return NULL;
   15056              : 
   15057     20721937 :   bitmap argmap = NULL;
   15058     20721937 :   if (TREE_CODE (fntype) == METHOD_TYPE)
   15059              :     {
   15060              :       /* The this pointer in C++ non-static member functions is
   15061              :          implicitly nonnull whether or not it's declared as such.  */
   15062      2593476 :       argmap = BITMAP_ALLOC (NULL);
   15063      2593476 :       bitmap_set_bit (argmap, 0);
   15064              :     }
   15065              : 
   15066     20721937 :   tree attrs = TYPE_ATTRIBUTES (fntype);
   15067     20721937 :   if (!attrs)
   15068              :     return argmap;
   15069              : 
   15070              :   /* A function declaration can specify multiple attribute nonnull,
   15071              :      each with zero or more arguments.  The loop below creates a bitmap
   15072              :      representing a union of all the arguments.  An empty (but non-null)
   15073              :      bitmap means that all arguments have been declared nonnull.  */
   15074      5904552 :   for ( ; attrs; attrs = TREE_CHAIN (attrs))
   15075              :     {
   15076      5799288 :       attrs = lookup_attribute ("nonnull", attrs);
   15077      5799288 :       if (!attrs)
   15078              :         break;
   15079              : 
   15080      1610261 :       if (!argmap)
   15081      1570579 :         argmap = BITMAP_ALLOC (NULL);
   15082              : 
   15083      1610261 :       if (!TREE_VALUE (attrs))
   15084              :         {
   15085              :           /* Clear the bitmap in case a previous attribute nonnull
   15086              :              set it and this one overrides it for all arguments.  */
   15087       983948 :           bitmap_clear (argmap);
   15088       983948 :           return argmap;
   15089              :         }
   15090              : 
   15091              :       /* Iterate over the indices of the format arguments declared nonnull
   15092              :          and set a bit for each.  */
   15093      1638376 :       for (tree idx = TREE_VALUE (attrs); idx; idx = TREE_CHAIN (idx))
   15094              :         {
   15095      1012063 :           unsigned int val = TREE_INT_CST_LOW (TREE_VALUE (idx)) - 1;
   15096      1012063 :           bitmap_set_bit (argmap, val);
   15097              :         }
   15098              :     }
   15099              : 
   15100              :   return argmap;
   15101              : }
   15102              : 
   15103              : /* Returns true if TYPE is a type where it and all of its subobjects
   15104              :    (recursively) are of structure, union, or array type.  */
   15105              : 
   15106              : bool
   15107   1951975060 : is_empty_type (const_tree type)
   15108              : {
   15109   1951975060 :   if (RECORD_OR_UNION_TYPE_P (type))
   15110              :     {
   15111    852494651 :       for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
   15112    783995812 :         if (TREE_CODE (field) == FIELD_DECL
   15113    402347029 :             && !DECL_PADDING_P (field)
   15114   1186341520 :             && !is_empty_type (TREE_TYPE (field)))
   15115              :           return false;
   15116              :       return true;
   15117              :     }
   15118   1507824026 :   else if (TREE_CODE (type) == ARRAY_TYPE)
   15119     84525517 :     return (integer_minus_onep (array_type_nelts_minus_one (type))
   15120     84481622 :             || TYPE_DOMAIN (type) == NULL_TREE
   15121    159231275 :             || is_empty_type (TREE_TYPE (type)));
   15122              :   return false;
   15123              : }
   15124              : 
   15125              : /* Implement TARGET_EMPTY_RECORD_P.  Return true if TYPE is an empty type
   15126              :    that shouldn't be passed via stack.  */
   15127              : 
   15128              : bool
   15129   1424107672 : default_is_empty_record (const_tree type)
   15130              : {
   15131   1424107672 :   if (!abi_version_at_least (12))
   15132              :     return false;
   15133              : 
   15134   1423059660 :   if (type == error_mark_node)
   15135              :     return false;
   15136              : 
   15137   1423059660 :   if (TREE_ADDRESSABLE (type))
   15138              :     return false;
   15139              : 
   15140   1423059660 :   return is_empty_type (TYPE_MAIN_VARIANT (type));
   15141              : }
   15142              : 
   15143              : /* Determine whether TYPE is a structure with a flexible array member,
   15144              :    or a union containing such a structure (possibly recursively).  */
   15145              : 
   15146              : bool
   15147        72157 : flexible_array_type_p (const_tree type)
   15148              : {
   15149        72157 :   tree x, last;
   15150        72157 :   switch (TREE_CODE (type))
   15151              :     {
   15152        37901 :     case RECORD_TYPE:
   15153        37901 :       last = NULL_TREE;
   15154       173140 :       for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
   15155       135239 :         if (TREE_CODE (x) == FIELD_DECL)
   15156       135239 :           last = x;
   15157        37901 :       if (last == NULL_TREE)
   15158              :         return false;
   15159        37893 :       if (TREE_CODE (TREE_TYPE (last)) == ARRAY_TYPE
   15160          518 :           && TYPE_SIZE (TREE_TYPE (last)) == NULL_TREE
   15161          289 :           && TYPE_DOMAIN (TREE_TYPE (last)) != NULL_TREE
   15162        38182 :           && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (last))) == NULL_TREE)
   15163              :         return true;
   15164              :       return false;
   15165          579 :     case UNION_TYPE:
   15166         1668 :       for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
   15167              :         {
   15168         1131 :           if (TREE_CODE (x) == FIELD_DECL
   15169         1131 :               && flexible_array_type_p (TREE_TYPE (x)))
   15170              :             return true;
   15171              :         }
   15172              :       return false;
   15173              :     default:
   15174              :       return false;
   15175              :   }
   15176              : }
   15177              : 
   15178              : /* Like int_size_in_bytes, but handle empty records specially.  */
   15179              : 
   15180              : HOST_WIDE_INT
   15181       458361 : arg_int_size_in_bytes (const_tree type)
   15182              : {
   15183       458361 :   return TYPE_EMPTY_P (type) ? 0 : int_size_in_bytes (type);
   15184              : }
   15185              : 
   15186              : /* Like size_in_bytes, but handle empty records specially.  */
   15187              : 
   15188              : tree
   15189      5676908 : arg_size_in_bytes (const_tree type)
   15190              : {
   15191      5676908 :   return TYPE_EMPTY_P (type) ? size_zero_node : size_in_bytes (type);
   15192              : }
   15193              : 
   15194              : /* Return true if an expression with CODE has to have the same result type as
   15195              :    its first operand.  */
   15196              : 
   15197              : bool
   15198            0 : expr_type_first_operand_type_p (tree_code code)
   15199              : {
   15200            0 :   switch (code)
   15201              :     {
   15202              :     case NEGATE_EXPR:
   15203              :     case ABS_EXPR:
   15204              :     case BIT_NOT_EXPR:
   15205              :     case PAREN_EXPR:
   15206              :     case CONJ_EXPR:
   15207              : 
   15208              :     case PLUS_EXPR:
   15209              :     case MINUS_EXPR:
   15210              :     case MULT_EXPR:
   15211              :     case TRUNC_DIV_EXPR:
   15212              :     case CEIL_DIV_EXPR:
   15213              :     case FLOOR_DIV_EXPR:
   15214              :     case ROUND_DIV_EXPR:
   15215              :     case TRUNC_MOD_EXPR:
   15216              :     case CEIL_MOD_EXPR:
   15217              :     case FLOOR_MOD_EXPR:
   15218              :     case ROUND_MOD_EXPR:
   15219              :     case RDIV_EXPR:
   15220              :     case EXACT_DIV_EXPR:
   15221              :     case MIN_EXPR:
   15222              :     case MAX_EXPR:
   15223              :     case BIT_IOR_EXPR:
   15224              :     case BIT_XOR_EXPR:
   15225              :     case BIT_AND_EXPR:
   15226              : 
   15227              :     case LSHIFT_EXPR:
   15228              :     case RSHIFT_EXPR:
   15229              :     case LROTATE_EXPR:
   15230              :     case RROTATE_EXPR:
   15231              :       return true;
   15232              : 
   15233            0 :     default:
   15234            0 :       return false;
   15235              :     }
   15236              : }
   15237              : 
   15238              : /* Return a typenode for the "standard" C type with a given name.  */
   15239              : tree
   15240       923523 : get_typenode_from_name (const char *name)
   15241              : {
   15242       923523 :   if (name == NULL || *name == '\0')
   15243              :     return NULL_TREE;
   15244              : 
   15245       923523 :   if (strcmp (name, "char") == 0)
   15246            0 :     return char_type_node;
   15247       923523 :   if (strcmp (name, "unsigned char") == 0)
   15248        95349 :     return unsigned_char_type_node;
   15249       828174 :   if (strcmp (name, "signed char") == 0)
   15250        95349 :     return signed_char_type_node;
   15251              : 
   15252       732825 :   if (strcmp (name, "short int") == 0)
   15253        65082 :     return short_integer_type_node;
   15254       667743 :   if (strcmp (name, "short unsigned int") == 0)
   15255        63566 :     return short_unsigned_type_node;
   15256              : 
   15257       604177 :   if (strcmp (name, "int") == 0)
   15258        65901 :     return integer_type_node;
   15259       538276 :   if (strcmp (name, "unsigned int") == 0)
   15260        64380 :     return unsigned_type_node;
   15261              : 
   15262       473896 :   if (strcmp (name, "long int") == 0)
   15263       282384 :     return long_integer_type_node;
   15264       191512 :   if (strcmp (name, "long unsigned int") == 0)
   15265       188256 :     return long_unsigned_type_node;
   15266              : 
   15267         3256 :   if (strcmp (name, "long long int") == 0)
   15268         1628 :     return long_long_integer_type_node;
   15269         1628 :   if (strcmp (name, "long long unsigned int") == 0)
   15270         1628 :     return long_long_unsigned_type_node;
   15271              : 
   15272            0 :   gcc_unreachable ();
   15273              : }
   15274              : 
   15275              : /* List of pointer types used to declare builtins before we have seen their
   15276              :    real declaration.
   15277              : 
   15278              :    Keep the size up to date in tree.h !  */
   15279              : const builtin_structptr_type builtin_structptr_types[6] =
   15280              : {
   15281              :   { fileptr_type_node, ptr_type_node, "FILE" },
   15282              :   { const_tm_ptr_type_node, const_ptr_type_node, "tm" },
   15283              :   { fenv_t_ptr_type_node, ptr_type_node, "fenv_t" },
   15284              :   { const_fenv_t_ptr_type_node, const_ptr_type_node, "fenv_t" },
   15285              :   { fexcept_t_ptr_type_node, ptr_type_node, "fexcept_t" },
   15286              :   { const_fexcept_t_ptr_type_node, const_ptr_type_node, "fexcept_t" }
   15287              : };
   15288              : 
   15289              : /* Return the maximum object size.  */
   15290              : 
   15291              : tree
   15292      7304815 : max_object_size (void)
   15293              : {
   15294              :   /* To do: Make this a configurable parameter.  */
   15295      7304815 :   return TYPE_MAX_VALUE (ptrdiff_type_node);
   15296              : }
   15297              : 
   15298              : /* A wrapper around TARGET_VERIFY_TYPE_CONTEXT that makes the silent_p
   15299              :    parameter default to false and that weeds out error_mark_node.  */
   15300              : 
   15301              : bool
   15302    147007631 : verify_type_context (location_t loc, type_context_kind context,
   15303              :                      const_tree type, bool silent_p)
   15304              : {
   15305    147007631 :   if (type == error_mark_node)
   15306              :     return true;
   15307              : 
   15308    147007535 :   gcc_assert (TYPE_P (type));
   15309    147007535 :   return (!targetm.verify_type_context
   15310    147007535 :           || targetm.verify_type_context (loc, context, type, silent_p));
   15311              : }
   15312              : 
   15313              : /* Callback of walk_tree telling whether the current tree pointed by TP is the
   15314              :    one provided as DATA.  */
   15315              : 
   15316              : static tree
   15317         4662 : find_tree_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, void *data)
   15318              : {
   15319         4662 :   if (*tp == data)
   15320              :     return (tree) data;
   15321              :   else
   15322         4590 :     return NULL;
   15323              : }
   15324              : 
   15325              : /* Return whether SEARCH is a subtree of TOP.  */
   15326              : 
   15327              : bool
   15328         3689 : find_tree (tree top, tree search)
   15329              : {
   15330         3689 :   return walk_tree_without_duplicates (&top, find_tree_1, search) != 0;
   15331              : }
   15332              : 
   15333              : /* Return true if NEW_ASM and DELETE_ASM name a valid pair of new and
   15334              :    delete operators.  Return false if they may or may not name such
   15335              :    a pair and, when nonnull, set *PCERTAIN to true if they certainly
   15336              :    do not.  */
   15337              : 
   15338              : bool
   15339        59768 : valid_new_delete_pair_p (tree new_asm, tree delete_asm,
   15340              :                          bool *pcertain /* = NULL */)
   15341              : {
   15342        59768 :   bool certain;
   15343        59768 :   if (!pcertain)
   15344        48388 :     pcertain = &certain;
   15345              : 
   15346        59768 :   const char *new_name = IDENTIFIER_POINTER (new_asm);
   15347        59768 :   const char *delete_name = IDENTIFIER_POINTER (delete_asm);
   15348        59768 :   unsigned int new_len = IDENTIFIER_LENGTH (new_asm);
   15349        59768 :   unsigned int delete_len = IDENTIFIER_LENGTH (delete_asm);
   15350              : 
   15351              :   /* The following failures are due to invalid names so they're not
   15352              :      considered certain mismatches.  */
   15353        59768 :   *pcertain = false;
   15354              : 
   15355        59768 :   if (new_len < 5 || delete_len < 6)
   15356              :     return false;
   15357        59768 :   if (new_name[0] == '_')
   15358        59696 :     ++new_name, --new_len;
   15359        59768 :   if (new_name[0] == '_')
   15360            0 :     ++new_name, --new_len;
   15361        59768 :   if (delete_name[0] == '_')
   15362        59768 :     ++delete_name, --delete_len;
   15363        59768 :   if (delete_name[0] == '_')
   15364            0 :     ++delete_name, --delete_len;
   15365        59768 :   if (new_len < 4 || delete_len < 5)
   15366              :     return false;
   15367              : 
   15368              :   /* The following failures are due to names of user-defined operators
   15369              :      so they're also not considered certain mismatches.  */
   15370              : 
   15371              :   /* *_len is now just the length after initial underscores.  */
   15372        59768 :   if (new_name[0] != 'Z' || new_name[1] != 'n')
   15373              :     return false;
   15374        59095 :   if (delete_name[0] != 'Z' || delete_name[1] != 'd')
   15375              :     return false;
   15376              : 
   15377              :   /* The following failures are certain mismatches.  */
   15378        59019 :   *pcertain = true;
   15379              : 
   15380              :   /* _Znw must match _Zdl, _Zna must match _Zda.  */
   15381        59019 :   if ((new_name[2] != 'w' || delete_name[2] != 'l')
   15382         5079 :       && (new_name[2] != 'a' || delete_name[2] != 'a'))
   15383              :     return false;
   15384        58923 :   if (new_name[3] == 'I' || delete_name[3] == 'I')
   15385              :     {
   15386              :       /* When ::operator new or ::operator delete are function templates,
   15387              :          return uncertain mismatch, we need demangler in that case.  */
   15388            6 :       *pcertain = false;
   15389            6 :       return false;
   15390              :     }
   15391              :   /* 'j', 'm' and 'y' correspond to size_t.  */
   15392        58917 :   if (new_name[3] != 'j' && new_name[3] != 'm' && new_name[3] != 'y')
   15393              :     return false;
   15394        58917 :   if (delete_name[3] != 'P' || delete_name[4] != 'v')
   15395              :     return false;
   15396        58917 :   if (new_len == 4
   15397          370 :       || (new_len == 18 && !memcmp (new_name + 4, "RKSt9nothrow_t", 14)))
   15398              :     {
   15399              :       /* _ZnXY or _ZnXYRKSt9nothrow_t matches
   15400              :          _ZdXPv, _ZdXPvY and _ZdXPvRKSt9nothrow_t.  */
   15401        58715 :       if (delete_len == 5)
   15402              :         return true;
   15403        52111 :       if (delete_len == 6 && delete_name[5] == new_name[3])
   15404              :         return true;
   15405           39 :       if (delete_len == 19 && !memcmp (delete_name + 5, "RKSt9nothrow_t", 14))
   15406              :         return true;
   15407              :     }
   15408          202 :   else if ((new_len == 19 && !memcmp (new_name + 4, "St11align_val_t", 15))
   15409           42 :            || (new_len == 33
   15410           10 :                && !memcmp (new_name + 4, "St11align_val_tRKSt9nothrow_t", 29)))
   15411              :     {
   15412              :       /* _ZnXYSt11align_val_t or _ZnXYSt11align_val_tRKSt9nothrow_t matches
   15413              :          _ZdXPvSt11align_val_t or _ZdXPvYSt11align_val_t or
   15414              :          _ZdXPvSt11align_val_tRKSt9nothrow_t.  */
   15415          170 :       if (delete_len == 20 && !memcmp (delete_name + 5, "St11align_val_t", 15))
   15416              :         return true;
   15417           54 :       if (delete_len == 21
   15418           39 :           && delete_name[5] == new_name[3]
   15419           39 :           && !memcmp (delete_name + 6, "St11align_val_t", 15))
   15420              :         return true;
   15421           15 :       if (delete_len == 34
   15422            9 :           && !memcmp (delete_name + 5, "St11align_val_tRKSt9nothrow_t", 29))
   15423              :         return true;
   15424              :     }
   15425              : 
   15426              :   /* The negative result is conservative.  */
   15427           38 :   *pcertain = false;
   15428           38 :   return false;
   15429              : }
   15430              : 
   15431              : /* Return the zero-based number corresponding to the argument being
   15432              :    deallocated if FNDECL is a deallocation function or an out-of-bounds
   15433              :    value if it isn't.  */
   15434              : 
   15435              : unsigned
   15436     22605747 : fndecl_dealloc_argno (tree fndecl)
   15437              : {
   15438              :   /* A call to operator delete isn't recognized as one to a built-in.  */
   15439     22605747 :   if (DECL_IS_OPERATOR_DELETE_P (fndecl))
   15440              :     {
   15441       320545 :       if (DECL_IS_REPLACEABLE_OPERATOR (fndecl))
   15442              :         return 0;
   15443              : 
   15444              :       /* Avoid placement delete that's not been inlined.  */
   15445        25008 :       tree fname = DECL_ASSEMBLER_NAME (fndecl);
   15446        25008 :       if (id_equal (fname, "_ZdlPvS_")       // ordinary form
   15447        25008 :           || id_equal (fname, "_ZdaPvS_"))   // array form
   15448              :         return UINT_MAX;
   15449              :       return 0;
   15450              :     }
   15451              : 
   15452              :   /* TODO: Handle user-defined functions with attribute malloc?  Handle
   15453              :      known non-built-ins like fopen?  */
   15454     22285202 :   if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
   15455              :     {
   15456      5535044 :       switch (DECL_FUNCTION_CODE (fndecl))
   15457              :         {
   15458              :         case BUILT_IN_FREE:
   15459              :         case BUILT_IN_REALLOC:
   15460              :         case BUILT_IN_GOMP_FREE:
   15461              :         case BUILT_IN_GOMP_REALLOC:
   15462              :           return 0;
   15463              :         default:
   15464              :           break;
   15465              :         }
   15466              :       return UINT_MAX;
   15467              :     }
   15468              : 
   15469     16750158 :   tree attrs = DECL_ATTRIBUTES (fndecl);
   15470     16750158 :   if (!attrs)
   15471              :     return UINT_MAX;
   15472              : 
   15473            0 :   for (tree atfree = attrs;
   15474      3819620 :        (atfree = lookup_attribute ("*dealloc", atfree));
   15475            0 :        atfree = TREE_CHAIN (atfree))
   15476              :     {
   15477         4929 :       tree alloc = TREE_VALUE (atfree);
   15478         4929 :       if (!alloc)
   15479            0 :         continue;
   15480              : 
   15481         4929 :       tree pos = TREE_CHAIN (alloc);
   15482         4929 :       if (!pos)
   15483              :         return 0;
   15484              : 
   15485         2766 :       pos = TREE_VALUE (pos);
   15486         2766 :       return TREE_INT_CST_LOW (pos) - 1;
   15487              :     }
   15488              : 
   15489              :   return UINT_MAX;
   15490              : }
   15491              : 
   15492              : /* If EXPR refers to a character array or pointer declared attribute
   15493              :    nonstring, return a decl for that array or pointer and set *REF
   15494              :    to the referenced enclosing object or pointer.  Otherwise return
   15495              :    null.  */
   15496              : 
   15497              : tree
   15498      1394353 : get_attr_nonstring_decl (tree expr, tree *ref)
   15499              : {
   15500      1400023 :   tree decl = expr;
   15501      1400023 :   tree var = NULL_TREE;
   15502      1400023 :   if (TREE_CODE (decl) == SSA_NAME)
   15503              :     {
   15504       834883 :       gimple *def = SSA_NAME_DEF_STMT (decl);
   15505              : 
   15506       834883 :       if (is_gimple_assign (def))
   15507              :         {
   15508        44131 :           tree_code code = gimple_assign_rhs_code (def);
   15509        44131 :           if (code == ADDR_EXPR
   15510        44131 :               || code == COMPONENT_REF
   15511        30020 :               || code == VAR_DECL)
   15512        18966 :             decl = gimple_assign_rhs1 (def);
   15513              :         }
   15514              :       else
   15515       790752 :         var = SSA_NAME_VAR (decl);
   15516              :     }
   15517              : 
   15518      1400023 :   if (TREE_CODE (decl) == ADDR_EXPR)
   15519        26019 :     decl = TREE_OPERAND (decl, 0);
   15520              : 
   15521              :   /* To simplify calling code, store the referenced DECL regardless of
   15522              :      the attribute determined below, but avoid storing the SSA_NAME_VAR
   15523              :      obtained above (it's not useful for dataflow purposes).  */
   15524      1400023 :   if (ref)
   15525         5463 :     *ref = decl;
   15526              : 
   15527              :   /* Use the SSA_NAME_VAR that was determined above to see if it's
   15528              :      declared nonstring.  Otherwise drill down into the referenced
   15529              :      DECL.  */
   15530      1400023 :   if (var)
   15531              :     decl = var;
   15532              :   else
   15533              :     {
   15534       634349 :       while (TREE_CODE (decl) == ARRAY_REF)
   15535        18627 :         decl = TREE_OPERAND (decl, 0);
   15536       615722 :       if (TREE_CODE (decl) == COMPONENT_REF)
   15537        15936 :         decl = TREE_OPERAND (decl, 1);
   15538       599786 :       else if (TREE_CODE (decl) == MEM_REF)
   15539         5670 :         return get_attr_nonstring_decl (TREE_OPERAND (decl, 0), ref);
   15540              :     }
   15541              : 
   15542      1394353 :   if (DECL_P (decl) && lookup_attribute ("nonstring", DECL_ATTRIBUTES (decl)))
   15543              :     return decl;
   15544              : 
   15545              :   return NULL_TREE;
   15546              : }
   15547              : 
   15548              : /* Returns an auto_vec of string_slices containing the version strings from
   15549              :    ARGLIST.  DEFAULT_COUNT is incremented for each default version found.
   15550              :    If FILTER is true then any invalid versions strings are not included.  */
   15551              : 
   15552              : auto_vec<string_slice>
   15553          208 : get_clone_attr_versions (const tree arglist,
   15554              :                          int *default_count,
   15555              :                          bool filter)
   15556              : {
   15557          208 :   gcc_assert (TREE_CODE (arglist) == TREE_LIST);
   15558          208 :   auto_vec<string_slice> versions;
   15559              : 
   15560          208 :   static const char separator_str[] = {TARGET_CLONES_ATTR_SEPARATOR, 0};
   15561          208 :   string_slice separators = string_slice (separator_str);
   15562              : 
   15563          764 :   for (tree arg = arglist; arg; arg = TREE_CHAIN (arg))
   15564              :     {
   15565          556 :       string_slice str = string_slice (TREE_STRING_POINTER (TREE_VALUE (arg)));
   15566         1696 :       while (str.is_valid ())
   15567              :         {
   15568          584 :           string_slice attr = string_slice::tokenize (&str, separators);
   15569          584 :           attr = attr.strip ();
   15570              : 
   15571          584 :           if (filter && !targetm.check_target_clone_version (attr, NULL))
   15572            0 :             continue;
   15573              : 
   15574          584 :           if (attr == "default" && default_count)
   15575          206 :             (*default_count)++;
   15576          584 :           versions.safe_push (attr);
   15577              :         }
   15578              :     }
   15579          208 :   return versions;
   15580              : }
   15581              : 
   15582              : /* Returns an auto_vec of string_slices containing the version strings from
   15583              :    the target_clone attribute from DECL.  DEFAULT_COUNT is incremented for each
   15584              :    default version found.  If FILTER is true then any invalid versions strings
   15585              :    are not included.  */
   15586              : auto_vec<string_slice>
   15587           97 : get_clone_versions (const tree decl, int *default_count, bool filter)
   15588              : {
   15589           97 :   tree attr = lookup_attribute ("target_clones", DECL_ATTRIBUTES (decl));
   15590           97 :   if (!attr)
   15591            0 :     return auto_vec<string_slice> ();
   15592           97 :   tree arglist = TREE_VALUE (attr);
   15593           97 :   return get_clone_attr_versions (arglist, default_count, filter);
   15594              : }
   15595              : 
   15596              : /* If DECL has a target_version attribute, returns a string_slice containing the
   15597              :    attribute value.  Otherwise, returns string_slice::invalid.
   15598              :    Only works for target_version due to target attributes allowing multiple
   15599              :    string arguments to specify one target.  */
   15600              : string_slice
   15601            0 : get_target_version (const tree decl)
   15602              : {
   15603            0 :   gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE);
   15604              : 
   15605              :   tree attr = lookup_attribute ("target_version", DECL_ATTRIBUTES (decl));
   15606              : 
   15607              :   if (!attr)
   15608              :     return string_slice::invalid ();
   15609              : 
   15610              :   return string_slice (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))))
   15611              :            .strip ();
   15612              : }
   15613              : 
   15614              : /* Returns true if FN1 and FN2 define disjoint function versions in an FMV
   15615              :    function set.  That is, the two declarations are completely non-overlapping.
   15616              :    For target_version semantics, that means if one is a target clone and one is
   15617              :    a target version, the target_version must not be defined by the target_clone,
   15618              :    and for two target_clones, they must not define any of the same version.
   15619              : 
   15620              :    FN1 and FN2 should be function decls.  */
   15621              : 
   15622              : bool
   15623     29576891 : disjoint_version_decls (tree fn1, tree fn2)
   15624              : {
   15625     29576891 :   if (TREE_CODE (fn1) != FUNCTION_DECL
   15626     29575859 :       || TREE_CODE (fn2) != FUNCTION_DECL)
   15627              :     return false;
   15628              : 
   15629     27437133 :   if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
   15630              :     {
   15631     27437133 :       tree attr1 = lookup_attribute ("target", DECL_ATTRIBUTES (fn1));
   15632     27437133 :       tree attr2 = lookup_attribute ("target", DECL_ATTRIBUTES (fn2));
   15633              : 
   15634              :       /* At least one function decl should have the target attribute
   15635              :          specified.  */
   15636     27437133 :       if (attr1 == NULL_TREE && attr2 == NULL_TREE)
   15637              :         return false;
   15638              : 
   15639              :       /* Diagnose missing target attribute if one of the decls is already
   15640              :          multi-versioned.  */
   15641        18843 :       if (attr1 == NULL_TREE || attr2 == NULL_TREE)
   15642              :         {
   15643          363 :           if (DECL_FUNCTION_VERSIONED (fn1) || DECL_FUNCTION_VERSIONED (fn2))
   15644              :             {
   15645          114 :               if (attr2 != NULL_TREE)
   15646              :                 {
   15647          114 :                   std::swap (fn1, fn2);
   15648          114 :                   attr1 = attr2;
   15649              :                 }
   15650          114 :               auto_diagnostic_group d;
   15651          114 :               error_at (DECL_SOURCE_LOCATION (fn2),
   15652              :                         "missing %<target%> attribute for multi-versioned %qD",
   15653              :                         fn2);
   15654          114 :               inform (DECL_SOURCE_LOCATION (fn1),
   15655              :                       "previous declaration of %qD", fn1);
   15656              :               /* Prevent diagnosing of the same error multiple times.  */
   15657          114 :               DECL_ATTRIBUTES (fn2)
   15658          228 :                 = tree_cons (get_identifier ("target"),
   15659          114 :                              copy_node (TREE_VALUE (attr1)),
   15660          114 :                              DECL_ATTRIBUTES (fn2));
   15661          114 :             }
   15662          363 :           return false;
   15663              :         }
   15664              : 
   15665        18480 :       char *target1 = sorted_attr_string (TREE_VALUE (attr1));
   15666        18480 :       char *target2 = sorted_attr_string (TREE_VALUE (attr2));
   15667              : 
   15668              :       /* The sorted target strings must be different for fn1 and fn2
   15669              :          to be versions.  */
   15670        18480 :       bool result = strcmp (target1, target2) != 0;
   15671              : 
   15672        18480 :       XDELETEVEC (target1);
   15673        18480 :       XDELETEVEC (target2);
   15674              : 
   15675        18480 :       return result;
   15676              :     }
   15677              :   else
   15678              :     {
   15679              :       /* As this is symmetric, can remove the case where fn2 is target clone
   15680              :          and fn1 is target version by swapping here.  */
   15681              :       if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn2)))
   15682              :         std::swap (fn1, fn2);
   15683              : 
   15684              :       if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn1)))
   15685              :         {
   15686              :           auto_vec<string_slice> fn1_versions = get_clone_versions (fn1);
   15687              :           /* fn1 is target_clone.  */
   15688              :           if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn2)))
   15689              :             {
   15690              :               /* Both are target_clone.  */
   15691              :               auto_vec<string_slice> fn2_versions = get_clone_versions (fn2);
   15692              :               for (string_slice v1 : fn1_versions)
   15693              :                 {
   15694              :                   for (string_slice v2 : fn2_versions)
   15695              :                     if (targetm.target_option.same_function_versions
   15696              :                           (v1, NULL_TREE, v2, NULL_TREE))
   15697              :                       return false;
   15698              :                 }
   15699              :               return true;
   15700              :             }
   15701              :           else
   15702              :             {
   15703              :               string_slice v2 = get_target_version (fn2);
   15704              : 
   15705              :               /* target and target_clones is always conflicting for target
   15706              :                  semantics.  */
   15707              :               if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
   15708              :                 return false;
   15709              : 
   15710              :               /* Only fn1 is target clone.  */
   15711              :               if (!v2.is_valid ())
   15712              :                 v2 = "default";
   15713              :               for (string_slice v1 : fn1_versions)
   15714              :                 if (targetm.target_option.same_function_versions
   15715              :                       (v1, NULL_TREE, v2, NULL_TREE))
   15716              :                   return false;
   15717              :               return true;
   15718              :             }
   15719              :         }
   15720              :       else
   15721              :         {
   15722              :           /* Both are target_version.  */
   15723              :           string_slice v1 = get_target_version (fn1);
   15724              :           string_slice v2 = get_target_version (fn2);
   15725              : 
   15726              :           if (!v1.is_valid () && !v2.is_valid ())
   15727              :             return false;
   15728              : 
   15729              :           if (!v1.is_valid ())
   15730              :             v1 = "default";
   15731              :           if (!v2.is_valid ())
   15732              :             v2 = "default";
   15733              : 
   15734              :           if (targetm.target_option.same_function_versions (v1, NULL_TREE,
   15735              :                                                             v2, NULL_TREE))
   15736              :             return false;
   15737              : 
   15738              :           return true;
   15739              :         }
   15740              :     }
   15741              : }
   15742              : 
   15743              : /* Check if the target_version/target_clones attributes are mergeable
   15744              :    for two decls, and if so returns false.
   15745              :    If they aren't mergeable, diagnose this and return true.
   15746              :    Only works for target_version semantics.  */
   15747              : bool
   15748            0 : diagnose_versioned_decls (tree old_decl, tree new_decl)
   15749              : {
   15750            0 :   gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE);
   15751              : 
   15752              :   string_slice old_target_attr = get_target_version (old_decl);
   15753              :   string_slice new_target_attr = get_target_version (new_decl);
   15754              : 
   15755              :   tree old_target_clones_attr = lookup_attribute ("target_clones",
   15756              :                                                   DECL_ATTRIBUTES (old_decl));
   15757              :   tree new_target_clones_attr = lookup_attribute ("target_clones",
   15758              :                                                   DECL_ATTRIBUTES (new_decl));
   15759              : 
   15760              :   /* If none of these are annotated, then it is mergeable.  */
   15761              :   if (!old_target_attr.is_valid ()
   15762              :       && !old_target_attr.is_valid ()
   15763              :       && !old_target_clones_attr
   15764              :       && !new_target_clones_attr)
   15765              :     return false;
   15766              : 
   15767              :   /* If fn1 is unnanotated and fn2 contains default, then is mergeable.  */
   15768              :   if (!old_target_attr.is_valid ()
   15769              :       && !old_target_clones_attr
   15770              :       && is_function_default_version (new_decl))
   15771              :     return false;
   15772              : 
   15773              :   /* If fn2 is unnanotated and fn1 contains default, then is mergeable.  */
   15774              :   if (!new_target_attr.is_valid ()
   15775              :       && !new_target_clones_attr
   15776              :       && is_function_default_version (old_decl))
   15777              :     return false;
   15778              : 
   15779              :   /* In the case where both are annotated with target_clones, only mergeable if
   15780              :      the two sets of target_clones imply the same set of versions.  */
   15781              :   if (old_target_clones_attr && new_target_clones_attr)
   15782              :     {
   15783              :       auto_vec<string_slice> old_versions = get_clone_versions (old_decl);
   15784              :       auto_vec<string_slice> new_versions = get_clone_versions (new_decl);
   15785              : 
   15786              :       bool mergeable = true;
   15787              : 
   15788              :       if (old_versions.length () != new_versions.length ())
   15789              :         mergeable = false;
   15790              : 
   15791              :       /* Check both inclusion directions.  */
   15792              :       for (auto oldv: old_versions)
   15793              :         {
   15794              :           bool matched = false;
   15795              :           for (auto newv: new_versions)
   15796              :             if (targetm.target_option.same_function_versions (oldv, old_decl,
   15797              :                                                               newv, new_decl))
   15798              :               matched = true;
   15799              :           if (!matched)
   15800              :             mergeable = false;
   15801              :         }
   15802              : 
   15803              :       for (auto newv: new_versions)
   15804              :         {
   15805              :           bool matched = false;
   15806              :           for (auto oldv: old_versions)
   15807              :             if (targetm.target_option.same_function_versions (oldv, old_decl,
   15808              :                                                               newv, new_decl))
   15809              :               matched = true;
   15810              :           if (!matched)
   15811              :             mergeable = false;
   15812              :         }
   15813              : 
   15814              :       if (!mergeable)
   15815              :         {
   15816              :           error_at (DECL_SOURCE_LOCATION (new_decl),
   15817              :                     "%qD conflicts with overlapping %<target_clone%> "
   15818              :                     "declaration",
   15819              :                     new_decl);
   15820              :           inform (DECL_SOURCE_LOCATION (old_decl),
   15821              :                   "previous declaration of %qD", old_decl);
   15822              :           return true;
   15823              :         }
   15824              : 
   15825              :       return false;
   15826              :     }
   15827              : 
   15828              :   /* If olddecl is target clones and newdecl is a target_version.
   15829              :      As they are not distinct this implies newdecl redefines a version of
   15830              :      olddecl.  Not mergeable.  */
   15831              :   if (new_target_clones_attr)
   15832              :     {
   15833              :       gcc_assert (old_target_attr.is_valid ());
   15834              : 
   15835              :       error_at (DECL_SOURCE_LOCATION (new_decl),
   15836              :                 "%qD conflicts for version %qB",
   15837              :                 new_decl, &old_target_attr);
   15838              :       inform (DECL_SOURCE_LOCATION (old_decl),
   15839              :               "previous declaration of %qD",
   15840              :               old_decl);
   15841              :       return true;
   15842              :     }
   15843              : 
   15844              :   if (old_target_clones_attr)
   15845              :     {
   15846              :       gcc_assert (new_target_attr.is_valid ());
   15847              : 
   15848              :       error_at (DECL_SOURCE_LOCATION (new_decl),
   15849              :                 "%qD conflicts with a previous declaration for version %qB",
   15850              :                 new_decl, &new_target_attr);
   15851              :       inform (DECL_SOURCE_LOCATION (old_decl),
   15852              :               "previous declaration of %qD",
   15853              :               old_decl);
   15854              :       return true;
   15855              :     }
   15856              : 
   15857              :   /* The only remaining case is two target_version annotated decls.  */
   15858              :   return !targetm.target_option.same_function_versions
   15859              :             (old_target_attr, old_decl, new_target_attr, new_decl);
   15860              : }
   15861              : 
   15862              : 
   15863              : /* This page contains routines to unshare tree nodes, i.e. to duplicate tree
   15864              :    nodes that are referenced more than once in GENERIC functions.  This is
   15865              :    necessary because gimplification (translation into GIMPLE) is performed
   15866              :    by modifying tree nodes in-place, so gimplification of a shared node in a
   15867              :    first context could generate an invalid GIMPLE form in a second context.
   15868              : 
   15869              :    This is achieved with a simple mark/copy/unmark algorithm that walks the
   15870              :    GENERIC representation top-down, marks nodes with TREE_VISITED the first
   15871              :    time it encounters them, duplicates them if they already have TREE_VISITED
   15872              :    set, and finally removes the TREE_VISITED marks it has set.
   15873              : 
   15874              :    The algorithm works only at the function level, i.e. it generates a GENERIC
   15875              :    representation of a function with no nodes shared within the function when
   15876              :    passed a GENERIC function (except for nodes that are allowed to be shared).
   15877              : 
   15878              :    At the global level, it is also necessary to unshare tree nodes that are
   15879              :    referenced in more than one function, for the same aforementioned reason.
   15880              :    This requires some cooperation from the front-end.  There are 2 strategies:
   15881              : 
   15882              :      1. Manual unsharing.  The front-end needs to call unshare_expr on every
   15883              :         expression that might end up being shared across functions.
   15884              : 
   15885              :      2. Deep unsharing.  This is an extension of regular unsharing.  Instead
   15886              :         of calling unshare_expr on expressions that might be shared across
   15887              :         functions, the front-end pre-marks them with TREE_VISITED.  This will
   15888              :         ensure that they are unshared on the first reference within functions
   15889              :         when the regular unsharing algorithm runs.  The counterpart is that
   15890              :         this algorithm must look deeper than for manual unsharing, which is
   15891              :         specified by LANG_HOOKS_DEEP_UNSHARING.
   15892              : 
   15893              :   If there are only few specific cases of node sharing across functions, it is
   15894              :   probably easier for a front-end to unshare the expressions manually.  On the
   15895              :   contrary, if the expressions generated at the global level are as widespread
   15896              :   as expressions generated within functions, deep unsharing is very likely the
   15897              :   way to go.  */
   15898              : 
   15899              : /* Similar to copy_tree_r but do not copy SAVE_EXPR or TARGET_EXPR nodes.
   15900              :    These nodes model computations that must be done once.  If we were to
   15901              :    unshare something like SAVE_EXPR(i++), the gimplification process would
   15902              :    create wrong code.  However, if DATA is non-null, it must hold a pointer
   15903              :    set that is used to unshare the subtrees of these nodes.  */
   15904              : 
   15905              : static tree
   15906   2622192513 : mostly_copy_tree_r (tree *tp, int *walk_subtrees, void *data)
   15907              : {
   15908   2622192513 :   tree t = *tp;
   15909   2622192513 :   enum tree_code code = TREE_CODE (t);
   15910              : 
   15911              :   /* Do not copy SAVE_EXPR, TARGET_EXPR or BIND_EXPR nodes themselves, but
   15912              :      copy their subtrees if we can make sure to do it only once.  */
   15913   2622192513 :   if (code == SAVE_EXPR || code == TARGET_EXPR || code == BIND_EXPR)
   15914              :     {
   15915     10805382 :       if (data && !((hash_set<tree> *)data)->add (t))
   15916              :         ;
   15917              :       else
   15918     10805382 :         *walk_subtrees = 0;
   15919              :     }
   15920              : 
   15921              :   /* Stop at types, decls, constants like copy_tree_r.  */
   15922   2611387131 :   else if (TREE_CODE_CLASS (code) == tcc_type
   15923              :            || TREE_CODE_CLASS (code) == tcc_declaration
   15924   2611387131 :            || TREE_CODE_CLASS (code) == tcc_constant)
   15925   1621849216 :     *walk_subtrees = 0;
   15926              : 
   15927              :   /* Cope with the statement expression extension.  */
   15928    989537915 :   else if (code == STATEMENT_LIST)
   15929              :     ;
   15930              : 
   15931              :   /* Leave the bulk of the work to copy_tree_r itself.  */
   15932              :   else
   15933    989488271 :     copy_tree_r (tp, walk_subtrees, NULL);
   15934              : 
   15935   2622192513 :   return NULL_TREE;
   15936              : }
   15937              : 
   15938              : /* Callback for walk_tree to unshare most of the shared trees rooted at *TP.
   15939              :    If *TP has been visited already, then *TP is deeply copied by calling
   15940              :    mostly_copy_tree_r.  DATA is passed to mostly_copy_tree_r unmodified.  */
   15941              : 
   15942              : static tree
   15943    278287455 : copy_if_shared_r (tree *tp, int *walk_subtrees, void *data)
   15944              : {
   15945    278287455 :   tree t = *tp;
   15946    278287455 :   enum tree_code code = TREE_CODE (t);
   15947              : 
   15948              :   /* Skip types, decls, and constants.  But we do want to look at their
   15949              :      types and the bounds of types.  Mark them as visited so we properly
   15950              :      unmark their subtrees on the unmark pass.  If we've already seen them,
   15951              :      don't look down further.  */
   15952    278287455 :   if (TREE_CODE_CLASS (code) == tcc_type
   15953              :       || TREE_CODE_CLASS (code) == tcc_declaration
   15954    278287455 :       || TREE_CODE_CLASS (code) == tcc_constant)
   15955              :     {
   15956    132646580 :       if (TREE_VISITED (t))
   15957     81688809 :         *walk_subtrees = 0;
   15958              :       else
   15959     50957771 :         TREE_VISITED (t) = 1;
   15960              :     }
   15961              : 
   15962              :   /* If this node has been visited already, unshare it and don't look
   15963              :      any deeper.  */
   15964    145640875 :   else if (TREE_VISITED (t))
   15965              :     {
   15966      1708549 :       walk_tree (tp, mostly_copy_tree_r, data, NULL);
   15967      1708549 :       *walk_subtrees = 0;
   15968              :     }
   15969              : 
   15970              :   /* Otherwise, mark the node as visited and keep looking.  */
   15971              :   else
   15972    143932326 :     TREE_VISITED (t) = 1;
   15973              : 
   15974    278287455 :   return NULL_TREE;
   15975              : }
   15976              : 
   15977              : /* Unshare most of the shared trees rooted at *TP.  DATA is passed to the
   15978              :    copy_if_shared_r callback unmodified.  */
   15979              : 
   15980              : void
   15981      8722083 : copy_if_shared (tree *tp, void *data)
   15982              : {
   15983      8722083 :   walk_tree (tp, copy_if_shared_r, data, NULL);
   15984      8722083 : }
   15985              : 
   15986              : /* Unconditionally make an unshared copy of EXPR.  This is used when using
   15987              :    stored expressions which span multiple functions, such as BINFO_VTABLE,
   15988              :    as the normal unsharing process can't tell that they're shared.  */
   15989              : 
   15990              : tree
   15991   1467004528 : unshare_expr (tree expr)
   15992              : {
   15993   1467004528 :   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
   15994   1467004528 :   return expr;
   15995              : }
   15996              : 
   15997              : /* Worker for unshare_expr_without_location.  */
   15998              : 
   15999              : static tree
   16000     14667600 : prune_expr_location (tree *tp, int *walk_subtrees, void *)
   16001              : {
   16002     14667600 :   if (EXPR_P (*tp))
   16003      7339971 :     SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION);
   16004              :   else
   16005      7327629 :     *walk_subtrees = 0;
   16006     14667600 :   return NULL_TREE;
   16007              : }
   16008              : 
   16009              : /* Similar to unshare_expr but also prune all expression locations
   16010              :    from EXPR.  */
   16011              : 
   16012              : tree
   16013     23471661 : unshare_expr_without_location (tree expr)
   16014              : {
   16015     23471661 :   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
   16016     23471661 :   if (EXPR_P (expr))
   16017      5023333 :     walk_tree (&expr, prune_expr_location, NULL, NULL);
   16018     23471661 :   return expr;
   16019              : }
   16020              : 
   16021              : void
   16022       268600 : tree_cc_finalize (void)
   16023              : {
   16024       268600 :   clear_nonstandard_integer_type_cache ();
   16025       268600 :   vec_free (bitint_type_cache);
   16026       268600 : }
   16027              : 
   16028              : void
   16029          232 : gt_ggc_mx (tree_raw_data *x)
   16030              : {
   16031          232 :   gt_ggc_m_9tree_node (x->typed.type);
   16032          232 :   gt_ggc_m_9tree_node (x->owner);
   16033          232 : }
   16034              : 
   16035              : void
   16036           12 : gt_pch_nx (tree_raw_data *x)
   16037              : {
   16038           12 :   gt_pch_n_9tree_node (x->typed.type);
   16039           12 :   gt_pch_n_9tree_node (x->owner);
   16040           12 : }
   16041              : 
   16042              : /* For PCH we guarantee that RAW_DATA_CST's RAW_DATA_OWNER is a STRING_CST and
   16043              :    RAW_DATA_POINTER points into it.  We don't want to save/restore
   16044              :    RAW_DATA_POINTER on its own but want to restore it pointing at the same
   16045              :    offset of the STRING_CST as before.  */
   16046              : 
   16047              : void
   16048           12 : gt_pch_nx (tree_raw_data *x, gt_pointer_operator op, void *cookie)
   16049              : {
   16050           12 :   op (&x->typed.type, NULL, cookie);
   16051           12 :   gcc_checking_assert (x->owner
   16052              :                        && TREE_CODE (x->owner) == STRING_CST
   16053              :                        && x->str >= TREE_STRING_POINTER (x->owner)
   16054              :                        && (x->str + x->length
   16055              :                            <= (TREE_STRING_POINTER (x->owner)
   16056              :                                + TREE_STRING_LENGTH (x->owner))));
   16057           12 :   ptrdiff_t off = x->str - (const char *) (x->owner);
   16058           12 :   tree owner = x->owner;
   16059           12 :   op (&x->owner, NULL, cookie);
   16060           12 :   x->owner = owner;
   16061              :   /* The above op call relocates x->owner and remembers the address
   16062              :      for relocation e.g. if the compiler is position independent.
   16063              :      We then restore x->owner back to its previous value and call
   16064              :      op again, for x->owner itself this just repeats (uselessly) what
   16065              :      the first call did, but as the second argument is now non-NULL
   16066              :      and different, it also arranges for &x->str to be noted for the
   16067              :      PIE relocation.  */
   16068           12 :   op (&x->owner, &x->str, cookie);
   16069           12 :   x->str = (const char *) (x->owner) + off;
   16070           12 : }
   16071              : 
   16072              : #if CHECKING_P
   16073              : 
   16074              : namespace selftest {
   16075              : 
   16076              : /* Selftests for tree.  */
   16077              : 
   16078              : /* Verify that integer constants are sane.  */
   16079              : 
   16080              : static void
   16081            4 : test_integer_constants ()
   16082              : {
   16083            4 :   ASSERT_TRUE (integer_type_node != NULL);
   16084            4 :   ASSERT_TRUE (build_int_cst (integer_type_node, 0) != NULL);
   16085              : 
   16086            4 :   tree type = integer_type_node;
   16087              : 
   16088            4 :   tree zero = build_zero_cst (type);
   16089            4 :   ASSERT_EQ (INTEGER_CST, TREE_CODE (zero));
   16090            4 :   ASSERT_EQ (type, TREE_TYPE (zero));
   16091              : 
   16092            4 :   tree one = build_int_cst (type, 1);
   16093            4 :   ASSERT_EQ (INTEGER_CST, TREE_CODE (one));
   16094            4 :   ASSERT_EQ (type, TREE_TYPE (zero));
   16095            4 : }
   16096              : 
   16097              : /* Verify identifiers.  */
   16098              : 
   16099              : static void
   16100            4 : test_identifiers ()
   16101              : {
   16102            4 :   tree identifier = get_identifier ("foo");
   16103            4 :   ASSERT_EQ (3, IDENTIFIER_LENGTH (identifier));
   16104            4 :   ASSERT_STREQ ("foo", IDENTIFIER_POINTER (identifier));
   16105            4 : }
   16106              : 
   16107              : /* Verify LABEL_DECL.  */
   16108              : 
   16109              : static void
   16110            4 : test_labels ()
   16111              : {
   16112            4 :   tree identifier = get_identifier ("err");
   16113            4 :   tree label_decl = build_decl (UNKNOWN_LOCATION, LABEL_DECL,
   16114              :                                 identifier, void_type_node);
   16115            4 :   ASSERT_EQ (-1, LABEL_DECL_UID (label_decl));
   16116            4 :   ASSERT_FALSE (FORCED_LABEL (label_decl));
   16117            4 : }
   16118              : 
   16119              : /* Return a new VECTOR_CST node whose type is TYPE and whose values
   16120              :    are given by VALS.  */
   16121              : 
   16122              : static tree
   16123           40 : build_vector (tree type, const vec<tree> &vals MEM_STAT_DECL)
   16124              : {
   16125           80 :   gcc_assert (known_eq (vals.length (), TYPE_VECTOR_SUBPARTS (type)));
   16126           40 :   tree_vector_builder builder (type, vals.length (), 1);
   16127           40 :   builder.splice (vals);
   16128           40 :   return builder.build ();
   16129           40 : }
   16130              : 
   16131              : /* Check that VECTOR_CST ACTUAL contains the elements in EXPECTED.  */
   16132              : 
   16133              : static void
   16134           40 : check_vector_cst (const vec<tree> &expected, tree actual)
   16135              : {
   16136           80 :   ASSERT_KNOWN_EQ (expected.length (),
   16137              :                    TYPE_VECTOR_SUBPARTS (TREE_TYPE (actual)));
   16138          360 :   for (unsigned int i = 0; i < expected.length (); ++i)
   16139          320 :     ASSERT_EQ (wi::to_wide (expected[i]),
   16140              :                wi::to_wide (vector_cst_elt (actual, i)));
   16141           40 : }
   16142              : 
   16143              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS duplicated elements,
   16144              :    and that its elements match EXPECTED.  */
   16145              : 
   16146              : static void
   16147            8 : check_vector_cst_duplicate (const vec<tree> &expected, tree actual,
   16148              :                             unsigned int npatterns)
   16149              : {
   16150            8 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16151            8 :   ASSERT_EQ (1, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16152            8 :   ASSERT_EQ (npatterns, vector_cst_encoded_nelts (actual));
   16153            8 :   ASSERT_TRUE (VECTOR_CST_DUPLICATE_P (actual));
   16154            8 :   ASSERT_FALSE (VECTOR_CST_STEPPED_P (actual));
   16155            8 :   check_vector_cst (expected, actual);
   16156            8 : }
   16157              : 
   16158              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS foreground elements
   16159              :    and NPATTERNS background elements, and that its elements match
   16160              :    EXPECTED.  */
   16161              : 
   16162              : static void
   16163            8 : check_vector_cst_fill (const vec<tree> &expected, tree actual,
   16164              :                        unsigned int npatterns)
   16165              : {
   16166            8 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16167            8 :   ASSERT_EQ (2, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16168            8 :   ASSERT_EQ (2 * npatterns, vector_cst_encoded_nelts (actual));
   16169            8 :   ASSERT_FALSE (VECTOR_CST_DUPLICATE_P (actual));
   16170            8 :   ASSERT_FALSE (VECTOR_CST_STEPPED_P (actual));
   16171            8 :   check_vector_cst (expected, actual);
   16172            8 : }
   16173              : 
   16174              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS stepped patterns,
   16175              :    and that its elements match EXPECTED.  */
   16176              : 
   16177              : static void
   16178           24 : check_vector_cst_stepped (const vec<tree> &expected, tree actual,
   16179              :                           unsigned int npatterns)
   16180              : {
   16181           24 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16182           24 :   ASSERT_EQ (3, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16183           24 :   ASSERT_EQ (3 * npatterns, vector_cst_encoded_nelts (actual));
   16184           24 :   ASSERT_FALSE (VECTOR_CST_DUPLICATE_P (actual));
   16185           24 :   ASSERT_TRUE (VECTOR_CST_STEPPED_P (actual));
   16186           24 :   check_vector_cst (expected, actual);
   16187           24 : }
   16188              : 
   16189              : /* Test the creation of VECTOR_CSTs.  */
   16190              : 
   16191              : static void
   16192            4 : test_vector_cst_patterns (ALONE_CXX_MEM_STAT_INFO)
   16193              : {
   16194            4 :   auto_vec<tree, 8> elements (8);
   16195            4 :   elements.quick_grow (8);
   16196            4 :   tree element_type = build_nonstandard_integer_type (16, true);
   16197            4 :   tree vector_type = build_vector_type (element_type, 8);
   16198              : 
   16199              :   /* Test a simple linear series with a base of 0 and a step of 1:
   16200              :      { 0, 1, 2, 3, 4, 5, 6, 7 }.  */
   16201           36 :   for (unsigned int i = 0; i < 8; ++i)
   16202           32 :     elements[i] = build_int_cst (element_type, i);
   16203            4 :   tree vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16204            4 :   check_vector_cst_stepped (elements, vector, 1);
   16205              : 
   16206              :   /* Try the same with the first element replaced by 100:
   16207              :      { 100, 1, 2, 3, 4, 5, 6, 7 }.  */
   16208            4 :   elements[0] = build_int_cst (element_type, 100);
   16209            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16210            4 :   check_vector_cst_stepped (elements, vector, 1);
   16211              : 
   16212              :   /* Try a series that wraps around.
   16213              :      { 100, 65531, 65532, 65533, 65534, 65535, 0, 1 }.  */
   16214           32 :   for (unsigned int i = 1; i < 8; ++i)
   16215           28 :     elements[i] = build_int_cst (element_type, (65530 + i) & 0xffff);
   16216            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16217            4 :   check_vector_cst_stepped (elements, vector, 1);
   16218              : 
   16219              :   /* Try a downward series:
   16220              :      { 100, 79, 78, 77, 76, 75, 75, 73 }.  */
   16221           32 :   for (unsigned int i = 1; i < 8; ++i)
   16222           28 :     elements[i] = build_int_cst (element_type, 80 - i);
   16223            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16224            4 :   check_vector_cst_stepped (elements, vector, 1);
   16225              : 
   16226              :   /* Try two interleaved series with different bases and steps:
   16227              :      { 100, 53, 66, 206, 62, 212, 58, 218 }.  */
   16228            4 :   elements[1] = build_int_cst (element_type, 53);
   16229           16 :   for (unsigned int i = 2; i < 8; i += 2)
   16230              :     {
   16231           12 :       elements[i] = build_int_cst (element_type, 70 - i * 2);
   16232           12 :       elements[i + 1] = build_int_cst (element_type, 200 + i * 3);
   16233              :     }
   16234            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16235            4 :   check_vector_cst_stepped (elements, vector, 2);
   16236              : 
   16237              :   /* Try a duplicated value:
   16238              :      { 100, 100, 100, 100, 100, 100, 100, 100 }.  */
   16239           32 :   for (unsigned int i = 1; i < 8; ++i)
   16240           28 :     elements[i] = elements[0];
   16241            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16242            4 :   check_vector_cst_duplicate (elements, vector, 1);
   16243              : 
   16244              :   /* Try an interleaved duplicated value:
   16245              :      { 100, 55, 100, 55, 100, 55, 100, 55 }.  */
   16246            4 :   elements[1] = build_int_cst (element_type, 55);
   16247           28 :   for (unsigned int i = 2; i < 8; ++i)
   16248           24 :     elements[i] = elements[i - 2];
   16249            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16250            4 :   check_vector_cst_duplicate (elements, vector, 2);
   16251              : 
   16252              :   /* Try a duplicated value with 2 exceptions
   16253              :      { 41, 97, 100, 55, 100, 55, 100, 55 }.  */
   16254            4 :   elements[0] = build_int_cst (element_type, 41);
   16255            4 :   elements[1] = build_int_cst (element_type, 97);
   16256            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16257            4 :   check_vector_cst_fill (elements, vector, 2);
   16258              : 
   16259              :   /* Try with and without a step
   16260              :      { 41, 97, 100, 21, 100, 35, 100, 49 }.  */
   16261           16 :   for (unsigned int i = 3; i < 8; i += 2)
   16262           12 :     elements[i] = build_int_cst (element_type, i * 7);
   16263            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16264            4 :   check_vector_cst_stepped (elements, vector, 2);
   16265              : 
   16266              :   /* Try a fully-general constant:
   16267              :      { 41, 97, 100, 21, 100, 9990, 100, 49 }.  */
   16268            4 :   elements[5] = build_int_cst (element_type, 9990);
   16269            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16270            4 :   check_vector_cst_fill (elements, vector, 4);
   16271            4 : }
   16272              : 
   16273              : /* Verify that STRIP_NOPS (NODE) is EXPECTED.
   16274              :    Helper function for test_location_wrappers, to deal with STRIP_NOPS
   16275              :    modifying its argument in-place.  */
   16276              : 
   16277              : static void
   16278           12 : check_strip_nops (tree node, tree expected)
   16279              : {
   16280           12 :   STRIP_NOPS (node);
   16281           12 :   ASSERT_EQ (expected, node);
   16282           12 : }
   16283              : 
   16284              : /* Verify location wrappers.  */
   16285              : 
   16286              : static void
   16287            4 : test_location_wrappers ()
   16288              : {
   16289            4 :   location_t loc = BUILTINS_LOCATION;
   16290              : 
   16291            4 :   ASSERT_EQ (NULL_TREE, maybe_wrap_with_location (NULL_TREE, loc));
   16292              : 
   16293              :   /* Wrapping a constant.  */
   16294            4 :   tree int_cst = build_int_cst (integer_type_node, 42);
   16295            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_cst));
   16296            4 :   ASSERT_FALSE (location_wrapper_p (int_cst));
   16297              : 
   16298            4 :   tree wrapped_int_cst = maybe_wrap_with_location (int_cst, loc);
   16299            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_cst));
   16300            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_cst));
   16301            4 :   ASSERT_EQ (int_cst, tree_strip_any_location_wrapper (wrapped_int_cst));
   16302              : 
   16303              :   /* We shouldn't add wrapper nodes for UNKNOWN_LOCATION.  */
   16304            4 :   ASSERT_EQ (int_cst, maybe_wrap_with_location (int_cst, UNKNOWN_LOCATION));
   16305              : 
   16306              :   /* We shouldn't add wrapper nodes for nodes that CAN_HAVE_LOCATION_P.  */
   16307            4 :   tree cast = build1 (NOP_EXPR, char_type_node, int_cst);
   16308            4 :   ASSERT_TRUE (CAN_HAVE_LOCATION_P (cast));
   16309            4 :   ASSERT_EQ (cast, maybe_wrap_with_location (cast, loc));
   16310              : 
   16311              :   /* Wrapping a STRING_CST.  */
   16312            4 :   tree string_cst = build_string (4, "foo");
   16313            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (string_cst));
   16314            4 :   ASSERT_FALSE (location_wrapper_p (string_cst));
   16315              : 
   16316            4 :   tree wrapped_string_cst = maybe_wrap_with_location (string_cst, loc);
   16317            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_string_cst));
   16318            4 :   ASSERT_EQ (VIEW_CONVERT_EXPR, TREE_CODE (wrapped_string_cst));
   16319            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_string_cst));
   16320            4 :   ASSERT_EQ (string_cst, tree_strip_any_location_wrapper (wrapped_string_cst));
   16321              : 
   16322              : 
   16323              :   /* Wrapping a variable.  */
   16324            4 :   tree int_var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   16325              :                              get_identifier ("some_int_var"),
   16326              :                              integer_type_node);
   16327            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_var));
   16328            4 :   ASSERT_FALSE (location_wrapper_p (int_var));
   16329              : 
   16330            4 :   tree wrapped_int_var = maybe_wrap_with_location (int_var, loc);
   16331            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_var));
   16332            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_var));
   16333            4 :   ASSERT_EQ (int_var, tree_strip_any_location_wrapper (wrapped_int_var));
   16334              : 
   16335              :   /* Verify that "reinterpret_cast<int>(some_int_var)" is not a location
   16336              :      wrapper.  */
   16337            4 :   tree r_cast = build1 (NON_LVALUE_EXPR, integer_type_node, int_var);
   16338            4 :   ASSERT_FALSE (location_wrapper_p (r_cast));
   16339            4 :   ASSERT_EQ (r_cast, tree_strip_any_location_wrapper (r_cast));
   16340              : 
   16341              :   /* Verify that STRIP_NOPS removes wrappers.  */
   16342            4 :   check_strip_nops (wrapped_int_cst, int_cst);
   16343            4 :   check_strip_nops (wrapped_string_cst, string_cst);
   16344            4 :   check_strip_nops (wrapped_int_var, int_var);
   16345            4 : }
   16346              : 
   16347              : /* Test various tree predicates.  Verify that location wrappers don't
   16348              :    affect the results.  */
   16349              : 
   16350              : static void
   16351            4 : test_predicates ()
   16352              : {
   16353              :   /* Build various constants and wrappers around them.  */
   16354              : 
   16355            4 :   location_t loc = BUILTINS_LOCATION;
   16356              : 
   16357            4 :   tree i_0 = build_int_cst (integer_type_node, 0);
   16358            4 :   tree wr_i_0 = maybe_wrap_with_location (i_0, loc);
   16359              : 
   16360            4 :   tree i_1 = build_int_cst (integer_type_node, 1);
   16361            4 :   tree wr_i_1 = maybe_wrap_with_location (i_1, loc);
   16362              : 
   16363            4 :   tree i_m1 = build_int_cst (integer_type_node, -1);
   16364            4 :   tree wr_i_m1 = maybe_wrap_with_location (i_m1, loc);
   16365              : 
   16366            4 :   tree f_0 = build_real_from_int_cst (float_type_node, i_0);
   16367            4 :   tree wr_f_0 = maybe_wrap_with_location (f_0, loc);
   16368            4 :   tree f_1 = build_real_from_int_cst (float_type_node, i_1);
   16369            4 :   tree wr_f_1 = maybe_wrap_with_location (f_1, loc);
   16370            4 :   tree f_m1 = build_real_from_int_cst (float_type_node, i_m1);
   16371            4 :   tree wr_f_m1 = maybe_wrap_with_location (f_m1, loc);
   16372              : 
   16373            4 :   tree c_i_0 = build_complex (NULL_TREE, i_0, i_0);
   16374            4 :   tree c_i_1 = build_complex (NULL_TREE, i_1, i_0);
   16375            4 :   tree c_i_m1 = build_complex (NULL_TREE, i_m1, i_0);
   16376              : 
   16377            4 :   tree c_f_0 = build_complex (NULL_TREE, f_0, f_0);
   16378            4 :   tree c_f_1 = build_complex (NULL_TREE, f_1, f_0);
   16379            4 :   tree c_f_m1 = build_complex (NULL_TREE, f_m1, f_0);
   16380              : 
   16381              :   /* TODO: vector constants.  */
   16382              : 
   16383              :   /* Test integer_onep.  */
   16384            4 :   ASSERT_FALSE (integer_onep (i_0));
   16385            4 :   ASSERT_FALSE (integer_onep (wr_i_0));
   16386            4 :   ASSERT_TRUE (integer_onep (i_1));
   16387            4 :   ASSERT_TRUE (integer_onep (wr_i_1));
   16388            4 :   ASSERT_FALSE (integer_onep (i_m1));
   16389            4 :   ASSERT_FALSE (integer_onep (wr_i_m1));
   16390            4 :   ASSERT_FALSE (integer_onep (f_0));
   16391            4 :   ASSERT_FALSE (integer_onep (wr_f_0));
   16392            4 :   ASSERT_FALSE (integer_onep (f_1));
   16393            4 :   ASSERT_FALSE (integer_onep (wr_f_1));
   16394            4 :   ASSERT_FALSE (integer_onep (f_m1));
   16395            4 :   ASSERT_FALSE (integer_onep (wr_f_m1));
   16396            4 :   ASSERT_FALSE (integer_onep (c_i_0));
   16397            4 :   ASSERT_TRUE (integer_onep (c_i_1));
   16398            4 :   ASSERT_FALSE (integer_onep (c_i_m1));
   16399            4 :   ASSERT_FALSE (integer_onep (c_f_0));
   16400            4 :   ASSERT_FALSE (integer_onep (c_f_1));
   16401            4 :   ASSERT_FALSE (integer_onep (c_f_m1));
   16402              : 
   16403              :   /* Test integer_zerop.  */
   16404            4 :   ASSERT_TRUE (integer_zerop (i_0));
   16405            4 :   ASSERT_TRUE (integer_zerop (wr_i_0));
   16406            4 :   ASSERT_FALSE (integer_zerop (i_1));
   16407            4 :   ASSERT_FALSE (integer_zerop (wr_i_1));
   16408            4 :   ASSERT_FALSE (integer_zerop (i_m1));
   16409            4 :   ASSERT_FALSE (integer_zerop (wr_i_m1));
   16410            4 :   ASSERT_FALSE (integer_zerop (f_0));
   16411            4 :   ASSERT_FALSE (integer_zerop (wr_f_0));
   16412            4 :   ASSERT_FALSE (integer_zerop (f_1));
   16413            4 :   ASSERT_FALSE (integer_zerop (wr_f_1));
   16414            4 :   ASSERT_FALSE (integer_zerop (f_m1));
   16415            4 :   ASSERT_FALSE (integer_zerop (wr_f_m1));
   16416            4 :   ASSERT_TRUE (integer_zerop (c_i_0));
   16417            4 :   ASSERT_FALSE (integer_zerop (c_i_1));
   16418            4 :   ASSERT_FALSE (integer_zerop (c_i_m1));
   16419            4 :   ASSERT_FALSE (integer_zerop (c_f_0));
   16420            4 :   ASSERT_FALSE (integer_zerop (c_f_1));
   16421            4 :   ASSERT_FALSE (integer_zerop (c_f_m1));
   16422              : 
   16423              :   /* Test integer_all_onesp.  */
   16424            4 :   ASSERT_FALSE (integer_all_onesp (i_0));
   16425            4 :   ASSERT_FALSE (integer_all_onesp (wr_i_0));
   16426            4 :   ASSERT_FALSE (integer_all_onesp (i_1));
   16427            4 :   ASSERT_FALSE (integer_all_onesp (wr_i_1));
   16428            4 :   ASSERT_TRUE (integer_all_onesp (i_m1));
   16429            4 :   ASSERT_TRUE (integer_all_onesp (wr_i_m1));
   16430            4 :   ASSERT_FALSE (integer_all_onesp (f_0));
   16431            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_0));
   16432            4 :   ASSERT_FALSE (integer_all_onesp (f_1));
   16433            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_1));
   16434            4 :   ASSERT_FALSE (integer_all_onesp (f_m1));
   16435            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_m1));
   16436            4 :   ASSERT_FALSE (integer_all_onesp (c_i_0));
   16437            4 :   ASSERT_FALSE (integer_all_onesp (c_i_1));
   16438            4 :   ASSERT_FALSE (integer_all_onesp (c_i_m1));
   16439            4 :   ASSERT_FALSE (integer_all_onesp (c_f_0));
   16440            4 :   ASSERT_FALSE (integer_all_onesp (c_f_1));
   16441            4 :   ASSERT_FALSE (integer_all_onesp (c_f_m1));
   16442              : 
   16443              :   /* Test integer_minus_onep.  */
   16444            4 :   ASSERT_FALSE (integer_minus_onep (i_0));
   16445            4 :   ASSERT_FALSE (integer_minus_onep (wr_i_0));
   16446            4 :   ASSERT_FALSE (integer_minus_onep (i_1));
   16447            4 :   ASSERT_FALSE (integer_minus_onep (wr_i_1));
   16448            4 :   ASSERT_TRUE (integer_minus_onep (i_m1));
   16449            4 :   ASSERT_TRUE (integer_minus_onep (wr_i_m1));
   16450            4 :   ASSERT_FALSE (integer_minus_onep (f_0));
   16451            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_0));
   16452            4 :   ASSERT_FALSE (integer_minus_onep (f_1));
   16453            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_1));
   16454            4 :   ASSERT_FALSE (integer_minus_onep (f_m1));
   16455            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_m1));
   16456            4 :   ASSERT_FALSE (integer_minus_onep (c_i_0));
   16457            4 :   ASSERT_FALSE (integer_minus_onep (c_i_1));
   16458            4 :   ASSERT_TRUE (integer_minus_onep (c_i_m1));
   16459            4 :   ASSERT_FALSE (integer_minus_onep (c_f_0));
   16460            4 :   ASSERT_FALSE (integer_minus_onep (c_f_1));
   16461            4 :   ASSERT_FALSE (integer_minus_onep (c_f_m1));
   16462              : 
   16463              :   /* Test integer_each_onep.  */
   16464            4 :   ASSERT_FALSE (integer_each_onep (i_0));
   16465            4 :   ASSERT_FALSE (integer_each_onep (wr_i_0));
   16466            4 :   ASSERT_TRUE (integer_each_onep (i_1));
   16467            4 :   ASSERT_TRUE (integer_each_onep (wr_i_1));
   16468            4 :   ASSERT_FALSE (integer_each_onep (i_m1));
   16469            4 :   ASSERT_FALSE (integer_each_onep (wr_i_m1));
   16470            4 :   ASSERT_FALSE (integer_each_onep (f_0));
   16471            4 :   ASSERT_FALSE (integer_each_onep (wr_f_0));
   16472            4 :   ASSERT_FALSE (integer_each_onep (f_1));
   16473            4 :   ASSERT_FALSE (integer_each_onep (wr_f_1));
   16474            4 :   ASSERT_FALSE (integer_each_onep (f_m1));
   16475            4 :   ASSERT_FALSE (integer_each_onep (wr_f_m1));
   16476            4 :   ASSERT_FALSE (integer_each_onep (c_i_0));
   16477            4 :   ASSERT_FALSE (integer_each_onep (c_i_1));
   16478            4 :   ASSERT_FALSE (integer_each_onep (c_i_m1));
   16479            4 :   ASSERT_FALSE (integer_each_onep (c_f_0));
   16480            4 :   ASSERT_FALSE (integer_each_onep (c_f_1));
   16481            4 :   ASSERT_FALSE (integer_each_onep (c_f_m1));
   16482              : 
   16483              :   /* Test integer_truep.  */
   16484            4 :   ASSERT_FALSE (integer_truep (i_0));
   16485            4 :   ASSERT_FALSE (integer_truep (wr_i_0));
   16486            4 :   ASSERT_TRUE (integer_truep (i_1));
   16487            4 :   ASSERT_TRUE (integer_truep (wr_i_1));
   16488            4 :   ASSERT_FALSE (integer_truep (i_m1));
   16489            4 :   ASSERT_FALSE (integer_truep (wr_i_m1));
   16490            4 :   ASSERT_FALSE (integer_truep (f_0));
   16491            4 :   ASSERT_FALSE (integer_truep (wr_f_0));
   16492            4 :   ASSERT_FALSE (integer_truep (f_1));
   16493            4 :   ASSERT_FALSE (integer_truep (wr_f_1));
   16494            4 :   ASSERT_FALSE (integer_truep (f_m1));
   16495            4 :   ASSERT_FALSE (integer_truep (wr_f_m1));
   16496            4 :   ASSERT_FALSE (integer_truep (c_i_0));
   16497            4 :   ASSERT_TRUE (integer_truep (c_i_1));
   16498            4 :   ASSERT_FALSE (integer_truep (c_i_m1));
   16499            4 :   ASSERT_FALSE (integer_truep (c_f_0));
   16500            4 :   ASSERT_FALSE (integer_truep (c_f_1));
   16501            4 :   ASSERT_FALSE (integer_truep (c_f_m1));
   16502              : 
   16503              :   /* Test integer_nonzerop.  */
   16504            4 :   ASSERT_FALSE (integer_nonzerop (i_0));
   16505            4 :   ASSERT_FALSE (integer_nonzerop (wr_i_0));
   16506            4 :   ASSERT_TRUE (integer_nonzerop (i_1));
   16507            4 :   ASSERT_TRUE (integer_nonzerop (wr_i_1));
   16508            4 :   ASSERT_TRUE (integer_nonzerop (i_m1));
   16509            4 :   ASSERT_TRUE (integer_nonzerop (wr_i_m1));
   16510            4 :   ASSERT_FALSE (integer_nonzerop (f_0));
   16511            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_0));
   16512            4 :   ASSERT_FALSE (integer_nonzerop (f_1));
   16513            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_1));
   16514            4 :   ASSERT_FALSE (integer_nonzerop (f_m1));
   16515            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_m1));
   16516            4 :   ASSERT_FALSE (integer_nonzerop (c_i_0));
   16517            4 :   ASSERT_TRUE (integer_nonzerop (c_i_1));
   16518            4 :   ASSERT_TRUE (integer_nonzerop (c_i_m1));
   16519            4 :   ASSERT_FALSE (integer_nonzerop (c_f_0));
   16520            4 :   ASSERT_FALSE (integer_nonzerop (c_f_1));
   16521            4 :   ASSERT_FALSE (integer_nonzerop (c_f_m1));
   16522              : 
   16523              :   /* Test real_zerop.  */
   16524            4 :   ASSERT_FALSE (real_zerop (i_0));
   16525            4 :   ASSERT_FALSE (real_zerop (wr_i_0));
   16526            4 :   ASSERT_FALSE (real_zerop (i_1));
   16527            4 :   ASSERT_FALSE (real_zerop (wr_i_1));
   16528            4 :   ASSERT_FALSE (real_zerop (i_m1));
   16529            4 :   ASSERT_FALSE (real_zerop (wr_i_m1));
   16530            4 :   ASSERT_TRUE (real_zerop (f_0));
   16531            4 :   ASSERT_TRUE (real_zerop (wr_f_0));
   16532            4 :   ASSERT_FALSE (real_zerop (f_1));
   16533            4 :   ASSERT_FALSE (real_zerop (wr_f_1));
   16534            4 :   ASSERT_FALSE (real_zerop (f_m1));
   16535            4 :   ASSERT_FALSE (real_zerop (wr_f_m1));
   16536            4 :   ASSERT_FALSE (real_zerop (c_i_0));
   16537            4 :   ASSERT_FALSE (real_zerop (c_i_1));
   16538            4 :   ASSERT_FALSE (real_zerop (c_i_m1));
   16539            4 :   ASSERT_TRUE (real_zerop (c_f_0));
   16540            4 :   ASSERT_FALSE (real_zerop (c_f_1));
   16541            4 :   ASSERT_FALSE (real_zerop (c_f_m1));
   16542              : 
   16543              :   /* Test real_onep.  */
   16544            4 :   ASSERT_FALSE (real_onep (i_0));
   16545            4 :   ASSERT_FALSE (real_onep (wr_i_0));
   16546            4 :   ASSERT_FALSE (real_onep (i_1));
   16547            4 :   ASSERT_FALSE (real_onep (wr_i_1));
   16548            4 :   ASSERT_FALSE (real_onep (i_m1));
   16549            4 :   ASSERT_FALSE (real_onep (wr_i_m1));
   16550            4 :   ASSERT_FALSE (real_onep (f_0));
   16551            4 :   ASSERT_FALSE (real_onep (wr_f_0));
   16552            4 :   ASSERT_TRUE (real_onep (f_1));
   16553            4 :   ASSERT_TRUE (real_onep (wr_f_1));
   16554            4 :   ASSERT_FALSE (real_onep (f_m1));
   16555            4 :   ASSERT_FALSE (real_onep (wr_f_m1));
   16556            4 :   ASSERT_FALSE (real_onep (c_i_0));
   16557            4 :   ASSERT_FALSE (real_onep (c_i_1));
   16558            4 :   ASSERT_FALSE (real_onep (c_i_m1));
   16559            4 :   ASSERT_FALSE (real_onep (c_f_0));
   16560            4 :   ASSERT_TRUE (real_onep (c_f_1));
   16561            4 :   ASSERT_FALSE (real_onep (c_f_m1));
   16562              : 
   16563              :   /* Test real_minus_onep.  */
   16564            4 :   ASSERT_FALSE (real_minus_onep (i_0));
   16565            4 :   ASSERT_FALSE (real_minus_onep (wr_i_0));
   16566            4 :   ASSERT_FALSE (real_minus_onep (i_1));
   16567            4 :   ASSERT_FALSE (real_minus_onep (wr_i_1));
   16568            4 :   ASSERT_FALSE (real_minus_onep (i_m1));
   16569            4 :   ASSERT_FALSE (real_minus_onep (wr_i_m1));
   16570            4 :   ASSERT_FALSE (real_minus_onep (f_0));
   16571            4 :   ASSERT_FALSE (real_minus_onep (wr_f_0));
   16572            4 :   ASSERT_FALSE (real_minus_onep (f_1));
   16573            4 :   ASSERT_FALSE (real_minus_onep (wr_f_1));
   16574            4 :   ASSERT_TRUE (real_minus_onep (f_m1));
   16575            4 :   ASSERT_TRUE (real_minus_onep (wr_f_m1));
   16576            4 :   ASSERT_FALSE (real_minus_onep (c_i_0));
   16577            4 :   ASSERT_FALSE (real_minus_onep (c_i_1));
   16578            4 :   ASSERT_FALSE (real_minus_onep (c_i_m1));
   16579            4 :   ASSERT_FALSE (real_minus_onep (c_f_0));
   16580            4 :   ASSERT_FALSE (real_minus_onep (c_f_1));
   16581            4 :   ASSERT_TRUE (real_minus_onep (c_f_m1));
   16582              : 
   16583              :   /* Test zerop.  */
   16584            4 :   ASSERT_TRUE (zerop (i_0));
   16585            4 :   ASSERT_TRUE (zerop (wr_i_0));
   16586            4 :   ASSERT_FALSE (zerop (i_1));
   16587            4 :   ASSERT_FALSE (zerop (wr_i_1));
   16588            4 :   ASSERT_FALSE (zerop (i_m1));
   16589            4 :   ASSERT_FALSE (zerop (wr_i_m1));
   16590            4 :   ASSERT_TRUE (zerop (f_0));
   16591            4 :   ASSERT_TRUE (zerop (wr_f_0));
   16592            4 :   ASSERT_FALSE (zerop (f_1));
   16593            4 :   ASSERT_FALSE (zerop (wr_f_1));
   16594            4 :   ASSERT_FALSE (zerop (f_m1));
   16595            4 :   ASSERT_FALSE (zerop (wr_f_m1));
   16596            4 :   ASSERT_TRUE (zerop (c_i_0));
   16597            4 :   ASSERT_FALSE (zerop (c_i_1));
   16598            4 :   ASSERT_FALSE (zerop (c_i_m1));
   16599            4 :   ASSERT_TRUE (zerop (c_f_0));
   16600            4 :   ASSERT_FALSE (zerop (c_f_1));
   16601            4 :   ASSERT_FALSE (zerop (c_f_m1));
   16602              : 
   16603              :   /* Test tree_expr_nonnegative_p.  */
   16604            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (i_0));
   16605            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_i_0));
   16606            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (i_1));
   16607            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_i_1));
   16608            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (i_m1));
   16609            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (wr_i_m1));
   16610            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (f_0));
   16611            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_f_0));
   16612            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (f_1));
   16613            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_f_1));
   16614            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (f_m1));
   16615            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (wr_f_m1));
   16616            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_0));
   16617            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_1));
   16618            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_m1));
   16619            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_0));
   16620            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_1));
   16621            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_m1));
   16622              : 
   16623              :   /* Test tree_expr_nonzero_p.  */
   16624            4 :   ASSERT_FALSE (tree_expr_nonzero_p (i_0));
   16625            4 :   ASSERT_FALSE (tree_expr_nonzero_p (wr_i_0));
   16626            4 :   ASSERT_TRUE (tree_expr_nonzero_p (i_1));
   16627            4 :   ASSERT_TRUE (tree_expr_nonzero_p (wr_i_1));
   16628            4 :   ASSERT_TRUE (tree_expr_nonzero_p (i_m1));
   16629            4 :   ASSERT_TRUE (tree_expr_nonzero_p (wr_i_m1));
   16630              : 
   16631              :   /* Test integer_valued_real_p.  */
   16632            4 :   ASSERT_FALSE (integer_valued_real_p (i_0));
   16633            4 :   ASSERT_TRUE (integer_valued_real_p (f_0));
   16634            4 :   ASSERT_TRUE (integer_valued_real_p (wr_f_0));
   16635            4 :   ASSERT_TRUE (integer_valued_real_p (f_1));
   16636            4 :   ASSERT_TRUE (integer_valued_real_p (wr_f_1));
   16637              : 
   16638              :   /* Test integer_pow2p.  */
   16639            4 :   ASSERT_FALSE (integer_pow2p (i_0));
   16640            4 :   ASSERT_TRUE (integer_pow2p (i_1));
   16641            4 :   ASSERT_TRUE (integer_pow2p (wr_i_1));
   16642              : 
   16643              :   /* Test uniform_integer_cst_p.  */
   16644            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_0));
   16645            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_0));
   16646            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_1));
   16647            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_1));
   16648            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_m1));
   16649            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_m1));
   16650            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_0));
   16651            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_0));
   16652            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_1));
   16653            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_1));
   16654            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_m1));
   16655            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_m1));
   16656            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_0));
   16657            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_1));
   16658            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_m1));
   16659            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_0));
   16660            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_1));
   16661            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_m1));
   16662            4 : }
   16663              : 
   16664              : /* Check that string escaping works correctly.  */
   16665              : 
   16666              : static void
   16667            4 : test_escaped_strings (void)
   16668              : {
   16669            4 :   int saved_cutoff;
   16670            4 :   escaped_string msg;
   16671              : 
   16672            4 :   msg.escape (NULL);
   16673              :   /* ASSERT_STREQ does not accept NULL as a valid test
   16674              :      result, so we have to use ASSERT_EQ instead.  */
   16675            4 :   ASSERT_EQ (NULL, (const char *) msg);
   16676              : 
   16677            4 :   msg.escape ("");
   16678            4 :   ASSERT_STREQ ("", (const char *) msg);
   16679              : 
   16680            4 :   msg.escape ("foobar");
   16681            4 :   ASSERT_STREQ ("foobar", (const char *) msg);
   16682              : 
   16683              :   /* Ensure that we have -fmessage-length set to 0.  */
   16684            4 :   pretty_printer *pp = global_dc->get_reference_printer ();
   16685            4 :   saved_cutoff = pp_line_cutoff (pp);
   16686            4 :   pp_line_cutoff (pp) = 0;
   16687              : 
   16688            4 :   msg.escape ("foo\nbar");
   16689            4 :   ASSERT_STREQ ("foo\\nbar", (const char *) msg);
   16690              : 
   16691            4 :   msg.escape ("\a\b\f\n\r\t\v");
   16692            4 :   ASSERT_STREQ ("\\a\\b\\f\\n\\r\\t\\v", (const char *) msg);
   16693              : 
   16694              :   /* Now repeat the tests with -fmessage-length set to 5.  */
   16695            4 :   pp_line_cutoff (pp) = 5;
   16696              : 
   16697              :   /* Note that the newline is not translated into an escape.  */
   16698            4 :   msg.escape ("foo\nbar");
   16699            4 :   ASSERT_STREQ ("foo\nbar", (const char *) msg);
   16700              : 
   16701            4 :   msg.escape ("\a\b\f\n\r\t\v");
   16702            4 :   ASSERT_STREQ ("\\a\\b\\f\n\\r\\t\\v", (const char *) msg);
   16703              : 
   16704              :   /* Restore the original message length setting.  */
   16705            4 :   pp_line_cutoff (pp) = saved_cutoff;
   16706            4 : }
   16707              : 
   16708              : /* Run all of the selftests within this file.  */
   16709              : 
   16710              : void
   16711            4 : tree_cc_tests ()
   16712              : {
   16713            4 :   test_integer_constants ();
   16714            4 :   test_identifiers ();
   16715            4 :   test_labels ();
   16716            4 :   test_vector_cst_patterns ();
   16717            4 :   test_location_wrappers ();
   16718            4 :   test_predicates ();
   16719            4 :   test_escaped_strings ();
   16720            4 : }
   16721              : 
   16722              : } // namespace selftest
   16723              : 
   16724              : #endif /* CHECKING_P */
   16725              : 
   16726              : #include "gt-tree.h"
        

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.