LCOV - code coverage report
Current view: top level - gcc - tree.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 85.1 % 7087 6032
Test Date: 2026-09-19 16:22:48 Functions: 90.2 % 461 416
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   7873902473 :   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   2062077266 :   keep_cache_entry (type_hash *&t)
     165              :   {
     166   2062077266 :     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       875168 : 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     24131901 : gt_value_expr_mark_2 (tree *tp, int *, void *data)
     228              : {
     229     24131901 :   tree t = *tp;
     230     24131901 :   if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t) && !ggc_marked_p (t))
     231              :     {
     232         1096 :       tree dve = DECL_VALUE_EXPR (t);
     233         1096 :       gt_value_expr_mark_data *d = (gt_value_expr_mark_data *) data;
     234         1096 :       walk_tree_1 (&dve, gt_value_expr_mark_2, data, &d->pset, NULL);
     235         1096 :       d->to_mark.safe_push (t);
     236              :     }
     237     24131901 :   return NULL_TREE;
     238              : }
     239              : 
     240              : /* Callback called through traverse_noresize on the
     241              :    value_expr_for_decl hash table.  */
     242              : 
     243              : int
     244     10214156 : gt_value_expr_mark_1 (tree_decl_map **e, gt_value_expr_mark_data *data)
     245              : {
     246     10214156 :   if (ggc_marked_p ((*e)->base.from))
     247      8917205 :     walk_tree_1 (&(*e)->to, gt_value_expr_mark_2, data, &data->pset, NULL);
     248     10214156 :   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       875168 : gt_value_expr_mark (hash_table<tree_decl_map_cache_hasher> *h)
     263              : {
     264       875168 :   if (!h)
     265            0 :     return;
     266              : 
     267       875168 :   gt_value_expr_mark_data data;
     268       875168 :   h->traverse_noresize<gt_value_expr_mark_data *,
     269     11089324 :                        gt_value_expr_mark_1> (&data);
     270      2626600 :   for (auto v : data.to_mark)
     271         1096 :     gt_ggc_mx (v);
     272       875168 : }
     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              :   2, /* OMP_CLAUSE_MESSAGE */
     404              : };
     405              : 
     406              : const char * const omp_clause_code_name[] =
     407              : {
     408              :   "error_clause",
     409              :   "private",
     410              :   "shared",
     411              :   "firstprivate",
     412              :   "lastprivate",
     413              :   "reduction",
     414              :   "task_reduction",
     415              :   "in_reduction",
     416              :   "copyin",
     417              :   "copyprivate",
     418              :   "linear",
     419              :   "affinity",
     420              :   "aligned",
     421              :   "allocate",
     422              :   "depend",
     423              :   "nontemporal",
     424              :   "uniform",
     425              :   "enter",
     426              :   "link",
     427              :   "detach",
     428              :   "use_device_ptr",
     429              :   "use_device_addr",
     430              :   "is_device_ptr",
     431              :   "inclusive",
     432              :   "exclusive",
     433              :   "from",
     434              :   "to",
     435              :   "map",
     436              :   "has_device_addr",
     437              :   "doacross",
     438              :   "_mapper_binding_",
     439              :   "_cache_",
     440              :   "destroy",
     441              :   "init",
     442              :   "use",
     443              :   "interop",
     444              :   "gang",
     445              :   "async",
     446              :   "wait",
     447              :   "auto",
     448              :   "seq",
     449              :   "_looptemp_",
     450              :   "_reductemp_",
     451              :   "_condtemp_",
     452              :   "_scantemp_",
     453              :   "if",
     454              :   "self",
     455              :   "num_threads",
     456              :   "schedule",
     457              :   "nowait",
     458              :   "ordered",
     459              :   "default",
     460              :   "collapse",
     461              :   "untied",
     462              :   "final",
     463              :   "mergeable",
     464              :   "device",
     465              :   "dist_schedule",
     466              :   "inbranch",
     467              :   "notinbranch",
     468              :   "num_teams",
     469              :   "thread_limit",
     470              :   "proc_bind",
     471              :   "safelen",
     472              :   "simdlen",
     473              :   "device_type",
     474              :   "for",
     475              :   "parallel",
     476              :   "sections",
     477              :   "taskgroup",
     478              :   "priority",
     479              :   "grainsize",
     480              :   "num_tasks",
     481              :   "nogroup",
     482              :   "threads",
     483              :   "simd",
     484              :   "hint",
     485              :   "defaultmap",
     486              :   "order",
     487              :   "bind",
     488              :   "filter",
     489              :   "indirect",
     490              :   "partial",
     491              :   "full",
     492              :   "sizes",
     493              :   "_simduid_",
     494              :   "_simt_",
     495              :   "independent",
     496              :   "worker",
     497              :   "vector",
     498              :   "num_gangs",
     499              :   "num_workers",
     500              :   "vector_length",
     501              :   "tile",
     502              :   "if_present",
     503              :   "finalize",
     504              :   "nohost",
     505              :   "novariants",
     506              :   "nocontext",
     507              :   "dyn_groupprivate",
     508              :   "uses_allocators",
     509              :   "message"
     510              : };
     511              : 
     512              : /* Unless specific to OpenACC, we tend to internally maintain OpenMP-centric
     513              :    clause names, but for use in diagnostics etc. would like to use the "user"
     514              :    clause names.  */
     515              : 
     516              : const char *
     517          445 : user_omp_clause_code_name (tree clause, bool oacc)
     518              : {
     519              :   /* For OpenACC, the 'OMP_CLAUSE_MAP_KIND' of an 'OMP_CLAUSE_MAP' is used to
     520              :      distinguish clauses as seen by the user.  See also where front ends do
     521              :      'build_omp_clause' with 'OMP_CLAUSE_MAP'.  */
     522          890 :   if (oacc && OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP)
     523          445 :     switch (OMP_CLAUSE_MAP_KIND (clause))
     524              :       {
     525              :       case GOMP_MAP_FORCE_ALLOC:
     526              :       case GOMP_MAP_ALLOC: return "create";
     527            0 :       case GOMP_MAP_FORCE_TO:
     528            0 :       case GOMP_MAP_TO: return "copyin";
     529            0 :       case GOMP_MAP_FORCE_FROM:
     530            0 :       case GOMP_MAP_FROM: return "copyout";
     531          361 :       case GOMP_MAP_FORCE_TOFROM:
     532          361 :       case GOMP_MAP_TOFROM: return "copy";
     533            0 :       case GOMP_MAP_RELEASE: return "delete";
     534            0 :       case GOMP_MAP_FORCE_PRESENT: return "present";
     535           42 :       case GOMP_MAP_ATTACH: return "attach";
     536           42 :       case GOMP_MAP_FORCE_DETACH:
     537           42 :       case GOMP_MAP_DETACH: return "detach";
     538            0 :       case GOMP_MAP_DEVICE_RESIDENT: return "device_resident";
     539            0 :       case GOMP_MAP_LINK: return "link";
     540            0 :       case GOMP_MAP_FORCE_DEVICEPTR: return "deviceptr";
     541              :       default: break;
     542              :       }
     543              : 
     544            0 :   return omp_clause_code_name[OMP_CLAUSE_CODE (clause)];
     545              : }
     546              : 
     547              : 
     548              : /* Return the tree node structure used by tree code CODE.  */
     549              : 
     550              : static inline enum tree_node_structure_enum
     551  44678217355 : tree_node_structure_for_code (enum tree_code code)
     552              : {
     553  44678217355 :   switch (TREE_CODE_CLASS (code))
     554              :     {
     555  11047018366 :     case tcc_declaration:
     556  11047018366 :       switch (code)
     557              :         {
     558              :         case CONST_DECL:        return TS_CONST_DECL;
     559              :         case DEBUG_EXPR_DECL:   return TS_DECL_WRTL;
     560              :         case FIELD_DECL:        return TS_FIELD_DECL;
     561              :         case FUNCTION_DECL:     return TS_FUNCTION_DECL;
     562              :         case LABEL_DECL:        return TS_LABEL_DECL;
     563              :         case PARM_DECL:         return TS_PARM_DECL;
     564              :         case RESULT_DECL:       return TS_RESULT_DECL;
     565              :         case TRANSLATION_UNIT_DECL: return TS_TRANSLATION_UNIT_DECL;
     566              :         case TYPE_DECL:         return TS_TYPE_DECL;
     567              :         case VAR_DECL:          return TS_VAR_DECL;
     568              :         default:                return TS_DECL_NON_COMMON;
     569              :         }
     570              : 
     571              :     case tcc_type:              return TS_TYPE_NON_COMMON;
     572              : 
     573  11624624186 :     case tcc_binary:
     574  11624624186 :     case tcc_comparison:
     575  11624624186 :     case tcc_expression:
     576  11624624186 :     case tcc_reference:
     577  11624624186 :     case tcc_statement:
     578  11624624186 :     case tcc_unary:
     579  11624624186 :     case tcc_vl_exp:            return TS_EXP;
     580              : 
     581  15935165046 :     default:  /* tcc_constant and tcc_exceptional */
     582  15935165046 :       break;
     583              :     }
     584              : 
     585  15935165046 :   switch (code)
     586              :     {
     587              :       /* tcc_constant cases.  */
     588              :     case COMPLEX_CST:           return TS_COMPLEX;
     589       294587 :     case FIXED_CST:             return TS_FIXED_CST;
     590    777148171 :     case INTEGER_CST:           return TS_INT_CST;
     591       294587 :     case POLY_INT_CST:          return TS_POLY_INT_CST;
     592     49678076 :     case REAL_CST:              return TS_REAL_CST;
     593    259829133 :     case STRING_CST:            return TS_STRING;
     594     13873375 :     case VECTOR_CST:            return TS_VECTOR;
     595      1170619 :     case VOID_CST:              return TS_TYPED;
     596       294843 :     case RAW_DATA_CST:          return TS_RAW_DATA_CST;
     597              : 
     598              :       /* tcc_exceptional cases.  */
     599    735967594 :     case BLOCK:                 return TS_BLOCK;
     600    142849311 :     case CONSTRUCTOR:           return TS_CONSTRUCTOR;
     601              :     case ERROR_MARK:            return TS_COMMON;
     602      9028503 :     case IDENTIFIER_NODE:       return TS_IDENTIFIER;
     603       868791 :     case OMP_CLAUSE:            return TS_OMP_CLAUSE;
     604      2059094 :     case OPTIMIZATION_NODE:     return TS_OPTIMIZATION;
     605              :     case PLACEHOLDER_EXPR:      return TS_COMMON;
     606    335646061 :     case SSA_NAME:              return TS_SSA_NAME;
     607    808832322 :     case STATEMENT_LIST:        return TS_STATEMENT_LIST;
     608      4006983 :     case TARGET_OPTION_NODE:    return TS_TARGET_OPTION;
     609    276125661 :     case TREE_BINFO:            return TS_BINFO;
     610  10292473251 :     case TREE_LIST:             return TS_LIST;
     611   2222756871 :     case TREE_VEC:              return TS_VEC;
     612              : 
     613            0 :     default:
     614            0 :       gcc_unreachable ();
     615              :     }
     616              : }
     617              : 
     618              : 
     619              : /* Initialize tree_contains_struct to describe the hierarchy of tree
     620              :    nodes.  */
     621              : 
     622              : static void
     623       294587 : initialize_tree_contains_struct (void)
     624              : {
     625       294587 :   unsigned i;
     626              : 
     627     72468402 :   for (i = ERROR_MARK; i < LAST_AND_UNUSED_TREE_CODE; i++)
     628              :     {
     629     72173815 :       enum tree_code code;
     630     72173815 :       enum tree_node_structure_enum ts_code;
     631              : 
     632     72173815 :       code = (enum tree_code) i;
     633     72173815 :       ts_code = tree_node_structure_for_code (code);
     634              : 
     635              :       /* Mark the TS structure itself.  */
     636     72173815 :       tree_contains_struct[code][ts_code] = 1;
     637              : 
     638              :       /* Mark all the structures that TS is derived from.  */
     639     72173815 :       switch (ts_code)
     640              :         {
     641      1178348 :         case TS_TYPED:
     642      1178348 :         case TS_BLOCK:
     643      1178348 :         case TS_OPTIMIZATION:
     644      1178348 :         case TS_TARGET_OPTION:
     645      1178348 :           MARK_TS_BASE (code);
     646      1178348 :           break;
     647              : 
     648     59506574 :         case TS_COMMON:
     649     59506574 :         case TS_INT_CST:
     650     59506574 :         case TS_POLY_INT_CST:
     651     59506574 :         case TS_REAL_CST:
     652     59506574 :         case TS_FIXED_CST:
     653     59506574 :         case TS_VECTOR:
     654     59506574 :         case TS_STRING:
     655     59506574 :         case TS_RAW_DATA_CST:
     656     59506574 :         case TS_COMPLEX:
     657     59506574 :         case TS_SSA_NAME:
     658     59506574 :         case TS_CONSTRUCTOR:
     659     59506574 :         case TS_EXP:
     660     59506574 :         case TS_STATEMENT_LIST:
     661     59506574 :           MARK_TS_TYPED (code);
     662     59506574 :           break;
     663              : 
     664      1472935 :         case TS_IDENTIFIER:
     665      1472935 :         case TS_DECL_MINIMAL:
     666      1472935 :         case TS_TYPE_COMMON:
     667      1472935 :         case TS_LIST:
     668      1472935 :         case TS_VEC:
     669      1472935 :         case TS_BINFO:
     670      1472935 :         case TS_OMP_CLAUSE:
     671      1472935 :           MARK_TS_COMMON (code);
     672      1472935 :           break;
     673              : 
     674              :         case TS_TYPE_WITH_LANG_SPECIFIC:
     675              :           MARK_TS_TYPE_COMMON (code);
     676              :           break;
     677              : 
     678      6186327 :         case TS_TYPE_NON_COMMON:
     679      6186327 :           MARK_TS_TYPE_WITH_LANG_SPECIFIC (code);
     680      6186327 :           break;
     681              : 
     682              :         case TS_DECL_COMMON:
     683              :           MARK_TS_DECL_MINIMAL (code);
     684              :           break;
     685              : 
     686       589174 :         case TS_DECL_WRTL:
     687       589174 :         case TS_CONST_DECL:
     688       589174 :           MARK_TS_DECL_COMMON (code);
     689       589174 :           break;
     690              : 
     691       883761 :         case TS_DECL_NON_COMMON:
     692       883761 :           MARK_TS_DECL_WITH_VIS (code);
     693       883761 :           break;
     694              : 
     695       883761 :         case TS_DECL_WITH_VIS:
     696       883761 :         case TS_PARM_DECL:
     697       883761 :         case TS_LABEL_DECL:
     698       883761 :         case TS_RESULT_DECL:
     699       883761 :           MARK_TS_DECL_WRTL (code);
     700       883761 :           break;
     701              : 
     702       294587 :         case TS_FIELD_DECL:
     703       294587 :           MARK_TS_DECL_COMMON (code);
     704       294587 :           break;
     705              : 
     706       294587 :         case TS_VAR_DECL:
     707       294587 :           MARK_TS_DECL_WITH_VIS (code);
     708       294587 :           break;
     709              : 
     710       589174 :         case TS_TYPE_DECL:
     711       589174 :         case TS_FUNCTION_DECL:
     712       589174 :           MARK_TS_DECL_NON_COMMON (code);
     713       589174 :           break;
     714              : 
     715       294587 :         case TS_TRANSLATION_UNIT_DECL:
     716       294587 :           MARK_TS_DECL_COMMON (code);
     717       294587 :           break;
     718              : 
     719              :         default:
     720              :           gcc_unreachable ();
     721              :         }
     722              :     }
     723              : 
     724              :   /* Basic consistency checks for attributes used in fold.  */
     725       294587 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]);
     726       294587 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]);
     727       294587 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]);
     728       294587 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]);
     729       294587 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]);
     730       294587 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]);
     731       294587 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_COMMON]);
     732       294587 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_COMMON]);
     733       294587 :   gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_COMMON]);
     734       294587 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_COMMON]);
     735       294587 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_COMMON]);
     736       294587 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WRTL]);
     737       294587 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_WRTL]);
     738       294587 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_WRTL]);
     739       294587 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WRTL]);
     740       294587 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_WRTL]);
     741       294587 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_MINIMAL]);
     742       294587 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_MINIMAL]);
     743       294587 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_MINIMAL]);
     744       294587 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_MINIMAL]);
     745       294587 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_MINIMAL]);
     746       294587 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_MINIMAL]);
     747       294587 :   gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_MINIMAL]);
     748       294587 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]);
     749       294587 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]);
     750       294587 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]);
     751       294587 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]);
     752       294587 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]);
     753       294587 :   gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]);
     754       294587 :   gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]);
     755       294587 :   gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]);
     756       294587 :   gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]);
     757       294587 :   gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]);
     758       294587 :   gcc_assert (tree_contains_struct[CONST_DECL][TS_CONST_DECL]);
     759       294587 :   gcc_assert (tree_contains_struct[TYPE_DECL][TS_TYPE_DECL]);
     760       294587 :   gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_FUNCTION_DECL]);
     761       294587 :   gcc_assert (tree_contains_struct[IMPORTED_DECL][TS_DECL_MINIMAL]);
     762       294587 :   gcc_assert (tree_contains_struct[IMPORTED_DECL][TS_DECL_COMMON]);
     763       294587 :   gcc_assert (tree_contains_struct[NAMELIST_DECL][TS_DECL_MINIMAL]);
     764       294587 :   gcc_assert (tree_contains_struct[NAMELIST_DECL][TS_DECL_COMMON]);
     765       294587 : }
     766              : 
     767              : 
     768              : /* Init tree.cc.  */
     769              : 
     770              : void
     771       294587 : init_ttree (void)
     772              : {
     773              :   /* Initialize the hash table of types.  */
     774       294587 :   type_hash_table
     775       294587 :     = hash_table<type_cache_hasher>::create_ggc (TYPE_HASH_INITIAL_SIZE);
     776              : 
     777       294587 :   debug_expr_for_decl
     778       294587 :     = hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
     779              : 
     780       294587 :   value_expr_for_decl
     781       294587 :     = hash_table<tree_decl_map_cache_hasher>::create_ggc (512);
     782              : 
     783       294587 :   int_cst_hash_table = hash_table<int_cst_hasher>::create_ggc (1024);
     784              : 
     785       294587 :   poly_int_cst_hash_table = hash_table<poly_int_cst_hasher>::create_ggc (64);
     786              : 
     787       294587 :   int_cst_node = make_int_cst (1, 1);
     788              : 
     789       294587 :   cl_option_hash_table = hash_table<cl_option_hasher>::create_ggc (64);
     790              : 
     791       294587 :   cl_optimization_node = make_node (OPTIMIZATION_NODE);
     792       294587 :   cl_target_option_node = make_node (TARGET_OPTION_NODE);
     793              : 
     794              :   /* Initialize the tree_contains_struct array.  */
     795       294587 :   initialize_tree_contains_struct ();
     796       294587 :   lang_hooks.init_ts ();
     797       294587 : }
     798              : 
     799              : 
     800              : /* Mapping from prefix to label number.  */
     801              : 
     802              : struct identifier_hash : ggc_ptr_hash <tree_node>
     803              : {
     804        55607 :   static inline hashval_t hash (tree t)
     805              :   {
     806        55607 :     return IDENTIFIER_HASH_VALUE (t);
     807              :   }
     808              : };
     809              : struct identifier_count_traits
     810              :   : simple_hashmap_traits<identifier_hash, long> {};
     811              : typedef hash_map<tree, long, identifier_count_traits> internal_label_map;
     812              : static GTY(()) internal_label_map *internal_label_nums;
     813              : 
     814              : /* Generates an identifier intended to be used internally with the
     815              :    given PREFIX.  This is intended to be used by the frontend so that
     816              :    C++ modules can regenerate appropriate (non-clashing) identifiers on
     817              :    stream-in.  */
     818              : 
     819              : tree
     820        44374 : generate_internal_label (const char *prefix)
     821              : {
     822        44374 :   tree prefix_id = get_identifier (prefix);
     823        44374 :   if (!internal_label_nums)
     824         3092 :     internal_label_nums = internal_label_map::create_ggc();
     825        44374 :   long &num = internal_label_nums->get_or_insert (prefix_id);
     826              : 
     827        44374 :   char tmp[32];
     828        44374 :   ASM_GENERATE_INTERNAL_LABEL (tmp, prefix, num++);
     829              : 
     830        44374 :   tree id = get_identifier (tmp);
     831        44374 :   IDENTIFIER_INTERNAL_P (id) = true;
     832              : 
     833              :   /* Cache the prefix on the identifier so we can retrieve it later.  */
     834        44374 :   TREE_CHAIN (id) = prefix_id;
     835              : 
     836        44374 :   return id;
     837              : }
     838              : 
     839              : /* Get the PREFIX we created the internal identifier LABEL with.  */
     840              : 
     841              : const char *
     842            7 : prefix_for_internal_label (tree label)
     843              : {
     844            7 :   gcc_assert (IDENTIFIER_INTERNAL_P (label)
     845              :               && !IDENTIFIER_TRANSPARENT_ALIAS (label)
     846              :               && TREE_CHAIN (label)
     847              :               && TREE_CODE (TREE_CHAIN (label)) == IDENTIFIER_NODE);
     848            7 :   return IDENTIFIER_POINTER (TREE_CHAIN (label));
     849              : }
     850              : 
     851              : /* The name of the object as the assembler will see it (but before any
     852              :    translations made by ASM_OUTPUT_LABELREF).  Often this is the same
     853              :    as DECL_NAME.  It is an IDENTIFIER_NODE.  */
     854              : tree
     855   1763481071 : decl_assembler_name (tree decl)
     856              : {
     857   1763481071 :   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
     858    173825425 :     lang_hooks.set_decl_assembler_name (decl);
     859   1763481071 :   return DECL_ASSEMBLER_NAME_RAW (decl);
     860              : }
     861              : 
     862              : /* The DECL_ASSEMBLER_NAME_RAW of DECL is being explicitly set to NAME
     863              :    (either of which may be NULL).  Inform the FE, if this changes the
     864              :    name.  */
     865              : 
     866              : void
     867    929805438 : overwrite_decl_assembler_name (tree decl, tree name)
     868              : {
     869    929805438 :   if (DECL_ASSEMBLER_NAME_RAW (decl) != name)
     870    459485948 :     lang_hooks.overwrite_decl_assembler_name (decl, name);
     871    929805438 : }
     872              : 
     873              : /* Return true if DECL may need an assembler name to be set.  */
     874              : 
     875              : static inline bool
     876      5182152 : need_assembler_name_p (tree decl)
     877              : {
     878              :   /* We use DECL_ASSEMBLER_NAME to hold mangled type names for One Definition
     879              :      Rule merging.  This makes type_odr_p to return true on those types during
     880              :      LTO and by comparing the mangled name, we can say what types are intended
     881              :      to be equivalent across compilation unit.
     882              : 
     883              :      We do not store names of type_in_anonymous_namespace_p.
     884              : 
     885              :      Record, union and enumeration type have linkage that allows use
     886              :      to check type_in_anonymous_namespace_p. We do not mangle compound types
     887              :      that always can be compared structurally.
     888              : 
     889              :      Similarly for builtin types, we compare properties of their main variant.
     890              :      A special case are integer types where mangling do make differences
     891              :      between char/signed char/unsigned char etc.  Storing name for these makes
     892              :      e.g.  -fno-signed-char/-fsigned-char mismatches to be handled well.
     893              :      See cp/mangle.cc:write_builtin_type for details.  */
     894              : 
     895      5182152 :   if (TREE_CODE (decl) == TYPE_DECL)
     896              :     {
     897       158862 :       if (DECL_NAME (decl)
     898       129426 :           && decl == TYPE_NAME (TREE_TYPE (decl))
     899       129271 :           && TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == TREE_TYPE (decl)
     900       109646 :           && !TYPE_ARTIFICIAL (TREE_TYPE (decl))
     901       106626 :           && ((TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
     902        88627 :                && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE)
     903        18257 :               || TYPE_CXX_ODR_P (TREE_TYPE (decl)))
     904       105225 :           && (type_with_linkage_p (TREE_TYPE (decl))
     905        90238 :               || TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE)
     906       228906 :           && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
     907        70044 :         return !DECL_ASSEMBLER_NAME_SET_P (decl);
     908              :       return false;
     909              :     }
     910              :   /* Only FUNCTION_DECLs and VAR_DECLs are considered.  */
     911      5023290 :   if (!VAR_OR_FUNCTION_DECL_P (decl))
     912              :     return false;
     913              : 
     914              :   /* If DECL already has its assembler name set, it does not need a
     915              :      new one.  */
     916      4325649 :   if (!HAS_DECL_ASSEMBLER_NAME_P (decl)
     917      4325649 :       || DECL_ASSEMBLER_NAME_SET_P (decl))
     918              :     return false;
     919              : 
     920              :   /* Abstract decls do not need an assembler name, except they
     921              :      can be looked up by autofdo.  */
     922      1733932 :   if (DECL_ABSTRACT_P (decl) && !flag_auto_profile)
     923              :     return false;
     924              : 
     925              :   /* For VAR_DECLs, only static, public and external symbols need an
     926              :      assembler name.  */
     927      1732551 :   if (VAR_P (decl)
     928       546320 :       && !TREE_STATIC (decl)
     929       545995 :       && !TREE_PUBLIC (decl)
     930      2278546 :       && !DECL_EXTERNAL (decl))
     931              :     return false;
     932              : 
     933      1186556 :   if (TREE_CODE (decl) == FUNCTION_DECL)
     934              :     {
     935              :       /* Do not set assembler name on builtins.  Allow RTL expansion to
     936              :          decide whether to expand inline or via a regular call.  */
     937      1186231 :       if (fndecl_built_in_p (decl)
     938      1186231 :           && DECL_BUILT_IN_CLASS (decl) != BUILT_IN_FRONTEND)
     939              :         return false;
     940              : 
     941              :       /* Functions represented in the callgraph need an assembler name.  */
     942      1181516 :       if (cgraph_node::get (decl) != NULL)
     943              :         return true;
     944              : 
     945              :       /* Unused and not public functions don't need an assembler name.  */
     946         3379 :       if (!TREE_USED (decl) && !TREE_PUBLIC (decl))
     947            3 :         return false;
     948              :     }
     949              : 
     950              :   return true;
     951              : }
     952              : 
     953              : /* If T needs an assembler name, have one created for it.  */
     954              : 
     955              : void
     956      5182152 : assign_assembler_name_if_needed (tree t)
     957              : {
     958      5182152 :   if (need_assembler_name_p (t))
     959              :     {
     960              :       /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit
     961              :          diagnostics that use input_location to show locus
     962              :          information.  The problem here is that, at this point,
     963              :          input_location is generally anchored to the end of the file
     964              :          (since the parser is long gone), so we don't have a good
     965              :          position to pin it to.
     966              : 
     967              :          To alleviate this problem, this uses the location of T's
     968              :          declaration.  Examples of this are
     969              :          testsuite/g++.dg/template/cond2.C and
     970              :          testsuite/g++.dg/template/pr35240.C.  */
     971      1251859 :       location_t saved_location = input_location;
     972      1251859 :       input_location = DECL_SOURCE_LOCATION (t);
     973              : 
     974      1251859 :       decl_assembler_name (t);
     975              : 
     976      1251859 :       input_location = saved_location;
     977              :     }
     978      5182152 : }
     979              : 
     980              : /* When the target supports COMDAT groups, this indicates which group the
     981              :    DECL is associated with.  This can be either an IDENTIFIER_NODE or a
     982              :    decl, in which case its DECL_ASSEMBLER_NAME identifies the group.  */
     983              : tree
     984    395947031 : decl_comdat_group (const_tree node)
     985              : {
     986    395947031 :   struct symtab_node *snode = symtab_node::get (node);
     987    395947031 :   if (!snode)
     988              :     return NULL;
     989    378378974 :   return snode->get_comdat_group ();
     990              : }
     991              : 
     992              : /* Likewise, but make sure it's been reduced to an IDENTIFIER_NODE.  */
     993              : tree
     994        12025 : decl_comdat_group_id (const_tree node)
     995              : {
     996        12025 :   struct symtab_node *snode = symtab_node::get (node);
     997        12025 :   if (!snode)
     998              :     return NULL;
     999        12025 :   return snode->get_comdat_group_id ();
    1000              : }
    1001              : 
    1002              : /* When the target supports named section, return its name as IDENTIFIER_NODE
    1003              :    or NULL if it is in no section.  */
    1004              : const char *
    1005    757252119 : decl_section_name (const_tree node)
    1006              : {
    1007    757252119 :   struct symtab_node *snode = symtab_node::get (node);
    1008    757252119 :   if (!snode)
    1009              :     return NULL;
    1010    568913745 :   return snode->get_section ();
    1011              : }
    1012              : 
    1013              : /* Set section name of NODE to VALUE (that is expected to be
    1014              :    identifier node) */
    1015              : void
    1016      1829684 : set_decl_section_name (tree node, const char *value)
    1017              : {
    1018      1829684 :   struct symtab_node *snode;
    1019              : 
    1020      1829684 :   if (value == NULL)
    1021              :     {
    1022          219 :       snode = symtab_node::get (node);
    1023          219 :       if (!snode)
    1024              :         return;
    1025              :     }
    1026      1829465 :   else if (VAR_P (node))
    1027      1569429 :     snode = varpool_node::get_create (node);
    1028              :   else
    1029       260036 :     snode = cgraph_node::get_create (node);
    1030      1829684 :   snode->set_section (value);
    1031              : }
    1032              : 
    1033              : /* Set section name of NODE to match the section name of OTHER.
    1034              : 
    1035              :    set_decl_section_name (decl, other) is equivalent to
    1036              :    set_decl_section_name (decl, DECL_SECTION_NAME (other)), but possibly more
    1037              :    efficient.  */
    1038              : void
    1039     16734093 : set_decl_section_name (tree decl, const_tree other)
    1040              : {
    1041     16734093 :   struct symtab_node *other_node = symtab_node::get (other);
    1042     16734093 :   if (other_node)
    1043              :     {
    1044     16732625 :       struct symtab_node *decl_node;
    1045     16732625 :       if (VAR_P (decl))
    1046           23 :     decl_node = varpool_node::get_create (decl);
    1047              :       else
    1048     16732602 :     decl_node = cgraph_node::get_create (decl);
    1049     16732625 :       decl_node->set_section (*other_node);
    1050              :     }
    1051              :   else
    1052              :     {
    1053         1468 :       struct symtab_node *decl_node = symtab_node::get (decl);
    1054         1468 :       if (!decl_node)
    1055              :     return;
    1056            0 :       decl_node->set_section (NULL);
    1057              :     }
    1058              : }
    1059              : 
    1060              : /* Return TLS model of a variable NODE.  */
    1061              : enum tls_model
    1062    282224704 : decl_tls_model (const_tree node)
    1063              : {
    1064    282224704 :   struct varpool_node *snode = varpool_node::get (node);
    1065    282224704 :   if (!snode)
    1066              :     return TLS_MODEL_NONE;
    1067    232598466 :   return snode->tls_model;
    1068              : }
    1069              : 
    1070              : /* Set TLS model of variable NODE to MODEL.  */
    1071              : void
    1072        57722 : set_decl_tls_model (tree node, enum tls_model model)
    1073              : {
    1074        57722 :   struct varpool_node *vnode;
    1075              : 
    1076        57722 :   if (model == TLS_MODEL_NONE)
    1077              :     {
    1078         6134 :       vnode = varpool_node::get (node);
    1079         6134 :       if (!vnode)
    1080              :         return;
    1081              :     }
    1082              :   else
    1083        51588 :     vnode = varpool_node::get_create (node);
    1084        51588 :   vnode->tls_model = model;
    1085              : }
    1086              : 
    1087              : /* Compute the number of bytes occupied by a tree with code CODE.
    1088              :    This function cannot be used for nodes that have variable sizes,
    1089              :    including TREE_VEC, INTEGER_CST, STRING_CST, and CALL_EXPR.  */
    1090              : size_t
    1091  19378348172 : tree_code_size (enum tree_code code)
    1092              : {
    1093  19378348172 :   switch (TREE_CODE_CLASS (code))
    1094              :     {
    1095   4663940109 :     case tcc_declaration:  /* A decl node */
    1096   4663940109 :       switch (code)
    1097              :         {
    1098              :         case FIELD_DECL:        return sizeof (tree_field_decl);
    1099              :         case PARM_DECL:         return sizeof (tree_parm_decl);
    1100    285262225 :         case VAR_DECL:          return sizeof (tree_var_decl);
    1101              :         case LABEL_DECL:        return sizeof (tree_label_decl);
    1102              :         case RESULT_DECL:       return sizeof (tree_result_decl);
    1103     31477337 :         case CONST_DECL:        return sizeof (tree_const_decl);
    1104              :         case TYPE_DECL:         return sizeof (tree_type_decl);
    1105   1501314378 :         case FUNCTION_DECL:     return sizeof (tree_function_decl);
    1106              :         case DEBUG_EXPR_DECL:   return sizeof (tree_decl_with_rtl);
    1107              :         case TRANSLATION_UNIT_DECL: return sizeof (tree_translation_unit_decl);
    1108              :         case NAMESPACE_DECL:
    1109              :         case IMPORTED_DECL:
    1110              :         case NAMELIST_DECL:     return sizeof (tree_decl_non_common);
    1111    301856500 :         default:
    1112    301856500 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1113    301856500 :           return lang_hooks.tree_size (code);
    1114              :         }
    1115              : 
    1116   3224486636 :     case tcc_type:  /* a type node */
    1117   3224486636 :       switch (code)
    1118              :         {
    1119              :         case OFFSET_TYPE:
    1120              :         case ENUMERAL_TYPE:
    1121              :         case BOOLEAN_TYPE:
    1122              :         case INTEGER_TYPE:
    1123              :         case REAL_TYPE:
    1124              :         case OPAQUE_TYPE:
    1125              :         case POINTER_TYPE:
    1126              :         case REFERENCE_TYPE:
    1127              :         case NULLPTR_TYPE:
    1128              :         case FIXED_POINT_TYPE:
    1129              :         case COMPLEX_TYPE:
    1130              :         case VECTOR_TYPE:
    1131              :         case ARRAY_TYPE:
    1132              :         case RECORD_TYPE:
    1133              :         case UNION_TYPE:
    1134              :         case QUAL_UNION_TYPE:
    1135              :         case VOID_TYPE:
    1136              :         case FUNCTION_TYPE:
    1137              :         case METHOD_TYPE:
    1138              :         case BITINT_TYPE:
    1139              :         case LANG_TYPE:         return sizeof (tree_type_non_common);
    1140    769783091 :         default:
    1141    769783091 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1142    769783091 :           return lang_hooks.tree_size (code);
    1143              :         }
    1144              : 
    1145   5309847293 :     case tcc_reference:   /* a reference */
    1146   5309847293 :     case tcc_expression:  /* an expression */
    1147   5309847293 :     case tcc_statement:   /* an expression with side effects */
    1148   5309847293 :     case tcc_comparison:  /* a comparison expression */
    1149   5309847293 :     case tcc_unary:       /* a unary arithmetic expression */
    1150   5309847293 :     case tcc_binary:      /* a binary arithmetic expression */
    1151   5309847293 :       return (sizeof (struct tree_exp)
    1152   5309847293 :               + (TREE_CODE_LENGTH (code) - 1) * sizeof (tree));
    1153              : 
    1154     44621143 :     case tcc_constant:  /* a constant */
    1155     44621143 :       switch (code)
    1156              :         {
    1157              :         case VOID_CST:          return sizeof (tree_typed);
    1158            0 :         case INTEGER_CST:       gcc_unreachable ();
    1159              :         case POLY_INT_CST:      return sizeof (tree_poly_int_cst);
    1160     43765184 :         case REAL_CST:          return sizeof (tree_real_cst);
    1161              :         case FIXED_CST:         return sizeof (tree_fixed_cst);
    1162              :         case COMPLEX_CST:       return sizeof (tree_complex);
    1163              :         case RAW_DATA_CST:      return sizeof (tree_raw_data);
    1164            0 :         case VECTOR_CST:        gcc_unreachable ();
    1165            0 :         case STRING_CST:        gcc_unreachable ();
    1166        64697 :         default:
    1167        64697 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1168        64697 :           return lang_hooks.tree_size (code);
    1169              :         }
    1170              : 
    1171   6135452991 :     case tcc_exceptional:  /* something random, like an identifier.  */
    1172   6135452991 :       switch (code)
    1173              :         {
    1174   1786413383 :         case IDENTIFIER_NODE:   return lang_hooks.identifier_size;
    1175              :         case TREE_LIST:         return sizeof (tree_list);
    1176              : 
    1177              :         case ERROR_MARK:
    1178              :         case PLACEHOLDER_EXPR:  return sizeof (tree_common);
    1179              : 
    1180            0 :         case TREE_VEC:          gcc_unreachable ();
    1181            0 :         case OMP_CLAUSE:        gcc_unreachable ();
    1182              : 
    1183              :         case SSA_NAME:          return sizeof (tree_ssa_name);
    1184              : 
    1185              :         case STATEMENT_LIST:    return sizeof (tree_statement_list);
    1186    319571151 :         case BLOCK:             return sizeof (struct tree_block);
    1187              :         case CONSTRUCTOR:       return sizeof (tree_constructor);
    1188              :         case OPTIMIZATION_NODE: return sizeof (tree_optimization_option);
    1189              :         case TARGET_OPTION_NODE: return sizeof (tree_target_option);
    1190              : 
    1191   1691681884 :         default:
    1192   1691681884 :           gcc_checking_assert (code >= NUM_TREE_CODES);
    1193   1691681884 :           return lang_hooks.tree_size (code);
    1194              :         }
    1195              : 
    1196            0 :     default:
    1197            0 :       gcc_unreachable ();
    1198              :     }
    1199              : }
    1200              : 
    1201              : /* Compute the number of bytes occupied by NODE.  This routine only
    1202              :    looks at TREE_CODE, except for those nodes that have variable sizes.  */
    1203              : size_t
    1204   4688783173 : tree_size (const_tree node)
    1205              : {
    1206   4688783173 :   const enum tree_code code = TREE_CODE (node);
    1207   4688783173 :   switch (code)
    1208              :     {
    1209       539091 :     case INTEGER_CST:
    1210       539091 :       return (sizeof (struct tree_int_cst)
    1211       539091 :               + (TREE_INT_CST_EXT_NUNITS (node) - 1) * sizeof (HOST_WIDE_INT));
    1212              : 
    1213            0 :     case TREE_BINFO:
    1214            0 :       return (offsetof (struct tree_binfo, base_binfos)
    1215              :               + vec<tree, va_gc>
    1216            0 :                   ::embedded_size (BINFO_N_BASE_BINFOS (node)));
    1217              : 
    1218    428828377 :     case TREE_VEC:
    1219    428828377 :       return (sizeof (struct tree_vec)
    1220    428828377 :               + (TREE_VEC_LENGTH (node) - 1) * sizeof (tree));
    1221              : 
    1222            0 :     case VECTOR_CST:
    1223            0 :       return (sizeof (struct tree_vector)
    1224            0 :               + (vector_cst_encoded_nelts (node) - 1) * sizeof (tree));
    1225              : 
    1226        23778 :     case STRING_CST:
    1227        23778 :       return TREE_STRING_LENGTH (node) + offsetof (struct tree_string, str) + 1;
    1228              : 
    1229        33813 :     case OMP_CLAUSE:
    1230        33813 :       return (sizeof (struct tree_omp_clause)
    1231        33813 :               + (omp_clause_num_ops[OMP_CLAUSE_CODE (node)] - 1)
    1232        33813 :                 * sizeof (tree));
    1233              : 
    1234   4259358114 :     default:
    1235   4259358114 :       if (TREE_CODE_CLASS (code) == tcc_vl_exp)
    1236    197870407 :         return (sizeof (struct tree_exp)
    1237    197870407 :                 + (VL_EXP_OPERAND_LENGTH (node) - 1) * sizeof (tree));
    1238              :       else
    1239   4061487707 :         return tree_code_size (code);
    1240              :     }
    1241              : }
    1242              : 
    1243              : /* Return tree node kind based on tree CODE.  */
    1244              : 
    1245              : static tree_node_kind
    1246            0 : get_stats_node_kind (enum tree_code code)
    1247              : {
    1248            0 :   enum tree_code_class type = TREE_CODE_CLASS (code);
    1249              : 
    1250            0 :   switch (type)
    1251              :     {
    1252              :     case tcc_declaration:  /* A decl node */
    1253              :       return d_kind;
    1254            0 :     case tcc_type:  /* a type node */
    1255            0 :       return t_kind;
    1256            0 :     case tcc_statement:  /* an expression with side effects */
    1257            0 :       return s_kind;
    1258            0 :     case tcc_reference:  /* a reference */
    1259            0 :       return r_kind;
    1260              :     case tcc_expression:  /* an expression */
    1261              :     case tcc_comparison:  /* a comparison expression */
    1262              :     case tcc_unary:  /* a unary arithmetic expression */
    1263              :     case tcc_binary:  /* a binary arithmetic expression */
    1264              :       return e_kind;
    1265            0 :     case tcc_constant:  /* a constant */
    1266            0 :       return c_kind;
    1267            0 :     case tcc_exceptional:  /* something random, like an identifier.  */
    1268            0 :       switch (code)
    1269              :         {
    1270              :         case IDENTIFIER_NODE:
    1271              :           return id_kind;
    1272            0 :         case TREE_VEC:
    1273            0 :           return vec_kind;
    1274            0 :         case TREE_BINFO:
    1275            0 :           return binfo_kind;
    1276            0 :         case SSA_NAME:
    1277            0 :           return ssa_name_kind;
    1278            0 :         case BLOCK:
    1279            0 :           return b_kind;
    1280            0 :         case CONSTRUCTOR:
    1281            0 :           return constr_kind;
    1282            0 :         case OMP_CLAUSE:
    1283            0 :           return omp_clause_kind;
    1284            0 :         default:
    1285            0 :           return x_kind;
    1286              :         }
    1287              :       break;
    1288              :     case tcc_vl_exp:
    1289              :       return e_kind;
    1290            0 :     default:
    1291            0 :       gcc_unreachable ();
    1292              :     }
    1293              : }
    1294              : 
    1295              : /* Record interesting allocation statistics for a tree node with CODE
    1296              :    and LENGTH.  */
    1297              : 
    1298              : static void
    1299            0 : record_node_allocation_statistics (enum tree_code code, size_t length)
    1300              : {
    1301            0 :   if (!GATHER_STATISTICS)
    1302            0 :     return;
    1303              : 
    1304              :   tree_node_kind kind = get_stats_node_kind (code);
    1305              : 
    1306              :   tree_code_counts[(int) code]++;
    1307              :   tree_node_counts[(int) kind]++;
    1308              :   tree_node_sizes[(int) kind] += length;
    1309              : }
    1310              : 
    1311              : /* Allocate and return a new UID from the DECL_UID namespace.  */
    1312              : 
    1313              : int
    1314   4657151901 : allocate_decl_uid (void)
    1315              : {
    1316   4657151901 :   return next_decl_uid++;
    1317              : }
    1318              : 
    1319              : /* Return a newly allocated node of code CODE.  For decl and type
    1320              :    nodes, some other fields are initialized.  The rest of the node is
    1321              :    initialized to zero.  This function cannot be used for TREE_VEC,
    1322              :    INTEGER_CST or OMP_CLAUSE nodes, which is enforced by asserts in
    1323              :    tree_code_size.
    1324              : 
    1325              :    Achoo!  I got a code in the node.  */
    1326              : 
    1327              : tree
    1328  15311040609 : make_node (enum tree_code code MEM_STAT_DECL)
    1329              : {
    1330  15311040609 :   tree t;
    1331  15311040609 :   enum tree_code_class type = TREE_CODE_CLASS (code);
    1332  15311040609 :   size_t length = tree_code_size (code);
    1333              : 
    1334  15311040609 :   record_node_allocation_statistics (code, length);
    1335              : 
    1336  15311040609 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    1337  15311040609 :   TREE_SET_CODE (t, code);
    1338              : 
    1339  15311040609 :   switch (type)
    1340              :     {
    1341    793274052 :     case tcc_statement:
    1342    793274052 :       if (code != DEBUG_BEGIN_STMT)
    1343    416740971 :         TREE_SIDE_EFFECTS (t) = 1;
    1344              :       break;
    1345              : 
    1346   3324386583 :     case tcc_declaration:
    1347   3324386583 :       if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
    1348              :         {
    1349   3324386583 :           if (code == FUNCTION_DECL)
    1350              :             {
    1351   1173845537 :               SET_DECL_ALIGN (t, FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY));
    1352   1173845537 :               SET_DECL_MODE (t, FUNCTION_MODE);
    1353              :             }
    1354              :           else
    1355   2150541046 :             SET_DECL_ALIGN (t, 1);
    1356              :         }
    1357   3324386583 :       DECL_SOURCE_LOCATION (t) = input_location;
    1358   3324386583 :       if (TREE_CODE (t) == DEBUG_EXPR_DECL)
    1359      2059492 :         DECL_UID (t) = --next_debug_decl_uid;
    1360              :       else
    1361              :         {
    1362   3322327091 :           DECL_UID (t) = allocate_decl_uid ();
    1363   3322327091 :           SET_DECL_PT_UID (t, -1);
    1364              :         }
    1365   3324386583 :       if (TREE_CODE (t) == LABEL_DECL)
    1366     38078019 :         LABEL_DECL_UID (t) = -1;
    1367              : 
    1368              :       break;
    1369              : 
    1370   2390971555 :     case tcc_type:
    1371   2390971555 :       TYPE_UID (t) = next_type_uid++;
    1372   2390971555 :       SET_TYPE_ALIGN (t, BITS_PER_UNIT);
    1373   2390971555 :       TYPE_USER_ALIGN (t) = 0;
    1374   2390971555 :       TYPE_MAIN_VARIANT (t) = t;
    1375   2390971555 :       TYPE_CANONICAL (t) = t;
    1376              : 
    1377              :       /* Default to no attributes for type, but let target change that.  */
    1378   2390971555 :       TYPE_ATTRIBUTES (t) = NULL_TREE;
    1379   2390971555 :       targetm.set_default_type_attributes (t);
    1380              : 
    1381              :       /* We have not yet computed the alias set for this type.  */
    1382   2390971555 :       TYPE_ALIAS_SET (t) = -1;
    1383   2390971555 :       break;
    1384              : 
    1385     44619281 :     case tcc_constant:
    1386     44619281 :       TREE_CONSTANT (t) = 1;
    1387     44619281 :       break;
    1388              : 
    1389   1381426454 :     case tcc_expression:
    1390   1381426454 :       switch (code)
    1391              :         {
    1392    298122636 :         case INIT_EXPR:
    1393    298122636 :         case MODIFY_EXPR:
    1394    298122636 :         case VA_ARG_EXPR:
    1395    298122636 :         case PREDECREMENT_EXPR:
    1396    298122636 :         case PREINCREMENT_EXPR:
    1397    298122636 :         case POSTDECREMENT_EXPR:
    1398    298122636 :         case POSTINCREMENT_EXPR:
    1399              :           /* All of these have side-effects, no matter what their
    1400              :              operands are.  */
    1401    298122636 :           TREE_SIDE_EFFECTS (t) = 1;
    1402    298122636 :           break;
    1403              : 
    1404              :         default:
    1405              :           break;
    1406              :         }
    1407              :       break;
    1408              : 
    1409   5907975943 :     case tcc_exceptional:
    1410   5907975943 :       switch (code)
    1411              :         {
    1412      1104465 :         case TARGET_OPTION_NODE:
    1413      2208930 :           TREE_TARGET_OPTION(t)
    1414      1104465 :                             = ggc_cleared_alloc<struct cl_target_option> ();
    1415      1104465 :           break;
    1416              : 
    1417       613574 :         case OPTIMIZATION_NODE:
    1418      1227148 :           TREE_OPTIMIZATION (t)
    1419       613574 :                             = ggc_cleared_alloc<struct cl_optimization> ();
    1420       613574 :           break;
    1421              : 
    1422              :         default:
    1423              :           break;
    1424              :         }
    1425              :       break;
    1426              : 
    1427              :     default:
    1428              :       /* Other classes need no special treatment.  */
    1429              :       break;
    1430              :     }
    1431              : 
    1432  15311040609 :   return t;
    1433              : }
    1434              : 
    1435              : /* Free tree node.  */
    1436              : 
    1437              : void
    1438    686100443 : free_node (tree node)
    1439              : {
    1440    686100443 :   enum tree_code code = TREE_CODE (node);
    1441    686100443 :   if (GATHER_STATISTICS)
    1442              :     {
    1443              :       enum tree_node_kind kind = get_stats_node_kind (code);
    1444              : 
    1445              :       gcc_checking_assert (tree_code_counts[(int) TREE_CODE (node)] != 0);
    1446              :       gcc_checking_assert (tree_node_counts[(int) kind] != 0);
    1447              :       gcc_checking_assert (tree_node_sizes[(int) kind] >= tree_size (node));
    1448              : 
    1449              :       tree_code_counts[(int) TREE_CODE (node)]--;
    1450              :       tree_node_counts[(int) kind]--;
    1451              :       tree_node_sizes[(int) kind] -= tree_size (node);
    1452              :     }
    1453    686100443 :   if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
    1454          349 :     vec_free (CONSTRUCTOR_ELTS (node));
    1455    686100250 :   else if (code == BLOCK)
    1456            0 :     vec_free (BLOCK_NONLOCALIZED_VARS (node));
    1457    686100250 :   else if (code == TREE_BINFO)
    1458          369 :     vec_free (BINFO_BASE_ACCESSES (node));
    1459    686099881 :   else if (code == OPTIMIZATION_NODE)
    1460          867 :     cl_optimization_option_free (TREE_OPTIMIZATION (node));
    1461    686099014 :   else if (code == TARGET_OPTION_NODE)
    1462          932 :     cl_target_option_free (TREE_TARGET_OPTION (node));
    1463    686100443 :   ggc_free (node);
    1464    686100443 : }
    1465              : 
    1466              : /* Return a new node with the same contents as NODE except that its
    1467              :    TREE_CHAIN, if it has one, is zero and it has a fresh uid.  */
    1468              : 
    1469              : tree
    1470   4602583743 : copy_node (tree node MEM_STAT_DECL)
    1471              : {
    1472   4602583743 :   tree t;
    1473   4602583743 :   enum tree_code code = TREE_CODE (node);
    1474   4602583743 :   size_t length;
    1475              : 
    1476   4602583743 :   gcc_assert (code != STATEMENT_LIST);
    1477              : 
    1478   4602583743 :   length = tree_size (node);
    1479   4602583743 :   record_node_allocation_statistics (code, length);
    1480   4602583743 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    1481   4602583743 :   memcpy (t, node, length);
    1482              : 
    1483   4602583743 :   if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
    1484   2647119916 :     TREE_CHAIN (t) = 0;
    1485   4602583743 :   TREE_ASM_WRITTEN (t) = 0;
    1486   4602583743 :   TREE_VISITED (t) = 0;
    1487              : 
    1488   4602583743 :   if (TREE_CODE_CLASS (code) == tcc_declaration)
    1489              :     {
    1490   1333733670 :       if (code == DEBUG_EXPR_DECL)
    1491            0 :         DECL_UID (t) = --next_debug_decl_uid;
    1492              :       else
    1493              :         {
    1494   1333733670 :           DECL_UID (t) = allocate_decl_uid ();
    1495   1333733670 :           if (DECL_PT_UID_SET_P (node))
    1496         3534 :             SET_DECL_PT_UID (t, DECL_PT_UID (node));
    1497              :         }
    1498    664674249 :       if ((TREE_CODE (node) == PARM_DECL || VAR_P (node))
    1499   1422641430 :           && DECL_HAS_VALUE_EXPR_P (node))
    1500              :         {
    1501      1274245 :           SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node));
    1502      1274245 :           DECL_HAS_VALUE_EXPR_P (t) = 1;
    1503              :         }
    1504              :       /* DECL_DEBUG_EXPR is copied explicitly by callers.  */
    1505   1333733670 :       if (VAR_P (node))
    1506              :         {
    1507     88907760 :           DECL_HAS_DEBUG_EXPR_P (t) = 0;
    1508     88907760 :           t->decl_with_vis.symtab_node = NULL;
    1509              :         }
    1510   1333733670 :       if (VAR_P (node) && DECL_HAS_INIT_PRIORITY_P (node))
    1511              :         {
    1512            0 :           SET_DECL_INIT_PRIORITY (t, DECL_INIT_PRIORITY (node));
    1513            0 :           DECL_HAS_INIT_PRIORITY_P (t) = 1;
    1514              :         }
    1515   1333733670 :       if (TREE_CODE (node) == FUNCTION_DECL)
    1516              :         {
    1517    322288677 :           DECL_STRUCT_FUNCTION (t) = NULL;
    1518    322288677 :           t->decl_with_vis.symtab_node = NULL;
    1519              :         }
    1520              :     }
    1521   3268850073 :   else if (TREE_CODE_CLASS (code) == tcc_type)
    1522              :     {
    1523    833515081 :       TYPE_UID (t) = next_type_uid++;
    1524              :       /* The following is so that the debug code for
    1525              :          the copy is different from the original type.
    1526              :          The two statements usually duplicate each other
    1527              :          (because they clear fields of the same union),
    1528              :          but the optimizer should catch that.  */
    1529    833515081 :       TYPE_SYMTAB_ADDRESS (t) = 0;
    1530    833515081 :       TYPE_SYMTAB_DIE (t) = 0;
    1531              : 
    1532              :       /* Do not copy the values cache.  */
    1533    833515081 :       if (TYPE_CACHED_VALUES_P (t))
    1534              :         {
    1535     20203674 :           TYPE_CACHED_VALUES_P (t) = 0;
    1536     20203674 :           TYPE_CACHED_VALUES (t) = NULL_TREE;
    1537              :         }
    1538              :     }
    1539   2435334992 :     else if (code == TARGET_OPTION_NODE)
    1540              :       {
    1541            0 :         TREE_TARGET_OPTION (t) = ggc_alloc<struct cl_target_option>();
    1542            0 :         memcpy (TREE_TARGET_OPTION (t), TREE_TARGET_OPTION (node),
    1543              :                 sizeof (struct cl_target_option));
    1544              :       }
    1545   2435334992 :     else if (code == OPTIMIZATION_NODE)
    1546              :       {
    1547            0 :         TREE_OPTIMIZATION (t) = ggc_alloc<struct cl_optimization>();
    1548            0 :         memcpy (TREE_OPTIMIZATION (t), TREE_OPTIMIZATION (node),
    1549              :                 sizeof (struct cl_optimization));
    1550              :       }
    1551              : 
    1552   4602583743 :   return t;
    1553              : }
    1554              : 
    1555              : /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
    1556              :    For example, this can copy a list made of TREE_LIST nodes.  */
    1557              : 
    1558              : tree
    1559    169991086 : copy_list (tree list)
    1560              : {
    1561    169991086 :   tree head;
    1562    169991086 :   tree prev, next;
    1563              : 
    1564    169991086 :   if (list == 0)
    1565              :     return 0;
    1566              : 
    1567    164694459 :   head = prev = copy_node (list);
    1568    164694459 :   next = TREE_CHAIN (list);
    1569    323401839 :   while (next)
    1570              :     {
    1571    158707380 :       TREE_CHAIN (prev) = copy_node (next);
    1572    158707380 :       prev = TREE_CHAIN (prev);
    1573    158707380 :       next = TREE_CHAIN (next);
    1574              :     }
    1575              :   return head;
    1576              : }
    1577              : 
    1578              : 
    1579              : /* Return the value that TREE_INT_CST_EXT_NUNITS should have for an
    1580              :    INTEGER_CST with value CST and type TYPE.   */
    1581              : 
    1582              : static unsigned int
    1583  11223035247 : get_int_cst_ext_nunits (tree type, const wide_int &cst)
    1584              : {
    1585  11223035247 :   gcc_checking_assert (cst.get_precision () == TYPE_PRECISION (type));
    1586              :   /* We need extra HWIs if CST is an unsigned integer with its
    1587              :      upper bit set.  */
    1588  11223035247 :   if (TYPE_UNSIGNED (type) && wi::neg_p (cst))
    1589    187760148 :     return cst.get_precision () / HOST_BITS_PER_WIDE_INT + 1;
    1590  11035275099 :   return cst.get_len ();
    1591              : }
    1592              : 
    1593              : /* Return a new INTEGER_CST with value CST and type TYPE.  */
    1594              : 
    1595              : static tree
    1596    136076163 : build_new_int_cst (tree type, const wide_int &cst)
    1597              : {
    1598    136076163 :   unsigned int len = cst.get_len ();
    1599    136076163 :   unsigned int ext_len = get_int_cst_ext_nunits (type, cst);
    1600    136076163 :   tree nt = make_int_cst (len, ext_len);
    1601              : 
    1602    136076163 :   if (len < ext_len)
    1603              :     {
    1604     69742222 :       --ext_len;
    1605    139484444 :       TREE_INT_CST_ELT (nt, ext_len)
    1606     69742222 :         = zext_hwi (-1, cst.get_precision () % HOST_BITS_PER_WIDE_INT);
    1607     93193748 :       for (unsigned int i = len; i < ext_len; ++i)
    1608     23451526 :         TREE_INT_CST_ELT (nt, i) = -1;
    1609              :     }
    1610     66333941 :   else if (TYPE_UNSIGNED (type)
    1611     66333941 :            && cst.get_precision () < len * HOST_BITS_PER_WIDE_INT)
    1612              :     {
    1613     14363573 :       len--;
    1614     28727146 :       TREE_INT_CST_ELT (nt, len)
    1615     14363573 :         = zext_hwi (cst.elt (len),
    1616     14363573 :                     cst.get_precision () % HOST_BITS_PER_WIDE_INT);
    1617              :     }
    1618              : 
    1619    261293074 :   for (unsigned int i = 0; i < len; i++)
    1620    125216911 :     TREE_INT_CST_ELT (nt, i) = cst.elt (i);
    1621    136076163 :   TREE_TYPE (nt) = type;
    1622    136076163 :   return nt;
    1623              : }
    1624              : 
    1625              : /* Return a new POLY_INT_CST with coefficients COEFFS and type TYPE.  */
    1626              : 
    1627              : static tree
    1628            0 : build_new_poly_int_cst (tree type, tree (&coeffs)[NUM_POLY_INT_COEFFS]
    1629              :                         CXX_MEM_STAT_INFO)
    1630              : {
    1631            0 :   size_t length = sizeof (struct tree_poly_int_cst);
    1632            0 :   record_node_allocation_statistics (POLY_INT_CST, length);
    1633              : 
    1634            0 :   tree t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    1635              : 
    1636            0 :   TREE_SET_CODE (t, POLY_INT_CST);
    1637            0 :   TREE_CONSTANT (t) = 1;
    1638            0 :   TREE_TYPE (t) = type;
    1639            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1640            0 :     POLY_INT_CST_COEFF (t, i) = coeffs[i];
    1641            0 :   return t;
    1642              : }
    1643              : 
    1644              : /* Create a constant tree that contains CST sign-extended to TYPE.  */
    1645              : 
    1646              : tree
    1647   7391376753 : build_int_cst (tree type, poly_int64 cst)
    1648              : {
    1649              :   /* Support legacy code.  */
    1650   7391376753 :   if (!type)
    1651           48 :     type = integer_type_node;
    1652              : 
    1653   7391376753 :   return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
    1654              : }
    1655              : 
    1656              : /* Create a constant tree that contains CST zero-extended to TYPE.  */
    1657              : 
    1658              : tree
    1659      9918193 : build_int_cstu (tree type, poly_uint64 cst)
    1660              : {
    1661      9918193 :   return wide_int_to_tree (type, wi::uhwi (cst, TYPE_PRECISION (type)));
    1662              : }
    1663              : 
    1664              : /* Create a constant tree that contains CST sign-extended to TYPE.  */
    1665              : 
    1666              : tree
    1667     27769192 : build_int_cst_type (tree type, poly_int64 cst)
    1668              : {
    1669     27769192 :   gcc_assert (type);
    1670     27769192 :   return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
    1671              : }
    1672              : 
    1673              : /* Constructs tree in type TYPE from with value given by CST.  Signedness
    1674              :    of CST is assumed to be the same as the signedness of TYPE.  */
    1675              : 
    1676              : tree
    1677      7298064 : double_int_to_tree (tree type, double_int cst)
    1678              : {
    1679      7298064 :   return wide_int_to_tree (type, widest_int::from (cst, TYPE_SIGN (type)));
    1680              : }
    1681              : 
    1682              : /* We force the wide_int CST to the range of the type TYPE by sign or
    1683              :    zero extending it.  OVERFLOWABLE indicates if we are interested in
    1684              :    overflow of the value, when >0 we are only interested in signed
    1685              :    overflow, for <0 we are interested in any overflow.  OVERFLOWED
    1686              :    indicates whether overflow has already occurred.  CONST_OVERFLOWED
    1687              :    indicates whether constant overflow has already occurred.  We force
    1688              :    T's value to be within range of T's type (by setting to 0 or 1 all
    1689              :    the bits outside the type's range).  We set TREE_OVERFLOWED if,
    1690              :         OVERFLOWED is nonzero,
    1691              :         or OVERFLOWABLE is >0 and signed overflow occurs
    1692              :         or OVERFLOWABLE is <0 and any overflow occurs
    1693              :    We return a new tree node for the extended wide_int.  The node
    1694              :    is shared if no overflow flags are set.  */
    1695              : 
    1696              : 
    1697              : tree
    1698   3061878822 : force_fit_type (tree type, const poly_wide_int_ref &cst,
    1699              :                 int overflowable, bool overflowed)
    1700              : {
    1701   3061878822 :   signop sign = TYPE_SIGN (type);
    1702              : 
    1703              :   /* If we need to set overflow flags, return a new unshared node.  */
    1704   3061878822 :   if (overflowed || !wi::fits_to_tree_p (cst, type))
    1705              :     {
    1706      7188437 :       if (overflowed
    1707      7188437 :           || overflowable < 0
    1708      5947386 :           || (overflowable > 0 && sign == SIGNED))
    1709              :         {
    1710      1322829 :           poly_wide_int tmp = poly_wide_int::from (cst, TYPE_PRECISION (type),
    1711      1322829 :                                                    sign);
    1712      1322829 :           tree t;
    1713      1322829 :           if (tmp.is_constant ())
    1714      1322829 :             t = build_new_int_cst (type, tmp.coeffs[0]);
    1715              :           else
    1716              :             {
    1717              :               tree coeffs[NUM_POLY_INT_COEFFS];
    1718              :               for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1719              :                 {
    1720              :                   coeffs[i] = build_new_int_cst (type, tmp.coeffs[i]);
    1721              :                   TREE_OVERFLOW (coeffs[i]) = 1;
    1722              :                 }
    1723              :               t = build_new_poly_int_cst (type, coeffs);
    1724              :             }
    1725      1322829 :           TREE_OVERFLOW (t) = 1;
    1726      1322829 :           return t;
    1727      1322829 :         }
    1728              :     }
    1729              : 
    1730              :   /* Else build a shared node.  */
    1731   3060555993 :   return wide_int_to_tree (type, cst);
    1732              : }
    1733              : 
    1734              : /* These are the hash table functions for the hash table of INTEGER_CST
    1735              :    nodes of a sizetype.  */
    1736              : 
    1737              : /* Return the hash code X, an INTEGER_CST.  */
    1738              : 
    1739              : hashval_t
    1740   2946029694 : int_cst_hasher::hash (tree x)
    1741              : {
    1742   2946029694 :   const_tree const t = x;
    1743   2946029694 :   hashval_t code = TYPE_UID (TREE_TYPE (t));
    1744   2946029694 :   int i;
    1745              : 
    1746   5897639446 :   for (i = 0; i < TREE_INT_CST_NUNITS (t); i++)
    1747   2951609752 :     code = iterative_hash_host_wide_int (TREE_INT_CST_ELT(t, i), code);
    1748              : 
    1749   2946029694 :   return code;
    1750              : }
    1751              : 
    1752              : /* Return nonzero if the value represented by *X (an INTEGER_CST tree node)
    1753              :    is the same as that given by *Y, which is the same.  */
    1754              : 
    1755              : bool
    1756   2886868379 : int_cst_hasher::equal (tree x, tree y)
    1757              : {
    1758   2886868379 :   const_tree const xt = x;
    1759   2886868379 :   const_tree const yt = y;
    1760              : 
    1761   2886868379 :   if (TREE_TYPE (xt) != TREE_TYPE (yt)
    1762    965147212 :       || TREE_INT_CST_NUNITS (xt) != TREE_INT_CST_NUNITS (yt)
    1763   3851963678 :       || TREE_INT_CST_EXT_NUNITS (xt) != TREE_INT_CST_EXT_NUNITS (yt))
    1764              :     return false;
    1765              : 
    1766   1321684360 :   for (int i = 0; i < TREE_INT_CST_NUNITS (xt); i++)
    1767    929027413 :     if (TREE_INT_CST_ELT (xt, i) != TREE_INT_CST_ELT (yt, i))
    1768              :       return false;
    1769              : 
    1770              :   return true;
    1771              : }
    1772              : 
    1773              : /* Cache wide_int CST into the TYPE_CACHED_VALUES cache for TYPE.
    1774              :    SLOT is the slot entry to store it in, and MAX_SLOTS is the maximum
    1775              :    number of slots that can be cached for the type.  */
    1776              : 
    1777              : static inline tree
    1778  10525830443 : cache_wide_int_in_type_cache (tree type, const wide_int &cst,
    1779              :                               int slot, int max_slots)
    1780              : {
    1781  10525830443 :   gcc_checking_assert (slot >= 0);
    1782              :   /* Initialize cache.  */
    1783  10525830443 :   if (!TYPE_CACHED_VALUES_P (type))
    1784              :     {
    1785     20426672 :       TYPE_CACHED_VALUES_P (type) = 1;
    1786     20426672 :       TYPE_CACHED_VALUES (type) = make_tree_vec (max_slots);
    1787              :     }
    1788  10525830443 :   tree t = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), slot);
    1789  10525830443 :   if (!t)
    1790              :     {
    1791              :       /* Create a new shared int.  */
    1792     62712985 :       t = build_new_int_cst (type, cst);
    1793     62712985 :       TREE_VEC_ELT (TYPE_CACHED_VALUES (type), slot) = t;
    1794              :     }
    1795  10525830443 :   return t;
    1796              : }
    1797              : 
    1798              : /* Create an INT_CST node of TYPE and value CST.
    1799              :    The returned node is always shared.  For small integers we use a
    1800              :    per-type vector cache, for larger ones we use a single hash table.
    1801              :    The value is extended from its precision according to the sign of
    1802              :    the type to be a multiple of HOST_BITS_PER_WIDE_INT.  This defines
    1803              :    the upper bits and ensures that hashing and value equality based
    1804              :    upon the underlying HOST_WIDE_INTs works without masking.  */
    1805              : 
    1806              : static tree
    1807  11086959084 : wide_int_to_tree_1 (tree type, const wide_int_ref &pcst)
    1808              : {
    1809  11086959084 :   tree t;
    1810  11086959084 :   int ix = -1;
    1811  11086959084 :   int limit = 0;
    1812              : 
    1813  11086959084 :   gcc_assert (type);
    1814  11086959084 :   unsigned int prec = TYPE_PRECISION (type);
    1815  11086959084 :   signop sgn = TYPE_SIGN (type);
    1816              : 
    1817              :   /* Verify that everything is canonical.  */
    1818  11086959084 :   int l = pcst.get_len ();
    1819  11086959084 :   if (l > 1)
    1820              :     {
    1821      4009402 :       if (pcst.elt (l - 1) == 0)
    1822      1149800 :         gcc_checking_assert (pcst.elt (l - 2) < 0);
    1823      4009402 :       if (pcst.elt (l - 1) == HOST_WIDE_INT_M1)
    1824        11456 :         gcc_checking_assert (pcst.elt (l - 2) >= 0);
    1825              :     }
    1826              : 
    1827  11086959084 :   wide_int cst = wide_int::from (pcst, prec, sgn);
    1828  11086959084 :   unsigned int ext_len = get_int_cst_ext_nunits (type, cst);
    1829              : 
    1830  11086959084 :   enum tree_code code = TREE_CODE (type);
    1831  11086959084 :   if (code == POINTER_TYPE || code == REFERENCE_TYPE)
    1832              :     {
    1833              :       /* Cache NULL pointer and zero bounds.  */
    1834    193660915 :       if (cst == 0)
    1835              :         ix = 0;
    1836              :       /* Cache upper bounds of pointers.  */
    1837     51526303 :       else if (cst == wi::max_value (prec, sgn))
    1838              :         ix = 1;
    1839              :       /* Cache 1 which is used for a non-zero range.  */
    1840     49406219 :       else if (cst == 1)
    1841              :         ix = 2;
    1842              : 
    1843              :       if (ix >= 0)
    1844              :         {
    1845    150100096 :           t = cache_wide_int_in_type_cache (type, cst, ix, 3);
    1846              :           /* Make sure no one is clobbering the shared constant.  */
    1847    150100096 :           gcc_checking_assert (TREE_TYPE (t) == type
    1848              :                                && cst == wi::to_wide (t));
    1849    150100096 :           return t;
    1850              :         }
    1851              :     }
    1852  10936858988 :   if (ext_len == 1)
    1853              :     {
    1854              :       /* We just need to store a single HOST_WIDE_INT.  */
    1855  10864818639 :       HOST_WIDE_INT hwi;
    1856  10864818639 :       if (TYPE_UNSIGNED (type))
    1857   7311710287 :         hwi = cst.to_uhwi ();
    1858              :       else
    1859   3553174487 :         hwi = cst.to_shwi ();
    1860              : 
    1861  10864818639 :       switch (code)
    1862              :         {
    1863              :         /* This could represent the C++ std::meta::info type.  */
    1864       228705 :         case LANG_TYPE:
    1865       228705 :         case NULLPTR_TYPE:
    1866       228705 :           gcc_assert (hwi == 0);
    1867              :           /* Fallthru.  */
    1868              : 
    1869              :         case POINTER_TYPE:
    1870              :         case REFERENCE_TYPE:
    1871              :           /* Ignore pointers, as they were already handled above.  */
    1872              :           break;
    1873              : 
    1874    115383213 :         case BOOLEAN_TYPE:
    1875              :           /* Cache false or true.  */
    1876    115383213 :           limit = 2;
    1877    115383213 :           if (IN_RANGE (hwi, 0, 1))
    1878    115176238 :             ix = hwi;
    1879              :           break;
    1880              : 
    1881  10690546664 :         case INTEGER_TYPE:
    1882  10690546664 :         case OFFSET_TYPE:
    1883  10690546664 :         case BITINT_TYPE:
    1884  10690546664 :           if (TYPE_SIGN (type) == UNSIGNED)
    1885              :             {
    1886              :               /* Cache [0, N).  */
    1887   7143733209 :               limit = param_integer_share_limit;
    1888   7143733209 :               if (IN_RANGE (hwi, 0, param_integer_share_limit - 1))
    1889   6863494245 :                 ix = hwi;
    1890              :             }
    1891              :           else
    1892              :             {
    1893              :               /* Cache [-1, N).  */
    1894   3546813455 :               limit = param_integer_share_limit + 1;
    1895   3546813455 :               if (IN_RANGE (hwi, -1, param_integer_share_limit - 1))
    1896   3397059864 :                 ix = hwi + 1;
    1897              :             }
    1898              :           break;
    1899              : 
    1900              :         case ENUMERAL_TYPE:
    1901              :           break;
    1902              : 
    1903            0 :         default:
    1904            0 :           gcc_unreachable ();
    1905              :         }
    1906              : 
    1907  10864818639 :       if (ix >= 0)
    1908              :         {
    1909  10375730347 :           t = cache_wide_int_in_type_cache (type, cst, ix, limit);
    1910              :           /* Make sure no one is clobbering the shared constant.  */
    1911  20751460694 :           gcc_checking_assert (TREE_TYPE (t) == type
    1912              :                                && TREE_INT_CST_NUNITS (t) == 1
    1913              :                                && TREE_INT_CST_EXT_NUNITS (t) == 1
    1914              :                                && TREE_INT_CST_ELT (t, 0) == hwi);
    1915              :           return t;
    1916              :         }
    1917              :       else
    1918              :         {
    1919              :           /* Use the cache of larger shared ints, using int_cst_node as
    1920              :              a temporary.  */
    1921              : 
    1922    489088292 :           TREE_INT_CST_ELT (int_cst_node, 0) = hwi;
    1923    489088292 :           TREE_TYPE (int_cst_node) = type;
    1924              : 
    1925    489088292 :           tree *slot = int_cst_hash_table->find_slot (int_cst_node, INSERT);
    1926    489088292 :           t = *slot;
    1927    489088292 :           if (!t)
    1928              :             {
    1929              :               /* Insert this one into the hash table.  */
    1930    156587280 :               t = int_cst_node;
    1931    156587280 :               *slot = t;
    1932              :               /* Make a new node for next time round.  */
    1933    156587280 :               int_cst_node = make_int_cst (1, 1);
    1934              :             }
    1935              :         }
    1936              :     }
    1937              :   else
    1938              :     {
    1939              :       /* The value either hashes properly or we drop it on the floor
    1940              :          for the gc to take care of.  There will not be enough of them
    1941              :          to worry about.  */
    1942              : 
    1943     72040349 :       tree nt = build_new_int_cst (type, cst);
    1944     72040349 :       tree *slot = int_cst_hash_table->find_slot (nt, INSERT);
    1945     72040349 :       t = *slot;
    1946     72040349 :       if (!t)
    1947              :         {
    1948              :           /* Insert this one into the hash table.  */
    1949     12609293 :           t = nt;
    1950     12609293 :           *slot = t;
    1951              :         }
    1952              :       else
    1953     59431056 :         ggc_free (nt);
    1954              :     }
    1955              : 
    1956              :   return t;
    1957  11086959084 : }
    1958              : 
    1959              : hashval_t
    1960            0 : poly_int_cst_hasher::hash (tree t)
    1961              : {
    1962            0 :   inchash::hash hstate;
    1963              : 
    1964            0 :   hstate.add_int (TYPE_UID (TREE_TYPE (t)));
    1965            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1966            0 :     hstate.add_wide_int (wi::to_wide (POLY_INT_CST_COEFF (t, i)));
    1967              : 
    1968            0 :   return hstate.end ();
    1969              : }
    1970              : 
    1971              : bool
    1972            0 : poly_int_cst_hasher::equal (tree x, const compare_type &y)
    1973              : {
    1974            0 :   if (TREE_TYPE (x) != y.first)
    1975              :     return false;
    1976            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1977            0 :     if (wi::to_wide (POLY_INT_CST_COEFF (x, i)) != y.second->coeffs[i])
    1978              :       return false;
    1979              :   return true;
    1980              : }
    1981              : 
    1982              : /* Build a POLY_INT_CST node with type TYPE and with the elements in VALUES.
    1983              :    The elements must also have type TYPE.  */
    1984              : 
    1985              : tree
    1986            0 : build_poly_int_cst (tree type, const poly_wide_int_ref &values)
    1987              : {
    1988            0 :   unsigned int prec = TYPE_PRECISION (type);
    1989            0 :   gcc_assert (prec <= values.coeffs[0].get_precision ());
    1990            0 :   poly_wide_int c = poly_wide_int::from (values, prec, SIGNED);
    1991              : 
    1992            0 :   inchash::hash h;
    1993            0 :   h.add_int (TYPE_UID (type));
    1994            0 :   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    1995            0 :     h.add_wide_int (c.coeffs[i]);
    1996            0 :   poly_int_cst_hasher::compare_type comp (type, &c);
    1997            0 :   tree *slot = poly_int_cst_hash_table->find_slot_with_hash (comp, h.end (),
    1998              :                                                              INSERT);
    1999            0 :   if (*slot == NULL_TREE)
    2000              :     {
    2001              :       tree coeffs[NUM_POLY_INT_COEFFS];
    2002            0 :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    2003            0 :         coeffs[i] = wide_int_to_tree_1 (type, c.coeffs[i]);
    2004            0 :       *slot = build_new_poly_int_cst (type, coeffs);
    2005              :     }
    2006            0 :   return *slot;
    2007            0 : }
    2008              : 
    2009              : /* Create a constant tree with value VALUE in type TYPE.  */
    2010              : 
    2011              : tree
    2012  11086959084 : wide_int_to_tree (tree type, const poly_wide_int_ref &value)
    2013              : {
    2014  11086959084 :   if (value.is_constant ())
    2015  11086959084 :     return wide_int_to_tree_1 (type, value.coeffs[0]);
    2016              :   return build_poly_int_cst (type, value);
    2017              : }
    2018              : 
    2019              : /* Insert INTEGER_CST T into a cache of integer constants.  And return
    2020              :    the cached constant (which may or may not be T).  If MIGHT_DUPLICATE
    2021              :    is false, and T falls into the type's 'smaller values' range, there
    2022              :    cannot be an existing entry.  Otherwise, if MIGHT_DUPLICATE is true,
    2023              :    or the value is large, should an existing entry exist, it is
    2024              :    returned (rather than inserting T).  */
    2025              : 
    2026              : tree
    2027       640019 : cache_integer_cst (tree t, bool might_duplicate ATTRIBUTE_UNUSED)
    2028              : {
    2029       640019 :   tree type = TREE_TYPE (t);
    2030       640019 :   int ix = -1;
    2031       640019 :   int limit = 0;
    2032       640019 :   int prec = TYPE_PRECISION (type);
    2033              : 
    2034       640019 :   gcc_assert (!TREE_OVERFLOW (t));
    2035              : 
    2036              :   /* The caching indices here must match those in
    2037              :      wide_int_to_type_1.  */
    2038       640019 :   switch (TREE_CODE (type))
    2039              :     {
    2040              :     /* This could represent the C++ std::meta::info type.  */
    2041            2 :     case LANG_TYPE:
    2042            2 :     case NULLPTR_TYPE:
    2043            2 :       gcc_checking_assert (integer_zerop (t));
    2044              :       /* Fallthru.  */
    2045              : 
    2046         4900 :     case POINTER_TYPE:
    2047         4900 :     case REFERENCE_TYPE:
    2048         4900 :       {
    2049         4900 :         if (integer_zerop (t))
    2050              :           ix = 0;
    2051         1896 :         else if (integer_onep (t))
    2052              :           ix = 2;
    2053              : 
    2054              :         if (ix >= 0)
    2055              :           limit = 3;
    2056              :       }
    2057              :       break;
    2058              : 
    2059        10884 :     case BOOLEAN_TYPE:
    2060              :       /* Cache false or true.  */
    2061        10884 :       limit = 2;
    2062        10884 :       if (wi::ltu_p (wi::to_wide (t), 2))
    2063            0 :         ix = TREE_INT_CST_ELT (t, 0);
    2064              :       break;
    2065              : 
    2066       608753 :     case INTEGER_TYPE:
    2067       608753 :     case OFFSET_TYPE:
    2068       608753 :     case BITINT_TYPE:
    2069       608753 :       if (TYPE_UNSIGNED (type))
    2070              :         {
    2071              :           /* Cache 0..N */
    2072       454459 :           limit = param_integer_share_limit;
    2073              : 
    2074              :           /* This is a little hokie, but if the prec is smaller than
    2075              :              what is necessary to hold param_integer_share_limit, then the
    2076              :              obvious test will not get the correct answer.  */
    2077       454459 :           if (prec < HOST_BITS_PER_WIDE_INT)
    2078              :             {
    2079        96942 :               if (tree_to_uhwi (t)
    2080        96942 :                   < (unsigned HOST_WIDE_INT) param_integer_share_limit)
    2081        15947 :                 ix = tree_to_uhwi (t);
    2082              :             }
    2083       357517 :           else if (wi::ltu_p (wi::to_wide (t), param_integer_share_limit))
    2084       277241 :             ix = tree_to_uhwi (t);
    2085              :         }
    2086              :       else
    2087              :         {
    2088              :           /* Cache -1..N */
    2089       154294 :           limit = param_integer_share_limit + 1;
    2090              : 
    2091       154294 :           if (integer_minus_onep (t))
    2092              :             ix = 0;
    2093       153821 :           else if (!wi::neg_p (wi::to_wide (t)))
    2094              :             {
    2095       136531 :               if (prec < HOST_BITS_PER_WIDE_INT)
    2096              :                 {
    2097       129810 :                   if (tree_to_shwi (t) < param_integer_share_limit)
    2098       120694 :                     ix = tree_to_shwi (t) + 1;
    2099              :                 }
    2100         6721 :               else if (wi::ltu_p (wi::to_wide (t), param_integer_share_limit))
    2101         5422 :                 ix = tree_to_shwi (t) + 1;
    2102              :             }
    2103              :         }
    2104              :       break;
    2105              : 
    2106              :     case ENUMERAL_TYPE:
    2107              :       /* The slot used by TYPE_CACHED_VALUES is used for the enum
    2108              :          members.  */
    2109              :       break;
    2110              : 
    2111            0 :     default:
    2112            0 :       gcc_unreachable ();
    2113              :     }
    2114              : 
    2115       422308 :   if (ix >= 0)
    2116              :     {
    2117              :       /* Look for it in the type's vector of small shared ints.  */
    2118       423243 :       if (!TYPE_CACHED_VALUES_P (type))
    2119              :         {
    2120        14564 :           TYPE_CACHED_VALUES_P (type) = 1;
    2121        14564 :           TYPE_CACHED_VALUES (type) = make_tree_vec (limit);
    2122              :         }
    2123              : 
    2124       423243 :       if (tree r = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix))
    2125              :         {
    2126       396409 :           gcc_checking_assert (might_duplicate);
    2127       396409 :           t = r;
    2128              :         }
    2129              :       else
    2130        26834 :         TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix) = t;
    2131              :     }
    2132              :   else
    2133              :     {
    2134              :       /* Use the cache of larger shared ints.  */
    2135       216776 :       tree *slot = int_cst_hash_table->find_slot (t, INSERT);
    2136       216776 :       if (tree r = *slot)
    2137              :         {
    2138              :           /* If there is already an entry for the number verify it's the
    2139              :              same value.  */
    2140       126148 :           gcc_checking_assert (wi::to_wide (tree (r)) == wi::to_wide (t));
    2141              :           /* And return the cached value.  */
    2142       126148 :           t = r;
    2143              :         }
    2144              :       else
    2145              :         /* Otherwise insert this one into the hash table.  */
    2146        90628 :         *slot = t;
    2147              :     }
    2148              : 
    2149       640019 :   return t;
    2150              : }
    2151              : 
    2152              : 
    2153              : /* Builds an integer constant in TYPE such that lowest BITS bits are ones
    2154              :    and the rest are zeros.  */
    2155              : 
    2156              : tree
    2157      9748014 : build_low_bits_mask (tree type, unsigned bits)
    2158              : {
    2159      9748014 :   gcc_assert (bits <= TYPE_PRECISION (type));
    2160              : 
    2161      9748014 :   return wide_int_to_tree (type, wi::mask (bits, false,
    2162      9748014 :                                            TYPE_PRECISION (type)));
    2163              : }
    2164              : 
    2165              : /* Checks that X is integer constant that can be expressed in (unsigned)
    2166              :    HOST_WIDE_INT without loss of precision.  */
    2167              : 
    2168              : bool
    2169    796179117 : cst_and_fits_in_hwi (const_tree x)
    2170              : {
    2171    796179117 :   return (TREE_CODE (x) == INTEGER_CST
    2172    796179117 :           && (tree_fits_shwi_p (x) || tree_fits_uhwi_p (x)));
    2173              : }
    2174              : 
    2175              : /* Build a newly constructed VECTOR_CST with the given values of
    2176              :    (VECTOR_CST_)LOG2_NPATTERNS and (VECTOR_CST_)NELTS_PER_PATTERN.  */
    2177              : 
    2178              : tree
    2179      3470959 : make_vector (unsigned log2_npatterns,
    2180              :              unsigned int nelts_per_pattern MEM_STAT_DECL)
    2181              : {
    2182      3470959 :   gcc_assert (IN_RANGE (nelts_per_pattern, 1, 3));
    2183      3470959 :   tree t;
    2184      3470959 :   unsigned npatterns = 1 << log2_npatterns;
    2185      3470959 :   unsigned encoded_nelts = npatterns * nelts_per_pattern;
    2186      3470959 :   unsigned length = (sizeof (struct tree_vector)
    2187              :                      + (encoded_nelts - 1) * sizeof (tree));
    2188              : 
    2189      3470959 :   record_node_allocation_statistics (VECTOR_CST, length);
    2190              : 
    2191      3470959 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2192              : 
    2193      3470959 :   TREE_SET_CODE (t, VECTOR_CST);
    2194      3470959 :   TREE_CONSTANT (t) = 1;
    2195      3470959 :   VECTOR_CST_LOG2_NPATTERNS (t) = log2_npatterns;
    2196      3470959 :   VECTOR_CST_NELTS_PER_PATTERN (t) = nelts_per_pattern;
    2197              : 
    2198      3470959 :   return t;
    2199              : }
    2200              : 
    2201              : /* Return a new VECTOR_CST node whose type is TYPE and whose values
    2202              :    are extracted from V, a vector of CONSTRUCTOR_ELT.  */
    2203              : 
    2204              : tree
    2205       689814 : build_vector_from_ctor (tree type, const vec<constructor_elt, va_gc> *v)
    2206              : {
    2207       689814 :   if (vec_safe_length (v) == 0)
    2208         2052 :     return build_zero_cst (type);
    2209              : 
    2210       687762 :   unsigned HOST_WIDE_INT idx, npatterns, nelts_per_pattern;
    2211       687762 :   tree value;
    2212              : 
    2213              :   /* If the vector is a VLA, build a VLA constant vector.  */
    2214       687762 :   npatterns = constant_lower_bound (TYPE_VECTOR_SUBPARTS (type));
    2215       687762 :   nelts_per_pattern = TYPE_VECTOR_SUBPARTS (type).is_constant () ? 1 : 2;
    2216       687762 :   gcc_assert (vec_safe_length (v) <= npatterns);
    2217              : 
    2218       687762 :   tree_vector_builder vec (type, npatterns, nelts_per_pattern);
    2219      5243924 :   FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
    2220              :     {
    2221      3868400 :       if (TREE_CODE (value) == VECTOR_CST)
    2222              :         {
    2223              :           /* If NPATTERNS is constant then this must be too.  */
    2224         4908 :           unsigned int sub_nelts = VECTOR_CST_NELTS (value).to_constant ();
    2225        19972 :           for (unsigned i = 0; i < sub_nelts; ++i)
    2226        15064 :             vec.quick_push (VECTOR_CST_ELT (value, i));
    2227              :         }
    2228              :       else
    2229      3863492 :         vec.quick_push (value);
    2230              :     }
    2231      1945184 :   while (vec.length () < npatterns * nelts_per_pattern)
    2232       284830 :     vec.quick_push (build_zero_cst (TREE_TYPE (type)));
    2233              : 
    2234       687762 :   return vec.build ();
    2235       687762 : }
    2236              : 
    2237              : /* Build a vector of type VECTYPE where all the elements are SCs.  */
    2238              : tree
    2239       664397 : build_vector_from_val (tree vectype, tree sc)
    2240              : {
    2241       664397 :   unsigned HOST_WIDE_INT i, nunits;
    2242              : 
    2243       664397 :   if (sc == error_mark_node)
    2244              :     return sc;
    2245              : 
    2246              :   /* Verify that the vector type is suitable for SC.  Note that there
    2247              :      is some inconsistency in the type-system with respect to restrict
    2248              :      qualifications of pointers.  Vector types always have a main-variant
    2249              :      element type and the qualification is applied to the vector-type.
    2250              :      So TREE_TYPE (vector-type) does not return a properly qualified
    2251              :      vector element-type.  */
    2252       664397 :   gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)),
    2253              :                                            TREE_TYPE (vectype)));
    2254              : 
    2255       664397 :   if (CONSTANT_CLASS_P (sc))
    2256              :     {
    2257       632784 :       tree_vector_builder v (vectype, 1, 1);
    2258       632784 :       v.quick_push (sc);
    2259       632784 :       return v.build ();
    2260       632784 :     }
    2261        31613 :   else if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits))
    2262              :     return fold_build1 (VEC_DUPLICATE_EXPR, vectype, sc);
    2263              :   else
    2264              :     {
    2265        31613 :       vec<constructor_elt, va_gc> *v;
    2266        31613 :       vec_alloc (v, nunits);
    2267       182566 :       for (i = 0; i < nunits; ++i)
    2268       119340 :         CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc);
    2269        31613 :       return build_constructor (vectype, v);
    2270              :     }
    2271              : }
    2272              : 
    2273              : /* If TYPE is not a vector type, just return SC, otherwise return
    2274              :    build_vector_from_val (TYPE, SC).  */
    2275              : 
    2276              : tree
    2277      5538620 : build_uniform_cst (tree type, tree sc)
    2278              : {
    2279      5538620 :   if (!VECTOR_TYPE_P (type))
    2280              :     return sc;
    2281              : 
    2282          370 :   return build_vector_from_val (type, sc);
    2283              : }
    2284              : 
    2285              : /* Build a vector series of type TYPE in which element I has the value
    2286              :    BASE + I * STEP.  The result is a constant if BASE and STEP are constant
    2287              :    and a VEC_SERIES_EXPR otherwise.  */
    2288              : 
    2289              : tree
    2290           18 : build_vec_series (tree type, tree base, tree step)
    2291              : {
    2292           18 :   if (integer_zerop (step))
    2293            0 :     return build_vector_from_val (type, base);
    2294           18 :   if (TREE_CODE (base) == INTEGER_CST && TREE_CODE (step) == INTEGER_CST)
    2295              :     {
    2296           18 :       tree_vector_builder builder (type, 1, 3);
    2297           18 :       tree elt1 = wide_int_to_tree (TREE_TYPE (base),
    2298           36 :                                     wi::to_wide (base) + wi::to_wide (step));
    2299           18 :       tree elt2 = wide_int_to_tree (TREE_TYPE (base),
    2300           36 :                                     wi::to_wide (elt1) + wi::to_wide (step));
    2301           18 :       builder.quick_push (base);
    2302           18 :       builder.quick_push (elt1);
    2303           18 :       builder.quick_push (elt2);
    2304           18 :       return builder.build ();
    2305           18 :     }
    2306            0 :   return build2 (VEC_SERIES_EXPR, type, base, step);
    2307              : }
    2308              : 
    2309              : /* Return a vector with the same number of units and number of bits
    2310              :    as VEC_TYPE, but in which the elements are a linear series of unsigned
    2311              :    integers { BASE, BASE + STEP, BASE + STEP * 2, ... }.  */
    2312              : 
    2313              : tree
    2314         1797 : build_index_vector (tree vec_type, poly_uint64 base, poly_uint64 step)
    2315              : {
    2316         1797 :   tree index_vec_type = vec_type;
    2317         1797 :   tree index_elt_type = TREE_TYPE (vec_type);
    2318         1797 :   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vec_type);
    2319         1797 :   if (!INTEGRAL_TYPE_P (index_elt_type) || !TYPE_UNSIGNED (index_elt_type))
    2320              :     {
    2321            4 :       index_elt_type = build_nonstandard_integer_type
    2322            8 :         (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (index_elt_type)), true);
    2323            4 :       index_vec_type = build_vector_type (index_elt_type, nunits);
    2324              :     }
    2325              : 
    2326         1797 :   tree_vector_builder v (index_vec_type, 1, 3);
    2327         8985 :   for (unsigned int i = 0; i < 3; ++i)
    2328         5391 :     v.quick_push (build_int_cstu (index_elt_type, base + i * step));
    2329         1797 :   return v.build ();
    2330         1797 : }
    2331              : 
    2332              : /* Return a VECTOR_CST of type VEC_TYPE in which the first NUM_A
    2333              :    elements are A and the rest are B.  */
    2334              : 
    2335              : tree
    2336            0 : build_vector_a_then_b (tree vec_type, unsigned int num_a, tree a, tree b)
    2337              : {
    2338            0 :   gcc_assert (known_le (num_a, TYPE_VECTOR_SUBPARTS (vec_type)));
    2339            0 :   unsigned int count = constant_lower_bound (TYPE_VECTOR_SUBPARTS (vec_type));
    2340              :   /* Optimize the constant case.  */
    2341            0 :   if ((count & 1) == 0 && TYPE_VECTOR_SUBPARTS (vec_type).is_constant ())
    2342            0 :     count /= 2;
    2343            0 :   tree_vector_builder builder (vec_type, count, 2);
    2344            0 :   for (unsigned int i = 0; i < count * 2; ++i)
    2345            0 :     builder.quick_push (i < num_a ? a : b);
    2346            0 :   return builder.build ();
    2347            0 : }
    2348              : 
    2349              : /* Something has messed with the elements of CONSTRUCTOR C after it was built;
    2350              :    calculate TREE_CONSTANT and TREE_SIDE_EFFECTS.  */
    2351              : 
    2352              : void
    2353    168049941 : recompute_constructor_flags (tree c)
    2354              : {
    2355    168049941 :   unsigned int i;
    2356    168049941 :   tree val;
    2357    168049941 :   bool constant_p = true;
    2358    168049941 :   bool side_effects_p = false;
    2359    168049941 :   vec<constructor_elt, va_gc> *vals = CONSTRUCTOR_ELTS (c);
    2360              : 
    2361    350252694 :   FOR_EACH_CONSTRUCTOR_VALUE (vals, i, val)
    2362              :     {
    2363              :       /* Mostly ctors will have elts that don't have side-effects, so
    2364              :          the usual case is to scan all the elements.  Hence a single
    2365              :          loop for both const and side effects, rather than one loop
    2366              :          each (with early outs).  */
    2367    182202753 :       if (!TREE_CONSTANT (val))
    2368     22640624 :         constant_p = false;
    2369    182202753 :       if (TREE_SIDE_EFFECTS (val))
    2370      4682128 :         side_effects_p = true;
    2371              :     }
    2372              : 
    2373    168049941 :   TREE_SIDE_EFFECTS (c) = side_effects_p;
    2374    168049941 :   TREE_CONSTANT (c) = constant_p;
    2375    168049941 : }
    2376              : 
    2377              : /* Make sure that TREE_CONSTANT and TREE_SIDE_EFFECTS are correct for
    2378              :    CONSTRUCTOR C.  */
    2379              : 
    2380              : void
    2381     19925214 : verify_constructor_flags (tree c)
    2382              : {
    2383     19925214 :   unsigned int i;
    2384     19925214 :   tree val;
    2385     19925214 :   bool constant_p = TREE_CONSTANT (c);
    2386     19925214 :   bool side_effects_p = TREE_SIDE_EFFECTS (c);
    2387     19925214 :   vec<constructor_elt, va_gc> *vals = CONSTRUCTOR_ELTS (c);
    2388              : 
    2389    175291453 :   FOR_EACH_CONSTRUCTOR_VALUE (vals, i, val)
    2390              :     {
    2391    155366239 :       if (constant_p && !TREE_CONSTANT (val))
    2392            0 :         internal_error ("non-constant element in constant CONSTRUCTOR");
    2393    155366239 :       if (!side_effects_p && TREE_SIDE_EFFECTS (val))
    2394            0 :         internal_error ("side-effects element in no-side-effects CONSTRUCTOR");
    2395              :     }
    2396     19925214 : }
    2397              : 
    2398              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2399              :    are in the vec pointed to by VALS.  */
    2400              : tree
    2401    143362300 : build_constructor (tree type, vec<constructor_elt, va_gc> *vals MEM_STAT_DECL)
    2402              : {
    2403    143362300 :   tree c = make_node (CONSTRUCTOR PASS_MEM_STAT);
    2404              : 
    2405    143362300 :   TREE_TYPE (c) = type;
    2406    143362300 :   CONSTRUCTOR_ELTS (c) = vals;
    2407              : 
    2408    143362300 :   recompute_constructor_flags (c);
    2409              : 
    2410    143362300 :   return c;
    2411              : }
    2412              : 
    2413              : /* Build a CONSTRUCTOR node made of a single initializer, with the specified
    2414              :    INDEX and VALUE.  */
    2415              : tree
    2416         7041 : build_constructor_single (tree type, tree index, tree value)
    2417              : {
    2418         7041 :   vec<constructor_elt, va_gc> *v;
    2419         7041 :   constructor_elt elt = {index, value};
    2420              : 
    2421         7041 :   vec_alloc (v, 1);
    2422         7041 :   v->quick_push (elt);
    2423              : 
    2424         7041 :   return build_constructor (type, v);
    2425              : }
    2426              : 
    2427              : 
    2428              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2429              :    are in a list pointed to by VALS.  */
    2430              : tree
    2431         1013 : build_constructor_from_list (tree type, tree vals)
    2432              : {
    2433         1013 :   tree t;
    2434         1013 :   vec<constructor_elt, va_gc> *v = NULL;
    2435              : 
    2436         1013 :   if (vals)
    2437              :     {
    2438         1013 :       vec_alloc (v, list_length (vals));
    2439        21849 :       for (t = vals; t; t = TREE_CHAIN (t))
    2440        19823 :         CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t));
    2441              :     }
    2442              : 
    2443         1013 :   return build_constructor (type, v);
    2444              : }
    2445              : 
    2446              : /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
    2447              :    are in a vector pointed to by VALS.  Note that the TREE_PURPOSE
    2448              :    fields in the constructor remain null.  */
    2449              : 
    2450              : tree
    2451         1617 : build_constructor_from_vec (tree type, const vec<tree, va_gc> *vals)
    2452              : {
    2453         1617 :   vec<constructor_elt, va_gc> *v = NULL;
    2454              : 
    2455        75520 :   for (tree t : vals)
    2456        73903 :     CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, t);
    2457              : 
    2458         1617 :   return build_constructor (type, v);
    2459              : }
    2460              : 
    2461              : /* Return a new CONSTRUCTOR node whose type is TYPE.  NELTS is the number
    2462              :    of elements, provided as index/value pairs.  */
    2463              : 
    2464              : tree
    2465        39889 : build_constructor_va (tree type, int nelts, ...)
    2466              : {
    2467        39889 :   vec<constructor_elt, va_gc> *v = NULL;
    2468        39889 :   va_list p;
    2469              : 
    2470        39889 :   va_start (p, nelts);
    2471        39889 :   vec_alloc (v, nelts);
    2472        39889 :   while (nelts--)
    2473              :     {
    2474       121179 :       tree index = va_arg (p, tree);
    2475       121179 :       tree value = va_arg (p, tree);
    2476       282247 :       CONSTRUCTOR_APPEND_ELT (v, index, value);
    2477              :     }
    2478        39889 :   va_end (p);
    2479        39889 :   return build_constructor (type, v);
    2480              : }
    2481              : 
    2482              : /* Return a node of type TYPE for which TREE_CLOBBER_P is true.  */
    2483              : 
    2484              : tree
    2485     10146045 : build_clobber (tree type, enum clobber_kind kind)
    2486              : {
    2487     10146045 :   tree clobber = build_constructor (type, NULL);
    2488     10146045 :   TREE_THIS_VOLATILE (clobber) = true;
    2489     10146045 :   CLOBBER_KIND (clobber) = kind;
    2490     10146045 :   return clobber;
    2491              : }
    2492              : 
    2493              : /* Return a new FIXED_CST node whose type is TYPE and value is F.  */
    2494              : 
    2495              : tree
    2496           54 : build_fixed (tree type, FIXED_VALUE_TYPE f)
    2497              : {
    2498           54 :   tree v;
    2499           54 :   FIXED_VALUE_TYPE *fp;
    2500              : 
    2501           54 :   v = make_node (FIXED_CST);
    2502           54 :   fp = ggc_alloc<fixed_value> ();
    2503           54 :   memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE));
    2504              : 
    2505           54 :   TREE_TYPE (v) = type;
    2506           54 :   TREE_FIXED_CST_PTR (v) = fp;
    2507           54 :   return v;
    2508              : }
    2509              : 
    2510              : /* Return a new REAL_CST node whose type is TYPE and value is D.  */
    2511              : 
    2512              : tree
    2513     43643579 : build_real (tree type, REAL_VALUE_TYPE d)
    2514              : {
    2515     43643579 :   tree v;
    2516     43643579 :   int overflow = 0;
    2517              : 
    2518              :   /* dconst{0,1,2,m1,half} are used in various places in
    2519              :      the middle-end and optimizers, allow them here
    2520              :      even for decimal floating point types as an exception
    2521              :      by converting them to decimal.  */
    2522     43643579 :   if (DECIMAL_FLOAT_MODE_P (TYPE_MODE (type))
    2523       610481 :       && (d.cl == rvc_normal || d.cl == rvc_zero)
    2524     44251862 :       && !d.decimal)
    2525              :     {
    2526          610 :       if (memcmp (&d, &dconst1, sizeof (d)) == 0)
    2527            0 :         decimal_real_from_string (&d, "1");
    2528          610 :       else if (memcmp (&d, &dconst2, sizeof (d)) == 0)
    2529           22 :         decimal_real_from_string (&d, "2");
    2530          588 :       else if (memcmp (&d, &dconstm1, sizeof (d)) == 0)
    2531           90 :         decimal_real_from_string (&d, "-1");
    2532          498 :       else if (memcmp (&d, &dconsthalf, sizeof (d)) == 0)
    2533            0 :         decimal_real_from_string (&d, "0.5");
    2534          498 :       else if (memcmp (&d, &dconst0, sizeof (d)) == 0)
    2535              :         {
    2536              :           /* Make sure to give zero the minimum quantum exponent for
    2537              :              the type (which corresponds to all bits zero).  */
    2538          498 :           const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type));
    2539          498 :           char buf[16];
    2540          498 :           sprintf (buf, "0e%d", fmt->emin - fmt->p);
    2541          498 :           decimal_real_from_string (&d, buf);
    2542              :         }
    2543              :       else
    2544            0 :         gcc_unreachable ();
    2545              :     }
    2546              : 
    2547              :   /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE.
    2548              :      Consider doing it via real_convert now.  */
    2549              : 
    2550     43643579 :   v = make_node (REAL_CST);
    2551     43643579 :   TREE_TYPE (v) = type;
    2552     43643579 :   memcpy (TREE_REAL_CST_PTR (v), &d, sizeof (REAL_VALUE_TYPE));
    2553     43643579 :   TREE_OVERFLOW (v) = overflow;
    2554     43643579 :   return v;
    2555              : }
    2556              : 
    2557              : /* Like build_real, but first truncate D to the type.  */
    2558              : 
    2559              : tree
    2560       175996 : build_real_truncate (tree type, REAL_VALUE_TYPE d)
    2561              : {
    2562       175996 :   return build_real (type, real_value_truncate (TYPE_MODE (type), d));
    2563              : }
    2564              : 
    2565              : /* Return a new REAL_CST node whose type is TYPE
    2566              :    and whose value is the integer value of the INTEGER_CST node I.  */
    2567              : 
    2568              : REAL_VALUE_TYPE
    2569     24864344 : real_value_from_int_cst (const_tree type, const_tree i)
    2570              : {
    2571     24864344 :   REAL_VALUE_TYPE d;
    2572              : 
    2573              :   /* Clear all bits of the real value type so that we can later do
    2574              :      bitwise comparisons to see if two values are the same.  */
    2575     24864344 :   memset (&d, 0, sizeof d);
    2576              : 
    2577     24864344 :   real_from_integer (&d, type ? TYPE_MODE (type) : VOIDmode, wi::to_wide (i),
    2578     24864344 :                      TYPE_SIGN (TREE_TYPE (i)));
    2579     24864344 :   return d;
    2580              : }
    2581              : 
    2582              : /* Given a tree representing an integer constant I, return a tree
    2583              :    representing the same value as a floating-point constant of type TYPE.  */
    2584              : 
    2585              : tree
    2586     24235871 : build_real_from_int_cst (tree type, const_tree i)
    2587              : {
    2588     24235871 :   tree v;
    2589     24235871 :   int overflow = TREE_OVERFLOW (i);
    2590              : 
    2591     24235871 :   v = build_real (type, real_value_from_int_cst (type, i));
    2592              : 
    2593     24235871 :   TREE_OVERFLOW (v) |= overflow;
    2594     24235871 :   return v;
    2595              : }
    2596              : 
    2597              : /* Return a new REAL_CST node whose type is TYPE
    2598              :    and whose value is the integer value I which has sign SGN.  */
    2599              : 
    2600              : tree
    2601          138 : build_real_from_wide (tree type, const wide_int_ref &i, signop sgn)
    2602              : {
    2603          138 :   REAL_VALUE_TYPE d;
    2604              : 
    2605              :   /* Clear all bits of the real value type so that we can later do
    2606              :      bitwise comparisons to see if two values are the same.  */
    2607          138 :   memset (&d, 0, sizeof d);
    2608              : 
    2609          138 :   real_from_integer (&d, TYPE_MODE (type), i, sgn);
    2610          138 :   return build_real (type, d);
    2611              : }
    2612              : 
    2613              : /* Return a newly constructed STRING_CST node whose value is the LEN
    2614              :    characters at STR when STR is nonnull, or all zeros otherwise.
    2615              :    Note that for a C string literal, LEN should include the trailing NUL.
    2616              :    The TREE_TYPE is not initialized.  */
    2617              : 
    2618              : tree
    2619    101339199 : build_string (unsigned len, const char *str /*= NULL */)
    2620              : {
    2621              :   /* Do not waste bytes provided by padding of struct tree_string.  */
    2622    101339199 :   unsigned size = len + offsetof (struct tree_string, str) + 1;
    2623              : 
    2624    101339199 :   record_node_allocation_statistics (STRING_CST, size);
    2625              : 
    2626    101339199 :   tree s = (tree) ggc_internal_alloc (size);
    2627              : 
    2628    101339199 :   memset (s, 0, sizeof (struct tree_typed));
    2629    101339199 :   TREE_SET_CODE (s, STRING_CST);
    2630    101339199 :   TREE_CONSTANT (s) = 1;
    2631    101339199 :   TREE_STRING_LENGTH (s) = len;
    2632    101339199 :   if (str)
    2633    101330032 :     memcpy (s->string.str, str, len);
    2634              :   else
    2635         9167 :     memset (s->string.str, 0, len);
    2636    101339199 :   s->string.str[len] = '\0';
    2637              : 
    2638    101339199 :   return s;
    2639              : }
    2640              : 
    2641              : /* Return a newly constructed COMPLEX_CST node whose value is
    2642              :    specified by the real and imaginary parts REAL and IMAG.
    2643              :    Both REAL and IMAG should be constant nodes.  TYPE, if specified,
    2644              :    will be the type of the COMPLEX_CST; otherwise a new type will be made.  */
    2645              : 
    2646              : tree
    2647       488011 : build_complex (tree type, tree real, tree imag)
    2648              : {
    2649       488011 :   gcc_assert (CONSTANT_CLASS_P (real));
    2650       488011 :   gcc_assert (CONSTANT_CLASS_P (imag));
    2651              : 
    2652       488011 :   tree t = make_node (COMPLEX_CST);
    2653              : 
    2654       488011 :   TREE_REALPART (t) = real;
    2655       488011 :   TREE_IMAGPART (t) = imag;
    2656       488011 :   TREE_TYPE (t) = type ? type : build_complex_type (TREE_TYPE (real));
    2657       488011 :   TREE_OVERFLOW (t) = TREE_OVERFLOW (real) | TREE_OVERFLOW (imag);
    2658       488011 :   return t;
    2659              : }
    2660              : 
    2661              : /* Build a complex (inf +- 0i), such as for the result of cproj.
    2662              :    TYPE is the complex tree type of the result.  If NEG is true, the
    2663              :    imaginary zero is negative.  */
    2664              : 
    2665              : tree
    2666          840 : build_complex_inf (tree type, bool neg)
    2667              : {
    2668          840 :   REAL_VALUE_TYPE rzero = dconst0;
    2669              : 
    2670          840 :   rzero.sign = neg;
    2671          840 :   return build_complex (type, build_real (TREE_TYPE (type), dconstinf),
    2672          840 :                         build_real (TREE_TYPE (type), rzero));
    2673              : }
    2674              : 
    2675              : /* Return the constant 1 in type TYPE.  If TYPE has several elements, each
    2676              :    element is set to 1.  In particular, this is 1 + i for complex types.  */
    2677              : 
    2678              : tree
    2679         3766 : build_each_one_cst (tree type)
    2680              : {
    2681         3766 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2682              :     {
    2683            0 :       tree scalar = build_one_cst (TREE_TYPE (type));
    2684            0 :       return build_complex (type, scalar, scalar);
    2685              :     }
    2686              :   else
    2687         3766 :     return build_one_cst (type);
    2688              : }
    2689              : 
    2690              : /* Return a constant of arithmetic type TYPE which is the
    2691              :    multiplicative identity of the set TYPE.  */
    2692              : 
    2693              : tree
    2694     10057479 : build_one_cst (tree type)
    2695              : {
    2696     10057479 :   switch (TREE_CODE (type))
    2697              :     {
    2698     10043172 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2699     10043172 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2700     10043172 :     case OFFSET_TYPE: case BITINT_TYPE:
    2701     10043172 :       return build_int_cst (type, 1);
    2702              : 
    2703        10695 :     case REAL_TYPE:
    2704        10695 :       return build_real (type, dconst1);
    2705              : 
    2706            0 :     case FIXED_POINT_TYPE:
    2707              :       /* We can only generate 1 for accum types.  */
    2708            0 :       gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
    2709            0 :       return build_fixed (type, FCONST1 (TYPE_MODE (type)));
    2710              : 
    2711          593 :     case VECTOR_TYPE:
    2712          593 :       {
    2713          593 :         tree scalar = build_one_cst (TREE_TYPE (type));
    2714              : 
    2715          593 :         return build_vector_from_val (type, scalar);
    2716              :       }
    2717              : 
    2718         3019 :     case COMPLEX_TYPE:
    2719         6038 :       return build_complex (type,
    2720         3019 :                             build_one_cst (TREE_TYPE (type)),
    2721         6038 :                             build_zero_cst (TREE_TYPE (type)));
    2722              : 
    2723            0 :     default:
    2724            0 :       gcc_unreachable ();
    2725              :     }
    2726              : }
    2727              : 
    2728              : /* Return an integer of type TYPE containing all 1's in as much precision as
    2729              :    it contains, or a complex or vector whose subparts are such integers.  */
    2730              : 
    2731              : tree
    2732      1720463 : build_all_ones_cst (tree type)
    2733              : {
    2734      1720463 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2735              :     {
    2736            0 :       tree scalar = build_all_ones_cst (TREE_TYPE (type));
    2737            0 :       return build_complex (type, scalar, scalar);
    2738              :     }
    2739              :   else
    2740      1720463 :     return build_minus_one_cst (type);
    2741              : }
    2742              : 
    2743              : /* Return a constant of arithmetic type TYPE which is the
    2744              :    opposite of the multiplicative identity of the set TYPE.  */
    2745              : 
    2746              : tree
    2747      3130423 : build_minus_one_cst (tree type)
    2748              : {
    2749      3130423 :   switch (TREE_CODE (type))
    2750              :     {
    2751      3005479 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2752      3005479 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2753      3005479 :     case OFFSET_TYPE: case BITINT_TYPE:
    2754      3005479 :       return build_int_cst (type, -1);
    2755              : 
    2756        14812 :     case REAL_TYPE:
    2757        14812 :       return build_real (type, dconstm1);
    2758              : 
    2759            0 :     case FIXED_POINT_TYPE:
    2760              :       /* We can only generate 1 for accum types.  */
    2761            0 :       gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type)));
    2762            0 :       return build_fixed (type,
    2763              :                           fixed_from_double_int (double_int_minus_one,
    2764            0 :                                                  SCALAR_TYPE_MODE (type)));
    2765              : 
    2766       110132 :     case VECTOR_TYPE:
    2767       110132 :       {
    2768       110132 :         tree scalar = build_minus_one_cst (TREE_TYPE (type));
    2769              : 
    2770       110132 :         return build_vector_from_val (type, scalar);
    2771              :       }
    2772              : 
    2773            0 :     case COMPLEX_TYPE:
    2774            0 :       return build_complex (type,
    2775            0 :                             build_minus_one_cst (TREE_TYPE (type)),
    2776            0 :                             build_zero_cst (TREE_TYPE (type)));
    2777              : 
    2778            0 :     default:
    2779            0 :       gcc_unreachable ();
    2780              :     }
    2781              : }
    2782              : 
    2783              : /* Build 0 constant of type TYPE.  This is used by constructor folding
    2784              :    and thus the constant should be represented in memory by
    2785              :    zero(es).  */
    2786              : 
    2787              : tree
    2788     90090210 : build_zero_cst (tree type)
    2789              : {
    2790     90090210 :   switch (TREE_CODE (type))
    2791              :     {
    2792     89500668 :     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
    2793     89500668 :     case POINTER_TYPE: case REFERENCE_TYPE:
    2794     89500668 :     case OFFSET_TYPE: case NULLPTR_TYPE: case BITINT_TYPE:
    2795     89500668 :       return build_int_cst (type, 0);
    2796              : 
    2797       223268 :     case REAL_TYPE:
    2798       223268 :       return build_real (type, dconst0);
    2799              : 
    2800            0 :     case FIXED_POINT_TYPE:
    2801            0 :       return build_fixed (type, FCONST0 (TYPE_MODE (type)));
    2802              : 
    2803       177949 :     case VECTOR_TYPE:
    2804       177949 :       {
    2805       177949 :         tree scalar = build_zero_cst (TREE_TYPE (type));
    2806              : 
    2807       177949 :         return build_vector_from_val (type, scalar);
    2808              :       }
    2809              : 
    2810         2083 :     case COMPLEX_TYPE:
    2811         2083 :       {
    2812         2083 :         tree zero = build_zero_cst (TREE_TYPE (type));
    2813              : 
    2814         2083 :         return build_complex (type, zero, zero);
    2815              :       }
    2816              : 
    2817       186242 :     default:
    2818       186242 :       if (!AGGREGATE_TYPE_P (type))
    2819            1 :         return fold_convert (type, integer_zero_node);
    2820       186241 :       return build_constructor (type, NULL);
    2821              :     }
    2822              : }
    2823              : 
    2824              : /* Build a constant of integer type TYPE, made of VALUE's bits replicated
    2825              :    every WIDTH bits to fit TYPE's precision.  */
    2826              : 
    2827              : tree
    2828           14 : build_replicated_int_cst (tree type, unsigned int width, HOST_WIDE_INT value)
    2829              : {
    2830           14 :   int n = ((TYPE_PRECISION (type) + HOST_BITS_PER_WIDE_INT - 1)
    2831           14 :            / HOST_BITS_PER_WIDE_INT);
    2832           14 :   unsigned HOST_WIDE_INT low, mask;
    2833           14 :   HOST_WIDE_INT a[WIDE_INT_MAX_INL_ELTS];
    2834           14 :   int i;
    2835              : 
    2836           14 :   gcc_assert (n && n <= WIDE_INT_MAX_INL_ELTS);
    2837              : 
    2838           14 :   if (width == HOST_BITS_PER_WIDE_INT)
    2839            0 :     low = value;
    2840              :   else
    2841              :     {
    2842           14 :       mask = (HOST_WIDE_INT_1U << width) - 1;
    2843           14 :       low = (unsigned HOST_WIDE_INT) ~0 / mask * (value & mask);
    2844              :     }
    2845              : 
    2846           28 :   for (i = 0; i < n; i++)
    2847           14 :     a[i] = low;
    2848              : 
    2849           14 :   gcc_assert (TYPE_PRECISION (type) <= MAX_BITSIZE_MODE_ANY_INT);
    2850           14 :   return wide_int_to_tree (type, wide_int::from_array (a, n,
    2851           14 :                                                        TYPE_PRECISION (type)));
    2852              : }
    2853              : 
    2854              : /* If floating-point type TYPE has an IEEE-style sign bit, return an
    2855              :    unsigned constant in which only the sign bit is set.  Return null
    2856              :    otherwise.  */
    2857              : 
    2858              : tree
    2859            0 : sign_mask_for (tree type)
    2860              : {
    2861              :   /* Avoid having to choose between a real-only sign and a pair of signs.
    2862              :      This could be relaxed if the choice becomes obvious later.  */
    2863            0 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    2864              :     return NULL_TREE;
    2865              : 
    2866            0 :   auto eltmode = as_a<scalar_float_mode> (element_mode (type));
    2867            0 :   auto bits = REAL_MODE_FORMAT (eltmode)->ieee_bits;
    2868            0 :   if (!bits || !pow2p_hwi (bits))
    2869              :     return NULL_TREE;
    2870              : 
    2871            0 :   tree inttype = unsigned_type_for (type);
    2872            0 :   if (!inttype)
    2873              :     return NULL_TREE;
    2874              : 
    2875            0 :   auto mask = wi::set_bit_in_zero (bits - 1, bits);
    2876            0 :   if (VECTOR_TYPE_P (inttype))
    2877              :     {
    2878            0 :       tree elt = wide_int_to_tree (TREE_TYPE (inttype), mask);
    2879            0 :       return build_vector_from_val (inttype, elt);
    2880              :     }
    2881            0 :   return wide_int_to_tree (inttype, mask);
    2882            0 : }
    2883              : 
    2884              : /* Build a BINFO with LEN language slots.  */
    2885              : 
    2886              : tree
    2887    112542730 : make_tree_binfo (unsigned base_binfos MEM_STAT_DECL)
    2888              : {
    2889    112542730 :   tree t;
    2890    112542730 :   size_t length = (offsetof (struct tree_binfo, base_binfos)
    2891    112542730 :                    + vec<tree, va_gc>::embedded_size (base_binfos));
    2892              : 
    2893    112542730 :   record_node_allocation_statistics (TREE_BINFO, length);
    2894              : 
    2895    112542730 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    2896              : 
    2897    112542730 :   memset (t, 0, offsetof (struct tree_binfo, base_binfos));
    2898              : 
    2899    112542730 :   TREE_SET_CODE (t, TREE_BINFO);
    2900              : 
    2901    112542730 :   BINFO_BASE_BINFOS (t)->embedded_init (base_binfos);
    2902              : 
    2903    112542730 :   return t;
    2904              : }
    2905              : 
    2906              : /* Create a CASE_LABEL_EXPR tree node and return it.  */
    2907              : 
    2908              : tree
    2909      7032794 : build_case_label (tree low_value, tree high_value, tree label_decl)
    2910              : {
    2911      7032794 :   tree t = make_node (CASE_LABEL_EXPR);
    2912              : 
    2913      7032794 :   TREE_TYPE (t) = void_type_node;
    2914      7032794 :   SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (label_decl));
    2915              : 
    2916      7032794 :   CASE_LOW (t) = low_value;
    2917      7032794 :   CASE_HIGH (t) = high_value;
    2918      7032794 :   CASE_LABEL (t) = label_decl;
    2919      7032794 :   CASE_CHAIN (t) = NULL_TREE;
    2920              : 
    2921      7032794 :   return t;
    2922              : }
    2923              : 
    2924              : /* Build a newly constructed INTEGER_CST node.  LEN and EXT_LEN are the
    2925              :    values of TREE_INT_CST_NUNITS and TREE_INT_CST_EXT_NUNITS respectively.
    2926              :    The latter determines the length of the HOST_WIDE_INT vector.  */
    2927              : 
    2928              : tree
    2929    293813150 : make_int_cst (int len, int ext_len MEM_STAT_DECL)
    2930              : {
    2931    293813150 :   tree t;
    2932    293813150 :   int length = ((ext_len - 1) * sizeof (HOST_WIDE_INT)
    2933    293813150 :                 + sizeof (struct tree_int_cst));
    2934              : 
    2935    293813150 :   gcc_assert (len);
    2936    293813150 :   record_node_allocation_statistics (INTEGER_CST, length);
    2937              : 
    2938    293813150 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2939              : 
    2940    293813150 :   TREE_SET_CODE (t, INTEGER_CST);
    2941    293813150 :   TREE_INT_CST_NUNITS (t) = len;
    2942    293813150 :   TREE_INT_CST_EXT_NUNITS (t) = ext_len;
    2943    293813150 :   TREE_CONSTANT (t) = 1;
    2944              : 
    2945    293813150 :   return t;
    2946              : }
    2947              : 
    2948              : /* Build a newly constructed TREE_VEC node of length LEN.  */
    2949              : 
    2950              : tree
    2951   3373144053 : make_tree_vec (int len MEM_STAT_DECL)
    2952              : {
    2953   3373144053 :   tree t;
    2954   3373144053 :   size_t length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2955              : 
    2956   3373144053 :   record_node_allocation_statistics (TREE_VEC, length);
    2957              : 
    2958   3373144053 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2959              : 
    2960   3373144053 :   TREE_SET_CODE (t, TREE_VEC);
    2961   3373144053 :   TREE_VEC_LENGTH (t) = len;
    2962              : 
    2963   3373144053 :   return t;
    2964              : }
    2965              : 
    2966              : /* Grow a TREE_VEC node to new length LEN.  */
    2967              : 
    2968              : tree
    2969       540039 : grow_tree_vec (tree v, int len MEM_STAT_DECL)
    2970              : {
    2971       540039 :   gcc_assert (TREE_CODE (v) == TREE_VEC);
    2972              : 
    2973       540039 :   int oldlen = TREE_VEC_LENGTH (v);
    2974       540039 :   gcc_assert (len > oldlen);
    2975              : 
    2976       540039 :   size_t oldlength = (oldlen - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2977       540039 :   size_t length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
    2978              : 
    2979       540039 :   record_node_allocation_statistics (TREE_VEC, length - oldlength);
    2980              : 
    2981       540039 :   v = (tree) ggc_realloc (v, length PASS_MEM_STAT);
    2982              : 
    2983       540039 :   TREE_VEC_LENGTH (v) = len;
    2984              : 
    2985       540039 :   return v;
    2986              : }
    2987              : 
    2988              : /* Return true if EXPR is the constant zero, whether it is integral, float or
    2989              :    fixed, and scalar, complex or vector.  */
    2990              : 
    2991              : bool
    2992     18529674 : zerop (const_tree expr)
    2993              : {
    2994     18529674 :   return (integer_zerop (expr)
    2995     12709145 :           || real_zerop (expr)
    2996     30833482 :           || fixed_zerop (expr));
    2997              : }
    2998              : 
    2999              : /* Return true if EXPR is the integer constant zero or a complex constant
    3000              :    of zero, or a location wrapper for such a constant.  */
    3001              : 
    3002              : bool
    3003   7075395874 : integer_zerop (const_tree expr)
    3004              : {
    3005   7075395874 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3006              : 
    3007   7075395874 :   switch (TREE_CODE (expr))
    3008              :     {
    3009   5568955711 :     case INTEGER_CST:
    3010   5568955711 :       return wi::to_wide (expr) == 0;
    3011      1202446 :     case COMPLEX_CST:
    3012      1202446 :       return (integer_zerop (TREE_REALPART (expr))
    3013      1225715 :               && integer_zerop (TREE_IMAGPART (expr)));
    3014      3067374 :     case VECTOR_CST:
    3015      3067374 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3016      2898035 :               && VECTOR_CST_DUPLICATE_P (expr)
    3017      5511525 :               && integer_zerop (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3018              :     default:
    3019              :       return false;
    3020              :     }
    3021              : }
    3022              : 
    3023              : /* Return true if EXPR is the integer constant one or the corresponding
    3024              :    complex constant, or a location wrapper for such a constant.  */
    3025              : 
    3026              : bool
    3027   1096647138 : integer_onep (const_tree expr)
    3028              : {
    3029   1096647138 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3030              : 
    3031   1096647138 :   switch (TREE_CODE (expr))
    3032              :     {
    3033    950175537 :     case INTEGER_CST:
    3034    950175537 :       return wi::eq_p (wi::to_widest (expr), 1);
    3035        22388 :     case COMPLEX_CST:
    3036        22388 :       return (integer_onep (TREE_REALPART (expr))
    3037        22440 :               && integer_zerop (TREE_IMAGPART (expr)));
    3038       192624 :     case VECTOR_CST:
    3039       192624 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3040       171340 :               && VECTOR_CST_DUPLICATE_P (expr)
    3041       340163 :               && integer_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3042              :     default:
    3043              :       return false;
    3044              :     }
    3045              : }
    3046              : 
    3047              : /* Return true if EXPR is the integer constant one.  For complex and vector,
    3048              :    return true if every piece is the integer constant one.
    3049              :    Also return true for location wrappers for such a constant.  */
    3050              : 
    3051              : bool
    3052       773530 : integer_each_onep (const_tree expr)
    3053              : {
    3054       773530 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3055              : 
    3056       773530 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3057           34 :     return (integer_onep (TREE_REALPART (expr))
    3058           48 :             && integer_onep (TREE_IMAGPART (expr)));
    3059              :   else
    3060       773496 :     return integer_onep (expr);
    3061              : }
    3062              : 
    3063              : /* Return true if EXPR is an integer containing all 1's in as much precision
    3064              :    as it contains, or a complex or vector whose subparts are such integers,
    3065              :    or a location wrapper for such a constant.  */
    3066              : 
    3067              : bool
    3068    299301657 : integer_all_onesp (const_tree expr)
    3069              : {
    3070    299301657 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3071              : 
    3072    299301657 :   if (TREE_CODE (expr) == COMPLEX_CST
    3073          952 :       && integer_all_onesp (TREE_REALPART (expr))
    3074    299301697 :       && integer_all_onesp (TREE_IMAGPART (expr)))
    3075              :     return true;
    3076              : 
    3077    299301621 :   else if (TREE_CODE (expr) == VECTOR_CST)
    3078       626964 :     return (VECTOR_CST_NPATTERNS (expr) == 1
    3079       573895 :             && VECTOR_CST_DUPLICATE_P (expr)
    3080      1176120 :             && integer_all_onesp (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3081              : 
    3082    298674657 :   else if (TREE_CODE (expr) != INTEGER_CST)
    3083              :     return false;
    3084              : 
    3085    197784290 :   return (wi::max_value (TYPE_PRECISION (TREE_TYPE (expr)), UNSIGNED)
    3086    395634676 :           == wi::to_wide (expr));
    3087              : }
    3088              : 
    3089              : /* Return true if EXPR is the integer constant minus one, or a location
    3090              :    wrapper for such a constant.  */
    3091              : 
    3092              : bool
    3093    218345290 : integer_minus_onep (const_tree expr)
    3094              : {
    3095    218345290 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3096              : 
    3097    218345290 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3098         9421 :     return (integer_all_onesp (TREE_REALPART (expr))
    3099         9425 :             && integer_zerop (TREE_IMAGPART (expr)));
    3100              :   else
    3101    218335869 :     return integer_all_onesp (expr);
    3102              : }
    3103              : 
    3104              : /* Return true if EXPR is an integer constant that is a power of 2 (i.e., has
    3105              :    only one bit on), or a location wrapper for such a constant.  */
    3106              : 
    3107              : bool
    3108     22403570 : integer_pow2p (const_tree expr)
    3109              : {
    3110     22403570 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3111              : 
    3112     22403570 :   if (TREE_CODE (expr) == COMPLEX_CST
    3113          567 :       && integer_pow2p (TREE_REALPART (expr))
    3114     22403811 :       && integer_zerop (TREE_IMAGPART (expr)))
    3115              :     return true;
    3116              : 
    3117     22403403 :   if (TREE_CODE (expr) != INTEGER_CST)
    3118              :     return false;
    3119              : 
    3120     14035850 :   return wi::popcount (wi::to_wide (expr)) == 1;
    3121              : }
    3122              : 
    3123              : /* Return true if EXPR is an integer constant other than zero or a
    3124              :    complex constant other than zero, or a location wrapper for such a
    3125              :    constant.  */
    3126              : 
    3127              : bool
    3128    163827042 : integer_nonzerop (const_tree expr)
    3129              : {
    3130    163827042 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3131              : 
    3132    163827042 :   return ((TREE_CODE (expr) == INTEGER_CST
    3133     85763942 :            && wi::to_wide (expr) != 0)
    3134    192972861 :           || (TREE_CODE (expr) == COMPLEX_CST
    3135          244 :               && (integer_nonzerop (TREE_REALPART (expr))
    3136          184 :                   || integer_nonzerop (TREE_IMAGPART (expr)))));
    3137              : }
    3138              : 
    3139              : /* Return true if EXPR is the integer constant one.  For vector,
    3140              :    return true if every piece is the integer constant minus one
    3141              :    (representing the value TRUE).
    3142              :    Also return true for location wrappers for such a constant.  */
    3143              : 
    3144              : bool
    3145      1184211 : integer_truep (const_tree expr)
    3146              : {
    3147      1184211 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3148              : 
    3149      1184211 :   if (TREE_CODE (expr) == VECTOR_CST)
    3150        15351 :     return integer_all_onesp (expr);
    3151      1168860 :   return integer_onep (expr);
    3152              : }
    3153              : 
    3154              : /* Return true if EXPR is the fixed-point constant zero, or a location wrapper
    3155              :    for such a constant.  */
    3156              : 
    3157              : bool
    3158     29783591 : fixed_zerop (const_tree expr)
    3159              : {
    3160     29783591 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3161              : 
    3162     29783591 :   return (TREE_CODE (expr) == FIXED_CST
    3163     29783591 :           && TREE_FIXED_CST (expr).data.is_zero ());
    3164              : }
    3165              : 
    3166              : /* Return the power of two represented by a tree node known to be a
    3167              :    power of two.  */
    3168              : 
    3169              : int
    3170       787145 : tree_log2 (const_tree expr)
    3171              : {
    3172       787145 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3173            0 :     return tree_log2 (TREE_REALPART (expr));
    3174              : 
    3175       787145 :   return wi::exact_log2 (wi::to_wide (expr));
    3176              : }
    3177              : 
    3178              : /* Similar, but return the largest integer Y such that 2 ** Y is less
    3179              :    than or equal to EXPR.  */
    3180              : 
    3181              : int
    3182      2981940 : tree_floor_log2 (const_tree expr)
    3183              : {
    3184      2981940 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3185            0 :     return tree_log2 (TREE_REALPART (expr));
    3186              : 
    3187      2981940 :   return wi::floor_log2 (wi::to_wide (expr));
    3188              : }
    3189              : 
    3190              : /* Return number of known trailing zero bits in EXPR, or, if the value of
    3191              :    EXPR is known to be zero, the precision of it's type.  */
    3192              : 
    3193              : unsigned int
    3194     84164170 : tree_ctz (const_tree expr)
    3195              : {
    3196    168326627 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
    3197     84172210 :       && !POINTER_TYPE_P (TREE_TYPE (expr)))
    3198              :     return 0;
    3199              : 
    3200     84164109 :   unsigned int ret1, ret2, prec = TYPE_PRECISION (TREE_TYPE (expr));
    3201     84164109 :   switch (TREE_CODE (expr))
    3202              :     {
    3203     44822184 :     case INTEGER_CST:
    3204     44822184 :       ret1 = wi::ctz (wi::to_wide (expr));
    3205     44822184 :       return MIN (ret1, prec);
    3206     12831937 :     case SSA_NAME:
    3207     12831937 :       ret1 = wi::ctz (get_nonzero_bits (expr));
    3208     12831937 :       return MIN (ret1, prec);
    3209      2094703 :     case PLUS_EXPR:
    3210      2094703 :     case MINUS_EXPR:
    3211      2094703 :     case BIT_IOR_EXPR:
    3212      2094703 :     case BIT_XOR_EXPR:
    3213      2094703 :     case MIN_EXPR:
    3214      2094703 :     case MAX_EXPR:
    3215      2094703 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3216      2094703 :       if (ret1 == 0)
    3217              :         return ret1;
    3218       962788 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3219       962788 :       return MIN (ret1, ret2);
    3220            0 :     case POINTER_PLUS_EXPR:
    3221            0 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3222            0 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3223              :       /* Second operand is sizetype, which could be in theory
    3224              :          wider than pointer's precision.  Make sure we never
    3225              :          return more than prec.  */
    3226            0 :       ret2 = MIN (ret2, prec);
    3227            0 :       return MIN (ret1, ret2);
    3228          234 :     case BIT_AND_EXPR:
    3229          234 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3230          234 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3231          234 :       return MAX (ret1, ret2);
    3232     11900019 :     case MULT_EXPR:
    3233     11900019 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3234     11900019 :       ret2 = tree_ctz (TREE_OPERAND (expr, 1));
    3235     11900019 :       return MIN (ret1 + ret2, prec);
    3236            0 :     case LSHIFT_EXPR:
    3237            0 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3238            0 :       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
    3239            0 :           && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
    3240              :         {
    3241            0 :           ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
    3242            0 :           return MIN (ret1 + ret2, prec);
    3243              :         }
    3244              :       return ret1;
    3245            0 :     case RSHIFT_EXPR:
    3246            0 :       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
    3247            0 :           && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
    3248              :         {
    3249            0 :           ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3250            0 :           ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
    3251            0 :           if (ret1 > ret2)
    3252            0 :             return ret1 - ret2;
    3253              :         }
    3254              :       return 0;
    3255         6077 :     case TRUNC_DIV_EXPR:
    3256         6077 :     case CEIL_DIV_EXPR:
    3257         6077 :     case FLOOR_DIV_EXPR:
    3258         6077 :     case ROUND_DIV_EXPR:
    3259         6077 :     case EXACT_DIV_EXPR:
    3260         6077 :       if (TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST
    3261         6077 :           && tree_int_cst_sgn (TREE_OPERAND (expr, 1)) == 1)
    3262              :         {
    3263         6077 :           int l = tree_log2 (TREE_OPERAND (expr, 1));
    3264         6077 :           if (l >= 0)
    3265              :             {
    3266         5001 :               ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3267         5001 :               ret2 = l;
    3268         5001 :               if (ret1 > ret2)
    3269            0 :                 return ret1 - ret2;
    3270              :             }
    3271              :         }
    3272              :       return 0;
    3273     12485910 :     CASE_CONVERT:
    3274     12485910 :       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
    3275     12485910 :       if (ret1 && ret1 == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
    3276              :         ret1 = prec;
    3277     12485910 :       return MIN (ret1, prec);
    3278            0 :     case SAVE_EXPR:
    3279            0 :       return tree_ctz (TREE_OPERAND (expr, 0));
    3280        12486 :     case COND_EXPR:
    3281        12486 :       ret1 = tree_ctz (TREE_OPERAND (expr, 1));
    3282        12486 :       if (ret1 == 0)
    3283              :         return 0;
    3284          205 :       ret2 = tree_ctz (TREE_OPERAND (expr, 2));
    3285          205 :       return MIN (ret1, ret2);
    3286            0 :     case COMPOUND_EXPR:
    3287            0 :       return tree_ctz (TREE_OPERAND (expr, 1));
    3288          196 :     case ADDR_EXPR:
    3289          196 :       ret1 = get_pointer_alignment (const_cast<tree> (expr));
    3290          196 :       if (ret1 > BITS_PER_UNIT)
    3291              :         {
    3292          196 :           ret1 = ctz_hwi (ret1 / BITS_PER_UNIT);
    3293          196 :           return MIN (ret1, prec);
    3294              :         }
    3295              :       return 0;
    3296              :     default:
    3297              :       return 0;
    3298              :     }
    3299              : }
    3300              : 
    3301              : /* Return true if EXPR is the real constant zero.  Trailing zeroes matter for
    3302              :    decimal float constants, so don't return true for them.
    3303              :    Also return true for location wrappers around such a constant.  */
    3304              : 
    3305              : bool
    3306    591034138 : real_zerop (const_tree expr)
    3307              : {
    3308    591034138 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3309              : 
    3310    591034138 :   switch (TREE_CODE (expr))
    3311              :     {
    3312     19432318 :     case REAL_CST:
    3313     19432318 :       return real_equal (&TREE_REAL_CST (expr), &dconst0)
    3314     19432318 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3315        45608 :     case COMPLEX_CST:
    3316        45608 :       return real_zerop (TREE_REALPART (expr))
    3317        58832 :              && real_zerop (TREE_IMAGPART (expr));
    3318       472456 :     case VECTOR_CST:
    3319       472456 :       {
    3320              :         /* Don't simply check for a duplicate because the predicate
    3321              :            accepts both +0.0 and -0.0.  */
    3322       472456 :         unsigned count = vector_cst_encoded_nelts (expr);
    3323       979788 :         for (unsigned int i = 0; i < count; ++i)
    3324       483522 :           if (!real_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
    3325              :             return false;
    3326              :         return true;
    3327              :       }
    3328              :     default:
    3329              :       return false;
    3330              :     }
    3331              : }
    3332              : 
    3333              : /* Return true if EXPR is the real constant negative zero.  */
    3334              : 
    3335              : bool
    3336            6 : real_negzerop (const_tree expr)
    3337              : {
    3338            6 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3339              : 
    3340            6 :   if (TREE_CODE (expr) == VECTOR_CST)
    3341              :     {
    3342            0 :       expr = uniform_vector_p (expr);
    3343            0 :       if (!expr)
    3344              :         return false;
    3345              :     }
    3346              : 
    3347            6 :   if (TREE_CODE (expr) == COMPLEX_CST)
    3348            2 :     return real_negzerop (TREE_REALPART (expr))
    3349            4 :            && real_negzerop (TREE_IMAGPART (expr));
    3350              : 
    3351            4 :   return TREE_CODE (expr) == REAL_CST
    3352            4 :           && REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (expr))
    3353            8 :           && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3354              : }
    3355              : 
    3356              : /* Return true if EXPR is the real constant one in real or complex form.
    3357              :    Trailing zeroes matter for decimal float constants, so don't return
    3358              :    true for them.
    3359              :    Also return true for location wrappers around such a constant.  */
    3360              : 
    3361              : bool
    3362    121792254 : real_onep (const_tree expr)
    3363              : {
    3364    121792254 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3365              : 
    3366    121792254 :   switch (TREE_CODE (expr))
    3367              :     {
    3368      7232900 :     case REAL_CST:
    3369      7232900 :       return real_equal (&TREE_REAL_CST (expr), &dconst1)
    3370      7232900 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3371        12972 :     case COMPLEX_CST:
    3372        12972 :       return real_onep (TREE_REALPART (expr))
    3373        16581 :              && real_zerop (TREE_IMAGPART (expr));
    3374        60999 :     case VECTOR_CST:
    3375        60999 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3376        51813 :               && VECTOR_CST_DUPLICATE_P (expr)
    3377       102253 :               && real_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3378              :     default:
    3379              :       return false;
    3380              :     }
    3381              : }
    3382              : 
    3383              : /* Return true if EXPR is the real constant minus one.  Trailing zeroes
    3384              :    matter for decimal float constants, so don't return true for them.
    3385              :    Also return true for location wrappers around such a constant.  */
    3386              : 
    3387              : bool
    3388    122825865 : real_minus_onep (const_tree expr)
    3389              : {
    3390    122825865 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3391              : 
    3392    122825865 :   switch (TREE_CODE (expr))
    3393              :     {
    3394      7166628 :     case REAL_CST:
    3395      7166628 :       return real_equal (&TREE_REAL_CST (expr), &dconstm1)
    3396      7166628 :              && !(DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (expr))));
    3397        12952 :     case COMPLEX_CST:
    3398        12952 :       return real_minus_onep (TREE_REALPART (expr))
    3399        15324 :              && real_zerop (TREE_IMAGPART (expr));
    3400        62633 :     case VECTOR_CST:
    3401        62633 :       return (VECTOR_CST_NPATTERNS (expr) == 1
    3402        52847 :               && VECTOR_CST_DUPLICATE_P (expr)
    3403       104722 :               && real_minus_onep (VECTOR_CST_ENCODED_ELT (expr, 0)));
    3404              :     default:
    3405              :       return false;
    3406              :     }
    3407              : }
    3408              : 
    3409              : /* Return true if T could be a floating point zero.  */
    3410              : 
    3411              : bool
    3412       706795 : real_maybe_zerop (const_tree expr)
    3413              : {
    3414       706795 :   switch (TREE_CODE (expr))
    3415              :     {
    3416       485166 :     case REAL_CST:
    3417              :       /* Can't use real_zerop here, as it always returns false for decimal
    3418              :          floats.  And can't use TREE_REAL_CST (expr).cl == rvc_zero
    3419              :          either, as decimal zeros are rvc_normal.  */
    3420       485166 :       return real_equal (&TREE_REAL_CST (expr), &dconst0);
    3421            0 :     case COMPLEX_CST:
    3422            0 :       return (real_maybe_zerop (TREE_REALPART (expr))
    3423            0 :               || real_maybe_zerop (TREE_IMAGPART (expr)));
    3424            0 :     case VECTOR_CST:
    3425            0 :       {
    3426            0 :         unsigned count = vector_cst_encoded_nelts (expr);
    3427            0 :         for (unsigned int i = 0; i < count; ++i)
    3428            0 :           if (real_maybe_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
    3429              :             return true;
    3430              :         return false;
    3431              :       }
    3432              :     default:
    3433              :       /* Perhaps for SSA_NAMEs we could query frange.  */
    3434              :       return true;
    3435              :     }
    3436              : }
    3437              : 
    3438              : /* True if EXP is a constant or a cast of a constant.  */
    3439              : 
    3440              : bool
    3441         6166 : really_constant_p (const_tree exp)
    3442              : {
    3443              :   /* This is not quite the same as STRIP_NOPS.  It does more.  */
    3444        12340 :   while (CONVERT_EXPR_P (exp)
    3445        12392 :          || TREE_CODE (exp) == NON_LVALUE_EXPR)
    3446           60 :     exp = TREE_OPERAND (exp, 0);
    3447         6166 :   return TREE_CONSTANT (exp);
    3448              : }
    3449              : 
    3450              : /* Return true if T holds a polynomial pointer difference, storing it in
    3451              :    *VALUE if so.  A true return means that T's precision is no greater
    3452              :    than 64 bits, which is the largest address space we support, so *VALUE
    3453              :    never loses precision.  However, the signedness of the result does
    3454              :    not necessarily match the signedness of T: sometimes an unsigned type
    3455              :    like sizetype is used to encode a value that is actually negative.  */
    3456              : 
    3457              : bool
    3458     11398467 : ptrdiff_tree_p (const_tree t, poly_int64 *value)
    3459              : {
    3460     11398467 :   if (!t)
    3461              :     return false;
    3462     11398467 :   if (TREE_CODE (t) == INTEGER_CST)
    3463              :     {
    3464      3294714 :       if (!cst_and_fits_in_hwi (t))
    3465              :         return false;
    3466      3294197 :       *value = int_cst_value (t);
    3467      3294197 :       return true;
    3468              :     }
    3469              :   if (POLY_INT_CST_P (t))
    3470              :     {
    3471              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    3472              :         if (!cst_and_fits_in_hwi (POLY_INT_CST_COEFF (t, i)))
    3473              :           return false;
    3474              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    3475              :         value->coeffs[i] = int_cst_value (POLY_INT_CST_COEFF (t, i));
    3476              :       return true;
    3477              :     }
    3478              :   return false;
    3479              : }
    3480              : 
    3481              : poly_int64
    3482    486999759 : tree_to_poly_int64 (const_tree t)
    3483              : {
    3484    486999759 :   gcc_assert (tree_fits_poly_int64_p (t));
    3485    486999759 :   if (POLY_INT_CST_P (t))
    3486              :     return poly_int_cst_value (t).force_shwi ();
    3487    486999759 :   return TREE_INT_CST_LOW (t);
    3488              : }
    3489              : 
    3490              : poly_uint64
    3491    552506363 : tree_to_poly_uint64 (const_tree t)
    3492              : {
    3493    552506363 :   gcc_assert (tree_fits_poly_uint64_p (t));
    3494    552506363 :   if (POLY_INT_CST_P (t))
    3495              :     return poly_int_cst_value (t).force_uhwi ();
    3496    552506363 :   return TREE_INT_CST_LOW (t);
    3497              : }
    3498              : 
    3499              : /* Return first list element whose TREE_VALUE is ELEM.
    3500              :    Return 0 if ELEM is not in LIST.  */
    3501              : 
    3502              : tree
    3503      8238590 : value_member (tree elem, tree list)
    3504              : {
    3505     23978773 :   while (list)
    3506              :     {
    3507     20825208 :       if (elem == TREE_VALUE (list))
    3508              :         return list;
    3509     15740183 :       list = TREE_CHAIN (list);
    3510              :     }
    3511              :   return NULL_TREE;
    3512              : }
    3513              : 
    3514              : /* Return first list element whose TREE_PURPOSE is ELEM.
    3515              :    Return 0 if ELEM is not in LIST.  */
    3516              : 
    3517              : tree
    3518    207271512 : purpose_member (const_tree elem, tree list)
    3519              : {
    3520    546149886 :   while (list)
    3521              :     {
    3522    371120044 :       if (elem == TREE_PURPOSE (list))
    3523              :         return list;
    3524    338878374 :       list = TREE_CHAIN (list);
    3525              :     }
    3526              :   return NULL_TREE;
    3527              : }
    3528              : 
    3529              : /* Return true if ELEM is in V.  */
    3530              : 
    3531              : bool
    3532      5370909 : vec_member (const_tree elem, vec<tree, va_gc> *v)
    3533              : {
    3534      5370909 :   unsigned ix;
    3535      5370909 :   tree t;
    3536      8111265 :   FOR_EACH_VEC_SAFE_ELT (v, ix, t)
    3537      2748610 :     if (elem == t)
    3538              :       return true;
    3539              :   return false;
    3540              : }
    3541              : 
    3542              : /* Returns element number IDX (zero-origin) of chain CHAIN, or
    3543              :    NULL_TREE.  */
    3544              : 
    3545              : tree
    3546     23082155 : chain_index (int idx, tree chain)
    3547              : {
    3548     29616152 :   for (; chain && idx > 0; --idx)
    3549      6533997 :     chain = TREE_CHAIN (chain);
    3550     23082155 :   return chain;
    3551              : }
    3552              : 
    3553              : /* Return true if ELEM is part of the chain CHAIN.  */
    3554              : 
    3555              : bool
    3556       234977 : chain_member (const_tree elem, const_tree chain)
    3557              : {
    3558       434173 :   while (chain)
    3559              :     {
    3560       432686 :       if (elem == chain)
    3561              :         return true;
    3562       199196 :       chain = DECL_CHAIN (chain);
    3563              :     }
    3564              : 
    3565              :   return false;
    3566              : }
    3567              : 
    3568              : /* Return the length of a chain of nodes chained through TREE_CHAIN.
    3569              :    We expect a null pointer to mark the end of the chain.
    3570              :    This is the Lisp primitive `length'.  */
    3571              : 
    3572              : int
    3573   2171075853 : list_length (const_tree t)
    3574              : {
    3575   2171075853 :   const_tree p = t;
    3576              : #ifdef ENABLE_TREE_CHECKING
    3577   2171075853 :   const_tree q = t;
    3578              : #endif
    3579   2171075853 :   int len = 0;
    3580              : 
    3581   3623741531 :   while (p)
    3582              :     {
    3583   1452665678 :       p = TREE_CHAIN (p);
    3584              : #ifdef ENABLE_TREE_CHECKING
    3585   1452665678 :       if (len % 2)
    3586    473333265 :         q = TREE_CHAIN (q);
    3587   1452665678 :       gcc_assert (p != q);
    3588              : #endif
    3589   1452665678 :       len++;
    3590              :     }
    3591              : 
    3592   2171075853 :   return len;
    3593              : }
    3594              : 
    3595              : /* Returns the first FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or
    3596              :    UNION_TYPE TYPE, or NULL_TREE if none.  */
    3597              : 
    3598              : tree
    3599       160171 : first_field (const_tree type)
    3600              : {
    3601       160171 :   tree t = TYPE_FIELDS (type);
    3602      4319629 :   while (t && TREE_CODE (t) != FIELD_DECL)
    3603      4159458 :     t = TREE_CHAIN (t);
    3604       160171 :   return t;
    3605              : }
    3606              : 
    3607              : /* Returns the last FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or
    3608              :    UNION_TYPE TYPE, or NULL_TREE if none.  */
    3609              : 
    3610              : tree
    3611      2844565 : last_field (const_tree type)
    3612              : {
    3613      2844565 :   tree last = NULL_TREE;
    3614              : 
    3615     66263244 :   for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
    3616              :     {
    3617     63418679 :       if (TREE_CODE (fld) != FIELD_DECL)
    3618     54848537 :         continue;
    3619              : 
    3620              :       last = fld;
    3621              :     }
    3622              : 
    3623      2844565 :   return last;
    3624              : }
    3625              : 
    3626              : /* Concatenate two chains of nodes (chained through TREE_CHAIN)
    3627              :    by modifying the last node in chain 1 to point to chain 2.
    3628              :    This is the Lisp primitive `nconc'.  */
    3629              : 
    3630              : tree
    3631   4229142179 : chainon (tree op1, tree op2)
    3632              : {
    3633   4229142179 :   tree t1;
    3634              : 
    3635   4229142179 :   if (!op1)
    3636              :     return op2;
    3637    785280988 :   if (!op2)
    3638              :     return op1;
    3639              : 
    3640   1618121916 :   for (t1 = op1; TREE_CHAIN (t1); t1 = TREE_CHAIN (t1))
    3641    912186967 :     continue;
    3642    705934949 :   TREE_CHAIN (t1) = op2;
    3643              : 
    3644              : #ifdef ENABLE_TREE_CHECKING
    3645    705934949 :   {
    3646    705934949 :     tree t2;
    3647   1797504500 :     for (t2 = op2; t2; t2 = TREE_CHAIN (t2))
    3648   1091569551 :       gcc_assert (t2 != t1);
    3649              :   }
    3650              : #endif
    3651              : 
    3652              :   return op1;
    3653    912186967 : }
    3654              : 
    3655              : /* Return the last node in a chain of nodes (chained through TREE_CHAIN).  */
    3656              : 
    3657              : tree
    3658    106583904 : tree_last (tree chain)
    3659              : {
    3660    106583904 :   tree next;
    3661    106583904 :   if (chain)
    3662    194973289 :     while ((next = TREE_CHAIN (chain)))
    3663              :       chain = next;
    3664    106583904 :   return chain;
    3665              : }
    3666              : 
    3667              : /* Reverse the order of elements in the chain T,
    3668              :    and return the new head of the chain (old last element).  */
    3669              : 
    3670              : tree
    3671   1600153028 : nreverse (tree t)
    3672              : {
    3673   1600153028 :   tree prev = 0, decl, next;
    3674   4042437254 :   for (decl = t; decl; decl = next)
    3675              :     {
    3676              :       /* We shouldn't be using this function to reverse BLOCK chains; we
    3677              :          have blocks_nreverse for that.  */
    3678   2442284226 :       gcc_checking_assert (TREE_CODE (decl) != BLOCK);
    3679   2442284226 :       next = TREE_CHAIN (decl);
    3680   2442284226 :       TREE_CHAIN (decl) = prev;
    3681   2442284226 :       prev = decl;
    3682              :     }
    3683   1600153028 :   return prev;
    3684              : }
    3685              : 
    3686              : /* Return a newly created TREE_LIST node whose
    3687              :    purpose and value fields are PARM and VALUE.  */
    3688              : 
    3689              : tree
    3690   1484800797 : build_tree_list (tree parm, tree value MEM_STAT_DECL)
    3691              : {
    3692   1484800797 :   tree t = make_node (TREE_LIST PASS_MEM_STAT);
    3693   1484800797 :   TREE_PURPOSE (t) = parm;
    3694   1484800797 :   TREE_VALUE (t) = value;
    3695   1484800797 :   return t;
    3696              : }
    3697              : 
    3698              : /* Build a chain of TREE_LIST nodes from a vector.  */
    3699              : 
    3700              : tree
    3701     93609174 : build_tree_list_vec (const vec<tree, va_gc> *vec MEM_STAT_DECL)
    3702              : {
    3703     93609174 :   tree ret = NULL_TREE;
    3704     93609174 :   tree *pp = &ret;
    3705     93609174 :   unsigned int i;
    3706     93609174 :   tree t;
    3707    196536033 :   FOR_EACH_VEC_SAFE_ELT (vec, i, t)
    3708              :     {
    3709    102926859 :       *pp = build_tree_list (NULL, t PASS_MEM_STAT);
    3710    102926859 :       pp = &TREE_CHAIN (*pp);
    3711              :     }
    3712     93609174 :   return ret;
    3713              : }
    3714              : 
    3715              : /* Return a newly created TREE_LIST node whose
    3716              :    purpose and value fields are PURPOSE and VALUE
    3717              :    and whose TREE_CHAIN is CHAIN.  */
    3718              : 
    3719              : tree
    3720   5702321841 : tree_cons (tree purpose, tree value, tree chain MEM_STAT_DECL)
    3721              : {
    3722   5702321841 :   tree node;
    3723              : 
    3724   5702321841 :   node = ggc_alloc_tree_node_stat (sizeof (struct tree_list) PASS_MEM_STAT);
    3725   5702321841 :   memset (node, 0, sizeof (struct tree_common));
    3726              : 
    3727   5702321841 :   record_node_allocation_statistics (TREE_LIST, sizeof (struct tree_list));
    3728              : 
    3729   5702321841 :   TREE_SET_CODE (node, TREE_LIST);
    3730   5702321841 :   TREE_CHAIN (node) = chain;
    3731   5702321841 :   TREE_PURPOSE (node) = purpose;
    3732   5702321841 :   TREE_VALUE (node) = value;
    3733   5702321841 :   return node;
    3734              : }
    3735              : 
    3736              : /* Return the values of the elements of a CONSTRUCTOR as a vector of
    3737              :    trees.  */
    3738              : 
    3739              : vec<tree, va_gc> *
    3740            0 : ctor_to_vec (tree ctor)
    3741              : {
    3742            0 :   vec<tree, va_gc> *vec;
    3743            0 :   vec_alloc (vec, CONSTRUCTOR_NELTS (ctor));
    3744            0 :   unsigned int ix;
    3745            0 :   tree val;
    3746              : 
    3747            0 :   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), ix, val)
    3748            0 :     vec->quick_push (val);
    3749              : 
    3750            0 :   return vec;
    3751              : }
    3752              : 
    3753              : /* Return the size nominally occupied by an object of type TYPE
    3754              :    when it resides in memory.  The value is measured in units of bytes,
    3755              :    and its data type is that normally used for type sizes
    3756              :    (which is the first type created by make_signed_type or
    3757              :    make_unsigned_type).  */
    3758              : 
    3759              : tree
    3760     29064946 : size_in_bytes_loc (location_t loc, const_tree type)
    3761              : {
    3762     29064946 :   tree t;
    3763              : 
    3764     29064946 :   if (type == error_mark_node)
    3765            0 :     return integer_zero_node;
    3766              : 
    3767     29064946 :   type = TYPE_MAIN_VARIANT (type);
    3768     29064946 :   t = TYPE_SIZE_UNIT (type);
    3769              : 
    3770     29064946 :   if (t == 0)
    3771              :     {
    3772           65 :       lang_hooks.types.incomplete_type_error (loc, NULL_TREE, type);
    3773           65 :       return size_zero_node;
    3774              :     }
    3775              : 
    3776              :   return t;
    3777              : }
    3778              : 
    3779              : /* Return the size of TYPE (in bytes) as a wide integer
    3780              :    or return -1 if the size can vary or is larger than an integer.  */
    3781              : 
    3782              : HOST_WIDE_INT
    3783    513883857 : int_size_in_bytes (const_tree type)
    3784              : {
    3785    513883857 :   tree t;
    3786              : 
    3787    513883857 :   if (type == error_mark_node)
    3788              :     return 0;
    3789              : 
    3790    513883857 :   type = TYPE_MAIN_VARIANT (type);
    3791    513883857 :   t = TYPE_SIZE_UNIT (type);
    3792              : 
    3793    513883857 :   if (t && tree_fits_uhwi_p (t))
    3794    513830253 :     return TREE_INT_CST_LOW (t);
    3795              :   else
    3796              :     return -1;
    3797              : }
    3798              : 
    3799              : /* Return the maximum size of TYPE (in bytes) as a wide integer
    3800              :    or return -1 if the size can vary or is larger than an integer.  */
    3801              : 
    3802              : HOST_WIDE_INT
    3803         9286 : max_int_size_in_bytes (const_tree type)
    3804              : {
    3805         9286 :   HOST_WIDE_INT size = -1;
    3806         9286 :   tree size_tree;
    3807              : 
    3808              :   /* If this is an array type, check for a possible MAX_SIZE attached.  */
    3809              : 
    3810         9286 :   if (TREE_CODE (type) == ARRAY_TYPE)
    3811              :     {
    3812         8553 :       size_tree = TYPE_ARRAY_MAX_SIZE (type);
    3813              : 
    3814         8553 :       if (size_tree && tree_fits_uhwi_p (size_tree))
    3815            0 :         size = tree_to_uhwi (size_tree);
    3816              :     }
    3817              : 
    3818              :   /* If we still haven't been able to get a size, see if the language
    3819              :      can compute a maximum size.  */
    3820              : 
    3821            0 :   if (size == -1)
    3822              :     {
    3823         9286 :       size_tree = lang_hooks.types.max_size (type);
    3824              : 
    3825         9286 :       if (size_tree && tree_fits_uhwi_p (size_tree))
    3826            0 :         size = tree_to_uhwi (size_tree);
    3827              :     }
    3828              : 
    3829         9286 :   return size;
    3830              : }
    3831              : 
    3832              : /* Return the bit position of FIELD, in bits from the start of the record.
    3833              :    This is a tree of type bitsizetype.  */
    3834              : 
    3835              : tree
    3836    147764739 : bit_position (const_tree field)
    3837              : {
    3838    147764739 :   return bit_from_pos (DECL_FIELD_OFFSET (field),
    3839    147764739 :                        DECL_FIELD_BIT_OFFSET (field));
    3840              : }
    3841              : 
    3842              : /* Return the byte position of FIELD, in bytes from the start of the record.
    3843              :    This is a tree of type sizetype.  */
    3844              : 
    3845              : tree
    3846    121390343 : byte_position (const_tree field)
    3847              : {
    3848    121390343 :   return byte_from_pos (DECL_FIELD_OFFSET (field),
    3849    121390343 :                         DECL_FIELD_BIT_OFFSET (field));
    3850              : }
    3851              : 
    3852              : /* Likewise, but return as an integer.  It must be representable in
    3853              :    that way (since it could be a signed value, we don't have the
    3854              :    option of returning -1 like int_size_in_byte can.  */
    3855              : 
    3856              : HOST_WIDE_INT
    3857     10121188 : int_byte_position (const_tree field)
    3858              : {
    3859     10121188 :   return tree_to_shwi (byte_position (field));
    3860              : }
    3861              : 
    3862              : /* Return, as a tree node, the number of elements for TYPE (which is an
    3863              :    ARRAY_TYPE) minus one.  This counts only elements of the top array.  */
    3864              : 
    3865              : tree
    3866    115211694 : array_type_nelts_minus_one (const_tree type)
    3867              : {
    3868    115211694 :   tree index_type, min, max;
    3869              : 
    3870              :   /* If they did it with unspecified bounds, then we should have already
    3871              :      given an error about it before we got here.  */
    3872    115211694 :   if (! TYPE_DOMAIN (type))
    3873     10232410 :     return error_mark_node;
    3874              : 
    3875    104979284 :   index_type = TYPE_DOMAIN (type);
    3876    104979284 :   min = TYPE_MIN_VALUE (index_type);
    3877    104979284 :   max = TYPE_MAX_VALUE (index_type);
    3878              : 
    3879              :   /* TYPE_MAX_VALUE may not be set if the array has unknown length.  */
    3880    104979284 :   if (!max)
    3881              :     {
    3882              :       /* zero sized arrays are represented from C FE as complete types with
    3883              :          NULL TYPE_MAX_VALUE and zero TYPE_SIZE, while C++ FE represents
    3884              :          them as min 0, max -1.  */
    3885      1285068 :       if (COMPLETE_TYPE_P (type)
    3886         3145 :           && integer_zerop (TYPE_SIZE (type))
    3887      1288213 :           && integer_zerop (min))
    3888         3145 :         return build_int_cst (TREE_TYPE (min), -1);
    3889              : 
    3890      1281923 :       return error_mark_node;
    3891              :     }
    3892              : 
    3893    103694216 :   return (integer_zerop (min)
    3894    103694216 :           ? max
    3895      1162440 :           : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));
    3896              : }
    3897              : 
    3898              : /* Return, as an INTEGER_CST node, the number of elements for TYPE
    3899              :    (which is an ARRAY_TYPE).  This counts only elements of the top
    3900              :    array.  */
    3901              : 
    3902              : tree
    3903     25155065 : array_type_nelts_top (tree type)
    3904              : {
    3905     25155065 :   return fold_build2_loc (input_location,
    3906              :                       PLUS_EXPR, sizetype,
    3907              :                       array_type_nelts_minus_one (type),
    3908     25155065 :                       size_one_node);
    3909              : }
    3910              : 
    3911              : /* If arg is static -- a reference to an object in static storage -- then
    3912              :    return the object.  This is not the same as the C meaning of `static'.
    3913              :    If arg isn't static, return NULL.  */
    3914              : 
    3915              : tree
    3916   1231982110 : staticp (tree arg)
    3917              : {
    3918   1233059054 :   switch (TREE_CODE (arg))
    3919              :     {
    3920              :     case FUNCTION_DECL:
    3921              :       /* Nested functions are static, even though taking their address will
    3922              :          involve a trampoline as we unnest the nested function and create
    3923              :          the trampoline on the tree level.  */
    3924              :       return arg;
    3925              : 
    3926    741351957 :     case VAR_DECL:
    3927    586354206 :       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
    3928    200542146 :               && ! DECL_THREAD_LOCAL_P (arg)
    3929    198680982 :               && ! DECL_DLLIMPORT_P (arg)
    3930    741351957 :               ? arg : NULL);
    3931              : 
    3932       696892 :     case CONST_DECL:
    3933           44 :       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
    3934       696892 :               ? arg : NULL);
    3935              : 
    3936            0 :     case CONSTRUCTOR:
    3937            0 :       return TREE_STATIC (arg) ? arg : NULL;
    3938              : 
    3939              :     case LABEL_DECL:
    3940              :     case STRING_CST:
    3941              :       return arg;
    3942              : 
    3943       823085 :     case COMPONENT_REF:
    3944              :       /* If the thing being referenced is not a field, then it is
    3945              :          something language specific.  */
    3946       823085 :       gcc_assert (TREE_CODE (TREE_OPERAND (arg, 1)) == FIELD_DECL);
    3947              : 
    3948              :       /* If we are referencing a bitfield, we can't evaluate an
    3949              :          ADDR_EXPR at compile time and so it isn't a constant.  */
    3950       823085 :       if (DECL_BIT_FIELD (TREE_OPERAND (arg, 1)))
    3951              :         return NULL;
    3952              : 
    3953       823085 :       return staticp (TREE_OPERAND (arg, 0));
    3954              : 
    3955              :     case BIT_FIELD_REF:
    3956              :       return NULL;
    3957              : 
    3958        35212 :     case INDIRECT_REF:
    3959        35212 :       return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL;
    3960              : 
    3961       253747 :     case ARRAY_REF:
    3962       253747 :     case ARRAY_RANGE_REF:
    3963       253747 :       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST
    3964       253747 :           && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
    3965       253403 :         return staticp (TREE_OPERAND (arg, 0));
    3966              :       else
    3967              :         return NULL;
    3968              : 
    3969          456 :     case REALPART_EXPR:
    3970          456 :     case IMAGPART_EXPR:
    3971          456 :       return staticp (TREE_OPERAND (arg, 0));
    3972              : 
    3973          934 :     case COMPOUND_LITERAL_EXPR:
    3974          934 :       return TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (arg)) ? arg : NULL;
    3975              : 
    3976              :     default:
    3977              :       return NULL;
    3978              :     }
    3979              : }
    3980              : 
    3981              : 
    3982              : 
    3983              : 
    3984              : /* Return whether OP is a DECL whose address is function-invariant.  */
    3985              : 
    3986              : bool
    3987   5359129618 : decl_address_invariant_p (const_tree op)
    3988              : {
    3989              :   /* The conditions below are slightly less strict than the one in
    3990              :      staticp.  */
    3991              : 
    3992   5359129618 :   switch (TREE_CODE (op))
    3993              :     {
    3994              :     case PARM_DECL:
    3995              :     case RESULT_DECL:
    3996              :     case LABEL_DECL:
    3997              :     case FUNCTION_DECL:
    3998              :       return true;
    3999              : 
    4000   2955702051 :     case VAR_DECL:
    4001   2250302504 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4002   2114303056 :           || DECL_THREAD_LOCAL_P (op)
    4003   2114303056 :           || DECL_CONTEXT (op) == current_function_decl
    4004   2963647216 :           || decl_function_context (op) == current_function_decl)
    4005              :         return true;
    4006              :       break;
    4007              : 
    4008     26037245 :     case CONST_DECL:
    4009            0 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4010     26037245 :           || decl_function_context (op) == current_function_decl)
    4011              :         return true;
    4012              :       break;
    4013              : 
    4014              :     default:
    4015              :       break;
    4016              :     }
    4017              : 
    4018              :   return false;
    4019              : }
    4020              : 
    4021              : /* Return whether OP is a DECL whose address is interprocedural-invariant.  */
    4022              : 
    4023              : bool
    4024      1854119 : decl_address_ip_invariant_p (const_tree op)
    4025              : {
    4026              :   /* The conditions below are slightly less strict than the one in
    4027              :      staticp.  */
    4028              : 
    4029      1854119 :   symtab_node* node;
    4030      1854119 :   switch (TREE_CODE (op))
    4031              :     {
    4032              :     case LABEL_DECL:
    4033              :     case STRING_CST:
    4034              :       return true;
    4035              : 
    4036        91266 :     case FUNCTION_DECL:
    4037              :       /* Disable const propagation of symbols defined in assembly.  */
    4038        91266 :       node = symtab_node::get (op);
    4039        91266 :       return !node || !node->must_remain_in_tu_name;
    4040              : 
    4041      1657638 :     case VAR_DECL:
    4042      1657638 :       if (TREE_STATIC (op) || DECL_EXTERNAL (op))
    4043              :           {
    4044              :             /* Disable const propagation of symbols defined in assembly.  */
    4045       481455 :             node = symtab_node::get (op);
    4046       481455 :             if (node && node->must_remain_in_tu_name)
    4047              :               return false;
    4048              :           }
    4049      1216080 :       if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
    4050       481453 :            && !DECL_DLLIMPORT_P (op))
    4051      2833819 :           || DECL_THREAD_LOCAL_P (op))
    4052              :         return true;
    4053              :       break;
    4054              : 
    4055        53548 :     case CONST_DECL:
    4056        53548 :       if ((TREE_STATIC (op) || DECL_EXTERNAL (op)))
    4057              :         return true;
    4058              :       break;
    4059              : 
    4060              :     default:
    4061              :       break;
    4062              :     }
    4063              : 
    4064              :   return false;
    4065              : }
    4066              : 
    4067              : /* Return true if T is an object with invariant address.  */
    4068              : 
    4069              : bool
    4070        45670 : address_invariant_p (tree t)
    4071              : {
    4072        53623 :   while (handled_component_p (t))
    4073              :     {
    4074         8952 :       switch (TREE_CODE (t))
    4075              :         {
    4076         1481 :         case ARRAY_REF:
    4077         1481 :         case ARRAY_RANGE_REF:
    4078         1481 :           if (!tree_invariant_p (TREE_OPERAND (t, 1))
    4079          482 :               || TREE_OPERAND (t, 2) != NULL_TREE
    4080         1963 :               || TREE_OPERAND (t, 3) != NULL_TREE)
    4081              :             return false;
    4082              :           break;
    4083              : 
    4084         7312 :         case COMPONENT_REF:
    4085         7312 :           if (TREE_OPERAND (t, 2) != NULL_TREE)
    4086              :             return false;
    4087              :           break;
    4088              : 
    4089              :         default:
    4090              :           break;
    4091              :         }
    4092         7953 :       t = TREE_OPERAND (t, 0);
    4093              :     }
    4094              : 
    4095        44671 :   STRIP_ANY_LOCATION_WRAPPER (t);
    4096        44671 :   return CONSTANT_CLASS_P (t) || decl_address_invariant_p (t);
    4097              : }
    4098              : 
    4099              : 
    4100              : /* Return true if T is function-invariant (internal function, does
    4101              :    not handle arithmetic; that's handled in skip_simple_arithmetic and
    4102              :    tree_invariant_p).  */
    4103              : 
    4104              : static bool
    4105     16133156 : tree_invariant_p_1 (tree t)
    4106              : {
    4107     16133156 :   if (TREE_CONSTANT (t) || (TREE_READONLY (t) && !TREE_SIDE_EFFECTS (t)))
    4108              :     return true;
    4109              : 
    4110     13489504 :   switch (TREE_CODE (t))
    4111              :     {
    4112              :     case SAVE_EXPR:
    4113              :     case TARGET_EXPR:
    4114              :       return true;
    4115              : 
    4116        45618 :     case ADDR_EXPR:
    4117        45618 :       return address_invariant_p (TREE_OPERAND (t, 0));
    4118              : 
    4119              :     default:
    4120              :       break;
    4121              :     }
    4122              : 
    4123              :   return false;
    4124              : }
    4125              : 
    4126              : /* Return true if T is function-invariant.  */
    4127              : 
    4128              : bool
    4129     12645469 : tree_invariant_p (tree t)
    4130              : {
    4131     12645469 :   tree inner = skip_simple_arithmetic (t);
    4132     12645469 :   return tree_invariant_p_1 (inner);
    4133              : }
    4134              : 
    4135              : /* Wrap a SAVE_EXPR around EXPR, if appropriate.
    4136              :    Do this to any expression which may be used in more than one place,
    4137              :    but must be evaluated only once.
    4138              : 
    4139              :    Normally, expand_expr would reevaluate the expression each time.
    4140              :    Calling save_expr produces something that is evaluated and recorded
    4141              :    the first time expand_expr is called on it.  Subsequent calls to
    4142              :    expand_expr just reuse the recorded value.
    4143              : 
    4144              :    The call to expand_expr that generates code that actually computes
    4145              :    the value is the first call *at compile time*.  Subsequent calls
    4146              :    *at compile time* generate code to use the saved value.
    4147              :    This produces correct result provided that *at run time* control
    4148              :    always flows through the insns made by the first expand_expr
    4149              :    before reaching the other places where the save_expr was evaluated.
    4150              :    You, the caller of save_expr, must make sure this is so.
    4151              : 
    4152              :    Constants, and certain read-only nodes, are returned with no
    4153              :    SAVE_EXPR because that is safe.  Expressions containing placeholders
    4154              :    are not touched; see tree.def for an explanation of what these
    4155              :    are used for.  */
    4156              : 
    4157              : tree
    4158      3487698 : save_expr (tree expr)
    4159              : {
    4160      3487698 :   tree inner;
    4161              : 
    4162              :   /* If the tree evaluates to a constant, then we don't want to hide that
    4163              :      fact (i.e. this allows further folding, and direct checks for constants).
    4164              :      However, a read-only object that has side effects cannot be bypassed.
    4165              :      Since it is no problem to reevaluate literals, we just return the
    4166              :      literal node.  */
    4167      3487698 :   inner = skip_simple_arithmetic (expr);
    4168      3487698 :   if (TREE_CODE (inner) == ERROR_MARK)
    4169              :     return inner;
    4170              : 
    4171      3487687 :   if (tree_invariant_p_1 (inner))
    4172              :     return expr;
    4173              : 
    4174              :   /* If INNER contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
    4175              :      it means that the size or offset of some field of an object depends on
    4176              :      the value within another field.
    4177              : 
    4178              :      Note that it must not be the case that EXPR contains both a PLACEHOLDER_EXPR
    4179              :      and some variable since it would then need to be both evaluated once and
    4180              :      evaluated more than once.  Front-ends must assure this case cannot
    4181              :      happen by surrounding any such subexpressions in their own SAVE_EXPR
    4182              :      and forcing evaluation at the proper time.  */
    4183      2432201 :   if (contains_placeholder_p (inner))
    4184              :     return expr;
    4185              : 
    4186      2432201 :   expr = build1_loc (EXPR_LOCATION (expr), SAVE_EXPR, TREE_TYPE (expr), expr);
    4187              : 
    4188              :   /* This expression might be placed ahead of a jump to ensure that the
    4189              :      value was computed on both sides of the jump.  So make sure it isn't
    4190              :      eliminated as dead.  */
    4191      2432201 :   TREE_SIDE_EFFECTS (expr) = 1;
    4192      2432201 :   return expr;
    4193              : }
    4194              : 
    4195              : /* Look inside EXPR into any simple arithmetic operations.  Return the
    4196              :    outermost non-arithmetic or non-invariant node.  */
    4197              : 
    4198              : tree
    4199     16133167 : skip_simple_arithmetic (tree expr)
    4200              : {
    4201              :   /* We don't care about whether this can be used as an lvalue in this
    4202              :      context.  */
    4203     16148912 :   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
    4204        15745 :     expr = TREE_OPERAND (expr, 0);
    4205              : 
    4206              :   /* If we have simple operations applied to a SAVE_EXPR or to a SAVE_EXPR and
    4207              :      a constant, it will be more efficient to not make another SAVE_EXPR since
    4208              :      it will allow better simplification and GCSE will be able to merge the
    4209              :      computations if they actually occur.  */
    4210     40594783 :   while (true)
    4211              :     {
    4212     40594783 :       if (UNARY_CLASS_P (expr))
    4213     15295542 :         expr = TREE_OPERAND (expr, 0);
    4214     25299241 :       else if (BINARY_CLASS_P (expr))
    4215              :         {
    4216              :           /* Before commutative binary operands are canonicalized,
    4217              :              it is quite common to have constants in the first operand.
    4218              :              Check for that common case first so that we don't walk
    4219              :              large expressions with tree_invariant_p unnecessarily.
    4220              :              This can still have terrible compile time complexity,
    4221              :              we should limit the depth of the tree_invariant_p and
    4222              :              skip_simple_arithmetic recursion.  */
    4223      9220225 :           if ((TREE_CONSTANT (TREE_OPERAND (expr, 0))
    4224      9209881 :                || (TREE_READONLY (TREE_OPERAND (expr, 0))
    4225        10328 :                    && !TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0))))
    4226      9230517 :               && tree_invariant_p (TREE_OPERAND (expr, 0)))
    4227        20636 :             expr = TREE_OPERAND (expr, 1);
    4228      9199589 :           else if (tree_invariant_p (TREE_OPERAND (expr, 1)))
    4229      9135571 :             expr = TREE_OPERAND (expr, 0);
    4230        64018 :           else if (tree_invariant_p (TREE_OPERAND (expr, 0)))
    4231         9867 :             expr = TREE_OPERAND (expr, 1);
    4232              :           else
    4233              :             break;
    4234              :         }
    4235              :       else
    4236              :         break;
    4237              :     }
    4238              : 
    4239     16133167 :   return expr;
    4240              : }
    4241              : 
    4242              : /* Look inside EXPR into simple arithmetic operations involving constants.
    4243              :    Return the outermost non-arithmetic or non-constant node.  */
    4244              : 
    4245              : tree
    4246            0 : skip_simple_constant_arithmetic (tree expr)
    4247              : {
    4248            0 :   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
    4249            0 :     expr = TREE_OPERAND (expr, 0);
    4250              : 
    4251            0 :   while (true)
    4252              :     {
    4253            0 :       if (UNARY_CLASS_P (expr))
    4254            0 :         expr = TREE_OPERAND (expr, 0);
    4255            0 :       else if (BINARY_CLASS_P (expr))
    4256              :         {
    4257            0 :           if (TREE_CONSTANT (TREE_OPERAND (expr, 1)))
    4258            0 :             expr = TREE_OPERAND (expr, 0);
    4259            0 :           else if (TREE_CONSTANT (TREE_OPERAND (expr, 0)))
    4260            0 :             expr = TREE_OPERAND (expr, 1);
    4261              :           else
    4262              :             break;
    4263              :         }
    4264              :       else
    4265              :         break;
    4266              :     }
    4267              : 
    4268            0 :   return expr;
    4269              : }
    4270              : 
    4271              : /* Return which tree structure is used by T.  */
    4272              : 
    4273              : enum tree_node_structure_enum
    4274  44606043540 : tree_node_structure (const_tree t)
    4275              : {
    4276  44606043540 :   const enum tree_code code = TREE_CODE (t);
    4277  44606043540 :   return tree_node_structure_for_code (code);
    4278              : }
    4279              : 
    4280              : /* Set various status flags when building a CALL_EXPR object T.  */
    4281              : 
    4282              : static void
    4283    295615535 : process_call_operands (tree t)
    4284              : {
    4285    295615535 :   bool side_effects = TREE_SIDE_EFFECTS (t);
    4286    295615535 :   bool read_only = false;
    4287    295615535 :   int i = call_expr_flags (t);
    4288              : 
    4289              :   /* Calls have side-effects, except those to const or pure functions.  */
    4290    295615535 :   if ((i & ECF_LOOPING_CONST_OR_PURE) || !(i & (ECF_CONST | ECF_PURE)))
    4291              :     side_effects = true;
    4292              :   /* Propagate TREE_READONLY of arguments for const functions.  */
    4293     61583410 :   if (i & ECF_CONST)
    4294     59964540 :     read_only = true;
    4295              : 
    4296    295615535 :   if (!side_effects || read_only)
    4297    307703505 :     for (i = 1; i < TREE_OPERAND_LENGTH (t); i++)
    4298              :       {
    4299    246120599 :         tree op = TREE_OPERAND (t, i);
    4300    246120599 :         if (op && TREE_SIDE_EFFECTS (op))
    4301              :           side_effects = true;
    4302    246120599 :         if (op && !TREE_READONLY (op) && !CONSTANT_CLASS_P (op))
    4303              :           read_only = false;
    4304              :       }
    4305              : 
    4306    295615535 :   TREE_SIDE_EFFECTS (t) = side_effects;
    4307    295615535 :   TREE_READONLY (t) = read_only;
    4308    295615535 : }
    4309              : 
    4310              : /* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a
    4311              :    size or offset that depends on a field within a record.  */
    4312              : 
    4313              : bool
    4314     38944220 : contains_placeholder_p (const_tree exp)
    4315              : {
    4316     38944220 :   enum tree_code code;
    4317              : 
    4318     38944220 :   if (!exp)
    4319              :     return false;
    4320              : 
    4321     38944220 :   code = TREE_CODE (exp);
    4322     38944220 :   if (code == PLACEHOLDER_EXPR)
    4323              :     return true;
    4324              : 
    4325     38944220 :   switch (TREE_CODE_CLASS (code))
    4326              :     {
    4327      1181187 :     case tcc_reference:
    4328              :       /* Don't look at any PLACEHOLDER_EXPRs that might be in index or bit
    4329              :          position computations since they will be converted into a
    4330              :          WITH_RECORD_EXPR involving the reference, which will assume
    4331              :          here will be valid.  */
    4332      1181187 :       return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
    4333              : 
    4334       585616 :     case tcc_exceptional:
    4335       585616 :       if (code == TREE_LIST)
    4336            0 :         return (CONTAINS_PLACEHOLDER_P (TREE_VALUE (exp))
    4337            0 :                 || CONTAINS_PLACEHOLDER_P (TREE_CHAIN (exp)));
    4338              :       break;
    4339              : 
    4340     33776423 :     case tcc_unary:
    4341     33776423 :     case tcc_binary:
    4342     33776423 :     case tcc_comparison:
    4343     33776423 :     case tcc_expression:
    4344     33776423 :       switch (code)
    4345              :         {
    4346         7298 :         case COMPOUND_EXPR:
    4347              :           /* Ignoring the first operand isn't quite right, but works best.  */
    4348         7298 :           return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1));
    4349              : 
    4350         4660 :         case COND_EXPR:
    4351         9320 :           return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
    4352         4660 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1))
    4353         9320 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 2)));
    4354              : 
    4355              :         case SAVE_EXPR:
    4356              :           /* The save_expr function never wraps anything containing
    4357              :              a PLACEHOLDER_EXPR. */
    4358              :           return false;
    4359              : 
    4360     24590649 :         default:
    4361     24590649 :           break;
    4362              :         }
    4363              : 
    4364     24590649 :       switch (TREE_CODE_LENGTH (code))
    4365              :         {
    4366     14982762 :         case 1:
    4367     14982762 :           return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
    4368      9509956 :         case 2:
    4369     19018370 :           return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
    4370     19018370 :                   || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1)));
    4371              :         default:
    4372              :           return false;
    4373              :         }
    4374              : 
    4375       817677 :     case tcc_vl_exp:
    4376       817677 :       switch (code)
    4377              :         {
    4378       817677 :         case CALL_EXPR:
    4379       817677 :           {
    4380       817677 :             const_tree arg;
    4381       817677 :             const_call_expr_arg_iterator iter;
    4382      2845601 :             FOR_EACH_CONST_CALL_EXPR_ARG (arg, iter, exp)
    4383      1210247 :               if (CONTAINS_PLACEHOLDER_P (arg))
    4384              :                 return true;
    4385              :             return false;
    4386              :           }
    4387              :         default:
    4388              :           return false;
    4389              :         }
    4390              : 
    4391              :     default:
    4392              :       return false;
    4393              :     }
    4394              :   return false;
    4395              : }
    4396              : 
    4397              : /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR
    4398              :    directly.  This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and
    4399              :    field positions.  */
    4400              : 
    4401              : static bool
    4402       813002 : type_contains_placeholder_1 (const_tree type)
    4403              : {
    4404              :   /* If the size contains a placeholder or the parent type (component type in
    4405              :      the case of arrays) type involves a placeholder, this type does.  */
    4406      1604650 :   if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type))
    4407       813002 :       || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type))
    4408      1626004 :       || (!POINTER_TYPE_P (type)
    4409       673811 :           && TREE_TYPE (type)
    4410       117372 :           && type_contains_placeholder_p (TREE_TYPE (type))))
    4411              :     return true;
    4412              : 
    4413              :   /* Now do type-specific checks.  Note that the last part of the check above
    4414              :      greatly limits what we have to do below.  */
    4415       813002 :   switch (TREE_CODE (type))
    4416              :     {
    4417              :     case VOID_TYPE:
    4418              :     case OPAQUE_TYPE:
    4419              :     case COMPLEX_TYPE:
    4420              :     case ENUMERAL_TYPE:
    4421              :     case BOOLEAN_TYPE:
    4422              :     case POINTER_TYPE:
    4423              :     case OFFSET_TYPE:
    4424              :     case REFERENCE_TYPE:
    4425              :     case METHOD_TYPE:
    4426              :     case FUNCTION_TYPE:
    4427              :     case VECTOR_TYPE:
    4428              :     case NULLPTR_TYPE:
    4429              :       return false;
    4430              : 
    4431       183047 :     case INTEGER_TYPE:
    4432       183047 :     case BITINT_TYPE:
    4433       183047 :     case REAL_TYPE:
    4434       183047 :     case FIXED_POINT_TYPE:
    4435              :       /* Here we just check the bounds.  */
    4436       356263 :       return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type))
    4437       356263 :               || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type)));
    4438              : 
    4439        58459 :     case ARRAY_TYPE:
    4440              :       /* We have already checked the component type above, so just check
    4441              :          the domain type.  Flexible array members have a null domain.  */
    4442       116906 :       return TYPE_DOMAIN (type) ?
    4443        58447 :         type_contains_placeholder_p (TYPE_DOMAIN (type)) : false;
    4444              : 
    4445       407749 :     case RECORD_TYPE:
    4446       407749 :     case UNION_TYPE:
    4447       407749 :     case QUAL_UNION_TYPE:
    4448       407749 :       {
    4449       407749 :         tree field;
    4450              : 
    4451     11963973 :         for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    4452     11556224 :           if (TREE_CODE (field) == FIELD_DECL
    4453     11556224 :               && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field))
    4454       949969 :                   || (TREE_CODE (type) == QUAL_UNION_TYPE
    4455            0 :                       && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field)))
    4456       949969 :                   || type_contains_placeholder_p (TREE_TYPE (field))))
    4457              :             return true;
    4458              : 
    4459              :         return false;
    4460              :       }
    4461              : 
    4462            0 :     default:
    4463            0 :       gcc_unreachable ();
    4464              :     }
    4465              : }
    4466              : 
    4467              : /* Wrapper around above function used to cache its result.  */
    4468              : 
    4469              : bool
    4470      3006647 : type_contains_placeholder_p (tree type)
    4471              : {
    4472      3006647 :   bool result;
    4473              : 
    4474              :   /* If the contains_placeholder_bits field has been initialized,
    4475              :      then we know the answer.  */
    4476      3006647 :   if (TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) > 0)
    4477      2193645 :     return TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) - 1;
    4478              : 
    4479              :   /* Indicate that we've seen this type node, and the answer is false.
    4480              :      This is what we want to return if we run into recursion via fields.  */
    4481       813002 :   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = 1;
    4482              : 
    4483              :   /* Compute the real value.  */
    4484       813002 :   result = type_contains_placeholder_1 (type);
    4485              : 
    4486              :   /* Store the real value.  */
    4487       813002 :   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = result + 1;
    4488              : 
    4489       813002 :   return result;
    4490              : }
    4491              : 
    4492              : /* Push tree EXP onto vector QUEUE if it is not already present.  */
    4493              : 
    4494              : static void
    4495            0 : push_without_duplicates (tree exp, vec<tree> *queue)
    4496              : {
    4497            0 :   unsigned int i;
    4498            0 :   tree iter;
    4499              : 
    4500            0 :   FOR_EACH_VEC_ELT (*queue, i, iter)
    4501            0 :     if (simple_cst_equal (iter, exp) == 1)
    4502              :       break;
    4503              : 
    4504            0 :   if (!iter)
    4505            0 :     queue->safe_push (exp);
    4506            0 : }
    4507              : 
    4508              : /* Given a tree EXP, find all occurrences of references to fields
    4509              :    in a PLACEHOLDER_EXPR and place them in vector REFS without
    4510              :    duplicates.  Also record VAR_DECLs and CONST_DECLs.  Note that
    4511              :    we assume here that EXP contains only arithmetic expressions
    4512              :    or CALL_EXPRs with PLACEHOLDER_EXPRs occurring only in their
    4513              :    argument list.  */
    4514              : 
    4515              : void
    4516            0 : find_placeholder_in_expr (tree exp, vec<tree> *refs)
    4517              : {
    4518            0 :   enum tree_code code = TREE_CODE (exp);
    4519            0 :   tree inner;
    4520            0 :   int i;
    4521              : 
    4522              :   /* We handle TREE_LIST and COMPONENT_REF separately.  */
    4523            0 :   if (code == TREE_LIST)
    4524              :     {
    4525            0 :       FIND_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), refs);
    4526            0 :       FIND_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), refs);
    4527              :     }
    4528            0 :   else if (code == COMPONENT_REF)
    4529              :     {
    4530            0 :       for (inner = TREE_OPERAND (exp, 0);
    4531            0 :            REFERENCE_CLASS_P (inner);
    4532            0 :            inner = TREE_OPERAND (inner, 0))
    4533              :         ;
    4534              : 
    4535            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR)
    4536            0 :         push_without_duplicates (exp, refs);
    4537              :       else
    4538            0 :         FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), refs);
    4539              :    }
    4540              :   else
    4541            0 :     switch (TREE_CODE_CLASS (code))
    4542              :       {
    4543              :       case tcc_constant:
    4544              :         break;
    4545              : 
    4546            0 :       case tcc_declaration:
    4547              :         /* Variables allocated to static storage can stay.  */
    4548            0 :         if (!TREE_STATIC (exp))
    4549            0 :           push_without_duplicates (exp, refs);
    4550              :         break;
    4551              : 
    4552            0 :       case tcc_expression:
    4553              :         /* This is the pattern built in ada/make_aligning_type.  */
    4554            0 :         if (code == ADDR_EXPR
    4555            0 :             && TREE_CODE (TREE_OPERAND (exp, 0)) == PLACEHOLDER_EXPR)
    4556              :           {
    4557            0 :             push_without_duplicates (exp, refs);
    4558            0 :             break;
    4559              :           }
    4560              : 
    4561              :         /* Fall through.  */
    4562              : 
    4563              :       case tcc_exceptional:
    4564              :       case tcc_unary:
    4565              :       case tcc_binary:
    4566              :       case tcc_comparison:
    4567              :       case tcc_reference:
    4568            0 :         for (i = 0; i < TREE_CODE_LENGTH (code); i++)
    4569            0 :           FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, i), refs);
    4570              :         break;
    4571              : 
    4572              :       case tcc_vl_exp:
    4573            0 :         for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4574            0 :           FIND_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, i), refs);
    4575              :         break;
    4576              : 
    4577            0 :       default:
    4578            0 :         gcc_unreachable ();
    4579              :       }
    4580            0 : }
    4581              : 
    4582              : /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
    4583              :    return a tree with all occurrences of references to F in a
    4584              :    PLACEHOLDER_EXPR replaced by R.  Also handle VAR_DECLs and
    4585              :    CONST_DECLs.  Note that we assume here that EXP contains only
    4586              :    arithmetic expressions or CALL_EXPRs with PLACEHOLDER_EXPRs
    4587              :    occurring only in their argument list.  */
    4588              : 
    4589              : tree
    4590            0 : substitute_in_expr (tree exp, tree f, tree r)
    4591              : {
    4592            0 :   enum tree_code code = TREE_CODE (exp);
    4593            0 :   tree op0, op1, op2, op3;
    4594            0 :   tree new_tree;
    4595              : 
    4596              :   /* We handle TREE_LIST and COMPONENT_REF separately.  */
    4597            0 :   if (code == TREE_LIST)
    4598              :     {
    4599            0 :       op0 = SUBSTITUTE_IN_EXPR (TREE_CHAIN (exp), f, r);
    4600            0 :       op1 = SUBSTITUTE_IN_EXPR (TREE_VALUE (exp), f, r);
    4601            0 :       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
    4602              :         return exp;
    4603              : 
    4604            0 :       return tree_cons (TREE_PURPOSE (exp), op1, op0);
    4605              :     }
    4606            0 :   else if (code == COMPONENT_REF)
    4607              :     {
    4608            0 :       tree inner;
    4609              : 
    4610              :       /* If this expression is getting a value from a PLACEHOLDER_EXPR
    4611              :          and it is the right field, replace it with R.  */
    4612            0 :       for (inner = TREE_OPERAND (exp, 0);
    4613            0 :            REFERENCE_CLASS_P (inner);
    4614            0 :            inner = TREE_OPERAND (inner, 0))
    4615              :         ;
    4616              : 
    4617              :       /* The field.  */
    4618            0 :       op1 = TREE_OPERAND (exp, 1);
    4619              : 
    4620            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR && op1 == f)
    4621              :         return r;
    4622              : 
    4623              :       /* If this expression hasn't been completed let, leave it alone.  */
    4624            0 :       if (TREE_CODE (inner) == PLACEHOLDER_EXPR && !TREE_TYPE (inner))
    4625              :         return exp;
    4626              : 
    4627            0 :       op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4628            0 :       if (op0 == TREE_OPERAND (exp, 0))
    4629              :         return exp;
    4630              : 
    4631            0 :       new_tree
    4632            0 :         = fold_build3 (COMPONENT_REF, TREE_TYPE (exp), op0, op1, NULL_TREE);
    4633              :    }
    4634              :   else
    4635            0 :     switch (TREE_CODE_CLASS (code))
    4636              :       {
    4637              :       case tcc_constant:
    4638              :         return exp;
    4639              : 
    4640            0 :       case tcc_declaration:
    4641            0 :         if (exp == f)
    4642              :           return r;
    4643              :         else
    4644            0 :           return exp;
    4645              : 
    4646            0 :       case tcc_expression:
    4647            0 :         if (exp == f)
    4648              :           return r;
    4649              : 
    4650              :         /* Fall through.  */
    4651              : 
    4652            0 :       case tcc_exceptional:
    4653            0 :       case tcc_unary:
    4654            0 :       case tcc_binary:
    4655            0 :       case tcc_comparison:
    4656            0 :       case tcc_reference:
    4657            0 :         switch (TREE_CODE_LENGTH (code))
    4658              :           {
    4659              :           case 0:
    4660              :             return exp;
    4661              : 
    4662            0 :           case 1:
    4663            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4664            0 :             if (op0 == TREE_OPERAND (exp, 0))
    4665              :               return exp;
    4666              : 
    4667            0 :             new_tree = fold_build1 (code, TREE_TYPE (exp), op0);
    4668            0 :             break;
    4669              : 
    4670            0 :           case 2:
    4671            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4672            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4673              : 
    4674            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
    4675              :               return exp;
    4676              : 
    4677            0 :             new_tree = fold_build2 (code, TREE_TYPE (exp), op0, op1);
    4678            0 :             break;
    4679              : 
    4680            0 :           case 3:
    4681            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4682            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4683            0 :             op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
    4684              : 
    4685            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4686            0 :                 && op2 == TREE_OPERAND (exp, 2))
    4687              :               return exp;
    4688              : 
    4689            0 :             new_tree = fold_build3 (code, TREE_TYPE (exp), op0, op1, op2);
    4690            0 :             break;
    4691              : 
    4692            0 :           case 4:
    4693            0 :             op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
    4694            0 :             op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
    4695            0 :             op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
    4696            0 :             op3 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 3), f, r);
    4697              : 
    4698            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4699            0 :                 && op2 == TREE_OPERAND (exp, 2)
    4700            0 :                 && op3 == TREE_OPERAND (exp, 3))
    4701              :               return exp;
    4702              : 
    4703            0 :             new_tree
    4704            0 :               = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
    4705            0 :             break;
    4706              : 
    4707            0 :           default:
    4708            0 :             gcc_unreachable ();
    4709              :           }
    4710              :         break;
    4711              : 
    4712            0 :       case tcc_vl_exp:
    4713            0 :         {
    4714            0 :           int i;
    4715              : 
    4716            0 :           new_tree = NULL_TREE;
    4717              : 
    4718              :           /* If we are trying to replace F with a constant or with another
    4719              :              instance of one of the arguments of the call, inline back
    4720              :              functions which do nothing else than computing a value from
    4721              :              the arguments they are passed.  This makes it possible to
    4722              :              fold partially or entirely the replacement expression.  */
    4723            0 :           if (code == CALL_EXPR)
    4724              :             {
    4725            0 :               bool maybe_inline = false;
    4726            0 :               if (CONSTANT_CLASS_P (r))
    4727              :                 maybe_inline = true;
    4728              :               else
    4729            0 :                 for (i = 3; i < TREE_OPERAND_LENGTH (exp); i++)
    4730            0 :                   if (operand_equal_p (TREE_OPERAND (exp, i), r, 0))
    4731              :                     {
    4732              :                       maybe_inline = true;
    4733              :                       break;
    4734              :                     }
    4735            0 :               if (maybe_inline)
    4736              :                 {
    4737            0 :                   tree t = maybe_inline_call_in_expr (exp);
    4738            0 :                   if (t)
    4739            0 :                     return SUBSTITUTE_IN_EXPR (t, f, r);
    4740              :                 }
    4741              :             }
    4742              : 
    4743            0 :           for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4744              :             {
    4745            0 :               tree op = TREE_OPERAND (exp, i);
    4746            0 :               tree new_op = SUBSTITUTE_IN_EXPR (op, f, r);
    4747            0 :               if (new_op != op)
    4748              :                 {
    4749            0 :                   if (!new_tree)
    4750            0 :                     new_tree = copy_node (exp);
    4751            0 :                   TREE_OPERAND (new_tree, i) = new_op;
    4752              :                 }
    4753              :             }
    4754              : 
    4755            0 :           if (new_tree)
    4756              :             {
    4757            0 :               new_tree = fold (new_tree);
    4758            0 :               if (TREE_CODE (new_tree) == CALL_EXPR)
    4759            0 :                 process_call_operands (new_tree);
    4760              :             }
    4761              :           else
    4762              :             return exp;
    4763              :         }
    4764              :         break;
    4765              : 
    4766            0 :       default:
    4767            0 :         gcc_unreachable ();
    4768              :       }
    4769              : 
    4770            0 :   TREE_READONLY (new_tree) |= TREE_READONLY (exp);
    4771              : 
    4772            0 :   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
    4773            0 :     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
    4774              : 
    4775              :   return new_tree;
    4776              : }
    4777              : 
    4778              : /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement
    4779              :    for it within OBJ, a tree that is an object or a chain of references.  */
    4780              : 
    4781              : tree
    4782       248080 : substitute_placeholder_in_expr (tree exp, tree obj)
    4783              : {
    4784       248080 :   enum tree_code code = TREE_CODE (exp);
    4785       248080 :   tree op0, op1, op2, op3;
    4786       248080 :   tree new_tree;
    4787              : 
    4788              :   /* If this is a PLACEHOLDER_EXPR, see if we find a corresponding type
    4789              :      in the chain of OBJ.  */
    4790       248080 :   if (code == PLACEHOLDER_EXPR)
    4791              :     {
    4792            0 :       tree need_type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
    4793            0 :       tree elt;
    4794              : 
    4795            0 :       for (elt = obj; elt != 0;
    4796            0 :            elt = ((TREE_CODE (elt) == COMPOUND_EXPR
    4797            0 :                    || TREE_CODE (elt) == COND_EXPR)
    4798            0 :                   ? TREE_OPERAND (elt, 1)
    4799            0 :                   : (REFERENCE_CLASS_P (elt)
    4800              :                      || UNARY_CLASS_P (elt)
    4801              :                      || BINARY_CLASS_P (elt)
    4802              :                      || VL_EXP_CLASS_P (elt)
    4803              :                      || EXPRESSION_CLASS_P (elt))
    4804            0 :                   ? TREE_OPERAND (elt, 0) : 0))
    4805            0 :         if (TYPE_MAIN_VARIANT (TREE_TYPE (elt)) == need_type)
    4806              :           return elt;
    4807              : 
    4808            0 :       for (elt = obj; elt != 0;
    4809            0 :            elt = ((TREE_CODE (elt) == COMPOUND_EXPR
    4810            0 :                    || TREE_CODE (elt) == COND_EXPR)
    4811            0 :                   ? TREE_OPERAND (elt, 1)
    4812            0 :                   : (REFERENCE_CLASS_P (elt)
    4813              :                      || UNARY_CLASS_P (elt)
    4814              :                      || BINARY_CLASS_P (elt)
    4815              :                      || VL_EXP_CLASS_P (elt)
    4816              :                      || EXPRESSION_CLASS_P (elt))
    4817            0 :                   ? TREE_OPERAND (elt, 0) : 0))
    4818            0 :         if (POINTER_TYPE_P (TREE_TYPE (elt))
    4819            0 :             && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (elt)))
    4820              :                 == need_type))
    4821            0 :           return fold_build1 (INDIRECT_REF, need_type, elt);
    4822              : 
    4823              :       /* If we didn't find it, return the original PLACEHOLDER_EXPR.  If it
    4824              :          survives until RTL generation, there will be an error.  */
    4825              :       return exp;
    4826              :     }
    4827              : 
    4828              :   /* TREE_LIST is special because we need to look at TREE_VALUE
    4829              :      and TREE_CHAIN, not TREE_OPERANDS.  */
    4830       248080 :   else if (code == TREE_LIST)
    4831              :     {
    4832            0 :       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), obj);
    4833            0 :       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), obj);
    4834            0 :       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
    4835              :         return exp;
    4836              : 
    4837            0 :       return tree_cons (TREE_PURPOSE (exp), op1, op0);
    4838              :     }
    4839              :   else
    4840       248080 :     switch (TREE_CODE_CLASS (code))
    4841              :       {
    4842              :       case tcc_constant:
    4843              :       case tcc_declaration:
    4844              :         return exp;
    4845              : 
    4846        10171 :       case tcc_exceptional:
    4847        10171 :       case tcc_unary:
    4848        10171 :       case tcc_binary:
    4849        10171 :       case tcc_comparison:
    4850        10171 :       case tcc_expression:
    4851        10171 :       case tcc_reference:
    4852        10171 :       case tcc_statement:
    4853        10171 :         switch (TREE_CODE_LENGTH (code))
    4854              :           {
    4855              :           case 0:
    4856              :             return exp;
    4857              : 
    4858         7776 :           case 1:
    4859         7776 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4860         7776 :             if (op0 == TREE_OPERAND (exp, 0))
    4861              :               return exp;
    4862              : 
    4863            0 :             new_tree = fold_build1 (code, TREE_TYPE (exp), op0);
    4864            0 :             break;
    4865              : 
    4866         2383 :           case 2:
    4867         2383 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4868         2383 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4869              : 
    4870         2383 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
    4871              :               return exp;
    4872              : 
    4873            0 :             new_tree = fold_build2 (code, TREE_TYPE (exp), op0, op1);
    4874            0 :             break;
    4875              : 
    4876           12 :           case 3:
    4877           12 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4878           12 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4879           12 :             op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
    4880              : 
    4881           24 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4882           24 :                 && op2 == TREE_OPERAND (exp, 2))
    4883              :               return exp;
    4884              : 
    4885            0 :             new_tree = fold_build3 (code, TREE_TYPE (exp), op0, op1, op2);
    4886            0 :             break;
    4887              : 
    4888            0 :           case 4:
    4889            0 :             op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
    4890            0 :             op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
    4891            0 :             op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
    4892            0 :             op3 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 3), obj);
    4893              : 
    4894            0 :             if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
    4895            0 :                 && op2 == TREE_OPERAND (exp, 2)
    4896            0 :                 && op3 == TREE_OPERAND (exp, 3))
    4897              :               return exp;
    4898              : 
    4899            0 :             new_tree
    4900            0 :               = fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
    4901            0 :             break;
    4902              : 
    4903            0 :           default:
    4904            0 :             gcc_unreachable ();
    4905              :           }
    4906              :         break;
    4907              : 
    4908              :       case tcc_vl_exp:
    4909              :         {
    4910              :           int i;
    4911              : 
    4912              :           new_tree = NULL_TREE;
    4913              : 
    4914            0 :           for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)
    4915              :             {
    4916            0 :               tree op = TREE_OPERAND (exp, i);
    4917            0 :               tree new_op = SUBSTITUTE_PLACEHOLDER_IN_EXPR (op, obj);
    4918            0 :               if (new_op != op)
    4919              :                 {
    4920            0 :                   if (!new_tree)
    4921            0 :                     new_tree = copy_node (exp);
    4922            0 :                   TREE_OPERAND (new_tree, i) = new_op;
    4923              :                 }
    4924              :             }
    4925              : 
    4926            0 :           if (new_tree)
    4927              :             {
    4928            0 :               new_tree = fold (new_tree);
    4929            0 :               if (TREE_CODE (new_tree) == CALL_EXPR)
    4930            0 :                 process_call_operands (new_tree);
    4931              :             }
    4932              :           else
    4933              :             return exp;
    4934              :         }
    4935              :         break;
    4936              : 
    4937            0 :       default:
    4938            0 :         gcc_unreachable ();
    4939              :       }
    4940              : 
    4941            0 :   TREE_READONLY (new_tree) |= TREE_READONLY (exp);
    4942              : 
    4943            0 :   if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF)
    4944            0 :     TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp);
    4945              : 
    4946              :   return new_tree;
    4947              : }
    4948              : 
    4949              : 
    4950              : /* Subroutine of stabilize_reference; this is called for subtrees of
    4951              :    references.  Any expression with side-effects must be put in a SAVE_EXPR
    4952              :    to ensure that it is only evaluated once.
    4953              : 
    4954              :    We don't put SAVE_EXPR nodes around everything, because assigning very
    4955              :    simple expressions to temporaries causes us to miss good opportunities
    4956              :    for optimizations.  Among other things, the opportunity to fold in the
    4957              :    addition of a constant into an addressing mode often gets lost, e.g.
    4958              :    "y[i+1] += x;".  In general, we take the approach that we should not make
    4959              :    an assignment unless we are forced into it - i.e., that any non-side effect
    4960              :    operator should be allowed, and that cse should take care of coalescing
    4961              :    multiple utterances of the same expression should that prove fruitful.  */
    4962              : 
    4963              : static tree
    4964       910827 : stabilize_reference_1 (tree e)
    4965              : {
    4966       910827 :   tree result;
    4967       910827 :   enum tree_code code = TREE_CODE (e);
    4968              : 
    4969              :   /* We cannot ignore const expressions because it might be a reference
    4970              :      to a const array but whose index contains side-effects.  But we can
    4971              :      ignore things that are actual constant or that already have been
    4972              :      handled by this function.  */
    4973              : 
    4974       910827 :   if (tree_invariant_p (e))
    4975              :     return e;
    4976              : 
    4977       134886 :   switch (TREE_CODE_CLASS (code))
    4978              :     {
    4979            0 :     case tcc_exceptional:
    4980              :       /* Always wrap STATEMENT_LIST into SAVE_EXPR, even if it doesn't
    4981              :          have side-effects.  */
    4982            0 :       if (code == STATEMENT_LIST)
    4983            0 :         return save_expr (e);
    4984              :       /* FALLTHRU */
    4985       105118 :     case tcc_type:
    4986       105118 :     case tcc_declaration:
    4987       105118 :     case tcc_comparison:
    4988       105118 :     case tcc_statement:
    4989       105118 :     case tcc_expression:
    4990       105118 :     case tcc_reference:
    4991       105118 :     case tcc_vl_exp:
    4992              :       /* If the expression has side-effects, then encase it in a SAVE_EXPR
    4993              :          so that it will only be evaluated once.  */
    4994              :       /* The reference (r) and comparison (<) classes could be handled as
    4995              :          below, but it is generally faster to only evaluate them once.  */
    4996       105118 :       if (TREE_SIDE_EFFECTS (e))
    4997          998 :         return save_expr (e);
    4998              :       return e;
    4999              : 
    5000              :     case tcc_constant:
    5001              :       /* Constants need no processing.  In fact, we should never reach
    5002              :          here.  */
    5003              :       return e;
    5004              : 
    5005        22007 :     case tcc_binary:
    5006              :       /* Division is slow and tends to be compiled with jumps,
    5007              :          especially the division by powers of 2 that is often
    5008              :          found inside of an array reference.  So do it just once.  */
    5009        22007 :       if (code == TRUNC_DIV_EXPR || code == TRUNC_MOD_EXPR
    5010        19967 :           || code == FLOOR_DIV_EXPR || code == FLOOR_MOD_EXPR
    5011        19967 :           || code == CEIL_DIV_EXPR || code == CEIL_MOD_EXPR
    5012        19967 :           || code == ROUND_DIV_EXPR || code == ROUND_MOD_EXPR)
    5013         2040 :         return save_expr (e);
    5014              :       /* Recursively stabilize each operand.  */
    5015        19967 :       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)),
    5016        19967 :                          stabilize_reference_1 (TREE_OPERAND (e, 1)));
    5017        19967 :       break;
    5018              : 
    5019         7761 :     case tcc_unary:
    5020              :       /* Recursively stabilize each operand.  */
    5021         7761 :       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)));
    5022         7761 :       break;
    5023              : 
    5024            0 :     default:
    5025            0 :       gcc_unreachable ();
    5026              :     }
    5027              : 
    5028        27728 :   TREE_TYPE (result) = TREE_TYPE (e);
    5029        27728 :   TREE_READONLY (result) = TREE_READONLY (e);
    5030        27728 :   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
    5031        27728 :   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
    5032              : 
    5033        27728 :   return result;
    5034              : }
    5035              : 
    5036              : /* Stabilize a reference so that we can use it any number of times
    5037              :    without causing its operands to be evaluated more than once.
    5038              :    Returns the stabilized reference.  This works by means of save_expr,
    5039              :    so see the caveats in the comments about save_expr.
    5040              : 
    5041              :    Also allows conversion expressions whose operands are references.
    5042              :    Any other kind of expression is returned unchanged.  */
    5043              : 
    5044              : tree
    5045      4927894 : stabilize_reference (tree ref)
    5046              : {
    5047      4927894 :   tree result;
    5048      4927894 :   enum tree_code code = TREE_CODE (ref);
    5049              : 
    5050      4927894 :   switch (code)
    5051              :     {
    5052              :     case VAR_DECL:
    5053              :     case PARM_DECL:
    5054              :     case RESULT_DECL:
    5055              :       /* No action is needed in this case.  */
    5056              :       return ref;
    5057              : 
    5058            0 :     CASE_CONVERT:
    5059            0 :     case FLOAT_EXPR:
    5060            0 :     case FIX_TRUNC_EXPR:
    5061            0 :       result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
    5062            0 :       break;
    5063              : 
    5064       816107 :     case INDIRECT_REF:
    5065       816107 :       result = build_nt (INDIRECT_REF,
    5066       816107 :                          stabilize_reference_1 (TREE_OPERAND (ref, 0)));
    5067       816107 :       break;
    5068              : 
    5069       472666 :     case COMPONENT_REF:
    5070       472666 :       result = build_nt (COMPONENT_REF,
    5071       472666 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5072       472666 :                          TREE_OPERAND (ref, 1), NULL_TREE);
    5073       472666 :       break;
    5074              : 
    5075            0 :     case BIT_FIELD_REF:
    5076            0 :       result = build_nt (BIT_FIELD_REF,
    5077            0 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5078            0 :                          TREE_OPERAND (ref, 1), TREE_OPERAND (ref, 2));
    5079            0 :       REF_REVERSE_STORAGE_ORDER (result) = REF_REVERSE_STORAGE_ORDER (ref);
    5080            0 :       break;
    5081              : 
    5082        47025 :     case ARRAY_REF:
    5083        94050 :       result = build_nt (ARRAY_REF,
    5084        47025 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5085        47025 :                          stabilize_reference_1 (TREE_OPERAND (ref, 1)),
    5086        47025 :                          TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
    5087        47025 :       break;
    5088              : 
    5089            0 :     case ARRAY_RANGE_REF:
    5090            0 :       result = build_nt (ARRAY_RANGE_REF,
    5091            0 :                          stabilize_reference (TREE_OPERAND (ref, 0)),
    5092            0 :                          stabilize_reference_1 (TREE_OPERAND (ref, 1)),
    5093            0 :                          TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
    5094            0 :       break;
    5095              : 
    5096            0 :     case COMPOUND_EXPR:
    5097              :       /* We cannot wrap the first expression in a SAVE_EXPR, as then
    5098              :          it wouldn't be ignored.  This matters when dealing with
    5099              :          volatiles.  */
    5100            0 :       return stabilize_reference_1 (ref);
    5101              : 
    5102              :       /* If arg isn't a kind of lvalue we recognize, make no change.
    5103              :          Caller should recognize the error for an invalid lvalue.  */
    5104              :     default:
    5105              :       return ref;
    5106              : 
    5107            0 :     case ERROR_MARK:
    5108            0 :       return error_mark_node;
    5109              :     }
    5110              : 
    5111      1335798 :   TREE_TYPE (result) = TREE_TYPE (ref);
    5112      1335798 :   TREE_READONLY (result) = TREE_READONLY (ref);
    5113      1335798 :   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
    5114      1335798 :   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
    5115      1335798 :   protected_set_expr_location (result, EXPR_LOCATION (ref));
    5116              : 
    5117      1335798 :   return result;
    5118              : }
    5119              : 
    5120              : /* Low-level constructors for expressions.  */
    5121              : 
    5122              : /* A helper function for build1 and constant folders.  Set TREE_CONSTANT,
    5123              :    and TREE_SIDE_EFFECTS for an ADDR_EXPR.  */
    5124              : 
    5125              : void
    5126   1451047330 : recompute_tree_invariant_for_addr_expr (tree t)
    5127              : {
    5128   1451047330 :   tree node;
    5129   1451047330 :   bool tc = true, se = false;
    5130              : 
    5131   1451047330 :   gcc_assert (TREE_CODE (t) == ADDR_EXPR);
    5132              : 
    5133              :   /* We started out assuming this address is both invariant and constant, but
    5134              :      does not have side effects.  Now go down any handled components and see if
    5135              :      any of them involve offsets that are either non-constant or non-invariant.
    5136              :      Also check for side-effects.
    5137              : 
    5138              :      ??? Note that this code makes no attempt to deal with the case where
    5139              :      taking the address of something causes a copy due to misalignment.  */
    5140              : 
    5141              : #define UPDATE_FLAGS(NODE)  \
    5142              : do { tree _node = (NODE); \
    5143              :      if (_node && !TREE_CONSTANT (_node)) tc = false; \
    5144              :      if (_node && TREE_SIDE_EFFECTS (_node)) se = true; } while (0)
    5145              : 
    5146   1701163996 :   for (node = TREE_OPERAND (t, 0); handled_component_p (node);
    5147    250116666 :        node = TREE_OPERAND (node, 0))
    5148              :     {
    5149              :       /* If the first operand doesn't have an ARRAY_TYPE, this is a bogus
    5150              :          array reference (probably made temporarily by the G++ front end),
    5151              :          so ignore all the operands.  */
    5152    250116666 :       if ((TREE_CODE (node) == ARRAY_REF
    5153    250116666 :            || TREE_CODE (node) == ARRAY_RANGE_REF)
    5154    250116666 :           && TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) == ARRAY_TYPE)
    5155              :         {
    5156     34572058 :           UPDATE_FLAGS (TREE_OPERAND (node, 1));
    5157     34572058 :           if (TREE_OPERAND (node, 2))
    5158      2247581 :             UPDATE_FLAGS (TREE_OPERAND (node, 2));
    5159     34572058 :           if (TREE_OPERAND (node, 3))
    5160       303045 :             UPDATE_FLAGS (TREE_OPERAND (node, 3));
    5161              :         }
    5162              :       /* Likewise, just because this is a COMPONENT_REF doesn't mean we have a
    5163              :          FIELD_DECL, apparently.  The G++ front end can put something else
    5164              :          there, at least temporarily.  */
    5165    215544608 :       else if (TREE_CODE (node) == COMPONENT_REF
    5166    215544608 :                && TREE_CODE (TREE_OPERAND (node, 1)) == FIELD_DECL)
    5167              :         {
    5168    214315328 :           if (TREE_OPERAND (node, 2))
    5169        17038 :             UPDATE_FLAGS (TREE_OPERAND (node, 2));
    5170              :         }
    5171              :     }
    5172              : 
    5173   1451047330 :   node = lang_hooks.expr_to_decl (node, &tc, &se);
    5174              : 
    5175              :   /* Now see what's inside.  If it's an INDIRECT_REF, copy our properties from
    5176              :      the address, since &(*a)->b is a form of addition.  If it's a constant, the
    5177              :      address is constant too.  If it's a decl, its address is constant if the
    5178              :      decl is static.  Everything else is not constant and, furthermore,
    5179              :      taking the address of a volatile variable is not volatile.  */
    5180   1451047330 :   if (INDIRECT_REF_P (node)
    5181   1411347338 :       || TREE_CODE (node) == MEM_REF)
    5182    165846437 :     UPDATE_FLAGS (TREE_OPERAND (node, 0));
    5183   1285200893 :   else if (CONSTANT_CLASS_P (node))
    5184              :     ;
    5185   1203384459 :   else if (DECL_P (node))
    5186   1178612250 :     tc &= (staticp (node) != NULL_TREE);
    5187              :   else
    5188              :     {
    5189     24772209 :       tc = false;
    5190     24772209 :       se |= TREE_SIDE_EFFECTS (node);
    5191              :     }
    5192              : 
    5193              : 
    5194   1451047330 :   TREE_CONSTANT (t) = tc;
    5195   1451047330 :   TREE_SIDE_EFFECTS (t) = se;
    5196              : #undef UPDATE_FLAGS
    5197   1451047330 : }
    5198              : 
    5199              : /* Build an expression of code CODE, data type TYPE, and operands as
    5200              :    specified.  Expressions and reference nodes can be created this way.
    5201              :    Constants, decls, types and misc nodes cannot be.
    5202              : 
    5203              :    We define 5 non-variadic functions, from 0 to 4 arguments.  This is
    5204              :    enough for all extant tree codes.  */
    5205              : 
    5206              : tree
    5207    403866867 : build0 (enum tree_code code, tree tt MEM_STAT_DECL)
    5208              : {
    5209    403866867 :   tree t;
    5210              : 
    5211    403866867 :   gcc_assert (TREE_CODE_LENGTH (code) == 0);
    5212              : 
    5213    403866867 :   t = make_node (code PASS_MEM_STAT);
    5214    403866867 :   TREE_TYPE (t) = tt;
    5215              : 
    5216    403866867 :   return t;
    5217              : }
    5218              : 
    5219              : tree
    5220   4158117484 : build1 (enum tree_code code, tree type, tree node MEM_STAT_DECL)
    5221              : {
    5222   4158117484 :   int length = sizeof (struct tree_exp);
    5223   4158117484 :   tree t;
    5224              : 
    5225   4158117484 :   record_node_allocation_statistics (code, length);
    5226              : 
    5227   4158117484 :   gcc_assert (TREE_CODE_LENGTH (code) == 1);
    5228              : 
    5229   4158117484 :   t = ggc_alloc_tree_node_stat (length PASS_MEM_STAT);
    5230              : 
    5231   4158117484 :   memset (t, 0, sizeof (struct tree_common));
    5232              : 
    5233   4158117484 :   TREE_SET_CODE (t, code);
    5234              : 
    5235   4158117484 :   TREE_TYPE (t) = type;
    5236   4158117484 :   SET_EXPR_LOCATION (t, UNKNOWN_LOCATION);
    5237   4158117484 :   TREE_OPERAND (t, 0) = node;
    5238   4158117484 :   if (node && !TYPE_P (node))
    5239              :     {
    5240   4158054673 :       TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
    5241   4158054673 :       TREE_READONLY (t) = TREE_READONLY (node);
    5242              :     }
    5243              : 
    5244   4158117484 :   if (TREE_CODE_CLASS (code) == tcc_statement)
    5245              :     {
    5246     24531258 :       if (code != DEBUG_BEGIN_STMT)
    5247     24531258 :         TREE_SIDE_EFFECTS (t) = 1;
    5248              :     }
    5249   4133586226 :   else switch (code)
    5250              :     {
    5251        51172 :     case VA_ARG_EXPR:
    5252              :       /* All of these have side-effects, no matter what their
    5253              :          operands are.  */
    5254        51172 :       TREE_SIDE_EFFECTS (t) = 1;
    5255        51172 :       TREE_READONLY (t) = 0;
    5256        51172 :       break;
    5257              : 
    5258    646824154 :     case INDIRECT_REF:
    5259              :       /* Whether a dereference is readonly has nothing to do with whether
    5260              :          its operand is readonly.  */
    5261    646824154 :       TREE_READONLY (t) = 0;
    5262    646824154 :       break;
    5263              : 
    5264    692240562 :     case ADDR_EXPR:
    5265    692240562 :       if (node)
    5266    692240562 :         recompute_tree_invariant_for_addr_expr (t);
    5267              :       break;
    5268              : 
    5269   2794470338 :     default:
    5270   1031404729 :       if ((TREE_CODE_CLASS (code) == tcc_unary || code == VIEW_CONVERT_EXPR)
    5271   2643619741 :           && node && !TYPE_P (node)
    5272   5438090079 :           && TREE_CONSTANT (node))
    5273    728959883 :         TREE_CONSTANT (t) = 1;
    5274   2794470338 :       if (TREE_CODE_CLASS (code) == tcc_reference
    5275    883335995 :           && node && TREE_THIS_VOLATILE (node))
    5276      3031107 :         TREE_THIS_VOLATILE (t) = 1;
    5277              :       break;
    5278              :     }
    5279              : 
    5280   4158117484 :   return t;
    5281              : }
    5282              : 
    5283              : #define PROCESS_ARG(N)                          \
    5284              :   do {                                          \
    5285              :     TREE_OPERAND (t, N) = arg##N;               \
    5286              :     if (arg##N &&!TYPE_P (arg##N))              \
    5287              :       {                                         \
    5288              :         if (TREE_SIDE_EFFECTS (arg##N))         \
    5289              :           side_effects = 1;                     \
    5290              :         if (!TREE_READONLY (arg##N)             \
    5291              :             && !CONSTANT_CLASS_P (arg##N))      \
    5292              :           (void) (read_only = 0);               \
    5293              :         if (!TREE_CONSTANT (arg##N))            \
    5294              :           (void) (constant = 0);                \
    5295              :       }                                         \
    5296              :   } while (0)
    5297              : 
    5298              : tree
    5299   1327180473 : build2 (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
    5300              : {
    5301   1327180473 :   bool constant, read_only, side_effects, div_by_zero;
    5302   1327180473 :   tree t;
    5303              : 
    5304   1327180473 :   gcc_assert (TREE_CODE_LENGTH (code) == 2);
    5305              : 
    5306   1327180473 :   if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
    5307    195687732 :       && arg0 && arg1 && tt && POINTER_TYPE_P (tt)
    5308              :       /* When sizetype precision doesn't match that of pointers
    5309              :          we need to be able to build explicit extensions or truncations
    5310              :          of the offset argument.  */
    5311   1327180473 :       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (tt))
    5312            0 :     gcc_assert (TREE_CODE (arg0) == INTEGER_CST
    5313              :                 && TREE_CODE (arg1) == INTEGER_CST);
    5314              : 
    5315   1327180473 :   if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
    5316     62997275 :     gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))
    5317              :                 && ptrofftype_p (TREE_TYPE (arg1)));
    5318              : 
    5319   1327180473 :   t = make_node (code PASS_MEM_STAT);
    5320   1327180473 :   TREE_TYPE (t) = tt;
    5321              : 
    5322              :   /* Below, we automatically set TREE_SIDE_EFFECTS and TREE_READONLY for the
    5323              :      result based on those same flags for the arguments.  But if the
    5324              :      arguments aren't really even `tree' expressions, we shouldn't be trying
    5325              :      to do this.  */
    5326              : 
    5327              :   /* Expressions without side effects may be constant if their
    5328              :      arguments are as well.  */
    5329   2654360946 :   constant = (TREE_CODE_CLASS (code) == tcc_comparison
    5330   1327180473 :               || TREE_CODE_CLASS (code) == tcc_binary);
    5331   1327180473 :   read_only = 1;
    5332   1327180473 :   side_effects = TREE_SIDE_EFFECTS (t);
    5333              : 
    5334   1327180473 :   switch (code)
    5335              :     {
    5336     14728418 :     case TRUNC_DIV_EXPR:
    5337     14728418 :     case CEIL_DIV_EXPR:
    5338     14728418 :     case FLOOR_DIV_EXPR:
    5339     14728418 :     case ROUND_DIV_EXPR:
    5340     14728418 :     case EXACT_DIV_EXPR:
    5341     14728418 :     case CEIL_MOD_EXPR:
    5342     14728418 :     case FLOOR_MOD_EXPR:
    5343     14728418 :     case ROUND_MOD_EXPR:
    5344     14728418 :     case TRUNC_MOD_EXPR:
    5345     14728418 :       div_by_zero = integer_zerop (arg1);
    5346     14728418 :       break;
    5347              :     default:
    5348              :       div_by_zero = false;
    5349              :     }
    5350              : 
    5351   1468799226 :   PROCESS_ARG (0);
    5352   1870156844 :   PROCESS_ARG (1);
    5353              : 
    5354   1327180473 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5355   1327180473 :   if (code == MEM_REF)
    5356              :     {
    5357     83114906 :       if (arg0 && TREE_CODE (arg0) == ADDR_EXPR)
    5358              :         {
    5359     23547119 :           tree o = TREE_OPERAND (arg0, 0);
    5360     23547119 :           TREE_READONLY (t) = TREE_READONLY (o);
    5361     23547119 :           TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o);
    5362              :         }
    5363              :     }
    5364              :   else
    5365              :     {
    5366   1244065567 :       TREE_READONLY (t) = read_only;
    5367              :       /* Don't mark X / 0 as constant.  */
    5368   1244065567 :       TREE_CONSTANT (t) = constant && !div_by_zero;
    5369   1244065567 :       TREE_THIS_VOLATILE (t)
    5370   1244065567 :         = (TREE_CODE_CLASS (code) == tcc_reference
    5371   1244065567 :            && arg0 && TREE_THIS_VOLATILE (arg0));
    5372              :     }
    5373              : 
    5374   1327180473 :   return t;
    5375              : }
    5376              : 
    5377              : 
    5378              : tree
    5379    489240818 : build3 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5380              :         tree arg2 MEM_STAT_DECL)
    5381              : {
    5382    489240818 :   bool constant, read_only, side_effects;
    5383    489240818 :   tree t;
    5384              : 
    5385    489240818 :   gcc_assert (TREE_CODE_LENGTH (code) == 3);
    5386    489240818 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    5387              : 
    5388    489240818 :   t = make_node (code PASS_MEM_STAT);
    5389    489240818 :   TREE_TYPE (t) = tt;
    5390              : 
    5391    489240818 :   read_only = 1;
    5392              : 
    5393              :   /* As a special exception, if COND_EXPR has NULL branches, we
    5394              :      assume that it is a gimple statement and always consider
    5395              :      it to have side effects.  */
    5396    489240818 :   if (code == COND_EXPR
    5397     41221555 :       && tt == void_type_node
    5398     25793393 :       && arg1 == NULL_TREE
    5399     25793393 :       && arg2 == NULL_TREE)
    5400              :     side_effects = true;
    5401              :   else
    5402    489240818 :     side_effects = TREE_SIDE_EFFECTS (t);
    5403              : 
    5404    489240818 :   PROCESS_ARG (0);
    5405    489240818 :   PROCESS_ARG (1);
    5406    489240818 :   PROCESS_ARG (2);
    5407              : 
    5408    489240818 :   if (code == COND_EXPR)
    5409     41221555 :     TREE_READONLY (t) = read_only;
    5410              : 
    5411    489240818 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5412    489240818 :   TREE_THIS_VOLATILE (t)
    5413    489240818 :     = (TREE_CODE_CLASS (code) == tcc_reference
    5414    489240818 :        && arg0 && TREE_THIS_VOLATILE (arg0));
    5415              : 
    5416    489240818 :   return t;
    5417              : }
    5418              : 
    5419              : tree
    5420     59643239 : build4 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5421              :         tree arg2, tree arg3 MEM_STAT_DECL)
    5422              : {
    5423     59643239 :   bool constant, read_only, side_effects;
    5424     59643239 :   tree t;
    5425              : 
    5426     59643239 :   gcc_assert (TREE_CODE_LENGTH (code) == 4);
    5427              : 
    5428     59643239 :   t = make_node (code PASS_MEM_STAT);
    5429     59643239 :   TREE_TYPE (t) = tt;
    5430              : 
    5431     59643239 :   side_effects = TREE_SIDE_EFFECTS (t);
    5432              : 
    5433     59643239 :   PROCESS_ARG (0);
    5434     59643239 :   PROCESS_ARG (1);
    5435     59643239 :   PROCESS_ARG (2);
    5436     59643239 :   PROCESS_ARG (3);
    5437              : 
    5438     59643239 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5439     59643239 :   TREE_THIS_VOLATILE (t)
    5440    119286478 :     = (TREE_CODE_CLASS (code) == tcc_reference
    5441     59643239 :        && arg0 && TREE_THIS_VOLATILE (arg0));
    5442              : 
    5443     59643239 :   return t;
    5444              : }
    5445              : 
    5446              : tree
    5447      1172509 : build5 (enum tree_code code, tree tt, tree arg0, tree arg1,
    5448              :         tree arg2, tree arg3, tree arg4 MEM_STAT_DECL)
    5449              : {
    5450      1172509 :   bool constant, read_only, side_effects;
    5451      1172509 :   tree t;
    5452              : 
    5453      1172509 :   gcc_assert (TREE_CODE_LENGTH (code) == 5);
    5454              : 
    5455      1172509 :   t = make_node (code PASS_MEM_STAT);
    5456      1172509 :   TREE_TYPE (t) = tt;
    5457              : 
    5458      1172509 :   side_effects = TREE_SIDE_EFFECTS (t);
    5459              : 
    5460      1172509 :   PROCESS_ARG (0);
    5461      1172509 :   PROCESS_ARG (1);
    5462      1172509 :   PROCESS_ARG (2);
    5463      1172509 :   PROCESS_ARG (3);
    5464      1172509 :   PROCESS_ARG (4);
    5465              : 
    5466      1172509 :   TREE_SIDE_EFFECTS (t) = side_effects;
    5467      1172509 :   if (code == TARGET_MEM_REF)
    5468              :     {
    5469      1163793 :       if (arg0 && TREE_CODE (arg0) == ADDR_EXPR)
    5470              :         {
    5471       182456 :           tree o = TREE_OPERAND (arg0, 0);
    5472       182456 :           TREE_READONLY (t) = TREE_READONLY (o);
    5473       182456 :           TREE_THIS_VOLATILE (t) = TREE_THIS_VOLATILE (o);
    5474              :         }
    5475              :     }
    5476              :   else
    5477         8716 :     TREE_THIS_VOLATILE (t)
    5478         8716 :       = (TREE_CODE_CLASS (code) == tcc_reference
    5479         8716 :          && arg0 && TREE_THIS_VOLATILE (arg0));
    5480              : 
    5481      1172509 :   return t;
    5482              : }
    5483              : 
    5484              : /* Build a simple MEM_REF tree with the semantics of a plain INDIRECT_REF
    5485              :    on the pointer PTR.  */
    5486              : 
    5487              : tree
    5488       484640 : build_simple_mem_ref_loc (location_t loc, tree ptr)
    5489              : {
    5490       484640 :   poly_int64 offset = 0;
    5491       484640 :   tree ptype = TREE_TYPE (ptr);
    5492       484640 :   tree tem;
    5493              :   /* For convenience allow addresses that collapse to a simple base
    5494              :      and offset.  */
    5495       484640 :   if (TREE_CODE (ptr) == ADDR_EXPR
    5496       484640 :       && (handled_component_p (TREE_OPERAND (ptr, 0))
    5497        15616 :           || TREE_CODE (TREE_OPERAND (ptr, 0)) == MEM_REF))
    5498              :     {
    5499          147 :       ptr = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &offset);
    5500          147 :       gcc_assert (ptr);
    5501          147 :       if (TREE_CODE (ptr) == MEM_REF)
    5502              :         {
    5503           37 :           offset += mem_ref_offset (ptr).force_shwi ();
    5504           37 :           ptr = TREE_OPERAND (ptr, 0);
    5505              :         }
    5506              :       else
    5507          110 :         ptr = build_fold_addr_expr (ptr);
    5508          147 :       gcc_assert (is_gimple_reg (ptr) || is_gimple_min_invariant (ptr));
    5509              :     }
    5510       484640 :   tem = build2 (MEM_REF, TREE_TYPE (ptype),
    5511              :                 ptr, build_int_cst (ptype, offset));
    5512       484640 :   SET_EXPR_LOCATION (tem, loc);
    5513       484640 :   return tem;
    5514              : }
    5515              : 
    5516              : /* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T.  */
    5517              : 
    5518              : poly_offset_int
    5519   1235747727 : mem_ref_offset (const_tree t)
    5520              : {
    5521   1235747727 :   return poly_offset_int::from (wi::to_poly_wide (TREE_OPERAND (t, 1)),
    5522   1235747727 :                                 SIGNED);
    5523              : }
    5524              : 
    5525              : /* Return an invariant ADDR_EXPR of type TYPE taking the address of BASE
    5526              :    offsetted by OFFSET units.  */
    5527              : 
    5528              : tree
    5529       200215 : build_invariant_address (tree type, tree base, poly_int64 offset)
    5530              : {
    5531       200215 :   tree ref = fold_build2 (MEM_REF, TREE_TYPE (type),
    5532              :                           build_fold_addr_expr (base),
    5533              :                           build_int_cst (ptr_type_node, offset));
    5534       200215 :   tree addr = build1 (ADDR_EXPR, type, ref);
    5535       200215 :   recompute_tree_invariant_for_addr_expr (addr);
    5536       200215 :   return addr;
    5537              : }
    5538              : 
    5539              : /* Similar except don't specify the TREE_TYPE
    5540              :    and leave the TREE_SIDE_EFFECTS as 0.
    5541              :    It is permissible for arguments to be null,
    5542              :    or even garbage if their values do not matter.  */
    5543              : 
    5544              : tree
    5545      5872168 : build_nt (enum tree_code code, ...)
    5546              : {
    5547      5872168 :   tree t;
    5548      5872168 :   int length;
    5549      5872168 :   int i;
    5550      5872168 :   va_list p;
    5551              : 
    5552      5872168 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    5553              : 
    5554      5872168 :   va_start (p, code);
    5555              : 
    5556      5872168 :   t = make_node (code);
    5557      5872168 :   length = TREE_CODE_LENGTH (code);
    5558              : 
    5559     17401475 :   for (i = 0; i < length; i++)
    5560     11529307 :     TREE_OPERAND (t, i) = va_arg (p, tree);
    5561              : 
    5562      5872168 :   va_end (p);
    5563      5872168 :   return t;
    5564              : }
    5565              : 
    5566              : /* Similar to build_nt, but for creating a CALL_EXPR object with a
    5567              :    tree vec.  */
    5568              : 
    5569              : tree
    5570            0 : build_nt_call_vec (tree fn, vec<tree, va_gc> *args)
    5571              : {
    5572            0 :   tree ret, t;
    5573            0 :   unsigned int ix;
    5574              : 
    5575            0 :   ret = build_vl_exp (CALL_EXPR, vec_safe_length (args) + 3);
    5576            0 :   CALL_EXPR_FN (ret) = fn;
    5577            0 :   CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE;
    5578            0 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
    5579            0 :     CALL_EXPR_ARG (ret, ix) = t;
    5580            0 :   return ret;
    5581              : }
    5582              : 
    5583              : /* Create a DECL_... node of code CODE, name NAME  (if non-null)
    5584              :    and data type TYPE.
    5585              :    We do NOT enter this node in any sort of symbol table.
    5586              : 
    5587              :    LOC is the location of the decl.
    5588              : 
    5589              :    layout_decl is used to set up the decl's storage layout.
    5590              :    Other slots are initialized to 0 or null pointers.  */
    5591              : 
    5592              : tree
    5593   3318024575 : build_decl (location_t loc, enum tree_code code, tree name,
    5594              :                  tree type MEM_STAT_DECL)
    5595              : {
    5596   3318024575 :   tree t;
    5597              : 
    5598   3318024575 :   t = make_node (code PASS_MEM_STAT);
    5599   3318024575 :   DECL_SOURCE_LOCATION (t) = loc;
    5600              : 
    5601              : /*  if (type == error_mark_node)
    5602              :     type = integer_type_node; */
    5603              : /* That is not done, deliberately, so that having error_mark_node
    5604              :    as the type can suppress useless errors in the use of this variable.  */
    5605              : 
    5606   3318024575 :   DECL_NAME (t) = name;
    5607   3318024575 :   TREE_TYPE (t) = type;
    5608              : 
    5609   3318024575 :   if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
    5610   1175329869 :     layout_decl (t, 0);
    5611              : 
    5612   3318024575 :   return t;
    5613              : }
    5614              : 
    5615              : /* Create and return a DEBUG_EXPR_DECL node of the given TYPE.  */
    5616              : 
    5617              : tree
    5618      1754870 : build_debug_expr_decl (tree type)
    5619              : {
    5620      1754870 :   tree vexpr = make_node (DEBUG_EXPR_DECL);
    5621      1754870 :   DECL_ARTIFICIAL (vexpr) = 1;
    5622      1754870 :   TREE_TYPE (vexpr) = type;
    5623      1754870 :   SET_DECL_MODE (vexpr, TYPE_MODE (type));
    5624      1754870 :   return vexpr;
    5625              : }
    5626              : 
    5627              : /* Builds and returns function declaration with NAME and TYPE.  */
    5628              : 
    5629              : tree
    5630        21453 : build_fn_decl (const char *name, tree type)
    5631              : {
    5632        21453 :   tree id = get_identifier (name);
    5633        21453 :   tree decl = build_decl (input_location, FUNCTION_DECL, id, type);
    5634              : 
    5635        21453 :   DECL_EXTERNAL (decl) = 1;
    5636        21453 :   TREE_PUBLIC (decl) = 1;
    5637        21453 :   DECL_ARTIFICIAL (decl) = 1;
    5638        21453 :   TREE_NOTHROW (decl) = 1;
    5639              : 
    5640        21453 :   return decl;
    5641              : }
    5642              : 
    5643              : vec<tree, va_gc> *all_translation_units;
    5644              : 
    5645              : /* Builds a new translation-unit decl with name NAME, queues it in the
    5646              :    global list of translation-unit decls and returns it.   */
    5647              : 
    5648              : tree
    5649       257110 : build_translation_unit_decl (tree name)
    5650              : {
    5651       257110 :   tree tu = build_decl (UNKNOWN_LOCATION, TRANSLATION_UNIT_DECL,
    5652       257110 :                         name, NULL_TREE);
    5653       257110 :   TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.name;
    5654       257110 :   vec_safe_push (all_translation_units, tu);
    5655       257110 :   return tu;
    5656              : }
    5657              : 
    5658              : 
    5659              : /* BLOCK nodes are used to represent the structure of binding contours
    5660              :    and declarations, once those contours have been exited and their contents
    5661              :    compiled.  This information is used for outputting debugging info.  */
    5662              : 
    5663              : tree
    5664       737701 : build_block (tree vars, tree subblocks, tree supercontext, tree chain)
    5665              : {
    5666       737701 :   tree block = make_node (BLOCK);
    5667              : 
    5668       737701 :   BLOCK_VARS (block) = vars;
    5669       737701 :   BLOCK_SUBBLOCKS (block) = subblocks;
    5670       737701 :   BLOCK_SUPERCONTEXT (block) = supercontext;
    5671       737701 :   BLOCK_CHAIN (block) = chain;
    5672       737701 :   return block;
    5673              : }
    5674              : 
    5675              : 
    5676              : /* Like SET_EXPR_LOCATION, but make sure the tree can have a location.
    5677              : 
    5678              :    LOC is the location to use in tree T.  */
    5679              : 
    5680              : void
    5681  15068072119 : protected_set_expr_location (tree t, location_t loc)
    5682              : {
    5683  15068072119 :   if (CAN_HAVE_LOCATION_P (t))
    5684   2387809965 :     SET_EXPR_LOCATION (t, loc);
    5685  12589370778 :   else if (t && TREE_CODE (t) == STATEMENT_LIST)
    5686              :     {
    5687        22265 :       t = expr_single (t);
    5688        22265 :       if (t && CAN_HAVE_LOCATION_P (t))
    5689           18 :         SET_EXPR_LOCATION (t, loc);
    5690              :     }
    5691  15068072119 : }
    5692              : 
    5693              : /* Like PROTECTED_SET_EXPR_LOCATION, but only do that if T has
    5694              :    UNKNOWN_LOCATION.  */
    5695              : 
    5696              : void
    5697     26470811 : protected_set_expr_location_if_unset (tree t, location_t loc)
    5698              : {
    5699     26470811 :   t = expr_single (t);
    5700     26470811 :   if (t && !EXPR_HAS_LOCATION (t))
    5701     17401225 :     protected_set_expr_location (t, loc);
    5702     26470811 : }
    5703              : 
    5704              : /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
    5705              :    of the various TYPE_QUAL values.  */
    5706              : 
    5707              : static void
    5708    114914658 : set_type_quals (tree type, int type_quals)
    5709              : {
    5710    114914658 :   TYPE_READONLY (type) = (type_quals & TYPE_QUAL_CONST) != 0;
    5711    114914658 :   TYPE_VOLATILE (type) = (type_quals & TYPE_QUAL_VOLATILE) != 0;
    5712    114914658 :   TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0;
    5713    114914658 :   TYPE_ATOMIC (type) = (type_quals & TYPE_QUAL_ATOMIC) != 0;
    5714    114914658 :   TYPE_ADDR_SPACE (type) = DECODE_QUAL_ADDR_SPACE (type_quals);
    5715    114914658 : }
    5716              : 
    5717              : /* Returns true iff CAND and BASE have equivalent language-specific
    5718              :    qualifiers.  */
    5719              : 
    5720              : bool
    5721   3261688576 : check_lang_type (const_tree cand, const_tree base)
    5722              : {
    5723   3261688576 :   if (lang_hooks.types.type_hash_eq == NULL)
    5724              :     return true;
    5725              :   /* type_hash_eq currently only applies to these types.  */
    5726   3203813833 :   if (TREE_CODE (cand) != FUNCTION_TYPE
    5727   3203813833 :       && TREE_CODE (cand) != METHOD_TYPE)
    5728              :     return true;
    5729      1186579 :   return lang_hooks.types.type_hash_eq (cand, base);
    5730              : }
    5731              : 
    5732              : /* This function checks to see if TYPE matches the size one of the built-in
    5733              :    atomic types, and returns that core atomic type.  */
    5734              : 
    5735              : static tree
    5736         8918 : find_atomic_core_type (const_tree type)
    5737              : {
    5738         8918 :   tree base_atomic_type;
    5739              : 
    5740              :   /* Only handle complete types.  */
    5741         8918 :   if (!tree_fits_uhwi_p (TYPE_SIZE (type)))
    5742              :     return NULL_TREE;
    5743              : 
    5744         8906 :   switch (tree_to_uhwi (TYPE_SIZE (type)))
    5745              :     {
    5746         2710 :     case 8:
    5747         2710 :       base_atomic_type = atomicQI_type_node;
    5748         2710 :       break;
    5749              : 
    5750          862 :     case 16:
    5751          862 :       base_atomic_type = atomicHI_type_node;
    5752          862 :       break;
    5753              : 
    5754         1117 :     case 32:
    5755         1117 :       base_atomic_type = atomicSI_type_node;
    5756         1117 :       break;
    5757              : 
    5758         2749 :     case 64:
    5759         2749 :       base_atomic_type = atomicDI_type_node;
    5760         2749 :       break;
    5761              : 
    5762         1348 :     case 128:
    5763         1348 :       base_atomic_type = atomicTI_type_node;
    5764         1348 :       break;
    5765              : 
    5766              :     default:
    5767              :       base_atomic_type = NULL_TREE;
    5768              :     }
    5769              : 
    5770              :   return base_atomic_type;
    5771              : }
    5772              : 
    5773              : /* Returns true iff unqualified CAND and BASE are equivalent.  */
    5774              : 
    5775              : bool
    5776   5204015102 : check_base_type (const_tree cand, const_tree base)
    5777              : {
    5778   5204015102 :   if (TYPE_NAME (cand) != TYPE_NAME (base)
    5779              :       /* Apparently this is needed for Objective-C.  */
    5780   4580588140 :       || TYPE_CONTEXT (cand) != TYPE_CONTEXT (base)
    5781   9784603241 :       || !attribute_list_equal (TYPE_ATTRIBUTES (cand),
    5782   4580588139 :                                 TYPE_ATTRIBUTES (base)))
    5783              :     return false;
    5784              :   /* Check alignment.  */
    5785   4580588139 :   if (TYPE_ALIGN (cand) == TYPE_ALIGN (base)
    5786   4580588139 :       && TYPE_USER_ALIGN (cand) == TYPE_USER_ALIGN (base))
    5787              :     return true;
    5788              :   /* Atomic types increase minimal alignment.  We must to do so as well
    5789              :      or we get duplicated canonical types. See PR88686.  */
    5790        11292 :   if ((TYPE_QUALS (cand) & TYPE_QUAL_ATOMIC))
    5791              :     {
    5792              :       /* See if this object can map to a basic atomic type.  */
    5793         1775 :       tree atomic_type = find_atomic_core_type (cand);
    5794         1775 :       if (atomic_type && TYPE_ALIGN (atomic_type) == TYPE_ALIGN (cand))
    5795         1775 :        return true;
    5796              :     }
    5797              :   return false;
    5798              : }
    5799              : 
    5800              : /* Returns true iff CAND is equivalent to BASE with TYPE_QUALS.  */
    5801              : 
    5802              : bool
    5803   5574016000 : check_qualified_type (const_tree cand, const_tree base, int type_quals)
    5804              : {
    5805   5574016000 :   return (TYPE_QUALS (cand) == type_quals
    5806   3882896556 :           && check_base_type (cand, base)
    5807   8833839107 :           && check_lang_type (cand, base));
    5808              : }
    5809              : 
    5810              : /* Returns true iff CAND is equivalent to BASE with ALIGN.  */
    5811              : 
    5812              : static bool
    5813      3895657 : check_aligned_type (const_tree cand, const_tree base, unsigned int align)
    5814              : {
    5815      3895657 :   return (TYPE_QUALS (cand) == TYPE_QUALS (base)
    5816      3159586 :           && TYPE_NAME (cand) == TYPE_NAME (base)
    5817              :           /* Apparently this is needed for Objective-C.  */
    5818      2250553 :           && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base)
    5819              :           /* Check alignment.  */
    5820      2250553 :           && TYPE_ALIGN (cand) == align
    5821              :           /* Check this is a user-aligned type as build_aligned_type
    5822              :              would create.  */
    5823      1065290 :           && TYPE_USER_ALIGN (cand)
    5824      1062424 :           && attribute_list_equal (TYPE_ATTRIBUTES (cand),
    5825      1062424 :                                    TYPE_ATTRIBUTES (base))
    5826      4958081 :           && check_lang_type (cand, base));
    5827              : }
    5828              : 
    5829              : /* Return a version of the TYPE, qualified as indicated by the
    5830              :    TYPE_QUALS, if one exists.  If no qualified version exists yet,
    5831              :    return NULL_TREE.  */
    5832              : 
    5833              : tree
    5834   4777493024 : get_qualified_type (tree type, int type_quals)
    5835              : {
    5836   4777493024 :   if (TYPE_QUALS (type) == type_quals)
    5837              :     return type;
    5838              : 
    5839   3374891637 :   tree mv = TYPE_MAIN_VARIANT (type);
    5840   3374891637 :   if (check_qualified_type (mv, type, type_quals))
    5841              :     return mv;
    5842              : 
    5843              :   /* Search the chain of variants to see if there is already one there just
    5844              :      like the one we need to have.  If so, use that existing one.  We must
    5845              :      preserve the TYPE_NAME, since there is code that depends on this.  */
    5846   2314203414 :   for (tree *tp = &TYPE_NEXT_VARIANT (mv); *tp; tp = &TYPE_NEXT_VARIANT (*tp))
    5847   2199060587 :     if (check_qualified_type (*tp, type, type_quals))
    5848              :       {
    5849              :         /* Put the found variant at the head of the variant list so
    5850              :            frequently searched variants get found faster.  The C++ FE
    5851              :            benefits greatly from this.  */
    5852   1380761959 :         tree t = *tp;
    5853   1380761959 :         *tp = TYPE_NEXT_VARIANT (t);
    5854   1380761959 :         TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (mv);
    5855   1380761959 :         TYPE_NEXT_VARIANT (mv) = t;
    5856   1380761959 :         return t;
    5857              :       }
    5858              : 
    5859              :   return NULL_TREE;
    5860              : }
    5861              : 
    5862              : /* Like get_qualified_type, but creates the type if it does not
    5863              :    exist.  This function never returns NULL_TREE.  */
    5864              : 
    5865              : tree
    5866   4273024079 : build_qualified_type (tree type, int type_quals MEM_STAT_DECL)
    5867              : {
    5868   4273024079 :   tree t;
    5869              : 
    5870              :   /* See if we already have the appropriate qualified variant.  */
    5871   4273024079 :   t = get_qualified_type (type, type_quals);
    5872              : 
    5873              :   /* If not, build it.  */
    5874   4273024079 :   if (!t)
    5875              :     {
    5876    113443253 :       t = build_variant_type_copy (type PASS_MEM_STAT);
    5877    113443253 :       set_type_quals (t, type_quals);
    5878              : 
    5879    113443253 :       if (((type_quals & TYPE_QUAL_ATOMIC) == TYPE_QUAL_ATOMIC))
    5880              :         {
    5881              :           /* See if this object can map to a basic atomic type.  */
    5882         7143 :           tree atomic_type = find_atomic_core_type (type);
    5883         7143 :           if (atomic_type)
    5884              :             {
    5885              :               /* Ensure the alignment of this type is compatible with
    5886              :                  the required alignment of the atomic type.  */
    5887         7011 :               if (TYPE_ALIGN (atomic_type) > TYPE_ALIGN (t))
    5888           98 :                 SET_TYPE_ALIGN (t, TYPE_ALIGN (atomic_type));
    5889              :             }
    5890              :         }
    5891              : 
    5892    113443253 :       if (TYPE_STRUCTURAL_EQUALITY_P (type))
    5893              :         /* Propagate structural equality. */
    5894      5766299 :         SET_TYPE_STRUCTURAL_EQUALITY (t);
    5895    107676954 :       else if (TYPE_CANONICAL (type) != type)
    5896              :         /* Build the underlying canonical type, since it is different
    5897              :            from TYPE. */
    5898              :         {
    5899     35171955 :           tree c = build_qualified_type (TYPE_CANONICAL (type), type_quals);
    5900     35171955 :           TYPE_CANONICAL (t) = TYPE_CANONICAL (c);
    5901              :         }
    5902              :       else
    5903              :         /* T is its own canonical type. */
    5904     72504999 :         TYPE_CANONICAL (t) = t;
    5905              : 
    5906              :     }
    5907              : 
    5908   4273024079 :   return t;
    5909              : }
    5910              : 
    5911              : /* Create a variant of type T with alignment ALIGN which
    5912              :    is measured in bits.  */
    5913              : 
    5914              : tree
    5915      1355924 : build_aligned_type (tree type, unsigned int align)
    5916              : {
    5917      1355924 :   tree t;
    5918              : 
    5919      1355924 :   if (TYPE_PACKED (type)
    5920      1355924 :       || TYPE_ALIGN (type) == align)
    5921              :     return type;
    5922              : 
    5923      4005349 :   for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
    5924      3895657 :     if (check_aligned_type (t, type, align))
    5925              :       return t;
    5926              : 
    5927       109692 :   t = build_variant_type_copy (type);
    5928       109692 :   SET_TYPE_ALIGN (t, align);
    5929       109692 :   TYPE_USER_ALIGN (t) = 1;
    5930              : 
    5931       109692 :   return t;
    5932              : }
    5933              : 
    5934              : /* Create a new distinct copy of TYPE.  The new type is made its own
    5935              :    MAIN_VARIANT. If TYPE requires structural equality checks, the
    5936              :    resulting type requires structural equality checks; otherwise, its
    5937              :    TYPE_CANONICAL points to itself. */
    5938              : 
    5939              : tree
    5940    818246930 : build_distinct_type_copy (tree type MEM_STAT_DECL)
    5941              : {
    5942    818246930 :   tree t = copy_node (type PASS_MEM_STAT);
    5943              : 
    5944    818246930 :   TYPE_POINTER_TO (t) = 0;
    5945    818246930 :   TYPE_REFERENCE_TO (t) = 0;
    5946              : 
    5947              :   /* Set the canonical type either to a new equivalence class, or
    5948              :      propagate the need for structural equality checks. */
    5949    818246930 :   if (TYPE_STRUCTURAL_EQUALITY_P (type))
    5950     68784961 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    5951              :   else
    5952    749461969 :     TYPE_CANONICAL (t) = t;
    5953              : 
    5954              :   /* Make it its own variant.  */
    5955    818246930 :   TYPE_MAIN_VARIANT (t) = t;
    5956    818246930 :   TYPE_NEXT_VARIANT (t) = 0;
    5957              : 
    5958              :   /* Note that it is now possible for TYPE_MIN_VALUE to be a value
    5959              :      whose TREE_TYPE is not t.  This can also happen in the Ada
    5960              :      frontend when using subtypes.  */
    5961              : 
    5962    818246930 :   return t;
    5963              : }
    5964              : 
    5965              : /* Create a new variant of TYPE, equivalent but distinct.  This is so
    5966              :    the caller can modify it. TYPE_CANONICAL for the return type will
    5967              :    be equivalent to TYPE_CANONICAL of TYPE, indicating that the types
    5968              :    are considered equal by the language itself (or that both types
    5969              :    require structural equality checks). */
    5970              : 
    5971              : tree
    5972    527639731 : build_variant_type_copy (tree type MEM_STAT_DECL)
    5973              : {
    5974    527639731 :   tree t, m = TYPE_MAIN_VARIANT (type);
    5975              : 
    5976    527639731 :   t = build_distinct_type_copy (type PASS_MEM_STAT);
    5977              : 
    5978              :   /* Since we're building a variant, assume that it is a non-semantic
    5979              :      variant.  This also propagates TYPE_STRUCTURAL_EQUALITY_P. */
    5980    527639731 :   TYPE_CANONICAL (t) = TYPE_CANONICAL (type);
    5981              :   /* Type variants have no alias set defined.  */
    5982    527639731 :   TYPE_ALIAS_SET (t) = -1;
    5983              : 
    5984              :   /* Add the new type to the chain of variants of TYPE.  */
    5985    527639731 :   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
    5986    527639731 :   TYPE_NEXT_VARIANT (m) = t;
    5987    527639731 :   TYPE_MAIN_VARIANT (t) = m;
    5988              : 
    5989    527639731 :   return t;
    5990              : }
    5991              : 
    5992              : /* Return true if the from tree in both tree maps are equal.  */
    5993              : 
    5994              : int
    5995   1901286455 : tree_map_base_eq (const void *va, const void *vb)
    5996              : {
    5997   1901286455 :   const struct tree_map_base  *const a = (const struct tree_map_base *) va,
    5998   1901286455 :     *const b = (const struct tree_map_base *) vb;
    5999   1901286455 :   return (a->from == b->from);
    6000              : }
    6001              : 
    6002              : /* Hash a from tree in a tree_base_map.  */
    6003              : 
    6004              : unsigned int
    6005            0 : tree_map_base_hash (const void *item)
    6006              : {
    6007            0 :   return htab_hash_pointer (((const struct tree_map_base *)item)->from);
    6008              : }
    6009              : 
    6010              : /* Return true if this tree map structure is marked for garbage collection
    6011              :    purposes.  We simply return true if the from tree is marked, so that this
    6012              :    structure goes away when the from tree goes away.  */
    6013              : 
    6014              : bool
    6015            0 : tree_map_base_marked_p (const void *p)
    6016              : {
    6017            0 :   return ggc_marked_p (((const struct tree_map_base *) p)->from);
    6018              : }
    6019              : 
    6020              : /* Hash a from tree in a tree_map.  */
    6021              : 
    6022              : unsigned int
    6023          259 : tree_map_hash (const void *item)
    6024              : {
    6025          259 :   return (((const struct tree_map *) item)->hash);
    6026              : }
    6027              : 
    6028              : /* Hash a from tree in a tree_decl_map.  */
    6029              : 
    6030              : unsigned int
    6031   1294487568 : tree_decl_map_hash (const void *item)
    6032              : {
    6033   1294487568 :   return DECL_UID (((const struct tree_decl_map *) item)->base.from);
    6034              : }
    6035              : 
    6036              : /* Return the initialization priority for DECL.  */
    6037              : 
    6038              : priority_type
    6039        23324 : decl_init_priority_lookup (tree decl)
    6040              : {
    6041        23324 :   symtab_node *snode = symtab_node::get (decl);
    6042              : 
    6043        23324 :   if (!snode)
    6044              :     return DEFAULT_INIT_PRIORITY;
    6045        23324 :   return
    6046        23324 :     snode->get_init_priority ();
    6047              : }
    6048              : 
    6049              : /* Return the finalization priority for DECL.  */
    6050              : 
    6051              : priority_type
    6052         1880 : decl_fini_priority_lookup (tree decl)
    6053              : {
    6054         1880 :   cgraph_node *node = cgraph_node::get (decl);
    6055              : 
    6056         1880 :   if (!node)
    6057              :     return DEFAULT_INIT_PRIORITY;
    6058         1880 :   return
    6059         1880 :     node->get_fini_priority ();
    6060              : }
    6061              : 
    6062              : /* Set the initialization priority for DECL to PRIORITY.  */
    6063              : 
    6064              : void
    6065        24916 : decl_init_priority_insert (tree decl, priority_type priority)
    6066              : {
    6067        24916 :   struct symtab_node *snode;
    6068              : 
    6069        24916 :   if (priority == DEFAULT_INIT_PRIORITY)
    6070              :     {
    6071        21355 :       snode = symtab_node::get (decl);
    6072        21355 :       if (!snode)
    6073              :         return;
    6074              :     }
    6075         3561 :   else if (VAR_P (decl))
    6076           45 :     snode = varpool_node::get_create (decl);
    6077              :   else
    6078         3516 :     snode = cgraph_node::get_create (decl);
    6079        24081 :   snode->set_init_priority (priority);
    6080              : }
    6081              : 
    6082              : /* Set the finalization priority for DECL to PRIORITY.  */
    6083              : 
    6084              : void
    6085         1740 : decl_fini_priority_insert (tree decl, priority_type priority)
    6086              : {
    6087         1740 :   struct cgraph_node *node;
    6088              : 
    6089         1740 :   if (priority == DEFAULT_INIT_PRIORITY)
    6090              :     {
    6091          105 :       node = cgraph_node::get (decl);
    6092          105 :       if (!node)
    6093              :         return;
    6094              :     }
    6095              :   else
    6096         1635 :     node = cgraph_node::get_create (decl);
    6097         1645 :   node->set_fini_priority (priority);
    6098              : }
    6099              : 
    6100              : /* Print out the statistics for the DECL_DEBUG_EXPR hash table.  */
    6101              : 
    6102              : static void
    6103            0 : print_debug_expr_statistics (void)
    6104              : {
    6105            0 :   fprintf (stderr, "DECL_DEBUG_EXPR  hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6106              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6107            0 :            (fmt_size_t) debug_expr_for_decl->size (),
    6108            0 :            (fmt_size_t) debug_expr_for_decl->elements (),
    6109              :            debug_expr_for_decl->collisions ());
    6110            0 : }
    6111              : 
    6112              : /* Print out the statistics for the DECL_VALUE_EXPR hash table.  */
    6113              : 
    6114              : static void
    6115            0 : print_value_expr_statistics (void)
    6116              : {
    6117            0 :   fprintf (stderr, "DECL_VALUE_EXPR  hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6118              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6119            0 :            (fmt_size_t) value_expr_for_decl->size (),
    6120            0 :            (fmt_size_t) value_expr_for_decl->elements (),
    6121              :            value_expr_for_decl->collisions ());
    6122            0 : }
    6123              : 
    6124              : /* Lookup a debug expression for FROM, and return it if we find one.  */
    6125              : 
    6126              : tree
    6127    449774998 : decl_debug_expr_lookup (tree from)
    6128              : {
    6129    449774998 :   struct tree_decl_map *h, in;
    6130    449774998 :   in.base.from = from;
    6131              : 
    6132    449774998 :   h = debug_expr_for_decl->find_with_hash (&in, DECL_UID (from));
    6133    449774998 :   if (h)
    6134    449774998 :     return h->to;
    6135              :   return NULL_TREE;
    6136              : }
    6137              : 
    6138              : /* Insert a mapping FROM->TO in the debug expression hashtable.  */
    6139              : 
    6140              : void
    6141      1428879 : decl_debug_expr_insert (tree from, tree to)
    6142              : {
    6143      1428879 :   struct tree_decl_map *h;
    6144              : 
    6145      1428879 :   h = ggc_alloc<tree_decl_map> ();
    6146      1428879 :   h->base.from = from;
    6147      1428879 :   h->to = to;
    6148      1428879 :   *debug_expr_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
    6149      1428879 : }
    6150              : 
    6151              : /* Lookup a value expression for FROM, and return it if we find one.  */
    6152              : 
    6153              : tree
    6154     24258033 : decl_value_expr_lookup (tree from)
    6155              : {
    6156     24258033 :   struct tree_decl_map *h, in;
    6157     24258033 :   in.base.from = from;
    6158              : 
    6159     24258033 :   h = value_expr_for_decl->find_with_hash (&in, DECL_UID (from));
    6160     24258033 :   if (h)
    6161     24258033 :     return h->to;
    6162              :   return NULL_TREE;
    6163              : }
    6164              : 
    6165              : /* Insert a mapping FROM->TO in the value expression hashtable.  */
    6166              : 
    6167              : void
    6168      8956265 : decl_value_expr_insert (tree from, tree to)
    6169              : {
    6170      8956265 :   struct tree_decl_map *h;
    6171              : 
    6172              :   /* Uses of FROM shouldn't look like they happen at the location of TO.  */
    6173      8956265 :   to = protected_set_expr_location_unshare (to, UNKNOWN_LOCATION);
    6174              : 
    6175      8956265 :   h = ggc_alloc<tree_decl_map> ();
    6176      8956265 :   h->base.from = from;
    6177      8956265 :   h->to = to;
    6178      8956265 :   *value_expr_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT) = h;
    6179      8956265 : }
    6180              : 
    6181              : /* Lookup a vector of debug arguments for FROM, and return it if we
    6182              :    find one.  */
    6183              : 
    6184              : vec<tree, va_gc> **
    6185       966679 : decl_debug_args_lookup (tree from)
    6186              : {
    6187       966679 :   struct tree_vec_map *h, in;
    6188              : 
    6189       966679 :   if (!DECL_HAS_DEBUG_ARGS_P (from))
    6190              :     return NULL;
    6191       824219 :   gcc_checking_assert (debug_args_for_decl != NULL);
    6192       824219 :   in.base.from = from;
    6193       824219 :   h = debug_args_for_decl->find_with_hash (&in, DECL_UID (from));
    6194       824219 :   if (h)
    6195       820322 :     return &h->to;
    6196              :   return NULL;
    6197              : }
    6198              : 
    6199              : /* Insert a mapping FROM->empty vector of debug arguments in the value
    6200              :    expression hashtable.  */
    6201              : 
    6202              : vec<tree, va_gc> **
    6203       307668 : decl_debug_args_insert (tree from)
    6204              : {
    6205       307668 :   struct tree_vec_map *h;
    6206       307668 :   tree_vec_map **loc;
    6207              : 
    6208       307668 :   if (DECL_HAS_DEBUG_ARGS_P (from))
    6209       213609 :     return decl_debug_args_lookup (from);
    6210        94059 :   if (debug_args_for_decl == NULL)
    6211         8645 :     debug_args_for_decl = hash_table<tree_vec_map_cache_hasher>::create_ggc (64);
    6212        94059 :   h = ggc_alloc<tree_vec_map> ();
    6213        94059 :   h->base.from = from;
    6214        94059 :   h->to = NULL;
    6215        94059 :   loc = debug_args_for_decl->find_slot_with_hash (h, DECL_UID (from), INSERT);
    6216        94059 :   *loc = h;
    6217        94059 :   DECL_HAS_DEBUG_ARGS_P (from) = 1;
    6218        94059 :   return &h->to;
    6219              : }
    6220              : 
    6221              : /* Hashing of types so that we don't make duplicates.
    6222              :    The entry point is `type_hash_canon'.  */
    6223              : 
    6224              : /* Generate the default hash code for TYPE.  This is designed for
    6225              :    speed, rather than maximum entropy.  */
    6226              : 
    6227              : hashval_t
    6228   1476680820 : type_hash_canon_hash (tree type)
    6229              : {
    6230   1476680820 :   inchash::hash hstate;
    6231              : 
    6232   1476680820 :   hstate.add_int (TREE_CODE (type));
    6233              : 
    6234   1476680820 :   hstate.add_flag (TYPE_STRUCTURAL_EQUALITY_P (type));
    6235              : 
    6236   1476680820 :   if (TREE_TYPE (type))
    6237   1476596994 :     hstate.add_object (TYPE_HASH (TREE_TYPE (type)));
    6238              : 
    6239   1762330511 :   for (tree t = TYPE_ATTRIBUTES (type); t; t = TREE_CHAIN (t))
    6240              :     /* Just the identifier is adequate to distinguish.  */
    6241    285649691 :     hstate.add_object (IDENTIFIER_HASH_VALUE (get_attribute_name (t)));
    6242              : 
    6243   1476680820 :   switch (TREE_CODE (type))
    6244              :     {
    6245    347209439 :     case METHOD_TYPE:
    6246    347209439 :       hstate.add_object (TYPE_HASH (TYPE_METHOD_BASETYPE (type)));
    6247              :       /* FALLTHROUGH. */
    6248   1278924702 :     case FUNCTION_TYPE:
    6249   5045767226 :       for (tree t = TYPE_ARG_TYPES (type); t; t = TREE_CHAIN (t))
    6250   3766842524 :         if (TREE_VALUE (t) != error_mark_node)
    6251   3766801389 :           hstate.add_object (TYPE_HASH (TREE_VALUE (t)));
    6252              :       break;
    6253              : 
    6254       995923 :     case OFFSET_TYPE:
    6255       995923 :       hstate.add_object (TYPE_HASH (TYPE_OFFSET_BASETYPE (type)));
    6256       995923 :       break;
    6257              : 
    6258     74391286 :     case ARRAY_TYPE:
    6259     74391286 :       {
    6260     74391286 :         if (TYPE_DOMAIN (type))
    6261     71360257 :           hstate.add_object (TYPE_HASH (TYPE_DOMAIN (type)));
    6262     74391286 :         if (!AGGREGATE_TYPE_P (TREE_TYPE (type)))
    6263              :           {
    6264     71877173 :             unsigned typeless = TYPE_TYPELESS_STORAGE (type);
    6265     71877173 :             hstate.add_object (typeless);
    6266              :           }
    6267              :       }
    6268              :       break;
    6269              : 
    6270     44109395 :     case INTEGER_TYPE:
    6271     44109395 :       {
    6272     44109395 :         tree t = TYPE_MAX_VALUE (type);
    6273     44109395 :         if (!t)
    6274       557780 :           t = TYPE_MIN_VALUE (type);
    6275     88218791 :         for (int i = 0; i < TREE_INT_CST_NUNITS (t); i++)
    6276     44109396 :           hstate.add_object (TREE_INT_CST_ELT (t, i));
    6277              :         break;
    6278              :       }
    6279              : 
    6280        61361 :     case BITINT_TYPE:
    6281        61361 :       {
    6282        61361 :         unsigned prec = TYPE_PRECISION (type);
    6283        61361 :         unsigned uns = TYPE_UNSIGNED (type);
    6284        61361 :         hstate.add_object (prec);
    6285        61361 :         hstate.add_int (uns);
    6286        61361 :         break;
    6287              :       }
    6288              : 
    6289        12078 :     case REAL_TYPE:
    6290        12078 :     case FIXED_POINT_TYPE:
    6291        12078 :       {
    6292        12078 :         unsigned prec = TYPE_PRECISION (type);
    6293        12078 :         hstate.add_object (prec);
    6294        12078 :         break;
    6295              :       }
    6296              : 
    6297     72434230 :     case VECTOR_TYPE:
    6298     72434230 :       hstate.add_poly_int (TYPE_VECTOR_SUBPARTS (type));
    6299     72434230 :       break;
    6300              : 
    6301              :     case REFERENCE_TYPE:
    6302   1476680820 :       hstate.add_flag (TYPE_REF_IS_RVALUE (type));
    6303              :       break;
    6304              : 
    6305              :     default:
    6306              :       break;
    6307              :     }
    6308              : 
    6309   1476680820 :   return hstate.end ();
    6310              : }
    6311              : 
    6312              : /* These are the Hashtable callback functions.  */
    6313              : 
    6314              : /* Returns true iff the types are equivalent.  */
    6315              : 
    6316              : bool
    6317   9314757624 : type_cache_hasher::equal (type_hash *a, type_hash *b)
    6318              : {
    6319              :   /* First test the things that are the same for all types.  */
    6320   9314757624 :   if (a->hash != b->hash
    6321    723313717 :       || TREE_CODE (a->type) != TREE_CODE (b->type)
    6322    723313417 :       || TREE_TYPE (a->type) != TREE_TYPE (b->type)
    6323    723312755 :       || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
    6324    723312755 :                                  TYPE_ATTRIBUTES (b->type))
    6325  10030821009 :       || (TREE_CODE (a->type) != COMPLEX_TYPE
    6326    713808617 :           && TYPE_NAME (a->type) != TYPE_NAME (b->type)))
    6327              :     return false;
    6328              : 
    6329              :   /* Be careful about comparing arrays before and after the element type
    6330              :      has been completed; don't compare TYPE_ALIGN unless both types are
    6331              :      complete.  */
    6332   1427078773 :   if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type)
    6333   1427078773 :       && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
    6334    711919445 :           || TYPE_MODE (a->type) != TYPE_MODE (b->type)))
    6335              :     return false;
    6336              : 
    6337    715158157 :   if (TYPE_STRUCTURAL_EQUALITY_P (a->type)
    6338    715158157 :       != TYPE_STRUCTURAL_EQUALITY_P (b->type))
    6339              :     return false;
    6340              : 
    6341    715148328 :   switch (TREE_CODE (a->type))
    6342              :     {
    6343              :     case VOID_TYPE:
    6344              :     case OPAQUE_TYPE:
    6345              :     case COMPLEX_TYPE:
    6346              :     case POINTER_TYPE:
    6347              :     case NULLPTR_TYPE:
    6348              :       return true;
    6349              : 
    6350     65766963 :     case VECTOR_TYPE:
    6351     65766963 :       return known_eq (TYPE_VECTOR_SUBPARTS (a->type),
    6352              :                        TYPE_VECTOR_SUBPARTS (b->type));
    6353              : 
    6354            0 :     case ENUMERAL_TYPE:
    6355            0 :       if (TYPE_VALUES (a->type) != TYPE_VALUES (b->type)
    6356            0 :           && !(TYPE_VALUES (a->type)
    6357            0 :                && TREE_CODE (TYPE_VALUES (a->type)) == TREE_LIST
    6358            0 :                && TYPE_VALUES (b->type)
    6359            0 :                && TREE_CODE (TYPE_VALUES (b->type)) == TREE_LIST
    6360            0 :                && type_list_equal (TYPE_VALUES (a->type),
    6361            0 :                                    TYPE_VALUES (b->type))))
    6362              :         return false;
    6363              : 
    6364              :       /* fall through */
    6365              : 
    6366     41085379 :     case INTEGER_TYPE:
    6367     41085379 :     case REAL_TYPE:
    6368     41085379 :     case BOOLEAN_TYPE:
    6369     41085379 :       if (TYPE_PRECISION (a->type) != TYPE_PRECISION (b->type))
    6370              :         return false;
    6371     41071511 :       return ((TYPE_MAX_VALUE (a->type) == TYPE_MAX_VALUE (b->type)
    6372       742705 :                || tree_int_cst_equal (TYPE_MAX_VALUE (a->type),
    6373       742705 :                                       TYPE_MAX_VALUE (b->type)))
    6374     41399726 :               && (TYPE_MIN_VALUE (a->type) == TYPE_MIN_VALUE (b->type)
    6375       487019 :                   || tree_int_cst_equal (TYPE_MIN_VALUE (a->type),
    6376       487019 :                                          TYPE_MIN_VALUE (b->type))));
    6377              : 
    6378        54596 :     case BITINT_TYPE:
    6379        54596 :       if (TYPE_PRECISION (a->type) != TYPE_PRECISION (b->type))
    6380              :         return false;
    6381        54596 :       return TYPE_UNSIGNED (a->type) == TYPE_UNSIGNED (b->type);
    6382              : 
    6383            0 :     case FIXED_POINT_TYPE:
    6384            0 :       return TYPE_SATURATING (a->type) == TYPE_SATURATING (b->type);
    6385              : 
    6386       754441 :     case OFFSET_TYPE:
    6387       754441 :       return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type);
    6388              : 
    6389     96484725 :     case METHOD_TYPE:
    6390     96484725 :       if (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type)
    6391     96484725 :           && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
    6392     96332539 :               || (TYPE_ARG_TYPES (a->type)
    6393     96332539 :                   && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
    6394     96332539 :                   && TYPE_ARG_TYPES (b->type)
    6395     96332539 :                   && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
    6396     96332539 :                   && type_list_equal (TYPE_ARG_TYPES (a->type),
    6397     96332539 :                                       TYPE_ARG_TYPES (b->type)))))
    6398              :         break;
    6399              :       return false;
    6400     62919638 :     case ARRAY_TYPE:
    6401              :       /* Don't compare TYPE_TYPELESS_STORAGE flag on aggregates,
    6402              :          where the flag should be inherited from the element type
    6403              :          and can change after ARRAY_TYPEs are created; on non-aggregates
    6404              :          compare it and hash it, scalars will never have that flag set
    6405              :          and we need to differentiate between arrays created by different
    6406              :          front-ends or middle-end created arrays.  */
    6407     62919638 :       return (TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type)
    6408     62919638 :               && (AGGREGATE_TYPE_P (TREE_TYPE (a->type))
    6409     61053335 :                   || (TYPE_TYPELESS_STORAGE (a->type)
    6410     61053335 :                       == TYPE_TYPELESS_STORAGE (b->type))));
    6411              : 
    6412            0 :     case RECORD_TYPE:
    6413            0 :     case UNION_TYPE:
    6414            0 :     case QUAL_UNION_TYPE:
    6415            0 :       return (TYPE_FIELDS (a->type) == TYPE_FIELDS (b->type)
    6416            0 :               || (TYPE_FIELDS (a->type)
    6417            0 :                   && TREE_CODE (TYPE_FIELDS (a->type)) == TREE_LIST
    6418            0 :                   && TYPE_FIELDS (b->type)
    6419            0 :                   && TREE_CODE (TYPE_FIELDS (b->type)) == TREE_LIST
    6420            0 :                   && type_list_equal (TYPE_FIELDS (a->type),
    6421            0 :                                       TYPE_FIELDS (b->type))));
    6422              : 
    6423    445827360 :     case FUNCTION_TYPE:
    6424    445827360 :       if ((TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
    6425    281363862 :            && (TYPE_NO_NAMED_ARGS_STDARG_P (a->type)
    6426    281363862 :                == TYPE_NO_NAMED_ARGS_STDARG_P (b->type)))
    6427    446272230 :           || (TYPE_ARG_TYPES (a->type)
    6428    164463498 :               && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
    6429    164463498 :               && TYPE_ARG_TYPES (b->type)
    6430    164463483 :               && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
    6431    164463483 :               && type_list_equal (TYPE_ARG_TYPES (a->type),
    6432    164463483 :                                   TYPE_ARG_TYPES (b->type))))
    6433              :         break;
    6434              :       return false;
    6435              : 
    6436            9 :     case REFERENCE_TYPE:
    6437            9 :       return TYPE_REF_IS_RVALUE (a->type) == TYPE_REF_IS_RVALUE (b->type);
    6438              : 
    6439              :     default:
    6440              :       return false;
    6441              :     }
    6442              : 
    6443    513701465 :   if (lang_hooks.types.type_hash_eq != NULL)
    6444    327667593 :     return lang_hooks.types.type_hash_eq (a->type, b->type);
    6445              : 
    6446              :   return true;
    6447              : }
    6448              : 
    6449              : /* Given TYPE, and HASHCODE its hash code, return the canonical
    6450              :    object for an identical type if one already exists.
    6451              :    Otherwise, return TYPE, and record it as the canonical object.
    6452              : 
    6453              :    To use this function, first create a type of the sort you want.
    6454              :    Then compute its hash code from the fields of the type that
    6455              :    make it different from other similar types.
    6456              :    Then call this function and use the value.  */
    6457              : 
    6458              : tree
    6459   1477770446 : type_hash_canon (unsigned int hashcode, tree type)
    6460              : {
    6461   1477770446 :   type_hash in;
    6462   1477770446 :   type_hash **loc;
    6463              : 
    6464              :   /* The hash table only contains main variants, so ensure that's what we're
    6465              :      being passed.  */
    6466   1477770446 :   gcc_assert (TYPE_MAIN_VARIANT (type) == type);
    6467              : 
    6468              :   /* The TYPE_ALIGN field of a type is set by layout_type(), so we
    6469              :      must call that routine before comparing TYPE_ALIGNs.  */
    6470   1477770446 :   layout_type (type);
    6471              : 
    6472   1477770446 :   in.hash = hashcode;
    6473   1477770446 :   in.type = type;
    6474              : 
    6475   1477770446 :   loc = type_hash_table->find_slot_with_hash (&in, hashcode, INSERT);
    6476   1477770446 :   if (*loc)
    6477              :     {
    6478    685944200 :       tree t1 = ((type_hash *) *loc)->type;
    6479    685944200 :       gcc_assert (TYPE_MAIN_VARIANT (t1) == t1
    6480              :                   && t1 != type);
    6481    685944200 :       if (TYPE_UID (type) + 1 == next_type_uid)
    6482    680443240 :         --next_type_uid;
    6483              :       /* Free also min/max values and the cache for integer
    6484              :          types.  This can't be done in free_node, as LTO frees
    6485              :          those on its own.  */
    6486    685944200 :       if (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == BITINT_TYPE)
    6487              :         {
    6488     40546464 :           if (TYPE_MIN_VALUE (type)
    6489     40546464 :               && TREE_TYPE (TYPE_MIN_VALUE (type)) == type)
    6490              :             {
    6491              :               /* Zero is always in TYPE_CACHED_VALUES.  */
    6492       375810 :               if (! TYPE_UNSIGNED (type))
    6493       222921 :                 int_cst_hash_table->remove_elt (TYPE_MIN_VALUE (type));
    6494       375810 :               ggc_free (TYPE_MIN_VALUE (type));
    6495              :             }
    6496     40546464 :           if (TYPE_MAX_VALUE (type)
    6497     40546464 :               && TREE_TYPE (TYPE_MAX_VALUE (type)) == type)
    6498              :             {
    6499       375810 :               int_cst_hash_table->remove_elt (TYPE_MAX_VALUE (type));
    6500       375810 :               ggc_free (TYPE_MAX_VALUE (type));
    6501              :             }
    6502     40546464 :           if (TYPE_CACHED_VALUES_P (type))
    6503       152889 :             ggc_free (TYPE_CACHED_VALUES (type));
    6504              :         }
    6505    685944200 :       free_node (type);
    6506    685944200 :       return t1;
    6507              :     }
    6508              :   else
    6509              :     {
    6510    791826246 :       struct type_hash *h;
    6511              : 
    6512    791826246 :       h = ggc_alloc<type_hash> ();
    6513    791826246 :       h->hash = hashcode;
    6514    791826246 :       h->type = type;
    6515    791826246 :       *loc = h;
    6516              : 
    6517    791826246 :       return type;
    6518              :     }
    6519              : }
    6520              : 
    6521              : static void
    6522            0 : print_type_hash_statistics (void)
    6523              : {
    6524            0 :   fprintf (stderr, "Type hash: size " HOST_SIZE_T_PRINT_DEC ", "
    6525              :            HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n",
    6526            0 :            (fmt_size_t) type_hash_table->size (),
    6527            0 :            (fmt_size_t) type_hash_table->elements (),
    6528              :            type_hash_table->collisions ());
    6529            0 : }
    6530              : 
    6531              : /* Given two lists of types
    6532              :    (chains of TREE_LIST nodes with types in the TREE_VALUE slots)
    6533              :    return 1 if the lists contain the same types in the same order.
    6534              :    Also, the TREE_PURPOSEs must match.  */
    6535              : 
    6536              : bool
    6537    260796558 : type_list_equal (const_tree l1, const_tree l2)
    6538              : {
    6539    260796558 :   const_tree t1, t2;
    6540              : 
    6541    980114670 :   for (t1 = l1, t2 = l2; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    6542    747483793 :     if (TREE_VALUE (t1) != TREE_VALUE (t2)
    6543    747483793 :         || (TREE_PURPOSE (t1) != TREE_PURPOSE (t2)
    6544     28167533 :             && ! (1 == simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2))
    6545         1887 :                   && (TREE_TYPE (TREE_PURPOSE (t1))
    6546         1887 :                       == TREE_TYPE (TREE_PURPOSE (t2))))))
    6547              :       return false;
    6548              : 
    6549    232630877 :   return t1 == t2;
    6550              : }
    6551              : 
    6552              : /* Returns the number of arguments to the FUNCTION_TYPE or METHOD_TYPE
    6553              :    given by TYPE.  If the argument list accepts variable arguments,
    6554              :    then this function counts only the ordinary arguments.  */
    6555              : 
    6556              : int
    6557     82202832 : type_num_arguments (const_tree fntype)
    6558              : {
    6559     82202832 :   int i = 0;
    6560              : 
    6561    319936175 :   for (tree t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t))
    6562              :     /* If the function does not take a variable number of arguments,
    6563              :        the last element in the list will have type `void'.  */
    6564    300742799 :     if (VOID_TYPE_P (TREE_VALUE (t)))
    6565              :       break;
    6566              :     else
    6567    237733343 :       ++i;
    6568              : 
    6569     82202832 :   return i;
    6570              : }
    6571              : 
    6572              : /* Return the type of the function TYPE's argument ARGNO if known.
    6573              :    For vararg function's where ARGNO refers to one of the variadic
    6574              :    arguments return null.  Otherwise, return a void_type_node for
    6575              :    out-of-bounds ARGNO.  */
    6576              : 
    6577              : tree
    6578     81122065 : type_argument_type (const_tree fntype, unsigned argno)
    6579              : {
    6580              :   /* Treat zero the same as an out-of-bounds argument number.  */
    6581     81122065 :   if (!argno)
    6582            0 :     return void_type_node;
    6583              : 
    6584     81122065 :   function_args_iterator iter;
    6585              : 
    6586     81122065 :   tree argtype;
    6587     81122065 :   unsigned i = 1;
    6588    174591776 :   FOREACH_FUNCTION_ARGS (fntype, argtype, iter)
    6589              :     {
    6590              :       /* A vararg function's argument list ends in a null.  Otherwise,
    6591              :          an ordinary function's argument list ends with void.  Return
    6592              :          null if ARGNO refers to a vararg argument, void_type_node if
    6593              :          it's out of bounds, and the formal argument type otherwise.  */
    6594    168832160 :       if (!argtype)
    6595              :         break;
    6596              : 
    6597    168832160 :       if (i == argno || VOID_TYPE_P (argtype))
    6598              :         return argtype;
    6599              : 
    6600     93469711 :       ++i;
    6601              :     }
    6602              : 
    6603              :   return NULL_TREE;
    6604              : }
    6605              : 
    6606              : /* True if integer constants T1 and T2
    6607              :    represent the same constant value.  */
    6608              : 
    6609              : bool
    6610   1338669535 : tree_int_cst_equal (const_tree t1, const_tree t2)
    6611              : {
    6612   1338669535 :   if (t1 == t2)
    6613              :     return true;
    6614              : 
    6615    677692738 :   if (t1 == 0 || t2 == 0)
    6616              :     return false;
    6617              : 
    6618    677276554 :   STRIP_ANY_LOCATION_WRAPPER (t1);
    6619    677276554 :   STRIP_ANY_LOCATION_WRAPPER (t2);
    6620              : 
    6621    677276554 :   if (TREE_CODE (t1) == INTEGER_CST
    6622    673122602 :       && TREE_CODE (t2) == INTEGER_CST
    6623   1350399156 :       && wi::to_widest (t1) == wi::to_widest (t2))
    6624     20635246 :     return true;
    6625              : 
    6626              :   return false;
    6627              : }
    6628              : 
    6629              : /* Return true if T is an INTEGER_CST whose numerical value (extended
    6630              :    according to TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  */
    6631              : 
    6632              : bool
    6633   2404193810 : tree_fits_shwi_p (const_tree t)
    6634              : {
    6635   2404193810 :   return (t != NULL_TREE
    6636   2404193719 :           && TREE_CODE (t) == INTEGER_CST
    6637   4805703290 :           && wi::fits_shwi_p (wi::to_widest (t)));
    6638              : }
    6639              : 
    6640              : /* Return true if T is an INTEGER_CST or POLY_INT_CST whose numerical
    6641              :    value (extended according to TYPE_UNSIGNED) fits in a poly_int64.  */
    6642              : 
    6643              : bool
    6644   1016770492 : tree_fits_poly_int64_p (const_tree t)
    6645              : {
    6646   1016770492 :   if (t == NULL_TREE)
    6647              :     return false;
    6648    978562914 :   if (POLY_INT_CST_P (t))
    6649              :     {
    6650              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; i++)
    6651              :         if (!wi::fits_shwi_p (wi::to_wide (POLY_INT_CST_COEFF (t, i))))
    6652              :           return false;
    6653              :       return true;
    6654              :     }
    6655    978562914 :   return (TREE_CODE (t) == INTEGER_CST
    6656   1957231278 :           && wi::fits_shwi_p (wi::to_widest (t)));
    6657              : }
    6658              : 
    6659              : /* Return true if T is an INTEGER_CST whose numerical value (extended
    6660              :    according to TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  */
    6661              : 
    6662              : bool
    6663   4194730200 : tree_fits_uhwi_p (const_tree t)
    6664              : {
    6665   4194730200 :   return (t != NULL_TREE
    6666   4194116358 :           && TREE_CODE (t) == INTEGER_CST
    6667   8383492753 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6668              : }
    6669              : 
    6670              : /* Return true if T is an INTEGER_CST or POLY_INT_CST whose numerical
    6671              :    value (extended according to TYPE_UNSIGNED) fits in a poly_uint64.  */
    6672              : 
    6673              : bool
    6674   1097806517 : tree_fits_poly_uint64_p (const_tree t)
    6675              : {
    6676   1097806517 :   if (t == NULL_TREE)
    6677              :     return false;
    6678   1097446389 :   if (POLY_INT_CST_P (t))
    6679              :     {
    6680              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; i++)
    6681              :         if (!wi::fits_uhwi_p (wi::to_widest (POLY_INT_CST_COEFF (t, i))))
    6682              :           return false;
    6683              :       return true;
    6684              :     }
    6685   1097446389 :   return (TREE_CODE (t) == INTEGER_CST
    6686   2194894189 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6687              : }
    6688              : 
    6689              : /* Return true if T is an INTEGER_CST whose numerical value (extended according
    6690              :    to TYPE_UNSIGNED) fits in a sanitize_code_type (uint64_t).  */
    6691              : 
    6692              : bool
    6693           90 : tree_fits_sanitize_code_type_p (const_tree t)
    6694              : {
    6695           90 :   if (t == NULL_TREE)
    6696              :     return false;
    6697           90 :   return (TREE_CODE (t) == INTEGER_CST
    6698          180 :           && wi::fits_uhwi_p (wi::to_widest (t)));
    6699              : }
    6700              : 
    6701              : /* T is an INTEGER_CST whose numerical value (extended according to
    6702              :    TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  Return that
    6703              :    HOST_WIDE_INT.  */
    6704              : 
    6705              : HOST_WIDE_INT
    6706   1422698436 : tree_to_shwi (const_tree t)
    6707              : {
    6708   1422698436 :   gcc_assert (tree_fits_shwi_p (t));
    6709   1422698436 :   return TREE_INT_CST_LOW (t);
    6710              : }
    6711              : 
    6712              : /* T is an INTEGER_CST whose numerical value (extended according to
    6713              :    TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  Return that
    6714              :    HOST_WIDE_INT.  */
    6715              : 
    6716              : unsigned HOST_WIDE_INT
    6717   1037621858 : tree_to_uhwi (const_tree t)
    6718              : {
    6719   1037621858 :   gcc_assert (tree_fits_uhwi_p (t));
    6720   1037621858 :   return TREE_INT_CST_LOW (t);
    6721              : }
    6722              : 
    6723              : /* T is an INTEGER_CST whose numerical value (extended according to
    6724              :    TYPE_UNSIGNED) fits in a sanitize_code_type.  Return that
    6725              :    sanitize_code_type.  */
    6726              : 
    6727              : sanitize_code_type
    6728           90 : tree_to_sanitize_code_type (const_tree t)
    6729              : {
    6730           90 :   gcc_assert (tree_fits_sanitize_code_type_p (t));
    6731           90 :   return TREE_INT_CST_LOW (t);
    6732              : }
    6733              : 
    6734              : /* Return the most significant (sign) bit of T.  */
    6735              : 
    6736              : int
    6737     45578974 : tree_int_cst_sign_bit (const_tree t)
    6738              : {
    6739     45578974 :   unsigned bitno = TYPE_PRECISION (TREE_TYPE (t)) - 1;
    6740              : 
    6741     45578974 :   return wi::extract_uhwi (wi::to_wide (t), bitno, 1);
    6742              : }
    6743              : 
    6744              : /* Return an indication of the sign of the integer constant T.
    6745              :    The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
    6746              :    Note that -1 will never be returned if T's type is unsigned.  */
    6747              : 
    6748              : int
    6749   1915020947 : tree_int_cst_sgn (const_tree t)
    6750              : {
    6751   1915020947 :   if (wi::to_wide (t) == 0)
    6752              :     return 0;
    6753   1780331908 :   else if (TYPE_UNSIGNED (TREE_TYPE (t)))
    6754              :     return 1;
    6755     84799625 :   else if (wi::neg_p (wi::to_wide (t)))
    6756              :     return -1;
    6757              :   else
    6758     81148261 :     return 1;
    6759              : }
    6760              : 
    6761              : /* Return the minimum number of bits needed to represent VALUE in a
    6762              :    signed or unsigned type, UNSIGNEDP says which.  */
    6763              : 
    6764              : unsigned int
    6765      3754063 : tree_int_cst_min_precision (tree value, signop sgn)
    6766              : {
    6767              :   /* If the value is negative, compute its negative minus 1.  The latter
    6768              :      adjustment is because the absolute value of the largest negative value
    6769              :      is one larger than the largest positive value.  This is equivalent to
    6770              :      a bit-wise negation, so use that operation instead.  */
    6771              : 
    6772      3754063 :   if (tree_int_cst_sgn (value) < 0)
    6773       107229 :     value = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (value), value);
    6774              : 
    6775              :   /* Return the number of bits needed, taking into account the fact
    6776              :      that we need one more bit for a signed than unsigned type.
    6777              :      If value is 0 or -1, the minimum precision is 1 no matter
    6778              :      whether unsignedp is true or false.  */
    6779              : 
    6780      3754063 :   if (integer_zerop (value))
    6781              :     return 1;
    6782              :   else
    6783      5393639 :     return tree_floor_log2 (value) + 1 + (sgn == SIGNED ? 1 : 0) ;
    6784              : }
    6785              : 
    6786              : /* Return truthvalue of whether T1 is the same tree structure as T2.
    6787              :    Return 1 if they are the same.
    6788              :    Return 0 if they are understandably different.
    6789              :    Return -1 if either contains tree structure not understood by
    6790              :    this function.  */
    6791              : 
    6792              : int
    6793    209756316 : simple_cst_equal (const_tree t1, const_tree t2)
    6794              : {
    6795    213555617 :   enum tree_code code1, code2;
    6796    213555617 :   int cmp;
    6797    213555617 :   int i;
    6798              : 
    6799    213555617 :   if (t1 == t2)
    6800              :     return 1;
    6801    136823594 :   if (t1 == 0 || t2 == 0)
    6802              :     return 0;
    6803              : 
    6804              :   /* For location wrappers to be the same, they must be at the same
    6805              :      source location (and wrap the same thing).  */
    6806    127911012 :   if (location_wrapper_p (t1) && location_wrapper_p (t2))
    6807              :     {
    6808     13450836 :       if (EXPR_LOCATION (t1) != EXPR_LOCATION (t2))
    6809              :         return 0;
    6810          738 :       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6811              :     }
    6812              : 
    6813    114460176 :   code1 = TREE_CODE (t1);
    6814    114460176 :   code2 = TREE_CODE (t2);
    6815              : 
    6816    114460176 :   if (CONVERT_EXPR_CODE_P (code1) || code1 == NON_LVALUE_EXPR)
    6817              :     {
    6818      3786584 :       if (CONVERT_EXPR_CODE_P (code2)
    6819      3785861 :           || code2 == NON_LVALUE_EXPR)
    6820          723 :         return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6821              :       else
    6822      3785861 :         return simple_cst_equal (TREE_OPERAND (t1, 0), t2);
    6823              :     }
    6824              : 
    6825    110673592 :   else if (CONVERT_EXPR_CODE_P (code2)
    6826    110673577 :            || code2 == NON_LVALUE_EXPR)
    6827          113 :     return simple_cst_equal (t1, TREE_OPERAND (t2, 0));
    6828              : 
    6829    110673479 :   if (code1 != code2)
    6830              :     return 0;
    6831              : 
    6832    106179443 :   switch (code1)
    6833              :     {
    6834     96267057 :     case INTEGER_CST:
    6835     96267057 :       return wi::to_widest (t1) == wi::to_widest (t2);
    6836              : 
    6837           93 :     case REAL_CST:
    6838           93 :       return real_identical (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
    6839              : 
    6840            0 :     case FIXED_CST:
    6841            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1), TREE_FIXED_CST (t2));
    6842              : 
    6843      3253736 :     case STRING_CST:
    6844      3253736 :       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
    6845      3253736 :               && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
    6846      3736438 :                          TREE_STRING_LENGTH (t1)));
    6847              : 
    6848          479 :     case CONSTRUCTOR:
    6849          479 :       {
    6850          479 :         unsigned HOST_WIDE_INT idx;
    6851          479 :         vec<constructor_elt, va_gc> *v1 = CONSTRUCTOR_ELTS (t1);
    6852          479 :         vec<constructor_elt, va_gc> *v2 = CONSTRUCTOR_ELTS (t2);
    6853              : 
    6854          503 :         if (vec_safe_length (v1) != vec_safe_length (v2))
    6855              :           return 0;
    6856              : 
    6857          485 :         for (idx = 0; idx < vec_safe_length (v1); ++idx)
    6858              :           {
    6859           12 :             if ((*v1)[idx].index
    6860           12 :                 && TREE_CODE ((*v1)[idx].index) == FIELD_DECL)
    6861              :               {
    6862            9 :                 if ((*v1)[idx].index != (*v2)[idx].index)
    6863              :                   return 0;
    6864              :               }
    6865              :             else
    6866              :               {
    6867            3 :                 cmp = simple_cst_equal ((*v1)[idx].index, (*v2)[idx].index);
    6868            3 :                 if (cmp <= 0)
    6869              :                   return cmp;
    6870              :               }
    6871           12 :             cmp = simple_cst_equal ((*v1)[idx].value, (*v2)[idx].value);
    6872           12 :             if (cmp <= 0)
    6873              :               return cmp;
    6874              :           }
    6875              :         return 1;
    6876              :       }
    6877              : 
    6878            0 :     case SAVE_EXPR:
    6879            0 :       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6880              : 
    6881       208038 :     case CALL_EXPR:
    6882       208038 :       cmp = simple_cst_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2));
    6883       208038 :       if (cmp <= 0)
    6884              :         return cmp;
    6885        85895 :       if (call_expr_nargs (t1) != call_expr_nargs (t2))
    6886              :         return 0;
    6887        85895 :       {
    6888        85895 :         const_tree arg1, arg2;
    6889        85895 :         const_call_expr_arg_iterator iter1, iter2;
    6890       171790 :         for (arg1 = first_const_call_expr_arg (t1, &iter1),
    6891        85895 :                arg2 = first_const_call_expr_arg (t2, &iter2);
    6892        85929 :              arg1 && arg2;
    6893           34 :              arg1 = next_const_call_expr_arg (&iter1),
    6894           34 :                arg2 = next_const_call_expr_arg (&iter2))
    6895              :           {
    6896        85869 :             cmp = simple_cst_equal (arg1, arg2);
    6897        85869 :             if (cmp <= 0)
    6898              :               return cmp;
    6899              :           }
    6900           60 :         return arg1 == arg2;
    6901              :       }
    6902              : 
    6903        11658 :     case TARGET_EXPR:
    6904              :       /* Special case: if either target is an unallocated VAR_DECL,
    6905              :          it means that it's going to be unified with whatever the
    6906              :          TARGET_EXPR is really supposed to initialize, so treat it
    6907              :          as being equivalent to anything.  */
    6908        11658 :       if ((TREE_CODE (TREE_OPERAND (t1, 0)) == VAR_DECL
    6909        11658 :            && DECL_NAME (TREE_OPERAND (t1, 0)) == NULL_TREE
    6910        11658 :            && !DECL_RTL_SET_P (TREE_OPERAND (t1, 0)))
    6911        11658 :           || (TREE_CODE (TREE_OPERAND (t2, 0)) == VAR_DECL
    6912            0 :               && DECL_NAME (TREE_OPERAND (t2, 0)) == NULL_TREE
    6913            0 :               && !DECL_RTL_SET_P (TREE_OPERAND (t2, 0))))
    6914              :         cmp = 1;
    6915              :       else
    6916            0 :         cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6917              : 
    6918            0 :       if (cmp <= 0)
    6919              :         return cmp;
    6920              : 
    6921        11658 :       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
    6922              : 
    6923            0 :     case WITH_CLEANUP_EXPR:
    6924            0 :       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6925            0 :       if (cmp <= 0)
    6926              :         return cmp;
    6927              : 
    6928            0 :       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
    6929              : 
    6930          208 :     case COMPONENT_REF:
    6931          208 :       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
    6932          208 :         return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    6933              : 
    6934              :       return 0;
    6935              : 
    6936              :     case VAR_DECL:
    6937              :     case PARM_DECL:
    6938              :     case CONST_DECL:
    6939              :     case FUNCTION_DECL:
    6940              :       return 0;
    6941              : 
    6942      6373562 :     default:
    6943      6373562 :       if (POLY_INT_CST_P (t1))
    6944              :         /* A false return means maybe_ne rather than known_ne.  */
    6945              :         return known_eq (poly_widest_int::from (poly_int_cst_value (t1),
    6946              :                                                 TYPE_SIGN (TREE_TYPE (t1))),
    6947              :                          poly_widest_int::from (poly_int_cst_value (t2),
    6948              :                                                 TYPE_SIGN (TREE_TYPE (t2))));
    6949      6373562 :       break;
    6950              :     }
    6951              : 
    6952              :   /* This general rule works for most tree codes.  All exceptions should be
    6953              :      handled above.  If this is a language-specific tree code, we can't
    6954              :      trust what might be in the operand, so say we don't know
    6955              :      the situation.  */
    6956      6373562 :   if ((int) code1 >= (int) LAST_AND_UNUSED_TREE_CODE)
    6957              :     return -1;
    6958              : 
    6959       881004 :   switch (TREE_CODE_CLASS (code1))
    6960              :     {
    6961              :     case tcc_unary:
    6962              :     case tcc_binary:
    6963              :     case tcc_comparison:
    6964              :     case tcc_expression:
    6965              :     case tcc_reference:
    6966              :     case tcc_statement:
    6967              :       cmp = 1;
    6968         1172 :       for (i = 0; i < TREE_CODE_LENGTH (code1); i++)
    6969              :         {
    6970          903 :           cmp = simple_cst_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
    6971          903 :           if (cmp <= 0)
    6972              :             return cmp;
    6973              :         }
    6974              : 
    6975              :       return cmp;
    6976              : 
    6977              :     default:
    6978              :       return -1;
    6979              :     }
    6980              : }
    6981              : 
    6982              : /* Compare the value of T, an INTEGER_CST, with U, an unsigned integer value.
    6983              :    Return -1, 0, or 1 if the value of T is less than, equal to, or greater
    6984              :    than U, respectively.  */
    6985              : 
    6986              : int
    6987   1562715214 : compare_tree_int (const_tree t, unsigned HOST_WIDE_INT u)
    6988              : {
    6989   1562715214 :   if (tree_int_cst_sgn (t) < 0)
    6990              :     return -1;
    6991   1562714936 :   else if (!tree_fits_uhwi_p (t))
    6992              :     return 1;
    6993   1562714907 :   else if (TREE_INT_CST_LOW (t) == u)
    6994              :     return 0;
    6995   1391564273 :   else if (TREE_INT_CST_LOW (t) < u)
    6996              :     return -1;
    6997              :   else
    6998     13930810 :     return 1;
    6999              : }
    7000              : 
    7001              : /* Return true if SIZE represents a constant size that is in bounds of
    7002              :    what the middle-end and the backend accepts (covering not more than
    7003              :    half of the address-space).
    7004              :    When PERR is non-null, set *PERR on failure to the description of
    7005              :    why SIZE is not valid.  */
    7006              : 
    7007              : bool
    7008     69638124 : valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
    7009              : {
    7010     69638124 :   if (POLY_INT_CST_P (size))
    7011              :     {
    7012              :       if (TREE_OVERFLOW (size))
    7013              :         return false;
    7014              :       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
    7015              :         if (!valid_constant_size_p (POLY_INT_CST_COEFF (size, i)))
    7016              :           return false;
    7017              :       return true;
    7018              :     }
    7019              : 
    7020     69638124 :   cst_size_error error;
    7021     69638124 :   if (!perr)
    7022     63848468 :     perr = &error;
    7023              : 
    7024     69638124 :   if (TREE_CODE (size) != INTEGER_CST)
    7025              :     {
    7026            3 :       *perr = cst_size_not_constant;
    7027            3 :       return false;
    7028              :     }
    7029              : 
    7030     69638121 :   if (TREE_OVERFLOW_P (size))
    7031              :     {
    7032           60 :       *perr = cst_size_overflow;
    7033           60 :       return false;
    7034              :     }
    7035              : 
    7036     69638061 :   if (tree_int_cst_sgn (size) < 0)
    7037              :     {
    7038          423 :       *perr = cst_size_negative;
    7039          423 :       return false;
    7040              :     }
    7041    139275276 :   if (!tree_fits_uhwi_p (size)
    7042    139275276 :       || (wi::to_widest (TYPE_MAX_VALUE (sizetype))
    7043    139275276 :           < wi::to_widest (size) * 2))
    7044              :     {
    7045          624 :       *perr = cst_size_too_big;
    7046          624 :       return false;
    7047              :     }
    7048              : 
    7049              :   return true;
    7050              : }
    7051              : 
    7052              : /* Return the precision of the type, or for a complex or vector type the
    7053              :    precision of the type of its elements.  */
    7054              : 
    7055              : unsigned int
    7056   7709390189 : element_precision (const_tree type)
    7057              : {
    7058   7709390189 :   if (!TYPE_P (type))
    7059      6315719 :     type = TREE_TYPE (type);
    7060   7709390189 :   enum tree_code code = TREE_CODE (type);
    7061   7709390189 :   if (code == COMPLEX_TYPE || code == VECTOR_TYPE)
    7062     57857633 :     type = TREE_TYPE (type);
    7063              : 
    7064   7709390189 :   return TYPE_PRECISION (type);
    7065              : }
    7066              : 
    7067              : /* Return true if CODE represents an associative tree code.  Otherwise
    7068              :    return false.  */
    7069              : bool
    7070     36592949 : associative_tree_code (enum tree_code code)
    7071              : {
    7072     36592949 :   switch (code)
    7073              :     {
    7074              :     case BIT_IOR_EXPR:
    7075              :     case BIT_AND_EXPR:
    7076              :     case BIT_XOR_EXPR:
    7077              :     case PLUS_EXPR:
    7078              :     case MULT_EXPR:
    7079              :     case MIN_EXPR:
    7080              :     case MAX_EXPR:
    7081              :       return true;
    7082              : 
    7083     25709816 :     default:
    7084     25709816 :       break;
    7085              :     }
    7086     25709816 :   return false;
    7087              : }
    7088              : 
    7089              : /* Return true if CODE represents a commutative tree code.  Otherwise
    7090              :    return false.  */
    7091              : bool
    7092   1808877690 : commutative_tree_code (enum tree_code code)
    7093              : {
    7094   1808877690 :   switch (code)
    7095              :     {
    7096              :     case PLUS_EXPR:
    7097              :     case MULT_EXPR:
    7098              :     case MULT_HIGHPART_EXPR:
    7099              :     case MIN_EXPR:
    7100              :     case MAX_EXPR:
    7101              :     case BIT_IOR_EXPR:
    7102              :     case BIT_XOR_EXPR:
    7103              :     case BIT_AND_EXPR:
    7104              :     case NE_EXPR:
    7105              :     case EQ_EXPR:
    7106              :     case UNORDERED_EXPR:
    7107              :     case ORDERED_EXPR:
    7108              :     case UNEQ_EXPR:
    7109              :     case LTGT_EXPR:
    7110              :     case TRUTH_AND_EXPR:
    7111              :     case TRUTH_XOR_EXPR:
    7112              :     case TRUTH_OR_EXPR:
    7113              :     case WIDEN_MULT_EXPR:
    7114              :     case VEC_WIDEN_MULT_HI_EXPR:
    7115              :     case VEC_WIDEN_MULT_LO_EXPR:
    7116              :     case VEC_WIDEN_MULT_EVEN_EXPR:
    7117              :     case VEC_WIDEN_MULT_ODD_EXPR:
    7118              :       return true;
    7119              : 
    7120    972739946 :     default:
    7121    972739946 :       break;
    7122              :     }
    7123    972739946 :   return false;
    7124              : }
    7125              : 
    7126              : /* Return true if CODE represents a ternary tree code for which the
    7127              :    first two operands are commutative.  Otherwise return false.  */
    7128              : bool
    7129     99313393 : commutative_ternary_tree_code (enum tree_code code)
    7130              : {
    7131     99313393 :   switch (code)
    7132              :     {
    7133              :     case WIDEN_MULT_PLUS_EXPR:
    7134              :     case WIDEN_MULT_MINUS_EXPR:
    7135              :     case DOT_PROD_EXPR:
    7136              :       return true;
    7137              : 
    7138     99303542 :     default:
    7139     99303542 :       break;
    7140              :     }
    7141     99303542 :   return false;
    7142              : }
    7143              : 
    7144              : /* Returns true if CODE can overflow.  */
    7145              : 
    7146              : bool
    7147         4519 : operation_can_overflow (enum tree_code code)
    7148              : {
    7149         4519 :   switch (code)
    7150              :     {
    7151              :     case PLUS_EXPR:
    7152              :     case MINUS_EXPR:
    7153              :     case MULT_EXPR:
    7154              :     case LSHIFT_EXPR:
    7155              :       /* Can overflow in various ways.  */
    7156              :       return true;
    7157              :     case TRUNC_DIV_EXPR:
    7158              :     case EXACT_DIV_EXPR:
    7159              :     case FLOOR_DIV_EXPR:
    7160              :     case CEIL_DIV_EXPR:
    7161              :       /* For INT_MIN / -1.  */
    7162              :       return true;
    7163              :     case NEGATE_EXPR:
    7164              :     case ABS_EXPR:
    7165              :       /* For -INT_MIN.  */
    7166              :       return true;
    7167          580 :     default:
    7168              :       /* These operators cannot overflow.  */
    7169          580 :       return false;
    7170              :     }
    7171              : }
    7172              : 
    7173              : /* Returns true if CODE operating on operands of type TYPE doesn't overflow, or
    7174              :    ftrapv doesn't generate trapping insns for CODE.  */
    7175              : 
    7176              : bool
    7177       260781 : operation_no_trapping_overflow (tree type, enum tree_code code)
    7178              : {
    7179       260781 :   gcc_checking_assert (ANY_INTEGRAL_TYPE_P (type));
    7180              : 
    7181              :   /* We don't generate instructions that trap on overflow for complex or vector
    7182              :      types.  */
    7183       260781 :   if (!INTEGRAL_TYPE_P (type))
    7184              :     return true;
    7185              : 
    7186       260781 :   if (!TYPE_OVERFLOW_TRAPS (type))
    7187              :     return true;
    7188              : 
    7189          262 :   switch (code)
    7190              :     {
    7191              :     case PLUS_EXPR:
    7192              :     case MINUS_EXPR:
    7193              :     case MULT_EXPR:
    7194              :     case NEGATE_EXPR:
    7195              :     case ABS_EXPR:
    7196              :       /* These operators can overflow, and -ftrapv generates trapping code for
    7197              :          these.  */
    7198              :       return false;
    7199              :     case TRUNC_DIV_EXPR:
    7200              :     case EXACT_DIV_EXPR:
    7201              :     case FLOOR_DIV_EXPR:
    7202              :     case CEIL_DIV_EXPR:
    7203              :     case LSHIFT_EXPR:
    7204              :       /* These operators can overflow, but -ftrapv does not generate trapping
    7205              :          code for these.  */
    7206              :       return true;
    7207              :     default:
    7208              :       /* These operators cannot overflow.  */
    7209              :       return true;
    7210              :     }
    7211              : }
    7212              : 
    7213              : /* Constructors for pointer, array and function types.
    7214              :    (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
    7215              :    constructed by language-dependent code, not here.)  */
    7216              : 
    7217              : /* Construct, lay out and return the type of pointers to TO_TYPE with
    7218              :    mode MODE.  If MODE is VOIDmode, a pointer mode for the address
    7219              :    space of TO_TYPE will be picked.  If CAN_ALIAS_ALL is TRUE,
    7220              :    indicate this type can reference all of memory. If such a type has
    7221              :    already been constructed, reuse it.  */
    7222              : 
    7223              : tree
    7224   2663249528 : build_pointer_type_for_mode (tree to_type, machine_mode mode,
    7225              :                              bool can_alias_all)
    7226              : {
    7227   2663249528 :   tree t;
    7228   2663249528 :   bool could_alias = can_alias_all;
    7229              : 
    7230   2663249528 :   if (to_type == error_mark_node)
    7231              :     return error_mark_node;
    7232              : 
    7233   2663249522 :   if (mode == VOIDmode)
    7234              :     {
    7235   2532246867 :       addr_space_t as = TYPE_ADDR_SPACE (to_type);
    7236   2532246867 :       mode = targetm.addr_space.pointer_mode (as);
    7237              :     }
    7238              : 
    7239              :   /* If the pointed-to type has the may_alias attribute set, force
    7240              :      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
    7241   2663249522 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
    7242      4504922 :     can_alias_all = true;
    7243              : 
    7244              :   /* In some cases, languages will have things that aren't a POINTER_TYPE
    7245              :      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
    7246              :      In that case, return that type without regard to the rest of our
    7247              :      operands.
    7248              : 
    7249              :      ??? This is a kludge, but consistent with the way this function has
    7250              :      always operated and there doesn't seem to be a good way to avoid this
    7251              :      at the moment.  */
    7252   2663249522 :   if (TYPE_POINTER_TO (to_type) != 0
    7253   2663249522 :       && TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
    7254        49951 :     return TYPE_POINTER_TO (to_type);
    7255              : 
    7256              :   /* First, if we already have a type for pointers to TO_TYPE and it's
    7257              :      the proper mode, use it.  */
    7258   2663932475 :   for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
    7259   2508684624 :     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
    7260              :       return t;
    7261              : 
    7262    155247851 :   t = make_node (POINTER_TYPE);
    7263              : 
    7264    155247851 :   TREE_TYPE (t) = to_type;
    7265    155247851 :   SET_TYPE_MODE (t, mode);
    7266    155247851 :   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
    7267    155247851 :   TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
    7268    155247851 :   TYPE_POINTER_TO (to_type) = t;
    7269              : 
    7270              :   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
    7271    155247851 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)
    7272      5372871 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7273    149874980 :   else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
    7274     44746949 :     TYPE_CANONICAL (t)
    7275     89493898 :       = build_pointer_type_for_mode (TYPE_CANONICAL (to_type),
    7276              :                                      mode, false);
    7277              : 
    7278              :   /* Lay out the type.  This function has many callers that are concerned
    7279              :      with expression-construction, and this simplifies them all.  */
    7280    155247851 :   layout_type (t);
    7281              : 
    7282    155247851 :   return t;
    7283              : }
    7284              : 
    7285              : /* By default build pointers in ptr_mode.  */
    7286              : 
    7287              : tree
    7288   2531525058 : build_pointer_type (tree to_type)
    7289              : {
    7290   2531525058 :   return build_pointer_type_for_mode (to_type, VOIDmode, false);
    7291              : }
    7292              : 
    7293              : /* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE.  */
    7294              : 
    7295              : tree
    7296    741932647 : build_reference_type_for_mode (tree to_type, machine_mode mode,
    7297              :                                bool can_alias_all)
    7298              : {
    7299    741932647 :   tree t;
    7300    741932647 :   bool could_alias = can_alias_all;
    7301              : 
    7302    741932647 :   if (to_type == error_mark_node)
    7303              :     return error_mark_node;
    7304              : 
    7305    741932647 :   if (mode == VOIDmode)
    7306              :     {
    7307    586173062 :       addr_space_t as = TYPE_ADDR_SPACE (to_type);
    7308    586173062 :       mode = targetm.addr_space.pointer_mode (as);
    7309              :     }
    7310              : 
    7311              :   /* If the pointed-to type has the may_alias attribute set, force
    7312              :      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
    7313    741932647 :   if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (to_type)))
    7314       756174 :     can_alias_all = true;
    7315              : 
    7316              :   /* In some cases, languages will have things that aren't a REFERENCE_TYPE
    7317              :      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_REFERENCE_TO.
    7318              :      In that case, return that type without regard to the rest of our
    7319              :      operands.
    7320              : 
    7321              :      ??? This is a kludge, but consistent with the way this function has
    7322              :      always operated and there doesn't seem to be a good way to avoid this
    7323              :      at the moment.  */
    7324    741932647 :   if (TYPE_REFERENCE_TO (to_type) != 0
    7325    741932647 :       && TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
    7326            0 :     return TYPE_REFERENCE_TO (to_type);
    7327              : 
    7328              :   /* First, if we already have a type for pointers to TO_TYPE and it's
    7329              :      the proper mode, use it.  */
    7330    741932647 :   for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
    7331    647840948 :     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
    7332              :       return t;
    7333              : 
    7334     94091699 :   t = make_node (REFERENCE_TYPE);
    7335              : 
    7336     94091699 :   TREE_TYPE (t) = to_type;
    7337     94091699 :   SET_TYPE_MODE (t, mode);
    7338     94091699 :   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
    7339     94091699 :   TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (to_type);
    7340     94091699 :   TYPE_REFERENCE_TO (to_type) = t;
    7341              : 
    7342              :   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
    7343     94091699 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)
    7344      5104147 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7345     88987552 :   else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
    7346     52713273 :     TYPE_CANONICAL (t)
    7347    105426546 :       = build_reference_type_for_mode (TYPE_CANONICAL (to_type),
    7348              :                                        mode, false);
    7349              : 
    7350     94091699 :   layout_type (t);
    7351              : 
    7352     94091699 :   return t;
    7353              : }
    7354              : 
    7355              : 
    7356              : /* Build the node for the type of references-to-TO_TYPE by default
    7357              :    in ptr_mode.  */
    7358              : 
    7359              : tree
    7360     27777642 : build_reference_type (tree to_type)
    7361              : {
    7362     27777642 :   return build_reference_type_for_mode (to_type, VOIDmode, false);
    7363              : }
    7364              : 
    7365              : #define MAX_INT_CACHED_PREC \
    7366              :   (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
    7367              : static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2];
    7368              : 
    7369              : static void
    7370       264541 : clear_nonstandard_integer_type_cache (void)
    7371              : {
    7372     34654871 :   for (size_t i = 0 ; i < 2 * MAX_INT_CACHED_PREC + 2 ; i++)
    7373              :   {
    7374     34390330 :     nonstandard_integer_type_cache[i] = NULL;
    7375              :   }
    7376            0 : }
    7377              : 
    7378              : /* Builds a signed or unsigned integer type of precision PRECISION.
    7379              :    Used for C bitfields whose precision does not match that of
    7380              :    built-in target types.  */
    7381              : tree
    7382     63655039 : build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
    7383              :                                 int unsignedp)
    7384              : {
    7385     63655039 :   tree itype, ret;
    7386              : 
    7387     63655039 :   if (unsignedp)
    7388     54814819 :     unsignedp = MAX_INT_CACHED_PREC + 1;
    7389              : 
    7390     63655039 :   if (precision <= MAX_INT_CACHED_PREC)
    7391              :     {
    7392     63293075 :       itype = nonstandard_integer_type_cache[precision + unsignedp];
    7393     63293075 :       if (itype)
    7394              :         return itype;
    7395              :     }
    7396              : 
    7397      1089626 :   itype = make_node (INTEGER_TYPE);
    7398      1089626 :   TYPE_PRECISION (itype) = precision;
    7399              : 
    7400      1089626 :   if (unsignedp)
    7401       712967 :     fixup_unsigned_type (itype);
    7402              :   else
    7403       376659 :     fixup_signed_type (itype);
    7404              : 
    7405      1089626 :   inchash::hash hstate;
    7406      1089626 :   inchash::add_expr (TYPE_MAX_VALUE (itype), hstate);
    7407      1089626 :   ret = type_hash_canon (hstate.end (), itype);
    7408      1089626 :   if (precision <= MAX_INT_CACHED_PREC)
    7409       727662 :     nonstandard_integer_type_cache[precision + unsignedp] = ret;
    7410              : 
    7411              :   return ret;
    7412              : }
    7413              : 
    7414              : #define MAX_BOOL_CACHED_PREC \
    7415              :   (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64)
    7416              : static GTY(()) tree nonstandard_boolean_type_cache[MAX_BOOL_CACHED_PREC + 1];
    7417              : 
    7418              : /* Builds a boolean type of precision PRECISION.
    7419              :    Used for boolean vectors to choose proper vector element size.  */
    7420              : tree
    7421      2758786 : build_nonstandard_boolean_type (unsigned HOST_WIDE_INT precision)
    7422              : {
    7423      2758786 :   tree type;
    7424              : 
    7425      2758786 :   if (precision <= MAX_BOOL_CACHED_PREC)
    7426              :     {
    7427      2754738 :       type = nonstandard_boolean_type_cache[precision];
    7428      2754738 :       if (type)
    7429              :         return type;
    7430              :     }
    7431              : 
    7432        84284 :   type = make_node (BOOLEAN_TYPE);
    7433        84284 :   TYPE_PRECISION (type) = precision;
    7434        84284 :   fixup_signed_type (type);
    7435              : 
    7436        84284 :   if (precision <= MAX_INT_CACHED_PREC)
    7437        80236 :     nonstandard_boolean_type_cache[precision] = type;
    7438              : 
    7439              :   return type;
    7440              : }
    7441              : 
    7442              : static GTY(()) vec<tree, va_gc> *bitint_type_cache;
    7443              : 
    7444              : /* Builds a signed or unsigned _BitInt(PRECISION) type.  */
    7445              : tree
    7446        76800 : build_bitint_type (unsigned HOST_WIDE_INT precision, int unsignedp)
    7447              : {
    7448        76800 :   tree itype, ret;
    7449              : 
    7450        76800 :   gcc_checking_assert (precision >= 1);
    7451              : 
    7452        76800 :   if (unsignedp)
    7453        37845 :     unsignedp = MAX_INT_CACHED_PREC + 1;
    7454              : 
    7455        76800 :   if (bitint_type_cache == NULL)
    7456          725 :     vec_safe_grow_cleared (bitint_type_cache, 2 * MAX_INT_CACHED_PREC + 2);
    7457              : 
    7458        76800 :   if (precision <= MAX_INT_CACHED_PREC)
    7459              :     {
    7460        17452 :       itype = (*bitint_type_cache)[precision + unsignedp];
    7461        17452 :       if (itype)
    7462              :         return itype;
    7463              :     }
    7464              : 
    7465        61360 :   itype = make_node (BITINT_TYPE);
    7466        61360 :   TYPE_PRECISION (itype) = precision;
    7467              : 
    7468        61360 :   if (unsignedp)
    7469        30731 :     fixup_unsigned_type (itype);
    7470              :   else
    7471        30629 :     fixup_signed_type (itype);
    7472              : 
    7473        61360 :   hashval_t hash = type_hash_canon_hash (itype);
    7474        61360 :   ret = type_hash_canon (hash, itype);
    7475        61360 :   if (precision <= MAX_INT_CACHED_PREC)
    7476         2012 :     (*bitint_type_cache)[precision + unsignedp] = ret;
    7477              : 
    7478              :   return ret;
    7479              : }
    7480              : 
    7481              : /* Create a range of some discrete type TYPE (an INTEGER_TYPE, ENUMERAL_TYPE
    7482              :    or BOOLEAN_TYPE) with low bound LOWVAL and high bound HIGHVAL.  If SHARED
    7483              :    is true, reuse such a type that has already been constructed.  */
    7484              : 
    7485              : static tree
    7486     45315696 : build_range_type_1 (tree type, tree lowval, tree highval, bool shared)
    7487              : {
    7488     45315696 :   tree itype = make_node (INTEGER_TYPE);
    7489              : 
    7490     45315696 :   TREE_TYPE (itype) = type;
    7491              : 
    7492     45315696 :   TYPE_MIN_VALUE (itype) = fold_convert (type, lowval);
    7493     45315696 :   TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL;
    7494              : 
    7495     45315696 :   TYPE_PRECISION (itype) = TYPE_PRECISION (type);
    7496     45315696 :   SET_TYPE_MODE (itype, TYPE_MODE (type));
    7497     45315696 :   TYPE_SIZE (itype) = TYPE_SIZE (type);
    7498     45315696 :   TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type);
    7499     45315696 :   SET_TYPE_ALIGN (itype, TYPE_ALIGN (type));
    7500     45315696 :   TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type);
    7501     45315696 :   SET_TYPE_WARN_IF_NOT_ALIGN (itype, TYPE_WARN_IF_NOT_ALIGN (type));
    7502              : 
    7503     45315696 :   if (!shared)
    7504              :     return itype;
    7505              : 
    7506     45315696 :   if ((TYPE_MIN_VALUE (itype)
    7507     45315696 :        && TREE_CODE (TYPE_MIN_VALUE (itype)) != INTEGER_CST)
    7508     90630555 :       || (TYPE_MAX_VALUE (itype)
    7509     44757079 :           && TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST))
    7510              :     {
    7511              :       /* Since we cannot reliably merge this type, we need to compare it using
    7512              :          structural equality checks.  */
    7513      1216787 :       SET_TYPE_STRUCTURAL_EQUALITY (itype);
    7514      1216787 :       return itype;
    7515              :     }
    7516              : 
    7517     44098909 :   hashval_t hash = type_hash_canon_hash (itype);
    7518     44098909 :   itype = type_hash_canon (hash, itype);
    7519              : 
    7520     44098909 :   return itype;
    7521              : }
    7522              : 
    7523              : /* Wrapper around build_range_type_1 with SHARED set to true.  */
    7524              : 
    7525              : tree
    7526     45315696 : build_range_type (tree type, tree lowval, tree highval)
    7527              : {
    7528     45315696 :   return build_range_type_1 (type, lowval, highval, true);
    7529              : }
    7530              : 
    7531              : /* Wrapper around build_range_type_1 with SHARED set to false.  */
    7532              : 
    7533              : tree
    7534            0 : build_nonshared_range_type (tree type, tree lowval, tree highval)
    7535              : {
    7536            0 :   return build_range_type_1 (type, lowval, highval, false);
    7537              : }
    7538              : 
    7539              : /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
    7540              :    MAXVAL should be the maximum value in the domain
    7541              :    (one less than the length of the array).
    7542              : 
    7543              :    The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
    7544              :    We don't enforce this limit, that is up to caller (e.g. language front end).
    7545              :    The limit exists because the result is a signed type and we don't handle
    7546              :    sizes that use more than one HOST_WIDE_INT.  */
    7547              : 
    7548              : tree
    7549     42368247 : build_index_type (tree maxval)
    7550              : {
    7551     42368247 :   return build_range_type (sizetype, size_zero_node, maxval);
    7552              : }
    7553              : 
    7554              : /* Return true if the debug information for TYPE, a subtype, should be emitted
    7555              :    as a subrange type.  If so, set LOWVAL to the low bound and HIGHVAL to the
    7556              :    high bound, respectively.  Sometimes doing so unnecessarily obfuscates the
    7557              :    debug info and doesn't reflect the source code.  */
    7558              : 
    7559              : bool
    7560           18 : subrange_type_for_debug_p (const_tree type, tree *lowval, tree *highval)
    7561              : {
    7562           18 :   tree base_type = TREE_TYPE (type), low, high;
    7563              : 
    7564              :   /* Subrange types have a base type which is an integral type.  */
    7565           18 :   if (!INTEGRAL_TYPE_P (base_type))
    7566              :     return false;
    7567              : 
    7568              :   /* Get the real bounds of the subtype.  */
    7569           18 :   if (lang_hooks.types.get_subrange_bounds)
    7570            0 :     lang_hooks.types.get_subrange_bounds (type, &low, &high);
    7571              :   else
    7572              :     {
    7573           18 :       low = TYPE_MIN_VALUE (type);
    7574           18 :       high = TYPE_MAX_VALUE (type);
    7575              :     }
    7576              : 
    7577              :   /* If the type and its base type have the same representation and the same
    7578              :      name, then the type is not a subrange but a copy of the base type.  */
    7579           18 :   if ((TREE_CODE (base_type) == INTEGER_TYPE
    7580           18 :        || TREE_CODE (base_type) == BOOLEAN_TYPE)
    7581           18 :       && int_size_in_bytes (type) == int_size_in_bytes (base_type)
    7582           18 :       && tree_int_cst_equal (low, TYPE_MIN_VALUE (base_type))
    7583            0 :       && tree_int_cst_equal (high, TYPE_MAX_VALUE (base_type))
    7584           18 :       && TYPE_IDENTIFIER (type) == TYPE_IDENTIFIER (base_type))
    7585              :     return false;
    7586              : 
    7587           18 :   if (lowval)
    7588           18 :     *lowval = low;
    7589           18 :   if (highval)
    7590           18 :     *highval = high;
    7591              :   return true;
    7592              : }
    7593              : 
    7594              : /* Construct, lay out and return the type of arrays of elements with ELT_TYPE
    7595              :    and number of elements specified by the range of values of INDEX_TYPE.
    7596              :    If TYPELESS_STORAGE is true, TYPE_TYPELESS_STORAGE flag is set on the type.
    7597              :    If SHARED is true, reuse such a type that has already been constructed.
    7598              :    If SET_CANONICAL is true, compute TYPE_CANONICAL from the element type.  */
    7599              : 
    7600              : tree
    7601     73747447 : build_array_type_1 (tree elt_type, tree index_type, bool typeless_storage,
    7602              :                     bool shared, bool set_canonical)
    7603              : {
    7604     73747447 :   tree t;
    7605              : 
    7606     73747447 :   if (TREE_CODE (elt_type) == FUNCTION_TYPE)
    7607              :     {
    7608            0 :       error ("arrays of functions are not meaningful");
    7609            0 :       elt_type = integer_type_node;
    7610              :     }
    7611              : 
    7612     73747447 :   t = make_node (ARRAY_TYPE);
    7613     73747447 :   TREE_TYPE (t) = elt_type;
    7614     73747447 :   TYPE_DOMAIN (t) = index_type;
    7615     73747447 :   TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (elt_type);
    7616     73747447 :   TYPE_TYPELESS_STORAGE (t) = typeless_storage;
    7617              : 
    7618              :   /* Set TYPE_STRUCTURAL_EQUALITY_P.  */
    7619     73747447 :   if (set_canonical
    7620     73747447 :       && (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    7621     73708069 :           || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
    7622     73425768 :           || in_lto_p))
    7623       394509 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7624              : 
    7625     73747447 :   layout_type (t);
    7626              : 
    7627     73747447 :   if (shared)
    7628              :     {
    7629     73747418 :       hashval_t hash = type_hash_canon_hash (t);
    7630     73747418 :       tree probe_type = t;
    7631     73747418 :       t = type_hash_canon (hash, t);
    7632     73747418 :       if (t != probe_type)
    7633              :         return t;
    7634              :     }
    7635              : 
    7636     11335007 :   if (TYPE_CANONICAL (t) == t && set_canonical)
    7637              :     {
    7638     10989589 :       if (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    7639     10989589 :           || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))
    7640     21979178 :           || in_lto_p)
    7641            0 :         gcc_unreachable ();
    7642     10989589 :       else if (TYPE_CANONICAL (elt_type) != elt_type
    7643     10989589 :                || (index_type && TYPE_CANONICAL (index_type) != index_type))
    7644       106637 :         TYPE_CANONICAL (t)
    7645       309431 :           = build_array_type_1 (TYPE_CANONICAL (elt_type),
    7646              :                                 index_type
    7647        96157 :                                 ? TYPE_CANONICAL (index_type) : NULL_TREE,
    7648              :                                 typeless_storage, shared, set_canonical);
    7649              :     }
    7650              : 
    7651              :   return t;
    7652              : }
    7653              : 
    7654              : /* Wrapper around build_array_type_1 with SHARED set to true.  */
    7655              : 
    7656              : tree
    7657     73640781 : build_array_type (tree elt_type, tree index_type, bool typeless_storage)
    7658              : {
    7659     73640781 :   return
    7660     73640781 :     build_array_type_1 (elt_type, index_type, typeless_storage, true, true);
    7661              : }
    7662              : 
    7663              : /* Wrapper around build_array_type_1 with SHARED set to false.  */
    7664              : 
    7665              : tree
    7666            0 : build_nonshared_array_type (tree elt_type, tree index_type)
    7667              : {
    7668            0 :   return build_array_type_1 (elt_type, index_type, false, false, true);
    7669              : }
    7670              : 
    7671              : /* Return a representation of ELT_TYPE[NELTS], using indices of type
    7672              :    sizetype.  */
    7673              : 
    7674              : tree
    7675      1710856 : build_array_type_nelts (tree elt_type, poly_uint64 nelts)
    7676              : {
    7677      1710856 :   return build_array_type (elt_type, build_index_type (size_int (nelts - 1)));
    7678              : }
    7679              : 
    7680              : /* Computes the canonical argument types from the argument type list
    7681              :    ARGTYPES.
    7682              : 
    7683              :    Upon return, *ANY_STRUCTURAL_P will be true iff either it was true
    7684              :    on entry to this function, or if any of the ARGTYPES are
    7685              :    structural.
    7686              : 
    7687              :    Upon return, *ANY_NONCANONICAL_P will be true iff either it was
    7688              :    true on entry to this function, or if any of the ARGTYPES are
    7689              :    non-canonical.
    7690              : 
    7691              :    Returns a canonical argument list, which may be ARGTYPES when the
    7692              :    canonical argument list is unneeded (i.e., *ANY_STRUCTURAL_P is
    7693              :    true) or would not differ from ARGTYPES.  */
    7694              : 
    7695              : static tree
    7696   1022753973 : maybe_canonicalize_argtypes (tree argtypes,
    7697              :                              bool *any_structural_p,
    7698              :                              bool *any_noncanonical_p)
    7699              : {
    7700   1022753973 :   tree arg;
    7701   1022753973 :   bool any_noncanonical_argtypes_p = false;
    7702              : 
    7703   3534031419 :   for (arg = argtypes; arg && !(*any_structural_p); arg = TREE_CHAIN (arg))
    7704              :     {
    7705   2511277446 :       if (!TREE_VALUE (arg) || TREE_VALUE (arg) == error_mark_node)
    7706              :         /* Fail gracefully by stating that the type is structural.  */
    7707        15540 :         *any_structural_p = true;
    7708   2511261906 :       else if (TYPE_STRUCTURAL_EQUALITY_P (TREE_VALUE (arg)))
    7709     35069018 :         *any_structural_p = true;
    7710   2476192888 :       else if (TYPE_CANONICAL (TREE_VALUE (arg)) != TREE_VALUE (arg)
    7711   2476192888 :                || TREE_PURPOSE (arg))
    7712              :         /* If the argument has a default argument, we consider it
    7713              :            non-canonical even though the type itself is canonical.
    7714              :            That way, different variants of function and method types
    7715              :            with default arguments will all point to the variant with
    7716              :            no defaults as their canonical type.  */
    7717              :         any_noncanonical_argtypes_p = true;
    7718              :     }
    7719              : 
    7720   1022753973 :   if (*any_structural_p)
    7721              :     return argtypes;
    7722              : 
    7723    926087768 :   if (any_noncanonical_argtypes_p)
    7724              :     {
    7725              :       /* Build the canonical list of argument types.  */
    7726              :       tree canon_argtypes = NULL_TREE;
    7727              :       bool is_void = false;
    7728              : 
    7729    903028414 :       for (arg = argtypes; arg; arg = TREE_CHAIN (arg))
    7730              :         {
    7731    693059979 :           if (arg == void_list_node)
    7732              :             is_void = true;
    7733              :           else
    7734    968225006 :             canon_argtypes = tree_cons (NULL_TREE,
    7735    484112503 :                                         TYPE_CANONICAL (TREE_VALUE (arg)),
    7736              :                                         canon_argtypes);
    7737              :         }
    7738              : 
    7739    209968435 :       canon_argtypes = nreverse (canon_argtypes);
    7740    209968435 :       if (is_void)
    7741    208947476 :         canon_argtypes = chainon (canon_argtypes, void_list_node);
    7742              : 
    7743              :       /* There is a non-canonical type.  */
    7744    209968435 :       *any_noncanonical_p = true;
    7745    209968435 :       return canon_argtypes;
    7746              :     }
    7747              : 
    7748              :   /* The canonical argument types are the same as ARGTYPES.  */
    7749              :   return argtypes;
    7750              : }
    7751              : 
    7752              : /* Construct, lay out and return
    7753              :    the type of functions returning type VALUE_TYPE
    7754              :    given arguments of types ARG_TYPES.
    7755              :    ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs
    7756              :    are data type nodes for the arguments of the function.
    7757              :    NO_NAMED_ARGS_STDARG_P is true if this is a prototyped
    7758              :    variable-arguments function with (...) prototype (no named arguments).
    7759              :    If such a type has already been constructed, reuse it.  */
    7760              : 
    7761              : tree
    7762    676620651 : build_function_type (tree value_type, tree arg_types,
    7763              :                      bool no_named_args_stdarg_p)
    7764              : {
    7765    676620651 :   tree t;
    7766    676620651 :   inchash::hash hstate;
    7767    676620651 :   bool any_structural_p, any_noncanonical_p;
    7768    676620651 :   tree canon_argtypes;
    7769              : 
    7770    676620651 :   gcc_assert (arg_types != error_mark_node);
    7771              : 
    7772    676620651 :   if (TREE_CODE (value_type) == FUNCTION_TYPE)
    7773              :     {
    7774            0 :       error ("function return type cannot be function");
    7775            0 :       value_type = integer_type_node;
    7776              :     }
    7777              : 
    7778              :   /* Make a node of the sort we want.  */
    7779    676620651 :   t = make_node (FUNCTION_TYPE);
    7780    676620651 :   TREE_TYPE (t) = value_type;
    7781    676620651 :   TYPE_ARG_TYPES (t) = arg_types;
    7782    676620651 :   if (no_named_args_stdarg_p)
    7783              :     {
    7784      1189823 :       gcc_assert (arg_types == NULL_TREE);
    7785      1189823 :       TYPE_NO_NAMED_ARGS_STDARG_P (t) = 1;
    7786              :     }
    7787              : 
    7788              :   /* Set up the canonical type. */
    7789    676620651 :   any_structural_p   = TYPE_STRUCTURAL_EQUALITY_P (value_type);
    7790    676620651 :   any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
    7791    676620651 :   canon_argtypes = maybe_canonicalize_argtypes (arg_types,
    7792              :                                                 &any_structural_p,
    7793              :                                                 &any_noncanonical_p);
    7794              :   /* Set TYPE_STRUCTURAL_EQUALITY_P early.  */
    7795    676620651 :   if (any_structural_p)
    7796     69915335 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7797              : 
    7798              :   /* If we already have such a type, use the old one.  */
    7799    676620651 :   hashval_t hash = type_hash_canon_hash (t);
    7800    676620651 :   tree probe_type = t;
    7801    676620651 :   t = type_hash_canon (hash, t);
    7802    676620651 :   if (t != probe_type)
    7803              :     return t;
    7804              : 
    7805    436853413 :   if (any_structural_p)
    7806     56246769 :     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
    7807    380606644 :   else if (any_noncanonical_p)
    7808     89840269 :     TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
    7809              :                                               canon_argtypes,
    7810              :                                               no_named_args_stdarg_p);
    7811              : 
    7812    436853413 :   if (!COMPLETE_TYPE_P (t))
    7813            0 :     layout_type (t);
    7814              :   return t;
    7815              : }
    7816              : 
    7817              : /* Build a function type.  The RETURN_TYPE is the type returned by the
    7818              :    function.  If VAARGS is set, no void_type_node is appended to the
    7819              :    list.  ARGP must be always be terminated be a NULL_TREE.  */
    7820              : 
    7821              : static tree
    7822     15628955 : build_function_type_list_1 (bool vaargs, tree return_type, va_list argp)
    7823              : {
    7824     15628955 :   tree t, args, last;
    7825              : 
    7826     15628955 :   t = va_arg (argp, tree);
    7827     65689422 :   for (args = NULL_TREE; t != NULL_TREE; t = va_arg (argp, tree))
    7828     34431512 :     args = tree_cons (NULL_TREE, t, args);
    7829              : 
    7830     15628955 :   if (vaargs)
    7831              :     {
    7832      1071234 :       last = args;
    7833      1071234 :       if (args != NULL_TREE)
    7834       835520 :         args = nreverse (args);
    7835      1071234 :       gcc_assert (last != void_list_node);
    7836              :     }
    7837     14557721 :   else if (args == NULL_TREE)
    7838      1239255 :     args = void_list_node;
    7839              :   else
    7840              :     {
    7841     13318466 :       last = args;
    7842     13318466 :       args = nreverse (args);
    7843     13318466 :       TREE_CHAIN (last) = void_list_node;
    7844              :     }
    7845     15628955 :   args = build_function_type (return_type, args, vaargs && args == NULL_TREE);
    7846              : 
    7847     15628955 :   return args;
    7848              : }
    7849              : 
    7850              : /* Build a function type.  The RETURN_TYPE is the type returned by the
    7851              :    function.  If additional arguments are provided, they are
    7852              :    additional argument types.  The list of argument types must always
    7853              :    be terminated by NULL_TREE.  */
    7854              : 
    7855              : tree
    7856     14557721 : build_function_type_list (tree return_type, ...)
    7857              : {
    7858     14557721 :   tree args;
    7859     14557721 :   va_list p;
    7860              : 
    7861     14557721 :   va_start (p, return_type);
    7862     14557721 :   args = build_function_type_list_1 (false, return_type, p);
    7863     14557721 :   va_end (p);
    7864     14557721 :   return args;
    7865              : }
    7866              : 
    7867              : /* Build a variable argument function type.  The RETURN_TYPE is the
    7868              :    type returned by the function.  If additional arguments are provided,
    7869              :    they are additional argument types.  The list of argument types must
    7870              :    always be terminated by NULL_TREE.  */
    7871              : 
    7872              : tree
    7873      1071234 : build_varargs_function_type_list (tree return_type, ...)
    7874              : {
    7875      1071234 :   tree args;
    7876      1071234 :   va_list p;
    7877              : 
    7878      1071234 :   va_start (p, return_type);
    7879      1071234 :   args = build_function_type_list_1 (true, return_type, p);
    7880      1071234 :   va_end (p);
    7881              : 
    7882      1071234 :   return args;
    7883              : }
    7884              : 
    7885              : /* Build a function type.  RETURN_TYPE is the type returned by the
    7886              :    function; VAARGS indicates whether the function takes varargs.  The
    7887              :    function takes N named arguments, the types of which are provided in
    7888              :    ARG_TYPES.  */
    7889              : 
    7890              : static tree
    7891    122553944 : build_function_type_array_1 (bool vaargs, tree return_type, int n,
    7892              :                              tree *arg_types)
    7893              : {
    7894    122553944 :   int i;
    7895    122553944 :   tree t = vaargs ? NULL_TREE : void_list_node;
    7896              : 
    7897    400898516 :   for (i = n - 1; i >= 0; i--)
    7898    278344572 :     t = tree_cons (NULL_TREE, arg_types[i], t);
    7899              : 
    7900    122553944 :   return build_function_type (return_type, t, vaargs && n == 0);
    7901              : }
    7902              : 
    7903              : /* Build a function type.  RETURN_TYPE is the type returned by the
    7904              :    function.  The function takes N named arguments, the types of which
    7905              :    are provided in ARG_TYPES.  */
    7906              : 
    7907              : tree
    7908    116013002 : build_function_type_array (tree return_type, int n, tree *arg_types)
    7909              : {
    7910    116013002 :   return build_function_type_array_1 (false, return_type, n, arg_types);
    7911              : }
    7912              : 
    7913              : /* Build a variable argument function type.  RETURN_TYPE is the type
    7914              :    returned by the function.  The function takes N named arguments, the
    7915              :    types of which are provided in ARG_TYPES.  */
    7916              : 
    7917              : tree
    7918      6540942 : build_varargs_function_type_array (tree return_type, int n, tree *arg_types)
    7919              : {
    7920      6540942 :   return build_function_type_array_1 (true, return_type, n, arg_types);
    7921              : }
    7922              : 
    7923              : /* Build a METHOD_TYPE for a member of BASETYPE.  The RETTYPE (a TYPE)
    7924              :    and ARGTYPES (a TREE_LIST) are the return type and arguments types
    7925              :    for the method.  An implicit additional parameter (of type
    7926              :    pointer-to-BASETYPE) is added to the ARGTYPES.  */
    7927              : 
    7928              : tree
    7929    346133322 : build_method_type_directly (tree basetype,
    7930              :                             tree rettype,
    7931              :                             tree argtypes)
    7932              : {
    7933    346133322 :   tree t;
    7934    346133322 :   tree ptype;
    7935    346133322 :   bool any_structural_p, any_noncanonical_p;
    7936    346133322 :   tree canon_argtypes;
    7937              : 
    7938              :   /* Make a node of the sort we want.  */
    7939    346133322 :   t = make_node (METHOD_TYPE);
    7940              : 
    7941    346133322 :   TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
    7942    346133322 :   TREE_TYPE (t) = rettype;
    7943    346133322 :   ptype = build_pointer_type (basetype);
    7944              : 
    7945              :   /* The actual arglist for this function includes a "hidden" argument
    7946              :      which is "this".  Put it into the list of argument types.  */
    7947    346133322 :   argtypes = tree_cons (NULL_TREE, ptype, argtypes);
    7948    346133322 :   TYPE_ARG_TYPES (t) = argtypes;
    7949              : 
    7950              :   /* Set up the canonical type. */
    7951    346133322 :   any_structural_p
    7952    346133322 :     = (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    7953    346133322 :        || TYPE_STRUCTURAL_EQUALITY_P (rettype));
    7954    346133322 :   any_noncanonical_p
    7955    346133322 :     = (TYPE_CANONICAL (basetype) != basetype
    7956    346133322 :        || TYPE_CANONICAL (rettype) != rettype);
    7957    346133322 :   canon_argtypes = maybe_canonicalize_argtypes (TREE_CHAIN (argtypes),
    7958              :                                                 &any_structural_p,
    7959              :                                                 &any_noncanonical_p);
    7960              : 
    7961              :   /* Set TYPE_STRUCTURAL_EQUALITY_P early.  */
    7962    346133322 :   if (any_structural_p)
    7963     26750870 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    7964              : 
    7965              :   /* If we already have such a type, use the old one.  */
    7966    346133322 :   hashval_t hash = type_hash_canon_hash (t);
    7967    346133322 :   tree probe_type = t;
    7968    346133322 :   t = type_hash_canon (hash, t);
    7969    346133322 :   if (t != probe_type)
    7970              :     return t;
    7971              : 
    7972    266875944 :   if (any_structural_p)
    7973     22577094 :     gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
    7974    244298850 :   else if (any_noncanonical_p)
    7975     89931780 :     TYPE_CANONICAL (t)
    7976    179863560 :       = build_method_type_directly (TYPE_CANONICAL (basetype),
    7977     89931780 :                                     TYPE_CANONICAL (rettype),
    7978              :                                     canon_argtypes);
    7979    266875944 :   if (!COMPLETE_TYPE_P (t))
    7980            0 :     layout_type (t);
    7981              : 
    7982              :   return t;
    7983              : }
    7984              : 
    7985              : /* Construct, lay out and return the type of methods belonging to class
    7986              :    BASETYPE and whose arguments and values are described by TYPE.
    7987              :    If that type exists already, reuse it.
    7988              :    TYPE must be a FUNCTION_TYPE node.  */
    7989              : 
    7990              : tree
    7991            0 : build_method_type (tree basetype, tree type)
    7992              : {
    7993            0 :   gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
    7994              : 
    7995            0 :   return build_method_type_directly (basetype,
    7996            0 :                                      TREE_TYPE (type),
    7997            0 :                                      TYPE_ARG_TYPES (type));
    7998              : }
    7999              : 
    8000              : /* Construct, lay out and return the type of offsets to a value
    8001              :    of type TYPE, within an object of type BASETYPE.
    8002              :    If a suitable offset type exists already, reuse it.  */
    8003              : 
    8004              : tree
    8005       995917 : build_offset_type (tree basetype, tree type)
    8006              : {
    8007       995917 :   tree t;
    8008              : 
    8009              :   /* Make a node of the sort we want.  */
    8010       995917 :   t = make_node (OFFSET_TYPE);
    8011              : 
    8012       995917 :   TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
    8013       995917 :   TREE_TYPE (t) = type;
    8014       995917 :   if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    8015       995917 :       || TYPE_STRUCTURAL_EQUALITY_P (type))
    8016            4 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    8017              : 
    8018              :   /* If we already have such a type, use the old one.  */
    8019       995917 :   hashval_t hash = type_hash_canon_hash (t);
    8020       995917 :   tree probe_type = t;
    8021       995917 :   t = type_hash_canon (hash, t);
    8022       995917 :   if (t != probe_type)
    8023              :     return t;
    8024              : 
    8025       241476 :   if (!COMPLETE_TYPE_P (t))
    8026            0 :     layout_type (t);
    8027              : 
    8028       241476 :   if (TYPE_CANONICAL (t) == t)
    8029              :     {
    8030       241472 :       if (TYPE_STRUCTURAL_EQUALITY_P (basetype)
    8031       241472 :           || TYPE_STRUCTURAL_EQUALITY_P (type))
    8032            0 :         gcc_unreachable ();
    8033       241472 :       else if (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)) != basetype
    8034       241472 :                || TYPE_CANONICAL (type) != type)
    8035       138391 :         TYPE_CANONICAL (t)
    8036       276782 :           = build_offset_type (TYPE_CANONICAL (TYPE_MAIN_VARIANT (basetype)),
    8037       138391 :                                TYPE_CANONICAL (type));
    8038              :     }
    8039              : 
    8040              :   return t;
    8041              : }
    8042              : 
    8043              : /* Create a complex type whose components are COMPONENT_TYPE.
    8044              : 
    8045              :    If NAMED is true, the type is given a TYPE_NAME.  We do not always
    8046              :    do so because this creates a DECL node and thus make the DECL_UIDs
    8047              :    dependent on the type canonicalization hashtable, which is GC-ed,
    8048              :    so the DECL_UIDs would not be stable wrt garbage collection.  */
    8049              : 
    8050              : tree
    8051      5463603 : build_complex_type (tree component_type, bool named)
    8052              : {
    8053      5463603 :   gcc_assert (INTEGRAL_TYPE_P (component_type)
    8054              :               || SCALAR_FLOAT_TYPE_P (component_type)
    8055              :               || FIXED_POINT_TYPE_P (component_type));
    8056              : 
    8057              :   /* Make a node of the sort we want.  */
    8058      5463603 :   tree probe = make_node (COMPLEX_TYPE);
    8059              : 
    8060      5463603 :   TREE_TYPE (probe) = TYPE_MAIN_VARIANT (component_type);
    8061      5463603 :   if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (probe)))
    8062            0 :     SET_TYPE_STRUCTURAL_EQUALITY (probe);
    8063              : 
    8064              :   /* If we already have such a type, use the old one.  */
    8065      5463603 :   hashval_t hash = type_hash_canon_hash (probe);
    8066      5463603 :   tree t = type_hash_canon (hash, probe);
    8067              : 
    8068      5463603 :   if (t == probe)
    8069              :     {
    8070              :       /* We created a new type.  The hash insertion will have laid
    8071              :          out the type.  We need to check the canonicalization and
    8072              :          maybe set the name.  */
    8073      3208835 :       gcc_checking_assert (COMPLETE_TYPE_P (t)
    8074              :                            && !TYPE_NAME (t));
    8075              : 
    8076      3208835 :       if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)))
    8077              :         ;
    8078      3208835 :       else if (TYPE_CANONICAL (TREE_TYPE (t)) != TREE_TYPE (t))
    8079          105 :         TYPE_CANONICAL (t)
    8080          210 :           = build_complex_type (TYPE_CANONICAL (TREE_TYPE (t)), named);
    8081              : 
    8082              :       /* We need to create a name, since complex is a fundamental type.  */
    8083      3208835 :       if (named)
    8084              :         {
    8085      1177124 :           const char *name = NULL;
    8086              : 
    8087      1177124 :           if (TREE_TYPE (t) == char_type_node)
    8088              :             name = "complex char";
    8089      1177124 :           else if (TREE_TYPE (t) == signed_char_type_node)
    8090              :             name = "complex signed char";
    8091      1177124 :           else if (TREE_TYPE (t) == unsigned_char_type_node)
    8092              :             name = "complex unsigned char";
    8093      1177124 :           else if (TREE_TYPE (t) == short_integer_type_node)
    8094              :             name = "complex short int";
    8095      1177124 :           else if (TREE_TYPE (t) == short_unsigned_type_node)
    8096              :             name = "complex short unsigned int";
    8097      1177124 :           else if (TREE_TYPE (t) == integer_type_node)
    8098              :             name = "complex int";
    8099       882843 :           else if (TREE_TYPE (t) == unsigned_type_node)
    8100              :             name = "complex unsigned int";
    8101       882843 :           else if (TREE_TYPE (t) == long_integer_type_node)
    8102              :             name = "complex long int";
    8103       882843 :           else if (TREE_TYPE (t) == long_unsigned_type_node)
    8104              :             name = "complex long unsigned int";
    8105       882843 :           else if (TREE_TYPE (t) == long_long_integer_type_node)
    8106              :             name = "complex long long int";
    8107       882843 :           else if (TREE_TYPE (t) == long_long_unsigned_type_node)
    8108              :             name = "complex long long unsigned int";
    8109              : 
    8110              :           if (name != NULL)
    8111       294281 :             TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
    8112              :                                         get_identifier (name), t);
    8113              :         }
    8114              :     }
    8115              : 
    8116      5463603 :   return build_qualified_type (t, TYPE_QUALS (component_type));
    8117              : }
    8118              : 
    8119              : /* If TYPE is a real or complex floating-point type and the target
    8120              :    does not directly support arithmetic on TYPE then return the wider
    8121              :    type to be used for arithmetic on TYPE.  Otherwise, return
    8122              :    NULL_TREE.  */
    8123              : 
    8124              : tree
    8125     91063883 : excess_precision_type (tree type)
    8126              : {
    8127              :   /* The target can give two different responses to the question of
    8128              :      which excess precision mode it would like depending on whether we
    8129              :      are in -fexcess-precision=standard or -fexcess-precision=fast.  */
    8130              : 
    8131      3551685 :   enum excess_precision_type requested_type
    8132     91063883 :     = (flag_excess_precision == EXCESS_PRECISION_FAST
    8133     91063883 :        ? EXCESS_PRECISION_TYPE_FAST
    8134              :        : (flag_excess_precision == EXCESS_PRECISION_FLOAT16
    8135      3552411 :           ? EXCESS_PRECISION_TYPE_FLOAT16 : EXCESS_PRECISION_TYPE_STANDARD));
    8136              : 
    8137     91063883 :   enum flt_eval_method target_flt_eval_method
    8138     91063883 :     = targetm.c.excess_precision (requested_type);
    8139              : 
    8140              :   /* The target should not ask for unpredictable float evaluation (though
    8141              :      it might advertise that implicitly the evaluation is unpredictable,
    8142              :      but we don't care about that here, it will have been reported
    8143              :      elsewhere).  If it does ask for unpredictable evaluation, we have
    8144              :      nothing to do here.  */
    8145     91063883 :   gcc_assert (target_flt_eval_method != FLT_EVAL_METHOD_UNPREDICTABLE);
    8146              : 
    8147              :   /* Nothing to do.  The target has asked for all types we know about
    8148              :      to be computed with their native precision and range.  */
    8149     91063883 :   if (target_flt_eval_method == FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16)
    8150              :     return NULL_TREE;
    8151              : 
    8152              :   /* The target will promote this type in a target-dependent way, so excess
    8153              :      precision ought to leave it alone.  */
    8154     89429761 :   if (targetm.promoted_type (type) != NULL_TREE)
    8155              :     return NULL_TREE;
    8156              : 
    8157     89429761 :   machine_mode float16_type_mode = (float16_type_node
    8158     89429761 :                                     ? TYPE_MODE (float16_type_node)
    8159     89429761 :                                     : VOIDmode);
    8160     89429761 :   machine_mode bfloat16_type_mode = (bfloat16_type_node
    8161     89429761 :                                      ? TYPE_MODE (bfloat16_type_node)
    8162     89429761 :                                      : VOIDmode);
    8163     89429761 :   machine_mode float_type_mode = TYPE_MODE (float_type_node);
    8164     89429761 :   machine_mode double_type_mode = TYPE_MODE (double_type_node);
    8165              : 
    8166     89429761 :   switch (TREE_CODE (type))
    8167              :     {
    8168     60894749 :     case REAL_TYPE:
    8169     60894749 :       {
    8170     60894749 :         machine_mode type_mode = TYPE_MODE (type);
    8171     60894749 :         switch (target_flt_eval_method)
    8172              :           {
    8173     60881916 :           case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT:
    8174     60881916 :             if (type_mode == float16_type_mode
    8175     60881916 :                 || type_mode == bfloat16_type_mode)
    8176       281475 :               return float_type_node;
    8177              :             break;
    8178            0 :           case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE:
    8179            0 :             if (type_mode == float16_type_mode
    8180            0 :                 || type_mode == bfloat16_type_mode
    8181            0 :                 || type_mode == float_type_mode)
    8182            0 :               return double_type_node;
    8183              :             break;
    8184        12833 :           case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE:
    8185        12833 :             if (type_mode == float16_type_mode
    8186        12833 :                 || type_mode == bfloat16_type_mode
    8187        12828 :                 || type_mode == float_type_mode
    8188        12828 :                 || type_mode == double_type_mode)
    8189        12384 :               return long_double_type_node;
    8190              :             break;
    8191            0 :           default:
    8192            0 :             gcc_unreachable ();
    8193              :           }
    8194              :         break;
    8195              :       }
    8196       380414 :     case COMPLEX_TYPE:
    8197       380414 :       {
    8198       380414 :         if (TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    8199              :           return NULL_TREE;
    8200       370891 :         machine_mode type_mode = TYPE_MODE (TREE_TYPE (type));
    8201       370891 :         switch (target_flt_eval_method)
    8202              :           {
    8203       370558 :           case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT:
    8204       370558 :             if (type_mode == float16_type_mode
    8205       370558 :                 || type_mode == bfloat16_type_mode)
    8206          281 :               return complex_float_type_node;
    8207              :             break;
    8208            0 :           case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE:
    8209            0 :             if (type_mode == float16_type_mode
    8210            0 :                 || type_mode == bfloat16_type_mode
    8211            0 :                 || type_mode == float_type_mode)
    8212            0 :               return complex_double_type_node;
    8213              :             break;
    8214          333 :           case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE:
    8215          333 :             if (type_mode == float16_type_mode
    8216          333 :                 || type_mode == bfloat16_type_mode
    8217          333 :                 || type_mode == float_type_mode
    8218          333 :                 || type_mode == double_type_mode)
    8219          281 :               return complex_long_double_type_node;
    8220              :             break;
    8221            0 :           default:
    8222            0 :             gcc_unreachable ();
    8223              :           }
    8224              :         break;
    8225              :       }
    8226              :     default:
    8227              :       break;
    8228              :     }
    8229              : 
    8230              :   return NULL_TREE;
    8231              : }
    8232              : 
    8233              : /* Return OP, stripped of any conversions to wider types as much as is safe.
    8234              :    Converting the value back to OP's type makes a value equivalent to OP.
    8235              : 
    8236              :    If FOR_TYPE is nonzero, we return a value which, if converted to
    8237              :    type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE.
    8238              : 
    8239              :    OP must have integer, real or enumeral type.  Pointers are not allowed!
    8240              : 
    8241              :    There are some cases where the obvious value we could return
    8242              :    would regenerate to OP if converted to OP's type,
    8243              :    but would not extend like OP to wider types.
    8244              :    If FOR_TYPE indicates such extension is contemplated, we eschew such values.
    8245              :    For example, if OP is (unsigned short)(signed char)-1,
    8246              :    we avoid returning (signed char)-1 if FOR_TYPE is int,
    8247              :    even though extending that to an unsigned short would regenerate OP,
    8248              :    since the result of extending (signed char)-1 to (int)
    8249              :    is different from (int) OP.  */
    8250              : 
    8251              : tree
    8252     11760134 : get_unwidened (tree op, tree for_type)
    8253              : {
    8254              :   /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension.  */
    8255     11760134 :   tree type = TREE_TYPE (op);
    8256     11760134 :   unsigned final_prec
    8257     19616205 :     = TYPE_PRECISION (for_type != 0 ? for_type : type);
    8258     11760134 :   int uns
    8259     11760134 :     = (for_type != 0 && for_type != type
    8260      3492587 :        && final_prec > TYPE_PRECISION (type)
    8261     12009219 :        && TYPE_UNSIGNED (type));
    8262     11760134 :   tree win = op;
    8263              : 
    8264     12133077 :   while (CONVERT_EXPR_P (op))
    8265              :     {
    8266       373036 :       int bitschange;
    8267              : 
    8268              :       /* TYPE_PRECISION on vector types has different meaning
    8269              :          (TYPE_VECTOR_SUBPARTS) and casts from vectors are view conversions,
    8270              :          so avoid them here.  */
    8271       373036 :       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == VECTOR_TYPE)
    8272              :         break;
    8273              : 
    8274       373036 :       bitschange = TYPE_PRECISION (TREE_TYPE (op))
    8275       373036 :                    - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
    8276              : 
    8277              :       /* Truncations are many-one so cannot be removed.
    8278              :          Unless we are later going to truncate down even farther.  */
    8279       373036 :       if (bitschange < 0
    8280       373036 :           && final_prec > TYPE_PRECISION (TREE_TYPE (op)))
    8281              :         break;
    8282              : 
    8283              :       /* See what's inside this conversion.  If we decide to strip it,
    8284              :          we will set WIN.  */
    8285       372943 :       op = TREE_OPERAND (op, 0);
    8286              : 
    8287              :       /* If we have not stripped any zero-extensions (uns is 0),
    8288              :          we can strip any kind of extension.
    8289              :          If we have previously stripped a zero-extension,
    8290              :          only zero-extensions can safely be stripped.
    8291              :          Any extension can be stripped if the bits it would produce
    8292              :          are all going to be discarded later by truncating to FOR_TYPE.  */
    8293              : 
    8294       372943 :       if (bitschange > 0)
    8295              :         {
    8296       229086 :           if (! uns || final_prec <= TYPE_PRECISION (TREE_TYPE (op)))
    8297              :             win = op;
    8298              :           /* TYPE_UNSIGNED says whether this is a zero-extension.
    8299              :              Let's avoid computing it if it does not affect WIN
    8300              :              and if UNS will not be needed again.  */
    8301       229086 :           if ((uns
    8302       229055 :                || CONVERT_EXPR_P (op))
    8303       229787 :               && TYPE_UNSIGNED (TREE_TYPE (op)))
    8304              :             {
    8305              :               uns = 1;
    8306              :               win = op;
    8307              :             }
    8308              :         }
    8309              :     }
    8310              : 
    8311              :   /* If we finally reach a constant see if it fits in sth smaller and
    8312              :      in that case convert it.  */
    8313     11760134 :   if (TREE_CODE (win) == INTEGER_CST)
    8314              :     {
    8315       575009 :       tree wtype = TREE_TYPE (win);
    8316       575009 :       unsigned prec = wi::min_precision (wi::to_wide (win), TYPE_SIGN (wtype));
    8317       575009 :       if (for_type)
    8318       563191 :         prec = MAX (prec, final_prec);
    8319       575009 :       if (prec < TYPE_PRECISION (wtype))
    8320              :         {
    8321       570496 :           tree t = lang_hooks.types.type_for_size (prec, TYPE_UNSIGNED (wtype));
    8322       570496 :           if (t && TYPE_PRECISION (t) < TYPE_PRECISION (wtype))
    8323       558671 :             win = fold_convert (t, win);
    8324              :         }
    8325              :     }
    8326              : 
    8327     11760134 :   return win;
    8328              : }
    8329              : 
    8330              : /* Return OP or a simpler expression for a narrower value
    8331              :    which can be sign-extended or zero-extended to give back OP.
    8332              :    Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
    8333              :    or 0 if the value should be sign-extended.  */
    8334              : 
    8335              : tree
    8336     86039666 : get_narrower (tree op, int *unsignedp_ptr)
    8337              : {
    8338     86039666 :   int uns = 0;
    8339     86039666 :   bool first = true;
    8340     86039666 :   tree win = op;
    8341     86039666 :   bool integral_p = INTEGRAL_TYPE_P (TREE_TYPE (op));
    8342              : 
    8343     86039666 :   if (TREE_CODE (op) == COMPOUND_EXPR)
    8344              :     {
    8345        90899 :       do
    8346        90899 :         op = TREE_OPERAND (op, 1);
    8347        90899 :       while (TREE_CODE (op) == COMPOUND_EXPR);
    8348        90884 :       tree ret = get_narrower (op, unsignedp_ptr);
    8349        90884 :       if (ret == op)
    8350              :         return win;
    8351         4262 :       auto_vec <tree, 16> v;
    8352         4262 :       unsigned int i;
    8353         8531 :       for (op = win; TREE_CODE (op) == COMPOUND_EXPR;
    8354         4269 :            op = TREE_OPERAND (op, 1))
    8355         4269 :         v.safe_push (op);
    8356        17055 :       FOR_EACH_VEC_ELT_REVERSE (v, i, op)
    8357         4269 :         ret = build2_loc (EXPR_LOCATION (op), COMPOUND_EXPR,
    8358         4269 :                           TREE_TYPE (ret), TREE_OPERAND (op, 0),
    8359              :                           ret);
    8360         4262 :       return ret;
    8361         4262 :     }
    8362    102470057 :   while (TREE_CODE (op) == NOP_EXPR)
    8363              :     {
    8364     16554487 :       int bitschange
    8365     16554487 :         = (TYPE_PRECISION (TREE_TYPE (op))
    8366     16554487 :            - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0))));
    8367              : 
    8368              :       /* Truncations are many-one so cannot be removed.  */
    8369     16554487 :       if (bitschange < 0)
    8370              :         break;
    8371              : 
    8372              :       /* See what's inside this conversion.  If we decide to strip it,
    8373              :          we will set WIN.  */
    8374              : 
    8375     16521371 :       if (bitschange > 0)
    8376              :         {
    8377      3906134 :           op = TREE_OPERAND (op, 0);
    8378              :           /* An extension: the outermost one can be stripped,
    8379              :              but remember whether it is zero or sign extension.  */
    8380      3906134 :           if (first)
    8381      3895162 :             uns = TYPE_UNSIGNED (TREE_TYPE (op));
    8382              :           /* Otherwise, if a sign extension has been stripped,
    8383              :              only sign extensions can now be stripped;
    8384              :              if a zero extension has been stripped, only zero-extensions.  */
    8385        10972 :           else if (uns != TYPE_UNSIGNED (TREE_TYPE (op)))
    8386              :             break;
    8387              :           first = false;
    8388              :         }
    8389              :       else /* bitschange == 0 */
    8390              :         {
    8391              :           /* A change in nominal type can always be stripped, but we must
    8392              :              preserve the unsignedness.  */
    8393     12615237 :           if (first)
    8394     12012679 :             uns = TYPE_UNSIGNED (TREE_TYPE (op));
    8395     12615237 :           first = false;
    8396     12615237 :           op = TREE_OPERAND (op, 0);
    8397              :           /* Keep trying to narrow, but don't assign op to win if it
    8398              :              would turn an integral type into something else.  */
    8399     23458178 :           if (INTEGRAL_TYPE_P (TREE_TYPE (op)) != integral_p)
    8400        99735 :             continue;
    8401              :         }
    8402              : 
    8403     16421540 :       win = op;
    8404              :     }
    8405              : 
    8406     85948782 :   if (TREE_CODE (op) == COMPONENT_REF
    8407              :       /* Since type_for_size always gives an integer type.  */
    8408      3013941 :       && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE
    8409      2911336 :       && TREE_CODE (TREE_TYPE (op)) != FIXED_POINT_TYPE
    8410              :       /* Ensure field is laid out already.  */
    8411      2911336 :       && DECL_SIZE (TREE_OPERAND (op, 1)) != 0
    8412     88860115 :       && tree_fits_uhwi_p (DECL_SIZE (TREE_OPERAND (op, 1))))
    8413              :     {
    8414      2911333 :       unsigned HOST_WIDE_INT innerprec
    8415      2911333 :         = tree_to_uhwi (DECL_SIZE (TREE_OPERAND (op, 1)));
    8416      2911333 :       int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
    8417      2911333 :                        || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
    8418      2911333 :       tree type = lang_hooks.types.type_for_size (innerprec, unsignedp);
    8419              : 
    8420              :       /* We can get this structure field in a narrower type that fits it,
    8421              :          but the resulting extension to its nominal type (a fullword type)
    8422              :          must satisfy the same conditions as for other extensions.
    8423              : 
    8424              :          Do this only for fields that are aligned (not bit-fields),
    8425              :          because when bit-field insns will be used there is no
    8426              :          advantage in doing this.  */
    8427              : 
    8428      2911333 :       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
    8429            0 :           && ! DECL_BIT_FIELD (TREE_OPERAND (op, 1))
    8430            0 :           && (first || uns == DECL_UNSIGNED (TREE_OPERAND (op, 1)))
    8431      2911333 :           && type != 0)
    8432              :         {
    8433            0 :           if (first)
    8434            0 :             uns = DECL_UNSIGNED (TREE_OPERAND (op, 1));
    8435            0 :           win = fold_convert (type, op);
    8436              :         }
    8437              :     }
    8438              : 
    8439     85948782 :   *unsignedp_ptr = uns;
    8440     85948782 :   return win;
    8441              : }
    8442              : 
    8443              : /* Return true if integer constant C has a value that is permissible
    8444              :    for TYPE, an integral type.  */
    8445              : 
    8446              : bool
    8447    199386978 : int_fits_type_p (const_tree c, const_tree type)
    8448              : {
    8449    199386978 :   tree type_low_bound, type_high_bound;
    8450    199386978 :   bool ok_for_low_bound, ok_for_high_bound;
    8451    199386978 :   signop sgn_c = TYPE_SIGN (TREE_TYPE (c));
    8452              : 
    8453              :   /* Non-standard boolean types can have arbitrary precision but various
    8454              :      transformations assume that they can only take values 0 and +/-1.  */
    8455    199386978 :   if (TREE_CODE (type) == BOOLEAN_TYPE)
    8456      1283431 :     return wi::fits_to_boolean_p (wi::to_wide (c), type);
    8457              : 
    8458    198103547 : retry:
    8459    198115394 :   type_low_bound = TYPE_MIN_VALUE (type);
    8460    198115394 :   type_high_bound = TYPE_MAX_VALUE (type);
    8461              : 
    8462              :   /* If at least one bound of the type is a constant integer, we can check
    8463              :      ourselves and maybe make a decision. If no such decision is possible, but
    8464              :      this type is a subtype, try checking against that.  Otherwise, use
    8465              :      fits_to_tree_p, which checks against the precision.
    8466              : 
    8467              :      Compute the status for each possibly constant bound, and return if we see
    8468              :      one does not match. Use ok_for_xxx_bound for this purpose, assigning -1
    8469              :      for "unknown if constant fits", 0 for "constant known *not* to fit" and 1
    8470              :      for "constant known to fit".  */
    8471              : 
    8472              :   /* Check if c >= type_low_bound.  */
    8473    198115394 :   if (type_low_bound && TREE_CODE (type_low_bound) == INTEGER_CST)
    8474              :     {
    8475    198115394 :       if (tree_int_cst_lt (c, type_low_bound))
    8476              :         return false;
    8477              :       ok_for_low_bound = true;
    8478              :     }
    8479              :   else
    8480              :     ok_for_low_bound = false;
    8481              : 
    8482              :   /* Check if c <= type_high_bound.  */
    8483    197860147 :   if (type_high_bound && TREE_CODE (type_high_bound) == INTEGER_CST)
    8484              :     {
    8485    197828555 :       if (tree_int_cst_lt (type_high_bound, c))
    8486              :         return false;
    8487              :       ok_for_high_bound = true;
    8488              :     }
    8489              :   else
    8490              :     ok_for_high_bound = false;
    8491              : 
    8492              :   /* If the constant fits both bounds, the result is known.  */
    8493    195902460 :   if (ok_for_low_bound && ok_for_high_bound)
    8494              :     return true;
    8495              : 
    8496              :   /* Perform some generic filtering which may allow making a decision
    8497              :      even if the bounds are not constant.  First, negative integers
    8498              :      never fit in unsigned types, */
    8499        31592 :   if (TYPE_UNSIGNED (type) && sgn_c == SIGNED && wi::neg_p (wi::to_wide (c)))
    8500            0 :     return false;
    8501              : 
    8502              :   /* Second, narrower types always fit in wider ones.  */
    8503        31592 :   if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c)))
    8504              :     return true;
    8505              : 
    8506              :   /* Third, unsigned integers with top bit set never fit signed types.  */
    8507        11856 :   if (!TYPE_UNSIGNED (type) && sgn_c == UNSIGNED)
    8508              :     {
    8509           14 :       int prec = GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (c))) - 1;
    8510           14 :       if (prec < TYPE_PRECISION (TREE_TYPE (c)))
    8511              :         {
    8512              :           /* When a tree_cst is converted to a wide-int, the precision
    8513              :              is taken from the type.  However, if the precision of the
    8514              :              mode underneath the type is smaller than that, it is
    8515              :              possible that the value will not fit.  The test below
    8516              :              fails if any bit is set between the sign bit of the
    8517              :              underlying mode and the top bit of the type.  */
    8518           14 :           if (wi::zext (wi::to_wide (c), prec - 1) != wi::to_wide (c))
    8519              :             return false;
    8520              :         }
    8521            0 :       else if (wi::neg_p (wi::to_wide (c)))
    8522              :         return false;
    8523              :     }
    8524              : 
    8525              :   /* If we haven't been able to decide at this point, there nothing more we
    8526              :      can check ourselves here.  Look at the base type if we have one and it
    8527              :      has the same precision.  */
    8528        11847 :   if (TREE_CODE (type) == INTEGER_TYPE
    8529        11847 :       && TREE_TYPE (type) != 0
    8530        23694 :       && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (type)))
    8531              :     {
    8532        11847 :       type = TREE_TYPE (type);
    8533        11847 :       goto retry;
    8534              :     }
    8535              : 
    8536              :   /* Or to fits_to_tree_p, if nothing else.  */
    8537            0 :   return wi::fits_to_tree_p (wi::to_wide (c), type);
    8538              : }
    8539              : 
    8540              : /* Stores bounds of an integer TYPE in MIN and MAX.  If TYPE has non-constant
    8541              :    bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be
    8542              :    represented (assuming two's-complement arithmetic) within the bit
    8543              :    precision of the type are returned instead.  */
    8544              : 
    8545              : void
    8546     23220133 : get_type_static_bounds (const_tree type, mpz_t min, mpz_t max)
    8547              : {
    8548     21695318 :   if (!POINTER_TYPE_P (type) && TYPE_MIN_VALUE (type)
    8549     44915451 :       && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
    8550     21695318 :     wi::to_mpz (wi::to_wide (TYPE_MIN_VALUE (type)), min, TYPE_SIGN (type));
    8551              :   else
    8552              :     {
    8553      1524815 :       if (TYPE_UNSIGNED (type))
    8554      1524815 :         mpz_set_ui (min, 0);
    8555              :       else
    8556              :         {
    8557            0 :           wide_int mn = wi::min_value (TYPE_PRECISION (type), SIGNED);
    8558            0 :           wi::to_mpz (mn, min, SIGNED);
    8559            0 :         }
    8560              :     }
    8561              : 
    8562     21695318 :   if (!POINTER_TYPE_P (type) && TYPE_MAX_VALUE (type)
    8563     44915451 :       && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
    8564     21695318 :     wi::to_mpz (wi::to_wide (TYPE_MAX_VALUE (type)), max, TYPE_SIGN (type));
    8565              :   else
    8566              :     {
    8567      1524815 :       wide_int mn = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
    8568      1524815 :       wi::to_mpz (mn, max, TYPE_SIGN (type));
    8569      1524815 :     }
    8570     23220133 : }
    8571              : 
    8572              : /* Return true if VAR is an automatic variable.  */
    8573              : 
    8574              : bool
    8575   1247331185 : auto_var_p (const_tree var)
    8576              : {
    8577   1029678615 :   return ((((VAR_P (var) && ! DECL_EXTERNAL (var))
    8578    223179466 :             || TREE_CODE (var) == PARM_DECL)
    8579   1124644552 :            && ! TREE_STATIC (var))
    8580   1396912677 :           || TREE_CODE (var) == RESULT_DECL);
    8581              : }
    8582              : 
    8583              : /* Return true if VAR is an automatic variable defined in function FN.  */
    8584              : 
    8585              : bool
    8586   1866627795 : auto_var_in_fn_p (const_tree var, const_tree fn)
    8587              : {
    8588    632891797 :   return (DECL_P (var) && DECL_CONTEXT (var) == fn
    8589   2274171880 :           && (auto_var_p (var)
    8590      6342587 :               || TREE_CODE (var) == LABEL_DECL));
    8591              : }
    8592              : 
    8593              : /* Subprogram of following function.  Called by walk_tree.
    8594              : 
    8595              :    Return *TP if it is an automatic variable or parameter of the
    8596              :    function passed in as DATA.  */
    8597              : 
    8598              : static tree
    8599       126371 : find_var_from_fn (tree *tp, int *walk_subtrees, void *data)
    8600              : {
    8601       126371 :   tree fn = (tree) data;
    8602              : 
    8603       126371 :   if (TYPE_P (*tp))
    8604            0 :     *walk_subtrees = 0;
    8605              : 
    8606       126371 :   else if (DECL_P (*tp)
    8607       126371 :            && auto_var_in_fn_p (*tp, fn))
    8608       117892 :     return *tp;
    8609              : 
    8610              :   return NULL_TREE;
    8611              : }
    8612              : 
    8613              : /* Returns true if T is, contains, or refers to a type with variable
    8614              :    size.  For METHOD_TYPEs and FUNCTION_TYPEs we exclude the
    8615              :    arguments, but not the return type.  If FN is nonzero, only return
    8616              :    true if a modifier of the type or position of FN is a variable or
    8617              :    parameter inside FN.
    8618              : 
    8619              :    This concept is more general than that of C99 'variably modified types':
    8620              :    in C99, a struct type is never variably modified because a VLA may not
    8621              :    appear as a structure member.  However, in GNU C code like:
    8622              : 
    8623              :      struct S { int i[f()]; };
    8624              : 
    8625              :    is valid, and other languages may define similar constructs.  */
    8626              : 
    8627              : bool
    8628   2469081946 : variably_modified_type_p (tree type, tree fn)
    8629              : {
    8630   2469081946 :   tree t;
    8631              : 
    8632              : /* Test if T is either variable (if FN is zero) or an expression containing
    8633              :    a variable in FN.  If TYPE isn't gimplified, return true also if
    8634              :    gimplify_one_sizepos would gimplify the expression into a local
    8635              :    variable.  */
    8636              : #define RETURN_TRUE_IF_VAR(T)                                           \
    8637              :   do { tree _t = (T);                                                   \
    8638              :     if (_t != NULL_TREE                                                 \
    8639              :         && _t != error_mark_node                                        \
    8640              :         && !CONSTANT_CLASS_P (_t)                                       \
    8641              :         && TREE_CODE (_t) != PLACEHOLDER_EXPR                           \
    8642              :         && (!fn                                                         \
    8643              :             || (!TYPE_SIZES_GIMPLIFIED (type)                           \
    8644              :                 && (TREE_CODE (_t) != VAR_DECL                          \
    8645              :                     && !CONTAINS_PLACEHOLDER_P (_t)))                   \
    8646              :             || walk_tree (&_t, find_var_from_fn, fn, NULL)))                \
    8647              :       return true;  } while (0)
    8648              : 
    8649   2469081946 :   if (type == error_mark_node)
    8650              :     return false;
    8651              : 
    8652              :   /* If TYPE itself has variable size, it is variably modified.  */
    8653   2469081562 :   RETURN_TRUE_IF_VAR (TYPE_SIZE (type));
    8654   2468941557 :   RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT (type));
    8655              : 
    8656   2468940933 :   switch (TREE_CODE (type))
    8657              :     {
    8658    661672263 :     case POINTER_TYPE:
    8659    661672263 :     case REFERENCE_TYPE:
    8660    661672263 :     case VECTOR_TYPE:
    8661              :       /* Ada can have pointer types referring to themselves indirectly.  */
    8662    661672263 :       if (TREE_VISITED (type))
    8663              :         return false;
    8664    661672263 :       TREE_VISITED (type) = true;
    8665    661672263 :       if (variably_modified_type_p (TREE_TYPE (type), fn))
    8666              :         {
    8667        80690 :           TREE_VISITED (type) = false;
    8668        80690 :           return true;
    8669              :         }
    8670    661591573 :       TREE_VISITED (type) = false;
    8671    661591573 :       break;
    8672              : 
    8673    140615547 :     case FUNCTION_TYPE:
    8674    140615547 :     case METHOD_TYPE:
    8675              :       /* If TYPE is a function type, it is variably modified if the
    8676              :          return type is variably modified.  */
    8677    140615547 :       if (variably_modified_type_p (TREE_TYPE (type), fn))
    8678              :           return true;
    8679              :       break;
    8680              : 
    8681    608514033 :     case INTEGER_TYPE:
    8682    608514033 :     case REAL_TYPE:
    8683    608514033 :     case FIXED_POINT_TYPE:
    8684    608514033 :     case ENUMERAL_TYPE:
    8685    608514033 :     case BOOLEAN_TYPE:
    8686              :       /* Scalar types are variably modified if their end points
    8687              :          aren't constant.  */
    8688    608514033 :       RETURN_TRUE_IF_VAR (TYPE_MIN_VALUE (type));
    8689    608514033 :       RETURN_TRUE_IF_VAR (TYPE_MAX_VALUE (type));
    8690    608478784 :       break;
    8691              : 
    8692    858716233 :     case RECORD_TYPE:
    8693    858716233 :     case UNION_TYPE:
    8694    858716233 :     case QUAL_UNION_TYPE:
    8695              :       /* We can't see if any of the fields are variably-modified by the
    8696              :          definition we normally use, since that would produce infinite
    8697              :          recursion via pointers.  */
    8698              :       /* This is variably modified if some field's type is.  */
    8699  39869292045 :       for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t))
    8700  39010575812 :         if (TREE_CODE (t) == FIELD_DECL)
    8701              :           {
    8702   1254925136 :             RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t));
    8703   1254925136 :             RETURN_TRUE_IF_VAR (DECL_SIZE (t));
    8704   1254925136 :             RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t));
    8705              : 
    8706              :             /* If the type is a qualified union, then the DECL_QUALIFIER
    8707              :                of fields can also be an expression containing a variable.  */
    8708   1254925136 :             if (TREE_CODE (type) == QUAL_UNION_TYPE)
    8709            0 :               RETURN_TRUE_IF_VAR (DECL_QUALIFIER (t));
    8710              : 
    8711              :             /* If the field is a qualified union, then it's only a container
    8712              :                for what's inside so we look into it.  That's necessary in LTO
    8713              :                mode because the sizes of the field tested above have been set
    8714              :                to PLACEHOLDER_EXPRs by free_lang_data.  */
    8715   1254925136 :             if (TREE_CODE (TREE_TYPE (t)) == QUAL_UNION_TYPE
    8716   1254925136 :                 && variably_modified_type_p (TREE_TYPE (t), fn))
    8717              :               return true;
    8718              :           }
    8719              :       break;
    8720              : 
    8721     14688203 :     case ARRAY_TYPE:
    8722              :       /* Do not call ourselves to avoid infinite recursion.  This is
    8723              :          variably modified if the element type is.  */
    8724     14688203 :       RETURN_TRUE_IF_VAR (TYPE_SIZE (TREE_TYPE (type)));
    8725     14684681 :       RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT (TREE_TYPE (type)));
    8726     14684655 :       break;
    8727              : 
    8728              :     default:
    8729              :       break;
    8730              :     }
    8731              : 
    8732              :   /* The current language may have other cases to check, but in general,
    8733              :      all other types are not variably modified.  */
    8734   2468821216 :   return lang_hooks.tree_inlining.var_mod_type_p (type, fn);
    8735              : 
    8736              : #undef RETURN_TRUE_IF_VAR
    8737              : }
    8738              : 
    8739              : /* Given a DECL or TYPE, return the scope in which it was declared, or
    8740              :    NULL_TREE if there is no containing scope.  */
    8741              : 
    8742              : tree
    8743   3014440375 : get_containing_scope (const_tree t)
    8744              : {
    8745   3014440375 :   return (TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t));
    8746              : }
    8747              : 
    8748              : /* Returns the ultimate TRANSLATION_UNIT_DECL context of DECL or NULL.  */
    8749              : 
    8750              : const_tree
    8751        14484 : get_ultimate_context (const_tree decl)
    8752              : {
    8753        39753 :   while (decl && TREE_CODE (decl) != TRANSLATION_UNIT_DECL)
    8754              :     {
    8755        25269 :       if (TREE_CODE (decl) == BLOCK)
    8756            0 :         decl = BLOCK_SUPERCONTEXT (decl);
    8757              :       else
    8758        25269 :         decl = get_containing_scope (decl);
    8759              :     }
    8760        14484 :   return decl;
    8761              : }
    8762              : 
    8763              : /* Return the innermost context enclosing DECL that is
    8764              :    a FUNCTION_DECL, or zero if none.  */
    8765              : 
    8766              : tree
    8767   1515200597 : decl_function_context (const_tree decl)
    8768              : {
    8769   1515200597 :   tree context;
    8770              : 
    8771   1515200597 :   if (TREE_CODE (decl) == ERROR_MARK)
    8772              :     return 0;
    8773              : 
    8774              :   /* C++ virtual functions use DECL_CONTEXT for the class of the vtable
    8775              :      where we look up the function at runtime.  Such functions always take
    8776              :      a first argument of type 'pointer to real context'.
    8777              : 
    8778              :      C++ should really be fixed to use DECL_CONTEXT for the real context,
    8779              :      and use something else for the "virtual context".  */
    8780   1515200597 :   else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
    8781      4897669 :     context
    8782      4897669 :       = TYPE_MAIN_VARIANT
    8783              :         (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
    8784              :   else
    8785   1510302928 :     context = DECL_CONTEXT (decl);
    8786              : 
    8787   3678157849 :   while (context && TREE_CODE (context) != FUNCTION_DECL)
    8788              :     {
    8789   2162957252 :       if (TREE_CODE (context) == BLOCK)
    8790            0 :         context = BLOCK_SUPERCONTEXT (context);
    8791              :       else
    8792   2162957252 :         context = get_containing_scope (context);
    8793              :     }
    8794              : 
    8795              :   return context;
    8796              : }
    8797              : 
    8798              : /* Return the innermost context enclosing DECL that is
    8799              :    a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
    8800              :    TYPE_DECLs and FUNCTION_DECLs are transparent to this function.  */
    8801              : 
    8802              : tree
    8803     99196066 : decl_type_context (const_tree decl)
    8804              : {
    8805     99196066 :   tree context = DECL_CONTEXT (decl);
    8806              : 
    8807    102349384 :   while (context)
    8808     96607950 :     switch (TREE_CODE (context))
    8809              :       {
    8810              :       case NAMESPACE_DECL:
    8811              :       case TRANSLATION_UNIT_DECL:
    8812              :         return NULL_TREE;
    8813              : 
    8814              :       case RECORD_TYPE:
    8815              :       case UNION_TYPE:
    8816              :       case QUAL_UNION_TYPE:
    8817              :         return context;
    8818              : 
    8819      3153318 :       case TYPE_DECL:
    8820      3153318 :       case FUNCTION_DECL:
    8821      3153318 :         context = DECL_CONTEXT (context);
    8822      3153318 :         break;
    8823              : 
    8824            0 :       case BLOCK:
    8825            0 :         context = BLOCK_SUPERCONTEXT (context);
    8826            0 :         break;
    8827              : 
    8828            0 :       default:
    8829            0 :         gcc_unreachable ();
    8830              :       }
    8831              : 
    8832              :   return NULL_TREE;
    8833              : }
    8834              : 
    8835              : /* CALL is a CALL_EXPR.  Return the declaration for the function
    8836              :    called, or NULL_TREE if the called function cannot be
    8837              :    determined.  */
    8838              : 
    8839              : tree
    8840   1262505074 : get_callee_fndecl (const_tree call)
    8841              : {
    8842   1262505074 :   tree addr;
    8843              : 
    8844   1262505074 :   if (call == error_mark_node)
    8845              :     return error_mark_node;
    8846              : 
    8847              :   /* It's invalid to call this function with anything but a
    8848              :      CALL_EXPR.  */
    8849   1262505074 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    8850              : 
    8851              :   /* The first operand to the CALL is the address of the function
    8852              :      called.  */
    8853   1262505074 :   addr = CALL_EXPR_FN (call);
    8854              : 
    8855              :   /* If there is no function, return early.  */
    8856   1262505074 :   if (addr == NULL_TREE)
    8857              :     return NULL_TREE;
    8858              : 
    8859   1259768668 :   STRIP_NOPS (addr);
    8860              : 
    8861              :   /* If this is a readonly function pointer, extract its initial value.  */
    8862     21237484 :   if (DECL_P (addr) && TREE_CODE (addr) != FUNCTION_DECL
    8863      2529267 :       && TREE_READONLY (addr) && ! TREE_THIS_VOLATILE (addr)
    8864   1260438052 :       && DECL_INITIAL (addr))
    8865       669329 :     addr = DECL_INITIAL (addr);
    8866              : 
    8867              :   /* If the address is just `&f' for some function `f', then we know
    8868              :      that `f' is being called.  */
    8869   1259768668 :   if (TREE_CODE (addr) == ADDR_EXPR
    8870   1259768668 :       && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
    8871   1204702636 :     return TREE_OPERAND (addr, 0);
    8872              : 
    8873              :   /* We couldn't figure out what was being called.  */
    8874              :   return NULL_TREE;
    8875              : }
    8876              : 
    8877              : /* Return true when STMTs arguments and return value match those of FNDECL,
    8878              :    a decl of a builtin function.  */
    8879              : 
    8880              : static bool
    8881      6473823 : tree_builtin_call_types_compatible_p (const_tree call, tree fndecl)
    8882              : {
    8883      6473823 :   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
    8884              : 
    8885      6473823 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
    8886      6473823 :     if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
    8887      6473823 :       fndecl = decl;
    8888              : 
    8889      6473823 :   bool gimple_form = (cfun && (cfun->curr_properties & PROP_gimple)) != 0;
    8890      6473823 :   if (gimple_form
    8891        15269 :       ? !useless_type_conversion_p (TREE_TYPE (call),
    8892        15269 :                                     TREE_TYPE (TREE_TYPE (fndecl)))
    8893      6458554 :       : (TYPE_MAIN_VARIANT (TREE_TYPE (call))
    8894      6458554 :          != TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))))
    8895              :     return false;
    8896              : 
    8897      6473607 :   tree targs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
    8898      6473607 :   unsigned nargs = call_expr_nargs (call);
    8899     16342530 :   for (unsigned i = 0; i < nargs; ++i, targs = TREE_CHAIN (targs))
    8900              :     {
    8901              :       /* Variadic args follow.  */
    8902     11429010 :       if (!targs)
    8903              :         return true;
    8904      9869580 :       tree arg = CALL_EXPR_ARG (call, i);
    8905      9869580 :       tree type = TREE_VALUE (targs);
    8906      9869580 :       if (gimple_form
    8907      9869580 :           ? !useless_type_conversion_p (type, TREE_TYPE (arg))
    8908      9854311 :           : TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (arg)))
    8909              :         {
    8910              :           /* For pointer arguments be more forgiving, e.g. due to
    8911              :              FILE * vs. fileptr_type_node, or say char * vs. const char *
    8912              :              differences etc.  */
    8913      1131115 :           if (!gimple_form
    8914       565886 :               && POINTER_TYPE_P (type)
    8915       565334 :               && POINTER_TYPE_P (TREE_TYPE (arg))
    8916      1131115 :               && tree_nop_conversion_p (type, TREE_TYPE (arg)))
    8917       565229 :             continue;
    8918              :           return false;
    8919              :         }
    8920              :     }
    8921      9826393 :   if (targs && !VOID_TYPE_P (TREE_VALUE (targs)))
    8922            5 :     return false;
    8923              :   return true;
    8924              : }
    8925              : 
    8926              : /* If CALL_EXPR CALL calls a normal built-in function or an internal function,
    8927              :    return the associated function code, otherwise return CFN_LAST.  */
    8928              : 
    8929              : combined_fn
    8930     42419566 : get_call_combined_fn (const_tree call)
    8931              : {
    8932              :   /* It's invalid to call this function with anything but a CALL_EXPR.  */
    8933     42419566 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    8934              : 
    8935     42419566 :   if (!CALL_EXPR_FN (call))
    8936        66983 :     return as_combined_fn (CALL_EXPR_IFN (call));
    8937              : 
    8938     42352583 :   tree fndecl = get_callee_fndecl (call);
    8939     42352583 :   if (fndecl
    8940     42329959 :       && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    8941     48826406 :       && tree_builtin_call_types_compatible_p (call, fndecl))
    8942      6472945 :     return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
    8943              : 
    8944              :   return CFN_LAST;
    8945              : }
    8946              : 
    8947              : /* Comparator of indices based on tree_node_counts.  */
    8948              : 
    8949              : static int
    8950            0 : tree_nodes_cmp (const void *p1, const void *p2)
    8951              : {
    8952            0 :   const unsigned *n1 = (const unsigned *)p1;
    8953            0 :   const unsigned *n2 = (const unsigned *)p2;
    8954              : 
    8955            0 :   return tree_node_counts[*n1] - tree_node_counts[*n2];
    8956              : }
    8957              : 
    8958              : /* Comparator of indices based on tree_code_counts.  */
    8959              : 
    8960              : static int
    8961            0 : tree_codes_cmp (const void *p1, const void *p2)
    8962              : {
    8963            0 :   const unsigned *n1 = (const unsigned *)p1;
    8964            0 :   const unsigned *n2 = (const unsigned *)p2;
    8965              : 
    8966            0 :   return tree_code_counts[*n1] - tree_code_counts[*n2];
    8967              : }
    8968              : 
    8969              : #define TREE_MEM_USAGE_SPACES 40
    8970              : 
    8971              : /* Print debugging information about tree nodes generated during the compile,
    8972              :    and any language-specific information.  */
    8973              : 
    8974              : void
    8975            0 : dump_tree_statistics (void)
    8976              : {
    8977            0 :   if (GATHER_STATISTICS)
    8978              :     {
    8979              :       uint64_t total_nodes, total_bytes;
    8980              :       fprintf (stderr, "\nKind                   Nodes      Bytes\n");
    8981              :       mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    8982              :       total_nodes = total_bytes = 0;
    8983              : 
    8984              :       {
    8985              :         auto_vec<unsigned> indices (all_kinds);
    8986              :         for (unsigned i = 0; i < all_kinds; i++)
    8987              :           indices.quick_push (i);
    8988              :         indices.qsort (tree_nodes_cmp);
    8989              : 
    8990              :         for (unsigned i = 0; i < (int) all_kinds; i++)
    8991              :           {
    8992              :             unsigned j = indices[i];
    8993              :             fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n",
    8994              :                      tree_node_kind_names[j], SIZE_AMOUNT (tree_node_counts[j]),
    8995              :                      SIZE_AMOUNT (tree_node_sizes[j]));
    8996              :             total_nodes += tree_node_counts[j];
    8997              :             total_bytes += tree_node_sizes[j];
    8998              :           }
    8999              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9000              :         fprintf (stderr, "%-20s %6" PRIu64 "%c %9" PRIu64 "%c\n", "Total",
    9001              :                  SIZE_AMOUNT (total_nodes), SIZE_AMOUNT (total_bytes));
    9002              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9003              :       }
    9004              : 
    9005              :       {
    9006              :         fprintf (stderr, "Code                              Nodes\n");
    9007              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9008              : 
    9009              :         auto_vec<unsigned> indices (MAX_TREE_CODES);
    9010              :         for (unsigned i = 0; i < MAX_TREE_CODES; i++)
    9011              :           indices.quick_push (i);
    9012              :         indices.qsort (tree_codes_cmp);
    9013              : 
    9014              :         for (unsigned i = 0; i < MAX_TREE_CODES; i++)
    9015              :           {
    9016              :             unsigned j = indices[i];
    9017              :             fprintf (stderr, "%-32s %6" PRIu64 "%c\n",
    9018              :                      get_tree_code_name ((enum tree_code) j),
    9019              :                      SIZE_AMOUNT (tree_code_counts[j]));
    9020              :           }
    9021              :         mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES);
    9022              :         fprintf (stderr, "\n");
    9023              :         ssanames_print_statistics ();
    9024              :         fprintf (stderr, "\n");
    9025              :         phinodes_print_statistics ();
    9026              :         fprintf (stderr, "\n");
    9027              :       }
    9028              :     }
    9029              :   else
    9030            0 :     fprintf (stderr, "(No per-node statistics)\n");
    9031              : 
    9032            0 :   print_type_hash_statistics ();
    9033            0 :   print_debug_expr_statistics ();
    9034            0 :   print_value_expr_statistics ();
    9035            0 :   lang_hooks.print_statistics ();
    9036            0 : }
    9037              : 
    9038              : #define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s"
    9039              : 
    9040              : /* Generate a crc32 of the low BYTES bytes of VALUE.  */
    9041              : 
    9042              : unsigned
    9043     17339071 : crc32_unsigned_n (unsigned chksum, unsigned value, unsigned bytes)
    9044              : {
    9045              :   /* This relies on the raw feedback's top 4 bits being zero.  */
    9046              : #define FEEDBACK(X) ((X) * 0x04c11db7)
    9047              : #define SYNDROME(X) (FEEDBACK ((X) & 1) ^ FEEDBACK ((X) & 2) \
    9048              :                      ^ FEEDBACK ((X) & 4) ^ FEEDBACK ((X) & 8))
    9049     17339071 :   static const unsigned syndromes[16] =
    9050              :     {
    9051              :       SYNDROME(0x0), SYNDROME(0x1), SYNDROME(0x2), SYNDROME(0x3),
    9052              :       SYNDROME(0x4), SYNDROME(0x5), SYNDROME(0x6), SYNDROME(0x7),
    9053              :       SYNDROME(0x8), SYNDROME(0x9), SYNDROME(0xa), SYNDROME(0xb),
    9054              :       SYNDROME(0xc), SYNDROME(0xd), SYNDROME(0xe), SYNDROME(0xf),
    9055              :     };
    9056              : #undef FEEDBACK
    9057              : #undef SYNDROME
    9058              : 
    9059     17339071 :   value <<= (32 - bytes * 8);
    9060     57780585 :   for (unsigned ix = bytes * 2; ix--; value <<= 4)
    9061              :     {
    9062     40441514 :       unsigned feedback = syndromes[((value ^ chksum) >> 28) & 0xf];
    9063              : 
    9064     40441514 :       chksum = (chksum << 4) ^ feedback;
    9065              :     }
    9066              : 
    9067     17339071 :   return chksum;
    9068              : }
    9069              : 
    9070              : /* Generate a crc32 of a string.  */
    9071              : 
    9072              : unsigned
    9073        10102 : crc32_string (unsigned chksum, const char *string)
    9074              : {
    9075       404421 :   do
    9076       404421 :     chksum = crc32_byte (chksum, *string);
    9077       404421 :   while (*string++);
    9078        10102 :   return chksum;
    9079              : }
    9080              : 
    9081              : /* P is a string that will be used in a symbol.  Mask out any characters
    9082              :    that are not valid in that context.  */
    9083              : 
    9084              : void
    9085         7554 : clean_symbol_name (char *p)
    9086              : {
    9087        86720 :   for (; *p; p++)
    9088        79166 :     if (! (ISALNUM (*p)
    9089              : #ifndef NO_DOLLAR_IN_LABEL      /* this for `$'; unlikely, but... -- kr */
    9090              :             || *p == '$'
    9091              : #endif
    9092              : #ifndef NO_DOT_IN_LABEL         /* this for `.'; unlikely, but...  */
    9093              :             || *p == '.'
    9094              : #endif
    9095              :            ))
    9096         7319 :       *p = '_';
    9097         7554 : }
    9098              : 
    9099              : static GTY(()) unsigned anon_cnt = 0; /* Saved for PCH.  */
    9100              : 
    9101              : /* Create a unique anonymous identifier.  The identifier is still a
    9102              :    valid assembly label.  */
    9103              : 
    9104              : tree
    9105      3656706 : make_anon_name ()
    9106              : {
    9107      3656706 :   const char *fmt =
    9108              : #if !defined (NO_DOT_IN_LABEL)
    9109              :     "."
    9110              : #elif !defined (NO_DOLLAR_IN_LABEL)
    9111              :     "$"
    9112              : #else
    9113              :     "_"
    9114              : #endif
    9115              :     "_anon_%d";
    9116              : 
    9117      3656706 :   char buf[24];
    9118      3656706 :   int len = snprintf (buf, sizeof (buf), fmt, anon_cnt++);
    9119      3656706 :   gcc_checking_assert (len < int (sizeof (buf)));
    9120              : 
    9121      3656706 :   tree id = get_identifier_with_length (buf, len);
    9122      3656706 :   IDENTIFIER_ANON_P (id) = true;
    9123              : 
    9124      3656706 :   return id;
    9125              : }
    9126              : 
    9127              : /* Generate a name for a special-purpose function.
    9128              :    The generated name may need to be unique across the whole link.
    9129              :    Changes to this function may also require corresponding changes to
    9130              :    xstrdup_mask_random.
    9131              :    TYPE is some string to identify the purpose of this function to the
    9132              :    linker or collect2; it must start with an uppercase letter,
    9133              :    one of:
    9134              :    I - for constructors
    9135              :    D - for destructors
    9136              :    N - for C++ anonymous namespaces
    9137              :    F - for DWARF unwind frame information.  */
    9138              : 
    9139              : tree
    9140         5637 : get_file_function_name (const char *type)
    9141              : {
    9142         5637 :   char *buf;
    9143         5637 :   const char *p;
    9144         5637 :   char *q;
    9145              : 
    9146              :   /* If we already have a name we know to be unique, just use that.  */
    9147         5637 :   if (first_global_object_name)
    9148         5338 :     p = q = ASTRDUP (first_global_object_name);
    9149              :   /* If the target is handling the constructors/destructors, they
    9150              :      will be local to this file and the name is only necessary for
    9151              :      debugging purposes.
    9152              :      We also assign sub_I and sub_D suffixes to constructors called from
    9153              :      the global static constructors.  These are always local.
    9154              :      OpenMP "declare target" offloaded constructors/destructors use "off_I" and
    9155              :      "off_D" for the same purpose.  */
    9156          299 :   else if (((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors)
    9157          598 :            || ((startswith (type, "sub_") || startswith (type, "off_"))
    9158          299 :                && (type[4] == 'I' || type[4] == 'D')))
    9159              :     {
    9160          299 :       const char *file = main_input_filename;
    9161          299 :       if (! file)
    9162            0 :         file = LOCATION_FILE (input_location);
    9163              :       /* Just use the file's basename, because the full pathname
    9164              :          might be quite long.  */
    9165          299 :       p = q = ASTRDUP (lbasename (file));
    9166              :     }
    9167              :   else
    9168              :     {
    9169              :       /* Otherwise, the name must be unique across the entire link.
    9170              :          We don't have anything that we know to be unique to this translation
    9171              :          unit, so use what we do have and throw in some randomness.  */
    9172            0 :       unsigned len;
    9173            0 :       const char *name = weak_global_object_name;
    9174            0 :       const char *file = main_input_filename;
    9175              : 
    9176            0 :       if (! name)
    9177            0 :         name = "";
    9178            0 :       if (! file)
    9179            0 :         file = LOCATION_FILE (input_location);
    9180              : 
    9181            0 :       len = strlen (file);
    9182            0 :       q = (char *) alloca (9 + 19 + len + 1);
    9183            0 :       memcpy (q, file, len + 1);
    9184              : 
    9185            0 :       snprintf (q + len, 9 + 19 + 1, "_%08X_" HOST_WIDE_INT_PRINT_HEX,
    9186              :                 crc32_string (0, name), get_random_seed (false));
    9187              : 
    9188            0 :       p = q;
    9189              :     }
    9190              : 
    9191         5637 :   clean_symbol_name (q);
    9192         5637 :   buf = (char *) alloca (sizeof (FILE_FUNCTION_FORMAT) + strlen (p)
    9193              :                          + strlen (type));
    9194              : 
    9195              :   /* Set up the name of the file-level functions we may need.
    9196              :      Use a global object (which is already required to be unique over
    9197              :      the program) rather than the file name (which imposes extra
    9198              :      constraints).  */
    9199         5637 :   sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
    9200              : 
    9201         5637 :   return get_identifier (buf);
    9202              : }
    9203              : 
    9204              : #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
    9205              : 
    9206              : /* Complain that the tree code of NODE does not match the expected 0
    9207              :    terminated list of trailing codes.  The trailing code list can be
    9208              :    empty, for a more vague error message.  FILE, LINE, and FUNCTION
    9209              :    are of the caller.  */
    9210              : 
    9211              : void
    9212            0 : tree_check_failed (const_tree node, const char *file,
    9213              :                    int line, const char *function, ...)
    9214              : {
    9215            0 :   va_list args;
    9216            0 :   const char *buffer;
    9217            0 :   unsigned length = 0;
    9218            0 :   enum tree_code code;
    9219              : 
    9220            0 :   va_start (args, function);
    9221            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9222            0 :     length += 4 + strlen (get_tree_code_name (code));
    9223            0 :   va_end (args);
    9224            0 :   if (length)
    9225              :     {
    9226            0 :       char *tmp;
    9227            0 :       va_start (args, function);
    9228            0 :       length += strlen ("expected ");
    9229            0 :       buffer = tmp = (char *) alloca (length);
    9230            0 :       length = 0;
    9231            0 :       while ((code = (enum tree_code) va_arg (args, int)))
    9232              :         {
    9233            0 :           const char *prefix = length ? " or " : "expected ";
    9234              : 
    9235            0 :           strcpy (tmp + length, prefix);
    9236            0 :           length += strlen (prefix);
    9237            0 :           strcpy (tmp + length, get_tree_code_name (code));
    9238            0 :           length += strlen (get_tree_code_name (code));
    9239              :         }
    9240            0 :       va_end (args);
    9241              :     }
    9242              :   else
    9243              :     buffer = "unexpected node";
    9244              : 
    9245            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9246            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9247              :                   function, trim_filename (file), line);
    9248              : }
    9249              : 
    9250              : /* Complain that the tree code of NODE does match the expected 0
    9251              :    terminated list of trailing codes. FILE, LINE, and FUNCTION are of
    9252              :    the caller.  */
    9253              : 
    9254              : void
    9255            0 : tree_not_check_failed (const_tree node, const char *file,
    9256              :                        int line, const char *function, ...)
    9257              : {
    9258            0 :   va_list args;
    9259            0 :   char *buffer;
    9260            0 :   unsigned length = 0;
    9261            0 :   enum tree_code code;
    9262              : 
    9263            0 :   va_start (args, function);
    9264            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9265            0 :     length += 4 + strlen (get_tree_code_name (code));
    9266            0 :   va_end (args);
    9267            0 :   va_start (args, function);
    9268            0 :   buffer = (char *) alloca (length);
    9269            0 :   length = 0;
    9270            0 :   while ((code = (enum tree_code) va_arg (args, int)))
    9271              :     {
    9272            0 :       if (length)
    9273              :         {
    9274            0 :           strcpy (buffer + length, " or ");
    9275            0 :           length += 4;
    9276              :         }
    9277            0 :       strcpy (buffer + length, get_tree_code_name (code));
    9278            0 :       length += strlen (get_tree_code_name (code));
    9279              :     }
    9280            0 :   va_end (args);
    9281              : 
    9282            0 :   internal_error ("tree check: expected none of %s, have %s in %s, at %s:%d",
    9283            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9284              :                   function, trim_filename (file), line);
    9285              : }
    9286              : 
    9287              : /* Similar to tree_check_failed, except that we check for a class of tree
    9288              :    code, given in CL.  */
    9289              : 
    9290              : void
    9291            0 : tree_class_check_failed (const_tree node, const enum tree_code_class cl,
    9292              :                          const char *file, int line, const char *function)
    9293              : {
    9294            0 :   internal_error
    9295            0 :     ("tree check: expected class %qs, have %qs (%s) in %s, at %s:%d",
    9296            0 :      TREE_CODE_CLASS_STRING (cl),
    9297            0 :      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
    9298            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9299              : }
    9300              : 
    9301              : /* Similar to tree_check_failed, except that instead of specifying a
    9302              :    dozen codes, use the knowledge that they're all sequential.  */
    9303              : 
    9304              : void
    9305            0 : tree_range_check_failed (const_tree node, const char *file, int line,
    9306              :                          const char *function, enum tree_code c1,
    9307              :                          enum tree_code c2)
    9308              : {
    9309            0 :   char *buffer;
    9310            0 :   unsigned length = 0;
    9311            0 :   unsigned int c;
    9312              : 
    9313            0 :   for (c = c1; c <= c2; ++c)
    9314            0 :     length += 4 + strlen (get_tree_code_name ((enum tree_code) c));
    9315              : 
    9316            0 :   length += strlen ("expected ");
    9317            0 :   buffer = (char *) alloca (length);
    9318            0 :   length = 0;
    9319              : 
    9320            0 :   for (c = c1; c <= c2; ++c)
    9321              :     {
    9322            0 :       const char *prefix = length ? " or " : "expected ";
    9323              : 
    9324            0 :       strcpy (buffer + length, prefix);
    9325            0 :       length += strlen (prefix);
    9326            0 :       strcpy (buffer + length, get_tree_code_name ((enum tree_code) c));
    9327            0 :       length += strlen (get_tree_code_name ((enum tree_code) c));
    9328              :     }
    9329              : 
    9330            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9331            0 :                   buffer, get_tree_code_name (TREE_CODE (node)),
    9332              :                   function, trim_filename (file), line);
    9333              : }
    9334              : 
    9335              : 
    9336              : /* Similar to tree_check_failed, except that we check that a tree does
    9337              :    not have the specified code, given in CL.  */
    9338              : 
    9339              : void
    9340            0 : tree_not_class_check_failed (const_tree node, const enum tree_code_class cl,
    9341              :                              const char *file, int line, const char *function)
    9342              : {
    9343            0 :   internal_error
    9344            0 :     ("tree check: did not expect class %qs, have %qs (%s) in %s, at %s:%d",
    9345            0 :      TREE_CODE_CLASS_STRING (cl),
    9346            0 :      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
    9347            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9348              : }
    9349              : 
    9350              : 
    9351              : /* Similar to tree_check_failed but applied to OMP_CLAUSE codes.  */
    9352              : 
    9353              : void
    9354            0 : omp_clause_check_failed (const_tree node, const char *file, int line,
    9355              :                          const char *function, enum omp_clause_code code)
    9356              : {
    9357            0 :   internal_error ("tree check: expected %<omp_clause %s%>, have %qs "
    9358              :                   "in %s, at %s:%d",
    9359            0 :                   omp_clause_code_name[code],
    9360            0 :                   get_tree_code_name (TREE_CODE (node)),
    9361              :                   function, trim_filename (file), line);
    9362              : }
    9363              : 
    9364              : 
    9365              : /* Similar to tree_range_check_failed but applied to OMP_CLAUSE codes.  */
    9366              : 
    9367              : void
    9368            0 : omp_clause_range_check_failed (const_tree node, const char *file, int line,
    9369              :                                const char *function, enum omp_clause_code c1,
    9370              :                                enum omp_clause_code c2)
    9371              : {
    9372            0 :   char *buffer;
    9373            0 :   unsigned length = 0;
    9374            0 :   unsigned int c;
    9375              : 
    9376            0 :   for (c = c1; c <= c2; ++c)
    9377            0 :     length += 4 + strlen (omp_clause_code_name[c]);
    9378              : 
    9379            0 :   length += strlen ("expected ");
    9380            0 :   buffer = (char *) alloca (length);
    9381            0 :   length = 0;
    9382              : 
    9383            0 :   for (c = c1; c <= c2; ++c)
    9384              :     {
    9385            0 :       const char *prefix = length ? " or " : "expected ";
    9386              : 
    9387            0 :       strcpy (buffer + length, prefix);
    9388            0 :       length += strlen (prefix);
    9389            0 :       strcpy (buffer + length, omp_clause_code_name[c]);
    9390            0 :       length += strlen (omp_clause_code_name[c]);
    9391              :     }
    9392              : 
    9393            0 :   internal_error ("tree check: %s, have %s in %s, at %s:%d",
    9394            0 :                   buffer, omp_clause_code_name[TREE_CODE (node)],
    9395              :                   function, trim_filename (file), line);
    9396              : }
    9397              : 
    9398              : 
    9399              : #undef DEFTREESTRUCT
    9400              : #define DEFTREESTRUCT(VAL, NAME) NAME,
    9401              : 
    9402              : static const char *ts_enum_names[] = {
    9403              : #include "treestruct.def"
    9404              : };
    9405              : #undef DEFTREESTRUCT
    9406              : 
    9407              : #define TS_ENUM_NAME(EN) (ts_enum_names[(EN)])
    9408              : 
    9409              : /* Similar to tree_class_check_failed, except that we check for
    9410              :    whether CODE contains the tree structure identified by EN.  */
    9411              : 
    9412              : void
    9413            0 : tree_contains_struct_check_failed (const_tree node,
    9414              :                                    const enum tree_node_structure_enum en,
    9415              :                                    const char *file, int line,
    9416              :                                    const char *function)
    9417              : {
    9418            0 :   internal_error
    9419            0 :     ("tree check: expected tree that contains %qs structure, have %qs in %s, at %s:%d",
    9420            0 :      TS_ENUM_NAME (en),
    9421            0 :      get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line);
    9422              : }
    9423              : 
    9424              : 
    9425              : /* Similar to above, except that the check is for the bounds of a TREE_VEC's
    9426              :    (dynamically sized) vector.  */
    9427              : 
    9428              : void
    9429            0 : tree_int_cst_elt_check_failed (int idx, int len, const char *file, int line,
    9430              :                                const char *function)
    9431              : {
    9432            0 :   internal_error
    9433            0 :     ("tree check: accessed elt %d of %<tree_int_cst%> with %d elts in %s, "
    9434              :      "at %s:%d",
    9435              :      idx + 1, len, function, trim_filename (file), line);
    9436              : }
    9437              : 
    9438              : /* Similar to above, except that the check is for the bounds of a TREE_VEC's
    9439              :    (dynamically sized) vector.  */
    9440              : 
    9441              : void
    9442            0 : tree_vec_elt_check_failed (int idx, int len, const char *file, int line,
    9443              :                            const char *function)
    9444              : {
    9445            0 :   internal_error
    9446            0 :     ("tree check: accessed elt %d of %<tree_vec%> with %d elts in %s, at %s:%d",
    9447              :      idx + 1, len, function, trim_filename (file), line);
    9448              : }
    9449              : 
    9450              : /* Similar to above, except that the check is for the bounds of the operand
    9451              :    vector of an expression node EXP.  */
    9452              : 
    9453              : void
    9454            0 : tree_operand_check_failed (int idx, const_tree exp, const char *file,
    9455              :                            int line, const char *function)
    9456              : {
    9457            0 :   enum tree_code code = TREE_CODE (exp);
    9458            0 :   internal_error
    9459            0 :     ("tree check: accessed operand %d of %s with %d operands in %s, at %s:%d",
    9460              :      idx + 1, get_tree_code_name (code), TREE_OPERAND_LENGTH (exp),
    9461              :      function, trim_filename (file), line);
    9462              : }
    9463              : 
    9464              : /* Similar to above, except that the check is for the number of
    9465              :    operands of an OMP_CLAUSE node.  */
    9466              : 
    9467              : void
    9468            0 : omp_clause_operand_check_failed (int idx, const_tree t, const char *file,
    9469              :                                  int line, const char *function)
    9470              : {
    9471            0 :   internal_error
    9472            0 :     ("tree check: accessed operand %d of %<omp_clause %s%> with %d operands "
    9473            0 :      "in %s, at %s:%d", idx + 1, omp_clause_code_name[OMP_CLAUSE_CODE (t)],
    9474            0 :      omp_clause_num_ops [OMP_CLAUSE_CODE (t)], function,
    9475              :      trim_filename (file), line);
    9476              : }
    9477              : #endif /* ENABLE_TREE_CHECKING */
    9478              : 
    9479              : /* Create a new vector type node holding NUNITS units of type INNERTYPE,
    9480              :    and mapped to the machine mode MODE.  Initialize its fields and build
    9481              :    the information necessary for debugging output.  */
    9482              : 
    9483              : static tree
    9484     71822145 : make_vector_type (tree innertype, poly_int64 nunits, machine_mode mode)
    9485              : {
    9486     71822145 :   tree t;
    9487     71822145 :   tree mv_innertype = TYPE_MAIN_VARIANT (innertype);
    9488              : 
    9489     71822145 :   t = make_node (VECTOR_TYPE);
    9490     71822145 :   TREE_TYPE (t) = mv_innertype;
    9491     71822145 :   SET_TYPE_VECTOR_SUBPARTS (t, nunits);
    9492     71822145 :   SET_TYPE_MODE (t, mode);
    9493              : 
    9494     71822145 :   if (TYPE_STRUCTURAL_EQUALITY_P (mv_innertype) || in_lto_p)
    9495      1175793 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    9496     70646352 :   else if ((TYPE_CANONICAL (mv_innertype) != innertype
    9497     66944372 :             || mode != VOIDmode)
    9498    102093222 :            && !VECTOR_BOOLEAN_TYPE_P (t))
    9499     32466228 :     TYPE_CANONICAL (t)
    9500     64932456 :       = make_vector_type (TYPE_CANONICAL (mv_innertype), nunits, VOIDmode);
    9501              : 
    9502     71822145 :   layout_type (t);
    9503              : 
    9504     71822145 :   hashval_t hash = type_hash_canon_hash (t);
    9505     71822145 :   t = type_hash_canon (hash, t);
    9506              : 
    9507              :   /* We have built a main variant, based on the main variant of the
    9508              :      inner type. Use it to build the variant we return.  */
    9509    143638673 :   if ((TYPE_ATTRIBUTES (innertype) || TYPE_QUALS (innertype))
    9510     72656717 :       && TREE_TYPE (t) != innertype)
    9511       838892 :     return build_type_attribute_qual_variant (t,
    9512       838892 :                                               TYPE_ATTRIBUTES (innertype),
    9513      1677784 :                                               TYPE_QUALS (innertype));
    9514              : 
    9515              :   return t;
    9516              : }
    9517              : 
    9518              : static tree
    9519      4112772 : make_or_reuse_type (unsigned size, int unsignedp)
    9520              : {
    9521      4112772 :   int i;
    9522              : 
    9523      4112772 :   if (size == INT_TYPE_SIZE)
    9524       882843 :     return unsignedp ? unsigned_type_node : integer_type_node;
    9525      3229929 :   if (size == CHAR_TYPE_SIZE)
    9526       588562 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    9527      2641367 :   if (size == SHORT_TYPE_SIZE)
    9528       882843 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    9529      1794904 :   if (size == LONG_TYPE_SIZE)
    9530       861072 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    9531       897452 :   if (size == LONG_LONG_TYPE_SIZE)
    9532        21771 :     return (unsignedp ? long_long_unsigned_type_node
    9533        21771 :             : long_long_integer_type_node);
    9534              : 
    9535       890005 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    9536       875681 :     if (size == int_n_data[i].bitsize
    9537       875681 :         && int_n_enabled_p[i])
    9538       861357 :       return (unsignedp ? int_n_trees[i].unsigned_type
    9539       861357 :               : int_n_trees[i].signed_type);
    9540              : 
    9541        14324 :   if (unsignedp)
    9542         7162 :     return make_unsigned_type (size);
    9543              :   else
    9544         7162 :     return make_signed_type (size);
    9545              : }
    9546              : 
    9547              : /* Create or reuse a fract type by SIZE, UNSIGNEDP, and SATP.  */
    9548              : 
    9549              : static tree
    9550      5885620 : make_or_reuse_fract_type (unsigned size, int unsignedp, int satp)
    9551              : {
    9552      5885620 :   if (satp)
    9553              :     {
    9554      2942810 :       if (size == SHORT_FRACT_TYPE_SIZE)
    9555       588562 :         return unsignedp ? sat_unsigned_short_fract_type_node
    9556       588562 :                          : sat_short_fract_type_node;
    9557      2354248 :       if (size == FRACT_TYPE_SIZE)
    9558       588562 :         return unsignedp ? sat_unsigned_fract_type_node : sat_fract_type_node;
    9559      1765686 :       if (size == LONG_FRACT_TYPE_SIZE)
    9560       588562 :         return unsignedp ? sat_unsigned_long_fract_type_node
    9561       588562 :                          : sat_long_fract_type_node;
    9562      1177124 :       if (size == LONG_LONG_FRACT_TYPE_SIZE)
    9563       588562 :         return unsignedp ? sat_unsigned_long_long_fract_type_node
    9564       588562 :                          : sat_long_long_fract_type_node;
    9565              :     }
    9566              :   else
    9567              :     {
    9568      2942810 :       if (size == SHORT_FRACT_TYPE_SIZE)
    9569       588562 :         return unsignedp ? unsigned_short_fract_type_node
    9570       588562 :                          : short_fract_type_node;
    9571      2354248 :       if (size == FRACT_TYPE_SIZE)
    9572       588562 :         return unsignedp ? unsigned_fract_type_node : fract_type_node;
    9573      1765686 :       if (size == LONG_FRACT_TYPE_SIZE)
    9574       588562 :         return unsignedp ? unsigned_long_fract_type_node
    9575       588562 :                          : long_fract_type_node;
    9576      1177124 :       if (size == LONG_LONG_FRACT_TYPE_SIZE)
    9577       588562 :         return unsignedp ? unsigned_long_long_fract_type_node
    9578       588562 :                          : long_long_fract_type_node;
    9579              :     }
    9580              : 
    9581      1177124 :   return make_fract_type (size, unsignedp, satp);
    9582              : }
    9583              : 
    9584              : /* Create or reuse an accum type by SIZE, UNSIGNEDP, and SATP.  */
    9585              : 
    9586              : static tree
    9587      4708496 : make_or_reuse_accum_type (unsigned size, int unsignedp, int satp)
    9588              : {
    9589      4708496 :   if (satp)
    9590              :     {
    9591      2354248 :       if (size == SHORT_ACCUM_TYPE_SIZE)
    9592       588562 :         return unsignedp ? sat_unsigned_short_accum_type_node
    9593       588562 :                          : sat_short_accum_type_node;
    9594      1765686 :       if (size == ACCUM_TYPE_SIZE)
    9595       588562 :         return unsignedp ? sat_unsigned_accum_type_node : sat_accum_type_node;
    9596      1177124 :       if (size == LONG_ACCUM_TYPE_SIZE)
    9597       588562 :         return unsignedp ? sat_unsigned_long_accum_type_node
    9598       588562 :                          : sat_long_accum_type_node;
    9599       588562 :       if (size == LONG_LONG_ACCUM_TYPE_SIZE)
    9600       588562 :         return unsignedp ? sat_unsigned_long_long_accum_type_node
    9601       588562 :                          : sat_long_long_accum_type_node;
    9602              :     }
    9603              :   else
    9604              :     {
    9605      2354248 :       if (size == SHORT_ACCUM_TYPE_SIZE)
    9606       588562 :         return unsignedp ? unsigned_short_accum_type_node
    9607       588562 :                          : short_accum_type_node;
    9608      1765686 :       if (size == ACCUM_TYPE_SIZE)
    9609       588562 :         return unsignedp ? unsigned_accum_type_node : accum_type_node;
    9610      1177124 :       if (size == LONG_ACCUM_TYPE_SIZE)
    9611       588562 :         return unsignedp ? unsigned_long_accum_type_node
    9612       588562 :                          : long_accum_type_node;
    9613       588562 :       if (size == LONG_LONG_ACCUM_TYPE_SIZE)
    9614       588562 :         return unsignedp ? unsigned_long_long_accum_type_node
    9615       588562 :                          : long_long_accum_type_node;
    9616              :     }
    9617              : 
    9618            0 :   return make_accum_type (size, unsignedp, satp);
    9619              : }
    9620              : 
    9621              : 
    9622              : /* Create an atomic variant node for TYPE.  This routine is called
    9623              :    during initialization of data types to create the 5 basic atomic
    9624              :    types.  The generic build_variant_type function requires these to
    9625              :    already be set up in order to function properly, so cannot be
    9626              :    called from there.  If ALIGN is non-zero, then ensure alignment is
    9627              :    overridden to this value.  */
    9628              : 
    9629              : static tree
    9630      1471405 : build_atomic_base (tree type, unsigned int align)
    9631              : {
    9632      1471405 :   tree t;
    9633              : 
    9634              :   /* Make sure its not already registered.  */
    9635      1471405 :   if ((t = get_qualified_type (type, TYPE_QUAL_ATOMIC)))
    9636              :     return t;
    9637              : 
    9638      1471405 :   t = build_variant_type_copy (type);
    9639      1471405 :   set_type_quals (t, TYPE_QUAL_ATOMIC);
    9640              : 
    9641      1471405 :   if (align)
    9642            0 :     SET_TYPE_ALIGN (t, align);
    9643              : 
    9644              :   return t;
    9645              : }
    9646              : 
    9647              : /* Return unsigned integer tree node for TYPE.  */
    9648              : 
    9649              : tree
    9650       294321 : unsigned_integer_tree_node_for_type (const char *type)
    9651              : {
    9652       294321 :   tree type_node;
    9653              : 
    9654       294321 :   if (strcmp (type, "unsigned int") == 0)
    9655         7257 :     type_node = unsigned_type_node;
    9656       287064 :   else if (strcmp (type, "long unsigned int") == 0)
    9657       287064 :     type_node = long_unsigned_type_node;
    9658            0 :   else if (strcmp (type, "long long unsigned int") == 0)
    9659            0 :     type_node = long_long_unsigned_type_node;
    9660            0 :   else if (strcmp (type, "short unsigned int") == 0)
    9661            0 :     type_node = short_unsigned_type_node;
    9662              :   else
    9663              :     {
    9664              :       int i;
    9665              : 
    9666              :       type_node = nullptr;
    9667            0 :       for (i = 0; i < NUM_INT_N_ENTS; i++)
    9668            0 :         if (int_n_enabled_p[i])
    9669              :           {
    9670            0 :             char name[50], altname[50];
    9671            0 :             sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
    9672            0 :             sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
    9673              : 
    9674            0 :             if (strcmp (name, type) == 0
    9675            0 :                 || strcmp (altname, type) == 0)
    9676              :               {
    9677            0 :                 type_node = int_n_trees[i].unsigned_type;
    9678              :               }
    9679              :           }
    9680            0 :       if (type_node == nullptr)
    9681            0 :         gcc_unreachable ();
    9682              :     }
    9683              : 
    9684       294321 :   return type_node;
    9685              : }
    9686              : 
    9687              : /* Information about the _FloatN and _FloatNx types.  This must be in
    9688              :    the same order as the corresponding TI_* enum values.  */
    9689              : const floatn_type_info floatn_nx_types[NUM_FLOATN_NX_TYPES] =
    9690              :   {
    9691              :     { 16, false },
    9692              :     { 32, false },
    9693              :     { 64, false },
    9694              :     { 128, false },
    9695              :     { 32, true },
    9696              :     { 64, true },
    9697              :     { 128, true },
    9698              :   };
    9699              : 
    9700              : 
    9701              : /* Create nodes for all integer types (and error_mark_node) using the sizes
    9702              :    of C datatypes.  SIGNED_CHAR specifies whether char is signed.  */
    9703              : 
    9704              : void
    9705       294281 : build_common_tree_nodes (bool signed_char)
    9706              : {
    9707       294281 :   int i;
    9708              : 
    9709       294281 :   error_mark_node = make_node (ERROR_MARK);
    9710       294281 :   TREE_TYPE (error_mark_node) = error_mark_node;
    9711              : 
    9712       294281 :   initialize_sizetypes ();
    9713              : 
    9714              :   /* Define both `signed char' and `unsigned char'.  */
    9715       294281 :   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
    9716       294281 :   TYPE_STRING_FLAG (signed_char_type_node) = 1;
    9717       294281 :   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
    9718       294281 :   TYPE_STRING_FLAG (unsigned_char_type_node) = 1;
    9719              : 
    9720              :   /* Define `char', which is like either `signed char' or `unsigned char'
    9721              :      but not the same as either.  */
    9722       294281 :   char_type_node
    9723       294281 :     = (signed_char
    9724       294281 :        ? make_signed_type (CHAR_TYPE_SIZE)
    9725        57763 :        : make_unsigned_type (CHAR_TYPE_SIZE));
    9726       294281 :   TYPE_STRING_FLAG (char_type_node) = 1;
    9727              : 
    9728       294281 :   short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
    9729       294281 :   short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
    9730       294281 :   integer_type_node = make_signed_type (INT_TYPE_SIZE);
    9731       294281 :   unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
    9732       301538 :   long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
    9733       301538 :   long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
    9734       294281 :   long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
    9735       294281 :   long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
    9736              : 
    9737       588562 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    9738              :     {
    9739       294281 :       int_n_trees[i].signed_type = make_signed_type (int_n_data[i].bitsize);
    9740       294281 :       int_n_trees[i].unsigned_type = make_unsigned_type (int_n_data[i].bitsize);
    9741              : 
    9742       294281 :       if (int_n_enabled_p[i])
    9743              :         {
    9744       287119 :           integer_types[itk_intN_0 + i * 2] = int_n_trees[i].signed_type;
    9745       287119 :           integer_types[itk_unsigned_intN_0 + i * 2] = int_n_trees[i].unsigned_type;
    9746              :         }
    9747              :     }
    9748              : 
    9749              :   /* Define a boolean type.  This type only represents boolean values but
    9750              :      may be larger than char depending on the value of BOOL_TYPE_SIZE.  */
    9751       294281 :   boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
    9752       294281 :   TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
    9753       294281 :   TYPE_PRECISION (boolean_type_node) = 1;
    9754       294281 :   TYPE_MAX_VALUE (boolean_type_node) = build_int_cst (boolean_type_node, 1);
    9755              : 
    9756              :   /* Define what type to use for size_t.  */
    9757       301538 :   size_type_node = unsigned_integer_tree_node_for_type (SIZE_TYPE);
    9758              : 
    9759              :   /* Define what type to use for ptrdiff_t.  */
    9760       301538 :   if (strcmp (PTRDIFF_TYPE, "int") == 0)
    9761         7257 :     ptrdiff_type_node = integer_type_node;
    9762       287024 :   else if (strcmp (PTRDIFF_TYPE, "long int") == 0)
    9763       287024 :     ptrdiff_type_node = long_integer_type_node;
    9764            0 :   else if (strcmp (PTRDIFF_TYPE, "long long int") == 0)
    9765            0 :     ptrdiff_type_node = long_long_integer_type_node;
    9766            0 :   else if (strcmp (PTRDIFF_TYPE, "short int") == 0)
    9767            0 :     ptrdiff_type_node = short_integer_type_node;
    9768              :   else
    9769              :     {
    9770            0 :       ptrdiff_type_node = NULL_TREE;
    9771            0 :       for (int i = 0; i < NUM_INT_N_ENTS; i++)
    9772            0 :         if (int_n_enabled_p[i])
    9773              :           {
    9774            0 :             char name[50], altname[50];
    9775            0 :             sprintf (name, "__int%d", int_n_data[i].bitsize);
    9776            0 :             sprintf (altname, "__int%d__", int_n_data[i].bitsize);
    9777              : 
    9778            0 :             if (strcmp (name, PTRDIFF_TYPE) == 0
    9779            0 :                 || strcmp (altname, PTRDIFF_TYPE) == 0)
    9780            0 :               ptrdiff_type_node = int_n_trees[i].signed_type;
    9781              :           }
    9782            0 :       if (ptrdiff_type_node == NULL_TREE)
    9783            0 :         gcc_unreachable ();
    9784              :     }
    9785              : 
    9786              :   /* Fill in the rest of the sized types.  Reuse existing type nodes
    9787              :      when possible.  */
    9788       294281 :   intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 0);
    9789       294281 :   intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 0);
    9790       294281 :   intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 0);
    9791       294281 :   intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 0);
    9792       294281 :   intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 0);
    9793              : 
    9794       294281 :   unsigned_intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 1);
    9795       294281 :   unsigned_intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 1);
    9796       294281 :   unsigned_intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 1);
    9797       294281 :   unsigned_intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 1);
    9798       294281 :   unsigned_intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 1);
    9799              : 
    9800              :   /* Don't call build_qualified type for atomics.  That routine does
    9801              :      special processing for atomics, and until they are initialized
    9802              :      it's better not to make that call.
    9803              : 
    9804              :      Check to see if there is a target override for atomic types.  */
    9805              : 
    9806       294281 :   atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node,
    9807       294281 :                                         targetm.atomic_align_for_mode (QImode));
    9808       294281 :   atomicHI_type_node = build_atomic_base (unsigned_intHI_type_node,
    9809       294281 :                                         targetm.atomic_align_for_mode (HImode));
    9810       294281 :   atomicSI_type_node = build_atomic_base (unsigned_intSI_type_node,
    9811       294281 :                                         targetm.atomic_align_for_mode (SImode));
    9812       294281 :   atomicDI_type_node = build_atomic_base (unsigned_intDI_type_node,
    9813       294281 :                                         targetm.atomic_align_for_mode (DImode));
    9814       294281 :   atomicTI_type_node = build_atomic_base (unsigned_intTI_type_node,
    9815       294281 :                                         targetm.atomic_align_for_mode (TImode));
    9816              : 
    9817       294281 :   access_public_node = get_identifier ("public");
    9818       294281 :   access_protected_node = get_identifier ("protected");
    9819       294281 :   access_private_node = get_identifier ("private");
    9820              : 
    9821              :   /* Define these next since types below may used them.  */
    9822       294281 :   integer_zero_node = build_int_cst (integer_type_node, 0);
    9823       294281 :   integer_one_node = build_int_cst (integer_type_node, 1);
    9824       294281 :   integer_minus_one_node = build_int_cst (integer_type_node, -1);
    9825              : 
    9826       294281 :   size_zero_node = size_int (0);
    9827       294281 :   size_one_node = size_int (1);
    9828       294281 :   bitsize_zero_node = bitsize_int (0);
    9829       294281 :   bitsize_one_node = bitsize_int (1);
    9830       294281 :   bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
    9831              : 
    9832       294281 :   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
    9833       294281 :   boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
    9834              : 
    9835       294281 :   void_type_node = make_node (VOID_TYPE);
    9836       294281 :   layout_type (void_type_node);
    9837              : 
    9838              :   /* We are not going to have real types in C with less than byte alignment,
    9839              :      so we might as well not have any types that claim to have it.  */
    9840       294281 :   SET_TYPE_ALIGN (void_type_node, BITS_PER_UNIT);
    9841       294281 :   TYPE_USER_ALIGN (void_type_node) = 0;
    9842              : 
    9843       294281 :   void_node = make_node (VOID_CST);
    9844       294281 :   TREE_TYPE (void_node) = void_type_node;
    9845              : 
    9846       294281 :   void_list_node = build_tree_list (NULL_TREE, void_type_node);
    9847              : 
    9848       294281 :   null_pointer_node = build_int_cst (build_pointer_type (void_type_node), 0);
    9849       294281 :   layout_type (TREE_TYPE (null_pointer_node));
    9850              : 
    9851       294281 :   ptr_type_node = build_pointer_type (void_type_node);
    9852       294281 :   const_ptr_type_node
    9853       294281 :     = build_pointer_type (build_type_variant (void_type_node, 1, 0));
    9854      2059967 :   for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
    9855      1765686 :     builtin_structptr_types[i].node = builtin_structptr_types[i].base;
    9856              : 
    9857       301538 :   pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
    9858              : 
    9859       294281 :   float_type_node = make_node (REAL_TYPE);
    9860       294281 :   machine_mode float_type_mode
    9861       294281 :     = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
    9862       294281 :   SET_TYPE_MODE (float_type_node, float_type_mode);
    9863       294281 :   TYPE_PRECISION (float_type_node)
    9864       294281 :     = GET_MODE_PRECISION (float_type_mode).to_constant ();
    9865       294281 :   layout_type (float_type_node);
    9866              : 
    9867       294281 :   double_type_node = make_node (REAL_TYPE);
    9868       294281 :   machine_mode double_type_mode
    9869       294281 :     = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
    9870       294281 :   SET_TYPE_MODE (double_type_node, double_type_mode);
    9871       294281 :   TYPE_PRECISION (double_type_node)
    9872       294281 :     = GET_MODE_PRECISION (double_type_mode).to_constant ();
    9873       294281 :   layout_type (double_type_node);
    9874              : 
    9875       294281 :   long_double_type_node = make_node (REAL_TYPE);
    9876       294281 :   machine_mode long_double_type_mode
    9877       294281 :     = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
    9878       294281 :   SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
    9879       294281 :   TYPE_PRECISION (long_double_type_node)
    9880       294281 :     = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
    9881       294281 :   layout_type (long_double_type_node);
    9882              : 
    9883      2648529 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    9884              :     {
    9885      2059967 :       int n = floatn_nx_types[i].n;
    9886      2059967 :       bool extended = floatn_nx_types[i].extended;
    9887      2059967 :       scalar_float_mode mode;
    9888      2059967 :       if (!targetm.floatn_mode (n, extended).exists (&mode))
    9889       294281 :         continue;
    9890      1765686 :       int precision = GET_MODE_PRECISION (mode);
    9891      1765686 :       FLOATN_NX_TYPE_NODE (i) = make_node (REAL_TYPE);
    9892      1765686 :       TYPE_PRECISION (FLOATN_NX_TYPE_NODE (i)) = precision;
    9893      1765686 :       layout_type (FLOATN_NX_TYPE_NODE (i));
    9894      1765686 :       SET_TYPE_MODE (FLOATN_NX_TYPE_NODE (i), mode);
    9895              :     }
    9896       294281 :   float128t_type_node = float128_type_node;
    9897              : #ifdef HAVE_BFmode
    9898       294281 :   if (REAL_MODE_FORMAT (BFmode) == &arm_bfloat_half_format
    9899       294281 :       && targetm.scalar_mode_supported_p (BFmode)
    9900       588562 :       && targetm.libgcc_floating_mode_supported_p (BFmode))
    9901              :     {
    9902       294281 :       bfloat16_type_node = make_node (REAL_TYPE);
    9903       294281 :       TYPE_PRECISION (bfloat16_type_node) = GET_MODE_PRECISION (BFmode);
    9904       294281 :       layout_type (bfloat16_type_node);
    9905       294281 :       SET_TYPE_MODE (bfloat16_type_node, BFmode);
    9906              :     }
    9907              : #endif
    9908              : 
    9909       294281 :   float_ptr_type_node = build_pointer_type (float_type_node);
    9910       294281 :   double_ptr_type_node = build_pointer_type (double_type_node);
    9911       294281 :   long_double_ptr_type_node = build_pointer_type (long_double_type_node);
    9912       294281 :   integer_ptr_type_node = build_pointer_type (integer_type_node);
    9913              : 
    9914              :   /* Fixed size integer types.  */
    9915       294281 :   uint16_type_node = make_or_reuse_type (16, 1);
    9916       294281 :   uint32_type_node = make_or_reuse_type (32, 1);
    9917       294281 :   uint64_type_node = make_or_reuse_type (64, 1);
    9918       294281 :   if (targetm.scalar_mode_supported_p (TImode))
    9919       287119 :     uint128_type_node = make_or_reuse_type (128, 1);
    9920              : 
    9921              :   /* Decimal float types. */
    9922       294281 :   if (targetm.decimal_float_supported_p ())
    9923              :     {
    9924       294281 :       dfloat32_type_node = make_node (REAL_TYPE);
    9925       294281 :       TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE;
    9926       294281 :       SET_TYPE_MODE (dfloat32_type_node, SDmode);
    9927       294281 :       layout_type (dfloat32_type_node);
    9928              : 
    9929       294281 :       dfloat64_type_node = make_node (REAL_TYPE);
    9930       294281 :       TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE;
    9931       294281 :       SET_TYPE_MODE (dfloat64_type_node, DDmode);
    9932       294281 :       layout_type (dfloat64_type_node);
    9933              : 
    9934       294281 :       dfloat128_type_node = make_node (REAL_TYPE);
    9935       294281 :       TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE;
    9936       294281 :       SET_TYPE_MODE (dfloat128_type_node, TDmode);
    9937       294281 :       layout_type (dfloat128_type_node);
    9938              : 
    9939       294281 :       dfloat64x_type_node = make_node (REAL_TYPE);
    9940       294281 :       TYPE_PRECISION (dfloat64x_type_node) = DECIMAL128_TYPE_SIZE;
    9941       294281 :       SET_TYPE_MODE (dfloat64x_type_node, TDmode);
    9942       294281 :       layout_type (dfloat64x_type_node);
    9943              :     }
    9944              : 
    9945       294281 :   complex_integer_type_node = build_complex_type (integer_type_node, true);
    9946       294281 :   complex_float_type_node = build_complex_type (float_type_node, true);
    9947       294281 :   complex_double_type_node = build_complex_type (double_type_node, true);
    9948       294281 :   complex_long_double_type_node = build_complex_type (long_double_type_node,
    9949              :                                                       true);
    9950              : 
    9951      2354248 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    9952              :     {
    9953      2059967 :       if (FLOATN_NX_TYPE_NODE (i) != NULL_TREE)
    9954      1765686 :         COMPLEX_FLOATN_NX_TYPE_NODE (i)
    9955      1765686 :           = build_complex_type (FLOATN_NX_TYPE_NODE (i));
    9956              :     }
    9957              : 
    9958              : /* Make fixed-point nodes based on sat/non-sat and signed/unsigned.  */
    9959              : #define MAKE_FIXED_TYPE_NODE(KIND,SIZE) \
    9960              :   sat_ ## KIND ## _type_node = \
    9961              :     make_sat_signed_ ## KIND ## _type (SIZE); \
    9962              :   sat_unsigned_ ## KIND ## _type_node = \
    9963              :     make_sat_unsigned_ ## KIND ## _type (SIZE); \
    9964              :   KIND ## _type_node = make_signed_ ## KIND ## _type (SIZE); \
    9965              :   unsigned_ ## KIND ## _type_node = \
    9966              :     make_unsigned_ ## KIND ## _type (SIZE);
    9967              : 
    9968              : #define MAKE_FIXED_TYPE_NODE_WIDTH(KIND,WIDTH,SIZE) \
    9969              :   sat_ ## WIDTH ## KIND ## _type_node = \
    9970              :     make_sat_signed_ ## KIND ## _type (SIZE); \
    9971              :   sat_unsigned_ ## WIDTH ## KIND ## _type_node = \
    9972              :     make_sat_unsigned_ ## KIND ## _type (SIZE); \
    9973              :   WIDTH ## KIND ## _type_node = make_signed_ ## KIND ## _type (SIZE); \
    9974              :   unsigned_ ## WIDTH ## KIND ## _type_node = \
    9975              :     make_unsigned_ ## KIND ## _type (SIZE);
    9976              : 
    9977              : /* Make fixed-point type nodes based on four different widths.  */
    9978              : #define MAKE_FIXED_TYPE_NODE_FAMILY(N1,N2) \
    9979              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, short_, SHORT_ ## N2 ## _TYPE_SIZE) \
    9980              :   MAKE_FIXED_TYPE_NODE (N1, N2 ## _TYPE_SIZE) \
    9981              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, long_, LONG_ ## N2 ## _TYPE_SIZE) \
    9982              :   MAKE_FIXED_TYPE_NODE_WIDTH (N1, long_long_, LONG_LONG_ ## N2 ## _TYPE_SIZE)
    9983              : 
    9984              : /* Make fixed-point mode nodes based on sat/non-sat and signed/unsigned.  */
    9985              : #define MAKE_FIXED_MODE_NODE(KIND,NAME,MODE) \
    9986              :   NAME ## _type_node = \
    9987              :     make_or_reuse_signed_ ## KIND ## _type (GET_MODE_BITSIZE (MODE ## mode)); \
    9988              :   u ## NAME ## _type_node = \
    9989              :     make_or_reuse_unsigned_ ## KIND ## _type \
    9990              :       (GET_MODE_BITSIZE (U ## MODE ## mode)); \
    9991              :   sat_ ## NAME ## _type_node = \
    9992              :     make_or_reuse_sat_signed_ ## KIND ## _type \
    9993              :       (GET_MODE_BITSIZE (MODE ## mode)); \
    9994              :   sat_u ## NAME ## _type_node = \
    9995              :     make_or_reuse_sat_unsigned_ ## KIND ## _type \
    9996              :       (GET_MODE_BITSIZE (U ## MODE ## mode));
    9997              : 
    9998              :   /* Fixed-point type and mode nodes.  */
    9999       294281 :   MAKE_FIXED_TYPE_NODE_FAMILY (fract, FRACT)
   10000       294281 :   MAKE_FIXED_TYPE_NODE_FAMILY (accum, ACCUM)
   10001       294281 :   MAKE_FIXED_MODE_NODE (fract, qq, QQ)
   10002       294281 :   MAKE_FIXED_MODE_NODE (fract, hq, HQ)
   10003       294281 :   MAKE_FIXED_MODE_NODE (fract, sq, SQ)
   10004       294281 :   MAKE_FIXED_MODE_NODE (fract, dq, DQ)
   10005       294281 :   MAKE_FIXED_MODE_NODE (fract, tq, TQ)
   10006       294281 :   MAKE_FIXED_MODE_NODE (accum, ha, HA)
   10007       294281 :   MAKE_FIXED_MODE_NODE (accum, sa, SA)
   10008       294281 :   MAKE_FIXED_MODE_NODE (accum, da, DA)
   10009       294281 :   MAKE_FIXED_MODE_NODE (accum, ta, TA)
   10010              : 
   10011       294281 :   {
   10012       294281 :     tree t = targetm.build_builtin_va_list ();
   10013              : 
   10014              :     /* Many back-ends define record types without setting TYPE_NAME.
   10015              :        If we copied the record type here, we'd keep the original
   10016              :        record type without a name.  This breaks name mangling.  So,
   10017              :        don't copy record types and let c_common_nodes_and_builtins()
   10018              :        declare the type to be __builtin_va_list.  */
   10019       294281 :     if (TREE_CODE (t) != RECORD_TYPE)
   10020       294281 :       t = build_variant_type_copy (t);
   10021              : 
   10022       294281 :     va_list_type_node = t;
   10023              :   }
   10024              : 
   10025              :   /* SCEV analyzer global shared trees.  */
   10026       294281 :   chrec_dont_know = make_node (SCEV_NOT_KNOWN);
   10027       294281 :   TREE_TYPE (chrec_dont_know) = void_type_node;
   10028       294281 :   chrec_known = make_node (SCEV_KNOWN);
   10029       294281 :   TREE_TYPE (chrec_known) = void_type_node;
   10030       294281 : }
   10031              : 
   10032              : /* Modify DECL for given flags.
   10033              :    TM_PURE attribute is set only on types, so the function will modify
   10034              :    DECL's type when ECF_TM_PURE is used.  */
   10035              : 
   10036              : void
   10037     33035585 : set_call_expr_flags (tree decl, int flags)
   10038              : {
   10039     33035585 :   if (flags & ECF_NOTHROW)
   10040     28677919 :     TREE_NOTHROW (decl) = 1;
   10041     33035585 :   if (flags & ECF_CONST)
   10042     13552899 :     TREE_READONLY (decl) = 1;
   10043     33035585 :   if (flags & ECF_PURE)
   10044      1589160 :     DECL_PURE_P (decl) = 1;
   10045     33035585 :   if (flags & ECF_LOOPING_CONST_OR_PURE)
   10046        53947 :     DECL_LOOPING_CONST_OR_PURE_P (decl) = 1;
   10047     33035585 :   if (flags & ECF_NOVOPS)
   10048            0 :     DECL_IS_NOVOPS (decl) = 1;
   10049     33035585 :   if (flags & ECF_NORETURN)
   10050      1245489 :     TREE_THIS_VOLATILE (decl) = 1;
   10051     33035585 :   if (flags & ECF_MALLOC)
   10052       753040 :     DECL_IS_MALLOC (decl) = 1;
   10053     33035585 :   if (flags & ECF_RETURNS_TWICE)
   10054            0 :     DECL_IS_RETURNS_TWICE (decl) = 1;
   10055     33035585 :   if (flags & ECF_LEAF)
   10056     28501698 :     DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
   10057     28501698 :                                         NULL, DECL_ATTRIBUTES (decl));
   10058     33035585 :   if (flags & ECF_COLD)
   10059       652611 :     DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("cold"),
   10060       652611 :                                         NULL, DECL_ATTRIBUTES (decl));
   10061     33035585 :   if (flags & ECF_RET1)
   10062            0 :     DECL_ATTRIBUTES (decl)
   10063            0 :       = tree_cons (get_identifier ("fn spec"),
   10064              :                    build_tree_list (NULL_TREE, build_string (2, "1 ")),
   10065            0 :                    DECL_ATTRIBUTES (decl));
   10066     33035585 :   if ((flags & ECF_TM_PURE) && flag_tm)
   10067          540 :     apply_tm_attr (decl, get_identifier ("transaction_pure"));
   10068     33035585 :   if ((flags & ECF_XTHROW))
   10069       424415 :     DECL_ATTRIBUTES (decl)
   10070       848830 :       = tree_cons (get_identifier ("expected_throw"),
   10071       424415 :                    NULL, DECL_ATTRIBUTES (decl));
   10072              : 
   10073     33035585 :   if (flags & ECF_CB_1_2)
   10074              :     {
   10075       386748 :       tree attr = callback_build_attr (1, 1, 2);
   10076       386748 :       TREE_CHAIN (attr) = DECL_ATTRIBUTES (decl);
   10077       386748 :       DECL_ATTRIBUTES (decl) = attr;
   10078              :     }
   10079              : 
   10080              :     /* Looping const or pure is implied by noreturn.
   10081              :      There is currently no way to declare looping const or looping pure alone.  */
   10082     33035585 :   gcc_assert (!(flags & ECF_LOOPING_CONST_OR_PURE)
   10083              :               || (flags & (ECF_CONST | ECF_PURE)));
   10084     33035585 : }
   10085              : 
   10086              : 
   10087              : /* A subroutine of build_common_builtin_nodes.  Define a builtin function.  */
   10088              : 
   10089              : static void
   10090      9725797 : local_define_builtin (const char *name, tree type, enum built_in_function code,
   10091              :                       const char *library_name, int ecf_flags)
   10092              : {
   10093      9725797 :   tree decl;
   10094              : 
   10095      9725797 :   decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL,
   10096              :                                library_name, NULL_TREE);
   10097      9725797 :   set_call_expr_flags (decl, ecf_flags);
   10098              : 
   10099      9725797 :   set_builtin_decl (code, decl, true);
   10100      9725797 : }
   10101              : 
   10102              : /* Call this function after instantiating all builtins that the language
   10103              :    front end cares about.  This will build the rest of the builtins
   10104              :    and internal functions that are relied upon by the tree optimizers and
   10105              :    the middle-end.  */
   10106              : 
   10107              : void
   10108       294264 : build_common_builtin_nodes (void)
   10109              : {
   10110       294264 :   tree tmp, ftype;
   10111       294264 :   int ecf_flags;
   10112              : 
   10113       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_CLEAR_PADDING))
   10114              :     {
   10115        59064 :       ftype = build_function_type_list (void_type_node,
   10116              :                                         ptr_type_node,
   10117              :                                         ptr_type_node,
   10118              :                                         NULL_TREE);
   10119        59064 :       local_define_builtin ("__builtin_clear_padding", ftype,
   10120              :                             BUILT_IN_CLEAR_PADDING,
   10121              :                             "__builtin_clear_padding",
   10122              :                             ECF_LEAF | ECF_NOTHROW);
   10123              :     }
   10124              : 
   10125       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE)
   10126       244961 :       || !builtin_decl_explicit_p (BUILT_IN_TRAP)
   10127       244961 :       || !builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP)
   10128       240317 :       || !builtin_decl_explicit_p (BUILT_IN_OBSERVABLE_CHKPT)
   10129       534581 :       || !builtin_decl_explicit_p (BUILT_IN_ABORT))
   10130              :     {
   10131        53947 :       ftype = build_function_type (void_type_node, void_list_node);
   10132        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE))
   10133        49303 :         local_define_builtin ("__builtin_unreachable", ftype,
   10134              :                               BUILT_IN_UNREACHABLE,
   10135              :                               "__builtin_unreachable",
   10136              :                               ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
   10137              :                               | ECF_CONST | ECF_COLD);
   10138        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE_TRAP))
   10139        53947 :         local_define_builtin ("__builtin_unreachable trap", ftype,
   10140              :                               BUILT_IN_UNREACHABLE_TRAP,
   10141              :                               "__builtin_unreachable trap",
   10142              :                               ECF_NOTHROW | ECF_LEAF | ECF_NORETURN
   10143              :                               | ECF_CONST | ECF_COLD);
   10144        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_ABORT))
   10145        53947 :         local_define_builtin ("__builtin_abort", ftype, BUILT_IN_ABORT,
   10146              :                               "abort",
   10147              :                               ECF_LEAF | ECF_NORETURN | ECF_CONST | ECF_COLD);
   10148        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_TRAP))
   10149        17074 :         local_define_builtin ("__builtin_trap", ftype, BUILT_IN_TRAP,
   10150              :                               "__builtin_trap",
   10151              :                               ECF_NORETURN | ECF_NOTHROW | ECF_LEAF | ECF_COLD);
   10152        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_OBSERVABLE_CHKPT))
   10153        53947 :         local_define_builtin ("__builtin_observable_checkpoint", ftype,
   10154              :                               BUILT_IN_OBSERVABLE_CHKPT,
   10155              :                               "__builtin_observable_checkpoint",
   10156              :                               ECF_NOTHROW | ECF_LEAF | ECF_CONST
   10157              :                               | ECF_LOOPING_CONST_OR_PURE);
   10158              :     }
   10159              : 
   10160       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY)
   10161       294264 :       || !builtin_decl_explicit_p (BUILT_IN_MEMMOVE))
   10162              :     {
   10163        53947 :       ftype = build_function_type_list (ptr_type_node,
   10164              :                                         ptr_type_node, const_ptr_type_node,
   10165              :                                         size_type_node, NULL_TREE);
   10166              : 
   10167        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY))
   10168        53947 :         local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
   10169              :                               "memcpy", ECF_NOTHROW | ECF_LEAF);
   10170        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_MEMMOVE))
   10171        49303 :         local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE,
   10172              :                               "memmove", ECF_NOTHROW | ECF_LEAF);
   10173              :     }
   10174              : 
   10175       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMCMP))
   10176              :     {
   10177        49303 :       ftype = build_function_type_list (integer_type_node, const_ptr_type_node,
   10178              :                                         const_ptr_type_node, size_type_node,
   10179              :                                         NULL_TREE);
   10180        49303 :       local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
   10181              :                             "memcmp", ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10182              :     }
   10183              : 
   10184       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_MEMSET))
   10185              :     {
   10186        49303 :       ftype = build_function_type_list (ptr_type_node,
   10187              :                                         ptr_type_node, integer_type_node,
   10188              :                                         size_type_node, NULL_TREE);
   10189        49303 :       local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
   10190              :                             "memset", ECF_NOTHROW | ECF_LEAF);
   10191              :     }
   10192              : 
   10193              :   /* If we're checking the stack, `alloca' can throw.  */
   10194       294196 :   const int alloca_flags
   10195       294264 :     = ECF_MALLOC | ECF_LEAF | (flag_stack_check ? 0 : ECF_NOTHROW);
   10196              : 
   10197       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_ALLOCA))
   10198              :     {
   10199        53947 :       ftype = build_function_type_list (ptr_type_node,
   10200              :                                         size_type_node, NULL_TREE);
   10201        53947 :       local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
   10202              :                             "alloca", alloca_flags);
   10203              :     }
   10204              : 
   10205       294264 :   ftype = build_function_type_list (ptr_type_node, size_type_node,
   10206              :                                     size_type_node, NULL_TREE);
   10207       294264 :   local_define_builtin ("__builtin_alloca_with_align", ftype,
   10208              :                         BUILT_IN_ALLOCA_WITH_ALIGN,
   10209              :                         "__builtin_alloca_with_align",
   10210              :                         alloca_flags);
   10211              : 
   10212       294264 :   ftype = build_function_type_list (ptr_type_node, size_type_node,
   10213              :                                     size_type_node, size_type_node, NULL_TREE);
   10214       294264 :   local_define_builtin ("__builtin_alloca_with_align_and_max", ftype,
   10215              :                         BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX,
   10216              :                         "__builtin_alloca_with_align_and_max",
   10217              :                         alloca_flags);
   10218              : 
   10219       294264 :   ftype = build_function_type_list (void_type_node,
   10220              :                                     ptr_type_node, ptr_type_node,
   10221              :                                     ptr_type_node, NULL_TREE);
   10222       294264 :   local_define_builtin ("__builtin_init_trampoline", ftype,
   10223              :                         BUILT_IN_INIT_TRAMPOLINE,
   10224              :                         "__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF);
   10225       294264 :   local_define_builtin ("__builtin_init_heap_trampoline", ftype,
   10226              :                         BUILT_IN_INIT_HEAP_TRAMPOLINE,
   10227              :                         "__builtin_init_heap_trampoline",
   10228              :                         ECF_NOTHROW | ECF_LEAF);
   10229       294264 :   local_define_builtin ("__builtin_init_descriptor", ftype,
   10230              :                         BUILT_IN_INIT_DESCRIPTOR,
   10231              :                         "__builtin_init_descriptor", ECF_NOTHROW | ECF_LEAF);
   10232              : 
   10233       294264 :   ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE);
   10234       294264 :   local_define_builtin ("__builtin_adjust_trampoline", ftype,
   10235              :                         BUILT_IN_ADJUST_TRAMPOLINE,
   10236              :                         "__builtin_adjust_trampoline",
   10237              :                         ECF_CONST | ECF_NOTHROW);
   10238       294264 :   local_define_builtin ("__builtin_adjust_descriptor", ftype,
   10239              :                         BUILT_IN_ADJUST_DESCRIPTOR,
   10240              :                         "__builtin_adjust_descriptor",
   10241              :                         ECF_CONST | ECF_NOTHROW);
   10242              : 
   10243       294264 :   ftype = build_function_type_list (void_type_node,
   10244              :                                     ptr_type_node, ptr_type_node, NULL_TREE);
   10245       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_CLEAR_CACHE))
   10246        53947 :     local_define_builtin ("__builtin___clear_cache", ftype,
   10247              :                           BUILT_IN_CLEAR_CACHE,
   10248              :                           "__clear_cache",
   10249              :                           ECF_NOTHROW);
   10250              : 
   10251       294264 :   local_define_builtin ("__builtin_nonlocal_goto", ftype,
   10252              :                         BUILT_IN_NONLOCAL_GOTO,
   10253              :                         "__builtin_nonlocal_goto",
   10254              :                         ECF_NORETURN | ECF_NOTHROW);
   10255              : 
   10256       294264 :   tree ptr_ptr_type_node = build_pointer_type (ptr_type_node);
   10257              : 
   10258       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_CREATED))
   10259              :     {
   10260        53947 :       ftype = build_function_type_list (void_type_node,
   10261              :                                         ptr_type_node, // void *chain
   10262              :                                         ptr_type_node, // void *func
   10263              :                                         ptr_ptr_type_node, // void **dst
   10264              :                                         NULL_TREE);
   10265        53947 :       local_define_builtin ("__builtin___gcc_nested_func_ptr_created", ftype,
   10266              :                             BUILT_IN_GCC_NESTED_PTR_CREATED,
   10267              :                             "__gcc_nested_func_ptr_created", ECF_NOTHROW);
   10268              :     }
   10269              : 
   10270       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_DELETED))
   10271              :     {
   10272        53947 :       ftype = build_function_type_list (void_type_node, NULL_TREE);
   10273        53947 :       local_define_builtin ("__builtin___gcc_nested_func_ptr_deleted", ftype,
   10274              :                             BUILT_IN_GCC_NESTED_PTR_DELETED,
   10275              :                             "__gcc_nested_func_ptr_deleted", ECF_NOTHROW);
   10276              :     }
   10277              : 
   10278       294264 :   ftype = build_function_type_list (void_type_node,
   10279              :                                     ptr_type_node, ptr_type_node, NULL_TREE);
   10280       294264 :   local_define_builtin ("__builtin_setjmp_setup", ftype,
   10281              :                         BUILT_IN_SETJMP_SETUP,
   10282              :                         "__builtin_setjmp_setup", ECF_NOTHROW);
   10283              : 
   10284       294264 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10285       294264 :   local_define_builtin ("__builtin_setjmp_receiver", ftype,
   10286              :                         BUILT_IN_SETJMP_RECEIVER,
   10287              :                         "__builtin_setjmp_receiver", ECF_NOTHROW | ECF_LEAF);
   10288              : 
   10289       294264 :   ftype = build_function_type_list (ptr_type_node, NULL_TREE);
   10290       294264 :   local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
   10291              :                         "__builtin_stack_save", ECF_NOTHROW | ECF_LEAF);
   10292              : 
   10293       294264 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10294       294264 :   local_define_builtin ("__builtin_stack_restore", ftype,
   10295              :                         BUILT_IN_STACK_RESTORE,
   10296              :                         "__builtin_stack_restore", ECF_NOTHROW | ECF_LEAF);
   10297              : 
   10298       294264 :   ftype = build_function_type_list (integer_type_node, const_ptr_type_node,
   10299              :                                     const_ptr_type_node, size_type_node,
   10300              :                                     NULL_TREE);
   10301       294264 :   local_define_builtin ("__builtin_memcmp_eq", ftype, BUILT_IN_MEMCMP_EQ,
   10302              :                         "__builtin_memcmp_eq",
   10303              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10304              : 
   10305       294264 :   local_define_builtin ("__builtin_strncmp_eq", ftype, BUILT_IN_STRNCMP_EQ,
   10306              :                         "__builtin_strncmp_eq",
   10307              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10308              : 
   10309       294264 :   local_define_builtin ("__builtin_strcmp_eq", ftype, BUILT_IN_STRCMP_EQ,
   10310              :                         "__builtin_strcmp_eq",
   10311              :                         ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10312              : 
   10313              :   /* If there's a possibility that we might use the ARM EABI, build the
   10314              :     alternate __cxa_end_cleanup node used to resume from C++.  */
   10315       294264 :   if (targetm.arm_eabi_unwinder)
   10316              :     {
   10317            0 :       ftype = build_function_type_list (void_type_node, NULL_TREE);
   10318            0 :       local_define_builtin ("__builtin_cxa_end_cleanup", ftype,
   10319              :                             BUILT_IN_CXA_END_CLEANUP,
   10320              :                             "__cxa_end_cleanup",
   10321              :                             ECF_NORETURN | ECF_XTHROW | ECF_LEAF);
   10322              :     }
   10323              : 
   10324       294264 :   ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
   10325       588528 :   local_define_builtin ("__builtin_unwind_resume", ftype,
   10326              :                         BUILT_IN_UNWIND_RESUME,
   10327       294264 :                         ((targetm_common.except_unwind_info (&global_options)
   10328              :                           == UI_SJLJ)
   10329              :                          ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"),
   10330              :                         ECF_NORETURN | ECF_XTHROW);
   10331              : 
   10332       294264 :   if (builtin_decl_explicit (BUILT_IN_RETURN_ADDRESS) == NULL_TREE)
   10333              :     {
   10334        49303 :       ftype = build_function_type_list (ptr_type_node, integer_type_node,
   10335              :                                         NULL_TREE);
   10336        49303 :       local_define_builtin ("__builtin_return_address", ftype,
   10337              :                             BUILT_IN_RETURN_ADDRESS,
   10338              :                             "__builtin_return_address",
   10339              :                             ECF_NOTHROW);
   10340              :     }
   10341              : 
   10342       294264 :   if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER)
   10343       294264 :       || !builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT))
   10344              :     {
   10345        53947 :       ftype = build_function_type_list (void_type_node, ptr_type_node,
   10346              :                                         ptr_type_node, NULL_TREE);
   10347        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER))
   10348        53947 :         local_define_builtin ("__cyg_profile_func_enter", ftype,
   10349              :                               BUILT_IN_PROFILE_FUNC_ENTER,
   10350              :                               "__cyg_profile_func_enter", 0);
   10351        53947 :       if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT))
   10352        53947 :         local_define_builtin ("__cyg_profile_func_exit", ftype,
   10353              :                               BUILT_IN_PROFILE_FUNC_EXIT,
   10354              :                               "__cyg_profile_func_exit", 0);
   10355              :     }
   10356              : 
   10357              :   /* The exception object and filter values from the runtime.  The argument
   10358              :      must be zero before exception lowering, i.e. from the front end.  After
   10359              :      exception lowering, it will be the region number for the exception
   10360              :      landing pad.  These functions are PURE instead of CONST to prevent
   10361              :      them from being hoisted past the exception edge that will initialize
   10362              :      its value in the landing pad.  */
   10363       294264 :   ftype = build_function_type_list (ptr_type_node,
   10364              :                                     integer_type_node, NULL_TREE);
   10365       294264 :   ecf_flags = ECF_PURE | ECF_NOTHROW | ECF_LEAF;
   10366              :   /* Only use TM_PURE if we have TM language support.  */
   10367       294264 :   if (builtin_decl_explicit_p (BUILT_IN_TM_LOAD_1))
   10368          476 :     ecf_flags |= ECF_TM_PURE;
   10369       294264 :   local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER,
   10370              :                         "__builtin_eh_pointer", ecf_flags);
   10371              : 
   10372       294264 :   tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0);
   10373       294264 :   ftype = build_function_type_list (tmp, integer_type_node, NULL_TREE);
   10374       294264 :   local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER,
   10375              :                         "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW | ECF_LEAF);
   10376              : 
   10377       294264 :   ftype = build_function_type_list (void_type_node,
   10378              :                                     integer_type_node, integer_type_node,
   10379              :                                     NULL_TREE);
   10380       294264 :   local_define_builtin ("__builtin_eh_copy_values", ftype,
   10381              :                         BUILT_IN_EH_COPY_VALUES,
   10382              :                         "__builtin_eh_copy_values", ECF_NOTHROW);
   10383              : 
   10384              :   /* Complex multiplication and division.  These are handled as builtins
   10385              :      rather than optabs because emit_library_call_value doesn't support
   10386              :      complex.  Further, we can do slightly better with folding these
   10387              :      beasties if the real and complex parts of the arguments are separate.  */
   10388       294264 :   {
   10389       294264 :     int mode;
   10390              : 
   10391      2354112 :     for (mode = MIN_MODE_COMPLEX_FLOAT; mode <= MAX_MODE_COMPLEX_FLOAT; ++mode)
   10392              :       {
   10393      1765584 :         char mode_name_buf[4], *q;
   10394      1765584 :         const char *p;
   10395      1765584 :         enum built_in_function mcode, dcode;
   10396      1765584 :         tree type, inner_type;
   10397      1765584 :         const char *prefix = "__";
   10398              : 
   10399      1765584 :         if (targetm.libfunc_gnu_prefix)
   10400            0 :           prefix = "__gnu_";
   10401              : 
   10402      1765584 :         type = lang_hooks.types.type_for_mode ((machine_mode) mode, 0);
   10403      1765584 :         if (type == NULL)
   10404       129255 :           continue;
   10405      1636329 :         inner_type = TREE_TYPE (type);
   10406              : 
   10407      1636329 :         ftype = build_function_type_list (type, inner_type, inner_type,
   10408              :                                           inner_type, inner_type, NULL_TREE);
   10409              : 
   10410      1636329 :         mcode = ((enum built_in_function)
   10411      1636329 :                  (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
   10412      1636329 :         dcode = ((enum built_in_function)
   10413      1636329 :                  (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
   10414              : 
   10415      4908987 :         for (p = GET_MODE_NAME (mode), q = mode_name_buf; *p; p++, q++)
   10416      3272658 :           *q = TOLOWER (*p);
   10417      1636329 :         *q = '\0';
   10418              : 
   10419              :         /* For -ftrapping-math these should throw from a former
   10420              :            -fnon-call-exception stmt.  */
   10421      1636329 :         built_in_names[mcode] = concat (prefix, "mul", mode_name_buf, "3",
   10422              :                                         NULL);
   10423      1636329 :         local_define_builtin (built_in_names[mcode], ftype, mcode,
   10424              :                               built_in_names[mcode],
   10425              :                               ECF_CONST | ECF_LEAF);
   10426              : 
   10427      1636329 :         built_in_names[dcode] = concat (prefix, "div", mode_name_buf, "3",
   10428              :                                         NULL);
   10429      1636329 :         local_define_builtin (built_in_names[dcode], ftype, dcode,
   10430              :                               built_in_names[dcode],
   10431              :                               ECF_CONST | ECF_LEAF);
   10432              :       }
   10433              :   }
   10434              : 
   10435       294264 :   init_internal_fns ();
   10436       294264 : }
   10437              : 
   10438              : /* HACK.  GROSS.  This is absolutely disgusting.  I wish there was a
   10439              :    better way.
   10440              : 
   10441              :    If we requested a pointer to a vector, build up the pointers that
   10442              :    we stripped off while looking for the inner type.  Similarly for
   10443              :    return values from functions.
   10444              : 
   10445              :    The argument TYPE is the top of the chain, and BOTTOM is the
   10446              :    new type which we will point to.  */
   10447              : 
   10448              : tree
   10449            0 : reconstruct_complex_type (tree type, tree bottom)
   10450              : {
   10451            0 :   tree inner, outer;
   10452              : 
   10453            0 :   if (TREE_CODE (type) == POINTER_TYPE)
   10454              :     {
   10455            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10456            0 :       outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
   10457            0 :                                            TYPE_REF_CAN_ALIAS_ALL (type));
   10458              :     }
   10459              :   else if (TREE_CODE (type) == REFERENCE_TYPE)
   10460              :     {
   10461            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10462            0 :       outer = build_reference_type_for_mode (inner, TYPE_MODE (type),
   10463            0 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
   10464              :     }
   10465              :   else if (TREE_CODE (type) == ARRAY_TYPE)
   10466              :     {
   10467            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10468            0 :       outer = build_array_type (inner, TYPE_DOMAIN (type));
   10469              :     }
   10470              :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   10471              :     {
   10472            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10473            0 :       outer = build_function_type (inner, TYPE_ARG_TYPES (type),
   10474            0 :                                    TYPE_NO_NAMED_ARGS_STDARG_P (type));
   10475              :     }
   10476              :   else if (TREE_CODE (type) == METHOD_TYPE)
   10477              :     {
   10478            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10479              :       /* The build_method_type_directly() routine prepends 'this' to argument list,
   10480              :          so we must compensate by getting rid of it.  */
   10481            0 :       outer
   10482              :         = build_method_type_directly
   10483            0 :             (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type))),
   10484              :              inner,
   10485            0 :              TREE_CHAIN (TYPE_ARG_TYPES (type)));
   10486              :     }
   10487              :   else if (TREE_CODE (type) == OFFSET_TYPE)
   10488              :     {
   10489            0 :       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
   10490            0 :       outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner);
   10491              :     }
   10492              :   else
   10493              :     return bottom;
   10494              : 
   10495            0 :   return build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
   10496            0 :                                             TYPE_QUALS (type));
   10497              : }
   10498              : 
   10499              : /* Returns a vector tree node given a mode (integer, vector, or BLKmode) and
   10500              :    the inner type.  */
   10501              : tree
   10502     33555228 : build_vector_type_for_mode (tree innertype, machine_mode mode)
   10503              : {
   10504     33555228 :   poly_int64 nunits;
   10505     33555228 :   unsigned int bitsize;
   10506              : 
   10507     33555228 :   switch (GET_MODE_CLASS (mode))
   10508              :     {
   10509     33553860 :     case MODE_VECTOR_BOOL:
   10510     33553860 :     case MODE_VECTOR_INT:
   10511     33553860 :     case MODE_VECTOR_FLOAT:
   10512     33553860 :     case MODE_VECTOR_FRACT:
   10513     33553860 :     case MODE_VECTOR_UFRACT:
   10514     33553860 :     case MODE_VECTOR_ACCUM:
   10515     33553860 :     case MODE_VECTOR_UACCUM:
   10516     67107720 :       nunits = GET_MODE_NUNITS (mode);
   10517     33553860 :       break;
   10518              : 
   10519         1368 :     case MODE_INT:
   10520              :       /* Check that there are no leftover bits.  */
   10521         1368 :       bitsize = GET_MODE_BITSIZE (as_a <scalar_int_mode> (mode));
   10522         1368 :       gcc_assert (bitsize % TREE_INT_CST_LOW (TYPE_SIZE (innertype)) == 0);
   10523         1368 :       nunits = bitsize / TREE_INT_CST_LOW (TYPE_SIZE (innertype));
   10524         1368 :       break;
   10525              : 
   10526            0 :     default:
   10527            0 :       gcc_unreachable ();
   10528              :     }
   10529              : 
   10530     33555228 :   return make_vector_type (innertype, nunits, mode);
   10531              : }
   10532              : 
   10533              : /* Similarly, but takes the inner type and number of units, which must be
   10534              :    a power of two.  */
   10535              : 
   10536              : tree
   10537      2931620 : build_vector_type (tree innertype, poly_int64 nunits)
   10538              : {
   10539      2931620 :   return make_vector_type (innertype, nunits, VOIDmode);
   10540              : }
   10541              : 
   10542              : /* Build a truth vector with NUNITS units, giving it mode MASK_MODE.  */
   10543              : 
   10544              : tree
   10545      2758154 : build_truth_vector_type_for_mode (poly_uint64 nunits, machine_mode mask_mode)
   10546              : {
   10547      2758154 :   gcc_assert (mask_mode != BLKmode);
   10548              : 
   10549      2758154 :   unsigned HOST_WIDE_INT esize;
   10550      2758154 :   if (VECTOR_MODE_P (mask_mode))
   10551              :     {
   10552      2620041 :       poly_uint64 vsize = GET_MODE_PRECISION (mask_mode);
   10553      2620041 :       esize = vector_element_size (vsize, nunits);
   10554      2620041 :     }
   10555              :   else
   10556              :     esize = 1;
   10557              : 
   10558      2758154 :   tree bool_type = build_nonstandard_boolean_type (esize);
   10559              : 
   10560      2758154 :   return make_vector_type (bool_type, nunits, mask_mode);
   10561              : }
   10562              : 
   10563              : /* Build a vector type that holds one boolean result for each element of
   10564              :    vector type VECTYPE.  The public interface for this operation is
   10565              :    truth_type_for.  */
   10566              : 
   10567              : static tree
   10568      2746964 : build_truth_vector_type_for (tree vectype)
   10569              : {
   10570      2746964 :   machine_mode vector_mode = TYPE_MODE (vectype);
   10571      2746964 :   poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
   10572              : 
   10573      2746964 :   machine_mode mask_mode;
   10574       104580 :   if (VECTOR_MODE_P (vector_mode)
   10575      2850923 :       && targetm.vectorize.get_mask_mode (vector_mode).exists (&mask_mode))
   10576      2746343 :     return build_truth_vector_type_for_mode (nunits, mask_mode);
   10577              : 
   10578          621 :   poly_uint64 vsize = tree_to_poly_uint64 (TYPE_SIZE (vectype));
   10579          621 :   unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
   10580          621 :   tree bool_type = build_nonstandard_boolean_type (esize);
   10581              : 
   10582          621 :   return make_vector_type (bool_type, nunits, VOIDmode);
   10583              : }
   10584              : 
   10585              : /* Like build_vector_type, but builds a variant type with TYPE_VECTOR_OPAQUE
   10586              :    set.  */
   10587              : 
   10588              : tree
   10589       110294 : build_opaque_vector_type (tree innertype, poly_int64 nunits)
   10590              : {
   10591       110294 :   tree t = make_vector_type (innertype, nunits, VOIDmode);
   10592       110294 :   tree cand;
   10593              :   /* We always build the non-opaque variant before the opaque one,
   10594              :      so if it already exists, it is TYPE_NEXT_VARIANT of this one.  */
   10595       110294 :   cand = TYPE_NEXT_VARIANT (t);
   10596       110294 :   if (cand
   10597        98569 :       && TYPE_VECTOR_OPAQUE (cand)
   10598       174070 :       && check_qualified_type (cand, t, TYPE_QUALS (t)))
   10599              :     return cand;
   10600              :   /* Otherwise build a variant type and make sure to queue it after
   10601              :      the non-opaque type.  */
   10602        46519 :   cand = build_distinct_type_copy (t);
   10603        46519 :   TYPE_VECTOR_OPAQUE (cand) = true;
   10604        46519 :   TYPE_CANONICAL (cand) = TYPE_CANONICAL (t);
   10605        46519 :   TYPE_NEXT_VARIANT (cand) = TYPE_NEXT_VARIANT (t);
   10606        46519 :   TYPE_NEXT_VARIANT (t) = cand;
   10607        46519 :   TYPE_MAIN_VARIANT (cand) = TYPE_MAIN_VARIANT (t);
   10608              :   /* Type variants have no alias set defined.  */
   10609        46519 :   TYPE_ALIAS_SET (cand) = -1;
   10610        46519 :   return cand;
   10611              : }
   10612              : 
   10613              : /* Return the value of element I of VECTOR_CST T as a wide_int.  */
   10614              : 
   10615              : static poly_wide_int
   10616       539483 : vector_cst_int_elt (const_tree t, unsigned int i)
   10617              : {
   10618              :   /* First handle elements that are directly encoded.  */
   10619       539483 :   unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
   10620       539483 :   if (i < encoded_nelts)
   10621            0 :     return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, i));
   10622              : 
   10623              :   /* Identify the pattern that contains element I and work out the index of
   10624              :      the last encoded element for that pattern.  */
   10625       539483 :   unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
   10626       539483 :   unsigned int pattern = i % npatterns;
   10627       539483 :   unsigned int count = i / npatterns;
   10628       539483 :   unsigned int final_i = encoded_nelts - npatterns + pattern;
   10629              : 
   10630              :   /* If there are no steps, the final encoded value is the right one.  */
   10631       539483 :   if (!VECTOR_CST_STEPPED_P (t))
   10632            0 :     return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
   10633              : 
   10634              :   /* Otherwise work out the value from the last two encoded elements.  */
   10635       539483 :   tree v1 = VECTOR_CST_ENCODED_ELT (t, final_i - npatterns);
   10636       539483 :   tree v2 = VECTOR_CST_ENCODED_ELT (t, final_i);
   10637       539483 :   poly_wide_int diff = wi::to_poly_wide (v2) - wi::to_poly_wide (v1);
   10638       539483 :   return wi::to_poly_wide (v2) + (count - 2) * diff;
   10639       539483 : }
   10640              : 
   10641              : /* Return the value of element I of VECTOR_CST T.  */
   10642              : 
   10643              : tree
   10644      8199266 : vector_cst_elt (const_tree t, unsigned int i)
   10645              : {
   10646              :   /* First handle elements that are directly encoded.  */
   10647      8199266 :   unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
   10648      8199266 :   if (i < encoded_nelts)
   10649      5280917 :     return VECTOR_CST_ENCODED_ELT (t, i);
   10650              : 
   10651              :   /* If there are no steps, the final encoded value is the right one.  */
   10652      2918349 :   if (!VECTOR_CST_STEPPED_P (t))
   10653              :     {
   10654              :       /* Identify the pattern that contains element I and work out the index of
   10655              :          the last encoded element for that pattern.  */
   10656      2378866 :       unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
   10657      2378866 :       unsigned int pattern = i % npatterns;
   10658      2378866 :       unsigned int final_i = encoded_nelts - npatterns + pattern;
   10659      2378866 :       return VECTOR_CST_ENCODED_ELT (t, final_i);
   10660              :     }
   10661              : 
   10662              :   /* Otherwise work out the value from the last two encoded elements.  */
   10663       539483 :   return wide_int_to_tree (TREE_TYPE (TREE_TYPE (t)),
   10664      1078966 :                            vector_cst_int_elt (t, i));
   10665              : }
   10666              : 
   10667              : /* Given an initializer INIT, return TRUE if INIT is zero or some
   10668              :    aggregate of zeros.  Otherwise return FALSE.  If NONZERO is not
   10669              :    null, set *NONZERO if and only if INIT is known not to be all
   10670              :    zeros.  The combination of return value of false and *NONZERO
   10671              :    false implies that INIT may but need not be all zeros.  Other
   10672              :    combinations indicate definitive answers.  */
   10673              : 
   10674              : bool
   10675     44971309 : initializer_zerop (const_tree init, bool *nonzero /* = NULL */)
   10676              : {
   10677     44971309 :   bool dummy;
   10678     44971309 :   if (!nonzero)
   10679     42188165 :     nonzero = &dummy;
   10680              : 
   10681              :   /* Conservatively clear NONZERO and set it only if INIT is definitely
   10682              :      not all zero.  */
   10683     44971309 :   *nonzero = false;
   10684              : 
   10685     44971309 :   STRIP_NOPS (init);
   10686              : 
   10687     44971309 :   unsigned HOST_WIDE_INT off = 0;
   10688              : 
   10689     44971309 :   switch (TREE_CODE (init))
   10690              :     {
   10691     17328062 :     case INTEGER_CST:
   10692     17328062 :       if (integer_zerop (init))
   10693              :         return true;
   10694              : 
   10695     10993353 :       *nonzero = true;
   10696     10993353 :       return false;
   10697              : 
   10698       578771 :     case REAL_CST:
   10699              :       /* ??? Note that this is not correct for C4X float formats.  There,
   10700              :          a bit pattern of all zeros is 1.0; 0.0 is encoded with the most
   10701              :          negative exponent.  */
   10702       578771 :       if (real_zerop (init)
   10703       676450 :           && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init)))
   10704              :         return true;
   10705              : 
   10706       484276 :       *nonzero = true;
   10707       484276 :       return false;
   10708              : 
   10709            0 :     case FIXED_CST:
   10710            0 :       if (fixed_zerop (init))
   10711              :         return true;
   10712              : 
   10713            0 :       *nonzero = true;
   10714            0 :       return false;
   10715              : 
   10716        18320 :     case COMPLEX_CST:
   10717        18320 :       if (integer_zerop (init)
   10718        18320 :           || (real_zerop (init)
   10719         3248 :               && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init)))
   10720         3168 :               && !REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init)))))
   10721              :         return true;
   10722              : 
   10723        14974 :       *nonzero = true;
   10724        14974 :       return false;
   10725              : 
   10726      1183241 :     case VECTOR_CST:
   10727      1183241 :       if (VECTOR_CST_NPATTERNS (init) == 1
   10728      1088000 :           && VECTOR_CST_DUPLICATE_P (init)
   10729      1863466 :           && initializer_zerop (VECTOR_CST_ENCODED_ELT (init, 0)))
   10730              :         return true;
   10731              : 
   10732       824798 :       *nonzero = true;
   10733       824798 :       return false;
   10734              : 
   10735              :     case RAW_DATA_CST:
   10736         1961 :       for (unsigned int i = 0; i < (unsigned int) RAW_DATA_LENGTH (init); ++i)
   10737         1961 :         if (RAW_DATA_POINTER (init)[i])
   10738              :           {
   10739         1915 :             *nonzero = true;
   10740         1915 :             return false;
   10741              :           }
   10742              :       return true;
   10743              : 
   10744      4369803 :     case CONSTRUCTOR:
   10745      4369803 :       {
   10746      4369803 :         if (TREE_CLOBBER_P (init))
   10747              :           return false;
   10748              : 
   10749              :         unsigned HOST_WIDE_INT idx;
   10750              :         tree elt;
   10751              : 
   10752      3673471 :         FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (init), idx, elt)
   10753      2783144 :           if (!initializer_zerop (elt, nonzero))
   10754              :             return false;
   10755              : 
   10756              :         return true;
   10757              :       }
   10758              : 
   10759       373022 :     case MEM_REF:
   10760       373022 :       {
   10761       373022 :         tree arg = TREE_OPERAND (init, 0);
   10762       373022 :         if (TREE_CODE (arg) != ADDR_EXPR)
   10763              :           return false;
   10764        93531 :         tree offset = TREE_OPERAND (init, 1);
   10765        93531 :         if (TREE_CODE (offset) != INTEGER_CST
   10766        93531 :             || !tree_fits_uhwi_p (offset))
   10767              :           return false;
   10768        93531 :         off = tree_to_uhwi (offset);
   10769        93531 :         if (INT_MAX < off)
   10770              :           return false;
   10771        93527 :         arg = TREE_OPERAND (arg, 0);
   10772        93527 :         if (TREE_CODE (arg) != STRING_CST)
   10773              :           return false;
   10774              :         init = arg;
   10775              :       }
   10776              :       /* Fall through.  */
   10777              : 
   10778              :     case STRING_CST:
   10779              :       {
   10780              :         gcc_assert (off <= INT_MAX);
   10781              : 
   10782       156802 :         int i = off;
   10783       156802 :         int n = TREE_STRING_LENGTH (init);
   10784       156802 :         if (n <= i)
   10785              :           return false;
   10786              : 
   10787              :         /* We need to loop through all elements to handle cases like
   10788              :            "\0" and "\0foobar".  */
   10789       168958 :         for (i = 0; i < n; ++i)
   10790       163428 :           if (TREE_STRING_POINTER (init)[i] != '\0')
   10791              :             {
   10792       151239 :               *nonzero = true;
   10793       151239 :               return false;
   10794              :             }
   10795              : 
   10796              :         return true;
   10797              :       }
   10798              : 
   10799              :     default:
   10800              :       return false;
   10801              :     }
   10802              : }
   10803              : 
   10804              : /* Return true if EXPR is an initializer expression in which every element
   10805              :    is a constant that is numerically equal to 0 or 1.  The elements do not
   10806              :    need to be equal to each other.  */
   10807              : 
   10808              : bool
   10809       132860 : initializer_each_zero_or_onep (const_tree expr)
   10810              : {
   10811       132860 :   STRIP_ANY_LOCATION_WRAPPER (expr);
   10812              : 
   10813       132860 :   switch (TREE_CODE (expr))
   10814              :     {
   10815        47285 :     case INTEGER_CST:
   10816        47285 :       return integer_zerop (expr) || integer_onep (expr);
   10817              : 
   10818        24914 :     case REAL_CST:
   10819        24914 :       return real_zerop (expr) || real_onep (expr);
   10820              : 
   10821        60661 :     case VECTOR_CST:
   10822        60661 :       {
   10823        60661 :         unsigned HOST_WIDE_INT nelts = vector_cst_encoded_nelts (expr);
   10824        60661 :         if (VECTOR_CST_STEPPED_P (expr)
   10825        60661 :             && !TYPE_VECTOR_SUBPARTS (TREE_TYPE (expr)).is_constant (&nelts))
   10826              :           return false;
   10827              : 
   10828        74644 :         for (unsigned int i = 0; i < nelts; ++i)
   10829              :           {
   10830        72199 :             tree elt = vector_cst_elt (expr, i);
   10831        72199 :             if (!initializer_each_zero_or_onep (elt))
   10832              :               return false;
   10833              :           }
   10834              : 
   10835              :         return true;
   10836              :       }
   10837              : 
   10838              :     default:
   10839              :       return false;
   10840              :     }
   10841              : }
   10842              : 
   10843              : /* Check if vector VEC consists of all the equal elements and
   10844              :    that the number of elements corresponds to the type of VEC.
   10845              :    The function returns first element of the vector
   10846              :    or NULL_TREE if the vector is not uniform.  */
   10847              : tree
   10848      3312278 : uniform_vector_p (const_tree vec)
   10849              : {
   10850      3312278 :   tree first, t;
   10851      3312278 :   unsigned HOST_WIDE_INT i, nelts;
   10852              : 
   10853      3312278 :   if (vec == NULL_TREE)
   10854              :     return NULL_TREE;
   10855              : 
   10856      3312278 :   gcc_assert (VECTOR_TYPE_P (TREE_TYPE (vec)));
   10857              : 
   10858      3312278 :   if (TREE_CODE (vec) == VEC_DUPLICATE_EXPR)
   10859            0 :     return TREE_OPERAND (vec, 0);
   10860              : 
   10861      3312278 :   else if (TREE_CODE (vec) == VECTOR_CST)
   10862              :     {
   10863       406472 :       if (VECTOR_CST_NPATTERNS (vec) == 1 && VECTOR_CST_DUPLICATE_P (vec))
   10864       340355 :         return VECTOR_CST_ENCODED_ELT (vec, 0);
   10865              :       return NULL_TREE;
   10866              :     }
   10867              : 
   10868      2905806 :   else if (TREE_CODE (vec) == CONSTRUCTOR
   10869      2905806 :            && TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec)).is_constant (&nelts))
   10870              :     {
   10871       180444 :       first = error_mark_node;
   10872              : 
   10873       590392 :       FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (vec), i, t)
   10874              :         {
   10875       526969 :           if (i == 0)
   10876              :             {
   10877       180444 :               first = t;
   10878       180444 :               continue;
   10879              :             }
   10880       346525 :           if (!operand_equal_p (first, t, 0))
   10881              :             return NULL_TREE;
   10882              :         }
   10883        63423 :       if (i != nelts)
   10884              :         return NULL_TREE;
   10885              : 
   10886        63127 :       if (TREE_CODE (first) == CONSTRUCTOR || TREE_CODE (first) == VECTOR_CST)
   10887            0 :         return uniform_vector_p (first);
   10888              :       return first;
   10889              :     }
   10890              : 
   10891              :   return NULL_TREE;
   10892              : }
   10893              : 
   10894              : /* If OP is a uniform vector return the element it is a splat from.  */
   10895              : 
   10896              : tree
   10897       291899 : ssa_uniform_vector_p (tree op)
   10898              : {
   10899       291899 :   if (TREE_CODE (op) == VECTOR_CST
   10900              :       || TREE_CODE (op) == VEC_DUPLICATE_EXPR
   10901              :       || TREE_CODE (op) == CONSTRUCTOR)
   10902        12106 :     return uniform_vector_p (op);
   10903              :   if (TREE_CODE (op) == SSA_NAME)
   10904              :     {
   10905       279793 :       gimple *def_stmt = SSA_NAME_DEF_STMT (op);
   10906       279793 :       if (gimple_assign_single_p (def_stmt))
   10907       119261 :         return uniform_vector_p (gimple_assign_rhs1 (def_stmt));
   10908              :       /* A VEC_DUPLICATE_EXPR is a unary assignment, so it is not covered
   10909              :          by the gimple_assign_single_p case above.  */
   10910       160532 :       if (is_gimple_assign (def_stmt)
   10911       160532 :           && gimple_assign_rhs_code (def_stmt) == VEC_DUPLICATE_EXPR)
   10912            0 :         return gimple_assign_rhs1 (def_stmt);
   10913              :     }
   10914              :   return NULL_TREE;
   10915              : }
   10916              : 
   10917              : /* If the argument is INTEGER_CST, return it.  If the argument is vector
   10918              :    with all elements the same INTEGER_CST, return that INTEGER_CST.  Otherwise
   10919              :    return NULL_TREE.
   10920              :    Look through location wrappers. */
   10921              : 
   10922              : tree
   10923    896928136 : uniform_integer_cst_p (tree t)
   10924              : {
   10925    896928136 :   STRIP_ANY_LOCATION_WRAPPER (t);
   10926              : 
   10927    896928136 :   if (TREE_CODE (t) == INTEGER_CST)
   10928              :     return t;
   10929              : 
   10930    362231131 :   if (VECTOR_TYPE_P (TREE_TYPE (t)))
   10931              :     {
   10932      1405985 :       t = uniform_vector_p (t);
   10933      1405985 :       if (t && TREE_CODE (t) == INTEGER_CST)
   10934       285465 :         return t;
   10935              :     }
   10936              : 
   10937              :   return NULL_TREE;
   10938              : }
   10939              : 
   10940              : /* Return true if ELT1 and ELT2 are INTEGER_CSTs and if ELT1 - ELT2 is
   10941              :    consistent with the uniform difference recorded in DIFF.  */
   10942              : 
   10943              : static bool
   10944          295 : record_uniform_integer_difference (const_tree elt1, const_tree elt2,
   10945              :                                    widest_int *diff, bool *diff_p)
   10946              : {
   10947          295 :   STRIP_ANY_LOCATION_WRAPPER (elt1);
   10948          295 :   STRIP_ANY_LOCATION_WRAPPER (elt2);
   10949              : 
   10950          295 :   if (TREE_CODE (elt1) != INTEGER_CST
   10951           94 :       || TREE_CODE (elt2) != INTEGER_CST)
   10952              :     return false;
   10953              : 
   10954           94 :   widest_int elt_diff = wi::to_widest (elt1) - wi::to_widest (elt2);
   10955           94 :   if (!*diff_p)
   10956              :     {
   10957           94 :       *diff = elt_diff;
   10958           94 :       *diff_p = true;
   10959           94 :       return true;
   10960              :     }
   10961              : 
   10962            0 :   return *diff == elt_diff;
   10963          295 : }
   10964              : 
   10965              : /* Return the uniform difference between two INTEGER_CSTs or corresponding
   10966              :    elements of two VECTOR_CSTs or NULL_TREE if no such difference exists.  */
   10967              : 
   10968              : tree
   10969          295 : uniform_vector_difference_p (const_tree t1, const_tree t2)
   10970              : {
   10971          295 :   STRIP_ANY_LOCATION_WRAPPER (t1);
   10972          295 :   STRIP_ANY_LOCATION_WRAPPER (t2);
   10973              : 
   10974          295 :   if (TREE_CODE (t1) == INTEGER_CST
   10975            0 :       && TREE_CODE (t2) == INTEGER_CST)
   10976              :     {
   10977            0 :       widest_int diff = wi::to_widest (t1) - wi::to_widest (t2);
   10978            0 :       if (!wi::fits_shwi_p (diff))
   10979              :         return NULL_TREE;
   10980            0 :       return build_int_cst (long_long_integer_type_node, diff.to_shwi ());
   10981            0 :     }
   10982              : 
   10983          295 :   if (TREE_CODE (t1) != VECTOR_CST
   10984          295 :       || TREE_CODE (t2) != VECTOR_CST
   10985          590 :       || !known_eq (VECTOR_CST_NELTS (t1), VECTOR_CST_NELTS (t2)))
   10986              :     return NULL_TREE;
   10987              : 
   10988          295 :   widest_int diff;
   10989          295 :   bool diff_p = false;
   10990              : 
   10991          295 :   if (VECTOR_CST_LOG2_NPATTERNS (t1) == VECTOR_CST_LOG2_NPATTERNS (t2)
   10992          295 :       && (VECTOR_CST_NELTS_PER_PATTERN (t1)
   10993          295 :           == VECTOR_CST_NELTS_PER_PATTERN (t2)))
   10994              :     {
   10995          295 :       unsigned int encoded_nelts = vector_cst_encoded_nelts (t1);
   10996          295 :       gcc_assert (encoded_nelts == vector_cst_encoded_nelts (t2));
   10997              : 
   10998          389 :       for (unsigned int i = 0; i < encoded_nelts; ++i)
   10999          590 :         if (!record_uniform_integer_difference (VECTOR_CST_ENCODED_ELT (t1, i),
   11000          295 :                                                 VECTOR_CST_ENCODED_ELT (t2, i),
   11001              :                                                 &diff, &diff_p))
   11002              :           return NULL_TREE;
   11003              :     }
   11004              :   else
   11005              :     {
   11006            0 :       unsigned HOST_WIDE_INT nelts;
   11007            0 :       if (!VECTOR_CST_NELTS (t1).is_constant (&nelts))
   11008          295 :         return NULL_TREE;
   11009              : 
   11010            0 :       for (unsigned HOST_WIDE_INT i = 0; i < nelts; ++i)
   11011            0 :         if (!record_uniform_integer_difference (vector_cst_elt (t1, i),
   11012            0 :                                                 vector_cst_elt (t2, i),
   11013              :                                                 &diff, &diff_p))
   11014              :           return NULL_TREE;
   11015              :     }
   11016              : 
   11017           94 :   if (!diff_p || !wi::fits_shwi_p (diff))
   11018              :     return NULL_TREE;
   11019              : 
   11020           94 :   return build_int_cst (long_long_integer_type_node, diff.to_shwi ());
   11021          295 : }
   11022              : 
   11023              : /* Checks to see if T is a constant or a constant vector and if each element E
   11024              :    adheres to ~E + 1 == pow2 then return ~E otherwise NULL_TREE.  */
   11025              : 
   11026              : tree
   11027      3038281 : bitmask_inv_cst_vector_p (tree t)
   11028              : {
   11029              : 
   11030      3038281 :   tree_code code = TREE_CODE (t);
   11031      3038281 :   tree type = TREE_TYPE (t);
   11032              : 
   11033      3038281 :   if (!INTEGRAL_TYPE_P (type)
   11034      3038281 :       && !VECTOR_INTEGER_TYPE_P (type))
   11035              :     return NULL_TREE;
   11036              : 
   11037      3038253 :   unsigned HOST_WIDE_INT nelts = 1;
   11038      3038253 :   tree cst;
   11039      3038253 :   unsigned int idx = 0;
   11040      3038253 :   bool uniform = uniform_integer_cst_p (t);
   11041      3038253 :   tree newtype = unsigned_type_for (type);
   11042      3038253 :   tree_vector_builder builder;
   11043      3038253 :   if (code == INTEGER_CST)
   11044              :     cst = t;
   11045              :   else
   11046              :     {
   11047        17779 :       if (!VECTOR_CST_NELTS (t).is_constant (&nelts))
   11048              :         return NULL_TREE;
   11049              : 
   11050        17779 :       cst = vector_cst_elt (t, 0);
   11051        17779 :       builder.new_vector (newtype, nelts, 1);
   11052              :     }
   11053              : 
   11054      3038253 :   tree ty = unsigned_type_for (TREE_TYPE (cst));
   11055              : 
   11056      3038265 :   do
   11057              :     {
   11058      3038265 :       if (idx > 0)
   11059           12 :         cst = vector_cst_elt (t, idx);
   11060      3038265 :       wide_int icst = wi::to_wide (cst);
   11061      3038265 :       wide_int inv =  wi::bit_not (icst);
   11062      3038265 :       icst = wi::add (1, inv);
   11063      3038265 :       if (wi::popcount (icst) != 1)
   11064              :         return NULL_TREE;
   11065              : 
   11066        15991 :       tree newcst = wide_int_to_tree (ty, inv);
   11067              : 
   11068        15991 :       if (uniform)
   11069        15975 :         return build_uniform_cst (newtype, newcst);
   11070              : 
   11071           16 :       builder.quick_push (newcst);
   11072      3038265 :     }
   11073           16 :   while (++idx < nelts);
   11074              : 
   11075            4 :   return builder.build ();
   11076      3038253 : }
   11077              : 
   11078              : /* If VECTOR_CST T has a single nonzero element, return the index of that
   11079              :    element, otherwise return -1.  */
   11080              : 
   11081              : int
   11082          179 : single_nonzero_element (const_tree t)
   11083              : {
   11084          179 :   unsigned HOST_WIDE_INT nelts;
   11085          179 :   unsigned int repeat_nelts;
   11086          179 :   if (VECTOR_CST_NELTS (t).is_constant (&nelts))
   11087          179 :     repeat_nelts = nelts;
   11088              :   else if (VECTOR_CST_NELTS_PER_PATTERN (t) == 2)
   11089              :     {
   11090              :       nelts = vector_cst_encoded_nelts (t);
   11091              :       repeat_nelts = VECTOR_CST_NPATTERNS (t);
   11092              :     }
   11093              :   else
   11094              :     return -1;
   11095              : 
   11096          179 :   int res = -1;
   11097          565 :   for (unsigned int i = 0; i < nelts; ++i)
   11098              :     {
   11099          530 :       tree elt = vector_cst_elt (t, i);
   11100          530 :       if (!integer_zerop (elt) && !real_zerop (elt))
   11101              :         {
   11102          323 :           if (res >= 0 || i >= repeat_nelts)
   11103              :             return -1;
   11104          179 :           res = i;
   11105              :         }
   11106              :     }
   11107              :   return res;
   11108              : }
   11109              : 
   11110              : /* Build an empty statement at location LOC.  */
   11111              : 
   11112              : tree
   11113     16207888 : build_empty_stmt (location_t loc)
   11114              : {
   11115     16207888 :   tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
   11116     16207888 :   SET_EXPR_LOCATION (t, loc);
   11117     16207888 :   return t;
   11118              : }
   11119              : 
   11120              : 
   11121              : /* Build an OMP clause with code CODE.  LOC is the location of the
   11122              :    clause.  */
   11123              : 
   11124              : tree
   11125      1773955 : build_omp_clause (location_t loc, enum omp_clause_code code)
   11126              : {
   11127      1773955 :   tree t;
   11128      1773955 :   int size, length;
   11129              : 
   11130      1773955 :   length = omp_clause_num_ops[code];
   11131      1773955 :   size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree));
   11132              : 
   11133      1773955 :   record_node_allocation_statistics (OMP_CLAUSE, size);
   11134              : 
   11135      1773955 :   t = (tree) ggc_internal_alloc (size);
   11136      1773955 :   memset (t, 0, size);
   11137      1773955 :   TREE_SET_CODE (t, OMP_CLAUSE);
   11138      1773955 :   OMP_CLAUSE_SET_CODE (t, code);
   11139      1773955 :   OMP_CLAUSE_LOCATION (t) = loc;
   11140              : 
   11141      1773955 :   return t;
   11142              : }
   11143              : 
   11144              : /* Build a tcc_vl_exp object with code CODE and room for LEN operands.  LEN
   11145              :    includes the implicit operand count in TREE_OPERAND 0, and so must be >= 1.
   11146              :    Except for the CODE and operand count field, other storage for the
   11147              :    object is initialized to zeros.  */
   11148              : 
   11149              : tree
   11150    550576621 : build_vl_exp (enum tree_code code, int len MEM_STAT_DECL)
   11151              : {
   11152    550576621 :   tree t;
   11153    550576621 :   int length = (len - 1) * sizeof (tree) + sizeof (struct tree_exp);
   11154              : 
   11155    550576621 :   gcc_assert (TREE_CODE_CLASS (code) == tcc_vl_exp);
   11156    550576621 :   gcc_assert (len >= 1);
   11157              : 
   11158    550576621 :   record_node_allocation_statistics (code, length);
   11159              : 
   11160    550576621 :   t = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
   11161              : 
   11162    550576621 :   TREE_SET_CODE (t, code);
   11163              : 
   11164              :   /* Can't use TREE_OPERAND to store the length because if checking is
   11165              :      enabled, it will try to check the length before we store it.  :-P  */
   11166    550576621 :   t->exp.operands[0] = build_int_cst (sizetype, len);
   11167              : 
   11168    550576621 :   return t;
   11169              : }
   11170              : 
   11171              : /* Helper function for build_call_* functions; build a CALL_EXPR with
   11172              :    indicated RETURN_TYPE, FN, and NARGS, but do not initialize any of
   11173              :    the argument slots.  */
   11174              : 
   11175              : static tree
   11176    295615535 : build_call_1 (tree return_type, tree fn, int nargs)
   11177              : {
   11178    295615535 :   tree t;
   11179              : 
   11180    295615535 :   t = build_vl_exp (CALL_EXPR, nargs + 3);
   11181    295615535 :   TREE_TYPE (t) = return_type;
   11182    295615535 :   CALL_EXPR_FN (t) = fn;
   11183    295615535 :   CALL_EXPR_STATIC_CHAIN (t) = NULL;
   11184              : 
   11185    295615535 :   return t;
   11186              : }
   11187              : 
   11188              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11189              :    FN and a null static chain slot.  NARGS is the number of call arguments
   11190              :    which are specified as a va_list ARGS.  */
   11191              : 
   11192              : tree
   11193       136103 : build_call_valist (tree return_type, tree fn, int nargs, va_list args)
   11194              : {
   11195       136103 :   tree t;
   11196       136103 :   int i;
   11197              : 
   11198       136103 :   t = build_call_1 (return_type, fn, nargs);
   11199       552198 :   for (i = 0; i < nargs; i++)
   11200       279992 :     CALL_EXPR_ARG (t, i) = va_arg (args, tree);
   11201       136103 :   process_call_operands (t);
   11202       136103 :   return t;
   11203              : }
   11204              : 
   11205              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11206              :    FN and a null static chain slot.  ARGS specifies the call arguments.  */
   11207              : 
   11208              : tree
   11209          266 : build_call (tree return_type, tree fn, std::initializer_list<tree> args)
   11210              : {
   11211          266 :   tree t;
   11212          266 :   int i;
   11213          266 :   int nargs = args.size();
   11214              : 
   11215          266 :   t = build_call_1 (return_type, fn, nargs);
   11216         1024 :   for (i = 0; i < nargs; i++)
   11217          492 :     CALL_EXPR_ARG (t, i) = args.begin()[i];
   11218          266 :   process_call_operands (t);
   11219          266 :   return t;
   11220              : }
   11221              : 
   11222              : /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and
   11223              :    FN and a null static chain slot.  NARGS is the number of call arguments
   11224              :    which are specified as a tree array ARGS.  */
   11225              : 
   11226              : tree
   11227    247593793 : build_call_array_loc (location_t loc, tree return_type, tree fn,
   11228              :                       int nargs, const tree *args)
   11229              : {
   11230    247593793 :   tree t;
   11231    247593793 :   int i;
   11232              : 
   11233    247593793 :   t = build_call_1 (return_type, fn, nargs);
   11234    828422050 :   for (i = 0; i < nargs; i++)
   11235    333234464 :     CALL_EXPR_ARG (t, i) = args[i];
   11236    247593793 :   process_call_operands (t);
   11237    247593793 :   SET_EXPR_LOCATION (t, loc);
   11238    247593793 :   return t;
   11239              : }
   11240              : 
   11241              : /* Like build_call_array, but takes a vec.  */
   11242              : 
   11243              : tree
   11244     47069787 : build_call_vec (tree return_type, tree fn, const vec<tree, va_gc> *args)
   11245              : {
   11246     47069787 :   tree ret, t;
   11247     47069787 :   unsigned int ix;
   11248              : 
   11249     47069787 :   ret = build_call_1 (return_type, fn, vec_safe_length (args));
   11250    129769561 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
   11251     35629987 :     CALL_EXPR_ARG (ret, ix) = t;
   11252     47069787 :   process_call_operands (ret);
   11253     47069787 :   return ret;
   11254              : }
   11255              : 
   11256              : /* Conveniently construct a function call expression.  FNDECL names the
   11257              :    function to be called and N arguments are passed in the array
   11258              :    ARGARRAY.  */
   11259              : 
   11260              : tree
   11261     24210951 : build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
   11262              : {
   11263     24210951 :   tree fntype = TREE_TYPE (fndecl);
   11264     24210951 :   tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
   11265              : 
   11266     24210951 :   return fold_build_call_array_loc (loc, TREE_TYPE (fntype), fn, n, argarray);
   11267              : }
   11268              : 
   11269              : /* Conveniently construct a function call expression.  FNDECL names the
   11270              :    function to be called and the arguments are passed in the vector
   11271              :    VEC.  */
   11272              : 
   11273              : tree
   11274        20908 : build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
   11275              : {
   11276        20908 :   return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
   11277        20908 :                                     vec_safe_address (vec));
   11278              : }
   11279              : 
   11280              : 
   11281              : /* Conveniently construct a function call expression.  FNDECL names the
   11282              :    function to be called, N is the number of arguments, and the "..."
   11283              :    parameters are the argument expressions.  */
   11284              : 
   11285              : tree
   11286     22113153 : build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
   11287              : {
   11288     22113153 :   va_list ap;
   11289     22113153 :   tree *argarray = XALLOCAVEC (tree, n);
   11290     22113153 :   int i;
   11291              : 
   11292     22113153 :   va_start (ap, n);
   11293     25034749 :   for (i = 0; i < n; i++)
   11294      2921596 :     argarray[i] = va_arg (ap, tree);
   11295     22113153 :   va_end (ap);
   11296     22113153 :   return build_call_expr_loc_array (loc, fndecl, n, argarray);
   11297              : }
   11298              : 
   11299              : /* Like build_call_expr_loc (UNKNOWN_LOCATION, ...).  Duplicated because
   11300              :    varargs macros aren't supported by all bootstrap compilers.  */
   11301              : 
   11302              : tree
   11303      2072395 : build_call_expr (tree fndecl, int n, ...)
   11304              : {
   11305      2072395 :   va_list ap;
   11306      2072395 :   tree *argarray = XALLOCAVEC (tree, n);
   11307      2072395 :   int i;
   11308              : 
   11309      2072395 :   va_start (ap, n);
   11310      6212586 :   for (i = 0; i < n; i++)
   11311      4140191 :     argarray[i] = va_arg (ap, tree);
   11312      2072395 :   va_end (ap);
   11313      2072395 :   return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
   11314              : }
   11315              : 
   11316              : /* Build an internal call to IFN, with arguments ARGS[0:N-1] and with return
   11317              :    type TYPE.  This is just like CALL_EXPR, except its CALL_EXPR_FN is NULL.
   11318              :    It will get gimplified later into an ordinary internal function.  */
   11319              : 
   11320              : tree
   11321       815586 : build_call_expr_internal_loc_array (location_t loc, internal_fn ifn,
   11322              :                                     tree type, int n, const tree *args)
   11323              : {
   11324       815586 :   tree t = build_call_1 (type, NULL_TREE, n);
   11325      3392969 :   for (int i = 0; i < n; ++i)
   11326      1761797 :     CALL_EXPR_ARG (t, i) = args[i];
   11327       815586 :   SET_EXPR_LOCATION (t, loc);
   11328       815586 :   CALL_EXPR_IFN (t) = ifn;
   11329       815586 :   process_call_operands (t);
   11330       815586 :   return t;
   11331              : }
   11332              : 
   11333              : /* Build internal call expression.  This is just like CALL_EXPR, except
   11334              :    its CALL_EXPR_FN is NULL.  It will get gimplified later into ordinary
   11335              :    internal function.  */
   11336              : 
   11337              : tree
   11338       814411 : build_call_expr_internal_loc (location_t loc, enum internal_fn ifn,
   11339              :                               tree type, int n, ...)
   11340              : {
   11341       814411 :   va_list ap;
   11342       814411 :   tree *argarray = XALLOCAVEC (tree, n);
   11343       814411 :   int i;
   11344              : 
   11345       814411 :   va_start (ap, n);
   11346      2573844 :   for (i = 0; i < n; i++)
   11347      1759433 :     argarray[i] = va_arg (ap, tree);
   11348       814411 :   va_end (ap);
   11349       814411 :   return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
   11350              : }
   11351              : 
   11352              : /* Return a function call to FN, if the target is guaranteed to support it,
   11353              :    or null otherwise.
   11354              : 
   11355              :    N is the number of arguments, passed in the "...", and TYPE is the
   11356              :    type of the return value.  */
   11357              : 
   11358              : tree
   11359         1968 : maybe_build_call_expr_loc (location_t loc, combined_fn fn, tree type,
   11360              :                            int n, ...)
   11361              : {
   11362         1968 :   va_list ap;
   11363         1968 :   tree *argarray = XALLOCAVEC (tree, n);
   11364         1968 :   int i;
   11365              : 
   11366         1968 :   va_start (ap, n);
   11367         5165 :   for (i = 0; i < n; i++)
   11368         3197 :     argarray[i] = va_arg (ap, tree);
   11369         1968 :   va_end (ap);
   11370         1968 :   if (internal_fn_p (fn))
   11371              :     {
   11372         1160 :       internal_fn ifn = as_internal_fn (fn);
   11373         1160 :       if (direct_internal_fn_p (ifn))
   11374              :         {
   11375            3 :           tree_pair types = direct_internal_fn_types (ifn, type, argarray);
   11376            3 :           if (!direct_internal_fn_supported_p (ifn, types,
   11377              :                                                OPTIMIZE_FOR_BOTH))
   11378            1 :             return NULL_TREE;
   11379              :         }
   11380         1159 :       return build_call_expr_internal_loc_array (loc, ifn, type, n, argarray);
   11381              :     }
   11382              :   else
   11383              :     {
   11384          808 :       tree fndecl = builtin_decl_implicit (as_builtin_fn (fn));
   11385          808 :       if (!fndecl)
   11386              :         return NULL_TREE;
   11387          700 :       return build_call_expr_loc_array (loc, fndecl, n, argarray);
   11388              :     }
   11389              : }
   11390              : 
   11391              : /* Return a function call to the appropriate builtin alloca variant.
   11392              : 
   11393              :    SIZE is the size to be allocated.  ALIGN, if non-zero, is the requested
   11394              :    alignment of the allocated area.  MAX_SIZE, if non-negative, is an upper
   11395              :    bound for SIZE in case it is not a fixed value.  */
   11396              : 
   11397              : tree
   11398         9029 : build_alloca_call_expr (tree size, unsigned int align, HOST_WIDE_INT max_size)
   11399              : {
   11400         9029 :   if (max_size >= 0)
   11401              :     {
   11402            0 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX);
   11403            0 :       return
   11404            0 :         build_call_expr (t, 3, size, size_int (align), size_int (max_size));
   11405              :     }
   11406         9029 :   else if (align > 0)
   11407              :     {
   11408         9029 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN);
   11409         9029 :       return build_call_expr (t, 2, size, size_int (align));
   11410              :     }
   11411              :   else
   11412              :     {
   11413            0 :       tree t = builtin_decl_explicit (BUILT_IN_ALLOCA);
   11414            0 :       return build_call_expr (t, 1, size);
   11415              :     }
   11416              : }
   11417              : 
   11418              : /* The built-in decl to use to mark code points believed to be unreachable.
   11419              :    Typically __builtin_unreachable, but __builtin_trap if
   11420              :    -fsanitize=unreachable -fsanitize-trap=unreachable.  If only
   11421              :    -fsanitize=unreachable, we rely on sanopt to replace calls with the
   11422              :    appropriate ubsan function.  When building a call directly, use
   11423              :    {gimple_},build_builtin_unreachable instead.  */
   11424              : 
   11425              : tree
   11426       357076 : builtin_decl_unreachable ()
   11427              : {
   11428       357076 :   enum built_in_function fncode = BUILT_IN_UNREACHABLE;
   11429              : 
   11430       714152 :   if (sanitize_flags_p (SANITIZE_UNREACHABLE)
   11431       357076 :       ? (flag_sanitize_trap & SANITIZE_UNREACHABLE)
   11432       356478 :       : flag_unreachable_traps)
   11433           22 :     fncode = BUILT_IN_UNREACHABLE_TRAP;
   11434              :   /* For non-trapping sanitize, we will rewrite __builtin_unreachable () later,
   11435              :      in the sanopt pass.  */
   11436              : 
   11437       357076 :   return builtin_decl_explicit (fncode);
   11438              : }
   11439              : 
   11440              : /* Build a call to __builtin_unreachable, possibly rewritten by
   11441              :    -fsanitize=unreachable.  Use this rather than the above when practical.  */
   11442              : 
   11443              : tree
   11444     20594948 : build_builtin_unreachable (location_t loc)
   11445              : {
   11446     20594948 :   tree data = NULL_TREE;
   11447     20594948 :   tree fn = sanitize_unreachable_fn (&data, loc);
   11448     20594948 :   return build_call_expr_loc (loc, fn, data != NULL_TREE, data);
   11449              : }
   11450              : 
   11451              : /* Create a new constant string literal of type ELTYPE[SIZE] (or LEN
   11452              :    if SIZE == -1) and return a tree node representing char* pointer to
   11453              :    it as an ADDR_EXPR (ARRAY_REF (ELTYPE, ...)).  When STR is nonnull
   11454              :    the STRING_CST value is the LEN bytes at STR (the representation
   11455              :    of the string, which may be wide).  Otherwise it's all zeros.  */
   11456              : 
   11457              : tree
   11458       267786 : build_string_literal (unsigned len, const char *str /* = NULL */,
   11459              :                       tree eltype /* = char_type_node */,
   11460              :                       unsigned HOST_WIDE_INT size /* = -1 */)
   11461              : {
   11462       267786 :   tree t = build_string (len, str);
   11463              :   /* Set the maximum valid index based on the string length or SIZE.  */
   11464       535572 :   unsigned HOST_WIDE_INT maxidx
   11465       267786 :     = (size == HOST_WIDE_INT_M1U ? len : size) - 1;
   11466              : 
   11467       267786 :   tree index = build_index_type (size_int (maxidx));
   11468       267786 :   eltype = build_type_variant (eltype, 1, 0);
   11469       267786 :   tree type = build_array_type (eltype, index);
   11470       267786 :   TREE_TYPE (t) = type;
   11471       267786 :   TREE_CONSTANT (t) = 1;
   11472       267786 :   TREE_READONLY (t) = 1;
   11473       267786 :   TREE_STATIC (t) = 1;
   11474              : 
   11475       267786 :   type = build_pointer_type (eltype);
   11476       267786 :   t = build1 (ADDR_EXPR, type,
   11477              :               build4 (ARRAY_REF, eltype,
   11478              :                       t, integer_zero_node, NULL_TREE, NULL_TREE));
   11479       267786 :   return t;
   11480              : }
   11481              : 
   11482              : 
   11483              : 
   11484              : /* Return true if T (assumed to be a DECL) must be assigned a memory
   11485              :    location.  */
   11486              : 
   11487              : bool
   11488   2017499769 : needs_to_live_in_memory (const_tree t)
   11489              : {
   11490   2017499769 :   return (TREE_ADDRESSABLE (t)
   11491   1640474169 :           || is_global_var (t)
   11492   3205395166 :           || (TREE_CODE (t) == RESULT_DECL
   11493      8419149 :               && !DECL_BY_REFERENCE (t)
   11494      5884265 :               && aggregate_value_p (t, current_function_decl)));
   11495              : }
   11496              : 
   11497              : /* Return value of a constant X and sign-extend it.  */
   11498              : 
   11499              : HOST_WIDE_INT
   11500    778305271 : int_cst_value (const_tree x)
   11501              : {
   11502    778305271 :   unsigned bits = TYPE_PRECISION (TREE_TYPE (x));
   11503    778305271 :   unsigned HOST_WIDE_INT val = TREE_INT_CST_LOW (x);
   11504              : 
   11505              :   /* Make sure the sign-extended value will fit in a HOST_WIDE_INT.  */
   11506    778305271 :   gcc_assert (cst_and_fits_in_hwi (x));
   11507              : 
   11508    778305271 :   if (bits < HOST_BITS_PER_WIDE_INT)
   11509              :     {
   11510    763546640 :       bool negative = ((val >> (bits - 1)) & 1) != 0;
   11511    763546640 :       if (negative)
   11512       210329 :         val |= HOST_WIDE_INT_M1U << (bits - 1) << 1;
   11513              :       else
   11514    763336311 :         val &= ~(HOST_WIDE_INT_M1U << (bits - 1) << 1);
   11515              :     }
   11516              : 
   11517    778305271 :   return val;
   11518              : }
   11519              : 
   11520              : /* If TYPE is an integral or pointer type, return an integer type with
   11521              :    the same precision which is unsigned iff UNSIGNEDP is true, or itself
   11522              :    if TYPE is already an integer type of signedness UNSIGNEDP.
   11523              :    If TYPE is a floating-point type, return an integer type with the same
   11524              :    bitsize and with the signedness given by UNSIGNEDP; this is useful
   11525              :    when doing bit-level operations on a floating-point value.  */
   11526              : 
   11527              : tree
   11528     88919481 : signed_or_unsigned_type_for (int unsignedp, tree type)
   11529              : {
   11530     88919481 :   if (ANY_INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) == unsignedp)
   11531              :     return type;
   11532              : 
   11533     57175154 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11534              :     {
   11535        29912 :       tree inner = TREE_TYPE (type);
   11536        29912 :       tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
   11537        29912 :       if (!inner2)
   11538              :         return NULL_TREE;
   11539        29912 :       if (inner == inner2)
   11540              :         return type;
   11541        29912 :       machine_mode new_mode;
   11542        59824 :       if (VECTOR_MODE_P (TYPE_MODE (type))
   11543        59740 :           && related_int_vector_mode (TYPE_MODE (type)).exists (&new_mode))
   11544        29828 :         return build_vector_type_for_mode (inner2, new_mode);
   11545           84 :       return build_vector_type (inner2, TYPE_VECTOR_SUBPARTS (type));
   11546              :     }
   11547              : 
   11548              :   if (TREE_CODE (type) == COMPLEX_TYPE)
   11549              :     {
   11550           24 :       tree inner = TREE_TYPE (type);
   11551           24 :       tree inner2 = signed_or_unsigned_type_for (unsignedp, inner);
   11552           24 :       if (!inner2)
   11553              :         return NULL_TREE;
   11554           24 :       if (inner == inner2)
   11555              :         return type;
   11556           24 :       return build_complex_type (inner2);
   11557              :     }
   11558              : 
   11559              :   unsigned int bits;
   11560              :   if (INTEGRAL_TYPE_P (type)
   11561              :       || POINTER_TYPE_P (type)
   11562              :       || TREE_CODE (type) == OFFSET_TYPE)
   11563     57145124 :     bits = TYPE_PRECISION (type);
   11564              :   else if (TREE_CODE (type) == REAL_TYPE)
   11565          188 :     bits = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (type));
   11566              :   else
   11567              :     return NULL_TREE;
   11568              : 
   11569     57145218 :   if (TREE_CODE (type) == BITINT_TYPE)
   11570         2302 :     return build_bitint_type (bits, unsignedp);
   11571     57142916 :   return build_nonstandard_integer_type (bits, unsignedp);
   11572              : }
   11573              : 
   11574              : /* If TYPE is an integral or pointer type, return an integer type with
   11575              :    the same precision which is unsigned, or itself if TYPE is already an
   11576              :    unsigned integer type.  If TYPE is a floating-point type, return an
   11577              :    unsigned integer type with the same bitsize as TYPE.  */
   11578              : 
   11579              : tree
   11580     78920334 : unsigned_type_for (tree type)
   11581              : {
   11582     78920334 :   return signed_or_unsigned_type_for (1, type);
   11583              : }
   11584              : 
   11585              : /* If TYPE is an integral or pointer type, return an integer type with
   11586              :    the same precision which is signed, or itself if TYPE is already a
   11587              :    signed integer type.  If TYPE is a floating-point type, return a
   11588              :    signed integer type with the same bitsize as TYPE.  */
   11589              : 
   11590              : tree
   11591      9963847 : signed_type_for (tree type)
   11592              : {
   11593      9963847 :   return signed_or_unsigned_type_for (0, type);
   11594              : }
   11595              : 
   11596              : /* - For VECTOR_TYPEs:
   11597              :     - The truth type must be a VECTOR_BOOLEAN_TYPE.
   11598              :     - The number of elements must match (known_eq).
   11599              :     - targetm.vectorize.get_mask_mode exists, and exactly
   11600              :       the same mode as the truth type.
   11601              :    - Otherwise, the truth type must be a BOOLEAN_TYPE
   11602              :      or useless_type_conversion_p to BOOLEAN_TYPE.  */
   11603              : bool
   11604         1374 : is_truth_type_for (tree type, tree truth_type)
   11605              : {
   11606         1374 :   machine_mode mask_mode = TYPE_MODE (truth_type);
   11607         1374 :   machine_mode vmode = TYPE_MODE (type);
   11608         1374 :   machine_mode tmask_mode;
   11609              : 
   11610         1374 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11611              :     {
   11612         1374 :       if (VECTOR_BOOLEAN_TYPE_P (truth_type)
   11613         1374 :           && known_eq (TYPE_VECTOR_SUBPARTS (type),
   11614              :                        TYPE_VECTOR_SUBPARTS (truth_type))
   11615         1374 :           && targetm.vectorize.get_mask_mode (vmode).exists (&tmask_mode)
   11616         2748 :           && tmask_mode == mask_mode)
   11617         1355 :         return true;
   11618              : 
   11619           19 :       return false;
   11620              :     }
   11621              : 
   11622            0 :   return useless_type_conversion_p (boolean_type_node, truth_type);
   11623              : }
   11624              : 
   11625              : /* If TYPE is a vector type, return a signed integer vector type with the
   11626              :    same width and number of subparts. Otherwise return boolean_type_node.  */
   11627              : 
   11628              : tree
   11629      5319868 : truth_type_for (tree type)
   11630              : {
   11631      5319868 :   if (TREE_CODE (type) == VECTOR_TYPE)
   11632              :     {
   11633      2804577 :       if (VECTOR_BOOLEAN_TYPE_P (type))
   11634              :         return type;
   11635      2746964 :       return build_truth_vector_type_for (type);
   11636              :     }
   11637              :   else
   11638      2515291 :     return boolean_type_node;
   11639              : }
   11640              : 
   11641              : /* Returns the largest value obtainable by casting something in INNER type to
   11642              :    OUTER type.  */
   11643              : 
   11644              : tree
   11645     11036586 : upper_bound_in_type (tree outer, tree inner)
   11646              : {
   11647     11036586 :   unsigned int det = 0;
   11648     11036586 :   unsigned oprec = TYPE_PRECISION (outer);
   11649     11036586 :   unsigned iprec = TYPE_PRECISION (inner);
   11650     11036586 :   unsigned prec;
   11651              : 
   11652              :   /* Compute a unique number for every combination.  */
   11653     11036586 :   det |= (oprec > iprec) ? 4 : 0;
   11654     11036586 :   det |= TYPE_UNSIGNED (outer) ? 2 : 0;
   11655     11036586 :   det |= TYPE_UNSIGNED (inner) ? 1 : 0;
   11656              : 
   11657              :   /* Determine the exponent to use.  */
   11658     11036586 :   switch (det)
   11659              :     {
   11660      7438047 :     case 0:
   11661      7438047 :     case 1:
   11662              :       /* oprec <= iprec, outer: signed, inner: don't care.  */
   11663      7438047 :       prec = oprec - 1;
   11664      7438047 :       break;
   11665              :     case 2:
   11666              :     case 3:
   11667              :       /* oprec <= iprec, outer: unsigned, inner: don't care.  */
   11668              :       prec = oprec;
   11669              :       break;
   11670        22695 :     case 4:
   11671              :       /* oprec > iprec, outer: signed, inner: signed.  */
   11672        22695 :       prec = iprec - 1;
   11673        22695 :       break;
   11674              :     case 5:
   11675              :       /* oprec > iprec, outer: signed, inner: unsigned.  */
   11676         9482 :       prec = iprec;
   11677              :       break;
   11678              :     case 6:
   11679              :       /* oprec > iprec, outer: unsigned, inner: signed.  */
   11680              :       prec = oprec;
   11681              :       break;
   11682              :     case 7:
   11683              :       /* oprec > iprec, outer: unsigned, inner: unsigned.  */
   11684         9482 :       prec = iprec;
   11685              :       break;
   11686              :     default:
   11687              :       gcc_unreachable ();
   11688              :     }
   11689              : 
   11690     11036586 :   return wide_int_to_tree (outer,
   11691     11036586 :                            wi::mask (prec, false, TYPE_PRECISION (outer)));
   11692              : }
   11693              : 
   11694              : /* Returns the smallest value obtainable by casting something in INNER type to
   11695              :    OUTER type.  */
   11696              : 
   11697              : tree
   11698      8464906 : lower_bound_in_type (tree outer, tree inner)
   11699              : {
   11700      8464906 :   unsigned oprec = TYPE_PRECISION (outer);
   11701      8464906 :   unsigned iprec = TYPE_PRECISION (inner);
   11702              : 
   11703              :   /* If OUTER type is unsigned, we can definitely cast 0 to OUTER type
   11704              :      and obtain 0.  */
   11705      8464906 :   if (TYPE_UNSIGNED (outer)
   11706              :       /* If we are widening something of an unsigned type, OUTER type
   11707              :          contains all values of INNER type.  In particular, both INNER
   11708              :          and OUTER types have zero in common.  */
   11709      8464906 :       || (oprec > iprec && TYPE_UNSIGNED (inner)))
   11710      2248613 :     return build_int_cst (outer, 0);
   11711              :   else
   11712              :     {
   11713              :       /* If we are widening a signed type to another signed type, we
   11714              :          want to obtain -2^^(iprec-1).  If we are keeping the
   11715              :          precision or narrowing to a signed type, we want to obtain
   11716              :          -2^(oprec-1).  */
   11717      6216293 :       unsigned prec = oprec > iprec ? iprec : oprec;
   11718      6216293 :       return wide_int_to_tree (outer,
   11719     12432586 :                                wi::mask (prec - 1, true,
   11720      6216293 :                                          TYPE_PRECISION (outer)));
   11721              :     }
   11722              : }
   11723              : 
   11724              : /* Return true if two operands that are suitable for PHI nodes are
   11725              :    necessarily equal.  Specifically, both ARG0 and ARG1 must be either
   11726              :    SSA_NAME or invariant.  Note that this is strictly an optimization.
   11727              :    That is, callers of this function can directly call operand_equal_p
   11728              :    and get the same result, only slower.  */
   11729              : 
   11730              : bool
   11731     22040517 : operand_equal_for_phi_arg_p (const_tree arg0, const_tree arg1)
   11732              : {
   11733     22040517 :   if (arg0 == arg1)
   11734              :     return true;
   11735     20274648 :   if (TREE_CODE (arg0) == SSA_NAME || TREE_CODE (arg1) == SSA_NAME)
   11736              :     return false;
   11737      4388980 :   return operand_equal_p (arg0, arg1, 0);
   11738              : }
   11739              : 
   11740              : /* Returns number of zeros at the end of binary representation of X.  */
   11741              : 
   11742              : tree
   11743      9283008 : num_ending_zeros (const_tree x)
   11744              : {
   11745      9283008 :   return build_int_cst (TREE_TYPE (x), wi::ctz (wi::to_wide (x)));
   11746              : }
   11747              : 
   11748              : 
   11749              : #define WALK_SUBTREE(NODE)                              \
   11750              :   do                                                    \
   11751              :     {                                                   \
   11752              :       result = walk_tree_1 (&(NODE), func, data, pset, lh); \
   11753              :       if (result)                                       \
   11754              :         return result;                                  \
   11755              :     }                                                   \
   11756              :   while (0)
   11757              : 
   11758              : /* This is a subroutine of walk_tree that walks field of TYPE that are to
   11759              :    be walked whenever a type is seen in the tree.  Rest of operands and return
   11760              :    value are as for walk_tree.  */
   11761              : 
   11762              : static tree
   11763   5255390565 : walk_type_fields (tree type, walk_tree_fn func, void *data,
   11764              :                   hash_set<tree> *pset, walk_tree_lh lh)
   11765              : {
   11766   5255390565 :   tree result = NULL_TREE;
   11767              : 
   11768   5255390565 :   switch (TREE_CODE (type))
   11769              :     {
   11770   1528717774 :     case POINTER_TYPE:
   11771   1528717774 :     case REFERENCE_TYPE:
   11772   1528717774 :     case VECTOR_TYPE:
   11773              :       /* We have to worry about mutually recursive pointers.  These can't
   11774              :          be written in C.  They can in Ada.  It's pathological, but
   11775              :          there's an ACATS test (c38102a) that checks it.  Deal with this
   11776              :          by checking if we're pointing to another pointer, that one
   11777              :          points to another pointer, that one does too, and we have no htab.
   11778              :          If so, get a hash table.  We check three levels deep to avoid
   11779              :          the cost of the hash table if we don't need one.  */
   11780   3007159561 :       if (POINTER_TYPE_P (TREE_TYPE (type))
   11781     50276056 :           && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (type)))
   11782      7329663 :           && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (TREE_TYPE (type))))
   11783   1535946056 :           && !pset)
   11784              :         {
   11785            0 :           result = walk_tree_without_duplicates (&TREE_TYPE (type),
   11786              :                                                  func, data);
   11787            0 :           if (result)
   11788              :             return result;
   11789              : 
   11790              :           break;
   11791              :         }
   11792              : 
   11793              :       /* fall through */
   11794              : 
   11795   1531687105 :     case COMPLEX_TYPE:
   11796   1531687105 :       WALK_SUBTREE (TREE_TYPE (type));
   11797              :       break;
   11798              : 
   11799    267670995 :     case METHOD_TYPE:
   11800    267670995 :       WALK_SUBTREE (TYPE_METHOD_BASETYPE (type));
   11801              : 
   11802              :       /* Fall through.  */
   11803              : 
   11804    437281254 :     case FUNCTION_TYPE:
   11805    437281254 :       WALK_SUBTREE (TREE_TYPE (type));
   11806    437281212 :       {
   11807    437281212 :         tree arg;
   11808              : 
   11809              :         /* We never want to walk into default arguments.  */
   11810   1676670965 :         for (arg = TYPE_ARG_TYPES (type); arg; arg = TREE_CHAIN (arg))
   11811   1239418520 :           WALK_SUBTREE (TREE_VALUE (arg));
   11812              :       }
   11813              :       break;
   11814              : 
   11815     17130202 :     case ARRAY_TYPE:
   11816              :       /* Don't follow this nodes's type if a pointer for fear that
   11817              :          we'll have infinite recursion.  If we have a PSET, then we
   11818              :          need not fear.  */
   11819     17130202 :       if (pset
   11820     17130202 :           || (!POINTER_TYPE_P (TREE_TYPE (type))
   11821       162178 :               && TREE_CODE (TREE_TYPE (type)) != OFFSET_TYPE))
   11822     17109332 :         WALK_SUBTREE (TREE_TYPE (type));
   11823     17127579 :       WALK_SUBTREE (TYPE_DOMAIN (type));
   11824              :       break;
   11825              : 
   11826      1138387 :     case OFFSET_TYPE:
   11827      1138387 :       WALK_SUBTREE (TREE_TYPE (type));
   11828      1137523 :       WALK_SUBTREE (TYPE_OFFSET_BASETYPE (type));
   11829              :       break;
   11830              : 
   11831              :     default:
   11832              :       break;
   11833              :     }
   11834              : 
   11835              :   return NULL_TREE;
   11836              : }
   11837              : 
   11838              : /* Apply FUNC to all the sub-trees of TP in a pre-order traversal.  FUNC is
   11839              :    called with the DATA and the address of each sub-tree.  If FUNC returns a
   11840              :    non-NULL value, the traversal is stopped, and the value returned by FUNC
   11841              :    is returned.  If PSET is non-NULL it is used to record the nodes visited,
   11842              :    and to avoid visiting a node more than once.  */
   11843              : 
   11844              : tree
   11845  >11150*10^7 : walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
   11846              :              hash_set<tree> *pset, walk_tree_lh lh)
   11847              : {
   11848              : #define WALK_SUBTREE_TAIL(NODE)                         \
   11849              :   do                                                    \
   11850              :     {                                                   \
   11851              :        tp = & (NODE);                                       \
   11852              :        goto tail_recurse;                               \
   11853              :     }                                                   \
   11854              :   while (0)
   11855              : 
   11856  26127013732 :  tail_recurse:
   11857              :   /* Skip empty subtrees.  */
   11858  >13763*10^7 :   if (!*tp)
   11859              :     return NULL_TREE;
   11860              : 
   11861              :   /* Don't walk the same tree twice, if the user has requested
   11862              :      that we avoid doing so.  */
   11863  >11381*10^7 :   if (pset && pset->add (*tp))
   11864              :     return NULL_TREE;
   11865              : 
   11866              :   /* Call the function.  */
   11867  >11203*10^7 :   int walk_subtrees = 1;
   11868  >11203*10^7 :   tree result = (*func) (tp, &walk_subtrees, data);
   11869              : 
   11870              :   /* If we found something, return it.  */
   11871  >11203*10^7 :   if (result)
   11872              :     return result;
   11873              : 
   11874  >11195*10^7 :   tree t = *tp;
   11875  >11195*10^7 :   tree_code code = TREE_CODE (t);
   11876              : 
   11877              :   /* Even if we didn't, FUNC may have decided that there was nothing
   11878              :      interesting below this point in the tree.  */
   11879  >11195*10^7 :   if (!walk_subtrees)
   11880              :     {
   11881              :       /* But we still need to check our siblings.  */
   11882  68620654299 :       if (code == TREE_LIST)
   11883       107445 :         WALK_SUBTREE_TAIL (TREE_CHAIN (t));
   11884  68620546854 :       else if (code == OMP_CLAUSE)
   11885       890471 :         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (t));
   11886              :       else
   11887              :         return NULL_TREE;
   11888              :     }
   11889              : 
   11890  43334401850 :   if (lh)
   11891              :     {
   11892  25509261195 :       result = (*lh) (tp, &walk_subtrees, func, data, pset);
   11893  25509261195 :       if (result || !walk_subtrees)
   11894              :         return result;
   11895              :     }
   11896              : 
   11897  40386478750 :   switch (code)
   11898              :     {
   11899              :     case ERROR_MARK:
   11900              :     case IDENTIFIER_NODE:
   11901              :     case INTEGER_CST:
   11902              :     case REAL_CST:
   11903              :     case FIXED_CST:
   11904              :     case STRING_CST:
   11905              :     case BLOCK:
   11906              :     case PLACEHOLDER_EXPR:
   11907              :     case SSA_NAME:
   11908              :     case FIELD_DECL:
   11909              :     case RESULT_DECL:
   11910              :       /* None of these have subtrees other than those already walked
   11911              :          above.  */
   11912              :       break;
   11913              : 
   11914    286932135 :     case TREE_LIST:
   11915    286932135 :       WALK_SUBTREE (TREE_VALUE (t));
   11916    286439604 :       WALK_SUBTREE_TAIL (TREE_CHAIN (t));
   11917              : 
   11918   1350408058 :     case TREE_VEC:
   11919   1350408058 :       {
   11920   1350408058 :         int len = TREE_VEC_LENGTH (t);
   11921              : 
   11922   1350408058 :         if (len == 0)
   11923              :           break;
   11924              : 
   11925              :         /* Walk all elements but the last.  */
   11926   2478675481 :         for (int i = 0; i < len - 1; ++i)
   11927   1138060135 :           WALK_SUBTREE (TREE_VEC_ELT (t, i));
   11928              : 
   11929              :         /* Now walk the last one as a tail call.  */
   11930   1340615346 :         WALK_SUBTREE_TAIL (TREE_VEC_ELT (t, len - 1));
   11931              :       }
   11932              : 
   11933      5595039 :     case VECTOR_CST:
   11934      5595039 :       {
   11935      5595039 :         unsigned len = vector_cst_encoded_nelts (t);
   11936      5595039 :         if (len == 0)
   11937              :           break;
   11938              :         /* Walk all elements but the last.  */
   11939     18448082 :         for (unsigned i = 0; i < len - 1; ++i)
   11940     12853211 :           WALK_SUBTREE (VECTOR_CST_ENCODED_ELT (t, i));
   11941              :         /* Now walk the last one as a tail call.  */
   11942      5594871 :         WALK_SUBTREE_TAIL (VECTOR_CST_ENCODED_ELT (t, len - 1));
   11943              :       }
   11944              : 
   11945       641085 :     case COMPLEX_CST:
   11946       641085 :       WALK_SUBTREE (TREE_REALPART (t));
   11947       639519 :       WALK_SUBTREE_TAIL (TREE_IMAGPART (t));
   11948              : 
   11949              :     case CONSTRUCTOR:
   11950              :       {
   11951              :         unsigned HOST_WIDE_INT idx;
   11952              :         constructor_elt *ce;
   11953              : 
   11954    970935631 :         for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (t), idx, &ce);
   11955              :              idx++)
   11956    500487594 :           WALK_SUBTREE (ce->value);
   11957              :       }
   11958              :       break;
   11959              : 
   11960      4844059 :     case SAVE_EXPR:
   11961      4844059 :       WALK_SUBTREE_TAIL (TREE_OPERAND (t, 0));
   11962              : 
   11963    272255459 :     case BIND_EXPR:
   11964    272255459 :       {
   11965    272255459 :         tree decl;
   11966    439673433 :         for (decl = BIND_EXPR_VARS (t); decl; decl = DECL_CHAIN (decl))
   11967              :           {
   11968              :             /* Walk the DECL_INITIAL and DECL_SIZE.  We don't want to walk
   11969              :                into declarations that are just mentioned, rather than
   11970              :                declared; they don't really belong to this part of the tree.
   11971              :                And, we can see cycles: the initializer for a declaration
   11972              :                can refer to the declaration itself.  */
   11973    167417998 :             WALK_SUBTREE (DECL_INITIAL (decl));
   11974    167417974 :             WALK_SUBTREE (DECL_SIZE (decl));
   11975    167417974 :             WALK_SUBTREE (DECL_SIZE_UNIT (decl));
   11976              :           }
   11977    272255435 :         WALK_SUBTREE_TAIL (BIND_EXPR_BODY (t));
   11978              :       }
   11979              : 
   11980    366114060 :     case STATEMENT_LIST:
   11981    366114060 :       {
   11982    366114060 :         tree_stmt_iterator i;
   11983   1317866084 :         for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
   11984    951946118 :           WALK_SUBTREE (*tsi_stmt_ptr (i));
   11985              :       }
   11986    365919966 :       break;
   11987              : 
   11988      1844319 :     case OMP_CLAUSE:
   11989      1844319 :       {
   11990      1844319 :         int len = omp_clause_num_ops[OMP_CLAUSE_CODE (t)];
   11991              :         /* Do not walk the iterator operand of OpenMP MAP clauses.  */
   11992      1844319 :         if (OMP_CLAUSE_HAS_ITERATORS (t))
   11993         1578 :           len--;
   11994      5255953 :         for (int i = 0; i < len; i++)
   11995      3411634 :           WALK_SUBTREE (OMP_CLAUSE_OPERAND (t, i));
   11996      1844319 :         WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (t));
   11997              :       }
   11998              : 
   11999     81881189 :     case TARGET_EXPR:
   12000     81881189 :       {
   12001     81881189 :         int i, len;
   12002              : 
   12003              :         /* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
   12004              :            But, we only want to walk once.  */
   12005     81881189 :         len = (TREE_OPERAND (t, 3) == TREE_OPERAND (t, 1)) ? 2 : 3;
   12006    327489495 :         for (i = 0; i < len; ++i)
   12007    245625885 :           WALK_SUBTREE (TREE_OPERAND (t, i));
   12008     81863610 :         WALK_SUBTREE_TAIL (TREE_OPERAND (t, len));
   12009              :       }
   12010              : 
   12011    164207459 :     case DECL_EXPR:
   12012              :       /* If this is a TYPE_DECL, walk into the fields of the type that it's
   12013              :          defining.  We only want to walk into these fields of a type in this
   12014              :          case and not in the general case of a mere reference to the type.
   12015              : 
   12016              :          The criterion is as follows: if the field can be an expression, it
   12017              :          must be walked only here.  This should be in keeping with the fields
   12018              :          that are directly gimplified in gimplify_type_sizes in order for the
   12019              :          mark/copy-if-shared/unmark machinery of the gimplifier to work with
   12020              :          variable-sized types.
   12021              : 
   12022              :          Note that DECLs get walked as part of processing the BIND_EXPR.  */
   12023    164207459 :       if (TREE_CODE (DECL_EXPR_DECL (t)) == TYPE_DECL)
   12024              :         {
   12025              :           /* Call the function for the decl so e.g. copy_tree_body_r can
   12026              :              replace it with the remapped one.  */
   12027      1784814 :           result = (*func) (&DECL_EXPR_DECL (t), &walk_subtrees, data);
   12028      1784814 :           if (result || !walk_subtrees)
   12029              :             return result;
   12030              : 
   12031      1739455 :           tree *type_p = &TREE_TYPE (DECL_EXPR_DECL (t));
   12032      1739455 :           if (TREE_CODE (*type_p) == ERROR_MARK)
   12033              :             return NULL_TREE;
   12034              : 
   12035              :           /* Call the function for the type.  See if it returns anything or
   12036              :              doesn't want us to continue.  If we are to continue, walk both
   12037              :              the normal fields and those for the declaration case.  */
   12038      1739455 :           result = (*func) (type_p, &walk_subtrees, data);
   12039      1739455 :           if (result || !walk_subtrees)
   12040              :             return result;
   12041              : 
   12042      1644762 :           tree type = *type_p;
   12043              : 
   12044              :           /* But do not walk a pointed-to type since it may itself need to
   12045              :              be walked in the declaration case if it isn't anonymous.  */
   12046      1644762 :           if (!POINTER_TYPE_P (type))
   12047              :             {
   12048      1629055 :               result = walk_type_fields (type, func, data, pset, lh);
   12049      1629055 :               if (result)
   12050              :                 return result;
   12051              :             }
   12052              : 
   12053              :           /* If this is a record type, also walk the fields.  */
   12054      1644762 :           if (RECORD_OR_UNION_TYPE_P (type))
   12055              :             {
   12056       504987 :               tree field;
   12057              : 
   12058      2377599 :               for (field = TYPE_FIELDS (type); field;
   12059      1872612 :                    field = DECL_CHAIN (field))
   12060              :                 {
   12061              :                   /* We'd like to look at the type of the field, but we can
   12062              :                      easily get infinite recursion.  So assume it's pointed
   12063              :                      to elsewhere in the tree.  Also, ignore things that
   12064              :                      aren't fields.  */
   12065      1872612 :                   if (TREE_CODE (field) != FIELD_DECL)
   12066      1399533 :                     continue;
   12067              : 
   12068       473079 :                   WALK_SUBTREE (DECL_FIELD_OFFSET (field));
   12069       473079 :                   WALK_SUBTREE (DECL_SIZE (field));
   12070       473079 :                   WALK_SUBTREE (DECL_SIZE_UNIT (field));
   12071       473079 :                   if (TREE_CODE (type) == QUAL_UNION_TYPE)
   12072            0 :                     WALK_SUBTREE (DECL_QUALIFIER (field));
   12073              :                 }
   12074              :             }
   12075              : 
   12076              :           /* Same for scalar types.  */
   12077              :           else if (TREE_CODE (type) == BOOLEAN_TYPE
   12078              :                    || TREE_CODE (type) == ENUMERAL_TYPE
   12079              :                    || TREE_CODE (type) == INTEGER_TYPE
   12080              :                    || TREE_CODE (type) == FIXED_POINT_TYPE
   12081              :                    || TREE_CODE (type) == REAL_TYPE)
   12082              :             {
   12083        38221 :               WALK_SUBTREE (TYPE_MIN_VALUE (type));
   12084        38221 :               WALK_SUBTREE (TYPE_MAX_VALUE (type));
   12085              :             }
   12086              : 
   12087      1644762 :           WALK_SUBTREE (TYPE_SIZE (type));
   12088      1644762 :           WALK_SUBTREE_TAIL (TYPE_SIZE_UNIT (type));
   12089              :         }
   12090              :       /* FALLTHRU */
   12091              : 
   12092  32874936480 :     default:
   12093  32874936480 :       if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
   12094              :         {
   12095  24404604128 :           int i, len;
   12096              : 
   12097              :           /* Walk over all the sub-trees of this operand.  */
   12098  24404604128 :           len = TREE_OPERAND_LENGTH (t);
   12099              : 
   12100              :           /* Go through the subtrees.  We need to do this in forward order so
   12101              :              that the scope of a FOR_EXPR is handled properly.  */
   12102  24404604128 :           if (len)
   12103              :             {
   12104  48901360670 :               for (i = 0; i < len - 1; ++i)
   12105  24771086379 :                 WALK_SUBTREE (TREE_OPERAND (t, i));
   12106  24130274291 :               WALK_SUBTREE_TAIL (TREE_OPERAND (t, len - 1));
   12107              :             }
   12108              :         }
   12109              :       /* If this is a type, walk the needed fields in the type.  */
   12110   8470332352 :       else if (TYPE_P (t))
   12111   5253761510 :         return walk_type_fields (t, func, data, pset, lh);
   12112              :       break;
   12113              :     }
   12114              : 
   12115              :   /* We didn't find what we were looking for.  */
   12116              :   return NULL_TREE;
   12117              : 
   12118              : #undef WALK_SUBTREE_TAIL
   12119              : }
   12120              : #undef WALK_SUBTREE
   12121              : 
   12122              : /* Like walk_tree, but does not walk duplicate nodes more than once.  */
   12123              : 
   12124              : tree
   12125   3932026726 : walk_tree_without_duplicates_1 (tree *tp, walk_tree_fn func, void *data,
   12126              :                                 walk_tree_lh lh)
   12127              : {
   12128   3932026726 :   tree result;
   12129              : 
   12130   3932026726 :   hash_set<tree> pset;
   12131   3932026726 :   result = walk_tree_1 (tp, func, data, &pset, lh);
   12132   3932026726 :   return result;
   12133   3932026726 : }
   12134              : 
   12135              : 
   12136              : tree
   12137   1203287262 : tree_block (tree t)
   12138              : {
   12139   1203287262 :   const enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
   12140              : 
   12141   1203287262 :   if (IS_EXPR_CODE_CLASS (c))
   12142   1203287262 :     return LOCATION_BLOCK (t->exp.locus);
   12143            0 :   gcc_unreachable ();
   12144              :   return NULL;
   12145              : }
   12146              : 
   12147              : void
   12148    755594874 : tree_set_block (tree t, tree b)
   12149              : {
   12150    755594874 :   const enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
   12151              : 
   12152    755594874 :   if (IS_EXPR_CODE_CLASS (c))
   12153              :     {
   12154    755594874 :       t->exp.locus = set_block (t->exp.locus, b);
   12155              :     }
   12156              :   else
   12157            0 :     gcc_unreachable ();
   12158    755594874 : }
   12159              : 
   12160              : /* Create a nameless artificial label and put it in the current
   12161              :    function context.  The label has a location of LOC.  Returns the
   12162              :    newly created label.  */
   12163              : 
   12164              : tree
   12165     33164433 : create_artificial_label (location_t loc)
   12166              : {
   12167     33164433 :   tree lab = build_decl (loc,
   12168              :                          LABEL_DECL, NULL_TREE, void_type_node);
   12169              : 
   12170     33164433 :   DECL_ARTIFICIAL (lab) = 1;
   12171     33164433 :   DECL_IGNORED_P (lab) = 1;
   12172     33164433 :   DECL_CONTEXT (lab) = current_function_decl;
   12173     33164433 :   return lab;
   12174              : }
   12175              : 
   12176              : /*  Given a tree, try to return a useful variable name that we can use
   12177              :     to prefix a temporary that is being assigned the value of the tree.
   12178              :     I.E. given  <temp> = &A, return A.  */
   12179              : 
   12180              : const char *
   12181     25469103 : get_name (tree t)
   12182              : {
   12183     27379987 :   tree stripped_decl;
   12184              : 
   12185     27379987 :   stripped_decl = t;
   12186     27379987 :   STRIP_NOPS (stripped_decl);
   12187     27379987 :   if (DECL_P (stripped_decl) && DECL_NAME (stripped_decl))
   12188      4092002 :     return IDENTIFIER_POINTER (DECL_NAME (stripped_decl));
   12189     23287985 :   else if (TREE_CODE (stripped_decl) == SSA_NAME)
   12190              :     {
   12191      1402083 :       tree name = SSA_NAME_IDENTIFIER (stripped_decl);
   12192       343416 :       if (!name)
   12193              :         return NULL;
   12194       341863 :       return IDENTIFIER_POINTER (name);
   12195              :     }
   12196              :   else
   12197              :     {
   12198     21885902 :       switch (TREE_CODE (stripped_decl))
   12199              :         {
   12200      1910884 :         case ADDR_EXPR:
   12201      1910884 :           return get_name (TREE_OPERAND (stripped_decl, 0));
   12202              :         default:
   12203              :           return NULL;
   12204              :         }
   12205              :     }
   12206              : }
   12207              : 
   12208              : /* Return true if TYPE has a variable argument list.  */
   12209              : 
   12210              : bool
   12211    238561002 : stdarg_p (const_tree fntype)
   12212              : {
   12213    238561002 :   function_args_iterator args_iter;
   12214    238561002 :   tree n = NULL_TREE, t;
   12215              : 
   12216    238561002 :   if (!fntype)
   12217              :     return false;
   12218              : 
   12219    238423794 :   if (TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
   12220              :     return true;
   12221              : 
   12222    966270329 :   FOREACH_FUNCTION_ARGS (fntype, t, args_iter)
   12223              :     {
   12224    728611423 :       n = t;
   12225              :     }
   12226              : 
   12227    237658906 :   return n != NULL_TREE && n != void_type_node;
   12228              : }
   12229              : 
   12230              : /* Return true if TYPE has a prototype.  */
   12231              : 
   12232              : bool
   12233    732965457 : prototype_p (const_tree fntype)
   12234              : {
   12235    732965457 :   tree t;
   12236              : 
   12237    732965457 :   gcc_assert (fntype != NULL_TREE);
   12238              : 
   12239    732965457 :   if (TYPE_NO_NAMED_ARGS_STDARG_P (fntype))
   12240              :     return true;
   12241              : 
   12242    732098200 :   t = TYPE_ARG_TYPES (fntype);
   12243    732098200 :   return (t != NULL_TREE);
   12244              : }
   12245              : 
   12246              : /* If BLOCK is inlined from an __attribute__((__artificial__))
   12247              :    routine, return pointer to location from where it has been
   12248              :    called.  */
   12249              : location_t *
   12250       174160 : block_nonartificial_location (tree block)
   12251              : {
   12252       174160 :   location_t *ret = NULL;
   12253              : 
   12254       445969 :   while (block && TREE_CODE (block) == BLOCK
   12255       538365 :          && BLOCK_ABSTRACT_ORIGIN (block))
   12256              :     {
   12257       168270 :       tree ao = BLOCK_ABSTRACT_ORIGIN (block);
   12258       168270 :       if (TREE_CODE (ao) == FUNCTION_DECL)
   12259              :         {
   12260              :           /* If AO is an artificial inline, point RET to the
   12261              :              call site locus at which it has been inlined and continue
   12262              :              the loop, in case AO's caller is also an artificial
   12263              :              inline.  */
   12264        72388 :           if (DECL_DECLARED_INLINE_P (ao)
   12265        72388 :               && lookup_attribute ("artificial", DECL_ATTRIBUTES (ao)))
   12266         1813 :             ret = &BLOCK_SOURCE_LOCATION (block);
   12267              :           else
   12268              :             break;
   12269              :         }
   12270        95882 :       else if (TREE_CODE (ao) != BLOCK)
   12271              :         break;
   12272              : 
   12273        97695 :       block = BLOCK_SUPERCONTEXT (block);
   12274              :     }
   12275       174160 :   return ret;
   12276              : }
   12277              : 
   12278              : 
   12279              : /* If EXP is inlined from an __attribute__((__artificial__))
   12280              :    function, return the location of the original call expression.  */
   12281              : 
   12282              : location_t
   12283           46 : tree_nonartificial_location (tree exp)
   12284              : {
   12285           46 :   location_t *loc = block_nonartificial_location (TREE_BLOCK (exp));
   12286              : 
   12287           46 :   if (loc)
   12288            0 :     return *loc;
   12289              :   else
   12290           46 :     return EXPR_LOCATION (exp);
   12291              : }
   12292              : 
   12293              : /* Return the location into which EXP has been inlined.  Analogous
   12294              :    to tree_nonartificial_location() above but not limited to artificial
   12295              :    functions declared inline.  If SYSTEM_HEADER is true, return
   12296              :    the macro expansion point of the location if it's in a system header */
   12297              : 
   12298              : location_t
   12299            0 : tree_inlined_location (tree exp, bool system_header /* = true */)
   12300              : {
   12301            0 :   location_t loc = UNKNOWN_LOCATION;
   12302              : 
   12303            0 :   tree block = TREE_BLOCK (exp);
   12304              : 
   12305            0 :   while (block && TREE_CODE (block) == BLOCK
   12306            0 :          && BLOCK_ABSTRACT_ORIGIN (block))
   12307              :     {
   12308            0 :       tree ao = BLOCK_ABSTRACT_ORIGIN (block);
   12309            0 :       if (TREE_CODE (ao) == FUNCTION_DECL)
   12310            0 :         loc = BLOCK_SOURCE_LOCATION (block);
   12311            0 :       else if (TREE_CODE (ao) != BLOCK)
   12312              :         break;
   12313              : 
   12314            0 :       block = BLOCK_SUPERCONTEXT (block);
   12315              :     }
   12316              : 
   12317            0 :   if (loc == UNKNOWN_LOCATION)
   12318              :     {
   12319            0 :       loc = EXPR_LOCATION (exp);
   12320            0 :       if (system_header)
   12321              :         /* Only consider macro expansion when the block traversal failed
   12322              :            to find a location.  Otherwise it's not relevant.  */
   12323            0 :         return expansion_point_location_if_in_system_header (loc);
   12324              :     }
   12325              : 
   12326              :   return loc;
   12327              : }
   12328              : 
   12329              : /* These are the hash table functions for the hash table of OPTIMIZATION_NODE
   12330              :    nodes.  */
   12331              : 
   12332              : /* Return the hash code X, an OPTIMIZATION_NODE or TARGET_OPTION code.  */
   12333              : 
   12334              : hashval_t
   12335    965348198 : cl_option_hasher::hash (tree x)
   12336              : {
   12337    965348198 :   const_tree const t = x;
   12338              : 
   12339    965348198 :   if (TREE_CODE (t) == OPTIMIZATION_NODE)
   12340    103127131 :     return cl_optimization_hash (TREE_OPTIMIZATION (t));
   12341    862221067 :   else if (TREE_CODE (t) == TARGET_OPTION_NODE)
   12342    862221067 :     return cl_target_option_hash (TREE_TARGET_OPTION (t));
   12343              :   else
   12344            0 :     gcc_unreachable ();
   12345              : }
   12346              : 
   12347              : /* Return nonzero if the value represented by *X (an OPTIMIZATION or
   12348              :    TARGET_OPTION tree node) is the same as that given by *Y, which is the
   12349              :    same.  */
   12350              : 
   12351              : bool
   12352   1016814022 : cl_option_hasher::equal (tree x, tree y)
   12353              : {
   12354   1016814022 :   const_tree const xt = x;
   12355   1016814022 :   const_tree const yt = y;
   12356              : 
   12357   1016814022 :   if (TREE_CODE (xt) != TREE_CODE (yt))
   12358              :     return false;
   12359              : 
   12360    567361931 :   if (TREE_CODE (xt) == OPTIMIZATION_NODE)
   12361    101535580 :     return cl_optimization_option_eq (TREE_OPTIMIZATION (xt),
   12362    101535580 :                                       TREE_OPTIMIZATION (yt));
   12363    465826351 :   else if (TREE_CODE (xt) == TARGET_OPTION_NODE)
   12364    465826351 :     return cl_target_option_eq (TREE_TARGET_OPTION (xt),
   12365    465826351 :                                 TREE_TARGET_OPTION (yt));
   12366              :   else
   12367            0 :     gcc_unreachable ();
   12368              : }
   12369              : 
   12370              : /* Build an OPTIMIZATION_NODE based on the options in OPTS and OPTS_SET.  */
   12371              : 
   12372              : tree
   12373    101503007 : build_optimization_node (struct gcc_options *opts,
   12374              :                          struct gcc_options *opts_set)
   12375              : {
   12376    101503007 :   tree t;
   12377              : 
   12378              :   /* Use the cache of optimization nodes.  */
   12379              : 
   12380    101503007 :   cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node),
   12381              :                         opts, opts_set);
   12382              : 
   12383    101503007 :   tree *slot = cl_option_hash_table->find_slot (cl_optimization_node, INSERT);
   12384    101503007 :   t = *slot;
   12385    101503007 :   if (!t)
   12386              :     {
   12387              :       /* Insert this one into the hash table.  */
   12388       296852 :       t = cl_optimization_node;
   12389       296852 :       *slot = t;
   12390              : 
   12391              :       /* Make a new node for next time round.  */
   12392       296852 :       cl_optimization_node = make_node (OPTIMIZATION_NODE);
   12393              :     }
   12394              : 
   12395    101503007 :   return t;
   12396              : }
   12397              : 
   12398              : /* Build a TARGET_OPTION_NODE based on the options in OPTS and OPTS_SET.  */
   12399              : 
   12400              : tree
   12401     78572668 : build_target_option_node (struct gcc_options *opts,
   12402              :                           struct gcc_options *opts_set)
   12403              : {
   12404     78572668 :   tree t;
   12405              : 
   12406              :   /* Use the cache of optimization nodes.  */
   12407              : 
   12408     78572668 :   cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node),
   12409              :                          opts, opts_set);
   12410              : 
   12411     78572668 :   tree *slot = cl_option_hash_table->find_slot (cl_target_option_node, INSERT);
   12412     78572668 :   t = *slot;
   12413     78572668 :   if (!t)
   12414              :     {
   12415              :       /* Insert this one into the hash table.  */
   12416       788180 :       t = cl_target_option_node;
   12417       788180 :       *slot = t;
   12418              : 
   12419              :       /* Make a new node for next time round.  */
   12420       788180 :       cl_target_option_node = make_node (TARGET_OPTION_NODE);
   12421              :     }
   12422              : 
   12423     78572668 :   return t;
   12424              : }
   12425              : 
   12426              : /* Clear TREE_TARGET_GLOBALS of all TARGET_OPTION_NODE trees,
   12427              :    so that they aren't saved during PCH writing.  */
   12428              : 
   12429              : void
   12430          432 : prepare_target_option_nodes_for_pch (void)
   12431              : {
   12432          432 :   hash_table<cl_option_hasher>::iterator iter = cl_option_hash_table->begin ();
   12433         1728 :   for (; iter != cl_option_hash_table->end (); ++iter)
   12434          864 :     if (TREE_CODE (*iter) == TARGET_OPTION_NODE)
   12435          432 :       TREE_TARGET_GLOBALS (*iter) = NULL;
   12436          432 : }
   12437              : 
   12438              : /* Determine the "ultimate origin" of a block.  */
   12439              : 
   12440              : tree
   12441    228639420 : block_ultimate_origin (const_tree block)
   12442              : {
   12443    228639420 :   tree origin = BLOCK_ABSTRACT_ORIGIN (block);
   12444              : 
   12445    228639420 :   if (origin == NULL_TREE)
   12446              :     return NULL_TREE;
   12447              :   else
   12448              :     {
   12449    282756277 :       gcc_checking_assert ((DECL_P (origin)
   12450              :                             && DECL_ORIGIN (origin) == origin)
   12451              :                            || BLOCK_ORIGIN (origin) == origin);
   12452              :       return origin;
   12453              :     }
   12454              : }
   12455              : 
   12456              : /* Return true iff conversion from INNER_TYPE to OUTER_TYPE generates
   12457              :    no instruction.  */
   12458              : 
   12459              : bool
   12460   1779816332 : tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
   12461              : {
   12462   1779816332 :   if (!inner_type || inner_type == error_mark_node)
   12463              :     return false;
   12464              : 
   12465              :   /* Do not strip casts into or out of differing address spaces.  */
   12466   1779778253 :   if (POINTER_TYPE_P (outer_type)
   12467   1779778253 :       && TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != ADDR_SPACE_GENERIC)
   12468              :     {
   12469          574 :       if (!POINTER_TYPE_P (inner_type)
   12470          574 :           || (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
   12471          551 :               != TYPE_ADDR_SPACE (TREE_TYPE (inner_type))))
   12472              :         return false;
   12473              :     }
   12474   1779777679 :   else if (POINTER_TYPE_P (inner_type)
   12475   1779777679 :            && TYPE_ADDR_SPACE (TREE_TYPE (inner_type)) != ADDR_SPACE_GENERIC)
   12476              :     {
   12477              :       /* We already know that outer_type is not a pointer with
   12478              :          a non-generic address space.  */
   12479              :       return false;
   12480              :     }
   12481              : 
   12482              :   /* Use precision rather then machine mode when we can, which gives
   12483              :      the correct answer even for submode (bit-field) types.  */
   12484   1779775391 :   if ((INTEGRAL_TYPE_P (outer_type)
   12485    783703767 :        || POINTER_TYPE_P (outer_type)
   12486     74221638 :        || TREE_CODE (outer_type) == OFFSET_TYPE)
   12487   1705565513 :       && (INTEGRAL_TYPE_P (inner_type)
   12488    802319475 :           || POINTER_TYPE_P (inner_type)
   12489      1986362 :           || TREE_CODE (inner_type) == OFFSET_TYPE))
   12490   1703604351 :     return TYPE_PRECISION (outer_type) == TYPE_PRECISION (inner_type);
   12491              : 
   12492     76171040 :   if (TYPE_MODE (outer_type) == BLKmode
   12493     76171040 :       && TYPE_MODE (inner_type) == BLKmode)
   12494              :     {
   12495         7944 :       if (VECTOR_TYPE_P (outer_type)
   12496         5324 :           && VECTOR_TYPE_P (inner_type)
   12497         5324 :           && known_eq (TYPE_VECTOR_SUBPARTS (outer_type),
   12498              :                        TYPE_VECTOR_SUBPARTS (inner_type))
   12499        18592 :           && (TYPE_MODE (TREE_TYPE (outer_type))
   12500         5324 :               == TYPE_MODE (TREE_TYPE (inner_type))))
   12501         5324 :         return true;
   12502         2620 :       return false;
   12503              :     }
   12504              : 
   12505              :   /* Otherwise fall back on comparing machine modes (e.g. for
   12506              :      aggregate types, floats).  */
   12507     76163096 :   return TYPE_MODE (outer_type) == TYPE_MODE (inner_type);
   12508              : }
   12509              : 
   12510              : /* Return true iff a view conversion from vector type INNER_TYPE to vector
   12511              :    type OUTER_TYPE has the same number of elements and does not change the
   12512              :    representation of an element.  */
   12513              : 
   12514              : bool
   12515      6920863 : vector_nop_conversion_p (const_tree outer_type, const_tree inner_type)
   12516              : {
   12517      6920863 :   return (VECTOR_TYPE_P (outer_type)
   12518      3616608 :           && VECTOR_TYPE_P (inner_type)
   12519      3587346 :           && known_eq (TYPE_VECTOR_SUBPARTS (outer_type),
   12520              :                        TYPE_VECTOR_SUBPARTS (inner_type))
   12521      9449167 :           && tree_nop_conversion_p (TREE_TYPE (outer_type),
   12522      2528304 :                                     TREE_TYPE (inner_type)));
   12523              : }
   12524              : 
   12525              : /* Return true iff conversion in EXP generates no instruction.  Mark
   12526              :    it inline so that we fully inline into the stripping functions even
   12527              :    though we have two uses of this function.  */
   12528              : 
   12529              : static inline bool
   12530  21103851703 : tree_nop_conversion (const_tree exp)
   12531              : {
   12532  21103851703 :   tree outer_type, inner_type;
   12533              : 
   12534  21103851703 :   if (location_wrapper_p (exp))
   12535              :     return true;
   12536  21035743031 :   if (!CONVERT_EXPR_P (exp)
   12537  19927287134 :       && TREE_CODE (exp) != NON_LVALUE_EXPR)
   12538              :     return false;
   12539              : 
   12540   1124925816 :   outer_type = TREE_TYPE (exp);
   12541   1124925816 :   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
   12542              : 
   12543   1124925816 :   return tree_nop_conversion_p (outer_type, inner_type);
   12544              : }
   12545              : 
   12546              : /* Return true iff conversion in EXP generates no instruction.  Don't
   12547              :    consider conversions changing the signedness.  */
   12548              : 
   12549              : static bool
   12550   2404487723 : tree_sign_nop_conversion (const_tree exp)
   12551              : {
   12552   2404487723 :   tree outer_type, inner_type;
   12553              : 
   12554   2404487723 :   if (!tree_nop_conversion (exp))
   12555              :     return false;
   12556              : 
   12557    240265498 :   outer_type = TREE_TYPE (exp);
   12558    240265498 :   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
   12559              : 
   12560    240265498 :   return (TYPE_UNSIGNED (outer_type) == TYPE_UNSIGNED (inner_type)
   12561    240265498 :           && POINTER_TYPE_P (outer_type) == POINTER_TYPE_P (inner_type));
   12562              : }
   12563              : 
   12564              : /* Strip conversions from EXP according to tree_nop_conversion and
   12565              :    return the resulting expression.  */
   12566              : 
   12567              : tree
   12568  17905447230 : tree_strip_nop_conversions (tree exp)
   12569              : {
   12570  18699363980 :   while (tree_nop_conversion (exp))
   12571    793916750 :     exp = TREE_OPERAND (exp, 0);
   12572  17905447230 :   return exp;
   12573              : }
   12574              : 
   12575              : /* Strip conversions from EXP according to tree_sign_nop_conversion
   12576              :    and return the resulting expression.  */
   12577              : 
   12578              : tree
   12579   2190960584 : tree_strip_sign_nop_conversions (tree exp)
   12580              : {
   12581   2404487723 :   while (tree_sign_nop_conversion (exp))
   12582    213527139 :     exp = TREE_OPERAND (exp, 0);
   12583   2190960584 :   return exp;
   12584              : }
   12585              : 
   12586              : /* Avoid any floating point extensions from EXP.  */
   12587              : tree
   12588    101106483 : strip_float_extensions (tree exp)
   12589              : {
   12590    101226149 :   tree sub, expt, subt;
   12591              : 
   12592              :   /*  For floating point constant look up the narrowest type that can hold
   12593              :       it properly and handle it like (type)(narrowest_type)constant.
   12594              :       This way we can optimize for instance a=a*2.0 where "a" is float
   12595              :       but 2.0 is double constant.  */
   12596    101226149 :   if (TREE_CODE (exp) == REAL_CST && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (exp)))
   12597              :     {
   12598      3262800 :       REAL_VALUE_TYPE orig;
   12599      3262800 :       tree type = NULL;
   12600              : 
   12601      3262800 :       orig = TREE_REAL_CST (exp);
   12602      3262800 :       if (TYPE_PRECISION (TREE_TYPE (exp)) > TYPE_PRECISION (float_type_node)
   12603      3262800 :           && exact_real_truncate (TYPE_MODE (float_type_node), &orig))
   12604       140898 :         type = float_type_node;
   12605      3121902 :       else if (TYPE_PRECISION (TREE_TYPE (exp))
   12606      3121902 :                > TYPE_PRECISION (double_type_node)
   12607      3121902 :                && exact_real_truncate (TYPE_MODE (double_type_node), &orig))
   12608        34571 :         type = double_type_node;
   12609      3262800 :       if (type)
   12610       175469 :         return build_real_truncate (type, orig);
   12611              :     }
   12612              : 
   12613    101050680 :   if (!CONVERT_EXPR_P (exp))
   12614              :     return exp;
   12615              : 
   12616      5604018 :   sub = TREE_OPERAND (exp, 0);
   12617      5604018 :   subt = TREE_TYPE (sub);
   12618      5604018 :   expt = TREE_TYPE (exp);
   12619              : 
   12620      5604018 :   if (!FLOAT_TYPE_P (subt))
   12621              :     return exp;
   12622              : 
   12623       431086 :   if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt))
   12624              :     return exp;
   12625              : 
   12626       144060 :   if (element_precision (subt) > element_precision (expt))
   12627              :     return exp;
   12628              : 
   12629              :   return strip_float_extensions (sub);
   12630              : }
   12631              : 
   12632              : /* Strip out all handled components that produce invariant
   12633              :    offsets.  */
   12634              : 
   12635              : const_tree
   12636   6053889647 : strip_invariant_refs (const_tree op)
   12637              : {
   12638   7069925076 :   while (handled_component_p (op))
   12639              :     {
   12640   1028403070 :       switch (TREE_CODE (op))
   12641              :         {
   12642    198313246 :         case ARRAY_REF:
   12643    198313246 :         case ARRAY_RANGE_REF:
   12644    198313246 :           if (!is_gimple_constant (TREE_OPERAND (op, 1))
   12645    187683082 :               || TREE_OPERAND (op, 2) != NULL_TREE
   12646    186120044 :               || TREE_OPERAND (op, 3) != NULL_TREE)
   12647              :             return NULL;
   12648              :           break;
   12649              : 
   12650    828664810 :         case COMPONENT_REF:
   12651    828664810 :           if (TREE_OPERAND (op, 2) != NULL_TREE)
   12652              :             return NULL;
   12653              :           break;
   12654              : 
   12655   1016035429 :         default:;
   12656              :         }
   12657   1016035429 :       op = TREE_OPERAND (op, 0);
   12658              :     }
   12659              : 
   12660              :   return op;
   12661              : }
   12662              : 
   12663              : /* Strip handled components with zero offset from OP.  */
   12664              : 
   12665              : tree
   12666       584231 : strip_zero_offset_components (tree op)
   12667              : {
   12668       584231 :   while (TREE_CODE (op) == COMPONENT_REF
   12669       439850 :          && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (op, 1)))
   12670      1137886 :          && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (op, 1))))
   12671       182584 :     op = TREE_OPERAND (op, 0);
   12672       584231 :   return op;
   12673              : }
   12674              : 
   12675              : static GTY(()) tree gcc_eh_personality_decl;
   12676              : 
   12677              : /* Return the GCC personality function decl.  */
   12678              : 
   12679              : tree
   12680          407 : lhd_gcc_personality (void)
   12681              : {
   12682          407 :   if (!gcc_eh_personality_decl)
   12683          163 :     gcc_eh_personality_decl = build_personality_function ("gcc");
   12684          407 :   return gcc_eh_personality_decl;
   12685              : }
   12686              : 
   12687              : /* TARGET is a call target of GIMPLE call statement
   12688              :    (obtained by gimple_call_fn).  Return true if it is
   12689              :    OBJ_TYPE_REF representing an virtual call of C++ method.
   12690              :    (As opposed to OBJ_TYPE_REF representing objc calls
   12691              :    through a cast where middle-end devirtualization machinery
   12692              :    can't apply.)  FOR_DUMP_P is true when being called from
   12693              :    the dump routines.  */
   12694              : 
   12695              : bool
   12696     28632850 : virtual_method_call_p (const_tree target, bool for_dump_p)
   12697              : {
   12698     28632850 :   if (TREE_CODE (target) != OBJ_TYPE_REF)
   12699              :     return false;
   12700      1308489 :   tree t = TREE_TYPE (target);
   12701      1308489 :   gcc_checking_assert (TREE_CODE (t) == POINTER_TYPE);
   12702      1308489 :   t = TREE_TYPE (t);
   12703      1308489 :   if (TREE_CODE (t) == FUNCTION_TYPE)
   12704              :     return false;
   12705      1307205 :   gcc_checking_assert (TREE_CODE (t) == METHOD_TYPE);
   12706              :   /* If we do not have BINFO associated, it means that type was built
   12707              :      without devirtualization enabled.  Do not consider this a virtual
   12708              :      call.  */
   12709      1307205 :   if (!TYPE_BINFO (obj_type_ref_class (target, for_dump_p)))
   12710            0 :     return false;
   12711              :   return true;
   12712              : }
   12713              : 
   12714              : /* Lookup sub-BINFO of BINFO of TYPE at offset POS.  */
   12715              : 
   12716              : static tree
   12717          108 : lookup_binfo_at_offset (tree binfo, tree type, HOST_WIDE_INT pos)
   12718              : {
   12719          108 :   unsigned int i;
   12720          108 :   tree base_binfo, b;
   12721              : 
   12722          124 :   for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
   12723          108 :     if (pos == tree_to_shwi (BINFO_OFFSET (base_binfo))
   12724          108 :         && types_same_for_odr (TREE_TYPE (base_binfo), type))
   12725              :       return base_binfo;
   12726           70 :     else if ((b = lookup_binfo_at_offset (base_binfo, type, pos)) != NULL)
   12727              :       return b;
   12728              :   return NULL;
   12729              : }
   12730              : 
   12731              : /* Try to find a base info of BINFO that would have its field decl at offset
   12732              :    OFFSET within the BINFO type and which is of EXPECTED_TYPE.  If it can be
   12733              :    found, return, otherwise return NULL_TREE.  */
   12734              : 
   12735              : tree
   12736       276154 : get_binfo_at_offset (tree binfo, poly_int64 offset, tree expected_type)
   12737              : {
   12738       276154 :   tree type = BINFO_TYPE (binfo);
   12739              : 
   12740       737356 :   while (true)
   12741              :     {
   12742       506755 :       HOST_WIDE_INT pos, size;
   12743       506755 :       tree fld;
   12744       506755 :       int i;
   12745              : 
   12746       506755 :       if (types_same_for_odr (type, expected_type))
   12747       276154 :           return binfo;
   12748       230601 :       if (maybe_lt (offset, 0))
   12749              :         return NULL_TREE;
   12750              : 
   12751      1164581 :       for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
   12752              :         {
   12753      1164581 :           if (TREE_CODE (fld) != FIELD_DECL || !DECL_ARTIFICIAL (fld))
   12754       933783 :             continue;
   12755              : 
   12756       230798 :           pos = int_bit_position (fld);
   12757       230798 :           size = tree_to_uhwi (DECL_SIZE (fld));
   12758      1164778 :           if (known_in_range_p (offset, pos, size))
   12759              :             break;
   12760              :         }
   12761       230601 :       if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE)
   12762              :         return NULL_TREE;
   12763              : 
   12764              :       /* Offset 0 indicates the primary base, whose vtable contents are
   12765              :          represented in the binfo for the derived class.  */
   12766       230601 :       else if (maybe_ne (offset, 0))
   12767              :         {
   12768          197 :           tree found_binfo = NULL, base_binfo;
   12769              :           /* Offsets in BINFO are in bytes relative to the whole structure
   12770              :              while POS is in bits relative to the containing field.  */
   12771          197 :           int binfo_offset = (tree_to_shwi (BINFO_OFFSET (binfo)) + pos
   12772          197 :                              / BITS_PER_UNIT);
   12773              : 
   12774          377 :           for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
   12775          339 :             if (tree_to_shwi (BINFO_OFFSET (base_binfo)) == binfo_offset
   12776          339 :                 && types_same_for_odr (TREE_TYPE (base_binfo), TREE_TYPE (fld)))
   12777              :               {
   12778              :                 found_binfo = base_binfo;
   12779              :                 break;
   12780              :               }
   12781          197 :           if (found_binfo)
   12782              :             binfo = found_binfo;
   12783              :           else
   12784           38 :             binfo = lookup_binfo_at_offset (binfo, TREE_TYPE (fld),
   12785              :                                             binfo_offset);
   12786              :          }
   12787              : 
   12788       230601 :       type = TREE_TYPE (fld);
   12789       230601 :       offset -= pos;
   12790       230601 :     }
   12791              : }
   12792              : 
   12793              : /* PR 84195: Replace control characters in "unescaped" with their
   12794              :    escaped equivalents.  Allow newlines if -fmessage-length has
   12795              :    been set to a non-zero value.  This is done here, rather than
   12796              :    where the attribute is recorded as the message length can
   12797              :    change between these two locations.  */
   12798              : 
   12799              : void
   12800       135930 : escaped_string::escape (const char *unescaped)
   12801              : {
   12802       135930 :   char *escaped;
   12803       135930 :   size_t i, new_i, len;
   12804              : 
   12805       135930 :   if (m_owned)
   12806            8 :     free (m_str);
   12807              : 
   12808       135930 :   m_str = const_cast<char *> (unescaped);
   12809       135930 :   m_owned = false;
   12810              : 
   12811       135930 :   if (unescaped == NULL || *unescaped == 0)
   12812              :     return;
   12813              : 
   12814       135922 :   len = strlen (unescaped);
   12815       135922 :   escaped = NULL;
   12816       135922 :   new_i = 0;
   12817              : 
   12818      3938920 :   for (i = 0; i < len; i++)
   12819              :     {
   12820      3802998 :       char c = unescaped[i];
   12821              : 
   12822      3802998 :       if (!ISCNTRL (c))
   12823              :         {
   12824      3802913 :           if (escaped)
   12825           33 :             escaped[new_i++] = c;
   12826      3802913 :           continue;
   12827              :         }
   12828              : 
   12829           85 :       if (c != '\n' || !pp_is_wrapping_line (global_dc->get_reference_printer ()))
   12830              :         {
   12831           77 :           if (escaped == NULL)
   12832              :             {
   12833              :               /* We only allocate space for a new string if we
   12834              :                  actually encounter a control character that
   12835              :                  needs replacing.  */
   12836           19 :               escaped = (char *) xmalloc (len * 2 + 1);
   12837           19 :               strncpy (escaped, unescaped, i);
   12838           19 :               new_i = i;
   12839              :             }
   12840              : 
   12841           77 :           escaped[new_i++] = '\\';
   12842              : 
   12843           77 :           switch (c)
   12844              :             {
   12845            8 :             case '\a': escaped[new_i++] = 'a'; break;
   12846            8 :             case '\b': escaped[new_i++] = 'b'; break;
   12847            8 :             case '\f': escaped[new_i++] = 'f'; break;
   12848           15 :             case '\n': escaped[new_i++] = 'n'; break;
   12849           15 :             case '\r': escaped[new_i++] = 'r'; break;
   12850           15 :             case '\t': escaped[new_i++] = 't'; break;
   12851            8 :             case '\v': escaped[new_i++] = 'v'; break;
   12852            0 :             default:   escaped[new_i++] = '?'; break;
   12853              :             }
   12854              :         }
   12855            8 :       else if (escaped)
   12856            4 :         escaped[new_i++] = c;
   12857              :     }
   12858              : 
   12859       135922 :   if (escaped)
   12860              :     {
   12861           19 :       escaped[new_i] = 0;
   12862           19 :       m_str = escaped;
   12863           19 :       m_owned = true;
   12864              :     }
   12865              : }
   12866              : 
   12867              : /* Warn about a use of an identifier which was marked deprecated.  Returns
   12868              :    whether a warning was given.  */
   12869              : 
   12870              : bool
   12871      1414935 : warn_deprecated_use (tree node, tree attr)
   12872              : {
   12873      1414935 :   escaped_string msg;
   12874              : 
   12875      1414935 :   if (node == 0 || !warn_deprecated_decl)
   12876              :     return false;
   12877              : 
   12878      1407696 :   if (!attr)
   12879              :     {
   12880      1292672 :       if (DECL_P (node))
   12881      1292502 :         attr = DECL_ATTRIBUTES (node);
   12882          170 :       else if (TYPE_P (node))
   12883              :         {
   12884          170 :           tree decl = TYPE_STUB_DECL (node);
   12885          170 :           if (decl)
   12886          146 :             attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
   12887           24 :           else if ((decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (node)))
   12888              :                    != NULL_TREE)
   12889              :             {
   12890            6 :               node = TREE_TYPE (decl);
   12891            6 :               attr = TYPE_ATTRIBUTES (node);
   12892              :             }
   12893              :         }
   12894              :     }
   12895              : 
   12896      1292672 :   if (attr)
   12897       135456 :     attr = lookup_attribute ("deprecated", attr);
   12898              : 
   12899       135456 :   if (attr)
   12900       135445 :     msg.escape (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   12901              : 
   12902      1407696 :   bool w = false;
   12903      1407696 :   if (DECL_P (node))
   12904              :     {
   12905      1407516 :       auto_diagnostic_group d;
   12906      1407516 :       if (msg)
   12907       135354 :         w = warning (OPT_Wdeprecated_declarations,
   12908              :                      "%qD is deprecated: %s", node, (const char *) msg);
   12909              :       else
   12910      1272162 :         w = warning (OPT_Wdeprecated_declarations,
   12911              :                      "%qD is deprecated", node);
   12912      1407516 :       if (w)
   12913          800 :         inform (DECL_SOURCE_LOCATION (node), "declared here");
   12914      1407516 :     }
   12915          180 :   else if (TYPE_P (node))
   12916              :     {
   12917          180 :       tree what = NULL_TREE;
   12918          180 :       tree decl = TYPE_STUB_DECL (node);
   12919              : 
   12920          180 :       if (TYPE_NAME (node))
   12921              :         {
   12922          175 :           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
   12923           10 :             what = TYPE_NAME (node);
   12924          165 :           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
   12925          165 :                    && DECL_NAME (TYPE_NAME (node)))
   12926          165 :             what = DECL_NAME (TYPE_NAME (node));
   12927              :         }
   12928              : 
   12929          180 :       auto_diagnostic_group d;
   12930          180 :       if (what)
   12931              :         {
   12932          175 :           if (msg)
   12933           89 :             w = warning (OPT_Wdeprecated_declarations,
   12934              :                          "%qE is deprecated: %s", what, (const char *) msg);
   12935              :           else
   12936           86 :             w = warning (OPT_Wdeprecated_declarations,
   12937              :                          "%qE is deprecated", what);
   12938              :         }
   12939              :       else
   12940              :         {
   12941            5 :           if (msg)
   12942            2 :             w = warning (OPT_Wdeprecated_declarations,
   12943              :                          "type is deprecated: %s", (const char *) msg);
   12944              :           else
   12945            3 :             w = warning (OPT_Wdeprecated_declarations,
   12946              :                          "type is deprecated");
   12947              :         }
   12948              : 
   12949          180 :       if (w && decl)
   12950          111 :         inform (DECL_SOURCE_LOCATION (decl), "declared here");
   12951          180 :     }
   12952              : 
   12953              :   return w;
   12954      1414935 : }
   12955              : 
   12956              : /* Error out with an identifier which was marked 'unavailable'. */
   12957              : void
   12958          376 : error_unavailable_use (tree node, tree attr)
   12959              : {
   12960          376 :   escaped_string msg;
   12961              : 
   12962          376 :   if (node == 0)
   12963            0 :     return;
   12964              : 
   12965          376 :   if (!attr)
   12966              :     {
   12967          366 :       if (DECL_P (node))
   12968          306 :         attr = DECL_ATTRIBUTES (node);
   12969           60 :       else if (TYPE_P (node))
   12970              :         {
   12971           60 :           tree decl = TYPE_STUB_DECL (node);
   12972           60 :           if (decl)
   12973           51 :             attr = lookup_attribute ("unavailable",
   12974           51 :                                      TYPE_ATTRIBUTES (TREE_TYPE (decl)));
   12975              :         }
   12976              :     }
   12977              : 
   12978          366 :   if (attr)
   12979          164 :     attr = lookup_attribute ("unavailable", attr);
   12980              : 
   12981          164 :   if (attr)
   12982          164 :     msg.escape (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
   12983              : 
   12984          376 :   if (DECL_P (node))
   12985              :     {
   12986          306 :       auto_diagnostic_group d;
   12987          306 :       if (msg)
   12988          129 :         error ("%qD is unavailable: %s", node, (const char *) msg);
   12989              :       else
   12990          177 :         error ("%qD is unavailable", node);
   12991          306 :       inform (DECL_SOURCE_LOCATION (node), "declared here");
   12992          306 :     }
   12993           70 :   else if (TYPE_P (node))
   12994              :     {
   12995           70 :       tree what = NULL_TREE;
   12996           70 :       tree decl = TYPE_STUB_DECL (node);
   12997              : 
   12998           70 :       if (TYPE_NAME (node))
   12999              :         {
   13000           66 :           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
   13001            4 :             what = TYPE_NAME (node);
   13002           62 :           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
   13003           62 :                    && DECL_NAME (TYPE_NAME (node)))
   13004           62 :             what = DECL_NAME (TYPE_NAME (node));
   13005              :         }
   13006              : 
   13007           70 :       auto_diagnostic_group d;
   13008           70 :       if (what)
   13009              :         {
   13010           66 :           if (msg)
   13011           33 :             error ("%qE is unavailable: %s", what, (const char *) msg);
   13012              :           else
   13013           33 :             error ("%qE is unavailable", what);
   13014              :         }
   13015              :       else
   13016              :         {
   13017            4 :           if (msg)
   13018            2 :             error ("type is unavailable: %s", (const char *) msg);
   13019              :           else
   13020            2 :             error ("type is unavailable");
   13021              :         }
   13022              : 
   13023           70 :       if (decl)
   13024           52 :         inform (DECL_SOURCE_LOCATION (decl), "declared here");
   13025           70 :     }
   13026          376 : }
   13027              : 
   13028              : /* Return true if REF has a COMPONENT_REF with a bit-field field declaration
   13029              :    somewhere in it.  */
   13030              : 
   13031              : bool
   13032      5862527 : contains_bitfld_component_ref_p (const_tree ref)
   13033              : {
   13034     11995873 :   while (handled_component_p (ref))
   13035              :     {
   13036      6150512 :       if (TREE_CODE (ref) == COMPONENT_REF
   13037      6150512 :           && DECL_BIT_FIELD (TREE_OPERAND (ref, 1)))
   13038              :         return true;
   13039      6133346 :       ref = TREE_OPERAND (ref, 0);
   13040              :     }
   13041              : 
   13042              :   return false;
   13043              : }
   13044              : 
   13045              : /* Try to determine whether a TRY_CATCH expression can fall through.
   13046              :    This is a subroutine of block_may_fallthru.  */
   13047              : 
   13048              : static bool
   13049            1 : try_catch_may_fallthru (const_tree stmt)
   13050              : {
   13051            1 :   tree_stmt_iterator i;
   13052              : 
   13053              :   /* If the TRY block can fall through, the whole TRY_CATCH can
   13054              :      fall through.  */
   13055            1 :   if (block_may_fallthru (TREE_OPERAND (stmt, 0)))
   13056              :     return true;
   13057              : 
   13058            1 :   switch (TREE_CODE (TREE_OPERAND (stmt, 1)))
   13059              :     {
   13060            0 :     case CATCH_EXPR:
   13061              :       /* See below.  */
   13062            0 :       return block_may_fallthru (CATCH_BODY (TREE_OPERAND (stmt, 1)));
   13063              : 
   13064            0 :     case EH_FILTER_EXPR:
   13065              :       /* See below.  */
   13066            0 :       return block_may_fallthru (EH_FILTER_FAILURE (TREE_OPERAND (stmt, 1)));
   13067              : 
   13068            0 :     case STATEMENT_LIST:
   13069            0 :       break;
   13070              : 
   13071              :     default:
   13072              :       /* See below.  */
   13073              :       return false;
   13074              :     }
   13075              : 
   13076            0 :   i = tsi_start (TREE_OPERAND (stmt, 1));
   13077            0 :   switch (TREE_CODE (tsi_stmt (i)))
   13078              :     {
   13079              :     case CATCH_EXPR:
   13080              :       /* We expect to see a sequence of CATCH_EXPR trees, each with a
   13081              :          catch expression and a body.  The whole TRY_CATCH may fall
   13082              :          through iff any of the catch bodies falls through.  */
   13083            0 :       for (; !tsi_end_p (i); tsi_next (&i))
   13084              :         {
   13085            0 :           if (block_may_fallthru (CATCH_BODY (tsi_stmt (i))))
   13086              :             return true;
   13087              :         }
   13088              :       return false;
   13089              : 
   13090            0 :     case EH_FILTER_EXPR:
   13091              :       /* The exception filter expression only matters if there is an
   13092              :          exception.  If the exception does not match EH_FILTER_TYPES,
   13093              :          we will execute EH_FILTER_FAILURE, and we will fall through
   13094              :          if that falls through.  If the exception does match
   13095              :          EH_FILTER_TYPES, the stack unwinder will continue up the
   13096              :          stack, so we will not fall through.  We don't know whether we
   13097              :          will throw an exception which matches EH_FILTER_TYPES or not,
   13098              :          so we just ignore EH_FILTER_TYPES and assume that we might
   13099              :          throw an exception which doesn't match.  */
   13100            0 :       return block_may_fallthru (EH_FILTER_FAILURE (tsi_stmt (i)));
   13101              : 
   13102              :     default:
   13103              :       /* This case represents statements to be executed when an
   13104              :          exception occurs.  Those statements are implicitly followed
   13105              :          by a RESX statement to resume execution after the exception.
   13106              :          So in this case the TRY_CATCH never falls through.  */
   13107              :       return false;
   13108              :     }
   13109              : }
   13110              : 
   13111              : /* Try to determine if we can fall out of the bottom of BLOCK.  This guess
   13112              :    need not be 100% accurate; simply be conservative and return true if we
   13113              :    don't know.  This is used only to avoid stupidly generating extra code.
   13114              :    If we're wrong, we'll just delete the extra code later.  */
   13115              : 
   13116              : bool
   13117      9382814 : block_may_fallthru (const_tree block)
   13118              : {
   13119              :   /* This CONST_CAST is okay because expr_last returns its argument
   13120              :      unmodified and we assign it to a const_tree.  */
   13121     10840782 :   const_tree stmt = expr_last (const_cast<tree> (block));
   13122              : 
   13123     10840782 :   switch (stmt ? TREE_CODE (stmt) : ERROR_MARK)
   13124              :     {
   13125              :     case GOTO_EXPR:
   13126              :     case RETURN_EXPR:
   13127              :       /* Easy cases.  If the last statement of the block implies
   13128              :          control transfer, then we can't fall through.  */
   13129              :       return false;
   13130              : 
   13131           12 :     case SWITCH_EXPR:
   13132              :       /* If there is a default: label or case labels cover all possible
   13133              :          SWITCH_COND values, then the SWITCH_EXPR will transfer control
   13134              :          to some case label in all cases and all we care is whether the
   13135              :          SWITCH_BODY falls through.  */
   13136           12 :       if (SWITCH_ALL_CASES_P (stmt))
   13137           11 :         return block_may_fallthru (SWITCH_BODY (stmt));
   13138              :       return true;
   13139              : 
   13140        22071 :     case COND_EXPR:
   13141        22071 :       if (block_may_fallthru (COND_EXPR_THEN (stmt)))
   13142              :         return true;
   13143         2823 :       return block_may_fallthru (COND_EXPR_ELSE (stmt));
   13144              : 
   13145       906608 :     case BIND_EXPR:
   13146       906608 :       return block_may_fallthru (BIND_EXPR_BODY (stmt));
   13147              : 
   13148            1 :     case TRY_CATCH_EXPR:
   13149            1 :       return try_catch_may_fallthru (stmt);
   13150              : 
   13151         2094 :     case TRY_FINALLY_EXPR:
   13152              :       /* The finally clause is always executed after the try clause,
   13153              :          so if it does not fall through, then the try-finally will not
   13154              :          fall through.  Otherwise, if the try clause does not fall
   13155              :          through, then when the finally clause falls through it will
   13156              :          resume execution wherever the try clause was going.  So the
   13157              :          whole try-finally will only fall through if both the try
   13158              :          clause and the finally clause fall through.  */
   13159         2094 :       return (block_may_fallthru (TREE_OPERAND (stmt, 0))
   13160         2094 :               && block_may_fallthru (TREE_OPERAND (stmt, 1)));
   13161              : 
   13162            0 :     case EH_ELSE_EXPR:
   13163            0 :       return block_may_fallthru (TREE_OPERAND (stmt, 0));
   13164              : 
   13165        92008 :     case MODIFY_EXPR:
   13166        92008 :       if (TREE_CODE (TREE_OPERAND (stmt, 1)) == CALL_EXPR)
   13167         1589 :         stmt = TREE_OPERAND (stmt, 1);
   13168              :       else
   13169              :         return true;
   13170              :       /* FALLTHRU */
   13171              : 
   13172       446220 :     case CALL_EXPR:
   13173              :       /* Functions that do not return do not fall through.  */
   13174       446220 :       return (call_expr_flags (stmt) & ECF_NORETURN) == 0;
   13175              : 
   13176       548516 :     case CLEANUP_POINT_EXPR:
   13177       548516 :       return block_may_fallthru (TREE_OPERAND (stmt, 0));
   13178              : 
   13179           10 :     case TARGET_EXPR:
   13180           10 :       return block_may_fallthru (TREE_OPERAND (stmt, 1));
   13181              : 
   13182              :     case ERROR_MARK:
   13183              :       return true;
   13184              : 
   13185      6548587 :     default:
   13186      6548587 :       return lang_hooks.block_may_fallthru (stmt);
   13187              :     }
   13188              : }
   13189              : 
   13190              : /* True if we are using EH to handle cleanups.  */
   13191              : static bool using_eh_for_cleanups_flag = false;
   13192              : 
   13193              : /* This routine is called from front ends to indicate eh should be used for
   13194              :    cleanups.  */
   13195              : void
   13196       126176 : using_eh_for_cleanups (void)
   13197              : {
   13198       126176 :   using_eh_for_cleanups_flag = true;
   13199       126176 : }
   13200              : 
   13201              : /* Query whether EH is used for cleanups.  */
   13202              : bool
   13203      1739717 : using_eh_for_cleanups_p (void)
   13204              : {
   13205      1739717 :   return using_eh_for_cleanups_flag;
   13206              : }
   13207              : 
   13208              : /* Wrapper for tree_code_name to ensure that tree code is valid */
   13209              : const char *
   13210  14680904798 : get_tree_code_name (enum tree_code code)
   13211              : {
   13212  14680904798 :   const char *invalid = "<invalid tree code>";
   13213              : 
   13214              :   /* The tree_code enum promotes to signed, but we could be getting
   13215              :      invalid values, so force an unsigned comparison.  */
   13216  14680904798 :   if (unsigned (code) >= MAX_TREE_CODES)
   13217              :     {
   13218            0 :       if ((unsigned)code == 0xa5a5)
   13219              :         return "ggc_freed";
   13220            0 :       return invalid;
   13221              :     }
   13222              : 
   13223  14680904798 :   return tree_code_name[code];
   13224              : }
   13225              : 
   13226              : /* Drops the TREE_OVERFLOW flag from T.  */
   13227              : 
   13228              : tree
   13229        36628 : drop_tree_overflow (tree t)
   13230              : {
   13231        36628 :   gcc_checking_assert (TREE_OVERFLOW (t));
   13232              : 
   13233              :   /* For tree codes with a sharing machinery re-build the result.  */
   13234        36628 :   if (poly_int_tree_p (t))
   13235        36616 :     return wide_int_to_tree (TREE_TYPE (t), wi::to_poly_wide (t));
   13236              : 
   13237              :   /* For VECTOR_CST, remove the overflow bits from the encoded elements
   13238              :      and canonicalize the result.  */
   13239           12 :   if (TREE_CODE (t) == VECTOR_CST)
   13240              :     {
   13241            0 :       tree_vector_builder builder;
   13242            0 :       builder.new_unary_operation (TREE_TYPE (t), t, true);
   13243            0 :       unsigned int count = builder.encoded_nelts ();
   13244            0 :       for (unsigned int i = 0; i < count; ++i)
   13245              :         {
   13246            0 :           tree elt = VECTOR_CST_ELT (t, i);
   13247            0 :           if (TREE_OVERFLOW (elt))
   13248            0 :             elt = drop_tree_overflow (elt);
   13249            0 :           builder.quick_push (elt);
   13250              :         }
   13251            0 :       return builder.build ();
   13252            0 :     }
   13253              : 
   13254              :   /* Otherwise, as all tcc_constants are possibly shared, copy the node
   13255              :      and drop the flag.  */
   13256           12 :   t = copy_node (t);
   13257           12 :   TREE_OVERFLOW (t) = 0;
   13258              : 
   13259              :   /* For constants that contain nested constants, drop the flag
   13260              :      from those as well.  */
   13261           12 :   if (TREE_CODE (t) == COMPLEX_CST)
   13262              :     {
   13263           12 :       if (TREE_OVERFLOW (TREE_REALPART (t)))
   13264           12 :         TREE_REALPART (t) = drop_tree_overflow (TREE_REALPART (t));
   13265           12 :       if (TREE_OVERFLOW (TREE_IMAGPART (t)))
   13266            0 :         TREE_IMAGPART (t) = drop_tree_overflow (TREE_IMAGPART (t));
   13267              :     }
   13268              : 
   13269              :   return t;
   13270              : }
   13271              : 
   13272              : /* Given a memory reference expression T, return its base address.
   13273              :    The base address of a memory reference expression is the main
   13274              :    object being referenced.  For instance, the base address for
   13275              :    'array[i].fld[j]' is 'array'.  You can think of this as stripping
   13276              :    away the offset part from a memory address.
   13277              : 
   13278              :    This function calls handled_component_p to strip away all the inner
   13279              :    parts of the memory reference until it reaches the base object.  */
   13280              : 
   13281              : tree
   13282   3278524833 : get_base_address (tree t)
   13283              : {
   13284   3278524833 :   if (TREE_CODE (t) == WITH_SIZE_EXPR)
   13285          899 :     t = TREE_OPERAND (t, 0);
   13286   4085260133 :   while (handled_component_p (t))
   13287    806735300 :     t = TREE_OPERAND (t, 0);
   13288              : 
   13289   3278524833 :   if ((TREE_CODE (t) == MEM_REF
   13290   3278524833 :        || TREE_CODE (t) == TARGET_MEM_REF)
   13291   3278524833 :       && TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
   13292    149310360 :     t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
   13293              : 
   13294   3278524833 :   return t;
   13295              : }
   13296              : 
   13297              : /* Return a tree of sizetype representing the size, in bytes, of the element
   13298              :    of EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13299              : 
   13300              : tree
   13301    796135007 : array_ref_element_size (tree exp)
   13302              : {
   13303    796135007 :   tree aligned_size = TREE_OPERAND (exp, 3);
   13304    796135007 :   tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13305    796135007 :   location_t loc = EXPR_LOCATION (exp);
   13306              : 
   13307              :   /* If a size was specified in the ARRAY_REF, it's the size measured
   13308              :      in alignment units of the element type.  So multiply by that value.  */
   13309    796135007 :   if (aligned_size)
   13310              :     {
   13311              :       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
   13312              :          sizetype from another type of the same width and signedness.  */
   13313       335375 :       if (TREE_TYPE (aligned_size) != sizetype)
   13314         3725 :         aligned_size = fold_convert_loc (loc, sizetype, aligned_size);
   13315       335375 :       return size_binop_loc (loc, MULT_EXPR, aligned_size,
   13316       335375 :                              size_int (TYPE_ALIGN_UNIT (elmt_type)));
   13317              :     }
   13318              : 
   13319              :   /* Otherwise, take the size from that of the element type.  Substitute
   13320              :      any PLACEHOLDER_EXPR that we have.  */
   13321              :   else
   13322    795799632 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (elmt_type), exp);
   13323              : }
   13324              : 
   13325              : /* Return a tree representing the lower bound of the array mentioned in
   13326              :    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13327              : 
   13328              : tree
   13329   1099051020 : array_ref_low_bound (tree exp)
   13330              : {
   13331   1099051020 :   tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13332              : 
   13333              :   /* If a lower bound is specified in EXP, use it.  */
   13334   1099051020 :   if (TREE_OPERAND (exp, 2))
   13335      1975403 :     return TREE_OPERAND (exp, 2);
   13336              : 
   13337              :   /* Otherwise, if there is a domain type and it has a lower bound, use it,
   13338              :      substituting for a PLACEHOLDER_EXPR as needed.  */
   13339   1097075617 :   if (domain_type && TYPE_MIN_VALUE (domain_type))
   13340   1096150655 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MIN_VALUE (domain_type), exp);
   13341              : 
   13342              :   /* Otherwise, return a zero of the appropriate type.  */
   13343       924962 :   tree idxtype = TREE_TYPE (TREE_OPERAND (exp, 1));
   13344       924962 :   return (idxtype == error_mark_node
   13345       924962 :           ? integer_zero_node : build_int_cst (idxtype, 0));
   13346              : }
   13347              : 
   13348              : /* Return a tree representing the upper bound of the array mentioned in
   13349              :    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
   13350              : 
   13351              : tree
   13352    252830226 : array_ref_up_bound (tree exp)
   13353              : {
   13354    252830226 :   tree domain_type = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
   13355              : 
   13356              :   /* If there is a domain type and it has an upper bound, use it, substituting
   13357              :      for a PLACEHOLDER_EXPR as needed.  */
   13358    252830226 :   if (domain_type && TYPE_MAX_VALUE (domain_type))
   13359    252037014 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MAX_VALUE (domain_type), exp);
   13360              : 
   13361              :   /* Otherwise fail.  */
   13362              :   return NULL_TREE;
   13363              : }
   13364              : 
   13365              : /* Returns true if REF is an array reference, a component reference,
   13366              :    or a memory reference to an array whose actual size might be larger
   13367              :    than its upper bound implies, there are multiple cases:
   13368              :    A. a ref to a flexible array member at the end of a structure;
   13369              :    B. a ref to an array with a different type against the original decl;
   13370              :       for example:
   13371              : 
   13372              :    short a[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
   13373              :    (*((char(*)[16])&a[0]))[i+8]
   13374              : 
   13375              :    C. a ref to an array that was passed as a parameter;
   13376              :       for example:
   13377              : 
   13378              :    int test (uint8_t *p, uint32_t t[1][1], int n) {
   13379              :    for (int i = 0; i < 4; i++, p++)
   13380              :      t[i][0] = ...;
   13381              : 
   13382              :    If non-null, set IS_TRAILING_ARRAY to true if the ref is the above case A.
   13383              : */
   13384              : 
   13385              : bool
   13386     75504039 : array_ref_flexible_size_p (tree ref, bool *is_trailing_array /* = NULL */)
   13387              : {
   13388              :   /* The TYPE for this array reference.  */
   13389     75504039 :   tree atype = NULL_TREE;
   13390              :   /* The FIELD_DECL for the array field in the containing structure.  */
   13391     75504039 :   tree afield_decl = NULL_TREE;
   13392              :   /* Whether this array is the trailing array of a structure.  */
   13393     75504039 :   bool is_trailing_array_tmp = false;
   13394     75504039 :   if (!is_trailing_array)
   13395     75421123 :     is_trailing_array = &is_trailing_array_tmp;
   13396              : 
   13397     75504039 :   if (TREE_CODE (ref) == ARRAY_REF
   13398     75504039 :       || TREE_CODE (ref) == ARRAY_RANGE_REF)
   13399              :     {
   13400     75260737 :       atype = TREE_TYPE (TREE_OPERAND (ref, 0));
   13401     75260737 :       ref = TREE_OPERAND (ref, 0);
   13402              :     }
   13403       243302 :   else if (TREE_CODE (ref) == COMPONENT_REF
   13404       243302 :            && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 1))) == ARRAY_TYPE)
   13405              :     {
   13406       171955 :       atype = TREE_TYPE (TREE_OPERAND (ref, 1));
   13407       171955 :       afield_decl = TREE_OPERAND (ref, 1);
   13408              :     }
   13409        71347 :   else if (TREE_CODE (ref) == MEM_REF)
   13410              :     {
   13411         7629 :       tree arg = TREE_OPERAND (ref, 0);
   13412         7629 :       if (TREE_CODE (arg) == ADDR_EXPR)
   13413         7629 :         arg = TREE_OPERAND (arg, 0);
   13414         7629 :       tree argtype = TREE_TYPE (arg);
   13415         7629 :       if (TREE_CODE (argtype) == RECORD_TYPE)
   13416              :         {
   13417          157 :           if (tree fld = last_field (argtype))
   13418              :             {
   13419          157 :               atype = TREE_TYPE (fld);
   13420          157 :               afield_decl = fld;
   13421          157 :               if (TREE_CODE (atype) != ARRAY_TYPE)
   13422              :                 return false;
   13423          157 :               if (VAR_P (arg) && DECL_SIZE (fld))
   13424              :                 return false;
   13425              :             }
   13426              :           else
   13427              :             return false;
   13428              :         }
   13429              :       else
   13430              :         return false;
   13431              :     }
   13432              :   else
   13433              :     return false;
   13434              : 
   13435     75432805 :   if (TREE_CODE (ref) == STRING_CST)
   13436              :     return false;
   13437              : 
   13438              :   tree ref_to_array = ref;
   13439     92797575 :   while (handled_component_p (ref))
   13440              :     {
   13441              :       /* If the reference chain contains a component reference to a
   13442              :          non-union type and there follows another field the reference
   13443              :          is not at the end of a structure.  */
   13444     20540723 :       if (TREE_CODE (ref) == COMPONENT_REF)
   13445              :         {
   13446     19403861 :           if (TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == RECORD_TYPE)
   13447              :             {
   13448     18135310 :               tree nextf = DECL_CHAIN (TREE_OPERAND (ref, 1));
   13449     45151990 :               while (nextf && TREE_CODE (nextf) != FIELD_DECL)
   13450     27016680 :                 nextf = DECL_CHAIN (nextf);
   13451              :               if (nextf)
   13452              :                 return false;
   13453              :             }
   13454              :         }
   13455              :       /* If we have a multi-dimensional array we do not consider
   13456              :          a non-innermost dimension as flex array if the whole
   13457              :          multi-dimensional array is at struct end.
   13458              :          Same for an array of aggregates with a trailing array
   13459              :          member.  */
   13460      1136862 :       else if (TREE_CODE (ref) == ARRAY_REF)
   13461              :         return false;
   13462       197987 :       else if (TREE_CODE (ref) == ARRAY_RANGE_REF)
   13463              :         ;
   13464              :       /* If we view an underlying object as sth else then what we
   13465              :          gathered up to now is what we have to rely on.  */
   13466       197971 :       else if (TREE_CODE (ref) == VIEW_CONVERT_EXPR)
   13467              :         break;
   13468              :       else
   13469            0 :         gcc_unreachable ();
   13470              : 
   13471     17366006 :       ref = TREE_OPERAND (ref, 0);
   13472              :     }
   13473              : 
   13474     72454823 :   gcc_assert (!afield_decl
   13475              :               || (afield_decl && TREE_CODE (afield_decl) == FIELD_DECL));
   13476              : 
   13477              :   /* The array now is at struct end.  Treat flexible array member as
   13478              :      always subject to extend, even into just padding constrained by
   13479              :      an underlying decl.  */
   13480     72454823 :   if (! TYPE_SIZE (atype)
   13481     69881284 :       || ! TYPE_DOMAIN (atype)
   13482    142336107 :       || ! TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
   13483              :     {
   13484      2578947 :       *is_trailing_array = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13485      2578947 :       return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13486              :     }
   13487              : 
   13488              :   /* If the reference is based on a declared entity, the size of the array
   13489              :      is constrained by its given domain.  (Do not trust commons PR/69368).  */
   13490     69875876 :   ref = get_base_address (ref);
   13491     69875876 :   if (ref
   13492     69875876 :       && DECL_P (ref)
   13493     59502298 :       && !(flag_unconstrained_commons
   13494           14 :            && VAR_P (ref) && DECL_COMMON (ref))
   13495     59502284 :       && DECL_SIZE_UNIT (ref)
   13496    129377783 :       && TREE_CODE (DECL_SIZE_UNIT (ref)) == INTEGER_CST)
   13497              :     {
   13498              :       /* If the object itself is the array it is not at struct end.  */
   13499     59501879 :       if (DECL_P (ref_to_array))
   13500              :         return false;
   13501              : 
   13502              :       /* Check whether the array domain covers all of the available
   13503              :          padding.  */
   13504     15765213 :       poly_int64 offset;
   13505     15765213 :       if (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (atype))) != INTEGER_CST
   13506     15763853 :           || TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (atype))) != INTEGER_CST
   13507     31506645 :           || TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (atype))) != INTEGER_CST)
   13508              :         {
   13509        23781 :           *is_trailing_array
   13510        23781 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13511        23781 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13512              :         }
   13513     15741432 :       if (! get_addr_base_and_unit_offset (ref_to_array, &offset))
   13514              :         {
   13515         2838 :           *is_trailing_array
   13516         2838 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13517         2838 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13518              :         }
   13519              : 
   13520              :       /* If at least one extra element fits it is a flexarray.  */
   13521     15738594 :       if (known_le ((wi::to_offset (TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
   13522              :                      - wi::to_offset (TYPE_MIN_VALUE (TYPE_DOMAIN (atype)))
   13523              :                      + 2)
   13524              :                     * wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (atype))),
   13525              :                     wi::to_offset (DECL_SIZE_UNIT (ref)) - offset))
   13526              :         {
   13527       395105 :           *is_trailing_array
   13528       395105 :             = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13529       395105 :           return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13530              :         }
   13531              : 
   13532              :       return false;
   13533              :     }
   13534              : 
   13535     10373997 :   *is_trailing_array = afield_decl && TREE_CODE (afield_decl) == FIELD_DECL;
   13536     10373997 :   return afield_decl ? !DECL_NOT_FLEXARRAY (afield_decl) : true;
   13537              : }
   13538              : 
   13539              : 
   13540              : /* Return a tree representing the offset, in bytes, of the field referenced
   13541              :    by EXP.  This does not include any offset in DECL_FIELD_BIT_OFFSET.  */
   13542              : 
   13543              : tree
   13544   2786517299 : component_ref_field_offset (tree exp)
   13545              : {
   13546   2786517299 :   tree aligned_offset = TREE_OPERAND (exp, 2);
   13547   2786517299 :   tree field = TREE_OPERAND (exp, 1);
   13548   2786517299 :   location_t loc = EXPR_LOCATION (exp);
   13549              : 
   13550              :   /* If an offset was specified in the COMPONENT_REF, it's the offset measured
   13551              :      in units of DECL_OFFSET_ALIGN / BITS_PER_UNIT.  So multiply by that
   13552              :      value.  */
   13553   2786517299 :   if (aligned_offset)
   13554              :     {
   13555              :       /* ??? tree_ssa_useless_type_conversion will eliminate casts to
   13556              :          sizetype from another type of the same width and signedness.  */
   13557        11893 :       if (TREE_TYPE (aligned_offset) != sizetype)
   13558          133 :         aligned_offset = fold_convert_loc (loc, sizetype, aligned_offset);
   13559        11893 :       return size_binop_loc (loc, MULT_EXPR, aligned_offset,
   13560        11893 :                              size_int (DECL_OFFSET_ALIGN (field)
   13561              :                                        / BITS_PER_UNIT));
   13562              :     }
   13563              : 
   13564              :   /* Otherwise, take the offset from that of the field.  Substitute
   13565              :      any PLACEHOLDER_EXPR that we have.  */
   13566              :   else
   13567   2786505406 :     return SUBSTITUTE_PLACEHOLDER_IN_EXPR (DECL_FIELD_OFFSET (field), exp);
   13568              : }
   13569              : 
   13570              : /* Given the initializer INIT, return the initializer for the field
   13571              :    DECL if it exists, otherwise null.  Used to obtain the initializer
   13572              :    for a flexible array member and determine its size.  */
   13573              : 
   13574              : static tree
   13575         1267 : get_initializer_for (tree init, tree decl)
   13576              : {
   13577         1267 :   STRIP_NOPS (init);
   13578              : 
   13579         1267 :   tree fld, fld_init;
   13580         1267 :   unsigned HOST_WIDE_INT i;
   13581         3571 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), i, fld, fld_init)
   13582              :     {
   13583         1926 :       if (decl == fld)
   13584              :         return fld_init;
   13585              : 
   13586         1037 :       if (TREE_CODE (fld) == CONSTRUCTOR)
   13587              :         {
   13588            0 :           fld_init = get_initializer_for (fld_init, decl);
   13589            0 :           if (fld_init)
   13590              :             return fld_init;
   13591              :         }
   13592              :     }
   13593              : 
   13594              :   return NULL_TREE;
   13595              : }
   13596              : 
   13597              : /* Determines the special array member type for the array reference REF.  */
   13598              : special_array_member
   13599       256435 : component_ref_sam_type (tree ref)
   13600              : {
   13601       256435 :   special_array_member sam_type = special_array_member::none;
   13602              : 
   13603       256435 :   tree member = TREE_OPERAND (ref, 1);
   13604       256435 :   tree memsize = DECL_SIZE_UNIT (member);
   13605       256435 :   if (memsize)
   13606              :     {
   13607       124341 :       tree memtype = TREE_TYPE (member);
   13608       124341 :       if (TREE_CODE (memtype) != ARRAY_TYPE)
   13609       124219 :         return sam_type;
   13610              : 
   13611        82916 :       bool trailing = false;
   13612        82916 :       (void) array_ref_flexible_size_p (ref, &trailing);
   13613        82916 :       bool zero_elts = integer_zerop (memsize);
   13614        82916 :       if (zero_elts && integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (memtype))))
   13615              :         {
   13616              :           /* If array element has zero size, verify if it is a flexible
   13617              :              array member or zero length array.  Clear zero_elts if
   13618              :              it has one or more members or is a VLA member.  */
   13619            6 :           if (tree dom = TYPE_DOMAIN (memtype))
   13620            6 :             if (tree min = TYPE_MIN_VALUE (dom))
   13621            6 :               if (tree max = TYPE_MAX_VALUE (dom))
   13622            4 :                 if (TREE_CODE (min) != INTEGER_CST
   13623            4 :                     || TREE_CODE (max) != INTEGER_CST
   13624           12 :                     || !((integer_zerop (min) && integer_all_onesp (max))
   13625            4 :                          || tree_int_cst_lt (max, min)))
   13626              :                   zero_elts = false;
   13627              :         }
   13628        82916 :       if (!trailing && !zero_elts)
   13629              :         /* MEMBER is an interior array with more than one element.  */
   13630              :         return special_array_member::int_n;
   13631              : 
   13632        23301 :       if (zero_elts)
   13633              :         {
   13634         1074 :           if (trailing)
   13635              :             return special_array_member::trail_0;
   13636              :           else
   13637          463 :             return special_array_member::int_0;
   13638              :         }
   13639              : 
   13640        22690 :       if (!zero_elts)
   13641        22690 :         if (tree dom = TYPE_DOMAIN (memtype))
   13642        22690 :           if (tree min = TYPE_MIN_VALUE (dom))
   13643        22690 :             if (tree max = TYPE_MAX_VALUE (dom))
   13644        22690 :               if (TREE_CODE (min) == INTEGER_CST
   13645        22690 :                   && TREE_CODE (max) == INTEGER_CST)
   13646              :                 {
   13647        22568 :                   offset_int minidx = wi::to_offset (min);
   13648        22568 :                   offset_int maxidx = wi::to_offset (max);
   13649        22568 :                   offset_int neltsm1 = maxidx - minidx;
   13650        22568 :                   if (neltsm1 > 0)
   13651              :                     /* MEMBER is a trailing array with more than
   13652              :                        one elements.  */
   13653        22568 :                     return special_array_member::trail_n;
   13654              : 
   13655         2182 :                   if (neltsm1 == 0)
   13656              :                     return special_array_member::trail_1;
   13657              :                 }
   13658              :     }
   13659              : 
   13660              :   return sam_type;
   13661              : }
   13662              : 
   13663              : /* Determines the size of the member referenced by the COMPONENT_REF
   13664              :    REF, using its initializer expression if necessary in order to
   13665              :    determine the size of an initialized flexible array member.
   13666              :    If non-null, set *SAM to the type of special array member.
   13667              :    Returns the size as sizetype (which might be zero for an object
   13668              :    with an uninitialized flexible array member) or null if the size
   13669              :    cannot be determined.  */
   13670              : 
   13671              : tree
   13672       157082 : component_ref_size (tree ref, special_array_member *sam /* = NULL */)
   13673              : {
   13674       157082 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
   13675              : 
   13676       157082 :   special_array_member sambuf;
   13677       157082 :   if (!sam)
   13678       100788 :     sam = &sambuf;
   13679       157082 :   *sam = component_ref_sam_type (ref);
   13680              : 
   13681              :   /* The object/argument referenced by the COMPONENT_REF and its type.  */
   13682       157082 :   tree arg = TREE_OPERAND (ref, 0);
   13683       157082 :   tree argtype = TREE_TYPE (arg);
   13684              :   /* The referenced member.  */
   13685       157082 :   tree member = TREE_OPERAND (ref, 1);
   13686              : 
   13687       157082 :   tree memsize = DECL_SIZE_UNIT (member);
   13688       157082 :   if (memsize)
   13689              :     {
   13690        89495 :       tree memtype = TREE_TYPE (member);
   13691        89495 :       if (TREE_CODE (memtype) != ARRAY_TYPE)
   13692              :         /* DECL_SIZE may be less than TYPE_SIZE in C++ when referring
   13693              :            to the type of a class with a virtual base which doesn't
   13694              :            reflect the size of the virtual's members (see pr97595).
   13695              :            If that's the case fail for now and implement something
   13696              :            more robust in the future.  */
   13697        41425 :         return (tree_int_cst_equal (memsize, TYPE_SIZE_UNIT (memtype))
   13698        41425 :                 ? memsize : NULL_TREE);
   13699              : 
   13700              :       /* 2-or-more elements arrays are treated as normal arrays by default.  */
   13701        48070 :       if (*sam == special_array_member::int_n
   13702        48070 :           || *sam == special_array_member::trail_n)
   13703              :         return memsize;
   13704              : 
   13705         1849 :       tree afield_decl = TREE_OPERAND (ref, 1);
   13706         1849 :       gcc_assert (TREE_CODE (afield_decl) == FIELD_DECL);
   13707              :       /* If the trailing array is a not a flexible array member, treat it as
   13708              :          a normal array.  */
   13709         1849 :       if (DECL_NOT_FLEXARRAY (afield_decl)
   13710         1849 :           && *sam != special_array_member::int_0)
   13711              :         return memsize;
   13712              : 
   13713         1840 :       if (*sam == special_array_member::int_0)
   13714          270 :         memsize = NULL_TREE;
   13715              : 
   13716              :       /* For a reference to a flexible array member of a union
   13717              :          use the size of the union instead of the size of the member.  */
   13718         1840 :       if (TREE_CODE (argtype) == UNION_TYPE)
   13719          277 :         memsize = TYPE_SIZE_UNIT (argtype);
   13720              :     }
   13721              : 
   13722              :   /* MEMBER is either a bona fide flexible array member, or a zero-elements
   13723              :      array member, or an array of length one treated as such.  */
   13724              : 
   13725              :   /* If the reference is to a declared object and the member a true
   13726              :      flexible array, try to determine its size from its initializer.  */
   13727        69427 :   poly_int64 baseoff = 0;
   13728        69427 :   tree base = get_addr_base_and_unit_offset (ref, &baseoff);
   13729        69427 :   if (!base || !VAR_P (base))
   13730              :     {
   13731        66079 :       if (*sam != special_array_member::int_0)
   13732              :         return NULL_TREE;
   13733              : 
   13734           52 :       if (TREE_CODE (arg) != COMPONENT_REF)
   13735              :         return NULL_TREE;
   13736              : 
   13737              :       base = arg;
   13738            6 :       while (TREE_CODE (base) == COMPONENT_REF)
   13739            3 :         base = TREE_OPERAND (base, 0);
   13740            3 :       baseoff = tree_to_poly_int64 (byte_position (TREE_OPERAND (ref, 1)));
   13741              :     }
   13742              : 
   13743              :   /* BASE is the declared object of which MEMBER is either a member
   13744              :      or that is cast to ARGTYPE (e.g., a char buffer used to store
   13745              :      an ARGTYPE object).  */
   13746         3351 :   tree basetype = TREE_TYPE (base);
   13747              : 
   13748              :   /* Determine the base type of the referenced object.  If it's
   13749              :      the same as ARGTYPE and MEMBER has a known size, return it.  */
   13750         3351 :   tree bt = basetype;
   13751         3351 :   if (*sam != special_array_member::int_0)
   13752         3352 :     while (TREE_CODE (bt) == ARRAY_TYPE)
   13753          222 :       bt = TREE_TYPE (bt);
   13754         3351 :   bool typematch = useless_type_conversion_p (argtype, bt);
   13755         3351 :   if (memsize && typematch)
   13756              :     return memsize;
   13757              : 
   13758         3261 :   memsize = NULL_TREE;
   13759              : 
   13760         3261 :   if (typematch)
   13761              :     /* MEMBER is a true flexible array member.  Compute its size from
   13762              :        the initializer of the BASE object if it has one.  */
   13763         2697 :     if (tree init = DECL_P (base) ? DECL_INITIAL (base) : NULL_TREE)
   13764         1300 :       if (init != error_mark_node)
   13765              :         {
   13766         1267 :           init = get_initializer_for (init, member);
   13767         1267 :           if (init)
   13768              :             {
   13769          889 :               memsize = TYPE_SIZE_UNIT (TREE_TYPE (init));
   13770          889 :               if (tree refsize = TYPE_SIZE_UNIT (argtype))
   13771              :                 {
   13772              :                   /* Use the larger of the initializer size and the tail
   13773              :                      padding in the enclosing struct.  */
   13774          889 :                   poly_int64 rsz = tree_to_poly_int64 (refsize);
   13775          889 :                   rsz -= baseoff;
   13776          889 :                   if (known_lt (tree_to_poly_int64 (memsize), rsz))
   13777           56 :                     memsize = wide_int_to_tree (TREE_TYPE (memsize), rsz);
   13778              :                 }
   13779              : 
   13780          889 :               baseoff = 0;
   13781              :             }
   13782              :         }
   13783              : 
   13784          889 :   if (!memsize)
   13785              :     {
   13786         2372 :       if (typematch)
   13787              :         {
   13788         1808 :           if (DECL_P (base)
   13789         1808 :               && DECL_EXTERNAL (base)
   13790          454 :               && bt == basetype
   13791         2256 :               && *sam != special_array_member::int_0)
   13792              :             /* The size of a flexible array member of an extern struct
   13793              :                with no initializer cannot be determined (it's defined
   13794              :                in another translation unit and can have an initializer
   13795              :                with an arbitrary number of elements).  */
   13796              :             return NULL_TREE;
   13797              : 
   13798              :           /* Use the size of the base struct or, for interior zero-length
   13799              :              arrays, the size of the enclosing type.  */
   13800         1383 :           memsize = TYPE_SIZE_UNIT (bt);
   13801              :         }
   13802          564 :       else if (DECL_P (base))
   13803              :         /* Use the size of the BASE object (possibly an array of some
   13804              :            other type such as char used to store the struct).  */
   13805          561 :         memsize = DECL_SIZE_UNIT (base);
   13806              :       else
   13807              :         return NULL_TREE;
   13808              :     }
   13809              : 
   13810              :   /* If the flexible array member has a known size use the greater
   13811              :      of it and the tail padding in the enclosing struct.
   13812              :      Otherwise, when the size of the flexible array member is unknown
   13813              :      and the referenced object is not a struct, use the size of its
   13814              :      type when known.  This detects sizes of array buffers when cast
   13815              :      to struct types with flexible array members.  */
   13816         1944 :   if (memsize)
   13817              :     {
   13818         2808 :       if (!tree_fits_poly_int64_p (memsize))
   13819              :         return NULL_TREE;
   13820         2808 :       poly_int64 memsz64 = memsize ? tree_to_poly_int64 (memsize) : 0;
   13821         2808 :       if (known_lt (baseoff, memsz64))
   13822              :         {
   13823         1341 :           memsz64 -= baseoff;
   13824         1341 :           return wide_int_to_tree (TREE_TYPE (memsize), memsz64);
   13825              :         }
   13826         1467 :       return size_zero_node;
   13827              :     }
   13828              : 
   13829              :   /* Return "don't know" for an external non-array object since its
   13830              :      flexible array member can be initialized to have any number of
   13831              :      elements.  Otherwise, return zero because the flexible array
   13832              :      member has no elements.  */
   13833           25 :   return (DECL_P (base)
   13834           25 :           && DECL_EXTERNAL (base)
   13835           25 :           && (!typematch
   13836            0 :               || TREE_CODE (basetype) != ARRAY_TYPE)
   13837           25 :           ? NULL_TREE : size_zero_node);
   13838              : }
   13839              : 
   13840              : /* Return true if the given node CALL is a call to a .ACCESS_WITH_SIZE
   13841              :    function.  */
   13842              : bool
   13843    168506002 : is_access_with_size_p (const_tree call)
   13844              : {
   13845    168506002 :   if (TREE_CODE (call) != CALL_EXPR)
   13846              :     return false;
   13847     43715478 :   if (CALL_EXPR_IFN (call) == IFN_ACCESS_WITH_SIZE)
   13848         1073 :     return true;
   13849              :   return false;
   13850              : }
   13851              : 
   13852              : /* Get the corresponding reference from the call to a .ACCESS_WITH_SIZE.
   13853              :  * i.e the first argument of this call.  Return NULL_TREE otherwise.  */
   13854              : tree
   13855            3 : get_ref_from_access_with_size (tree call)
   13856              : {
   13857            3 :   if (is_access_with_size_p (call))
   13858            3 :     return  CALL_EXPR_ARG (call, 0);
   13859              :   return NULL_TREE;
   13860              : }
   13861              : 
   13862              : /* Return the machine mode of T.  For vectors, returns the mode of the
   13863              :    inner type.  The main use case is to feed the result to HONOR_NANS,
   13864              :    avoiding the BLKmode that a direct TYPE_MODE (T) might return.  */
   13865              : 
   13866              : machine_mode
   13867   5968086609 : element_mode (const_tree t)
   13868              : {
   13869   5968086609 :   if (!TYPE_P (t))
   13870    208585463 :     t = TREE_TYPE (t);
   13871   5968086609 :   if (VECTOR_TYPE_P (t) || TREE_CODE (t) == COMPLEX_TYPE)
   13872   1564704893 :     t = TREE_TYPE (t);
   13873   5968086609 :   return TYPE_MODE (t);
   13874              : }
   13875              : 
   13876              : /* Vector types need to re-check the target flags each time we report
   13877              :    the machine mode.  We need to do this because attribute target can
   13878              :    change the result of vector_mode_supported_p and have_regs_of_mode
   13879              :    on a per-function basis.  Thus the TYPE_MODE of a VECTOR_TYPE can
   13880              :    change on a per-function basis.  */
   13881              : /* ??? Possibly a better solution is to run through all the types
   13882              :    referenced by a function and re-compute the TYPE_MODE once, rather
   13883              :    than make the TYPE_MODE macro call a function.  */
   13884              : 
   13885              : machine_mode
   13886   1375245098 : vector_type_mode (const_tree t)
   13887              : {
   13888   1375245098 :   machine_mode mode;
   13889              : 
   13890   1375245098 :   gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
   13891              : 
   13892   1375245098 :   mode = t->type_common.mode;
   13893    318968725 :   if (VECTOR_MODE_P (mode)
   13894   1655995627 :       && (!targetm.vector_mode_supported_p (mode)
   13895   1313184395 :           || !have_regs_of_mode[mode]))
   13896              :     {
   13897     24807102 :       scalar_int_mode innermode;
   13898              : 
   13899              :       /* For integers, try mapping it to a same-sized scalar mode.  */
   13900     24807102 :       if (is_int_mode (TREE_TYPE (t)->type_common.mode, &innermode))
   13901              :         {
   13902     36752574 :           poly_int64 size = (TYPE_VECTOR_SUBPARTS (t)
   13903     18376287 :                              * GET_MODE_BITSIZE (innermode));
   13904     18376287 :           scalar_int_mode mode;
   13905     33228301 :           if (int_mode_for_size (size, 0).exists (&mode)
   13906     15014170 :               && have_regs_of_mode[mode])
   13907       162156 :             return mode;
   13908              :         }
   13909              : 
   13910              :       return BLKmode;
   13911              :     }
   13912              : 
   13913              :   return mode;
   13914              : }
   13915              : 
   13916              : /* Return the size in bits of each element of vector type TYPE.  */
   13917              : 
   13918              : unsigned int
   13919       254457 : vector_element_bits (const_tree type)
   13920              : {
   13921       254457 :   gcc_checking_assert (VECTOR_TYPE_P (type));
   13922       254457 :   if (VECTOR_BOOLEAN_TYPE_P (type))
   13923         1316 :     return TYPE_PRECISION (TREE_TYPE (type));
   13924       253141 :   return tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type)));
   13925              : }
   13926              : 
   13927              : /* Calculate the size in bits of each element of vector type TYPE
   13928              :    and return the result as a tree of type bitsizetype.  */
   13929              : 
   13930              : tree
   13931       127907 : vector_element_bits_tree (const_tree type)
   13932              : {
   13933       127907 :   gcc_checking_assert (VECTOR_TYPE_P (type));
   13934       127907 :   if (VECTOR_BOOLEAN_TYPE_P (type))
   13935          681 :     return bitsize_int (vector_element_bits (type));
   13936       127226 :   return TYPE_SIZE (TREE_TYPE (type));
   13937              : }
   13938              : 
   13939              : /* Verify that basic properties of T match TV and thus T can be a variant of
   13940              :    TV.  TV should be the more specified variant (i.e. the main variant).  */
   13941              : 
   13942              : static bool
   13943    199471200 : verify_type_variant (const_tree t, tree tv)
   13944              : {
   13945              :   /* Type variant can differ by:
   13946              : 
   13947              :      - TYPE_QUALS: TYPE_READONLY, TYPE_VOLATILE, TYPE_ATOMIC, TYPE_RESTRICT,
   13948              :                    ENCODE_QUAL_ADDR_SPACE.
   13949              :      - main variant may be TYPE_COMPLETE_P and variant types !TYPE_COMPLETE_P
   13950              :        in this case some values may not be set in the variant types
   13951              :        (see TYPE_COMPLETE_P checks).
   13952              :      - it is possible to have TYPE_ARTIFICIAL variant of non-artificial type
   13953              :      - by TYPE_NAME and attributes (i.e. when variant originate by typedef)
   13954              :      - TYPE_CANONICAL (TYPE_ALIAS_SET is the same among variants)
   13955              :      - by the alignment: TYPE_ALIGN and TYPE_USER_ALIGN
   13956              :      - during LTO by TYPE_CONTEXT if type is TYPE_FILE_SCOPE_P
   13957              :        this is necessary to make it possible to merge types form different TUs
   13958              :      - arrays, pointers and references may have TREE_TYPE that is a variant
   13959              :        of TREE_TYPE of their main variants.
   13960              :      - aggregates may have new TYPE_FIELDS list that list variants of
   13961              :        the main variant TYPE_FIELDS.
   13962              :      - vector types may differ by TYPE_VECTOR_OPAQUE
   13963              :    */
   13964              : 
   13965              :   /* Convenience macro for matching individual fields.  */
   13966              : #define verify_variant_match(flag)                                          \
   13967              :   do {                                                                      \
   13968              :     if (flag (tv) != flag (t))                                              \
   13969              :       {                                                                     \
   13970              :         error ("type variant differs by %s", #flag);                      \
   13971              :         debug_tree (tv);                                                    \
   13972              :         return false;                                                       \
   13973              :       }                                                                     \
   13974              :   } while (false)
   13975              : 
   13976              :   /* tree_base checks.  */
   13977              : 
   13978    199471200 :   verify_variant_match (TREE_CODE);
   13979              :   /* FIXME: Ada builds non-artificial variants of artificial types.  */
   13980              : #if 0
   13981              :   if (TYPE_ARTIFICIAL (tv))
   13982              :     verify_variant_match (TYPE_ARTIFICIAL);
   13983              : #endif
   13984    199471200 :   if (POINTER_TYPE_P (tv))
   13985     13022237 :     verify_variant_match (TYPE_REF_CAN_ALIAS_ALL);
   13986              :   /* FIXME: TYPE_SIZES_GIMPLIFIED may differs for Ada build.  */
   13987    199471200 :   verify_variant_match (TYPE_UNSIGNED);
   13988    199471200 :   verify_variant_match (TYPE_PACKED);
   13989    199471200 :   if (TREE_CODE (t) == REFERENCE_TYPE)
   13990      3181974 :     verify_variant_match (TYPE_REF_IS_RVALUE);
   13991    199471200 :   if (AGGREGATE_TYPE_P (t))
   13992     82123295 :     verify_variant_match (TYPE_REVERSE_STORAGE_ORDER);
   13993              :   else
   13994    117347905 :     verify_variant_match (TYPE_SATURATING);
   13995              :   /* FIXME: This check trigger during libstdc++ build.  */
   13996              : #if 0
   13997              :   if (RECORD_OR_UNION_TYPE_P (t) && COMPLETE_TYPE_P (t))
   13998              :     verify_variant_match (TYPE_FINAL_P);
   13999              : #endif
   14000              : 
   14001              :   /* tree_type_common checks.  */
   14002              : 
   14003    199471200 :   if (COMPLETE_TYPE_P (t))
   14004              :     {
   14005    187540695 :       verify_variant_match (TYPE_MODE);
   14006    187540695 :       if (TREE_CODE (TYPE_SIZE (t)) != PLACEHOLDER_EXPR
   14007    187540695 :           && TREE_CODE (TYPE_SIZE (tv)) != PLACEHOLDER_EXPR)
   14008    187540695 :         verify_variant_match (TYPE_SIZE);
   14009    187540695 :       if (TREE_CODE (TYPE_SIZE_UNIT (t)) != PLACEHOLDER_EXPR
   14010    187540695 :           && TREE_CODE (TYPE_SIZE_UNIT (tv)) != PLACEHOLDER_EXPR
   14011    375081390 :           && TYPE_SIZE_UNIT (t) != TYPE_SIZE_UNIT (tv))
   14012              :         {
   14013            0 :           gcc_assert (!operand_equal_p (TYPE_SIZE_UNIT (t),
   14014              :                                         TYPE_SIZE_UNIT (tv), 0));
   14015            0 :           error ("type variant has different %<TYPE_SIZE_UNIT%>");
   14016            0 :           debug_tree (tv);
   14017            0 :           error ("type variant%'s %<TYPE_SIZE_UNIT%>");
   14018            0 :           debug_tree (TYPE_SIZE_UNIT (tv));
   14019            0 :           error ("type%'s %<TYPE_SIZE_UNIT%>");
   14020            0 :           debug_tree (TYPE_SIZE_UNIT (t));
   14021            0 :           return false;
   14022              :         }
   14023    187540695 :       verify_variant_match (TYPE_NEEDS_CONSTRUCTING);
   14024              :     }
   14025    199471200 :   verify_variant_match (TYPE_PRECISION_RAW);
   14026    199471200 :   if (RECORD_OR_UNION_TYPE_P (t))
   14027     81499465 :     verify_variant_match (TYPE_TRANSPARENT_AGGR);
   14028    117971735 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14029       623830 :     verify_variant_match (TYPE_NONALIASED_COMPONENT);
   14030              :   /* During LTO we merge variant lists from different translation units
   14031              :      that may differ BY TYPE_CONTEXT that in turn may point
   14032              :      to TRANSLATION_UNIT_DECL.
   14033              :      Ada also builds variants of types with different TYPE_CONTEXT.   */
   14034              : #if 0
   14035              :   if (!in_lto_p || !TYPE_FILE_SCOPE_P (t))
   14036              :     verify_variant_match (TYPE_CONTEXT);
   14037              : #endif
   14038    199471200 :   if (TREE_CODE (t) == ARRAY_TYPE || TREE_CODE (t) == INTEGER_TYPE)
   14039     63749865 :     verify_variant_match (TYPE_STRING_FLAG);
   14040    199471200 :   if (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE)
   14041     81499465 :     verify_variant_match (TYPE_CXX_ODR_P);
   14042    199471200 :   if (TYPE_ALIAS_SET_KNOWN_P (t))
   14043              :     {
   14044            0 :       error ("type variant with %<TYPE_ALIAS_SET_KNOWN_P%>");
   14045            0 :       debug_tree (tv);
   14046            0 :       return false;
   14047              :     }
   14048              : 
   14049              :   /* tree_type_non_common checks.  */
   14050              : 
   14051              :   /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
   14052              :      and dangle the pointer from time to time.  */
   14053     81499465 :   if (RECORD_OR_UNION_TYPE_P (t) && TYPE_VFIELD (t) != TYPE_VFIELD (tv)
   14054    199471200 :       && (in_lto_p || !TYPE_VFIELD (tv)
   14055            0 :           || TREE_CODE (TYPE_VFIELD (tv)) != TREE_LIST))
   14056              :     {
   14057            0 :       error ("type variant has different %<TYPE_VFIELD%>");
   14058            0 :       debug_tree (tv);
   14059            0 :       return false;
   14060              :     }
   14061      3556825 :   if ((TREE_CODE (t) == ENUMERAL_TYPE && COMPLETE_TYPE_P (t))
   14062    195914432 :        || TREE_CODE (t) == INTEGER_TYPE
   14063    132788397 :        || TREE_CODE (t) == BOOLEAN_TYPE
   14064     97874912 :        || TREE_CODE (t) == BITINT_TYPE
   14065     97874652 :        || SCALAR_FLOAT_TYPE_P (t)
   14066    295369397 :        || FIXED_POINT_TYPE_P (t))
   14067              :     {
   14068    103573003 :       verify_variant_match (TYPE_MAX_VALUE);
   14069    103573003 :       verify_variant_match (TYPE_MIN_VALUE);
   14070              :     }
   14071    199471200 :   if (TREE_CODE (t) == METHOD_TYPE)
   14072        11908 :     verify_variant_match (TYPE_METHOD_BASETYPE);
   14073    199471200 :   if (TREE_CODE (t) == OFFSET_TYPE)
   14074         1607 :     verify_variant_match (TYPE_OFFSET_BASETYPE);
   14075    199471200 :   if (TREE_CODE (t) == ARRAY_TYPE)
   14076       623830 :     verify_variant_match (TYPE_ARRAY_MAX_SIZE);
   14077              :   /* FIXME: Be lax and allow TYPE_BINFO to be missing in variant types
   14078              :      or even type's main variant.  This is needed to make bootstrap pass
   14079              :      and the bug seems new in GCC 5.
   14080              :      C++ FE should be updated to make this consistent and we should check
   14081              :      that TYPE_BINFO is always NULL for !COMPLETE_TYPE_P and otherwise there
   14082              :      is a match with main variant.
   14083              : 
   14084              :      Also disable the check for Java for now because of parser hack that builds
   14085              :      first an dummy BINFO and then sometimes replace it by real BINFO in some
   14086              :      of the copies.  */
   14087     81499465 :   if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t) && TYPE_BINFO (tv)
   14088     69397154 :       && TYPE_BINFO (t) != TYPE_BINFO (tv)
   14089              :       /* FIXME: Java sometimes keep dump TYPE_BINFOs on variant types.
   14090              :          Since there is no cheap way to tell C++/Java type w/o LTO, do checking
   14091              :          at LTO time only.  */
   14092    199471200 :       && (in_lto_p && odr_type_p (t)))
   14093              :     {
   14094            0 :       error ("type variant has different %<TYPE_BINFO%>");
   14095            0 :       debug_tree (tv);
   14096            0 :       error ("type variant%'s %<TYPE_BINFO%>");
   14097            0 :       debug_tree (TYPE_BINFO (tv));
   14098            0 :       error ("type%'s %<TYPE_BINFO%>");
   14099            0 :       debug_tree (TYPE_BINFO (t));
   14100            0 :       return false;
   14101              :     }
   14102              : 
   14103              :   /* Check various uses of TYPE_VALUES_RAW.  */
   14104    199471200 :   if (TREE_CODE (t) == ENUMERAL_TYPE
   14105    199471200 :       && TYPE_VALUES (t))
   14106      3386523 :     verify_variant_match (TYPE_VALUES);
   14107    196084677 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14108       623830 :     verify_variant_match (TYPE_DOMAIN);
   14109              :   /* Permit incomplete variants of complete type.  While FEs may complete
   14110              :      all variants, this does not happen for C++ templates in all cases.  */
   14111    195460847 :   else if (RECORD_OR_UNION_TYPE_P (t)
   14112     81499465 :            && COMPLETE_TYPE_P (t)
   14113    265237796 :            && TYPE_FIELDS (t) != TYPE_FIELDS (tv))
   14114              :     {
   14115         4151 :       tree f1, f2;
   14116              : 
   14117              :       /* Fortran builds qualified variants as new records with items of
   14118              :          qualified type. Verify that they looks same.  */
   14119         4151 :       for (f1 = TYPE_FIELDS (t), f2 = TYPE_FIELDS (tv);
   14120        13257 :            f1 && f2;
   14121         9106 :            f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
   14122         9106 :         if (TREE_CODE (f1) != FIELD_DECL || TREE_CODE (f2) != FIELD_DECL
   14123         9106 :             || (TYPE_MAIN_VARIANT (TREE_TYPE (f1))
   14124         9106 :                  != TYPE_MAIN_VARIANT (TREE_TYPE (f2))
   14125              :                 /* FIXME: gfc_nonrestricted_type builds all types as variants
   14126              :                    with exception of pointer types.  It deeply copies the type
   14127              :                    which means that we may end up with a variant type
   14128              :                    referring non-variant pointer.  We may change it to
   14129              :                    produce types as variants, too, like
   14130              :                    objc_get_protocol_qualified_type does.  */
   14131           69 :                 && !POINTER_TYPE_P (TREE_TYPE (f1)))
   14132         9106 :             || DECL_FIELD_OFFSET (f1) != DECL_FIELD_OFFSET (f2)
   14133        18212 :             || DECL_FIELD_BIT_OFFSET (f1) != DECL_FIELD_BIT_OFFSET (f2))
   14134              :           break;
   14135         4151 :       if (f1 || f2)
   14136              :         {
   14137            0 :           error ("type variant has different %<TYPE_FIELDS%>");
   14138            0 :           debug_tree (tv);
   14139            0 :           error ("first mismatch is field");
   14140            0 :           debug_tree (f1);
   14141            0 :           error ("and field");
   14142            0 :           debug_tree (f2);
   14143            0 :           return false;
   14144              :         }
   14145              :     }
   14146    195456696 :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14147       152377 :     verify_variant_match (TYPE_ARG_TYPES);
   14148              :   /* For C++ the qualified variant of array type is really an array type
   14149              :      of qualified TREE_TYPE.
   14150              :      objc builds variants of pointer where pointer to type is a variant, too
   14151              :      in objc_get_protocol_qualified_type.  */
   14152    199471200 :   if (TREE_TYPE (t) != TREE_TYPE (tv)
   14153    199471200 :       && ((TREE_CODE (t) != ARRAY_TYPE
   14154            0 :            && !POINTER_TYPE_P (t))
   14155       538280 :           || TYPE_MAIN_VARIANT (TREE_TYPE (t))
   14156       538280 :              != TYPE_MAIN_VARIANT (TREE_TYPE (tv))))
   14157              :     {
   14158            0 :       error ("type variant has different %<TREE_TYPE%>");
   14159            0 :       debug_tree (tv);
   14160            0 :       error ("type variant%'s %<TREE_TYPE%>");
   14161            0 :       debug_tree (TREE_TYPE (tv));
   14162            0 :       error ("type%'s %<TREE_TYPE%>");
   14163            0 :       debug_tree (TREE_TYPE (t));
   14164            0 :       return false;
   14165              :     }
   14166    199471200 :   if (type_with_alias_set_p (t)
   14167    199471200 :       && !gimple_canonical_types_compatible_p (t, tv, false))
   14168              :     {
   14169            0 :       error ("type is not compatible with its variant");
   14170            0 :       debug_tree (tv);
   14171            0 :       error ("type variant%'s %<TREE_TYPE%>");
   14172            0 :       debug_tree (TREE_TYPE (tv));
   14173            0 :       error ("type%'s %<TREE_TYPE%>");
   14174            0 :       debug_tree (TREE_TYPE (t));
   14175            0 :       return false;
   14176              :     }
   14177              :   return true;
   14178              : #undef verify_variant_match
   14179              : }
   14180              : 
   14181              : 
   14182              : /* The TYPE_CANONICAL merging machinery.  It should closely resemble
   14183              :    the middle-end types_compatible_p function.  It needs to avoid
   14184              :    claiming types are different for types that should be treated
   14185              :    the same with respect to TBAA.  Canonical types are also used
   14186              :    for IL consistency checks via the useless_type_conversion_p
   14187              :    predicate which does not handle all type kinds itself but falls
   14188              :    back to pointer-comparison of TYPE_CANONICAL for aggregates
   14189              :    for example.  */
   14190              : 
   14191              : /* Return true if TYPE_UNSIGNED of TYPE should be ignored for canonical
   14192              :    type calculation because we need to allow inter-operability between signed
   14193              :    and unsigned variants.  */
   14194              : 
   14195              : bool
   14196      1687576 : type_with_interoperable_signedness (const_tree type)
   14197              : {
   14198              :   /* Fortran standard require C_SIGNED_CHAR to be interoperable with both
   14199              :      signed char and unsigned char.  Similarly fortran FE builds
   14200              :      C_SIZE_T as signed type, while C defines it unsigned.  */
   14201              : 
   14202      1687576 :   return tree_code_for_canonical_type_merging (TREE_CODE (type))
   14203              :            == INTEGER_TYPE
   14204      1687372 :          && (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node)
   14205       456160 :              || TYPE_PRECISION (type) == TYPE_PRECISION (size_type_node));
   14206              : }
   14207              : 
   14208              : /* Return true iff T1 and T2 are structurally identical for what
   14209              :    TBAA is concerned.
   14210              :    This function is used both by lto.cc canonical type merging and by the
   14211              :    verifier.  If TRUST_TYPE_CANONICAL we do not look into structure of types
   14212              :    that have TYPE_CANONICAL defined and assume them equivalent.  This is useful
   14213              :    only for LTO because only in these cases TYPE_CANONICAL equivalence
   14214              :    correspond to one defined by gimple_canonical_types_compatible_p.  */
   14215              : 
   14216              : bool
   14217    408095904 : gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
   14218              :                                      bool trust_type_canonical)
   14219              : {
   14220              :   /* Type variants should be same as the main variant.  When not doing sanity
   14221              :      checking to verify this fact, go to main variants and save some work.  */
   14222    408493947 :   if (trust_type_canonical)
   14223              :     {
   14224       903269 :       t1 = TYPE_MAIN_VARIANT (t1);
   14225       903269 :       t2 = TYPE_MAIN_VARIANT (t2);
   14226              :     }
   14227              : 
   14228              :   /* Check first for the obvious case of pointer identity.  */
   14229    408493947 :   if (t1 == t2)
   14230              :     return true;
   14231              : 
   14232              :   /* Check that we have two types to compare.  */
   14233    345544937 :   if (t1 == NULL_TREE || t2 == NULL_TREE)
   14234              :     return false;
   14235              : 
   14236              :   /* We consider complete types always compatible with incomplete type.
   14237              :      This does not make sense for canonical type calculation and thus we
   14238              :      need to ensure that we are never called on it.
   14239              : 
   14240              :      FIXME: For more correctness the function probably should have three modes
   14241              :         1) mode assuming that types are complete matching their structure
   14242              :         2) mode allowing incomplete types but producing equivalence classes
   14243              :            and thus ignoring all info from complete types
   14244              :         3) mode allowing incomplete types to match complete but checking
   14245              :            compatibility between complete types.
   14246              : 
   14247              :      1 and 2 can be used for canonical type calculation. 3 is the real
   14248              :      definition of type compatibility that can be used i.e. for warnings during
   14249              :      declaration merging.  */
   14250              : 
   14251    345544937 :   gcc_assert (!trust_type_canonical
   14252              :               || (type_with_alias_set_p (t1) && type_with_alias_set_p (t2)));
   14253              : 
   14254              :   /* If the types have been previously registered and found equal
   14255              :      they still are.  */
   14256              : 
   14257    690793109 :   if (TYPE_CANONICAL (t1) && TYPE_CANONICAL (t2)
   14258    689840095 :       && trust_type_canonical)
   14259              :     {
   14260              :       /* Do not use TYPE_CANONICAL of pointer types.  For LTO streamed types
   14261              :          they are always NULL, but they are set to non-NULL for types
   14262              :          constructed by build_pointer_type and variants.  In this case the
   14263              :          TYPE_CANONICAL is more fine grained than the equivalnce we test (where
   14264              :          all pointers are considered equal.  Be sure to not return false
   14265              :          negatives.  */
   14266       166632 :       gcc_checking_assert (canonical_type_used_p (t1)
   14267              :                            && canonical_type_used_p (t2));
   14268        83316 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
   14269              :     }
   14270              : 
   14271              :   /* For types where we do ODR based TBAA the canonical type is always
   14272              :      set correctly, so we know that types are different if their
   14273              :      canonical types does not match.  */
   14274    345461621 :   if (trust_type_canonical
   14275    346278525 :       && (odr_type_p (t1) && odr_based_tbaa_p (t1))
   14276       816904 :           != (odr_type_p (t2) && odr_based_tbaa_p (t2)))
   14277              :     return false;
   14278              : 
   14279              :   /* Can't be the same type if the types don't have the same code.  */
   14280    345461621 :   enum tree_code code = tree_code_for_canonical_type_merging (TREE_CODE (t1));
   14281    686660430 :   if (code != tree_code_for_canonical_type_merging (TREE_CODE (t2)))
   14282              :     return false;
   14283              : 
   14284              :   /* Qualifiers do not matter for canonical type comparison purposes.  */
   14285              : 
   14286              :   /* Void types and nullptr types are always the same.  */
   14287    345461586 :   if (VOID_TYPE_P (t1)
   14288    345412977 :       || TREE_CODE (t1) == NULLPTR_TYPE)
   14289              :     return true;
   14290              : 
   14291              :   /* Can't be compatible types if they have different mode.  Because of
   14292              :      flexible array members, we allow mismatching modes for structures or
   14293              :      unions.  */
   14294    344750256 :   if (!RECORD_OR_UNION_TYPE_P (t1)
   14295    344750256 :       && TREE_CODE (t1) != ARRAY_TYPE
   14296    344750256 :       && TYPE_MODE (t1) != TYPE_MODE (t2))
   14297              :     return false;
   14298              : 
   14299              :   /* Non-aggregate types can be handled cheaply.  */
   14300    344750256 :   if (INTEGRAL_TYPE_P (t1)
   14301    344750256 :       || SCALAR_FLOAT_TYPE_P (t1)
   14302    182644501 :       || FIXED_POINT_TYPE_P (t1)
   14303    182270083 :       || VECTOR_TYPE_P (t1)
   14304    182219886 :       || TREE_CODE (t1) == COMPLEX_TYPE
   14305    181872040 :       || TREE_CODE (t1) == OFFSET_TYPE
   14306    181868804 :       || POINTER_TYPE_P (t1))
   14307              :     {
   14308              :       /* Can't be the same type if they have different precision.  */
   14309    206278993 :       if (TYPE_PRECISION_RAW (t1) != TYPE_PRECISION_RAW (t2))
   14310              :         return false;
   14311              : 
   14312              :       /* In some cases the signed and unsigned types are required to be
   14313              :          inter-operable.  */
   14314    206278993 :       if (TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2)
   14315    206278993 :           && !type_with_interoperable_signedness (t1))
   14316              :         return false;
   14317              : 
   14318              :       /* Fortran's C_SIGNED_CHAR is !TYPE_STRING_FLAG but needs to be
   14319              :          interoperable with "signed char".  Unless all frontends are revisited
   14320              :          to agree on these types, we must ignore the flag completely.  */
   14321              : 
   14322              :       /* Fortran standard define C_PTR type that is compatible with every
   14323              :          C pointer.  For this reason we need to glob all pointers into one.
   14324              :          Still pointers in different address spaces are not compatible.  */
   14325    206278993 :       if (POINTER_TYPE_P (t1))
   14326              :         {
   14327     43397541 :           if (TYPE_ADDR_SPACE (TREE_TYPE (t1))
   14328     43397541 :               != TYPE_ADDR_SPACE (TREE_TYPE (t2)))
   14329              :             return false;
   14330              :         }
   14331              : 
   14332              :       /* Tail-recurse to components.  */
   14333    206278993 :       if (VECTOR_TYPE_P (t1)
   14334    206278993 :           || TREE_CODE (t1) == COMPLEX_TYPE)
   14335      1194129 :         return gimple_canonical_types_compatible_p (TREE_TYPE (t1),
   14336       398043 :                                                     TREE_TYPE (t2),
   14337       398043 :                                                     trust_type_canonical);
   14338              : 
   14339              :       return true;
   14340              :     }
   14341              : 
   14342              :   /* Do type-specific comparisons.  */
   14343    138471263 :   switch (TREE_CODE (t1))
   14344              :     {
   14345      1123746 :     case ARRAY_TYPE:
   14346              :       /* Array types are the same if the element types are the same and
   14347              :          minimum and maximum index are the same.  */
   14348      1123746 :       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
   14349              :                                                 trust_type_canonical)
   14350      1123707 :           || TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2)
   14351      1123707 :           || TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2)
   14352      2247453 :           || TYPE_NONALIASED_COMPONENT (t1) != TYPE_NONALIASED_COMPONENT (t2))
   14353              :         return false;
   14354              :       else
   14355              :         {
   14356      1123707 :           tree i1 = TYPE_DOMAIN (t1);
   14357      1123707 :           tree i2 = TYPE_DOMAIN (t2);
   14358              : 
   14359              :           /* For an incomplete external array, the type domain can be
   14360              :              NULL_TREE.  Check this condition also.  */
   14361      1123707 :           if (i1 == NULL_TREE && i2 == NULL_TREE)
   14362              :             return true;
   14363      1023894 :           else if (i1 == NULL_TREE || i2 == NULL_TREE)
   14364              :             return false;
   14365              :           else
   14366              :             {
   14367      1023894 :               tree min1 = TYPE_MIN_VALUE (i1);
   14368      1023894 :               tree min2 = TYPE_MIN_VALUE (i2);
   14369      1023894 :               tree max1 = TYPE_MAX_VALUE (i1);
   14370      1023894 :               tree max2 = TYPE_MAX_VALUE (i2);
   14371              : 
   14372              :               /* The minimum/maximum values have to be the same.  */
   14373      1023894 :               if ((min1 == min2
   14374            0 :                    || (min1 && min2
   14375            0 :                        && ((TREE_CODE (min1) == PLACEHOLDER_EXPR
   14376            0 :                             && TREE_CODE (min2) == PLACEHOLDER_EXPR)
   14377            0 :                            || operand_equal_p (min1, min2, 0))))
   14378      1023894 :                   && (max1 == max2
   14379            0 :                       || (max1 && max2
   14380            0 :                           && ((TREE_CODE (max1) == PLACEHOLDER_EXPR
   14381            0 :                                && TREE_CODE (max2) == PLACEHOLDER_EXPR)
   14382            0 :                               || operand_equal_p (max1, max2, 0)))))
   14383      1023894 :                 return true;
   14384              :               else
   14385              :                 return false;
   14386              :             }
   14387              :         }
   14388              : 
   14389         7206 :     case METHOD_TYPE:
   14390         7206 :     case FUNCTION_TYPE:
   14391              :       /* Function types are the same if the return type and arguments types
   14392              :          are the same.  */
   14393         7206 :       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
   14394              :                                                 trust_type_canonical))
   14395              :         return false;
   14396              : 
   14397         7206 :       if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2)
   14398         7206 :           && (TYPE_NO_NAMED_ARGS_STDARG_P (t1)
   14399          322 :               == TYPE_NO_NAMED_ARGS_STDARG_P (t2)))
   14400              :         return true;
   14401              :       else
   14402              :         {
   14403         6884 :           tree parms1, parms2;
   14404              : 
   14405         6884 :           for (parms1 = TYPE_ARG_TYPES (t1), parms2 = TYPE_ARG_TYPES (t2);
   14406        30613 :                parms1 && parms2;
   14407        23729 :                parms1 = TREE_CHAIN (parms1), parms2 = TREE_CHAIN (parms2))
   14408              :             {
   14409        47458 :               if (!gimple_canonical_types_compatible_p
   14410        23729 :                      (TREE_VALUE (parms1), TREE_VALUE (parms2),
   14411              :                       trust_type_canonical))
   14412              :                 return false;
   14413              :             }
   14414              : 
   14415         6884 :           if (parms1 || parms2)
   14416              :             return false;
   14417              : 
   14418         6884 :           return true;
   14419              :         }
   14420              : 
   14421    136994691 :     case RECORD_TYPE:
   14422    136994691 :     case UNION_TYPE:
   14423    136994691 :     case QUAL_UNION_TYPE:
   14424    136994691 :       {
   14425    136994691 :         tree f1, f2;
   14426              : 
   14427              :         /* Don't try to compare variants of an incomplete type, before
   14428              :            TYPE_FIELDS has been copied around.  */
   14429    136994691 :         if (!COMPLETE_TYPE_P (t1) && !COMPLETE_TYPE_P (t2))
   14430              :           return true;
   14431              : 
   14432              : 
   14433    125970948 :         if (TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2))
   14434              :           return false;
   14435              : 
   14436              :         /* For aggregate types, all the fields must be the same.  */
   14437    125970948 :         for (f1 = TYPE_FIELDS (t1), f2 = TYPE_FIELDS (t2);
   14438    188630469 :              f1 || f2;
   14439     62659521 :              f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
   14440              :           {
   14441              :             /* Skip non-fields and zero-sized fields, except zero-sized
   14442              :                arrays at the end.  */
   14443   1897323667 :             while (f1 && (TREE_CODE (f1) != FIELD_DECL
   14444    115003693 :                           || (DECL_SIZE (f1)
   14445    114986353 :                               && integer_zerop (DECL_SIZE (f1))
   14446     52344149 :                               && (TREE_CHAIN (f1)
   14447         3657 :                                   || TREE_CODE (TREE_TYPE (f1))
   14448              :                                      != ARRAY_TYPE))))
   14449   1709821177 :               f1 = TREE_CHAIN (f1);
   14450   1897325285 :             while (f2 && (TREE_CODE (f2) != FIELD_DECL
   14451    115018935 :                           || (DECL_SIZE (f2)
   14452    115001487 :                               && integer_zerop (DECL_SIZE (f2))
   14453     52345774 :                               && (TREE_CHAIN (f2)
   14454         4766 :                                   || TREE_CODE (TREE_TYPE (f2))
   14455              :                                      != ARRAY_TYPE))))
   14456   1709822795 :               f2 = TREE_CHAIN (f2);
   14457    187502490 :             if (!f1 || !f2)
   14458              :               break;
   14459              : 
   14460     62660316 :             tree t1 = TREE_TYPE (f1);
   14461     62660316 :             tree t2 = TREE_TYPE (f2);
   14462              : 
   14463              :             /* If the last element are arrays, we only compare the element
   14464              :                types.  */
   14465     63778669 :             if (TREE_CHAIN (f1) == NULL_TREE && TREE_CODE (t1) == ARRAY_TYPE
   14466     62747656 :                 && TREE_CHAIN (f2) == NULL_TREE && TREE_CODE (t2) == ARRAY_TYPE)
   14467              :               {
   14468              :                 /* If both arrays have zero size, this is a match.  */
   14469       157748 :                 if (DECL_SIZE (f1) && integer_zerop (DECL_SIZE (f1))
   14470        88107 :                     && DECL_SIZE (f2) && integer_zerop (DECL_SIZE (f2)))
   14471              :                   return true;
   14472              : 
   14473        86564 :                 t1 = TREE_TYPE (t1);
   14474        86564 :                 t2 = TREE_TYPE (t2);
   14475              :               }
   14476              : 
   14477     62659545 :             if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
   14478     62659540 :                 || !gimple_compare_field_offset (f1, f2)
   14479    125319085 :                 || !gimple_canonical_types_compatible_p
   14480     62659540 :                       (t1, t2, trust_type_canonical))
   14481              :               return false;
   14482              :           }
   14483              : 
   14484              :         /* If one aggregate has more fields than the other, they
   14485              :            are not the same.  */
   14486    125970153 :         if (f1 || f2)
   14487        13624 :           return false;
   14488              : 
   14489              :         return true;
   14490              :       }
   14491              : 
   14492       345620 :     default:
   14493              :       /* Consider all types with language specific trees in them mutually
   14494              :          compatible.  This is executed only from verify_type and false
   14495              :          positives can be tolerated.  */
   14496       345620 :       gcc_assert (!in_lto_p);
   14497              :       return true;
   14498              :     }
   14499              : }
   14500              : 
   14501              : /* For OPAQUE_TYPE T, it should have only size and alignment information
   14502              :    and its mode should be of class MODE_OPAQUE.  This function verifies
   14503              :    these properties of T match TV which is the main variant of T and TC
   14504              :    which is the canonical of T.  */
   14505              : 
   14506              : static void
   14507            0 : verify_opaque_type (const_tree t, tree tv, tree tc)
   14508              : {
   14509            0 :   gcc_assert (OPAQUE_TYPE_P (t));
   14510            0 :   gcc_assert (tv && tv == TYPE_MAIN_VARIANT (tv));
   14511            0 :   gcc_assert (tc && tc == TYPE_CANONICAL (tc));
   14512              : 
   14513              :   /* For an opaque type T1, check if some of its properties match
   14514              :      the corresponding ones of the other opaque type T2, emit some
   14515              :      error messages for those inconsistent ones.  */
   14516            0 :   auto check_properties_for_opaque_type = [](const_tree t1, tree t2,
   14517              :                                              const char *kind_msg)
   14518              :   {
   14519            0 :     if (!OPAQUE_TYPE_P (t2))
   14520              :       {
   14521            0 :         error ("type %s is not an opaque type", kind_msg);
   14522            0 :         debug_tree (t2);
   14523            0 :         return;
   14524              :       }
   14525            0 :     if (!OPAQUE_MODE_P (TYPE_MODE (t2)))
   14526              :       {
   14527            0 :         error ("type %s is not with opaque mode", kind_msg);
   14528            0 :         debug_tree (t2);
   14529            0 :         return;
   14530              :       }
   14531            0 :     if (TYPE_MODE (t1) != TYPE_MODE (t2))
   14532              :       {
   14533            0 :         error ("type %s differs by %<TYPE_MODE%>", kind_msg);
   14534            0 :         debug_tree (t2);
   14535            0 :         return;
   14536              :       }
   14537            0 :     poly_uint64 t1_size = tree_to_poly_uint64 (TYPE_SIZE (t1));
   14538            0 :     poly_uint64 t2_size = tree_to_poly_uint64 (TYPE_SIZE (t2));
   14539            0 :     if (maybe_ne (t1_size, t2_size))
   14540              :       {
   14541            0 :         error ("type %s differs by %<TYPE_SIZE%>", kind_msg);
   14542            0 :         debug_tree (t2);
   14543            0 :         return;
   14544              :       }
   14545            0 :     if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2))
   14546              :       {
   14547            0 :         error ("type %s differs by %<TYPE_ALIGN%>", kind_msg);
   14548            0 :         debug_tree (t2);
   14549            0 :         return;
   14550              :       }
   14551            0 :     if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
   14552              :       {
   14553            0 :         error ("type %s differs by %<TYPE_USER_ALIGN%>", kind_msg);
   14554            0 :         debug_tree (t2);
   14555            0 :         return;
   14556              :       }
   14557              :   };
   14558              : 
   14559            0 :   if (t != tv)
   14560            0 :     check_properties_for_opaque_type (t, tv, "variant");
   14561              : 
   14562            0 :   if (t != tc)
   14563            0 :     check_properties_for_opaque_type (t, tc, "canonical");
   14564            0 : }
   14565              : 
   14566              : /* Verify type T.  */
   14567              : 
   14568              : void
   14569    921917024 : verify_type (const_tree t)
   14570              : {
   14571    921917024 :   bool error_found = false;
   14572    921917024 :   tree mv = TYPE_MAIN_VARIANT (t);
   14573    921917024 :   tree ct = TYPE_CANONICAL (t);
   14574              : 
   14575    921917024 :   if (OPAQUE_TYPE_P (t))
   14576              :     {
   14577            0 :       verify_opaque_type (t, mv, ct);
   14578            0 :       return;
   14579              :     }
   14580              : 
   14581    921917024 :   if (!mv)
   14582              :     {
   14583            0 :       error ("main variant is not defined");
   14584            0 :       error_found = true;
   14585              :     }
   14586    921917024 :   else if (mv != TYPE_MAIN_VARIANT (mv))
   14587              :     {
   14588            0 :       error ("%<TYPE_MAIN_VARIANT%> has different %<TYPE_MAIN_VARIANT%>");
   14589            0 :       debug_tree (mv);
   14590            0 :       error_found = true;
   14591              :     }
   14592    921917024 :   else if (t != mv && !verify_type_variant (t, mv))
   14593              :     error_found = true;
   14594              : 
   14595    921917024 :   if (!ct)
   14596              :     ;
   14597    919883248 :   else if (TYPE_CANONICAL (ct) != ct)
   14598              :     {
   14599            0 :       error ("%<TYPE_CANONICAL%> has different %<TYPE_CANONICAL%>");
   14600            0 :       debug_tree (ct);
   14601            0 :       error_found = true;
   14602              :     }
   14603              :   /* Method and function types cannot be used to address memory and thus
   14604              :      TYPE_CANONICAL really matters only for determining useless conversions.
   14605              : 
   14606              :      FIXME: C++ FE produce declarations of builtin functions that are not
   14607              :      compatible with main variants.  */
   14608    919883248 :   else if (TREE_CODE (t) == FUNCTION_TYPE)
   14609              :     ;
   14610    919246218 :   else if (t != ct
   14611              :            /* FIXME: gimple_canonical_types_compatible_p cannot compare types
   14612              :               with variably sized arrays because their sizes possibly
   14613              :               gimplified to different variables.  */
   14614    155985556 :            && !variably_modified_type_p (ct, NULL)
   14615    155980915 :            && !gimple_canonical_types_compatible_p (t, ct, false)
   14616    919259842 :            && COMPLETE_TYPE_P (t))
   14617              :     {
   14618            0 :       error ("%<TYPE_CANONICAL%> is not compatible");
   14619            0 :       debug_tree (ct);
   14620            0 :       error_found = true;
   14621              :     }
   14622   1666681568 :   if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t)
   14623              :       /* We allow a mismatch for structure or union because of
   14624              :          flexible array members.  */
   14625    742801590 :       && !RECORD_OR_UNION_TYPE_P (t)
   14626    306340653 :       && !RECORD_OR_UNION_TYPE_P (TYPE_CANONICAL (t))
   14627    306340653 :       && TREE_CODE (t) != ARRAY_TYPE
   14628   1226743285 :       && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t)))
   14629              :     {
   14630            0 :       error ("%<TYPE_MODE%> of %<TYPE_CANONICAL%> is not compatible");
   14631            0 :       debug_tree (ct);
   14632            0 :       error_found = true;
   14633              :     }
   14634    921917024 :   if (TYPE_MAIN_VARIANT (t) == t && ct && TYPE_MAIN_VARIANT (ct) != ct)
   14635              :    {
   14636              :      /* This can happen when build_type_attribute_variant is called on
   14637              :         C/C++ arrays of qualified types.  volatile int[2] is unqualified
   14638              :         ARRAY_TYPE with volatile int element type.
   14639              :         TYPE_CANONICAL (volatile int) is itself and so is
   14640              :         TYPE_CANONICAL (volatile int[2]).  build_type_attribute_qual_variant
   14641              :         creates a distinct type copy (so TYPE_MAIN_VARIANT is itself) and sets
   14642              :         its TYPE_CANONICAL to the unqualified ARRAY_TYPE (so volatile int[2]).
   14643              :         But this is not the TYPE_MAIN_VARIANT, which is int[2].  So, just
   14644              :         verify that TYPE_MAIN_VARIANT (ct) is already the final type we
   14645              :         need.  */
   14646            2 :       tree mvc = TYPE_MAIN_VARIANT (ct);
   14647            2 :       if (TYPE_CANONICAL (mvc) != mvc)
   14648              :         {
   14649            0 :           error ("main variant of %<TYPE_CANONICAL%> of main variant is not"
   14650              :                  " its own %<TYPE_CANONICAL%>");
   14651            0 :           debug_tree (ct);
   14652            0 :           debug_tree (TYPE_MAIN_VARIANT (ct));
   14653            0 :           error_found = true;
   14654              :         }
   14655              :    }
   14656              : 
   14657              : 
   14658              :   /* Check various uses of TYPE_MIN_VALUE_RAW.  */
   14659    921917024 :   if (RECORD_OR_UNION_TYPE_P (t))
   14660              :     {
   14661              :       /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
   14662              :          and danagle the pointer from time to time.  */
   14663    484947426 :       if (TYPE_VFIELD (t)
   14664     12369116 :           && TREE_CODE (TYPE_VFIELD (t)) != FIELD_DECL
   14665    484947426 :           && TREE_CODE (TYPE_VFIELD (t)) != TREE_LIST)
   14666              :         {
   14667            0 :           error ("%<TYPE_VFIELD%> is not %<FIELD_DECL%> nor %<TREE_LIST%>");
   14668            0 :           debug_tree (TYPE_VFIELD (t));
   14669            0 :           error_found = true;
   14670              :         }
   14671              :     }
   14672    436969598 :   else if (TREE_CODE (t) == POINTER_TYPE)
   14673              :     {
   14674    112268292 :       if (TYPE_NEXT_PTR_TO (t)
   14675    112268292 :           && TREE_CODE (TYPE_NEXT_PTR_TO (t)) != POINTER_TYPE)
   14676              :         {
   14677            0 :           error ("%<TYPE_NEXT_PTR_TO%> is not %<POINTER_TYPE%>");
   14678            0 :           debug_tree (TYPE_NEXT_PTR_TO (t));
   14679            0 :           error_found = true;
   14680              :         }
   14681              :     }
   14682    324701306 :   else if (TREE_CODE (t) == REFERENCE_TYPE)
   14683              :     {
   14684     51228806 :       if (TYPE_NEXT_REF_TO (t)
   14685     51228806 :           && TREE_CODE (TYPE_NEXT_REF_TO (t)) != REFERENCE_TYPE)
   14686              :         {
   14687            0 :           error ("%<TYPE_NEXT_REF_TO%> is not %<REFERENCE_TYPE%>");
   14688            0 :           debug_tree (TYPE_NEXT_REF_TO (t));
   14689            0 :           error_found = true;
   14690              :         }
   14691              :     }
   14692              :   else if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t)
   14693              :            || FIXED_POINT_TYPE_P (t))
   14694              :     {
   14695              :       /* FIXME: The following check should pass:
   14696              :           useless_type_conversion_p (const_cast <tree> (t),
   14697              :                                      TREE_TYPE (TYPE_MIN_VALUE (t))
   14698              :          but does not for C sizetypes in LTO.  */
   14699              :     }
   14700              : 
   14701              :   /* Check various uses of TYPE_MAXVAL_RAW.  */
   14702    921917024 :   if (RECORD_OR_UNION_TYPE_P (t))
   14703              :     {
   14704    484947426 :       if (!TYPE_BINFO (t))
   14705              :         ;
   14706    456093884 :       else if (TREE_CODE (TYPE_BINFO (t)) != TREE_BINFO)
   14707              :         {
   14708            0 :           error ("%<TYPE_BINFO%> is not %<TREE_BINFO%>");
   14709            0 :           debug_tree (TYPE_BINFO (t));
   14710            0 :           error_found = true;
   14711              :         }
   14712    456093884 :       else if (TREE_TYPE (TYPE_BINFO (t)) != TYPE_MAIN_VARIANT (t))
   14713              :         {
   14714            0 :           error ("%<TYPE_BINFO%> type is not %<TYPE_MAIN_VARIANT%>");
   14715            0 :           debug_tree (TREE_TYPE (TYPE_BINFO (t)));
   14716            0 :           error_found = true;
   14717              :         }
   14718              :     }
   14719              :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14720              :     {
   14721       860023 :       if (TYPE_METHOD_BASETYPE (t)
   14722        70279 :           && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != RECORD_TYPE
   14723       860221 :           && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != UNION_TYPE)
   14724              :         {
   14725            0 :           error ("%<TYPE_METHOD_BASETYPE%> is not record nor union");
   14726            0 :           debug_tree (TYPE_METHOD_BASETYPE (t));
   14727            0 :           error_found = true;
   14728              :         }
   14729              :     }
   14730              :   else if (TREE_CODE (t) == OFFSET_TYPE)
   14731              :     {
   14732        35391 :       if (TYPE_OFFSET_BASETYPE (t)
   14733        35391 :           && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != RECORD_TYPE
   14734        35399 :           && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != UNION_TYPE)
   14735              :         {
   14736            0 :           error ("%<TYPE_OFFSET_BASETYPE%> is not record nor union");
   14737            0 :           debug_tree (TYPE_OFFSET_BASETYPE (t));
   14738            0 :           error_found = true;
   14739              :         }
   14740              :     }
   14741              :   else if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t)
   14742              :            || FIXED_POINT_TYPE_P (t))
   14743              :     {
   14744              :       /* FIXME: The following check should pass:
   14745              :           useless_type_conversion_p (const_cast <tree> (t),
   14746              :                                      TREE_TYPE (TYPE_MAX_VALUE (t))
   14747              :          but does not for C sizetypes in LTO.  */
   14748              :     }
   14749              :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14750              :     {
   14751      1788126 :       if (TYPE_ARRAY_MAX_SIZE (t)
   14752      1788126 :           && TREE_CODE (TYPE_ARRAY_MAX_SIZE (t)) != INTEGER_CST)
   14753              :         {
   14754            0 :           error ("%<TYPE_ARRAY_MAX_SIZE%> not %<INTEGER_CST%>");
   14755            0 :           debug_tree (TYPE_ARRAY_MAX_SIZE (t));
   14756            0 :           error_found = true;
   14757              :         }
   14758              :     }
   14759    293423398 :   else if (TYPE_MAX_VALUE_RAW (t))
   14760              :     {
   14761            0 :       error ("%<TYPE_MAX_VALUE_RAW%> non-NULL");
   14762            0 :       debug_tree (TYPE_MAX_VALUE_RAW (t));
   14763            0 :       error_found = true;
   14764              :     }
   14765              : 
   14766    921917024 :   if (TYPE_LANG_SLOT_1 (t) && in_lto_p)
   14767              :     {
   14768            0 :       error ("%<TYPE_LANG_SLOT_1 (binfo)%> field is non-NULL");
   14769            0 :       debug_tree (TYPE_LANG_SLOT_1 (t));
   14770            0 :       error_found = true;
   14771              :     }
   14772              : 
   14773              :   /* Check various uses of TYPE_VALUES_RAW.  */
   14774    921917024 :   if (TREE_CODE (t) == ENUMERAL_TYPE)
   14775    103643366 :     for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l))
   14776              :       {
   14777     90089238 :         tree value = TREE_VALUE (l);
   14778     90089238 :         tree name = TREE_PURPOSE (l);
   14779              : 
   14780              :         /* C FE porduce INTEGER_CST of INTEGER_TYPE, while C++ FE uses
   14781              :            CONST_DECL of ENUMERAL TYPE.  */
   14782     90089238 :         if (TREE_CODE (value) != INTEGER_CST && TREE_CODE (value) != CONST_DECL)
   14783              :           {
   14784            0 :             error ("enum value is not %<CONST_DECL%> or %<INTEGER_CST%>");
   14785            0 :             debug_tree (value);
   14786            0 :             debug_tree (name);
   14787            0 :             error_found = true;
   14788              :           }
   14789     90089238 :         if (TREE_CODE (TREE_TYPE (value)) != INTEGER_TYPE
   14790     90072286 :             && TREE_CODE (TREE_TYPE (value)) != BOOLEAN_TYPE
   14791    180161521 :             && !useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (value)))
   14792              :           {
   14793            0 :             error ("enum value type is not %<INTEGER_TYPE%> nor convertible "
   14794              :                    "to the enum");
   14795            0 :             debug_tree (value);
   14796            0 :             debug_tree (name);
   14797            0 :             error_found = true;
   14798              :           }
   14799     90089238 :         if (TREE_CODE (name) != IDENTIFIER_NODE)
   14800              :           {
   14801            0 :             error ("enum value name is not %<IDENTIFIER_NODE%>");
   14802            0 :             debug_tree (value);
   14803            0 :             debug_tree (name);
   14804            0 :             error_found = true;
   14805              :           }
   14806              :       }
   14807    908362896 :   else if (TREE_CODE (t) == ARRAY_TYPE)
   14808              :     {
   14809      1788126 :       if (TYPE_DOMAIN (t) && TREE_CODE (TYPE_DOMAIN (t)) != INTEGER_TYPE)
   14810              :         {
   14811            0 :           error ("array %<TYPE_DOMAIN%> is not integer type");
   14812            0 :           debug_tree (TYPE_DOMAIN (t));
   14813            0 :           error_found = true;
   14814              :         }
   14815              :     }
   14816    906574770 :   else if (RECORD_OR_UNION_TYPE_P (t))
   14817              :     {
   14818    484947426 :       if (TYPE_FIELDS (t) && !COMPLETE_TYPE_P (t) && in_lto_p)
   14819              :         {
   14820            0 :           error ("%<TYPE_FIELDS%> defined in incomplete type");
   14821            0 :           error_found = true;
   14822              :         }
   14823  20960367480 :       for (tree fld = TYPE_FIELDS (t); fld; fld = TREE_CHAIN (fld))
   14824              :         {
   14825              :           /* TODO: verify properties of decls.  */
   14826  20475420054 :           if (TREE_CODE (fld) == FIELD_DECL)
   14827              :             ;
   14828              :           else if (TREE_CODE (fld) == TYPE_DECL)
   14829              :             ;
   14830              :           else if (TREE_CODE (fld) == CONST_DECL)
   14831              :             ;
   14832              :           else if (VAR_P (fld))
   14833              :             ;
   14834              :           else if (TREE_CODE (fld) == TEMPLATE_DECL)
   14835              :             ;
   14836              :           else if (TREE_CODE (fld) == USING_DECL)
   14837              :             ;
   14838              :           else if (TREE_CODE (fld) == FUNCTION_DECL)
   14839              :             ;
   14840              :           else
   14841              :             {
   14842            0 :               error ("wrong tree in %<TYPE_FIELDS%> list");
   14843            0 :               debug_tree (fld);
   14844            0 :               error_found = true;
   14845              :             }
   14846              :         }
   14847              :     }
   14848    421627344 :   else if (TREE_CODE (t) == INTEGER_TYPE
   14849              :            || TREE_CODE (t) == BOOLEAN_TYPE
   14850    421627344 :            || TREE_CODE (t) == BITINT_TYPE
   14851    299674679 :            || TREE_CODE (t) == OFFSET_TYPE
   14852    299639288 :            || TREE_CODE (t) == REFERENCE_TYPE
   14853    248410482 :            || TREE_CODE (t) == NULLPTR_TYPE
   14854    248063218 :            || TREE_CODE (t) == POINTER_TYPE)
   14855              :     {
   14856    285832418 :       if (TYPE_CACHED_VALUES_P (t) != (TYPE_CACHED_VALUES (t) != NULL))
   14857              :         {
   14858            0 :           error ("%<TYPE_CACHED_VALUES_P%> is %i while %<TYPE_CACHED_VALUES%> "
   14859              :                  "is %p",
   14860            0 :                  TYPE_CACHED_VALUES_P (t), (void *)TYPE_CACHED_VALUES (t));
   14861            0 :           error_found = true;
   14862              :         }
   14863    285832418 :       else if (TYPE_CACHED_VALUES_P (t) && TREE_CODE (TYPE_CACHED_VALUES (t)) != TREE_VEC)
   14864              :         {
   14865            0 :           error ("%<TYPE_CACHED_VALUES%> is not %<TREE_VEC%>");
   14866            0 :           debug_tree (TYPE_CACHED_VALUES (t));
   14867            0 :           error_found = true;
   14868              :         }
   14869              :       /* Verify just enough of cache to ensure that no one copied it to new type.
   14870              :          All copying should go by copy_node that should clear it.  */
   14871    285832418 :       else if (TYPE_CACHED_VALUES_P (t))
   14872              :         {
   14873              :           int i;
   14874   8523207444 :           for (i = 0; i < TREE_VEC_LENGTH (TYPE_CACHED_VALUES (t)); i++)
   14875   8456535091 :             if (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i)
   14876   8456535091 :                 && TREE_TYPE (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i)) != t)
   14877              :               {
   14878            0 :                 error ("wrong %<TYPE_CACHED_VALUES%> entry");
   14879            0 :                 debug_tree (TREE_VEC_ELT (TYPE_CACHED_VALUES (t), i));
   14880            0 :                 error_found = true;
   14881            0 :                 break;
   14882              :               }
   14883              :         }
   14884              :     }
   14885    135794926 :   else if (FUNC_OR_METHOD_TYPE_P (t))
   14886      3250616 :     for (tree l = TYPE_ARG_TYPES (t); l; l = TREE_CHAIN (l))
   14887              :       {
   14888              :         /* C++ FE uses TREE_PURPOSE to store initial values.  */
   14889      2390593 :         if (TREE_PURPOSE (l) && in_lto_p)
   14890              :           {
   14891            0 :             error ("%<TREE_PURPOSE%> is non-NULL in %<TYPE_ARG_TYPES%> list");
   14892            0 :             debug_tree (l);
   14893            0 :             error_found = true;
   14894              :           }
   14895      2390593 :         if (!TYPE_P (TREE_VALUE (l)))
   14896              :           {
   14897            0 :             error ("wrong entry in %<TYPE_ARG_TYPES%> list");
   14898            0 :             debug_tree (l);
   14899            0 :             error_found = true;
   14900              :           }
   14901              :       }
   14902    269494030 :   else if (!is_lang_specific (t) && TYPE_VALUES_RAW (t))
   14903              :     {
   14904            0 :       error ("%<TYPE_VALUES_RAW%> field is non-NULL");
   14905            0 :       debug_tree (TYPE_VALUES_RAW (t));
   14906            0 :       error_found = true;
   14907              :     }
   14908    921917024 :   if (TREE_CODE (t) != INTEGER_TYPE
   14909              :       && TREE_CODE (t) != BOOLEAN_TYPE
   14910    921917024 :       && TREE_CODE (t) != BITINT_TYPE
   14911              :       && TREE_CODE (t) != OFFSET_TYPE
   14912              :       && TREE_CODE (t) != REFERENCE_TYPE
   14913              :       && TREE_CODE (t) != NULLPTR_TYPE
   14914              :       && TREE_CODE (t) != POINTER_TYPE
   14915    636084606 :       && TYPE_CACHED_VALUES_P (t))
   14916              :     {
   14917            0 :       error ("%<TYPE_CACHED_VALUES_P%> is set while it should not be");
   14918            0 :       error_found = true;
   14919              :     }
   14920              : 
   14921              :   /* ipa-devirt makes an assumption that TYPE_METHOD_BASETYPE is always
   14922              :      TYPE_MAIN_VARIANT and it would be odd to add methods only to variatns
   14923              :      of a type. */
   14924    921917024 :   if (TREE_CODE (t) == METHOD_TYPE
   14925    921917024 :       && TYPE_MAIN_VARIANT (TYPE_METHOD_BASETYPE (t)) != TYPE_METHOD_BASETYPE (t))
   14926              :     {
   14927            0 :         error ("%<TYPE_METHOD_BASETYPE%> is not main variant");
   14928            0 :         error_found = true;
   14929              :     }
   14930              : 
   14931    921917024 :   if (error_found)
   14932              :     {
   14933            0 :       debug_tree (const_cast <tree> (t));
   14934            0 :       internal_error ("%qs failed", __func__);
   14935              :     }
   14936              : }
   14937              : 
   14938              : 
   14939              : /* Return 1 if ARG interpreted as signed in its precision is known to be
   14940              :    always non-negative or 2 if ARG is known to be always negative, or 3 if
   14941              :    ARG may be non-negative or negative.  STMT if specified is the statement
   14942              :    on which it is being tested.  */
   14943              : 
   14944              : int
   14945       872248 : get_range_pos_neg (tree arg, gimple *stmt)
   14946              : {
   14947       872248 :   if (arg == error_mark_node || !INTEGRAL_TYPE_P (TREE_TYPE (arg)))
   14948              :     return 3;
   14949              : 
   14950       872248 :   int prec = TYPE_PRECISION (TREE_TYPE (arg));
   14951       872248 :   int cnt = 0;
   14952       872248 :   if (TREE_CODE (arg) == INTEGER_CST)
   14953              :     {
   14954        69970 :       wide_int w = wi::sext (wi::to_wide (arg), prec);
   14955        69970 :       if (wi::neg_p (w))
   14956              :         return 2;
   14957              :       else
   14958        55502 :         return 1;
   14959        69970 :     }
   14960       801003 :   while (CONVERT_EXPR_P (arg)
   14961        14749 :          && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
   14962       830501 :          && TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg, 0))) <= prec)
   14963              :     {
   14964        14105 :       arg = TREE_OPERAND (arg, 0);
   14965              :       /* Narrower value zero extended into wider type
   14966              :          will always result in positive values.  */
   14967        14105 :       if (TYPE_UNSIGNED (TREE_TYPE (arg))
   14968        14105 :           && TYPE_PRECISION (TREE_TYPE (arg)) < prec)
   14969              :         return 1;
   14970        13474 :       prec = TYPE_PRECISION (TREE_TYPE (arg));
   14971        13474 :       if (++cnt > 30)
   14972              :         return 3;
   14973              :     }
   14974              : 
   14975       801647 :   if (TREE_CODE (arg) != SSA_NAME)
   14976              :     return 3;
   14977       795429 :   int_range_max r;
   14978      1608177 :   while (!get_range_query (cfun)->range_of_expr (r, arg, stmt)
   14979      1625496 :          || r.undefined_p () || r.varying_p ())
   14980              :     {
   14981       536158 :       gimple *g = SSA_NAME_DEF_STMT (arg);
   14982       536158 :       if (is_gimple_assign (g)
   14983       536158 :           && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (g)))
   14984              :         {
   14985        29384 :           tree t = gimple_assign_rhs1 (g);
   14986        58441 :           if (INTEGRAL_TYPE_P (TREE_TYPE (t))
   14987        55755 :               && TYPE_PRECISION (TREE_TYPE (t)) <= prec)
   14988              :             {
   14989        19720 :               if (TYPE_UNSIGNED (TREE_TYPE (t))
   14990        19720 :                   && TYPE_PRECISION (TREE_TYPE (t)) < prec)
   14991              :                 return 1;
   14992        17319 :               prec = TYPE_PRECISION (TREE_TYPE (t));
   14993        17319 :               arg = t;
   14994        17319 :               if (++cnt > 30)
   14995              :                 return 3;
   14996        17319 :               continue;
   14997              :             }
   14998              :         }
   14999              :       return 3;
   15000              :     }
   15001       276590 :   if (TYPE_UNSIGNED (TREE_TYPE (arg)))
   15002              :     {
   15003              :       /* For unsigned values, the "positive" range comes
   15004              :          below the "negative" range.  */
   15005       113805 :       if (!wi::neg_p (wi::sext (r.upper_bound (), prec), SIGNED))
   15006              :         return 1;
   15007        31962 :       if (wi::neg_p (wi::sext (r.lower_bound (), prec), SIGNED))
   15008          819 :         return 2;
   15009              :     }
   15010              :   else
   15011              :     {
   15012       162785 :       if (!wi::neg_p (wi::sext (r.lower_bound (), prec), SIGNED))
   15013              :         return 1;
   15014        65548 :       if (wi::neg_p (wi::sext (r.upper_bound (), prec), SIGNED))
   15015         1197 :         return 2;
   15016              :     }
   15017              :   return 3;
   15018       795429 : }
   15019              : 
   15020              : 
   15021              : 
   15022              : 
   15023              : /* Return true if ARG is marked with the nonnull attribute in the
   15024              :    current function signature.  */
   15025              : 
   15026              : bool
   15027     29829990 : nonnull_arg_p (const_tree arg)
   15028              : {
   15029     29829990 :   tree t, attrs, fntype;
   15030     29829990 :   unsigned HOST_WIDE_INT arg_num;
   15031              : 
   15032     29829990 :   gcc_assert (TREE_CODE (arg) == PARM_DECL
   15033              :               && (POINTER_TYPE_P (TREE_TYPE (arg))
   15034              :                   || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE));
   15035              : 
   15036              :   /* The static chain decl is always non null.  */
   15037     29829990 :   if (arg == cfun->static_chain_decl)
   15038              :     return true;
   15039              : 
   15040              :   /* THIS argument of method is always non-NULL.  */
   15041     29560895 :   if (TREE_CODE (TREE_TYPE (cfun->decl)) == METHOD_TYPE
   15042     12076910 :       && arg == DECL_ARGUMENTS (cfun->decl)
   15043     37380687 :       && flag_delete_null_pointer_checks)
   15044              :     return true;
   15045              : 
   15046              :   /* Values passed by reference are always non-NULL.  */
   15047     21743558 :   if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE
   15048     21743558 :       && flag_delete_null_pointer_checks)
   15049              :     return true;
   15050              : 
   15051     14242961 :   fntype = TREE_TYPE (cfun->decl);
   15052     14266951 :   for (attrs = TYPE_ATTRIBUTES (fntype); attrs; attrs = TREE_CHAIN (attrs))
   15053              :     {
   15054       575490 :       attrs = lookup_attribute ("nonnull", attrs);
   15055              : 
   15056              :       /* If "nonnull" wasn't specified, we know nothing about the argument.  */
   15057       575490 :       if (attrs == NULL_TREE)
   15058              :         return false;
   15059              : 
   15060              :       /* If "nonnull" applies to all the arguments, then ARG is non-null.  */
   15061       116449 :       if (TREE_VALUE (attrs) == NULL_TREE)
   15062              :         return true;
   15063              : 
   15064              :       /* Get the position number for ARG in the function signature.  */
   15065        57546 :       for (arg_num = 1, t = DECL_ARGUMENTS (cfun->decl);
   15066       132059 :            t;
   15067        74513 :            t = DECL_CHAIN (t), arg_num++)
   15068              :         {
   15069       132059 :           if (t == arg)
   15070              :             break;
   15071              :         }
   15072              : 
   15073        57546 :       gcc_assert (t == arg);
   15074              : 
   15075              :       /* Now see if ARG_NUM is mentioned in the nonnull list.  */
   15076        91251 :       for (t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t))
   15077              :         {
   15078        67261 :           if (compare_tree_int (TREE_VALUE (t), arg_num) == 0)
   15079              :             return true;
   15080              :         }
   15081              :     }
   15082              : 
   15083              :   return false;
   15084              : }
   15085              : 
   15086              : /* Combine LOC and BLOCK to a combined adhoc loc, retaining any range
   15087              :    information.  */
   15088              : 
   15089              : location_t
   15090    957799448 : set_block (location_t loc, tree block)
   15091              : {
   15092    957799448 :   location_t pure_loc = get_pure_location (loc);
   15093    957799448 :   source_range src_range = get_range_from_loc (line_table, loc);
   15094    957799448 :   unsigned discriminator = get_discriminator_from_loc (line_table, loc);
   15095    957799448 :   return line_table->get_or_create_combined_loc (pure_loc, src_range, block,
   15096    957799448 :                                                  discriminator);
   15097              : }
   15098              : 
   15099              : location_t
   15100    228314735 : set_source_range (tree expr, location_t start, location_t finish)
   15101              : {
   15102    228314735 :   source_range src_range;
   15103    228314735 :   src_range.m_start = start;
   15104    228314735 :   src_range.m_finish = finish;
   15105    228314735 :   return set_source_range (expr, src_range);
   15106              : }
   15107              : 
   15108              : location_t
   15109    464932448 : set_source_range (tree expr, source_range src_range)
   15110              : {
   15111    464932448 :   if (!EXPR_P (expr))
   15112              :     return UNKNOWN_LOCATION;
   15113              : 
   15114    205361542 :   location_t expr_location = EXPR_LOCATION (expr);
   15115    205361542 :   location_t pure_loc = get_pure_location (expr_location);
   15116    205361542 :   unsigned discriminator = get_discriminator_from_loc (expr_location);
   15117    205361542 :   location_t adhoc = line_table->get_or_create_combined_loc (pure_loc,
   15118              :                                                              src_range,
   15119              :                                                              nullptr,
   15120              :                                                              discriminator);
   15121    205361542 :   SET_EXPR_LOCATION (expr, adhoc);
   15122    205361542 :   return adhoc;
   15123              : }
   15124              : 
   15125              : /* Return EXPR, potentially wrapped with a node expression LOC,
   15126              :    if !CAN_HAVE_LOCATION_P (expr).
   15127              : 
   15128              :    NON_LVALUE_EXPR is used for wrapping constants, apart from STRING_CST.
   15129              :    VIEW_CONVERT_EXPR is used for wrapping non-constants and STRING_CST.
   15130              : 
   15131              :    Wrapper nodes can be identified using location_wrapper_p.  */
   15132              : 
   15133              : tree
   15134   1613946941 : maybe_wrap_with_location (tree expr, location_t loc)
   15135              : {
   15136   1613946941 :   if (expr == NULL)
   15137              :     return NULL;
   15138   1613946937 :   if (loc == UNKNOWN_LOCATION)
   15139              :     return expr;
   15140   1559138273 :   if (CAN_HAVE_LOCATION_P (expr))
   15141              :     return expr;
   15142              :   /* We should only be adding wrappers for constants and for decls,
   15143              :      or for some exceptional tree nodes (e.g. BASELINK in the C++ FE).  */
   15144    953659407 :   gcc_assert (CONSTANT_CLASS_P (expr)
   15145              :               || DECL_P (expr)
   15146              :               || EXCEPTIONAL_CLASS_P (expr));
   15147              : 
   15148              :   /* For now, don't add wrappers to exceptional tree nodes, to minimize
   15149              :      any impact of the wrapper nodes.  */
   15150    953659407 :   if (EXCEPTIONAL_CLASS_P (expr) || error_operand_p (expr))
   15151              :     return expr;
   15152              : 
   15153              :   /* Compiler-generated temporary variables don't need a wrapper.  */
   15154    879113028 :   if (DECL_P (expr) && DECL_ARTIFICIAL (expr) && DECL_IGNORED_P (expr))
   15155              :     return expr;
   15156              : 
   15157              :   /* If any auto_suppress_location_wrappers are active, don't create
   15158              :      wrappers.  */
   15159    879110530 :   if (suppress_location_wrappers > 0)
   15160              :     return expr;
   15161              : 
   15162   1643414694 :   tree_code code
   15163    215824580 :     = (((CONSTANT_CLASS_P (expr) && TREE_CODE (expr) != STRING_CST)
   15164    614789242 :         || (TREE_CODE (expr) == CONST_DECL && !TREE_STATIC (expr)))
   15165    821707347 :        ? NON_LVALUE_EXPR : VIEW_CONVERT_EXPR);
   15166    821707347 :   tree wrapper = build1_loc (loc, code, TREE_TYPE (expr), expr);
   15167              :   /* Mark this node as being a wrapper.  */
   15168    821707347 :   EXPR_LOCATION_WRAPPER_P (wrapper) = 1;
   15169    821707347 :   return wrapper;
   15170              : }
   15171              : 
   15172              : int suppress_location_wrappers;
   15173              : 
   15174              : /* Return the name of combined function FN, for debugging purposes.  */
   15175              : 
   15176              : const char *
   15177            0 : combined_fn_name (combined_fn fn)
   15178              : {
   15179            0 :   if (builtin_fn_p (fn))
   15180              :     {
   15181            0 :       tree fndecl = builtin_decl_explicit (as_builtin_fn (fn));
   15182            0 :       return IDENTIFIER_POINTER (DECL_NAME (fndecl));
   15183              :     }
   15184              :   else
   15185            0 :     return internal_fn_name (as_internal_fn (fn));
   15186              : }
   15187              : 
   15188              : /* Return a bitmap with a bit set corresponding to each argument in
   15189              :    a function call type FNTYPE declared with attribute nonnull,
   15190              :    or null if none of the function's argument are nonnull.  The caller
   15191              :    must free the bitmap.  */
   15192              : 
   15193              : bitmap
   15194     22026811 : get_nonnull_args (const_tree fntype)
   15195              : {
   15196     22026811 :   if (fntype == NULL_TREE)
   15197              :     return NULL;
   15198              : 
   15199     21363183 :   bitmap argmap = NULL;
   15200     21363183 :   if (TREE_CODE (fntype) == METHOD_TYPE)
   15201              :     {
   15202              :       /* The this pointer in C++ non-static member functions is
   15203              :          implicitly nonnull whether or not it's declared as such.  */
   15204      2859559 :       argmap = BITMAP_ALLOC (NULL);
   15205      2859559 :       bitmap_set_bit (argmap, 0);
   15206              :     }
   15207              : 
   15208     21363183 :   tree attrs = TYPE_ATTRIBUTES (fntype);
   15209     21363183 :   if (!attrs)
   15210              :     return argmap;
   15211              : 
   15212              :   /* A function declaration can specify multiple attribute nonnull,
   15213              :      each with zero or more arguments.  The loop below creates a bitmap
   15214              :      representing a union of all the arguments.  An empty (but non-null)
   15215              :      bitmap means that all arguments have been declared nonnull.  */
   15216      6015478 :   for ( ; attrs; attrs = TREE_CHAIN (attrs))
   15217              :     {
   15218      5905149 :       attrs = lookup_attribute ("nonnull", attrs);
   15219      5905149 :       if (!attrs)
   15220              :         break;
   15221              : 
   15222      1429111 :       if (!argmap)
   15223      1390768 :         argmap = BITMAP_ALLOC (NULL);
   15224              : 
   15225      1429111 :       if (!TREE_VALUE (attrs))
   15226              :         {
   15227              :           /* Clear the bitmap in case a previous attribute nonnull
   15228              :              set it and this one overrides it for all arguments.  */
   15229       783235 :           bitmap_clear (argmap);
   15230       783235 :           return argmap;
   15231              :         }
   15232              : 
   15233              :       /* Iterate over the indices of the format arguments declared nonnull
   15234              :          and set a bit for each.  */
   15235      1693571 :       for (tree idx = TREE_VALUE (attrs); idx; idx = TREE_CHAIN (idx))
   15236              :         {
   15237      1047695 :           unsigned int val = TREE_INT_CST_LOW (TREE_VALUE (idx)) - 1;
   15238      1047695 :           bitmap_set_bit (argmap, val);
   15239              :         }
   15240              :     }
   15241              : 
   15242              :   return argmap;
   15243              : }
   15244              : 
   15245              : /* Returns true if TYPE is a type where it and all of its subobjects
   15246              :    (recursively) are of structure, union, or array type.  */
   15247              : 
   15248              : bool
   15249   2031232640 : is_empty_type (const_tree type)
   15250              : {
   15251   2031232640 :   if (RECORD_OR_UNION_TYPE_P (type))
   15252              :     {
   15253    892874556 :       for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
   15254    819664037 :         if (TREE_CODE (field) == FIELD_DECL
   15255    405611255 :             && !DECL_PADDING_P (field)
   15256   1225273942 :             && !is_empty_type (TREE_TYPE (field)))
   15257              :           return false;
   15258              :       return true;
   15259              :     }
   15260   1580930522 :   else if (TREE_CODE (type) == ARRAY_TYPE)
   15261     89050877 :     return (integer_minus_onep (array_type_nelts_minus_one (type))
   15262     89006695 :             || TYPE_DOMAIN (type) == NULL_TREE
   15263    167825284 :             || is_empty_type (TREE_TYPE (type)));
   15264              :   return false;
   15265              : }
   15266              : 
   15267              : /* Implement TARGET_EMPTY_RECORD_P.  Return true if TYPE is an empty type
   15268              :    that shouldn't be passed via stack.  */
   15269              : 
   15270              : bool
   15271   1494571686 : default_is_empty_record (const_tree type)
   15272              : {
   15273   1494571686 :   if (!abi_version_at_least (12))
   15274              :     return false;
   15275              : 
   15276   1493508670 :   if (type == error_mark_node)
   15277              :     return false;
   15278              : 
   15279   1493508670 :   if (TREE_ADDRESSABLE (type))
   15280              :     return false;
   15281              : 
   15282   1493508670 :   return is_empty_type (TYPE_MAIN_VARIANT (type));
   15283              : }
   15284              : 
   15285              : 
   15286              : /* Determine whether TYPE is an ISO C99 flexible array member type "[]".  */
   15287              : 
   15288              : bool
   15289     11833721 : flexible_array_member_type_p (const_tree type)
   15290              : {
   15291     11833721 :   if (TREE_CODE (type) == ARRAY_TYPE
   15292      4943973 :       && TYPE_SIZE (type) == NULL_TREE
   15293       649234 :       && TYPE_DOMAIN (type) != NULL_TREE
   15294     12392859 :       && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE)
   15295       559138 :     return true;
   15296              : 
   15297              :   return false;
   15298              : }
   15299              : 
   15300              : 
   15301              : /* Determine whether TYPE is a structure with a flexible array member,
   15302              :    or a union containing such a structure (possibly recursively).  */
   15303              : 
   15304              : bool
   15305        72552 : flexible_array_type_p (const_tree type)
   15306              : {
   15307        72552 :   tree x, last;
   15308        72552 :   switch (TREE_CODE (type))
   15309              :     {
   15310        38250 :     case RECORD_TYPE:
   15311        38250 :       last = NULL_TREE;
   15312       174073 :       for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
   15313       135823 :         if (TREE_CODE (x) == FIELD_DECL)
   15314       135823 :           last = x;
   15315        38250 :       if (last == NULL_TREE)
   15316              :         return false;
   15317        38242 :        return flexible_array_member_type_p (TREE_TYPE (last));
   15318          579 :     case UNION_TYPE:
   15319         1668 :       for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
   15320              :         {
   15321         1131 :           if (TREE_CODE (x) == FIELD_DECL
   15322         1131 :               && flexible_array_type_p (TREE_TYPE (x)))
   15323              :             return true;
   15324              :         }
   15325              :       return false;
   15326              :     default:
   15327              :       return false;
   15328              :   }
   15329              : }
   15330              : 
   15331              : /* Like int_size_in_bytes, but handle empty records specially.  */
   15332              : 
   15333              : HOST_WIDE_INT
   15334       464350 : arg_int_size_in_bytes (const_tree type)
   15335              : {
   15336       464350 :   return TYPE_EMPTY_P (type) ? 0 : int_size_in_bytes (type);
   15337              : }
   15338              : 
   15339              : /* Like size_in_bytes, but handle empty records specially.  */
   15340              : 
   15341              : tree
   15342      5723633 : arg_size_in_bytes (const_tree type)
   15343              : {
   15344      5723633 :   return TYPE_EMPTY_P (type) ? size_zero_node : size_in_bytes (type);
   15345              : }
   15346              : 
   15347              : /* Return true if an expression with CODE has to have the same result type as
   15348              :    its first operand.  */
   15349              : 
   15350              : bool
   15351            0 : expr_type_first_operand_type_p (tree_code code)
   15352              : {
   15353            0 :   switch (code)
   15354              :     {
   15355              :     case NEGATE_EXPR:
   15356              :     case ABS_EXPR:
   15357              :     case BIT_NOT_EXPR:
   15358              :     case PAREN_EXPR:
   15359              :     case CONJ_EXPR:
   15360              : 
   15361              :     case PLUS_EXPR:
   15362              :     case MINUS_EXPR:
   15363              :     case MULT_EXPR:
   15364              :     case TRUNC_DIV_EXPR:
   15365              :     case CEIL_DIV_EXPR:
   15366              :     case FLOOR_DIV_EXPR:
   15367              :     case ROUND_DIV_EXPR:
   15368              :     case TRUNC_MOD_EXPR:
   15369              :     case CEIL_MOD_EXPR:
   15370              :     case FLOOR_MOD_EXPR:
   15371              :     case ROUND_MOD_EXPR:
   15372              :     case RDIV_EXPR:
   15373              :     case EXACT_DIV_EXPR:
   15374              :     case MIN_EXPR:
   15375              :     case MAX_EXPR:
   15376              :     case BIT_IOR_EXPR:
   15377              :     case BIT_XOR_EXPR:
   15378              :     case BIT_AND_EXPR:
   15379              : 
   15380              :     case LSHIFT_EXPR:
   15381              :     case RSHIFT_EXPR:
   15382              :     case LROTATE_EXPR:
   15383              :     case RROTATE_EXPR:
   15384              :       return true;
   15385              : 
   15386            0 :     default:
   15387            0 :       return false;
   15388              :     }
   15389              : }
   15390              : 
   15391              : /* Return a typenode for the "standard" C type with a given name.  */
   15392              : tree
   15393       936951 : get_typenode_from_name (const char *name)
   15394              : {
   15395       936951 :   if (name == NULL || *name == '\0')
   15396              :     return NULL_TREE;
   15397              : 
   15398       936951 :   if (strcmp (name, "char") == 0)
   15399            0 :     return char_type_node;
   15400       936951 :   if (strcmp (name, "unsigned char") == 0)
   15401        96738 :     return unsigned_char_type_node;
   15402       840213 :   if (strcmp (name, "signed char") == 0)
   15403        96738 :     return signed_char_type_node;
   15404              : 
   15405       743475 :   if (strcmp (name, "short int") == 0)
   15406        66009 :     return short_integer_type_node;
   15407       677466 :   if (strcmp (name, "short unsigned int") == 0)
   15408        64492 :     return short_unsigned_type_node;
   15409              : 
   15410       612974 :   if (strcmp (name, "int") == 0)
   15411        66837 :     return integer_type_node;
   15412       546137 :   if (strcmp (name, "unsigned int") == 0)
   15413        65310 :     return unsigned_type_node;
   15414              : 
   15415       480827 :   if (strcmp (name, "long int") == 0)
   15416       286533 :     return long_integer_type_node;
   15417       194294 :   if (strcmp (name, "long unsigned int") == 0)
   15418       191022 :     return long_unsigned_type_node;
   15419              : 
   15420         3272 :   if (strcmp (name, "long long int") == 0)
   15421         1636 :     return long_long_integer_type_node;
   15422         1636 :   if (strcmp (name, "long long unsigned int") == 0)
   15423         1636 :     return long_long_unsigned_type_node;
   15424              : 
   15425            0 :   gcc_unreachable ();
   15426              : }
   15427              : 
   15428              : /* List of pointer types used to declare builtins before we have seen their
   15429              :    real declaration.
   15430              : 
   15431              :    Keep the size up to date in tree.h !  */
   15432              : const builtin_structptr_type builtin_structptr_types[6] =
   15433              : {
   15434              :   { fileptr_type_node, ptr_type_node, "FILE" },
   15435              :   { const_tm_ptr_type_node, const_ptr_type_node, "tm" },
   15436              :   { fenv_t_ptr_type_node, ptr_type_node, "fenv_t" },
   15437              :   { const_fenv_t_ptr_type_node, const_ptr_type_node, "fenv_t" },
   15438              :   { fexcept_t_ptr_type_node, ptr_type_node, "fexcept_t" },
   15439              :   { const_fexcept_t_ptr_type_node, const_ptr_type_node, "fexcept_t" }
   15440              : };
   15441              : 
   15442              : /* Return the maximum object size.  */
   15443              : 
   15444              : tree
   15445      7611672 : max_object_size (void)
   15446              : {
   15447              :   /* To do: Make this a configurable parameter.  */
   15448      7611672 :   return TYPE_MAX_VALUE (ptrdiff_type_node);
   15449              : }
   15450              : 
   15451              : /* A wrapper around TARGET_VERIFY_TYPE_CONTEXT that makes the silent_p
   15452              :    parameter default to false and that weeds out error_mark_node.  */
   15453              : 
   15454              : bool
   15455    156733156 : verify_type_context (location_t loc, type_context_kind context,
   15456              :                      const_tree type, bool silent_p)
   15457              : {
   15458    156733156 :   if (type == error_mark_node)
   15459              :     return true;
   15460              : 
   15461    156733060 :   gcc_assert (TYPE_P (type));
   15462    156733060 :   return (!targetm.verify_type_context
   15463    156733060 :           || targetm.verify_type_context (loc, context, type, silent_p));
   15464              : }
   15465              : 
   15466              : /* Callback of walk_tree telling whether the current tree pointed by TP is the
   15467              :    one provided as DATA.  */
   15468              : 
   15469              : static tree
   15470         4739 : find_tree_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, void *data)
   15471              : {
   15472         4739 :   if (*tp == data)
   15473              :     return (tree) data;
   15474              :   else
   15475         4667 :     return NULL;
   15476              : }
   15477              : 
   15478              : /* Return whether SEARCH is a subtree of TOP.  */
   15479              : 
   15480              : bool
   15481         3863 : find_tree (tree top, tree search)
   15482              : {
   15483         3863 :   return walk_tree_without_duplicates (&top, find_tree_1, search) != 0;
   15484              : }
   15485              : 
   15486              : /* Return true if NEW_ASM and DELETE_ASM name a valid pair of new and
   15487              :    delete operators.  Return false if they may or may not name such
   15488              :    a pair and, when nonnull, set *PCERTAIN to true if they certainly
   15489              :    do not.  */
   15490              : 
   15491              : bool
   15492        67364 : valid_new_delete_pair_p (tree new_asm, tree delete_asm,
   15493              :                          bool *pcertain /* = NULL */)
   15494              : {
   15495        67364 :   bool certain;
   15496        67364 :   if (!pcertain)
   15497        54816 :     pcertain = &certain;
   15498              : 
   15499        67364 :   const char *new_name = IDENTIFIER_POINTER (new_asm);
   15500        67364 :   const char *delete_name = IDENTIFIER_POINTER (delete_asm);
   15501        67364 :   unsigned int new_len = IDENTIFIER_LENGTH (new_asm);
   15502        67364 :   unsigned int delete_len = IDENTIFIER_LENGTH (delete_asm);
   15503              : 
   15504              :   /* The following failures are due to invalid names so they're not
   15505              :      considered certain mismatches.  */
   15506        67364 :   *pcertain = false;
   15507              : 
   15508        67364 :   if (new_len < 5 || delete_len < 6)
   15509              :     return false;
   15510        67364 :   if (new_name[0] == '_')
   15511        67292 :     ++new_name, --new_len;
   15512        67364 :   if (new_name[0] == '_')
   15513            0 :     ++new_name, --new_len;
   15514        67364 :   if (delete_name[0] == '_')
   15515        67364 :     ++delete_name, --delete_len;
   15516        67364 :   if (delete_name[0] == '_')
   15517            0 :     ++delete_name, --delete_len;
   15518        67364 :   if (new_len < 4 || delete_len < 5)
   15519              :     return false;
   15520              : 
   15521              :   /* The following failures are due to names of user-defined operators
   15522              :      so they're also not considered certain mismatches.  */
   15523              : 
   15524              :   /* *_len is now just the length after initial underscores.  */
   15525        67364 :   if (new_name[0] != 'Z' || new_name[1] != 'n')
   15526              :     return false;
   15527        66691 :   if (delete_name[0] != 'Z' || delete_name[1] != 'd')
   15528              :     return false;
   15529              : 
   15530              :   /* The following failures are certain mismatches.  */
   15531        66615 :   *pcertain = true;
   15532              : 
   15533              :   /* _Znw must match _Zdl, _Zna must match _Zda.  */
   15534        66615 :   if ((new_name[2] != 'w' || delete_name[2] != 'l')
   15535         5060 :       && (new_name[2] != 'a' || delete_name[2] != 'a'))
   15536              :     return false;
   15537        66519 :   if (new_name[3] == 'I' || delete_name[3] == 'I')
   15538              :     {
   15539              :       /* When ::operator new or ::operator delete are function templates,
   15540              :          return uncertain mismatch, we need demangler in that case.  */
   15541            6 :       *pcertain = false;
   15542            6 :       return false;
   15543              :     }
   15544              :   /* 'j', 'm' and 'y' correspond to size_t.  */
   15545        66513 :   if (new_name[3] != 'j' && new_name[3] != 'm' && new_name[3] != 'y')
   15546              :     return false;
   15547        66513 :   if (delete_name[3] != 'P' || delete_name[4] != 'v')
   15548              :     return false;
   15549        66513 :   if (new_len == 4
   15550          460 :       || (new_len == 18 && !memcmp (new_name + 4, "RKSt9nothrow_t", 14)))
   15551              :     {
   15552              :       /* _ZnXY or _ZnXYRKSt9nothrow_t matches
   15553              :          _ZdXPv, _ZdXPvY and _ZdXPvRKSt9nothrow_t.  */
   15554        66221 :       if (delete_len == 5)
   15555              :         return true;
   15556        59614 :       if (delete_len == 6 && delete_name[5] == new_name[3])
   15557              :         return true;
   15558           39 :       if (delete_len == 19 && !memcmp (delete_name + 5, "RKSt9nothrow_t", 14))
   15559              :         return true;
   15560              :     }
   15561          292 :   else if ((new_len == 19 && !memcmp (new_name + 4, "St11align_val_t", 15))
   15562           42 :            || (new_len == 33
   15563           10 :                && !memcmp (new_name + 4, "St11align_val_tRKSt9nothrow_t", 29)))
   15564              :     {
   15565              :       /* _ZnXYSt11align_val_t or _ZnXYSt11align_val_tRKSt9nothrow_t matches
   15566              :          _ZdXPvSt11align_val_t or _ZdXPvYSt11align_val_t or
   15567              :          _ZdXPvSt11align_val_tRKSt9nothrow_t.  */
   15568          260 :       if (delete_len == 20 && !memcmp (delete_name + 5, "St11align_val_t", 15))
   15569              :         return true;
   15570          144 :       if (delete_len == 21
   15571          129 :           && delete_name[5] == new_name[3]
   15572          129 :           && !memcmp (delete_name + 6, "St11align_val_t", 15))
   15573              :         return true;
   15574           15 :       if (delete_len == 34
   15575            9 :           && !memcmp (delete_name + 5, "St11align_val_tRKSt9nothrow_t", 29))
   15576              :         return true;
   15577              :     }
   15578              : 
   15579              :   /* The negative result is conservative.  */
   15580           38 :   *pcertain = false;
   15581           38 :   return false;
   15582              : }
   15583              : 
   15584              : /* Return the zero-based number corresponding to the argument being
   15585              :    deallocated if FNDECL is a deallocation function or an out-of-bounds
   15586              :    value if it isn't.  */
   15587              : 
   15588              : unsigned
   15589     23358545 : fndecl_dealloc_argno (tree fndecl)
   15590              : {
   15591              :   /* A call to operator delete isn't recognized as one to a built-in.  */
   15592     23358545 :   if (DECL_IS_OPERATOR_DELETE_P (fndecl))
   15593              :     {
   15594       357830 :       if (DECL_IS_REPLACEABLE_OPERATOR (fndecl))
   15595              :         return 0;
   15596              : 
   15597              :       /* Avoid placement delete that's not been inlined.  */
   15598        26789 :       tree fname = DECL_ASSEMBLER_NAME (fndecl);
   15599        26789 :       if (id_equal (fname, "_ZdlPvS_")       // ordinary form
   15600        26789 :           || id_equal (fname, "_ZdaPvS_"))   // array form
   15601        24161 :         return UINT_MAX;
   15602              :       return 0;
   15603              :     }
   15604              : 
   15605              :   /* TODO: Handle user-defined functions with attribute malloc?  Handle
   15606              :      known non-built-ins like fopen?  */
   15607     23000715 :   if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
   15608              :     {
   15609      5640500 :       switch (DECL_FUNCTION_CODE (fndecl))
   15610              :         {
   15611              :         case BUILT_IN_FREE:
   15612              :         case BUILT_IN_REALLOC:
   15613              :         case BUILT_IN_GOMP_FREE:
   15614              :         case BUILT_IN_GOMP_REALLOC:
   15615              :           return 0;
   15616      5414802 :         default:
   15617      5414802 :           break;
   15618              :         }
   15619      5414802 :       return UINT_MAX;
   15620              :     }
   15621              : 
   15622     17360215 :   tree attrs = DECL_ATTRIBUTES (fndecl);
   15623     17360215 :   if (!attrs)
   15624              :     return UINT_MAX;
   15625              : 
   15626            0 :   for (tree atfree = attrs;
   15627      4008334 :        (atfree = lookup_attribute ("*dealloc", atfree));
   15628            0 :        atfree = TREE_CHAIN (atfree))
   15629              :     {
   15630         4938 :       tree alloc = TREE_VALUE (atfree);
   15631         4938 :       if (!alloc)
   15632            0 :         continue;
   15633              : 
   15634         4938 :       tree pos = TREE_CHAIN (alloc);
   15635         4938 :       if (!pos)
   15636              :         return 0;
   15637              : 
   15638         2751 :       pos = TREE_VALUE (pos);
   15639         2751 :       return TREE_INT_CST_LOW (pos) - 1;
   15640              :     }
   15641              : 
   15642              :   return UINT_MAX;
   15643              : }
   15644              : 
   15645              : /* If EXPR refers to a character array or pointer declared attribute
   15646              :    nonstring, return a decl for that array or pointer and set *REF
   15647              :    to the referenced enclosing object or pointer.  Otherwise return
   15648              :    null.  */
   15649              : 
   15650              : tree
   15651      1400456 : get_attr_nonstring_decl (tree expr, tree *ref)
   15652              : {
   15653      1406158 :   tree decl = expr;
   15654      1406158 :   tree var = NULL_TREE;
   15655      1406158 :   if (TREE_CODE (decl) == SSA_NAME)
   15656              :     {
   15657       836285 :       gimple *def = SSA_NAME_DEF_STMT (decl);
   15658              : 
   15659       836285 :       if (is_gimple_assign (def))
   15660              :         {
   15661        44459 :           tree_code code = gimple_assign_rhs_code (def);
   15662        44459 :           if (code == ADDR_EXPR
   15663        44459 :               || code == COMPONENT_REF
   15664        29557 :               || code == VAR_DECL)
   15665        19421 :             decl = gimple_assign_rhs1 (def);
   15666              :         }
   15667              :       else
   15668       791826 :         var = SSA_NAME_VAR (decl);
   15669              :     }
   15670              : 
   15671      1406158 :   if (TREE_CODE (decl) == ADDR_EXPR)
   15672        25994 :     decl = TREE_OPERAND (decl, 0);
   15673              : 
   15674              :   /* To simplify calling code, store the referenced DECL regardless of
   15675              :      the attribute determined below, but avoid storing the SSA_NAME_VAR
   15676              :      obtained above (it's not useful for dataflow purposes).  */
   15677      1406158 :   if (ref)
   15678         5463 :     *ref = decl;
   15679              : 
   15680              :   /* Use the SSA_NAME_VAR that was determined above to see if it's
   15681              :      declared nonstring.  Otherwise drill down into the referenced
   15682              :      DECL.  */
   15683      1406158 :   if (var)
   15684              :     decl = var;
   15685              :   else
   15686              :     {
   15687       639323 :       while (TREE_CODE (decl) == ARRAY_REF)
   15688        18661 :         decl = TREE_OPERAND (decl, 0);
   15689       620662 :       if (TREE_CODE (decl) == COMPONENT_REF)
   15690        16751 :         decl = TREE_OPERAND (decl, 1);
   15691       603911 :       else if (TREE_CODE (decl) == MEM_REF)
   15692         5702 :         return get_attr_nonstring_decl (TREE_OPERAND (decl, 0), ref);
   15693              :     }
   15694              : 
   15695      1400456 :   if (DECL_P (decl) && lookup_attribute ("nonstring", DECL_ATTRIBUTES (decl)))
   15696         7921 :     return decl;
   15697              : 
   15698              :   return NULL_TREE;
   15699              : }
   15700              : 
   15701              : /* Returns an auto_vec of string_slices containing the version strings from
   15702              :    ARGLIST.  DEFAULT_COUNT is incremented for each default version found.
   15703              :    If FILTER is true then any invalid versions strings are not included.  */
   15704              : 
   15705              : auto_vec<string_slice>
   15706          212 : get_clone_attr_versions (const tree arglist,
   15707              :                          int *default_count,
   15708              :                          bool filter)
   15709              : {
   15710          212 :   gcc_assert (TREE_CODE (arglist) == TREE_LIST);
   15711          212 :   auto_vec<string_slice> versions;
   15712              : 
   15713          212 :   static const char separator_str[] = {TARGET_CLONES_ATTR_SEPARATOR, 0};
   15714          212 :   string_slice separators = string_slice (separator_str);
   15715              : 
   15716          776 :   for (tree arg = arglist; arg; arg = TREE_CHAIN (arg))
   15717              :     {
   15718          564 :       string_slice str = string_slice (TREE_STRING_POINTER (TREE_VALUE (arg)));
   15719         1720 :       while (str.is_valid ())
   15720              :         {
   15721          592 :           string_slice attr = string_slice::tokenize (&str, separators);
   15722          592 :           attr = attr.strip ();
   15723              : 
   15724          592 :           if (filter && !targetm.check_target_clone_version (attr, NULL))
   15725            0 :             continue;
   15726              : 
   15727          592 :           if (attr == "default" && default_count)
   15728          210 :             (*default_count)++;
   15729          592 :           versions.safe_push (attr);
   15730              :         }
   15731              :     }
   15732          212 :   return versions;
   15733              : }
   15734              : 
   15735              : /* Returns an auto_vec of string_slices containing the version strings from
   15736              :    the target_clone attribute from DECL.  DEFAULT_COUNT is incremented for each
   15737              :    default version found.  If FILTER is true then any invalid versions strings
   15738              :    are not included.  */
   15739              : auto_vec<string_slice>
   15740           99 : get_clone_versions (const tree decl, int *default_count, bool filter)
   15741              : {
   15742           99 :   tree attr = lookup_attribute ("target_clones", DECL_ATTRIBUTES (decl));
   15743           99 :   if (!attr)
   15744            0 :     return auto_vec<string_slice> ();
   15745           99 :   tree arglist = TREE_VALUE (attr);
   15746           99 :   return get_clone_attr_versions (arglist, default_count, filter);
   15747              : }
   15748              : 
   15749              : /* If DECL has a target_version attribute, returns a string_slice containing the
   15750              :    attribute value.  Otherwise, returns string_slice::invalid.
   15751              :    Only works for target_version due to target attributes allowing multiple
   15752              :    string arguments to specify one target.  */
   15753              : string_slice
   15754            0 : get_target_version (const tree decl)
   15755              : {
   15756            0 :   gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE);
   15757              : 
   15758              :   tree attr = lookup_attribute ("target_version", DECL_ATTRIBUTES (decl));
   15759              : 
   15760              :   if (!attr)
   15761              :     return string_slice::invalid ();
   15762              : 
   15763              :   return string_slice (TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))))
   15764              :            .strip ();
   15765              : }
   15766              : 
   15767              : /* Returns true if FN1 and FN2 define disjoint function versions in an FMV
   15768              :    function set.  That is, the two declarations are completely non-overlapping.
   15769              :    For target_version semantics, that means if one is a target clone and one is
   15770              :    a target version, the target_version must not be defined by the target_clone,
   15771              :    and for two target_clones, they must not define any of the same version.
   15772              : 
   15773              :    FN1 and FN2 should be function decls.  */
   15774              : 
   15775              : bool
   15776     31229035 : disjoint_version_decls (tree fn1, tree fn2)
   15777              : {
   15778     31229035 :   if (TREE_CODE (fn1) != FUNCTION_DECL
   15779     31227805 :       || TREE_CODE (fn2) != FUNCTION_DECL)
   15780              :     return false;
   15781              : 
   15782     28961105 :   if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
   15783              :     {
   15784     28961105 :       tree attr1 = lookup_attribute ("target", DECL_ATTRIBUTES (fn1));
   15785     28961105 :       tree attr2 = lookup_attribute ("target", DECL_ATTRIBUTES (fn2));
   15786              : 
   15787              :       /* At least one function decl should have the target attribute
   15788              :          specified.  */
   15789     28961105 :       if (attr1 == NULL_TREE && attr2 == NULL_TREE)
   15790              :         return false;
   15791              : 
   15792              :       /* Diagnose missing target attribute if one of the decls is already
   15793              :          multi-versioned.  */
   15794        18867 :       if (attr1 == NULL_TREE || attr2 == NULL_TREE)
   15795              :         {
   15796          363 :           if (DECL_FUNCTION_VERSIONED (fn1) || DECL_FUNCTION_VERSIONED (fn2))
   15797              :             {
   15798          114 :               if (attr2 != NULL_TREE)
   15799              :                 {
   15800          114 :                   std::swap (fn1, fn2);
   15801          114 :                   attr1 = attr2;
   15802              :                 }
   15803          114 :               auto_diagnostic_group d;
   15804          114 :               error_at (DECL_SOURCE_LOCATION (fn2),
   15805              :                         "missing %<target%> attribute for multi-versioned %qD",
   15806              :                         fn2);
   15807          114 :               inform (DECL_SOURCE_LOCATION (fn1),
   15808              :                       "previous declaration of %qD", fn1);
   15809              :               /* Prevent diagnosing of the same error multiple times.  */
   15810          114 :               DECL_ATTRIBUTES (fn2)
   15811          228 :                 = tree_cons (get_identifier ("target"),
   15812          114 :                              copy_node (TREE_VALUE (attr1)),
   15813          114 :                              DECL_ATTRIBUTES (fn2));
   15814          114 :             }
   15815              :           return false;
   15816              :         }
   15817              : 
   15818        18504 :       char *target1 = sorted_attr_string (TREE_VALUE (attr1));
   15819        18504 :       char *target2 = sorted_attr_string (TREE_VALUE (attr2));
   15820              : 
   15821              :       /* The sorted target strings must be different for fn1 and fn2
   15822              :          to be versions.  */
   15823        18504 :       bool result = strcmp (target1, target2) != 0;
   15824              : 
   15825        18504 :       XDELETEVEC (target1);
   15826        18504 :       XDELETEVEC (target2);
   15827              : 
   15828        18504 :       return result;
   15829              :     }
   15830              :   else
   15831              :     {
   15832              :       /* As this is symmetric, can remove the case where fn2 is target clone
   15833              :          and fn1 is target version by swapping here.  */
   15834              :       if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn2)))
   15835              :         std::swap (fn1, fn2);
   15836              : 
   15837              :       if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn1)))
   15838              :         {
   15839              :           auto_vec<string_slice> fn1_versions = get_clone_versions (fn1);
   15840              :           /* fn1 is target_clone.  */
   15841              :           if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn2)))
   15842              :             {
   15843              :               /* Both are target_clone.  */
   15844              :               auto_vec<string_slice> fn2_versions = get_clone_versions (fn2);
   15845              :               for (string_slice v1 : fn1_versions)
   15846              :                 {
   15847              :                   for (string_slice v2 : fn2_versions)
   15848              :                     if (targetm.target_option.same_function_versions
   15849              :                           (v1, NULL_TREE, v2, NULL_TREE))
   15850              :                       return false;
   15851              :                 }
   15852              :               return true;
   15853              :             }
   15854              :           else
   15855              :             {
   15856              :               string_slice v2 = get_target_version (fn2);
   15857              : 
   15858              :               /* target and target_clones is always conflicting for target
   15859              :                  semantics.  */
   15860              :               if (TARGET_HAS_FMV_TARGET_ATTRIBUTE)
   15861              :                 return false;
   15862              : 
   15863              :               /* Only fn1 is target clone.  */
   15864              :               if (!v2.is_valid ())
   15865              :                 v2 = "default";
   15866              :               for (string_slice v1 : fn1_versions)
   15867              :                 if (targetm.target_option.same_function_versions
   15868              :                       (v1, NULL_TREE, v2, NULL_TREE))
   15869              :                   return false;
   15870              :               return true;
   15871              :             }
   15872              :         }
   15873              :       else
   15874              :         {
   15875              :           /* Both are target_version.  */
   15876              :           string_slice v1 = get_target_version (fn1);
   15877              :           string_slice v2 = get_target_version (fn2);
   15878              : 
   15879              :           if (!v1.is_valid () && !v2.is_valid ())
   15880              :             return false;
   15881              : 
   15882              :           if (!v1.is_valid ())
   15883              :             v1 = "default";
   15884              :           if (!v2.is_valid ())
   15885              :             v2 = "default";
   15886              : 
   15887              :           if (targetm.target_option.same_function_versions (v1, NULL_TREE,
   15888              :                                                             v2, NULL_TREE))
   15889              :             return false;
   15890              : 
   15891              :           return true;
   15892              :         }
   15893              :     }
   15894              : }
   15895              : 
   15896              : /* Check if the target_version/target_clones attributes are mergeable
   15897              :    for two decls, and if so returns false.
   15898              :    If they aren't mergeable, diagnose this and return true.
   15899              :    Only works for target_version semantics.  */
   15900              : bool
   15901            0 : diagnose_versioned_decls (tree old_decl, tree new_decl)
   15902              : {
   15903            0 :   gcc_assert (!TARGET_HAS_FMV_TARGET_ATTRIBUTE);
   15904              : 
   15905              :   string_slice old_target_attr = get_target_version (old_decl);
   15906              :   string_slice new_target_attr = get_target_version (new_decl);
   15907              : 
   15908              :   tree old_target_clones_attr = lookup_attribute ("target_clones",
   15909              :                                                   DECL_ATTRIBUTES (old_decl));
   15910              :   tree new_target_clones_attr = lookup_attribute ("target_clones",
   15911              :                                                   DECL_ATTRIBUTES (new_decl));
   15912              : 
   15913              :   /* If none of these are annotated, then it is mergeable.  */
   15914              :   if (!old_target_attr.is_valid ()
   15915              :       && !old_target_attr.is_valid ()
   15916              :       && !old_target_clones_attr
   15917              :       && !new_target_clones_attr)
   15918              :     return false;
   15919              : 
   15920              :   /* If fn1 is unnanotated and fn2 contains default, then is mergeable.  */
   15921              :   if (!old_target_attr.is_valid ()
   15922              :       && !old_target_clones_attr
   15923              :       && is_function_default_version (new_decl))
   15924              :     return false;
   15925              : 
   15926              :   /* If fn2 is unnanotated and fn1 contains default, then is mergeable.  */
   15927              :   if (!new_target_attr.is_valid ()
   15928              :       && !new_target_clones_attr
   15929              :       && is_function_default_version (old_decl))
   15930              :     return false;
   15931              : 
   15932              :   /* In the case where both are annotated with target_clones, only mergeable if
   15933              :      the two sets of target_clones imply the same set of versions.  */
   15934              :   if (old_target_clones_attr && new_target_clones_attr)
   15935              :     {
   15936              :       auto_vec<string_slice> old_versions = get_clone_versions (old_decl);
   15937              :       auto_vec<string_slice> new_versions = get_clone_versions (new_decl);
   15938              : 
   15939              :       bool mergeable = true;
   15940              : 
   15941              :       if (old_versions.length () != new_versions.length ())
   15942              :         mergeable = false;
   15943              : 
   15944              :       /* Check both inclusion directions.  */
   15945              :       for (auto oldv: old_versions)
   15946              :         {
   15947              :           bool matched = false;
   15948              :           for (auto newv: new_versions)
   15949              :             if (targetm.target_option.same_function_versions (oldv, old_decl,
   15950              :                                                               newv, new_decl))
   15951              :               matched = true;
   15952              :           if (!matched)
   15953              :             mergeable = false;
   15954              :         }
   15955              : 
   15956              :       for (auto newv: new_versions)
   15957              :         {
   15958              :           bool matched = false;
   15959              :           for (auto oldv: old_versions)
   15960              :             if (targetm.target_option.same_function_versions (oldv, old_decl,
   15961              :                                                               newv, new_decl))
   15962              :               matched = true;
   15963              :           if (!matched)
   15964              :             mergeable = false;
   15965              :         }
   15966              : 
   15967              :       if (!mergeable)
   15968              :         {
   15969              :           error_at (DECL_SOURCE_LOCATION (new_decl),
   15970              :                     "%qD conflicts with overlapping %<target_clone%> "
   15971              :                     "declaration",
   15972              :                     new_decl);
   15973              :           inform (DECL_SOURCE_LOCATION (old_decl),
   15974              :                   "previous declaration of %qD", old_decl);
   15975              :           return true;
   15976              :         }
   15977              : 
   15978              :       return false;
   15979              :     }
   15980              : 
   15981              :   /* If olddecl is target clones and newdecl is a target_version.
   15982              :      As they are not distinct this implies newdecl redefines a version of
   15983              :      olddecl.  Not mergeable.  */
   15984              :   if (new_target_clones_attr)
   15985              :     {
   15986              :       gcc_assert (old_target_attr.is_valid ());
   15987              : 
   15988              :       error_at (DECL_SOURCE_LOCATION (new_decl),
   15989              :                 "%qD conflicts for version %qB",
   15990              :                 new_decl, &old_target_attr);
   15991              :       inform (DECL_SOURCE_LOCATION (old_decl),
   15992              :               "previous declaration of %qD",
   15993              :               old_decl);
   15994              :       return true;
   15995              :     }
   15996              : 
   15997              :   if (old_target_clones_attr)
   15998              :     {
   15999              :       gcc_assert (new_target_attr.is_valid ());
   16000              : 
   16001              :       error_at (DECL_SOURCE_LOCATION (new_decl),
   16002              :                 "%qD conflicts with a previous declaration for version %qB",
   16003              :                 new_decl, &new_target_attr);
   16004              :       inform (DECL_SOURCE_LOCATION (old_decl),
   16005              :               "previous declaration of %qD",
   16006              :               old_decl);
   16007              :       return true;
   16008              :     }
   16009              : 
   16010              :   /* The only remaining case is two target_version annotated decls.  */
   16011              :   return !targetm.target_option.same_function_versions
   16012              :             (old_target_attr, old_decl, new_target_attr, new_decl);
   16013              : }
   16014              : 
   16015              : 
   16016              : /* This page contains routines to unshare tree nodes, i.e. to duplicate tree
   16017              :    nodes that are referenced more than once in GENERIC functions.  This is
   16018              :    necessary because gimplification (translation into GIMPLE) is performed
   16019              :    by modifying tree nodes in-place, so gimplification of a shared node in a
   16020              :    first context could generate an invalid GIMPLE form in a second context.
   16021              : 
   16022              :    This is achieved with a simple mark/copy/unmark algorithm that walks the
   16023              :    GENERIC representation top-down, marks nodes with TREE_VISITED the first
   16024              :    time it encounters them, duplicates them if they already have TREE_VISITED
   16025              :    set, and finally removes the TREE_VISITED marks it has set.
   16026              : 
   16027              :    The algorithm works only at the function level, i.e. it generates a GENERIC
   16028              :    representation of a function with no nodes shared within the function when
   16029              :    passed a GENERIC function (except for nodes that are allowed to be shared).
   16030              : 
   16031              :    At the global level, it is also necessary to unshare tree nodes that are
   16032              :    referenced in more than one function, for the same aforementioned reason.
   16033              :    This requires some cooperation from the front-end.  There are 2 strategies:
   16034              : 
   16035              :      1. Manual unsharing.  The front-end needs to call unshare_expr on every
   16036              :         expression that might end up being shared across functions.
   16037              : 
   16038              :      2. Deep unsharing.  This is an extension of regular unsharing.  Instead
   16039              :         of calling unshare_expr on expressions that might be shared across
   16040              :         functions, the front-end pre-marks them with TREE_VISITED.  This will
   16041              :         ensure that they are unshared on the first reference within functions
   16042              :         when the regular unsharing algorithm runs.  The counterpart is that
   16043              :         this algorithm must look deeper than for manual unsharing, which is
   16044              :         specified by LANG_HOOKS_DEEP_UNSHARING.
   16045              : 
   16046              :   If there are only few specific cases of node sharing across functions, it is
   16047              :   probably easier for a front-end to unshare the expressions manually.  On the
   16048              :   contrary, if the expressions generated at the global level are as widespread
   16049              :   as expressions generated within functions, deep unsharing is very likely the
   16050              :   way to go.  */
   16051              : 
   16052              : /* Similar to copy_tree_r but do not copy SAVE_EXPR or TARGET_EXPR nodes.
   16053              :    These nodes model computations that must be done once.  If we were to
   16054              :    unshare something like SAVE_EXPR(i++), the gimplification process would
   16055              :    create wrong code.  However, if DATA is non-null, it must hold a pointer
   16056              :    set that is used to unshare the subtrees of these nodes.  */
   16057              : 
   16058              : static tree
   16059   2840536359 : mostly_copy_tree_r (tree *tp, int *walk_subtrees, void *data)
   16060              : {
   16061   2840536359 :   tree t = *tp;
   16062   2840536359 :   enum tree_code code = TREE_CODE (t);
   16063              : 
   16064              :   /* Do not copy SAVE_EXPR, TARGET_EXPR or BIND_EXPR nodes themselves, but
   16065              :      copy their subtrees if we can make sure to do it only once.  */
   16066   2840536359 :   if (code == SAVE_EXPR || code == TARGET_EXPR || code == BIND_EXPR)
   16067              :     {
   16068     11718993 :       if (data && !((hash_set<tree> *)data)->add (t))
   16069              :         ;
   16070              :       else
   16071     11718993 :         *walk_subtrees = 0;
   16072              :     }
   16073              : 
   16074              :   /* Stop at types, decls, constants like copy_tree_r.  */
   16075   2828817366 :   else if (TREE_CODE_CLASS (code) == tcc_type
   16076              :            || TREE_CODE_CLASS (code) == tcc_declaration
   16077   2828817366 :            || TREE_CODE_CLASS (code) == tcc_constant)
   16078   1750521452 :     *walk_subtrees = 0;
   16079              : 
   16080              :   /* Cope with the statement expression extension.  */
   16081   1078295914 :   else if (code == STATEMENT_LIST)
   16082              :     ;
   16083              : 
   16084              :   /* Leave the bulk of the work to copy_tree_r itself.  */
   16085              :   else
   16086   1078246270 :     copy_tree_r (tp, walk_subtrees, NULL);
   16087              : 
   16088   2840536359 :   return NULL_TREE;
   16089              : }
   16090              : 
   16091              : /* Callback for walk_tree to unshare most of the shared trees rooted at *TP.
   16092              :    If *TP has been visited already, then *TP is deeply copied by calling
   16093              :    mostly_copy_tree_r.  DATA is passed to mostly_copy_tree_r unmodified.  */
   16094              : 
   16095              : static tree
   16096    286979588 : copy_if_shared_r (tree *tp, int *walk_subtrees, void *data)
   16097              : {
   16098    286979588 :   tree t = *tp;
   16099    286979588 :   enum tree_code code = TREE_CODE (t);
   16100              : 
   16101              :   /* Skip types, decls, and constants.  But we do want to look at their
   16102              :      types and the bounds of types.  Mark them as visited so we properly
   16103              :      unmark their subtrees on the unmark pass.  If we've already seen them,
   16104              :      don't look down further.  */
   16105    286979588 :   if (TREE_CODE_CLASS (code) == tcc_type
   16106              :       || TREE_CODE_CLASS (code) == tcc_declaration
   16107    286979588 :       || TREE_CODE_CLASS (code) == tcc_constant)
   16108              :     {
   16109    136364451 :       if (TREE_VISITED (t))
   16110     83428372 :         *walk_subtrees = 0;
   16111              :       else
   16112     52936079 :         TREE_VISITED (t) = 1;
   16113              :     }
   16114              : 
   16115              :   /* If this node has been visited already, unshare it and don't look
   16116              :      any deeper.  */
   16117    150615137 :   else if (TREE_VISITED (t))
   16118              :     {
   16119      1780610 :       walk_tree (tp, mostly_copy_tree_r, data, NULL);
   16120      1780610 :       *walk_subtrees = 0;
   16121              :     }
   16122              : 
   16123              :   /* Otherwise, mark the node as visited and keep looking.  */
   16124              :   else
   16125    148834527 :     TREE_VISITED (t) = 1;
   16126              : 
   16127    286979588 :   return NULL_TREE;
   16128              : }
   16129              : 
   16130              : /* Unshare most of the shared trees rooted at *TP.  DATA is passed to the
   16131              :    copy_if_shared_r callback unmodified.  */
   16132              : 
   16133              : void
   16134      9157305 : copy_if_shared (tree *tp, void *data)
   16135              : {
   16136      9157305 :   walk_tree (tp, copy_if_shared_r, data, NULL);
   16137      9157305 : }
   16138              : 
   16139              : /* Unconditionally make an unshared copy of EXPR.  This is used when using
   16140              :    stored expressions which span multiple functions, such as BINFO_VTABLE,
   16141              :    as the normal unsharing process can't tell that they're shared.  */
   16142              : 
   16143              : tree
   16144   1585719936 : unshare_expr (tree expr)
   16145              : {
   16146   1585719936 :   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
   16147   1585719936 :   return expr;
   16148              : }
   16149              : 
   16150              : /* Worker for unshare_expr_without_location.  */
   16151              : 
   16152              : static tree
   16153     15548397 : prune_expr_location (tree *tp, int *walk_subtrees, void *)
   16154              : {
   16155     15548397 :   if (EXPR_P (*tp))
   16156      7796881 :     SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION);
   16157              :   else
   16158      7751516 :     *walk_subtrees = 0;
   16159     15548397 :   return NULL_TREE;
   16160              : }
   16161              : 
   16162              : /* Similar to unshare_expr but also prune all expression locations
   16163              :    from EXPR.  */
   16164              : 
   16165              : tree
   16166     24730834 : unshare_expr_without_location (tree expr)
   16167              : {
   16168     24730834 :   walk_tree (&expr, mostly_copy_tree_r, NULL, NULL);
   16169     24730834 :   if (EXPR_P (expr))
   16170      5317306 :     walk_tree (&expr, prune_expr_location, NULL, NULL);
   16171     24730834 :   return expr;
   16172              : }
   16173              : 
   16174              : void
   16175       264541 : tree_cc_finalize (void)
   16176              : {
   16177       264541 :   clear_nonstandard_integer_type_cache ();
   16178       264541 :   vec_free (bitint_type_cache);
   16179       264541 : }
   16180              : 
   16181              : void
   16182          232 : gt_ggc_mx (tree_raw_data *x)
   16183              : {
   16184          232 :   gt_ggc_m_9tree_node (x->typed.type);
   16185          232 :   gt_ggc_m_9tree_node (x->owner);
   16186          232 : }
   16187              : 
   16188              : void
   16189           12 : gt_pch_nx (tree_raw_data *x)
   16190              : {
   16191           12 :   gt_pch_n_9tree_node (x->typed.type);
   16192           12 :   gt_pch_n_9tree_node (x->owner);
   16193           12 : }
   16194              : 
   16195              : /* For PCH we guarantee that RAW_DATA_CST's RAW_DATA_OWNER is a STRING_CST and
   16196              :    RAW_DATA_POINTER points into it.  We don't want to save/restore
   16197              :    RAW_DATA_POINTER on its own but want to restore it pointing at the same
   16198              :    offset of the STRING_CST as before.  */
   16199              : 
   16200              : void
   16201           12 : gt_pch_nx (tree_raw_data *x, gt_pointer_operator op, void *cookie)
   16202              : {
   16203           12 :   op (&x->typed.type, NULL, cookie);
   16204           12 :   gcc_checking_assert (x->owner
   16205              :                        && TREE_CODE (x->owner) == STRING_CST
   16206              :                        && x->str >= TREE_STRING_POINTER (x->owner)
   16207              :                        && (x->str + x->length
   16208              :                            <= (TREE_STRING_POINTER (x->owner)
   16209              :                                + TREE_STRING_LENGTH (x->owner))));
   16210           12 :   ptrdiff_t off = x->str - (const char *) (x->owner);
   16211           12 :   tree owner = x->owner;
   16212           12 :   op (&x->owner, NULL, cookie);
   16213           12 :   x->owner = owner;
   16214              :   /* The above op call relocates x->owner and remembers the address
   16215              :      for relocation e.g. if the compiler is position independent.
   16216              :      We then restore x->owner back to its previous value and call
   16217              :      op again, for x->owner itself this just repeats (uselessly) what
   16218              :      the first call did, but as the second argument is now non-NULL
   16219              :      and different, it also arranges for &x->str to be noted for the
   16220              :      PIE relocation.  */
   16221           12 :   op (&x->owner, &x->str, cookie);
   16222           12 :   x->str = (const char *) (x->owner) + off;
   16223           12 : }
   16224              : 
   16225              : #if CHECKING_P
   16226              : 
   16227              : namespace selftest {
   16228              : 
   16229              : /* Selftests for tree.  */
   16230              : 
   16231              : /* Verify that integer constants are sane.  */
   16232              : 
   16233              : static void
   16234            4 : test_integer_constants ()
   16235              : {
   16236            4 :   ASSERT_TRUE (integer_type_node != NULL);
   16237            4 :   ASSERT_TRUE (build_int_cst (integer_type_node, 0) != NULL);
   16238              : 
   16239            4 :   tree type = integer_type_node;
   16240              : 
   16241            4 :   tree zero = build_zero_cst (type);
   16242            4 :   ASSERT_EQ (INTEGER_CST, TREE_CODE (zero));
   16243            4 :   ASSERT_EQ (type, TREE_TYPE (zero));
   16244              : 
   16245            4 :   tree one = build_int_cst (type, 1);
   16246            4 :   ASSERT_EQ (INTEGER_CST, TREE_CODE (one));
   16247            4 :   ASSERT_EQ (type, TREE_TYPE (zero));
   16248            4 : }
   16249              : 
   16250              : /* Verify identifiers.  */
   16251              : 
   16252              : static void
   16253            4 : test_identifiers ()
   16254              : {
   16255            4 :   tree identifier = get_identifier ("foo");
   16256            4 :   ASSERT_EQ (3, IDENTIFIER_LENGTH (identifier));
   16257            4 :   ASSERT_STREQ ("foo", IDENTIFIER_POINTER (identifier));
   16258            4 : }
   16259              : 
   16260              : /* Verify LABEL_DECL.  */
   16261              : 
   16262              : static void
   16263            4 : test_labels ()
   16264              : {
   16265            4 :   tree identifier = get_identifier ("err");
   16266            4 :   tree label_decl = build_decl (UNKNOWN_LOCATION, LABEL_DECL,
   16267              :                                 identifier, void_type_node);
   16268            4 :   ASSERT_EQ (-1, LABEL_DECL_UID (label_decl));
   16269            4 :   ASSERT_FALSE (FORCED_LABEL (label_decl));
   16270            4 : }
   16271              : 
   16272              : /* Return a new VECTOR_CST node whose type is TYPE and whose values
   16273              :    are given by VALS.  */
   16274              : 
   16275              : static tree
   16276           40 : build_vector (tree type, const vec<tree> &vals MEM_STAT_DECL)
   16277              : {
   16278           80 :   gcc_assert (known_eq (vals.length (), TYPE_VECTOR_SUBPARTS (type)));
   16279           40 :   tree_vector_builder builder (type, vals.length (), 1);
   16280           40 :   builder.splice (vals);
   16281           40 :   return builder.build ();
   16282           40 : }
   16283              : 
   16284              : /* Check that VECTOR_CST ACTUAL contains the elements in EXPECTED.  */
   16285              : 
   16286              : static void
   16287           40 : check_vector_cst (const vec<tree> &expected, tree actual)
   16288              : {
   16289           80 :   ASSERT_KNOWN_EQ (expected.length (),
   16290              :                    TYPE_VECTOR_SUBPARTS (TREE_TYPE (actual)));
   16291          360 :   for (unsigned int i = 0; i < expected.length (); ++i)
   16292          320 :     ASSERT_EQ (wi::to_wide (expected[i]),
   16293              :                wi::to_wide (vector_cst_elt (actual, i)));
   16294           40 : }
   16295              : 
   16296              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS duplicated elements,
   16297              :    and that its elements match EXPECTED.  */
   16298              : 
   16299              : static void
   16300            8 : check_vector_cst_duplicate (const vec<tree> &expected, tree actual,
   16301              :                             unsigned int npatterns)
   16302              : {
   16303            8 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16304            8 :   ASSERT_EQ (1, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16305            8 :   ASSERT_EQ (npatterns, vector_cst_encoded_nelts (actual));
   16306            8 :   ASSERT_TRUE (VECTOR_CST_DUPLICATE_P (actual));
   16307            8 :   ASSERT_FALSE (VECTOR_CST_STEPPED_P (actual));
   16308            8 :   check_vector_cst (expected, actual);
   16309            8 : }
   16310              : 
   16311              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS foreground elements
   16312              :    and NPATTERNS background elements, and that its elements match
   16313              :    EXPECTED.  */
   16314              : 
   16315              : static void
   16316            8 : check_vector_cst_fill (const vec<tree> &expected, tree actual,
   16317              :                        unsigned int npatterns)
   16318              : {
   16319            8 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16320            8 :   ASSERT_EQ (2, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16321            8 :   ASSERT_EQ (2 * npatterns, vector_cst_encoded_nelts (actual));
   16322            8 :   ASSERT_FALSE (VECTOR_CST_DUPLICATE_P (actual));
   16323            8 :   ASSERT_FALSE (VECTOR_CST_STEPPED_P (actual));
   16324            8 :   check_vector_cst (expected, actual);
   16325            8 : }
   16326              : 
   16327              : /* Check that VECTOR_CST ACTUAL contains NPATTERNS stepped patterns,
   16328              :    and that its elements match EXPECTED.  */
   16329              : 
   16330              : static void
   16331           24 : check_vector_cst_stepped (const vec<tree> &expected, tree actual,
   16332              :                           unsigned int npatterns)
   16333              : {
   16334           24 :   ASSERT_EQ (npatterns, VECTOR_CST_NPATTERNS (actual));
   16335           24 :   ASSERT_EQ (3, VECTOR_CST_NELTS_PER_PATTERN (actual));
   16336           24 :   ASSERT_EQ (3 * npatterns, vector_cst_encoded_nelts (actual));
   16337           24 :   ASSERT_FALSE (VECTOR_CST_DUPLICATE_P (actual));
   16338           24 :   ASSERT_TRUE (VECTOR_CST_STEPPED_P (actual));
   16339           24 :   check_vector_cst (expected, actual);
   16340           24 : }
   16341              : 
   16342              : /* Test the creation of VECTOR_CSTs.  */
   16343              : 
   16344              : static void
   16345            4 : test_vector_cst_patterns (ALONE_CXX_MEM_STAT_INFO)
   16346              : {
   16347            4 :   auto_vec<tree, 8> elements (8);
   16348            4 :   elements.quick_grow (8);
   16349            4 :   tree element_type = build_nonstandard_integer_type (16, true);
   16350            4 :   tree vector_type = build_vector_type (element_type, 8);
   16351              : 
   16352              :   /* Test a simple linear series with a base of 0 and a step of 1:
   16353              :      { 0, 1, 2, 3, 4, 5, 6, 7 }.  */
   16354           36 :   for (unsigned int i = 0; i < 8; ++i)
   16355           32 :     elements[i] = build_int_cst (element_type, i);
   16356            4 :   tree vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16357            4 :   check_vector_cst_stepped (elements, vector, 1);
   16358              : 
   16359              :   /* Try the same with the first element replaced by 100:
   16360              :      { 100, 1, 2, 3, 4, 5, 6, 7 }.  */
   16361            4 :   elements[0] = build_int_cst (element_type, 100);
   16362            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16363            4 :   check_vector_cst_stepped (elements, vector, 1);
   16364              : 
   16365              :   /* Try a series that wraps around.
   16366              :      { 100, 65531, 65532, 65533, 65534, 65535, 0, 1 }.  */
   16367           36 :   for (unsigned int i = 1; i < 8; ++i)
   16368           28 :     elements[i] = build_int_cst (element_type, (65530 + i) & 0xffff);
   16369            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16370            4 :   check_vector_cst_stepped (elements, vector, 1);
   16371              : 
   16372              :   /* Try a downward series:
   16373              :      { 100, 79, 78, 77, 76, 75, 75, 73 }.  */
   16374           36 :   for (unsigned int i = 1; i < 8; ++i)
   16375           28 :     elements[i] = build_int_cst (element_type, 80 - i);
   16376            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16377            4 :   check_vector_cst_stepped (elements, vector, 1);
   16378              : 
   16379              :   /* Try two interleaved series with different bases and steps:
   16380              :      { 100, 53, 66, 206, 62, 212, 58, 218 }.  */
   16381            4 :   elements[1] = build_int_cst (element_type, 53);
   16382           16 :   for (unsigned int i = 2; i < 8; i += 2)
   16383              :     {
   16384           12 :       elements[i] = build_int_cst (element_type, 70 - i * 2);
   16385           12 :       elements[i + 1] = build_int_cst (element_type, 200 + i * 3);
   16386              :     }
   16387            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16388            4 :   check_vector_cst_stepped (elements, vector, 2);
   16389              : 
   16390              :   /* Try a duplicated value:
   16391              :      { 100, 100, 100, 100, 100, 100, 100, 100 }.  */
   16392           36 :   for (unsigned int i = 1; i < 8; ++i)
   16393           28 :     elements[i] = elements[0];
   16394            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16395            4 :   check_vector_cst_duplicate (elements, vector, 1);
   16396              : 
   16397              :   /* Try an interleaved duplicated value:
   16398              :      { 100, 55, 100, 55, 100, 55, 100, 55 }.  */
   16399            4 :   elements[1] = build_int_cst (element_type, 55);
   16400           28 :   for (unsigned int i = 2; i < 8; ++i)
   16401           24 :     elements[i] = elements[i - 2];
   16402            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16403            4 :   check_vector_cst_duplicate (elements, vector, 2);
   16404              : 
   16405              :   /* Try a duplicated value with 2 exceptions
   16406              :      { 41, 97, 100, 55, 100, 55, 100, 55 }.  */
   16407            4 :   elements[0] = build_int_cst (element_type, 41);
   16408            4 :   elements[1] = build_int_cst (element_type, 97);
   16409            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16410            4 :   check_vector_cst_fill (elements, vector, 2);
   16411              : 
   16412              :   /* Try with and without a step
   16413              :      { 41, 97, 100, 21, 100, 35, 100, 49 }.  */
   16414           20 :   for (unsigned int i = 3; i < 8; i += 2)
   16415           12 :     elements[i] = build_int_cst (element_type, i * 7);
   16416            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16417            4 :   check_vector_cst_stepped (elements, vector, 2);
   16418              : 
   16419              :   /* Try a fully-general constant:
   16420              :      { 41, 97, 100, 21, 100, 9990, 100, 49 }.  */
   16421            4 :   elements[5] = build_int_cst (element_type, 9990);
   16422            4 :   vector = build_vector (vector_type, elements PASS_MEM_STAT);
   16423            4 :   check_vector_cst_fill (elements, vector, 4);
   16424            4 : }
   16425              : 
   16426              : /* Verify that STRIP_NOPS (NODE) is EXPECTED.
   16427              :    Helper function for test_location_wrappers, to deal with STRIP_NOPS
   16428              :    modifying its argument in-place.  */
   16429              : 
   16430              : static void
   16431           12 : check_strip_nops (tree node, tree expected)
   16432              : {
   16433           12 :   STRIP_NOPS (node);
   16434           12 :   ASSERT_EQ (expected, node);
   16435           12 : }
   16436              : 
   16437              : /* Verify location wrappers.  */
   16438              : 
   16439              : static void
   16440            4 : test_location_wrappers ()
   16441              : {
   16442            4 :   location_t loc = BUILTINS_LOCATION;
   16443              : 
   16444            4 :   ASSERT_EQ (NULL_TREE, maybe_wrap_with_location (NULL_TREE, loc));
   16445              : 
   16446              :   /* Wrapping a constant.  */
   16447            4 :   tree int_cst = build_int_cst (integer_type_node, 42);
   16448            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_cst));
   16449            4 :   ASSERT_FALSE (location_wrapper_p (int_cst));
   16450              : 
   16451            4 :   tree wrapped_int_cst = maybe_wrap_with_location (int_cst, loc);
   16452            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_cst));
   16453            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_cst));
   16454            4 :   ASSERT_EQ (int_cst, tree_strip_any_location_wrapper (wrapped_int_cst));
   16455              : 
   16456              :   /* We shouldn't add wrapper nodes for UNKNOWN_LOCATION.  */
   16457            4 :   ASSERT_EQ (int_cst, maybe_wrap_with_location (int_cst, UNKNOWN_LOCATION));
   16458              : 
   16459              :   /* We shouldn't add wrapper nodes for nodes that CAN_HAVE_LOCATION_P.  */
   16460            4 :   tree cast = build1 (NOP_EXPR, char_type_node, int_cst);
   16461            4 :   ASSERT_TRUE (CAN_HAVE_LOCATION_P (cast));
   16462            4 :   ASSERT_EQ (cast, maybe_wrap_with_location (cast, loc));
   16463              : 
   16464              :   /* Wrapping a STRING_CST.  */
   16465            4 :   tree string_cst = build_string (4, "foo");
   16466            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (string_cst));
   16467            4 :   ASSERT_FALSE (location_wrapper_p (string_cst));
   16468              : 
   16469            4 :   tree wrapped_string_cst = maybe_wrap_with_location (string_cst, loc);
   16470            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_string_cst));
   16471            4 :   ASSERT_EQ (VIEW_CONVERT_EXPR, TREE_CODE (wrapped_string_cst));
   16472            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_string_cst));
   16473            4 :   ASSERT_EQ (string_cst, tree_strip_any_location_wrapper (wrapped_string_cst));
   16474              : 
   16475              : 
   16476              :   /* Wrapping a variable.  */
   16477            4 :   tree int_var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   16478              :                              get_identifier ("some_int_var"),
   16479              :                              integer_type_node);
   16480            4 :   ASSERT_FALSE (CAN_HAVE_LOCATION_P (int_var));
   16481            4 :   ASSERT_FALSE (location_wrapper_p (int_var));
   16482              : 
   16483            4 :   tree wrapped_int_var = maybe_wrap_with_location (int_var, loc);
   16484            4 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_var));
   16485            4 :   ASSERT_EQ (loc, EXPR_LOCATION (wrapped_int_var));
   16486            4 :   ASSERT_EQ (int_var, tree_strip_any_location_wrapper (wrapped_int_var));
   16487              : 
   16488              :   /* Verify that "reinterpret_cast<int>(some_int_var)" is not a location
   16489              :      wrapper.  */
   16490            4 :   tree r_cast = build1 (NON_LVALUE_EXPR, integer_type_node, int_var);
   16491            4 :   ASSERT_FALSE (location_wrapper_p (r_cast));
   16492            4 :   ASSERT_EQ (r_cast, tree_strip_any_location_wrapper (r_cast));
   16493              : 
   16494              :   /* Verify that STRIP_NOPS removes wrappers.  */
   16495            4 :   check_strip_nops (wrapped_int_cst, int_cst);
   16496            4 :   check_strip_nops (wrapped_string_cst, string_cst);
   16497            4 :   check_strip_nops (wrapped_int_var, int_var);
   16498            4 : }
   16499              : 
   16500              : /* Test various tree predicates.  Verify that location wrappers don't
   16501              :    affect the results.  */
   16502              : 
   16503              : static void
   16504            4 : test_predicates ()
   16505              : {
   16506              :   /* Build various constants and wrappers around them.  */
   16507              : 
   16508            4 :   location_t loc = BUILTINS_LOCATION;
   16509              : 
   16510            4 :   tree i_0 = build_int_cst (integer_type_node, 0);
   16511            4 :   tree wr_i_0 = maybe_wrap_with_location (i_0, loc);
   16512              : 
   16513            4 :   tree i_1 = build_int_cst (integer_type_node, 1);
   16514            4 :   tree wr_i_1 = maybe_wrap_with_location (i_1, loc);
   16515              : 
   16516            4 :   tree i_m1 = build_int_cst (integer_type_node, -1);
   16517            4 :   tree wr_i_m1 = maybe_wrap_with_location (i_m1, loc);
   16518              : 
   16519            4 :   tree f_0 = build_real_from_int_cst (float_type_node, i_0);
   16520            4 :   tree wr_f_0 = maybe_wrap_with_location (f_0, loc);
   16521            4 :   tree f_1 = build_real_from_int_cst (float_type_node, i_1);
   16522            4 :   tree wr_f_1 = maybe_wrap_with_location (f_1, loc);
   16523            4 :   tree f_m1 = build_real_from_int_cst (float_type_node, i_m1);
   16524            4 :   tree wr_f_m1 = maybe_wrap_with_location (f_m1, loc);
   16525              : 
   16526            4 :   tree c_i_0 = build_complex (NULL_TREE, i_0, i_0);
   16527            4 :   tree c_i_1 = build_complex (NULL_TREE, i_1, i_0);
   16528            4 :   tree c_i_m1 = build_complex (NULL_TREE, i_m1, i_0);
   16529              : 
   16530            4 :   tree c_f_0 = build_complex (NULL_TREE, f_0, f_0);
   16531            4 :   tree c_f_1 = build_complex (NULL_TREE, f_1, f_0);
   16532            4 :   tree c_f_m1 = build_complex (NULL_TREE, f_m1, f_0);
   16533              : 
   16534              :   /* TODO: vector constants.  */
   16535              : 
   16536              :   /* Test integer_onep.  */
   16537            4 :   ASSERT_FALSE (integer_onep (i_0));
   16538            4 :   ASSERT_FALSE (integer_onep (wr_i_0));
   16539            4 :   ASSERT_TRUE (integer_onep (i_1));
   16540            4 :   ASSERT_TRUE (integer_onep (wr_i_1));
   16541            4 :   ASSERT_FALSE (integer_onep (i_m1));
   16542            4 :   ASSERT_FALSE (integer_onep (wr_i_m1));
   16543            4 :   ASSERT_FALSE (integer_onep (f_0));
   16544            4 :   ASSERT_FALSE (integer_onep (wr_f_0));
   16545            4 :   ASSERT_FALSE (integer_onep (f_1));
   16546            4 :   ASSERT_FALSE (integer_onep (wr_f_1));
   16547            4 :   ASSERT_FALSE (integer_onep (f_m1));
   16548            4 :   ASSERT_FALSE (integer_onep (wr_f_m1));
   16549            4 :   ASSERT_FALSE (integer_onep (c_i_0));
   16550            4 :   ASSERT_TRUE (integer_onep (c_i_1));
   16551            4 :   ASSERT_FALSE (integer_onep (c_i_m1));
   16552            4 :   ASSERT_FALSE (integer_onep (c_f_0));
   16553            4 :   ASSERT_FALSE (integer_onep (c_f_1));
   16554            4 :   ASSERT_FALSE (integer_onep (c_f_m1));
   16555              : 
   16556              :   /* Test integer_zerop.  */
   16557            4 :   ASSERT_TRUE (integer_zerop (i_0));
   16558            4 :   ASSERT_TRUE (integer_zerop (wr_i_0));
   16559            4 :   ASSERT_FALSE (integer_zerop (i_1));
   16560            4 :   ASSERT_FALSE (integer_zerop (wr_i_1));
   16561            4 :   ASSERT_FALSE (integer_zerop (i_m1));
   16562            4 :   ASSERT_FALSE (integer_zerop (wr_i_m1));
   16563            4 :   ASSERT_FALSE (integer_zerop (f_0));
   16564            4 :   ASSERT_FALSE (integer_zerop (wr_f_0));
   16565            4 :   ASSERT_FALSE (integer_zerop (f_1));
   16566            4 :   ASSERT_FALSE (integer_zerop (wr_f_1));
   16567            4 :   ASSERT_FALSE (integer_zerop (f_m1));
   16568            4 :   ASSERT_FALSE (integer_zerop (wr_f_m1));
   16569            4 :   ASSERT_TRUE (integer_zerop (c_i_0));
   16570            4 :   ASSERT_FALSE (integer_zerop (c_i_1));
   16571            4 :   ASSERT_FALSE (integer_zerop (c_i_m1));
   16572            4 :   ASSERT_FALSE (integer_zerop (c_f_0));
   16573            4 :   ASSERT_FALSE (integer_zerop (c_f_1));
   16574            4 :   ASSERT_FALSE (integer_zerop (c_f_m1));
   16575              : 
   16576              :   /* Test integer_all_onesp.  */
   16577            4 :   ASSERT_FALSE (integer_all_onesp (i_0));
   16578            4 :   ASSERT_FALSE (integer_all_onesp (wr_i_0));
   16579            4 :   ASSERT_FALSE (integer_all_onesp (i_1));
   16580            4 :   ASSERT_FALSE (integer_all_onesp (wr_i_1));
   16581            4 :   ASSERT_TRUE (integer_all_onesp (i_m1));
   16582            4 :   ASSERT_TRUE (integer_all_onesp (wr_i_m1));
   16583            4 :   ASSERT_FALSE (integer_all_onesp (f_0));
   16584            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_0));
   16585            4 :   ASSERT_FALSE (integer_all_onesp (f_1));
   16586            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_1));
   16587            4 :   ASSERT_FALSE (integer_all_onesp (f_m1));
   16588            4 :   ASSERT_FALSE (integer_all_onesp (wr_f_m1));
   16589            4 :   ASSERT_FALSE (integer_all_onesp (c_i_0));
   16590            4 :   ASSERT_FALSE (integer_all_onesp (c_i_1));
   16591            4 :   ASSERT_FALSE (integer_all_onesp (c_i_m1));
   16592            4 :   ASSERT_FALSE (integer_all_onesp (c_f_0));
   16593            4 :   ASSERT_FALSE (integer_all_onesp (c_f_1));
   16594            4 :   ASSERT_FALSE (integer_all_onesp (c_f_m1));
   16595              : 
   16596              :   /* Test integer_minus_onep.  */
   16597            4 :   ASSERT_FALSE (integer_minus_onep (i_0));
   16598            4 :   ASSERT_FALSE (integer_minus_onep (wr_i_0));
   16599            4 :   ASSERT_FALSE (integer_minus_onep (i_1));
   16600            4 :   ASSERT_FALSE (integer_minus_onep (wr_i_1));
   16601            4 :   ASSERT_TRUE (integer_minus_onep (i_m1));
   16602            4 :   ASSERT_TRUE (integer_minus_onep (wr_i_m1));
   16603            4 :   ASSERT_FALSE (integer_minus_onep (f_0));
   16604            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_0));
   16605            4 :   ASSERT_FALSE (integer_minus_onep (f_1));
   16606            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_1));
   16607            4 :   ASSERT_FALSE (integer_minus_onep (f_m1));
   16608            4 :   ASSERT_FALSE (integer_minus_onep (wr_f_m1));
   16609            4 :   ASSERT_FALSE (integer_minus_onep (c_i_0));
   16610            4 :   ASSERT_FALSE (integer_minus_onep (c_i_1));
   16611            4 :   ASSERT_TRUE (integer_minus_onep (c_i_m1));
   16612            4 :   ASSERT_FALSE (integer_minus_onep (c_f_0));
   16613            4 :   ASSERT_FALSE (integer_minus_onep (c_f_1));
   16614            4 :   ASSERT_FALSE (integer_minus_onep (c_f_m1));
   16615              : 
   16616              :   /* Test integer_each_onep.  */
   16617            4 :   ASSERT_FALSE (integer_each_onep (i_0));
   16618            4 :   ASSERT_FALSE (integer_each_onep (wr_i_0));
   16619            4 :   ASSERT_TRUE (integer_each_onep (i_1));
   16620            4 :   ASSERT_TRUE (integer_each_onep (wr_i_1));
   16621            4 :   ASSERT_FALSE (integer_each_onep (i_m1));
   16622            4 :   ASSERT_FALSE (integer_each_onep (wr_i_m1));
   16623            4 :   ASSERT_FALSE (integer_each_onep (f_0));
   16624            4 :   ASSERT_FALSE (integer_each_onep (wr_f_0));
   16625            4 :   ASSERT_FALSE (integer_each_onep (f_1));
   16626            4 :   ASSERT_FALSE (integer_each_onep (wr_f_1));
   16627            4 :   ASSERT_FALSE (integer_each_onep (f_m1));
   16628            4 :   ASSERT_FALSE (integer_each_onep (wr_f_m1));
   16629            4 :   ASSERT_FALSE (integer_each_onep (c_i_0));
   16630            4 :   ASSERT_FALSE (integer_each_onep (c_i_1));
   16631            4 :   ASSERT_FALSE (integer_each_onep (c_i_m1));
   16632            4 :   ASSERT_FALSE (integer_each_onep (c_f_0));
   16633            4 :   ASSERT_FALSE (integer_each_onep (c_f_1));
   16634            4 :   ASSERT_FALSE (integer_each_onep (c_f_m1));
   16635              : 
   16636              :   /* Test integer_truep.  */
   16637            4 :   ASSERT_FALSE (integer_truep (i_0));
   16638            4 :   ASSERT_FALSE (integer_truep (wr_i_0));
   16639            4 :   ASSERT_TRUE (integer_truep (i_1));
   16640            4 :   ASSERT_TRUE (integer_truep (wr_i_1));
   16641            4 :   ASSERT_FALSE (integer_truep (i_m1));
   16642            4 :   ASSERT_FALSE (integer_truep (wr_i_m1));
   16643            4 :   ASSERT_FALSE (integer_truep (f_0));
   16644            4 :   ASSERT_FALSE (integer_truep (wr_f_0));
   16645            4 :   ASSERT_FALSE (integer_truep (f_1));
   16646            4 :   ASSERT_FALSE (integer_truep (wr_f_1));
   16647            4 :   ASSERT_FALSE (integer_truep (f_m1));
   16648            4 :   ASSERT_FALSE (integer_truep (wr_f_m1));
   16649            4 :   ASSERT_FALSE (integer_truep (c_i_0));
   16650            4 :   ASSERT_TRUE (integer_truep (c_i_1));
   16651            4 :   ASSERT_FALSE (integer_truep (c_i_m1));
   16652            4 :   ASSERT_FALSE (integer_truep (c_f_0));
   16653            4 :   ASSERT_FALSE (integer_truep (c_f_1));
   16654            4 :   ASSERT_FALSE (integer_truep (c_f_m1));
   16655              : 
   16656              :   /* Test integer_nonzerop.  */
   16657            4 :   ASSERT_FALSE (integer_nonzerop (i_0));
   16658            4 :   ASSERT_FALSE (integer_nonzerop (wr_i_0));
   16659            4 :   ASSERT_TRUE (integer_nonzerop (i_1));
   16660            4 :   ASSERT_TRUE (integer_nonzerop (wr_i_1));
   16661            4 :   ASSERT_TRUE (integer_nonzerop (i_m1));
   16662            4 :   ASSERT_TRUE (integer_nonzerop (wr_i_m1));
   16663            4 :   ASSERT_FALSE (integer_nonzerop (f_0));
   16664            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_0));
   16665            4 :   ASSERT_FALSE (integer_nonzerop (f_1));
   16666            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_1));
   16667            4 :   ASSERT_FALSE (integer_nonzerop (f_m1));
   16668            4 :   ASSERT_FALSE (integer_nonzerop (wr_f_m1));
   16669            4 :   ASSERT_FALSE (integer_nonzerop (c_i_0));
   16670            4 :   ASSERT_TRUE (integer_nonzerop (c_i_1));
   16671            4 :   ASSERT_TRUE (integer_nonzerop (c_i_m1));
   16672            4 :   ASSERT_FALSE (integer_nonzerop (c_f_0));
   16673            4 :   ASSERT_FALSE (integer_nonzerop (c_f_1));
   16674            4 :   ASSERT_FALSE (integer_nonzerop (c_f_m1));
   16675              : 
   16676              :   /* Test real_zerop.  */
   16677            4 :   ASSERT_FALSE (real_zerop (i_0));
   16678            4 :   ASSERT_FALSE (real_zerop (wr_i_0));
   16679            4 :   ASSERT_FALSE (real_zerop (i_1));
   16680            4 :   ASSERT_FALSE (real_zerop (wr_i_1));
   16681            4 :   ASSERT_FALSE (real_zerop (i_m1));
   16682            4 :   ASSERT_FALSE (real_zerop (wr_i_m1));
   16683            4 :   ASSERT_TRUE (real_zerop (f_0));
   16684            4 :   ASSERT_TRUE (real_zerop (wr_f_0));
   16685            4 :   ASSERT_FALSE (real_zerop (f_1));
   16686            4 :   ASSERT_FALSE (real_zerop (wr_f_1));
   16687            4 :   ASSERT_FALSE (real_zerop (f_m1));
   16688            4 :   ASSERT_FALSE (real_zerop (wr_f_m1));
   16689            4 :   ASSERT_FALSE (real_zerop (c_i_0));
   16690            4 :   ASSERT_FALSE (real_zerop (c_i_1));
   16691            4 :   ASSERT_FALSE (real_zerop (c_i_m1));
   16692            4 :   ASSERT_TRUE (real_zerop (c_f_0));
   16693            4 :   ASSERT_FALSE (real_zerop (c_f_1));
   16694            4 :   ASSERT_FALSE (real_zerop (c_f_m1));
   16695              : 
   16696              :   /* Test real_onep.  */
   16697            4 :   ASSERT_FALSE (real_onep (i_0));
   16698            4 :   ASSERT_FALSE (real_onep (wr_i_0));
   16699            4 :   ASSERT_FALSE (real_onep (i_1));
   16700            4 :   ASSERT_FALSE (real_onep (wr_i_1));
   16701            4 :   ASSERT_FALSE (real_onep (i_m1));
   16702            4 :   ASSERT_FALSE (real_onep (wr_i_m1));
   16703            4 :   ASSERT_FALSE (real_onep (f_0));
   16704            4 :   ASSERT_FALSE (real_onep (wr_f_0));
   16705            4 :   ASSERT_TRUE (real_onep (f_1));
   16706            4 :   ASSERT_TRUE (real_onep (wr_f_1));
   16707            4 :   ASSERT_FALSE (real_onep (f_m1));
   16708            4 :   ASSERT_FALSE (real_onep (wr_f_m1));
   16709            4 :   ASSERT_FALSE (real_onep (c_i_0));
   16710            4 :   ASSERT_FALSE (real_onep (c_i_1));
   16711            4 :   ASSERT_FALSE (real_onep (c_i_m1));
   16712            4 :   ASSERT_FALSE (real_onep (c_f_0));
   16713            4 :   ASSERT_TRUE (real_onep (c_f_1));
   16714            4 :   ASSERT_FALSE (real_onep (c_f_m1));
   16715              : 
   16716              :   /* Test real_minus_onep.  */
   16717            4 :   ASSERT_FALSE (real_minus_onep (i_0));
   16718            4 :   ASSERT_FALSE (real_minus_onep (wr_i_0));
   16719            4 :   ASSERT_FALSE (real_minus_onep (i_1));
   16720            4 :   ASSERT_FALSE (real_minus_onep (wr_i_1));
   16721            4 :   ASSERT_FALSE (real_minus_onep (i_m1));
   16722            4 :   ASSERT_FALSE (real_minus_onep (wr_i_m1));
   16723            4 :   ASSERT_FALSE (real_minus_onep (f_0));
   16724            4 :   ASSERT_FALSE (real_minus_onep (wr_f_0));
   16725            4 :   ASSERT_FALSE (real_minus_onep (f_1));
   16726            4 :   ASSERT_FALSE (real_minus_onep (wr_f_1));
   16727            4 :   ASSERT_TRUE (real_minus_onep (f_m1));
   16728            4 :   ASSERT_TRUE (real_minus_onep (wr_f_m1));
   16729            4 :   ASSERT_FALSE (real_minus_onep (c_i_0));
   16730            4 :   ASSERT_FALSE (real_minus_onep (c_i_1));
   16731            4 :   ASSERT_FALSE (real_minus_onep (c_i_m1));
   16732            4 :   ASSERT_FALSE (real_minus_onep (c_f_0));
   16733            4 :   ASSERT_FALSE (real_minus_onep (c_f_1));
   16734            4 :   ASSERT_TRUE (real_minus_onep (c_f_m1));
   16735              : 
   16736              :   /* Test zerop.  */
   16737            4 :   ASSERT_TRUE (zerop (i_0));
   16738            4 :   ASSERT_TRUE (zerop (wr_i_0));
   16739            4 :   ASSERT_FALSE (zerop (i_1));
   16740            4 :   ASSERT_FALSE (zerop (wr_i_1));
   16741            4 :   ASSERT_FALSE (zerop (i_m1));
   16742            4 :   ASSERT_FALSE (zerop (wr_i_m1));
   16743            4 :   ASSERT_TRUE (zerop (f_0));
   16744            4 :   ASSERT_TRUE (zerop (wr_f_0));
   16745            4 :   ASSERT_FALSE (zerop (f_1));
   16746            4 :   ASSERT_FALSE (zerop (wr_f_1));
   16747            4 :   ASSERT_FALSE (zerop (f_m1));
   16748            4 :   ASSERT_FALSE (zerop (wr_f_m1));
   16749            4 :   ASSERT_TRUE (zerop (c_i_0));
   16750            4 :   ASSERT_FALSE (zerop (c_i_1));
   16751            4 :   ASSERT_FALSE (zerop (c_i_m1));
   16752            4 :   ASSERT_TRUE (zerop (c_f_0));
   16753            4 :   ASSERT_FALSE (zerop (c_f_1));
   16754            4 :   ASSERT_FALSE (zerop (c_f_m1));
   16755              : 
   16756              :   /* Test tree_expr_nonnegative_p.  */
   16757            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (i_0));
   16758            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_i_0));
   16759            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (i_1));
   16760            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_i_1));
   16761            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (i_m1));
   16762            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (wr_i_m1));
   16763            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (f_0));
   16764            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_f_0));
   16765            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (f_1));
   16766            4 :   ASSERT_TRUE (tree_expr_nonnegative_p (wr_f_1));
   16767            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (f_m1));
   16768            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (wr_f_m1));
   16769            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_0));
   16770            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_1));
   16771            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_i_m1));
   16772            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_0));
   16773            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_1));
   16774            4 :   ASSERT_FALSE (tree_expr_nonnegative_p (c_f_m1));
   16775              : 
   16776              :   /* Test tree_expr_nonzero_p.  */
   16777            4 :   ASSERT_FALSE (tree_expr_nonzero_p (i_0));
   16778            4 :   ASSERT_FALSE (tree_expr_nonzero_p (wr_i_0));
   16779            4 :   ASSERT_TRUE (tree_expr_nonzero_p (i_1));
   16780            4 :   ASSERT_TRUE (tree_expr_nonzero_p (wr_i_1));
   16781            4 :   ASSERT_TRUE (tree_expr_nonzero_p (i_m1));
   16782            4 :   ASSERT_TRUE (tree_expr_nonzero_p (wr_i_m1));
   16783              : 
   16784              :   /* Test integer_valued_real_p.  */
   16785            4 :   ASSERT_FALSE (integer_valued_real_p (i_0));
   16786            4 :   ASSERT_TRUE (integer_valued_real_p (f_0));
   16787            4 :   ASSERT_TRUE (integer_valued_real_p (wr_f_0));
   16788            4 :   ASSERT_TRUE (integer_valued_real_p (f_1));
   16789            4 :   ASSERT_TRUE (integer_valued_real_p (wr_f_1));
   16790              : 
   16791              :   /* Test integer_pow2p.  */
   16792            4 :   ASSERT_FALSE (integer_pow2p (i_0));
   16793            4 :   ASSERT_TRUE (integer_pow2p (i_1));
   16794            4 :   ASSERT_TRUE (integer_pow2p (wr_i_1));
   16795              : 
   16796              :   /* Test uniform_integer_cst_p.  */
   16797            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_0));
   16798            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_0));
   16799            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_1));
   16800            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_1));
   16801            4 :   ASSERT_TRUE (uniform_integer_cst_p (i_m1));
   16802            4 :   ASSERT_TRUE (uniform_integer_cst_p (wr_i_m1));
   16803            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_0));
   16804            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_0));
   16805            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_1));
   16806            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_1));
   16807            4 :   ASSERT_FALSE (uniform_integer_cst_p (f_m1));
   16808            4 :   ASSERT_FALSE (uniform_integer_cst_p (wr_f_m1));
   16809            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_0));
   16810            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_1));
   16811            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_i_m1));
   16812            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_0));
   16813            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_1));
   16814            4 :   ASSERT_FALSE (uniform_integer_cst_p (c_f_m1));
   16815            4 : }
   16816              : 
   16817              : /* Check that string escaping works correctly.  */
   16818              : 
   16819              : static void
   16820            4 : test_escaped_strings (void)
   16821              : {
   16822            4 :   int saved_cutoff;
   16823            4 :   escaped_string msg;
   16824              : 
   16825            4 :   msg.escape (NULL);
   16826              :   /* ASSERT_STREQ does not accept NULL as a valid test
   16827              :      result, so we have to use ASSERT_EQ instead.  */
   16828            4 :   ASSERT_EQ (NULL, (const char *) msg);
   16829              : 
   16830            4 :   msg.escape ("");
   16831            4 :   ASSERT_STREQ ("", (const char *) msg);
   16832              : 
   16833            4 :   msg.escape ("foobar");
   16834            4 :   ASSERT_STREQ ("foobar", (const char *) msg);
   16835              : 
   16836              :   /* Ensure that we have -fmessage-length set to 0.  */
   16837            4 :   pretty_printer *pp = global_dc->get_reference_printer ();
   16838            4 :   saved_cutoff = pp_line_cutoff (pp);
   16839            4 :   pp_line_cutoff (pp) = 0;
   16840              : 
   16841            4 :   msg.escape ("foo\nbar");
   16842            4 :   ASSERT_STREQ ("foo\\nbar", (const char *) msg);
   16843              : 
   16844            4 :   msg.escape ("\a\b\f\n\r\t\v");
   16845            4 :   ASSERT_STREQ ("\\a\\b\\f\\n\\r\\t\\v", (const char *) msg);
   16846              : 
   16847              :   /* Now repeat the tests with -fmessage-length set to 5.  */
   16848            4 :   pp_line_cutoff (pp) = 5;
   16849              : 
   16850              :   /* Note that the newline is not translated into an escape.  */
   16851            4 :   msg.escape ("foo\nbar");
   16852            4 :   ASSERT_STREQ ("foo\nbar", (const char *) msg);
   16853              : 
   16854            4 :   msg.escape ("\a\b\f\n\r\t\v");
   16855            4 :   ASSERT_STREQ ("\\a\\b\\f\n\\r\\t\\v", (const char *) msg);
   16856              : 
   16857              :   /* Restore the original message length setting.  */
   16858            4 :   pp_line_cutoff (pp) = saved_cutoff;
   16859            4 : }
   16860              : 
   16861              : /* Run all of the selftests within this file.  */
   16862              : 
   16863              : void
   16864            4 : tree_cc_tests ()
   16865              : {
   16866            4 :   test_integer_constants ();
   16867            4 :   test_identifiers ();
   16868            4 :   test_labels ();
   16869            4 :   test_vector_cst_patterns ();
   16870            4 :   test_location_wrappers ();
   16871            4 :   test_predicates ();
   16872            4 :   test_escaped_strings ();
   16873            4 : }
   16874              : 
   16875              : } // namespace selftest
   16876              : 
   16877              : #endif /* CHECKING_P */
   16878              : 
   16879              : #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.